pdf.combined.js 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/ // The require function
  29. /******/ function __w_pdfjs_require__(moduleId) {
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId])
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __w_pdfjs_require__.m = modules;
  48. /******/ // expose the module cache
  49. /******/ __w_pdfjs_require__.c = installedModules;
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  52. /******/ // define getter function for harmony exports
  53. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  54. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/ // getDefaultExport function for compatibility with non-harmony modules
  63. /******/ __w_pdfjs_require__.n = function(module) {
  64. /******/ var getter = module && module.__esModule ?
  65. /******/ function getDefault() { return module['default']; } :
  66. /******/ function getModuleExports() { return module; };
  67. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  68. /******/ return getter;
  69. /******/ };
  70. /******/ // Object.prototype.hasOwnProperty.call
  71. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  72. /******/ // __webpack_public_path__
  73. /******/ __w_pdfjs_require__.p = "";
  74. /******/ // Load entry module and return exports
  75. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 48);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var compatibility = __w_pdfjs_require__(47);
  84. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  85. var FONT_IDENTITY_MATRIX = [
  86. 0.001,
  87. 0,
  88. 0,
  89. 0.001,
  90. 0,
  91. 0
  92. ];
  93. var TextRenderingMode = {
  94. FILL: 0,
  95. STROKE: 1,
  96. FILL_STROKE: 2,
  97. INVISIBLE: 3,
  98. FILL_ADD_TO_PATH: 4,
  99. STROKE_ADD_TO_PATH: 5,
  100. FILL_STROKE_ADD_TO_PATH: 6,
  101. ADD_TO_PATH: 7,
  102. FILL_STROKE_MASK: 3,
  103. ADD_TO_PATH_FLAG: 4
  104. };
  105. var ImageKind = {
  106. GRAYSCALE_1BPP: 1,
  107. RGB_24BPP: 2,
  108. RGBA_32BPP: 3
  109. };
  110. var AnnotationType = {
  111. TEXT: 1,
  112. LINK: 2,
  113. FREETEXT: 3,
  114. LINE: 4,
  115. SQUARE: 5,
  116. CIRCLE: 6,
  117. POLYGON: 7,
  118. POLYLINE: 8,
  119. HIGHLIGHT: 9,
  120. UNDERLINE: 10,
  121. SQUIGGLY: 11,
  122. STRIKEOUT: 12,
  123. STAMP: 13,
  124. CARET: 14,
  125. INK: 15,
  126. POPUP: 16,
  127. FILEATTACHMENT: 17,
  128. SOUND: 18,
  129. MOVIE: 19,
  130. WIDGET: 20,
  131. SCREEN: 21,
  132. PRINTERMARK: 22,
  133. TRAPNET: 23,
  134. WATERMARK: 24,
  135. THREED: 25,
  136. REDACT: 26
  137. };
  138. var AnnotationFlag = {
  139. INVISIBLE: 0x01,
  140. HIDDEN: 0x02,
  141. PRINT: 0x04,
  142. NOZOOM: 0x08,
  143. NOROTATE: 0x10,
  144. NOVIEW: 0x20,
  145. READONLY: 0x40,
  146. LOCKED: 0x80,
  147. TOGGLENOVIEW: 0x100,
  148. LOCKEDCONTENTS: 0x200
  149. };
  150. var AnnotationFieldFlag = {
  151. READONLY: 0x0000001,
  152. REQUIRED: 0x0000002,
  153. NOEXPORT: 0x0000004,
  154. MULTILINE: 0x0001000,
  155. PASSWORD: 0x0002000,
  156. NOTOGGLETOOFF: 0x0004000,
  157. RADIO: 0x0008000,
  158. PUSHBUTTON: 0x0010000,
  159. COMBO: 0x0020000,
  160. EDIT: 0x0040000,
  161. SORT: 0x0080000,
  162. FILESELECT: 0x0100000,
  163. MULTISELECT: 0x0200000,
  164. DONOTSPELLCHECK: 0x0400000,
  165. DONOTSCROLL: 0x0800000,
  166. COMB: 0x1000000,
  167. RICHTEXT: 0x2000000,
  168. RADIOSINUNISON: 0x2000000,
  169. COMMITONSELCHANGE: 0x4000000
  170. };
  171. var AnnotationBorderStyleType = {
  172. SOLID: 1,
  173. DASHED: 2,
  174. BEVELED: 3,
  175. INSET: 4,
  176. UNDERLINE: 5
  177. };
  178. var StreamType = {
  179. UNKNOWN: 0,
  180. FLATE: 1,
  181. LZW: 2,
  182. DCT: 3,
  183. JPX: 4,
  184. JBIG: 5,
  185. A85: 6,
  186. AHX: 7,
  187. CCF: 8,
  188. RL: 9
  189. };
  190. var FontType = {
  191. UNKNOWN: 0,
  192. TYPE1: 1,
  193. TYPE1C: 2,
  194. CIDFONTTYPE0: 3,
  195. CIDFONTTYPE0C: 4,
  196. TRUETYPE: 5,
  197. CIDFONTTYPE2: 6,
  198. TYPE3: 7,
  199. OPENTYPE: 8,
  200. TYPE0: 9,
  201. MMTYPE1: 10
  202. };
  203. var VERBOSITY_LEVELS = {
  204. errors: 0,
  205. warnings: 1,
  206. infos: 5
  207. };
  208. var CMapCompressionType = {
  209. NONE: 0,
  210. BINARY: 1,
  211. STREAM: 2
  212. };
  213. var OPS = {
  214. dependency: 1,
  215. setLineWidth: 2,
  216. setLineCap: 3,
  217. setLineJoin: 4,
  218. setMiterLimit: 5,
  219. setDash: 6,
  220. setRenderingIntent: 7,
  221. setFlatness: 8,
  222. setGState: 9,
  223. save: 10,
  224. restore: 11,
  225. transform: 12,
  226. moveTo: 13,
  227. lineTo: 14,
  228. curveTo: 15,
  229. curveTo2: 16,
  230. curveTo3: 17,
  231. closePath: 18,
  232. rectangle: 19,
  233. stroke: 20,
  234. closeStroke: 21,
  235. fill: 22,
  236. eoFill: 23,
  237. fillStroke: 24,
  238. eoFillStroke: 25,
  239. closeFillStroke: 26,
  240. closeEOFillStroke: 27,
  241. endPath: 28,
  242. clip: 29,
  243. eoClip: 30,
  244. beginText: 31,
  245. endText: 32,
  246. setCharSpacing: 33,
  247. setWordSpacing: 34,
  248. setHScale: 35,
  249. setLeading: 36,
  250. setFont: 37,
  251. setTextRenderingMode: 38,
  252. setTextRise: 39,
  253. moveText: 40,
  254. setLeadingMoveText: 41,
  255. setTextMatrix: 42,
  256. nextLine: 43,
  257. showText: 44,
  258. showSpacedText: 45,
  259. nextLineShowText: 46,
  260. nextLineSetSpacingShowText: 47,
  261. setCharWidth: 48,
  262. setCharWidthAndBounds: 49,
  263. setStrokeColorSpace: 50,
  264. setFillColorSpace: 51,
  265. setStrokeColor: 52,
  266. setStrokeColorN: 53,
  267. setFillColor: 54,
  268. setFillColorN: 55,
  269. setStrokeGray: 56,
  270. setFillGray: 57,
  271. setStrokeRGBColor: 58,
  272. setFillRGBColor: 59,
  273. setStrokeCMYKColor: 60,
  274. setFillCMYKColor: 61,
  275. shadingFill: 62,
  276. beginInlineImage: 63,
  277. beginImageData: 64,
  278. endInlineImage: 65,
  279. paintXObject: 66,
  280. markPoint: 67,
  281. markPointProps: 68,
  282. beginMarkedContent: 69,
  283. beginMarkedContentProps: 70,
  284. endMarkedContent: 71,
  285. beginCompat: 72,
  286. endCompat: 73,
  287. paintFormXObjectBegin: 74,
  288. paintFormXObjectEnd: 75,
  289. beginGroup: 76,
  290. endGroup: 77,
  291. beginAnnotations: 78,
  292. endAnnotations: 79,
  293. beginAnnotation: 80,
  294. endAnnotation: 81,
  295. paintJpegXObject: 82,
  296. paintImageMaskXObject: 83,
  297. paintImageMaskXObjectGroup: 84,
  298. paintImageXObject: 85,
  299. paintInlineImageXObject: 86,
  300. paintInlineImageXObjectGroup: 87,
  301. paintImageXObjectRepeat: 88,
  302. paintImageMaskXObjectRepeat: 89,
  303. paintSolidColorImageMask: 90,
  304. constructPath: 91
  305. };
  306. var verbosity = VERBOSITY_LEVELS.warnings;
  307. function setVerbosityLevel(level) {
  308. verbosity = level;
  309. }
  310. function getVerbosityLevel() {
  311. return verbosity;
  312. }
  313. function info(msg) {
  314. if (verbosity >= VERBOSITY_LEVELS.infos) {
  315. console.log('Info: ' + msg);
  316. }
  317. }
  318. function warn(msg) {
  319. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  320. console.log('Warning: ' + msg);
  321. }
  322. }
  323. function deprecated(details) {
  324. console.log('Deprecated API usage: ' + details);
  325. }
  326. function error(msg) {
  327. if (verbosity >= VERBOSITY_LEVELS.errors) {
  328. console.log('Error: ' + msg);
  329. console.log(backtrace());
  330. }
  331. throw new Error(msg);
  332. }
  333. function backtrace() {
  334. try {
  335. throw new Error();
  336. } catch (e) {
  337. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  338. }
  339. }
  340. function assert(cond, msg) {
  341. if (!cond) {
  342. error(msg);
  343. }
  344. }
  345. var UNSUPPORTED_FEATURES = {
  346. unknown: 'unknown',
  347. forms: 'forms',
  348. javaScript: 'javaScript',
  349. smask: 'smask',
  350. shadingPattern: 'shadingPattern',
  351. font: 'font'
  352. };
  353. function isSameOrigin(baseUrl, otherUrl) {
  354. try {
  355. var base = new URL(baseUrl);
  356. if (!base.origin || base.origin === 'null') {
  357. return false;
  358. }
  359. } catch (e) {
  360. return false;
  361. }
  362. var other = new URL(otherUrl, base);
  363. return base.origin === other.origin;
  364. }
  365. function isValidProtocol(url) {
  366. if (!url) {
  367. return false;
  368. }
  369. switch (url.protocol) {
  370. case 'http:':
  371. case 'https:':
  372. case 'ftp:':
  373. case 'mailto:':
  374. case 'tel:':
  375. return true;
  376. default:
  377. return false;
  378. }
  379. }
  380. function createValidAbsoluteUrl(url, baseUrl) {
  381. if (!url) {
  382. return null;
  383. }
  384. try {
  385. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  386. if (isValidProtocol(absoluteUrl)) {
  387. return absoluteUrl;
  388. }
  389. } catch (ex) {
  390. }
  391. return null;
  392. }
  393. function shadow(obj, prop, value) {
  394. Object.defineProperty(obj, prop, {
  395. value: value,
  396. enumerable: true,
  397. configurable: true,
  398. writable: false
  399. });
  400. return value;
  401. }
  402. function getLookupTableFactory(initializer) {
  403. var lookup;
  404. return function () {
  405. if (initializer) {
  406. lookup = Object.create(null);
  407. initializer(lookup);
  408. initializer = null;
  409. }
  410. return lookup;
  411. };
  412. }
  413. var PasswordResponses = {
  414. NEED_PASSWORD: 1,
  415. INCORRECT_PASSWORD: 2
  416. };
  417. var PasswordException = function PasswordExceptionClosure() {
  418. function PasswordException(msg, code) {
  419. this.name = 'PasswordException';
  420. this.message = msg;
  421. this.code = code;
  422. }
  423. PasswordException.prototype = new Error();
  424. PasswordException.constructor = PasswordException;
  425. return PasswordException;
  426. }();
  427. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  428. function UnknownErrorException(msg, details) {
  429. this.name = 'UnknownErrorException';
  430. this.message = msg;
  431. this.details = details;
  432. }
  433. UnknownErrorException.prototype = new Error();
  434. UnknownErrorException.constructor = UnknownErrorException;
  435. return UnknownErrorException;
  436. }();
  437. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  438. function InvalidPDFException(msg) {
  439. this.name = 'InvalidPDFException';
  440. this.message = msg;
  441. }
  442. InvalidPDFException.prototype = new Error();
  443. InvalidPDFException.constructor = InvalidPDFException;
  444. return InvalidPDFException;
  445. }();
  446. var MissingPDFException = function MissingPDFExceptionClosure() {
  447. function MissingPDFException(msg) {
  448. this.name = 'MissingPDFException';
  449. this.message = msg;
  450. }
  451. MissingPDFException.prototype = new Error();
  452. MissingPDFException.constructor = MissingPDFException;
  453. return MissingPDFException;
  454. }();
  455. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  456. function UnexpectedResponseException(msg, status) {
  457. this.name = 'UnexpectedResponseException';
  458. this.message = msg;
  459. this.status = status;
  460. }
  461. UnexpectedResponseException.prototype = new Error();
  462. UnexpectedResponseException.constructor = UnexpectedResponseException;
  463. return UnexpectedResponseException;
  464. }();
  465. var NotImplementedException = function NotImplementedExceptionClosure() {
  466. function NotImplementedException(msg) {
  467. this.message = msg;
  468. }
  469. NotImplementedException.prototype = new Error();
  470. NotImplementedException.prototype.name = 'NotImplementedException';
  471. NotImplementedException.constructor = NotImplementedException;
  472. return NotImplementedException;
  473. }();
  474. var MissingDataException = function MissingDataExceptionClosure() {
  475. function MissingDataException(begin, end) {
  476. this.begin = begin;
  477. this.end = end;
  478. this.message = 'Missing data [' + begin + ', ' + end + ')';
  479. }
  480. MissingDataException.prototype = new Error();
  481. MissingDataException.prototype.name = 'MissingDataException';
  482. MissingDataException.constructor = MissingDataException;
  483. return MissingDataException;
  484. }();
  485. var XRefParseException = function XRefParseExceptionClosure() {
  486. function XRefParseException(msg) {
  487. this.message = msg;
  488. }
  489. XRefParseException.prototype = new Error();
  490. XRefParseException.prototype.name = 'XRefParseException';
  491. XRefParseException.constructor = XRefParseException;
  492. return XRefParseException;
  493. }();
  494. var NullCharactersRegExp = /\x00/g;
  495. function removeNullCharacters(str) {
  496. if (typeof str !== 'string') {
  497. warn('The argument for removeNullCharacters must be a string.');
  498. return str;
  499. }
  500. return str.replace(NullCharactersRegExp, '');
  501. }
  502. function bytesToString(bytes) {
  503. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  504. var length = bytes.length;
  505. var MAX_ARGUMENT_COUNT = 8192;
  506. if (length < MAX_ARGUMENT_COUNT) {
  507. return String.fromCharCode.apply(null, bytes);
  508. }
  509. var strBuf = [];
  510. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  511. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  512. var chunk = bytes.subarray(i, chunkEnd);
  513. strBuf.push(String.fromCharCode.apply(null, chunk));
  514. }
  515. return strBuf.join('');
  516. }
  517. function stringToBytes(str) {
  518. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  519. var length = str.length;
  520. var bytes = new Uint8Array(length);
  521. for (var i = 0; i < length; ++i) {
  522. bytes[i] = str.charCodeAt(i) & 0xFF;
  523. }
  524. return bytes;
  525. }
  526. function arrayByteLength(arr) {
  527. if (arr.length !== undefined) {
  528. return arr.length;
  529. }
  530. assert(arr.byteLength !== undefined);
  531. return arr.byteLength;
  532. }
  533. function arraysToBytes(arr) {
  534. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  535. return arr[0];
  536. }
  537. var resultLength = 0;
  538. var i, ii = arr.length;
  539. var item, itemLength;
  540. for (i = 0; i < ii; i++) {
  541. item = arr[i];
  542. itemLength = arrayByteLength(item);
  543. resultLength += itemLength;
  544. }
  545. var pos = 0;
  546. var data = new Uint8Array(resultLength);
  547. for (i = 0; i < ii; i++) {
  548. item = arr[i];
  549. if (!(item instanceof Uint8Array)) {
  550. if (typeof item === 'string') {
  551. item = stringToBytes(item);
  552. } else {
  553. item = new Uint8Array(item);
  554. }
  555. }
  556. itemLength = item.byteLength;
  557. data.set(item, pos);
  558. pos += itemLength;
  559. }
  560. return data;
  561. }
  562. function string32(value) {
  563. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  564. }
  565. function log2(x) {
  566. var n = 1, i = 0;
  567. while (x > n) {
  568. n <<= 1;
  569. i++;
  570. }
  571. return i;
  572. }
  573. function readInt8(data, start) {
  574. return data[start] << 24 >> 24;
  575. }
  576. function readUint16(data, offset) {
  577. return data[offset] << 8 | data[offset + 1];
  578. }
  579. function readUint32(data, offset) {
  580. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  581. }
  582. function isLittleEndian() {
  583. var buffer8 = new Uint8Array(2);
  584. buffer8[0] = 1;
  585. var buffer16 = new Uint16Array(buffer8.buffer);
  586. return buffer16[0] === 1;
  587. }
  588. function isEvalSupported() {
  589. try {
  590. new Function('');
  591. return true;
  592. } catch (e) {
  593. return false;
  594. }
  595. }
  596. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  597. function Uint32ArrayView(buffer, length) {
  598. this.buffer = buffer;
  599. this.byteLength = buffer.length;
  600. this.length = length === undefined ? this.byteLength >> 2 : length;
  601. ensureUint32ArrayViewProps(this.length);
  602. }
  603. Uint32ArrayView.prototype = Object.create(null);
  604. var uint32ArrayViewSetters = 0;
  605. function createUint32ArrayProp(index) {
  606. return {
  607. get: function () {
  608. var buffer = this.buffer, offset = index << 2;
  609. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  610. },
  611. set: function (value) {
  612. var buffer = this.buffer, offset = index << 2;
  613. buffer[offset] = value & 255;
  614. buffer[offset + 1] = value >> 8 & 255;
  615. buffer[offset + 2] = value >> 16 & 255;
  616. buffer[offset + 3] = value >>> 24 & 255;
  617. }
  618. };
  619. }
  620. function ensureUint32ArrayViewProps(length) {
  621. while (uint32ArrayViewSetters < length) {
  622. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  623. uint32ArrayViewSetters++;
  624. }
  625. }
  626. return Uint32ArrayView;
  627. }();
  628. exports.Uint32ArrayView = Uint32ArrayView;
  629. var IDENTITY_MATRIX = [
  630. 1,
  631. 0,
  632. 0,
  633. 1,
  634. 0,
  635. 0
  636. ];
  637. var Util = function UtilClosure() {
  638. function Util() {
  639. }
  640. var rgbBuf = [
  641. 'rgb(',
  642. 0,
  643. ',',
  644. 0,
  645. ',',
  646. 0,
  647. ')'
  648. ];
  649. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  650. rgbBuf[1] = r;
  651. rgbBuf[3] = g;
  652. rgbBuf[5] = b;
  653. return rgbBuf.join('');
  654. };
  655. Util.transform = function Util_transform(m1, m2) {
  656. return [
  657. m1[0] * m2[0] + m1[2] * m2[1],
  658. m1[1] * m2[0] + m1[3] * m2[1],
  659. m1[0] * m2[2] + m1[2] * m2[3],
  660. m1[1] * m2[2] + m1[3] * m2[3],
  661. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  662. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  663. ];
  664. };
  665. Util.applyTransform = function Util_applyTransform(p, m) {
  666. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  667. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  668. return [
  669. xt,
  670. yt
  671. ];
  672. };
  673. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  674. var d = m[0] * m[3] - m[1] * m[2];
  675. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  676. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  677. return [
  678. xt,
  679. yt
  680. ];
  681. };
  682. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  683. var p1 = Util.applyTransform(r, m);
  684. var p2 = Util.applyTransform(r.slice(2, 4), m);
  685. var p3 = Util.applyTransform([
  686. r[0],
  687. r[3]
  688. ], m);
  689. var p4 = Util.applyTransform([
  690. r[2],
  691. r[1]
  692. ], m);
  693. return [
  694. Math.min(p1[0], p2[0], p3[0], p4[0]),
  695. Math.min(p1[1], p2[1], p3[1], p4[1]),
  696. Math.max(p1[0], p2[0], p3[0], p4[0]),
  697. Math.max(p1[1], p2[1], p3[1], p4[1])
  698. ];
  699. };
  700. Util.inverseTransform = function Util_inverseTransform(m) {
  701. var d = m[0] * m[3] - m[1] * m[2];
  702. return [
  703. m[3] / d,
  704. -m[1] / d,
  705. -m[2] / d,
  706. m[0] / d,
  707. (m[2] * m[5] - m[4] * m[3]) / d,
  708. (m[4] * m[1] - m[5] * m[0]) / d
  709. ];
  710. };
  711. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  712. return [
  713. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  714. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  715. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  716. ];
  717. };
  718. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  719. var transpose = [
  720. m[0],
  721. m[2],
  722. m[1],
  723. m[3]
  724. ];
  725. var a = m[0] * transpose[0] + m[1] * transpose[2];
  726. var b = m[0] * transpose[1] + m[1] * transpose[3];
  727. var c = m[2] * transpose[0] + m[3] * transpose[2];
  728. var d = m[2] * transpose[1] + m[3] * transpose[3];
  729. var first = (a + d) / 2;
  730. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  731. var sx = first + second || 1;
  732. var sy = first - second || 1;
  733. return [
  734. Math.sqrt(sx),
  735. Math.sqrt(sy)
  736. ];
  737. };
  738. Util.normalizeRect = function Util_normalizeRect(rect) {
  739. var r = rect.slice(0);
  740. if (rect[0] > rect[2]) {
  741. r[0] = rect[2];
  742. r[2] = rect[0];
  743. }
  744. if (rect[1] > rect[3]) {
  745. r[1] = rect[3];
  746. r[3] = rect[1];
  747. }
  748. return r;
  749. };
  750. Util.intersect = function Util_intersect(rect1, rect2) {
  751. function compare(a, b) {
  752. return a - b;
  753. }
  754. var orderedX = [
  755. rect1[0],
  756. rect1[2],
  757. rect2[0],
  758. rect2[2]
  759. ].sort(compare), orderedY = [
  760. rect1[1],
  761. rect1[3],
  762. rect2[1],
  763. rect2[3]
  764. ].sort(compare), result = [];
  765. rect1 = Util.normalizeRect(rect1);
  766. rect2 = Util.normalizeRect(rect2);
  767. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  768. result[0] = orderedX[1];
  769. result[2] = orderedX[2];
  770. } else {
  771. return false;
  772. }
  773. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  774. result[1] = orderedY[1];
  775. result[3] = orderedY[2];
  776. } else {
  777. return false;
  778. }
  779. return result;
  780. };
  781. Util.sign = function Util_sign(num) {
  782. return num < 0 ? -1 : 1;
  783. };
  784. var ROMAN_NUMBER_MAP = [
  785. '',
  786. 'C',
  787. 'CC',
  788. 'CCC',
  789. 'CD',
  790. 'D',
  791. 'DC',
  792. 'DCC',
  793. 'DCCC',
  794. 'CM',
  795. '',
  796. 'X',
  797. 'XX',
  798. 'XXX',
  799. 'XL',
  800. 'L',
  801. 'LX',
  802. 'LXX',
  803. 'LXXX',
  804. 'XC',
  805. '',
  806. 'I',
  807. 'II',
  808. 'III',
  809. 'IV',
  810. 'V',
  811. 'VI',
  812. 'VII',
  813. 'VIII',
  814. 'IX'
  815. ];
  816. Util.toRoman = function Util_toRoman(number, lowerCase) {
  817. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  818. var pos, romanBuf = [];
  819. while (number >= 1000) {
  820. number -= 1000;
  821. romanBuf.push('M');
  822. }
  823. pos = number / 100 | 0;
  824. number %= 100;
  825. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  826. pos = number / 10 | 0;
  827. number %= 10;
  828. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  829. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  830. var romanStr = romanBuf.join('');
  831. return lowerCase ? romanStr.toLowerCase() : romanStr;
  832. };
  833. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  834. Array.prototype.push.apply(arr1, arr2);
  835. };
  836. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  837. Array.prototype.unshift.apply(arr1, arr2);
  838. };
  839. Util.extendObj = function extendObj(obj1, obj2) {
  840. for (var key in obj2) {
  841. obj1[key] = obj2[key];
  842. }
  843. };
  844. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  845. while (dict && !dict.has(name)) {
  846. dict = dict.get('Parent');
  847. }
  848. if (!dict) {
  849. return null;
  850. }
  851. return getArray ? dict.getArray(name) : dict.get(name);
  852. };
  853. Util.inherit = function Util_inherit(sub, base, prototype) {
  854. sub.prototype = Object.create(base.prototype);
  855. sub.prototype.constructor = sub;
  856. for (var prop in prototype) {
  857. sub.prototype[prop] = prototype[prop];
  858. }
  859. };
  860. Util.loadScript = function Util_loadScript(src, callback) {
  861. var script = document.createElement('script');
  862. var loaded = false;
  863. script.setAttribute('src', src);
  864. if (callback) {
  865. script.onload = function () {
  866. if (!loaded) {
  867. callback();
  868. }
  869. loaded = true;
  870. };
  871. }
  872. document.getElementsByTagName('head')[0].appendChild(script);
  873. };
  874. return Util;
  875. }();
  876. var PageViewport = function PageViewportClosure() {
  877. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  878. this.viewBox = viewBox;
  879. this.scale = scale;
  880. this.rotation = rotation;
  881. this.offsetX = offsetX;
  882. this.offsetY = offsetY;
  883. var centerX = (viewBox[2] + viewBox[0]) / 2;
  884. var centerY = (viewBox[3] + viewBox[1]) / 2;
  885. var rotateA, rotateB, rotateC, rotateD;
  886. rotation = rotation % 360;
  887. rotation = rotation < 0 ? rotation + 360 : rotation;
  888. switch (rotation) {
  889. case 180:
  890. rotateA = -1;
  891. rotateB = 0;
  892. rotateC = 0;
  893. rotateD = 1;
  894. break;
  895. case 90:
  896. rotateA = 0;
  897. rotateB = 1;
  898. rotateC = 1;
  899. rotateD = 0;
  900. break;
  901. case 270:
  902. rotateA = 0;
  903. rotateB = -1;
  904. rotateC = -1;
  905. rotateD = 0;
  906. break;
  907. default:
  908. rotateA = 1;
  909. rotateB = 0;
  910. rotateC = 0;
  911. rotateD = -1;
  912. break;
  913. }
  914. if (dontFlip) {
  915. rotateC = -rotateC;
  916. rotateD = -rotateD;
  917. }
  918. var offsetCanvasX, offsetCanvasY;
  919. var width, height;
  920. if (rotateA === 0) {
  921. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  922. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  923. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  924. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  925. } else {
  926. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  927. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  928. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  929. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  930. }
  931. this.transform = [
  932. rotateA * scale,
  933. rotateB * scale,
  934. rotateC * scale,
  935. rotateD * scale,
  936. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  937. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  938. ];
  939. this.width = width;
  940. this.height = height;
  941. this.fontScale = scale;
  942. }
  943. PageViewport.prototype = {
  944. clone: function PageViewPort_clone(args) {
  945. args = args || {};
  946. var scale = 'scale' in args ? args.scale : this.scale;
  947. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  948. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  949. },
  950. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  951. return Util.applyTransform([
  952. x,
  953. y
  954. ], this.transform);
  955. },
  956. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  957. var tl = Util.applyTransform([
  958. rect[0],
  959. rect[1]
  960. ], this.transform);
  961. var br = Util.applyTransform([
  962. rect[2],
  963. rect[3]
  964. ], this.transform);
  965. return [
  966. tl[0],
  967. tl[1],
  968. br[0],
  969. br[1]
  970. ];
  971. },
  972. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  973. return Util.applyInverseTransform([
  974. x,
  975. y
  976. ], this.transform);
  977. }
  978. };
  979. return PageViewport;
  980. }();
  981. var PDFStringTranslateTable = [
  982. 0,
  983. 0,
  984. 0,
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0,
  993. 0,
  994. 0,
  995. 0,
  996. 0,
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0x2D8,
  1007. 0x2C7,
  1008. 0x2C6,
  1009. 0x2D9,
  1010. 0x2DD,
  1011. 0x2DB,
  1012. 0x2DA,
  1013. 0x2DC,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0,
  1022. 0,
  1023. 0,
  1024. 0,
  1025. 0,
  1026. 0,
  1027. 0,
  1028. 0,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0,
  1110. 0x2022,
  1111. 0x2020,
  1112. 0x2021,
  1113. 0x2026,
  1114. 0x2014,
  1115. 0x2013,
  1116. 0x192,
  1117. 0x2044,
  1118. 0x2039,
  1119. 0x203A,
  1120. 0x2212,
  1121. 0x2030,
  1122. 0x201E,
  1123. 0x201C,
  1124. 0x201D,
  1125. 0x2018,
  1126. 0x2019,
  1127. 0x201A,
  1128. 0x2122,
  1129. 0xFB01,
  1130. 0xFB02,
  1131. 0x141,
  1132. 0x152,
  1133. 0x160,
  1134. 0x178,
  1135. 0x17D,
  1136. 0x131,
  1137. 0x142,
  1138. 0x153,
  1139. 0x161,
  1140. 0x17E,
  1141. 0,
  1142. 0x20AC
  1143. ];
  1144. function stringToPDFString(str) {
  1145. var i, n = str.length, strBuf = [];
  1146. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1147. for (i = 2; i < n; i += 2) {
  1148. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1149. }
  1150. } else {
  1151. for (i = 0; i < n; ++i) {
  1152. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1153. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1154. }
  1155. }
  1156. return strBuf.join('');
  1157. }
  1158. function stringToUTF8String(str) {
  1159. return decodeURIComponent(escape(str));
  1160. }
  1161. function utf8StringToString(str) {
  1162. return unescape(encodeURIComponent(str));
  1163. }
  1164. function isEmptyObj(obj) {
  1165. for (var key in obj) {
  1166. return false;
  1167. }
  1168. return true;
  1169. }
  1170. function isBool(v) {
  1171. return typeof v === 'boolean';
  1172. }
  1173. function isInt(v) {
  1174. return typeof v === 'number' && (v | 0) === v;
  1175. }
  1176. function isNum(v) {
  1177. return typeof v === 'number';
  1178. }
  1179. function isString(v) {
  1180. return typeof v === 'string';
  1181. }
  1182. function isArray(v) {
  1183. return v instanceof Array;
  1184. }
  1185. function isArrayBuffer(v) {
  1186. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1187. }
  1188. function isSpace(ch) {
  1189. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1190. }
  1191. function isNodeJS() {
  1192. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1193. return typeof process === 'object' && process + '' === '[object process]';
  1194. }
  1195. return false;
  1196. }
  1197. function createPromiseCapability() {
  1198. var capability = {};
  1199. capability.promise = new Promise(function (resolve, reject) {
  1200. capability.resolve = resolve;
  1201. capability.reject = reject;
  1202. });
  1203. return capability;
  1204. }
  1205. var StatTimer = function StatTimerClosure() {
  1206. function rpad(str, pad, length) {
  1207. while (str.length < length) {
  1208. str += pad;
  1209. }
  1210. return str;
  1211. }
  1212. function StatTimer() {
  1213. this.started = Object.create(null);
  1214. this.times = [];
  1215. this.enabled = true;
  1216. }
  1217. StatTimer.prototype = {
  1218. time: function StatTimer_time(name) {
  1219. if (!this.enabled) {
  1220. return;
  1221. }
  1222. if (name in this.started) {
  1223. warn('Timer is already running for ' + name);
  1224. }
  1225. this.started[name] = Date.now();
  1226. },
  1227. timeEnd: function StatTimer_timeEnd(name) {
  1228. if (!this.enabled) {
  1229. return;
  1230. }
  1231. if (!(name in this.started)) {
  1232. warn('Timer has not been started for ' + name);
  1233. }
  1234. this.times.push({
  1235. 'name': name,
  1236. 'start': this.started[name],
  1237. 'end': Date.now()
  1238. });
  1239. delete this.started[name];
  1240. },
  1241. toString: function StatTimer_toString() {
  1242. var i, ii;
  1243. var times = this.times;
  1244. var out = '';
  1245. var longest = 0;
  1246. for (i = 0, ii = times.length; i < ii; ++i) {
  1247. var name = times[i]['name'];
  1248. if (name.length > longest) {
  1249. longest = name.length;
  1250. }
  1251. }
  1252. for (i = 0, ii = times.length; i < ii; ++i) {
  1253. var span = times[i];
  1254. var duration = span.end - span.start;
  1255. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1256. }
  1257. return out;
  1258. }
  1259. };
  1260. return StatTimer;
  1261. }();
  1262. var createBlob = function createBlob(data, contentType) {
  1263. if (typeof Blob !== 'undefined') {
  1264. return new Blob([data], { type: contentType });
  1265. }
  1266. warn('The "Blob" constructor is not supported.');
  1267. };
  1268. var createObjectURL = function createObjectURLClosure() {
  1269. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1270. return function createObjectURL(data, contentType, forceDataSchema) {
  1271. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1272. var blob = createBlob(data, contentType);
  1273. return URL.createObjectURL(blob);
  1274. }
  1275. var buffer = 'data:' + contentType + ';base64,';
  1276. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1277. var b1 = data[i] & 0xFF;
  1278. var b2 = data[i + 1] & 0xFF;
  1279. var b3 = data[i + 2] & 0xFF;
  1280. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1281. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1282. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1283. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1284. }
  1285. return buffer;
  1286. };
  1287. }();
  1288. function MessageHandler(sourceName, targetName, comObj) {
  1289. this.sourceName = sourceName;
  1290. this.targetName = targetName;
  1291. this.comObj = comObj;
  1292. this.callbackIndex = 1;
  1293. this.postMessageTransfers = true;
  1294. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1295. var ah = this.actionHandler = Object.create(null);
  1296. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1297. var data = event.data;
  1298. if (data.targetName !== this.sourceName) {
  1299. return;
  1300. }
  1301. if (data.isReply) {
  1302. var callbackId = data.callbackId;
  1303. if (data.callbackId in callbacksCapabilities) {
  1304. var callback = callbacksCapabilities[callbackId];
  1305. delete callbacksCapabilities[callbackId];
  1306. if ('error' in data) {
  1307. callback.reject(data.error);
  1308. } else {
  1309. callback.resolve(data.data);
  1310. }
  1311. } else {
  1312. error('Cannot resolve callback ' + callbackId);
  1313. }
  1314. } else if (data.action in ah) {
  1315. var action = ah[data.action];
  1316. if (data.callbackId) {
  1317. var sourceName = this.sourceName;
  1318. var targetName = data.sourceName;
  1319. Promise.resolve().then(function () {
  1320. return action[0].call(action[1], data.data);
  1321. }).then(function (result) {
  1322. comObj.postMessage({
  1323. sourceName: sourceName,
  1324. targetName: targetName,
  1325. isReply: true,
  1326. callbackId: data.callbackId,
  1327. data: result
  1328. });
  1329. }, function (reason) {
  1330. if (reason instanceof Error) {
  1331. reason = reason + '';
  1332. }
  1333. comObj.postMessage({
  1334. sourceName: sourceName,
  1335. targetName: targetName,
  1336. isReply: true,
  1337. callbackId: data.callbackId,
  1338. error: reason
  1339. });
  1340. });
  1341. } else {
  1342. action[0].call(action[1], data.data);
  1343. }
  1344. } else {
  1345. error('Unknown action from worker: ' + data.action);
  1346. }
  1347. }.bind(this);
  1348. comObj.addEventListener('message', this._onComObjOnMessage);
  1349. }
  1350. MessageHandler.prototype = {
  1351. on: function messageHandlerOn(actionName, handler, scope) {
  1352. var ah = this.actionHandler;
  1353. if (ah[actionName]) {
  1354. error('There is already an actionName called "' + actionName + '"');
  1355. }
  1356. ah[actionName] = [
  1357. handler,
  1358. scope
  1359. ];
  1360. },
  1361. send: function messageHandlerSend(actionName, data, transfers) {
  1362. var message = {
  1363. sourceName: this.sourceName,
  1364. targetName: this.targetName,
  1365. action: actionName,
  1366. data: data
  1367. };
  1368. this.postMessage(message, transfers);
  1369. },
  1370. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1371. var callbackId = this.callbackIndex++;
  1372. var message = {
  1373. sourceName: this.sourceName,
  1374. targetName: this.targetName,
  1375. action: actionName,
  1376. data: data,
  1377. callbackId: callbackId
  1378. };
  1379. var capability = createPromiseCapability();
  1380. this.callbacksCapabilities[callbackId] = capability;
  1381. try {
  1382. this.postMessage(message, transfers);
  1383. } catch (e) {
  1384. capability.reject(e);
  1385. }
  1386. return capability.promise;
  1387. },
  1388. postMessage: function (message, transfers) {
  1389. if (transfers && this.postMessageTransfers) {
  1390. this.comObj.postMessage(message, transfers);
  1391. } else {
  1392. this.comObj.postMessage(message);
  1393. }
  1394. },
  1395. destroy: function () {
  1396. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1397. }
  1398. };
  1399. function loadJpegStream(id, imageUrl, objs) {
  1400. var img = new Image();
  1401. img.onload = function loadJpegStream_onloadClosure() {
  1402. objs.resolve(id, img);
  1403. };
  1404. img.onerror = function loadJpegStream_onerrorClosure() {
  1405. objs.resolve(id, null);
  1406. warn('Error during JPEG image loading');
  1407. };
  1408. img.src = imageUrl;
  1409. }
  1410. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1411. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1412. exports.OPS = OPS;
  1413. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1414. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1415. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1416. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1417. exports.AnnotationFlag = AnnotationFlag;
  1418. exports.AnnotationType = AnnotationType;
  1419. exports.FontType = FontType;
  1420. exports.ImageKind = ImageKind;
  1421. exports.CMapCompressionType = CMapCompressionType;
  1422. exports.InvalidPDFException = InvalidPDFException;
  1423. exports.MessageHandler = MessageHandler;
  1424. exports.MissingDataException = MissingDataException;
  1425. exports.MissingPDFException = MissingPDFException;
  1426. exports.NotImplementedException = NotImplementedException;
  1427. exports.PageViewport = PageViewport;
  1428. exports.PasswordException = PasswordException;
  1429. exports.PasswordResponses = PasswordResponses;
  1430. exports.StatTimer = StatTimer;
  1431. exports.StreamType = StreamType;
  1432. exports.TextRenderingMode = TextRenderingMode;
  1433. exports.UnexpectedResponseException = UnexpectedResponseException;
  1434. exports.UnknownErrorException = UnknownErrorException;
  1435. exports.Util = Util;
  1436. exports.XRefParseException = XRefParseException;
  1437. exports.arrayByteLength = arrayByteLength;
  1438. exports.arraysToBytes = arraysToBytes;
  1439. exports.assert = assert;
  1440. exports.bytesToString = bytesToString;
  1441. exports.createBlob = createBlob;
  1442. exports.createPromiseCapability = createPromiseCapability;
  1443. exports.createObjectURL = createObjectURL;
  1444. exports.deprecated = deprecated;
  1445. exports.error = error;
  1446. exports.getLookupTableFactory = getLookupTableFactory;
  1447. exports.getVerbosityLevel = getVerbosityLevel;
  1448. exports.globalScope = globalScope;
  1449. exports.info = info;
  1450. exports.isArray = isArray;
  1451. exports.isArrayBuffer = isArrayBuffer;
  1452. exports.isBool = isBool;
  1453. exports.isEmptyObj = isEmptyObj;
  1454. exports.isInt = isInt;
  1455. exports.isNum = isNum;
  1456. exports.isString = isString;
  1457. exports.isSpace = isSpace;
  1458. exports.isNodeJS = isNodeJS;
  1459. exports.isSameOrigin = isSameOrigin;
  1460. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1461. exports.isLittleEndian = isLittleEndian;
  1462. exports.isEvalSupported = isEvalSupported;
  1463. exports.loadJpegStream = loadJpegStream;
  1464. exports.log2 = log2;
  1465. exports.readInt8 = readInt8;
  1466. exports.readUint16 = readUint16;
  1467. exports.readUint32 = readUint32;
  1468. exports.removeNullCharacters = removeNullCharacters;
  1469. exports.setVerbosityLevel = setVerbosityLevel;
  1470. exports.shadow = shadow;
  1471. exports.string32 = string32;
  1472. exports.stringToBytes = stringToBytes;
  1473. exports.stringToPDFString = stringToPDFString;
  1474. exports.stringToUTF8String = stringToUTF8String;
  1475. exports.utf8StringToString = utf8StringToString;
  1476. exports.warn = warn;
  1477. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  1478. /***/ }),
  1479. /* 1 */
  1480. /***/ (function(module, exports, __w_pdfjs_require__) {
  1481. "use strict";
  1482. var sharedUtil = __w_pdfjs_require__(0);
  1483. var isArray = sharedUtil.isArray;
  1484. var EOF = {};
  1485. var Name = function NameClosure() {
  1486. function Name(name) {
  1487. this.name = name;
  1488. }
  1489. Name.prototype = {};
  1490. var nameCache = Object.create(null);
  1491. Name.get = function Name_get(name) {
  1492. var nameValue = nameCache[name];
  1493. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1494. };
  1495. return Name;
  1496. }();
  1497. var Cmd = function CmdClosure() {
  1498. function Cmd(cmd) {
  1499. this.cmd = cmd;
  1500. }
  1501. Cmd.prototype = {};
  1502. var cmdCache = Object.create(null);
  1503. Cmd.get = function Cmd_get(cmd) {
  1504. var cmdValue = cmdCache[cmd];
  1505. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1506. };
  1507. return Cmd;
  1508. }();
  1509. var Dict = function DictClosure() {
  1510. var nonSerializable = function nonSerializableClosure() {
  1511. return nonSerializable;
  1512. };
  1513. function Dict(xref) {
  1514. this.map = Object.create(null);
  1515. this.xref = xref;
  1516. this.objId = null;
  1517. this.suppressEncryption = false;
  1518. this.__nonSerializable__ = nonSerializable;
  1519. }
  1520. Dict.prototype = {
  1521. assignXref: function Dict_assignXref(newXref) {
  1522. this.xref = newXref;
  1523. },
  1524. get: function Dict_get(key1, key2, key3) {
  1525. var value;
  1526. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1527. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1528. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1529. }
  1530. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1531. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1532. }
  1533. value = this.map[key3] || null;
  1534. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1535. },
  1536. getAsync: function Dict_getAsync(key1, key2, key3) {
  1537. var value;
  1538. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1539. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1540. if (xref) {
  1541. return xref.fetchIfRefAsync(value, suppressEncryption);
  1542. }
  1543. return Promise.resolve(value);
  1544. }
  1545. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1546. if (xref) {
  1547. return xref.fetchIfRefAsync(value, suppressEncryption);
  1548. }
  1549. return Promise.resolve(value);
  1550. }
  1551. value = this.map[key3] || null;
  1552. if (xref) {
  1553. return xref.fetchIfRefAsync(value, suppressEncryption);
  1554. }
  1555. return Promise.resolve(value);
  1556. },
  1557. getArray: function Dict_getArray(key1, key2, key3) {
  1558. var value = this.get(key1, key2, key3);
  1559. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1560. if (!isArray(value) || !xref) {
  1561. return value;
  1562. }
  1563. value = value.slice();
  1564. for (var i = 0, ii = value.length; i < ii; i++) {
  1565. if (!isRef(value[i])) {
  1566. continue;
  1567. }
  1568. value[i] = xref.fetch(value[i], suppressEncryption);
  1569. }
  1570. return value;
  1571. },
  1572. getRaw: function Dict_getRaw(key) {
  1573. return this.map[key];
  1574. },
  1575. getKeys: function Dict_getKeys() {
  1576. return Object.keys(this.map);
  1577. },
  1578. set: function Dict_set(key, value) {
  1579. this.map[key] = value;
  1580. },
  1581. has: function Dict_has(key) {
  1582. return key in this.map;
  1583. },
  1584. forEach: function Dict_forEach(callback) {
  1585. for (var key in this.map) {
  1586. callback(key, this.get(key));
  1587. }
  1588. }
  1589. };
  1590. Dict.empty = new Dict(null);
  1591. Dict.merge = function Dict_merge(xref, dictArray) {
  1592. var mergedDict = new Dict(xref);
  1593. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1594. var dict = dictArray[i];
  1595. if (!isDict(dict)) {
  1596. continue;
  1597. }
  1598. for (var keyName in dict.map) {
  1599. if (mergedDict.map[keyName]) {
  1600. continue;
  1601. }
  1602. mergedDict.map[keyName] = dict.map[keyName];
  1603. }
  1604. }
  1605. return mergedDict;
  1606. };
  1607. return Dict;
  1608. }();
  1609. var Ref = function RefClosure() {
  1610. function Ref(num, gen) {
  1611. this.num = num;
  1612. this.gen = gen;
  1613. }
  1614. Ref.prototype = {
  1615. toString: function Ref_toString() {
  1616. var str = this.num + 'R';
  1617. if (this.gen !== 0) {
  1618. str += this.gen;
  1619. }
  1620. return str;
  1621. }
  1622. };
  1623. return Ref;
  1624. }();
  1625. var RefSet = function RefSetClosure() {
  1626. function RefSet() {
  1627. this.dict = Object.create(null);
  1628. }
  1629. RefSet.prototype = {
  1630. has: function RefSet_has(ref) {
  1631. return ref.toString() in this.dict;
  1632. },
  1633. put: function RefSet_put(ref) {
  1634. this.dict[ref.toString()] = true;
  1635. },
  1636. remove: function RefSet_remove(ref) {
  1637. delete this.dict[ref.toString()];
  1638. }
  1639. };
  1640. return RefSet;
  1641. }();
  1642. var RefSetCache = function RefSetCacheClosure() {
  1643. function RefSetCache() {
  1644. this.dict = Object.create(null);
  1645. }
  1646. RefSetCache.prototype = {
  1647. get: function RefSetCache_get(ref) {
  1648. return this.dict[ref.toString()];
  1649. },
  1650. has: function RefSetCache_has(ref) {
  1651. return ref.toString() in this.dict;
  1652. },
  1653. put: function RefSetCache_put(ref, obj) {
  1654. this.dict[ref.toString()] = obj;
  1655. },
  1656. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1657. this.dict[ref.toString()] = this.get(aliasRef);
  1658. },
  1659. forEach: function RefSetCache_forEach(fn, thisArg) {
  1660. for (var i in this.dict) {
  1661. fn.call(thisArg, this.dict[i]);
  1662. }
  1663. },
  1664. clear: function RefSetCache_clear() {
  1665. this.dict = Object.create(null);
  1666. }
  1667. };
  1668. return RefSetCache;
  1669. }();
  1670. function isEOF(v) {
  1671. return v === EOF;
  1672. }
  1673. function isName(v, name) {
  1674. return v instanceof Name && (name === undefined || v.name === name);
  1675. }
  1676. function isCmd(v, cmd) {
  1677. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1678. }
  1679. function isDict(v, type) {
  1680. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1681. }
  1682. function isRef(v) {
  1683. return v instanceof Ref;
  1684. }
  1685. function isRefsEqual(v1, v2) {
  1686. return v1.num === v2.num && v1.gen === v2.gen;
  1687. }
  1688. function isStream(v) {
  1689. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  1690. }
  1691. exports.EOF = EOF;
  1692. exports.Cmd = Cmd;
  1693. exports.Dict = Dict;
  1694. exports.Name = Name;
  1695. exports.Ref = Ref;
  1696. exports.RefSet = RefSet;
  1697. exports.RefSetCache = RefSetCache;
  1698. exports.isEOF = isEOF;
  1699. exports.isCmd = isCmd;
  1700. exports.isDict = isDict;
  1701. exports.isName = isName;
  1702. exports.isRef = isRef;
  1703. exports.isRefsEqual = isRefsEqual;
  1704. exports.isStream = isStream;
  1705. /***/ }),
  1706. /* 2 */
  1707. /***/ (function(module, exports, __w_pdfjs_require__) {
  1708. "use strict";
  1709. var sharedUtil = __w_pdfjs_require__(0);
  1710. var corePrimitives = __w_pdfjs_require__(1);
  1711. var coreJbig2 = __w_pdfjs_require__(35);
  1712. var coreJpg = __w_pdfjs_require__(36);
  1713. var coreJpx = __w_pdfjs_require__(19);
  1714. var Util = sharedUtil.Util;
  1715. var error = sharedUtil.error;
  1716. var info = sharedUtil.info;
  1717. var isInt = sharedUtil.isInt;
  1718. var isArray = sharedUtil.isArray;
  1719. var createObjectURL = sharedUtil.createObjectURL;
  1720. var shadow = sharedUtil.shadow;
  1721. var isSpace = sharedUtil.isSpace;
  1722. var Dict = corePrimitives.Dict;
  1723. var isDict = corePrimitives.isDict;
  1724. var isStream = corePrimitives.isStream;
  1725. var Jbig2Image = coreJbig2.Jbig2Image;
  1726. var JpegImage = coreJpg.JpegImage;
  1727. var JpxImage = coreJpx.JpxImage;
  1728. var Stream = function StreamClosure() {
  1729. function Stream(arrayBuffer, start, length, dict) {
  1730. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1731. this.start = start || 0;
  1732. this.pos = this.start;
  1733. this.end = start + length || this.bytes.length;
  1734. this.dict = dict;
  1735. }
  1736. Stream.prototype = {
  1737. get length() {
  1738. return this.end - this.start;
  1739. },
  1740. get isEmpty() {
  1741. return this.length === 0;
  1742. },
  1743. getByte: function Stream_getByte() {
  1744. if (this.pos >= this.end) {
  1745. return -1;
  1746. }
  1747. return this.bytes[this.pos++];
  1748. },
  1749. getUint16: function Stream_getUint16() {
  1750. var b0 = this.getByte();
  1751. var b1 = this.getByte();
  1752. if (b0 === -1 || b1 === -1) {
  1753. return -1;
  1754. }
  1755. return (b0 << 8) + b1;
  1756. },
  1757. getInt32: function Stream_getInt32() {
  1758. var b0 = this.getByte();
  1759. var b1 = this.getByte();
  1760. var b2 = this.getByte();
  1761. var b3 = this.getByte();
  1762. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1763. },
  1764. getBytes: function Stream_getBytes(length) {
  1765. var bytes = this.bytes;
  1766. var pos = this.pos;
  1767. var strEnd = this.end;
  1768. if (!length) {
  1769. return bytes.subarray(pos, strEnd);
  1770. }
  1771. var end = pos + length;
  1772. if (end > strEnd) {
  1773. end = strEnd;
  1774. }
  1775. this.pos = end;
  1776. return bytes.subarray(pos, end);
  1777. },
  1778. peekByte: function Stream_peekByte() {
  1779. var peekedByte = this.getByte();
  1780. this.pos--;
  1781. return peekedByte;
  1782. },
  1783. peekBytes: function Stream_peekBytes(length) {
  1784. var bytes = this.getBytes(length);
  1785. this.pos -= bytes.length;
  1786. return bytes;
  1787. },
  1788. skip: function Stream_skip(n) {
  1789. if (!n) {
  1790. n = 1;
  1791. }
  1792. this.pos += n;
  1793. },
  1794. reset: function Stream_reset() {
  1795. this.pos = this.start;
  1796. },
  1797. moveStart: function Stream_moveStart() {
  1798. this.start = this.pos;
  1799. },
  1800. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1801. return new Stream(this.bytes.buffer, start, length, dict);
  1802. }
  1803. };
  1804. return Stream;
  1805. }();
  1806. var StringStream = function StringStreamClosure() {
  1807. function StringStream(str) {
  1808. var length = str.length;
  1809. var bytes = new Uint8Array(length);
  1810. for (var n = 0; n < length; ++n) {
  1811. bytes[n] = str.charCodeAt(n);
  1812. }
  1813. Stream.call(this, bytes);
  1814. }
  1815. StringStream.prototype = Stream.prototype;
  1816. return StringStream;
  1817. }();
  1818. var DecodeStream = function DecodeStreamClosure() {
  1819. var emptyBuffer = new Uint8Array(0);
  1820. function DecodeStream(maybeMinBufferLength) {
  1821. this.pos = 0;
  1822. this.bufferLength = 0;
  1823. this.eof = false;
  1824. this.buffer = emptyBuffer;
  1825. this.minBufferLength = 512;
  1826. if (maybeMinBufferLength) {
  1827. while (this.minBufferLength < maybeMinBufferLength) {
  1828. this.minBufferLength *= 2;
  1829. }
  1830. }
  1831. }
  1832. DecodeStream.prototype = {
  1833. get isEmpty() {
  1834. while (!this.eof && this.bufferLength === 0) {
  1835. this.readBlock();
  1836. }
  1837. return this.bufferLength === 0;
  1838. },
  1839. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1840. var buffer = this.buffer;
  1841. if (requested <= buffer.byteLength) {
  1842. return buffer;
  1843. }
  1844. var size = this.minBufferLength;
  1845. while (size < requested) {
  1846. size *= 2;
  1847. }
  1848. var buffer2 = new Uint8Array(size);
  1849. buffer2.set(buffer);
  1850. return this.buffer = buffer2;
  1851. },
  1852. getByte: function DecodeStream_getByte() {
  1853. var pos = this.pos;
  1854. while (this.bufferLength <= pos) {
  1855. if (this.eof) {
  1856. return -1;
  1857. }
  1858. this.readBlock();
  1859. }
  1860. return this.buffer[this.pos++];
  1861. },
  1862. getUint16: function DecodeStream_getUint16() {
  1863. var b0 = this.getByte();
  1864. var b1 = this.getByte();
  1865. if (b0 === -1 || b1 === -1) {
  1866. return -1;
  1867. }
  1868. return (b0 << 8) + b1;
  1869. },
  1870. getInt32: function DecodeStream_getInt32() {
  1871. var b0 = this.getByte();
  1872. var b1 = this.getByte();
  1873. var b2 = this.getByte();
  1874. var b3 = this.getByte();
  1875. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1876. },
  1877. getBytes: function DecodeStream_getBytes(length) {
  1878. var end, pos = this.pos;
  1879. if (length) {
  1880. this.ensureBuffer(pos + length);
  1881. end = pos + length;
  1882. while (!this.eof && this.bufferLength < end) {
  1883. this.readBlock();
  1884. }
  1885. var bufEnd = this.bufferLength;
  1886. if (end > bufEnd) {
  1887. end = bufEnd;
  1888. }
  1889. } else {
  1890. while (!this.eof) {
  1891. this.readBlock();
  1892. }
  1893. end = this.bufferLength;
  1894. }
  1895. this.pos = end;
  1896. return this.buffer.subarray(pos, end);
  1897. },
  1898. peekByte: function DecodeStream_peekByte() {
  1899. var peekedByte = this.getByte();
  1900. this.pos--;
  1901. return peekedByte;
  1902. },
  1903. peekBytes: function DecodeStream_peekBytes(length) {
  1904. var bytes = this.getBytes(length);
  1905. this.pos -= bytes.length;
  1906. return bytes;
  1907. },
  1908. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1909. var end = start + length;
  1910. while (this.bufferLength <= end && !this.eof) {
  1911. this.readBlock();
  1912. }
  1913. return new Stream(this.buffer, start, length, dict);
  1914. },
  1915. skip: function DecodeStream_skip(n) {
  1916. if (!n) {
  1917. n = 1;
  1918. }
  1919. this.pos += n;
  1920. },
  1921. reset: function DecodeStream_reset() {
  1922. this.pos = 0;
  1923. },
  1924. getBaseStreams: function DecodeStream_getBaseStreams() {
  1925. if (this.str && this.str.getBaseStreams) {
  1926. return this.str.getBaseStreams();
  1927. }
  1928. return [];
  1929. }
  1930. };
  1931. return DecodeStream;
  1932. }();
  1933. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1934. function StreamsSequenceStream(streams) {
  1935. this.streams = streams;
  1936. DecodeStream.call(this, null);
  1937. }
  1938. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1939. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1940. var streams = this.streams;
  1941. if (streams.length === 0) {
  1942. this.eof = true;
  1943. return;
  1944. }
  1945. var stream = streams.shift();
  1946. var chunk = stream.getBytes();
  1947. var bufferLength = this.bufferLength;
  1948. var newLength = bufferLength + chunk.length;
  1949. var buffer = this.ensureBuffer(newLength);
  1950. buffer.set(chunk, bufferLength);
  1951. this.bufferLength = newLength;
  1952. };
  1953. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1954. var baseStreams = [];
  1955. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1956. var stream = this.streams[i];
  1957. if (stream.getBaseStreams) {
  1958. Util.appendToArray(baseStreams, stream.getBaseStreams());
  1959. }
  1960. }
  1961. return baseStreams;
  1962. };
  1963. return StreamsSequenceStream;
  1964. }();
  1965. var FlateStream = function FlateStreamClosure() {
  1966. var codeLenCodeMap = new Int32Array([
  1967. 16,
  1968. 17,
  1969. 18,
  1970. 0,
  1971. 8,
  1972. 7,
  1973. 9,
  1974. 6,
  1975. 10,
  1976. 5,
  1977. 11,
  1978. 4,
  1979. 12,
  1980. 3,
  1981. 13,
  1982. 2,
  1983. 14,
  1984. 1,
  1985. 15
  1986. ]);
  1987. var lengthDecode = new Int32Array([
  1988. 0x00003,
  1989. 0x00004,
  1990. 0x00005,
  1991. 0x00006,
  1992. 0x00007,
  1993. 0x00008,
  1994. 0x00009,
  1995. 0x0000a,
  1996. 0x1000b,
  1997. 0x1000d,
  1998. 0x1000f,
  1999. 0x10011,
  2000. 0x20013,
  2001. 0x20017,
  2002. 0x2001b,
  2003. 0x2001f,
  2004. 0x30023,
  2005. 0x3002b,
  2006. 0x30033,
  2007. 0x3003b,
  2008. 0x40043,
  2009. 0x40053,
  2010. 0x40063,
  2011. 0x40073,
  2012. 0x50083,
  2013. 0x500a3,
  2014. 0x500c3,
  2015. 0x500e3,
  2016. 0x00102,
  2017. 0x00102,
  2018. 0x00102
  2019. ]);
  2020. var distDecode = new Int32Array([
  2021. 0x00001,
  2022. 0x00002,
  2023. 0x00003,
  2024. 0x00004,
  2025. 0x10005,
  2026. 0x10007,
  2027. 0x20009,
  2028. 0x2000d,
  2029. 0x30011,
  2030. 0x30019,
  2031. 0x40021,
  2032. 0x40031,
  2033. 0x50041,
  2034. 0x50061,
  2035. 0x60081,
  2036. 0x600c1,
  2037. 0x70101,
  2038. 0x70181,
  2039. 0x80201,
  2040. 0x80301,
  2041. 0x90401,
  2042. 0x90601,
  2043. 0xa0801,
  2044. 0xa0c01,
  2045. 0xb1001,
  2046. 0xb1801,
  2047. 0xc2001,
  2048. 0xc3001,
  2049. 0xd4001,
  2050. 0xd6001
  2051. ]);
  2052. var fixedLitCodeTab = [
  2053. new Int32Array([
  2054. 0x70100,
  2055. 0x80050,
  2056. 0x80010,
  2057. 0x80118,
  2058. 0x70110,
  2059. 0x80070,
  2060. 0x80030,
  2061. 0x900c0,
  2062. 0x70108,
  2063. 0x80060,
  2064. 0x80020,
  2065. 0x900a0,
  2066. 0x80000,
  2067. 0x80080,
  2068. 0x80040,
  2069. 0x900e0,
  2070. 0x70104,
  2071. 0x80058,
  2072. 0x80018,
  2073. 0x90090,
  2074. 0x70114,
  2075. 0x80078,
  2076. 0x80038,
  2077. 0x900d0,
  2078. 0x7010c,
  2079. 0x80068,
  2080. 0x80028,
  2081. 0x900b0,
  2082. 0x80008,
  2083. 0x80088,
  2084. 0x80048,
  2085. 0x900f0,
  2086. 0x70102,
  2087. 0x80054,
  2088. 0x80014,
  2089. 0x8011c,
  2090. 0x70112,
  2091. 0x80074,
  2092. 0x80034,
  2093. 0x900c8,
  2094. 0x7010a,
  2095. 0x80064,
  2096. 0x80024,
  2097. 0x900a8,
  2098. 0x80004,
  2099. 0x80084,
  2100. 0x80044,
  2101. 0x900e8,
  2102. 0x70106,
  2103. 0x8005c,
  2104. 0x8001c,
  2105. 0x90098,
  2106. 0x70116,
  2107. 0x8007c,
  2108. 0x8003c,
  2109. 0x900d8,
  2110. 0x7010e,
  2111. 0x8006c,
  2112. 0x8002c,
  2113. 0x900b8,
  2114. 0x8000c,
  2115. 0x8008c,
  2116. 0x8004c,
  2117. 0x900f8,
  2118. 0x70101,
  2119. 0x80052,
  2120. 0x80012,
  2121. 0x8011a,
  2122. 0x70111,
  2123. 0x80072,
  2124. 0x80032,
  2125. 0x900c4,
  2126. 0x70109,
  2127. 0x80062,
  2128. 0x80022,
  2129. 0x900a4,
  2130. 0x80002,
  2131. 0x80082,
  2132. 0x80042,
  2133. 0x900e4,
  2134. 0x70105,
  2135. 0x8005a,
  2136. 0x8001a,
  2137. 0x90094,
  2138. 0x70115,
  2139. 0x8007a,
  2140. 0x8003a,
  2141. 0x900d4,
  2142. 0x7010d,
  2143. 0x8006a,
  2144. 0x8002a,
  2145. 0x900b4,
  2146. 0x8000a,
  2147. 0x8008a,
  2148. 0x8004a,
  2149. 0x900f4,
  2150. 0x70103,
  2151. 0x80056,
  2152. 0x80016,
  2153. 0x8011e,
  2154. 0x70113,
  2155. 0x80076,
  2156. 0x80036,
  2157. 0x900cc,
  2158. 0x7010b,
  2159. 0x80066,
  2160. 0x80026,
  2161. 0x900ac,
  2162. 0x80006,
  2163. 0x80086,
  2164. 0x80046,
  2165. 0x900ec,
  2166. 0x70107,
  2167. 0x8005e,
  2168. 0x8001e,
  2169. 0x9009c,
  2170. 0x70117,
  2171. 0x8007e,
  2172. 0x8003e,
  2173. 0x900dc,
  2174. 0x7010f,
  2175. 0x8006e,
  2176. 0x8002e,
  2177. 0x900bc,
  2178. 0x8000e,
  2179. 0x8008e,
  2180. 0x8004e,
  2181. 0x900fc,
  2182. 0x70100,
  2183. 0x80051,
  2184. 0x80011,
  2185. 0x80119,
  2186. 0x70110,
  2187. 0x80071,
  2188. 0x80031,
  2189. 0x900c2,
  2190. 0x70108,
  2191. 0x80061,
  2192. 0x80021,
  2193. 0x900a2,
  2194. 0x80001,
  2195. 0x80081,
  2196. 0x80041,
  2197. 0x900e2,
  2198. 0x70104,
  2199. 0x80059,
  2200. 0x80019,
  2201. 0x90092,
  2202. 0x70114,
  2203. 0x80079,
  2204. 0x80039,
  2205. 0x900d2,
  2206. 0x7010c,
  2207. 0x80069,
  2208. 0x80029,
  2209. 0x900b2,
  2210. 0x80009,
  2211. 0x80089,
  2212. 0x80049,
  2213. 0x900f2,
  2214. 0x70102,
  2215. 0x80055,
  2216. 0x80015,
  2217. 0x8011d,
  2218. 0x70112,
  2219. 0x80075,
  2220. 0x80035,
  2221. 0x900ca,
  2222. 0x7010a,
  2223. 0x80065,
  2224. 0x80025,
  2225. 0x900aa,
  2226. 0x80005,
  2227. 0x80085,
  2228. 0x80045,
  2229. 0x900ea,
  2230. 0x70106,
  2231. 0x8005d,
  2232. 0x8001d,
  2233. 0x9009a,
  2234. 0x70116,
  2235. 0x8007d,
  2236. 0x8003d,
  2237. 0x900da,
  2238. 0x7010e,
  2239. 0x8006d,
  2240. 0x8002d,
  2241. 0x900ba,
  2242. 0x8000d,
  2243. 0x8008d,
  2244. 0x8004d,
  2245. 0x900fa,
  2246. 0x70101,
  2247. 0x80053,
  2248. 0x80013,
  2249. 0x8011b,
  2250. 0x70111,
  2251. 0x80073,
  2252. 0x80033,
  2253. 0x900c6,
  2254. 0x70109,
  2255. 0x80063,
  2256. 0x80023,
  2257. 0x900a6,
  2258. 0x80003,
  2259. 0x80083,
  2260. 0x80043,
  2261. 0x900e6,
  2262. 0x70105,
  2263. 0x8005b,
  2264. 0x8001b,
  2265. 0x90096,
  2266. 0x70115,
  2267. 0x8007b,
  2268. 0x8003b,
  2269. 0x900d6,
  2270. 0x7010d,
  2271. 0x8006b,
  2272. 0x8002b,
  2273. 0x900b6,
  2274. 0x8000b,
  2275. 0x8008b,
  2276. 0x8004b,
  2277. 0x900f6,
  2278. 0x70103,
  2279. 0x80057,
  2280. 0x80017,
  2281. 0x8011f,
  2282. 0x70113,
  2283. 0x80077,
  2284. 0x80037,
  2285. 0x900ce,
  2286. 0x7010b,
  2287. 0x80067,
  2288. 0x80027,
  2289. 0x900ae,
  2290. 0x80007,
  2291. 0x80087,
  2292. 0x80047,
  2293. 0x900ee,
  2294. 0x70107,
  2295. 0x8005f,
  2296. 0x8001f,
  2297. 0x9009e,
  2298. 0x70117,
  2299. 0x8007f,
  2300. 0x8003f,
  2301. 0x900de,
  2302. 0x7010f,
  2303. 0x8006f,
  2304. 0x8002f,
  2305. 0x900be,
  2306. 0x8000f,
  2307. 0x8008f,
  2308. 0x8004f,
  2309. 0x900fe,
  2310. 0x70100,
  2311. 0x80050,
  2312. 0x80010,
  2313. 0x80118,
  2314. 0x70110,
  2315. 0x80070,
  2316. 0x80030,
  2317. 0x900c1,
  2318. 0x70108,
  2319. 0x80060,
  2320. 0x80020,
  2321. 0x900a1,
  2322. 0x80000,
  2323. 0x80080,
  2324. 0x80040,
  2325. 0x900e1,
  2326. 0x70104,
  2327. 0x80058,
  2328. 0x80018,
  2329. 0x90091,
  2330. 0x70114,
  2331. 0x80078,
  2332. 0x80038,
  2333. 0x900d1,
  2334. 0x7010c,
  2335. 0x80068,
  2336. 0x80028,
  2337. 0x900b1,
  2338. 0x80008,
  2339. 0x80088,
  2340. 0x80048,
  2341. 0x900f1,
  2342. 0x70102,
  2343. 0x80054,
  2344. 0x80014,
  2345. 0x8011c,
  2346. 0x70112,
  2347. 0x80074,
  2348. 0x80034,
  2349. 0x900c9,
  2350. 0x7010a,
  2351. 0x80064,
  2352. 0x80024,
  2353. 0x900a9,
  2354. 0x80004,
  2355. 0x80084,
  2356. 0x80044,
  2357. 0x900e9,
  2358. 0x70106,
  2359. 0x8005c,
  2360. 0x8001c,
  2361. 0x90099,
  2362. 0x70116,
  2363. 0x8007c,
  2364. 0x8003c,
  2365. 0x900d9,
  2366. 0x7010e,
  2367. 0x8006c,
  2368. 0x8002c,
  2369. 0x900b9,
  2370. 0x8000c,
  2371. 0x8008c,
  2372. 0x8004c,
  2373. 0x900f9,
  2374. 0x70101,
  2375. 0x80052,
  2376. 0x80012,
  2377. 0x8011a,
  2378. 0x70111,
  2379. 0x80072,
  2380. 0x80032,
  2381. 0x900c5,
  2382. 0x70109,
  2383. 0x80062,
  2384. 0x80022,
  2385. 0x900a5,
  2386. 0x80002,
  2387. 0x80082,
  2388. 0x80042,
  2389. 0x900e5,
  2390. 0x70105,
  2391. 0x8005a,
  2392. 0x8001a,
  2393. 0x90095,
  2394. 0x70115,
  2395. 0x8007a,
  2396. 0x8003a,
  2397. 0x900d5,
  2398. 0x7010d,
  2399. 0x8006a,
  2400. 0x8002a,
  2401. 0x900b5,
  2402. 0x8000a,
  2403. 0x8008a,
  2404. 0x8004a,
  2405. 0x900f5,
  2406. 0x70103,
  2407. 0x80056,
  2408. 0x80016,
  2409. 0x8011e,
  2410. 0x70113,
  2411. 0x80076,
  2412. 0x80036,
  2413. 0x900cd,
  2414. 0x7010b,
  2415. 0x80066,
  2416. 0x80026,
  2417. 0x900ad,
  2418. 0x80006,
  2419. 0x80086,
  2420. 0x80046,
  2421. 0x900ed,
  2422. 0x70107,
  2423. 0x8005e,
  2424. 0x8001e,
  2425. 0x9009d,
  2426. 0x70117,
  2427. 0x8007e,
  2428. 0x8003e,
  2429. 0x900dd,
  2430. 0x7010f,
  2431. 0x8006e,
  2432. 0x8002e,
  2433. 0x900bd,
  2434. 0x8000e,
  2435. 0x8008e,
  2436. 0x8004e,
  2437. 0x900fd,
  2438. 0x70100,
  2439. 0x80051,
  2440. 0x80011,
  2441. 0x80119,
  2442. 0x70110,
  2443. 0x80071,
  2444. 0x80031,
  2445. 0x900c3,
  2446. 0x70108,
  2447. 0x80061,
  2448. 0x80021,
  2449. 0x900a3,
  2450. 0x80001,
  2451. 0x80081,
  2452. 0x80041,
  2453. 0x900e3,
  2454. 0x70104,
  2455. 0x80059,
  2456. 0x80019,
  2457. 0x90093,
  2458. 0x70114,
  2459. 0x80079,
  2460. 0x80039,
  2461. 0x900d3,
  2462. 0x7010c,
  2463. 0x80069,
  2464. 0x80029,
  2465. 0x900b3,
  2466. 0x80009,
  2467. 0x80089,
  2468. 0x80049,
  2469. 0x900f3,
  2470. 0x70102,
  2471. 0x80055,
  2472. 0x80015,
  2473. 0x8011d,
  2474. 0x70112,
  2475. 0x80075,
  2476. 0x80035,
  2477. 0x900cb,
  2478. 0x7010a,
  2479. 0x80065,
  2480. 0x80025,
  2481. 0x900ab,
  2482. 0x80005,
  2483. 0x80085,
  2484. 0x80045,
  2485. 0x900eb,
  2486. 0x70106,
  2487. 0x8005d,
  2488. 0x8001d,
  2489. 0x9009b,
  2490. 0x70116,
  2491. 0x8007d,
  2492. 0x8003d,
  2493. 0x900db,
  2494. 0x7010e,
  2495. 0x8006d,
  2496. 0x8002d,
  2497. 0x900bb,
  2498. 0x8000d,
  2499. 0x8008d,
  2500. 0x8004d,
  2501. 0x900fb,
  2502. 0x70101,
  2503. 0x80053,
  2504. 0x80013,
  2505. 0x8011b,
  2506. 0x70111,
  2507. 0x80073,
  2508. 0x80033,
  2509. 0x900c7,
  2510. 0x70109,
  2511. 0x80063,
  2512. 0x80023,
  2513. 0x900a7,
  2514. 0x80003,
  2515. 0x80083,
  2516. 0x80043,
  2517. 0x900e7,
  2518. 0x70105,
  2519. 0x8005b,
  2520. 0x8001b,
  2521. 0x90097,
  2522. 0x70115,
  2523. 0x8007b,
  2524. 0x8003b,
  2525. 0x900d7,
  2526. 0x7010d,
  2527. 0x8006b,
  2528. 0x8002b,
  2529. 0x900b7,
  2530. 0x8000b,
  2531. 0x8008b,
  2532. 0x8004b,
  2533. 0x900f7,
  2534. 0x70103,
  2535. 0x80057,
  2536. 0x80017,
  2537. 0x8011f,
  2538. 0x70113,
  2539. 0x80077,
  2540. 0x80037,
  2541. 0x900cf,
  2542. 0x7010b,
  2543. 0x80067,
  2544. 0x80027,
  2545. 0x900af,
  2546. 0x80007,
  2547. 0x80087,
  2548. 0x80047,
  2549. 0x900ef,
  2550. 0x70107,
  2551. 0x8005f,
  2552. 0x8001f,
  2553. 0x9009f,
  2554. 0x70117,
  2555. 0x8007f,
  2556. 0x8003f,
  2557. 0x900df,
  2558. 0x7010f,
  2559. 0x8006f,
  2560. 0x8002f,
  2561. 0x900bf,
  2562. 0x8000f,
  2563. 0x8008f,
  2564. 0x8004f,
  2565. 0x900ff
  2566. ]),
  2567. 9
  2568. ];
  2569. var fixedDistCodeTab = [
  2570. new Int32Array([
  2571. 0x50000,
  2572. 0x50010,
  2573. 0x50008,
  2574. 0x50018,
  2575. 0x50004,
  2576. 0x50014,
  2577. 0x5000c,
  2578. 0x5001c,
  2579. 0x50002,
  2580. 0x50012,
  2581. 0x5000a,
  2582. 0x5001a,
  2583. 0x50006,
  2584. 0x50016,
  2585. 0x5000e,
  2586. 0x00000,
  2587. 0x50001,
  2588. 0x50011,
  2589. 0x50009,
  2590. 0x50019,
  2591. 0x50005,
  2592. 0x50015,
  2593. 0x5000d,
  2594. 0x5001d,
  2595. 0x50003,
  2596. 0x50013,
  2597. 0x5000b,
  2598. 0x5001b,
  2599. 0x50007,
  2600. 0x50017,
  2601. 0x5000f,
  2602. 0x00000
  2603. ]),
  2604. 5
  2605. ];
  2606. function FlateStream(str, maybeLength) {
  2607. this.str = str;
  2608. this.dict = str.dict;
  2609. var cmf = str.getByte();
  2610. var flg = str.getByte();
  2611. if (cmf === -1 || flg === -1) {
  2612. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  2613. }
  2614. if ((cmf & 0x0f) !== 0x08) {
  2615. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  2616. }
  2617. if (((cmf << 8) + flg) % 31 !== 0) {
  2618. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  2619. }
  2620. if (flg & 0x20) {
  2621. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  2622. }
  2623. this.codeSize = 0;
  2624. this.codeBuf = 0;
  2625. DecodeStream.call(this, maybeLength);
  2626. }
  2627. FlateStream.prototype = Object.create(DecodeStream.prototype);
  2628. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  2629. var str = this.str;
  2630. var codeSize = this.codeSize;
  2631. var codeBuf = this.codeBuf;
  2632. var b;
  2633. while (codeSize < bits) {
  2634. if ((b = str.getByte()) === -1) {
  2635. error('Bad encoding in flate stream');
  2636. }
  2637. codeBuf |= b << codeSize;
  2638. codeSize += 8;
  2639. }
  2640. b = codeBuf & (1 << bits) - 1;
  2641. this.codeBuf = codeBuf >> bits;
  2642. this.codeSize = codeSize -= bits;
  2643. return b;
  2644. };
  2645. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2646. var str = this.str;
  2647. var codes = table[0];
  2648. var maxLen = table[1];
  2649. var codeSize = this.codeSize;
  2650. var codeBuf = this.codeBuf;
  2651. var b;
  2652. while (codeSize < maxLen) {
  2653. if ((b = str.getByte()) === -1) {
  2654. break;
  2655. }
  2656. codeBuf |= b << codeSize;
  2657. codeSize += 8;
  2658. }
  2659. var code = codes[codeBuf & (1 << maxLen) - 1];
  2660. var codeLen = code >> 16;
  2661. var codeVal = code & 0xffff;
  2662. if (codeLen < 1 || codeSize < codeLen) {
  2663. error('Bad encoding in flate stream');
  2664. }
  2665. this.codeBuf = codeBuf >> codeLen;
  2666. this.codeSize = codeSize - codeLen;
  2667. return codeVal;
  2668. };
  2669. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2670. var n = lengths.length;
  2671. var maxLen = 0;
  2672. var i;
  2673. for (i = 0; i < n; ++i) {
  2674. if (lengths[i] > maxLen) {
  2675. maxLen = lengths[i];
  2676. }
  2677. }
  2678. var size = 1 << maxLen;
  2679. var codes = new Int32Array(size);
  2680. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2681. for (var val = 0; val < n; ++val) {
  2682. if (lengths[val] === len) {
  2683. var code2 = 0;
  2684. var t = code;
  2685. for (i = 0; i < len; ++i) {
  2686. code2 = code2 << 1 | t & 1;
  2687. t >>= 1;
  2688. }
  2689. for (i = code2; i < size; i += skip) {
  2690. codes[i] = len << 16 | val;
  2691. }
  2692. ++code;
  2693. }
  2694. }
  2695. }
  2696. return [
  2697. codes,
  2698. maxLen
  2699. ];
  2700. };
  2701. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2702. var buffer, len;
  2703. var str = this.str;
  2704. var hdr = this.getBits(3);
  2705. if (hdr & 1) {
  2706. this.eof = true;
  2707. }
  2708. hdr >>= 1;
  2709. if (hdr === 0) {
  2710. var b;
  2711. if ((b = str.getByte()) === -1) {
  2712. error('Bad block header in flate stream');
  2713. }
  2714. var blockLen = b;
  2715. if ((b = str.getByte()) === -1) {
  2716. error('Bad block header in flate stream');
  2717. }
  2718. blockLen |= b << 8;
  2719. if ((b = str.getByte()) === -1) {
  2720. error('Bad block header in flate stream');
  2721. }
  2722. var check = b;
  2723. if ((b = str.getByte()) === -1) {
  2724. error('Bad block header in flate stream');
  2725. }
  2726. check |= b << 8;
  2727. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2728. error('Bad uncompressed block length in flate stream');
  2729. }
  2730. this.codeBuf = 0;
  2731. this.codeSize = 0;
  2732. var bufferLength = this.bufferLength;
  2733. buffer = this.ensureBuffer(bufferLength + blockLen);
  2734. var end = bufferLength + blockLen;
  2735. this.bufferLength = end;
  2736. if (blockLen === 0) {
  2737. if (str.peekByte() === -1) {
  2738. this.eof = true;
  2739. }
  2740. } else {
  2741. for (var n = bufferLength; n < end; ++n) {
  2742. if ((b = str.getByte()) === -1) {
  2743. this.eof = true;
  2744. break;
  2745. }
  2746. buffer[n] = b;
  2747. }
  2748. }
  2749. return;
  2750. }
  2751. var litCodeTable;
  2752. var distCodeTable;
  2753. if (hdr === 1) {
  2754. litCodeTable = fixedLitCodeTab;
  2755. distCodeTable = fixedDistCodeTab;
  2756. } else if (hdr === 2) {
  2757. var numLitCodes = this.getBits(5) + 257;
  2758. var numDistCodes = this.getBits(5) + 1;
  2759. var numCodeLenCodes = this.getBits(4) + 4;
  2760. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2761. var i;
  2762. for (i = 0; i < numCodeLenCodes; ++i) {
  2763. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2764. }
  2765. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2766. len = 0;
  2767. i = 0;
  2768. var codes = numLitCodes + numDistCodes;
  2769. var codeLengths = new Uint8Array(codes);
  2770. var bitsLength, bitsOffset, what;
  2771. while (i < codes) {
  2772. var code = this.getCode(codeLenCodeTab);
  2773. if (code === 16) {
  2774. bitsLength = 2;
  2775. bitsOffset = 3;
  2776. what = len;
  2777. } else if (code === 17) {
  2778. bitsLength = 3;
  2779. bitsOffset = 3;
  2780. what = len = 0;
  2781. } else if (code === 18) {
  2782. bitsLength = 7;
  2783. bitsOffset = 11;
  2784. what = len = 0;
  2785. } else {
  2786. codeLengths[i++] = len = code;
  2787. continue;
  2788. }
  2789. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2790. while (repeatLength-- > 0) {
  2791. codeLengths[i++] = what;
  2792. }
  2793. }
  2794. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2795. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2796. } else {
  2797. error('Unknown block type in flate stream');
  2798. }
  2799. buffer = this.buffer;
  2800. var limit = buffer ? buffer.length : 0;
  2801. var pos = this.bufferLength;
  2802. while (true) {
  2803. var code1 = this.getCode(litCodeTable);
  2804. if (code1 < 256) {
  2805. if (pos + 1 >= limit) {
  2806. buffer = this.ensureBuffer(pos + 1);
  2807. limit = buffer.length;
  2808. }
  2809. buffer[pos++] = code1;
  2810. continue;
  2811. }
  2812. if (code1 === 256) {
  2813. this.bufferLength = pos;
  2814. return;
  2815. }
  2816. code1 -= 257;
  2817. code1 = lengthDecode[code1];
  2818. var code2 = code1 >> 16;
  2819. if (code2 > 0) {
  2820. code2 = this.getBits(code2);
  2821. }
  2822. len = (code1 & 0xffff) + code2;
  2823. code1 = this.getCode(distCodeTable);
  2824. code1 = distDecode[code1];
  2825. code2 = code1 >> 16;
  2826. if (code2 > 0) {
  2827. code2 = this.getBits(code2);
  2828. }
  2829. var dist = (code1 & 0xffff) + code2;
  2830. if (pos + len >= limit) {
  2831. buffer = this.ensureBuffer(pos + len);
  2832. limit = buffer.length;
  2833. }
  2834. for (var k = 0; k < len; ++k, ++pos) {
  2835. buffer[pos] = buffer[pos - dist];
  2836. }
  2837. }
  2838. };
  2839. return FlateStream;
  2840. }();
  2841. var PredictorStream = function PredictorStreamClosure() {
  2842. function PredictorStream(str, maybeLength, params) {
  2843. if (!isDict(params)) {
  2844. return str;
  2845. }
  2846. var predictor = this.predictor = params.get('Predictor') || 1;
  2847. if (predictor <= 1) {
  2848. return str;
  2849. }
  2850. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2851. error('Unsupported predictor: ' + predictor);
  2852. }
  2853. if (predictor === 2) {
  2854. this.readBlock = this.readBlockTiff;
  2855. } else {
  2856. this.readBlock = this.readBlockPng;
  2857. }
  2858. this.str = str;
  2859. this.dict = str.dict;
  2860. var colors = this.colors = params.get('Colors') || 1;
  2861. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2862. var columns = this.columns = params.get('Columns') || 1;
  2863. this.pixBytes = colors * bits + 7 >> 3;
  2864. this.rowBytes = columns * colors * bits + 7 >> 3;
  2865. DecodeStream.call(this, maybeLength);
  2866. return this;
  2867. }
  2868. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2869. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2870. var rowBytes = this.rowBytes;
  2871. var bufferLength = this.bufferLength;
  2872. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2873. var bits = this.bits;
  2874. var colors = this.colors;
  2875. var rawBytes = this.str.getBytes(rowBytes);
  2876. this.eof = !rawBytes.length;
  2877. if (this.eof) {
  2878. return;
  2879. }
  2880. var inbuf = 0, outbuf = 0;
  2881. var inbits = 0, outbits = 0;
  2882. var pos = bufferLength;
  2883. var i;
  2884. if (bits === 1 && colors === 1) {
  2885. for (i = 0; i < rowBytes; ++i) {
  2886. var c = rawBytes[i] ^ inbuf;
  2887. c ^= c >> 1;
  2888. c ^= c >> 2;
  2889. c ^= c >> 4;
  2890. inbuf = (c & 1) << 7;
  2891. buffer[pos++] = c;
  2892. }
  2893. } else if (bits === 8) {
  2894. for (i = 0; i < colors; ++i) {
  2895. buffer[pos++] = rawBytes[i];
  2896. }
  2897. for (; i < rowBytes; ++i) {
  2898. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2899. pos++;
  2900. }
  2901. } else {
  2902. var compArray = new Uint8Array(colors + 1);
  2903. var bitMask = (1 << bits) - 1;
  2904. var j = 0, k = bufferLength;
  2905. var columns = this.columns;
  2906. for (i = 0; i < columns; ++i) {
  2907. for (var kk = 0; kk < colors; ++kk) {
  2908. if (inbits < bits) {
  2909. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2910. inbits += 8;
  2911. }
  2912. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2913. inbits -= bits;
  2914. outbuf = outbuf << bits | compArray[kk];
  2915. outbits += bits;
  2916. if (outbits >= 8) {
  2917. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2918. outbits -= 8;
  2919. }
  2920. }
  2921. }
  2922. if (outbits > 0) {
  2923. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2924. }
  2925. }
  2926. this.bufferLength += rowBytes;
  2927. };
  2928. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2929. var rowBytes = this.rowBytes;
  2930. var pixBytes = this.pixBytes;
  2931. var predictor = this.str.getByte();
  2932. var rawBytes = this.str.getBytes(rowBytes);
  2933. this.eof = !rawBytes.length;
  2934. if (this.eof) {
  2935. return;
  2936. }
  2937. var bufferLength = this.bufferLength;
  2938. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2939. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2940. if (prevRow.length === 0) {
  2941. prevRow = new Uint8Array(rowBytes);
  2942. }
  2943. var i, j = bufferLength, up, c;
  2944. switch (predictor) {
  2945. case 0:
  2946. for (i = 0; i < rowBytes; ++i) {
  2947. buffer[j++] = rawBytes[i];
  2948. }
  2949. break;
  2950. case 1:
  2951. for (i = 0; i < pixBytes; ++i) {
  2952. buffer[j++] = rawBytes[i];
  2953. }
  2954. for (; i < rowBytes; ++i) {
  2955. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2956. j++;
  2957. }
  2958. break;
  2959. case 2:
  2960. for (i = 0; i < rowBytes; ++i) {
  2961. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2962. }
  2963. break;
  2964. case 3:
  2965. for (i = 0; i < pixBytes; ++i) {
  2966. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2967. }
  2968. for (; i < rowBytes; ++i) {
  2969. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2970. j++;
  2971. }
  2972. break;
  2973. case 4:
  2974. for (i = 0; i < pixBytes; ++i) {
  2975. up = prevRow[i];
  2976. c = rawBytes[i];
  2977. buffer[j++] = up + c;
  2978. }
  2979. for (; i < rowBytes; ++i) {
  2980. up = prevRow[i];
  2981. var upLeft = prevRow[i - pixBytes];
  2982. var left = buffer[j - pixBytes];
  2983. var p = left + up - upLeft;
  2984. var pa = p - left;
  2985. if (pa < 0) {
  2986. pa = -pa;
  2987. }
  2988. var pb = p - up;
  2989. if (pb < 0) {
  2990. pb = -pb;
  2991. }
  2992. var pc = p - upLeft;
  2993. if (pc < 0) {
  2994. pc = -pc;
  2995. }
  2996. c = rawBytes[i];
  2997. if (pa <= pb && pa <= pc) {
  2998. buffer[j++] = left + c;
  2999. } else if (pb <= pc) {
  3000. buffer[j++] = up + c;
  3001. } else {
  3002. buffer[j++] = upLeft + c;
  3003. }
  3004. }
  3005. break;
  3006. default:
  3007. error('Unsupported predictor: ' + predictor);
  3008. }
  3009. this.bufferLength += rowBytes;
  3010. };
  3011. return PredictorStream;
  3012. }();
  3013. var JpegStream = function JpegStreamClosure() {
  3014. function JpegStream(stream, maybeLength, dict, params) {
  3015. var ch;
  3016. while ((ch = stream.getByte()) !== -1) {
  3017. if (ch === 0xFF) {
  3018. stream.skip(-1);
  3019. break;
  3020. }
  3021. }
  3022. this.stream = stream;
  3023. this.maybeLength = maybeLength;
  3024. this.dict = dict;
  3025. this.params = params;
  3026. DecodeStream.call(this, maybeLength);
  3027. }
  3028. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3029. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3030. get: function JpegStream_bytes() {
  3031. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3032. },
  3033. configurable: true
  3034. });
  3035. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3036. if (this.bufferLength) {
  3037. return;
  3038. }
  3039. var jpegImage = new JpegImage();
  3040. var decodeArr = this.dict.getArray('Decode', 'D');
  3041. if (this.forceRGB && isArray(decodeArr)) {
  3042. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3043. var decodeArrLength = decodeArr.length;
  3044. var transform = new Int32Array(decodeArrLength);
  3045. var transformNeeded = false;
  3046. var maxValue = (1 << bitsPerComponent) - 1;
  3047. for (var i = 0; i < decodeArrLength; i += 2) {
  3048. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3049. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3050. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3051. transformNeeded = true;
  3052. }
  3053. }
  3054. if (transformNeeded) {
  3055. jpegImage.decodeTransform = transform;
  3056. }
  3057. }
  3058. if (isDict(this.params)) {
  3059. var colorTransform = this.params.get('ColorTransform');
  3060. if (isInt(colorTransform)) {
  3061. jpegImage.colorTransform = colorTransform;
  3062. }
  3063. }
  3064. jpegImage.parse(this.bytes);
  3065. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3066. this.buffer = data;
  3067. this.bufferLength = data.length;
  3068. this.eof = true;
  3069. };
  3070. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3071. this.ensureBuffer();
  3072. return this.buffer;
  3073. };
  3074. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3075. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3076. };
  3077. return JpegStream;
  3078. }();
  3079. var JpxStream = function JpxStreamClosure() {
  3080. function JpxStream(stream, maybeLength, dict, params) {
  3081. this.stream = stream;
  3082. this.maybeLength = maybeLength;
  3083. this.dict = dict;
  3084. this.params = params;
  3085. DecodeStream.call(this, maybeLength);
  3086. }
  3087. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3088. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3089. get: function JpxStream_bytes() {
  3090. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3091. },
  3092. configurable: true
  3093. });
  3094. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3095. if (this.bufferLength) {
  3096. return;
  3097. }
  3098. var jpxImage = new JpxImage();
  3099. jpxImage.parse(this.bytes);
  3100. var width = jpxImage.width;
  3101. var height = jpxImage.height;
  3102. var componentsCount = jpxImage.componentsCount;
  3103. var tileCount = jpxImage.tiles.length;
  3104. if (tileCount === 1) {
  3105. this.buffer = jpxImage.tiles[0].items;
  3106. } else {
  3107. var data = new Uint8Array(width * height * componentsCount);
  3108. for (var k = 0; k < tileCount; k++) {
  3109. var tileComponents = jpxImage.tiles[k];
  3110. var tileWidth = tileComponents.width;
  3111. var tileHeight = tileComponents.height;
  3112. var tileLeft = tileComponents.left;
  3113. var tileTop = tileComponents.top;
  3114. var src = tileComponents.items;
  3115. var srcPosition = 0;
  3116. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3117. var imgRowSize = width * componentsCount;
  3118. var tileRowSize = tileWidth * componentsCount;
  3119. for (var j = 0; j < tileHeight; j++) {
  3120. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3121. data.set(rowBytes, dataPosition);
  3122. srcPosition += tileRowSize;
  3123. dataPosition += imgRowSize;
  3124. }
  3125. }
  3126. this.buffer = data;
  3127. }
  3128. this.bufferLength = this.buffer.length;
  3129. this.eof = true;
  3130. };
  3131. return JpxStream;
  3132. }();
  3133. var Jbig2Stream = function Jbig2StreamClosure() {
  3134. function Jbig2Stream(stream, maybeLength, dict, params) {
  3135. this.stream = stream;
  3136. this.maybeLength = maybeLength;
  3137. this.dict = dict;
  3138. this.params = params;
  3139. DecodeStream.call(this, maybeLength);
  3140. }
  3141. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3142. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3143. get: function Jbig2Stream_bytes() {
  3144. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3145. },
  3146. configurable: true
  3147. });
  3148. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3149. if (this.bufferLength) {
  3150. return;
  3151. }
  3152. var jbig2Image = new Jbig2Image();
  3153. var chunks = [];
  3154. if (isDict(this.params)) {
  3155. var globalsStream = this.params.get('JBIG2Globals');
  3156. if (isStream(globalsStream)) {
  3157. var globals = globalsStream.getBytes();
  3158. chunks.push({
  3159. data: globals,
  3160. start: 0,
  3161. end: globals.length
  3162. });
  3163. }
  3164. }
  3165. chunks.push({
  3166. data: this.bytes,
  3167. start: 0,
  3168. end: this.bytes.length
  3169. });
  3170. var data = jbig2Image.parseChunks(chunks);
  3171. var dataLength = data.length;
  3172. for (var i = 0; i < dataLength; i++) {
  3173. data[i] ^= 0xFF;
  3174. }
  3175. this.buffer = data;
  3176. this.bufferLength = dataLength;
  3177. this.eof = true;
  3178. };
  3179. return Jbig2Stream;
  3180. }();
  3181. var DecryptStream = function DecryptStreamClosure() {
  3182. function DecryptStream(str, maybeLength, decrypt) {
  3183. this.str = str;
  3184. this.dict = str.dict;
  3185. this.decrypt = decrypt;
  3186. this.nextChunk = null;
  3187. this.initialized = false;
  3188. DecodeStream.call(this, maybeLength);
  3189. }
  3190. var chunkSize = 512;
  3191. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  3192. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  3193. var chunk;
  3194. if (this.initialized) {
  3195. chunk = this.nextChunk;
  3196. } else {
  3197. chunk = this.str.getBytes(chunkSize);
  3198. this.initialized = true;
  3199. }
  3200. if (!chunk || chunk.length === 0) {
  3201. this.eof = true;
  3202. return;
  3203. }
  3204. this.nextChunk = this.str.getBytes(chunkSize);
  3205. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  3206. var decrypt = this.decrypt;
  3207. chunk = decrypt(chunk, !hasMoreData);
  3208. var bufferLength = this.bufferLength;
  3209. var i, n = chunk.length;
  3210. var buffer = this.ensureBuffer(bufferLength + n);
  3211. for (i = 0; i < n; i++) {
  3212. buffer[bufferLength++] = chunk[i];
  3213. }
  3214. this.bufferLength = bufferLength;
  3215. };
  3216. return DecryptStream;
  3217. }();
  3218. var Ascii85Stream = function Ascii85StreamClosure() {
  3219. function Ascii85Stream(str, maybeLength) {
  3220. this.str = str;
  3221. this.dict = str.dict;
  3222. this.input = new Uint8Array(5);
  3223. if (maybeLength) {
  3224. maybeLength = 0.8 * maybeLength;
  3225. }
  3226. DecodeStream.call(this, maybeLength);
  3227. }
  3228. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  3229. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  3230. var TILDA_CHAR = 0x7E;
  3231. var Z_LOWER_CHAR = 0x7A;
  3232. var EOF = -1;
  3233. var str = this.str;
  3234. var c = str.getByte();
  3235. while (isSpace(c)) {
  3236. c = str.getByte();
  3237. }
  3238. if (c === EOF || c === TILDA_CHAR) {
  3239. this.eof = true;
  3240. return;
  3241. }
  3242. var bufferLength = this.bufferLength, buffer;
  3243. var i;
  3244. if (c === Z_LOWER_CHAR) {
  3245. buffer = this.ensureBuffer(bufferLength + 4);
  3246. for (i = 0; i < 4; ++i) {
  3247. buffer[bufferLength + i] = 0;
  3248. }
  3249. this.bufferLength += 4;
  3250. } else {
  3251. var input = this.input;
  3252. input[0] = c;
  3253. for (i = 1; i < 5; ++i) {
  3254. c = str.getByte();
  3255. while (isSpace(c)) {
  3256. c = str.getByte();
  3257. }
  3258. input[i] = c;
  3259. if (c === EOF || c === TILDA_CHAR) {
  3260. break;
  3261. }
  3262. }
  3263. buffer = this.ensureBuffer(bufferLength + i - 1);
  3264. this.bufferLength += i - 1;
  3265. if (i < 5) {
  3266. for (; i < 5; ++i) {
  3267. input[i] = 0x21 + 84;
  3268. }
  3269. this.eof = true;
  3270. }
  3271. var t = 0;
  3272. for (i = 0; i < 5; ++i) {
  3273. t = t * 85 + (input[i] - 0x21);
  3274. }
  3275. for (i = 3; i >= 0; --i) {
  3276. buffer[bufferLength + i] = t & 0xFF;
  3277. t >>= 8;
  3278. }
  3279. }
  3280. };
  3281. return Ascii85Stream;
  3282. }();
  3283. var AsciiHexStream = function AsciiHexStreamClosure() {
  3284. function AsciiHexStream(str, maybeLength) {
  3285. this.str = str;
  3286. this.dict = str.dict;
  3287. this.firstDigit = -1;
  3288. if (maybeLength) {
  3289. maybeLength = 0.5 * maybeLength;
  3290. }
  3291. DecodeStream.call(this, maybeLength);
  3292. }
  3293. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  3294. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  3295. var UPSTREAM_BLOCK_SIZE = 8000;
  3296. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  3297. if (!bytes.length) {
  3298. this.eof = true;
  3299. return;
  3300. }
  3301. var maxDecodeLength = bytes.length + 1 >> 1;
  3302. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  3303. var bufferLength = this.bufferLength;
  3304. var firstDigit = this.firstDigit;
  3305. for (var i = 0, ii = bytes.length; i < ii; i++) {
  3306. var ch = bytes[i], digit;
  3307. if (ch >= 0x30 && ch <= 0x39) {
  3308. digit = ch & 0x0F;
  3309. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  3310. digit = (ch & 0x0F) + 9;
  3311. } else if (ch === 0x3E) {
  3312. this.eof = true;
  3313. break;
  3314. } else {
  3315. continue;
  3316. }
  3317. if (firstDigit < 0) {
  3318. firstDigit = digit;
  3319. } else {
  3320. buffer[bufferLength++] = firstDigit << 4 | digit;
  3321. firstDigit = -1;
  3322. }
  3323. }
  3324. if (firstDigit >= 0 && this.eof) {
  3325. buffer[bufferLength++] = firstDigit << 4;
  3326. firstDigit = -1;
  3327. }
  3328. this.firstDigit = firstDigit;
  3329. this.bufferLength = bufferLength;
  3330. };
  3331. return AsciiHexStream;
  3332. }();
  3333. var RunLengthStream = function RunLengthStreamClosure() {
  3334. function RunLengthStream(str, maybeLength) {
  3335. this.str = str;
  3336. this.dict = str.dict;
  3337. DecodeStream.call(this, maybeLength);
  3338. }
  3339. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  3340. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  3341. var repeatHeader = this.str.getBytes(2);
  3342. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  3343. this.eof = true;
  3344. return;
  3345. }
  3346. var buffer;
  3347. var bufferLength = this.bufferLength;
  3348. var n = repeatHeader[0];
  3349. if (n < 128) {
  3350. buffer = this.ensureBuffer(bufferLength + n + 1);
  3351. buffer[bufferLength++] = repeatHeader[1];
  3352. if (n > 0) {
  3353. var source = this.str.getBytes(n);
  3354. buffer.set(source, bufferLength);
  3355. bufferLength += n;
  3356. }
  3357. } else {
  3358. n = 257 - n;
  3359. var b = repeatHeader[1];
  3360. buffer = this.ensureBuffer(bufferLength + n + 1);
  3361. for (var i = 0; i < n; i++) {
  3362. buffer[bufferLength++] = b;
  3363. }
  3364. }
  3365. this.bufferLength = bufferLength;
  3366. };
  3367. return RunLengthStream;
  3368. }();
  3369. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  3370. var ccittEOL = -2;
  3371. var ccittEOF = -1;
  3372. var twoDimPass = 0;
  3373. var twoDimHoriz = 1;
  3374. var twoDimVert0 = 2;
  3375. var twoDimVertR1 = 3;
  3376. var twoDimVertL1 = 4;
  3377. var twoDimVertR2 = 5;
  3378. var twoDimVertL2 = 6;
  3379. var twoDimVertR3 = 7;
  3380. var twoDimVertL3 = 8;
  3381. var twoDimTable = [
  3382. [
  3383. -1,
  3384. -1
  3385. ],
  3386. [
  3387. -1,
  3388. -1
  3389. ],
  3390. [
  3391. 7,
  3392. twoDimVertL3
  3393. ],
  3394. [
  3395. 7,
  3396. twoDimVertR3
  3397. ],
  3398. [
  3399. 6,
  3400. twoDimVertL2
  3401. ],
  3402. [
  3403. 6,
  3404. twoDimVertL2
  3405. ],
  3406. [
  3407. 6,
  3408. twoDimVertR2
  3409. ],
  3410. [
  3411. 6,
  3412. twoDimVertR2
  3413. ],
  3414. [
  3415. 4,
  3416. twoDimPass
  3417. ],
  3418. [
  3419. 4,
  3420. twoDimPass
  3421. ],
  3422. [
  3423. 4,
  3424. twoDimPass
  3425. ],
  3426. [
  3427. 4,
  3428. twoDimPass
  3429. ],
  3430. [
  3431. 4,
  3432. twoDimPass
  3433. ],
  3434. [
  3435. 4,
  3436. twoDimPass
  3437. ],
  3438. [
  3439. 4,
  3440. twoDimPass
  3441. ],
  3442. [
  3443. 4,
  3444. twoDimPass
  3445. ],
  3446. [
  3447. 3,
  3448. twoDimHoriz
  3449. ],
  3450. [
  3451. 3,
  3452. twoDimHoriz
  3453. ],
  3454. [
  3455. 3,
  3456. twoDimHoriz
  3457. ],
  3458. [
  3459. 3,
  3460. twoDimHoriz
  3461. ],
  3462. [
  3463. 3,
  3464. twoDimHoriz
  3465. ],
  3466. [
  3467. 3,
  3468. twoDimHoriz
  3469. ],
  3470. [
  3471. 3,
  3472. twoDimHoriz
  3473. ],
  3474. [
  3475. 3,
  3476. twoDimHoriz
  3477. ],
  3478. [
  3479. 3,
  3480. twoDimHoriz
  3481. ],
  3482. [
  3483. 3,
  3484. twoDimHoriz
  3485. ],
  3486. [
  3487. 3,
  3488. twoDimHoriz
  3489. ],
  3490. [
  3491. 3,
  3492. twoDimHoriz
  3493. ],
  3494. [
  3495. 3,
  3496. twoDimHoriz
  3497. ],
  3498. [
  3499. 3,
  3500. twoDimHoriz
  3501. ],
  3502. [
  3503. 3,
  3504. twoDimHoriz
  3505. ],
  3506. [
  3507. 3,
  3508. twoDimHoriz
  3509. ],
  3510. [
  3511. 3,
  3512. twoDimVertL1
  3513. ],
  3514. [
  3515. 3,
  3516. twoDimVertL1
  3517. ],
  3518. [
  3519. 3,
  3520. twoDimVertL1
  3521. ],
  3522. [
  3523. 3,
  3524. twoDimVertL1
  3525. ],
  3526. [
  3527. 3,
  3528. twoDimVertL1
  3529. ],
  3530. [
  3531. 3,
  3532. twoDimVertL1
  3533. ],
  3534. [
  3535. 3,
  3536. twoDimVertL1
  3537. ],
  3538. [
  3539. 3,
  3540. twoDimVertL1
  3541. ],
  3542. [
  3543. 3,
  3544. twoDimVertL1
  3545. ],
  3546. [
  3547. 3,
  3548. twoDimVertL1
  3549. ],
  3550. [
  3551. 3,
  3552. twoDimVertL1
  3553. ],
  3554. [
  3555. 3,
  3556. twoDimVertL1
  3557. ],
  3558. [
  3559. 3,
  3560. twoDimVertL1
  3561. ],
  3562. [
  3563. 3,
  3564. twoDimVertL1
  3565. ],
  3566. [
  3567. 3,
  3568. twoDimVertL1
  3569. ],
  3570. [
  3571. 3,
  3572. twoDimVertL1
  3573. ],
  3574. [
  3575. 3,
  3576. twoDimVertR1
  3577. ],
  3578. [
  3579. 3,
  3580. twoDimVertR1
  3581. ],
  3582. [
  3583. 3,
  3584. twoDimVertR1
  3585. ],
  3586. [
  3587. 3,
  3588. twoDimVertR1
  3589. ],
  3590. [
  3591. 3,
  3592. twoDimVertR1
  3593. ],
  3594. [
  3595. 3,
  3596. twoDimVertR1
  3597. ],
  3598. [
  3599. 3,
  3600. twoDimVertR1
  3601. ],
  3602. [
  3603. 3,
  3604. twoDimVertR1
  3605. ],
  3606. [
  3607. 3,
  3608. twoDimVertR1
  3609. ],
  3610. [
  3611. 3,
  3612. twoDimVertR1
  3613. ],
  3614. [
  3615. 3,
  3616. twoDimVertR1
  3617. ],
  3618. [
  3619. 3,
  3620. twoDimVertR1
  3621. ],
  3622. [
  3623. 3,
  3624. twoDimVertR1
  3625. ],
  3626. [
  3627. 3,
  3628. twoDimVertR1
  3629. ],
  3630. [
  3631. 3,
  3632. twoDimVertR1
  3633. ],
  3634. [
  3635. 3,
  3636. twoDimVertR1
  3637. ],
  3638. [
  3639. 1,
  3640. twoDimVert0
  3641. ],
  3642. [
  3643. 1,
  3644. twoDimVert0
  3645. ],
  3646. [
  3647. 1,
  3648. twoDimVert0
  3649. ],
  3650. [
  3651. 1,
  3652. twoDimVert0
  3653. ],
  3654. [
  3655. 1,
  3656. twoDimVert0
  3657. ],
  3658. [
  3659. 1,
  3660. twoDimVert0
  3661. ],
  3662. [
  3663. 1,
  3664. twoDimVert0
  3665. ],
  3666. [
  3667. 1,
  3668. twoDimVert0
  3669. ],
  3670. [
  3671. 1,
  3672. twoDimVert0
  3673. ],
  3674. [
  3675. 1,
  3676. twoDimVert0
  3677. ],
  3678. [
  3679. 1,
  3680. twoDimVert0
  3681. ],
  3682. [
  3683. 1,
  3684. twoDimVert0
  3685. ],
  3686. [
  3687. 1,
  3688. twoDimVert0
  3689. ],
  3690. [
  3691. 1,
  3692. twoDimVert0
  3693. ],
  3694. [
  3695. 1,
  3696. twoDimVert0
  3697. ],
  3698. [
  3699. 1,
  3700. twoDimVert0
  3701. ],
  3702. [
  3703. 1,
  3704. twoDimVert0
  3705. ],
  3706. [
  3707. 1,
  3708. twoDimVert0
  3709. ],
  3710. [
  3711. 1,
  3712. twoDimVert0
  3713. ],
  3714. [
  3715. 1,
  3716. twoDimVert0
  3717. ],
  3718. [
  3719. 1,
  3720. twoDimVert0
  3721. ],
  3722. [
  3723. 1,
  3724. twoDimVert0
  3725. ],
  3726. [
  3727. 1,
  3728. twoDimVert0
  3729. ],
  3730. [
  3731. 1,
  3732. twoDimVert0
  3733. ],
  3734. [
  3735. 1,
  3736. twoDimVert0
  3737. ],
  3738. [
  3739. 1,
  3740. twoDimVert0
  3741. ],
  3742. [
  3743. 1,
  3744. twoDimVert0
  3745. ],
  3746. [
  3747. 1,
  3748. twoDimVert0
  3749. ],
  3750. [
  3751. 1,
  3752. twoDimVert0
  3753. ],
  3754. [
  3755. 1,
  3756. twoDimVert0
  3757. ],
  3758. [
  3759. 1,
  3760. twoDimVert0
  3761. ],
  3762. [
  3763. 1,
  3764. twoDimVert0
  3765. ],
  3766. [
  3767. 1,
  3768. twoDimVert0
  3769. ],
  3770. [
  3771. 1,
  3772. twoDimVert0
  3773. ],
  3774. [
  3775. 1,
  3776. twoDimVert0
  3777. ],
  3778. [
  3779. 1,
  3780. twoDimVert0
  3781. ],
  3782. [
  3783. 1,
  3784. twoDimVert0
  3785. ],
  3786. [
  3787. 1,
  3788. twoDimVert0
  3789. ],
  3790. [
  3791. 1,
  3792. twoDimVert0
  3793. ],
  3794. [
  3795. 1,
  3796. twoDimVert0
  3797. ],
  3798. [
  3799. 1,
  3800. twoDimVert0
  3801. ],
  3802. [
  3803. 1,
  3804. twoDimVert0
  3805. ],
  3806. [
  3807. 1,
  3808. twoDimVert0
  3809. ],
  3810. [
  3811. 1,
  3812. twoDimVert0
  3813. ],
  3814. [
  3815. 1,
  3816. twoDimVert0
  3817. ],
  3818. [
  3819. 1,
  3820. twoDimVert0
  3821. ],
  3822. [
  3823. 1,
  3824. twoDimVert0
  3825. ],
  3826. [
  3827. 1,
  3828. twoDimVert0
  3829. ],
  3830. [
  3831. 1,
  3832. twoDimVert0
  3833. ],
  3834. [
  3835. 1,
  3836. twoDimVert0
  3837. ],
  3838. [
  3839. 1,
  3840. twoDimVert0
  3841. ],
  3842. [
  3843. 1,
  3844. twoDimVert0
  3845. ],
  3846. [
  3847. 1,
  3848. twoDimVert0
  3849. ],
  3850. [
  3851. 1,
  3852. twoDimVert0
  3853. ],
  3854. [
  3855. 1,
  3856. twoDimVert0
  3857. ],
  3858. [
  3859. 1,
  3860. twoDimVert0
  3861. ],
  3862. [
  3863. 1,
  3864. twoDimVert0
  3865. ],
  3866. [
  3867. 1,
  3868. twoDimVert0
  3869. ],
  3870. [
  3871. 1,
  3872. twoDimVert0
  3873. ],
  3874. [
  3875. 1,
  3876. twoDimVert0
  3877. ],
  3878. [
  3879. 1,
  3880. twoDimVert0
  3881. ],
  3882. [
  3883. 1,
  3884. twoDimVert0
  3885. ],
  3886. [
  3887. 1,
  3888. twoDimVert0
  3889. ],
  3890. [
  3891. 1,
  3892. twoDimVert0
  3893. ]
  3894. ];
  3895. var whiteTable1 = [
  3896. [
  3897. -1,
  3898. -1
  3899. ],
  3900. [
  3901. 12,
  3902. ccittEOL
  3903. ],
  3904. [
  3905. -1,
  3906. -1
  3907. ],
  3908. [
  3909. -1,
  3910. -1
  3911. ],
  3912. [
  3913. -1,
  3914. -1
  3915. ],
  3916. [
  3917. -1,
  3918. -1
  3919. ],
  3920. [
  3921. -1,
  3922. -1
  3923. ],
  3924. [
  3925. -1,
  3926. -1
  3927. ],
  3928. [
  3929. -1,
  3930. -1
  3931. ],
  3932. [
  3933. -1,
  3934. -1
  3935. ],
  3936. [
  3937. -1,
  3938. -1
  3939. ],
  3940. [
  3941. -1,
  3942. -1
  3943. ],
  3944. [
  3945. -1,
  3946. -1
  3947. ],
  3948. [
  3949. -1,
  3950. -1
  3951. ],
  3952. [
  3953. -1,
  3954. -1
  3955. ],
  3956. [
  3957. -1,
  3958. -1
  3959. ],
  3960. [
  3961. 11,
  3962. 1792
  3963. ],
  3964. [
  3965. 11,
  3966. 1792
  3967. ],
  3968. [
  3969. 12,
  3970. 1984
  3971. ],
  3972. [
  3973. 12,
  3974. 2048
  3975. ],
  3976. [
  3977. 12,
  3978. 2112
  3979. ],
  3980. [
  3981. 12,
  3982. 2176
  3983. ],
  3984. [
  3985. 12,
  3986. 2240
  3987. ],
  3988. [
  3989. 12,
  3990. 2304
  3991. ],
  3992. [
  3993. 11,
  3994. 1856
  3995. ],
  3996. [
  3997. 11,
  3998. 1856
  3999. ],
  4000. [
  4001. 11,
  4002. 1920
  4003. ],
  4004. [
  4005. 11,
  4006. 1920
  4007. ],
  4008. [
  4009. 12,
  4010. 2368
  4011. ],
  4012. [
  4013. 12,
  4014. 2432
  4015. ],
  4016. [
  4017. 12,
  4018. 2496
  4019. ],
  4020. [
  4021. 12,
  4022. 2560
  4023. ]
  4024. ];
  4025. var whiteTable2 = [
  4026. [
  4027. -1,
  4028. -1
  4029. ],
  4030. [
  4031. -1,
  4032. -1
  4033. ],
  4034. [
  4035. -1,
  4036. -1
  4037. ],
  4038. [
  4039. -1,
  4040. -1
  4041. ],
  4042. [
  4043. 8,
  4044. 29
  4045. ],
  4046. [
  4047. 8,
  4048. 29
  4049. ],
  4050. [
  4051. 8,
  4052. 30
  4053. ],
  4054. [
  4055. 8,
  4056. 30
  4057. ],
  4058. [
  4059. 8,
  4060. 45
  4061. ],
  4062. [
  4063. 8,
  4064. 45
  4065. ],
  4066. [
  4067. 8,
  4068. 46
  4069. ],
  4070. [
  4071. 8,
  4072. 46
  4073. ],
  4074. [
  4075. 7,
  4076. 22
  4077. ],
  4078. [
  4079. 7,
  4080. 22
  4081. ],
  4082. [
  4083. 7,
  4084. 22
  4085. ],
  4086. [
  4087. 7,
  4088. 22
  4089. ],
  4090. [
  4091. 7,
  4092. 23
  4093. ],
  4094. [
  4095. 7,
  4096. 23
  4097. ],
  4098. [
  4099. 7,
  4100. 23
  4101. ],
  4102. [
  4103. 7,
  4104. 23
  4105. ],
  4106. [
  4107. 8,
  4108. 47
  4109. ],
  4110. [
  4111. 8,
  4112. 47
  4113. ],
  4114. [
  4115. 8,
  4116. 48
  4117. ],
  4118. [
  4119. 8,
  4120. 48
  4121. ],
  4122. [
  4123. 6,
  4124. 13
  4125. ],
  4126. [
  4127. 6,
  4128. 13
  4129. ],
  4130. [
  4131. 6,
  4132. 13
  4133. ],
  4134. [
  4135. 6,
  4136. 13
  4137. ],
  4138. [
  4139. 6,
  4140. 13
  4141. ],
  4142. [
  4143. 6,
  4144. 13
  4145. ],
  4146. [
  4147. 6,
  4148. 13
  4149. ],
  4150. [
  4151. 6,
  4152. 13
  4153. ],
  4154. [
  4155. 7,
  4156. 20
  4157. ],
  4158. [
  4159. 7,
  4160. 20
  4161. ],
  4162. [
  4163. 7,
  4164. 20
  4165. ],
  4166. [
  4167. 7,
  4168. 20
  4169. ],
  4170. [
  4171. 8,
  4172. 33
  4173. ],
  4174. [
  4175. 8,
  4176. 33
  4177. ],
  4178. [
  4179. 8,
  4180. 34
  4181. ],
  4182. [
  4183. 8,
  4184. 34
  4185. ],
  4186. [
  4187. 8,
  4188. 35
  4189. ],
  4190. [
  4191. 8,
  4192. 35
  4193. ],
  4194. [
  4195. 8,
  4196. 36
  4197. ],
  4198. [
  4199. 8,
  4200. 36
  4201. ],
  4202. [
  4203. 8,
  4204. 37
  4205. ],
  4206. [
  4207. 8,
  4208. 37
  4209. ],
  4210. [
  4211. 8,
  4212. 38
  4213. ],
  4214. [
  4215. 8,
  4216. 38
  4217. ],
  4218. [
  4219. 7,
  4220. 19
  4221. ],
  4222. [
  4223. 7,
  4224. 19
  4225. ],
  4226. [
  4227. 7,
  4228. 19
  4229. ],
  4230. [
  4231. 7,
  4232. 19
  4233. ],
  4234. [
  4235. 8,
  4236. 31
  4237. ],
  4238. [
  4239. 8,
  4240. 31
  4241. ],
  4242. [
  4243. 8,
  4244. 32
  4245. ],
  4246. [
  4247. 8,
  4248. 32
  4249. ],
  4250. [
  4251. 6,
  4252. 1
  4253. ],
  4254. [
  4255. 6,
  4256. 1
  4257. ],
  4258. [
  4259. 6,
  4260. 1
  4261. ],
  4262. [
  4263. 6,
  4264. 1
  4265. ],
  4266. [
  4267. 6,
  4268. 1
  4269. ],
  4270. [
  4271. 6,
  4272. 1
  4273. ],
  4274. [
  4275. 6,
  4276. 1
  4277. ],
  4278. [
  4279. 6,
  4280. 1
  4281. ],
  4282. [
  4283. 6,
  4284. 12
  4285. ],
  4286. [
  4287. 6,
  4288. 12
  4289. ],
  4290. [
  4291. 6,
  4292. 12
  4293. ],
  4294. [
  4295. 6,
  4296. 12
  4297. ],
  4298. [
  4299. 6,
  4300. 12
  4301. ],
  4302. [
  4303. 6,
  4304. 12
  4305. ],
  4306. [
  4307. 6,
  4308. 12
  4309. ],
  4310. [
  4311. 6,
  4312. 12
  4313. ],
  4314. [
  4315. 8,
  4316. 53
  4317. ],
  4318. [
  4319. 8,
  4320. 53
  4321. ],
  4322. [
  4323. 8,
  4324. 54
  4325. ],
  4326. [
  4327. 8,
  4328. 54
  4329. ],
  4330. [
  4331. 7,
  4332. 26
  4333. ],
  4334. [
  4335. 7,
  4336. 26
  4337. ],
  4338. [
  4339. 7,
  4340. 26
  4341. ],
  4342. [
  4343. 7,
  4344. 26
  4345. ],
  4346. [
  4347. 8,
  4348. 39
  4349. ],
  4350. [
  4351. 8,
  4352. 39
  4353. ],
  4354. [
  4355. 8,
  4356. 40
  4357. ],
  4358. [
  4359. 8,
  4360. 40
  4361. ],
  4362. [
  4363. 8,
  4364. 41
  4365. ],
  4366. [
  4367. 8,
  4368. 41
  4369. ],
  4370. [
  4371. 8,
  4372. 42
  4373. ],
  4374. [
  4375. 8,
  4376. 42
  4377. ],
  4378. [
  4379. 8,
  4380. 43
  4381. ],
  4382. [
  4383. 8,
  4384. 43
  4385. ],
  4386. [
  4387. 8,
  4388. 44
  4389. ],
  4390. [
  4391. 8,
  4392. 44
  4393. ],
  4394. [
  4395. 7,
  4396. 21
  4397. ],
  4398. [
  4399. 7,
  4400. 21
  4401. ],
  4402. [
  4403. 7,
  4404. 21
  4405. ],
  4406. [
  4407. 7,
  4408. 21
  4409. ],
  4410. [
  4411. 7,
  4412. 28
  4413. ],
  4414. [
  4415. 7,
  4416. 28
  4417. ],
  4418. [
  4419. 7,
  4420. 28
  4421. ],
  4422. [
  4423. 7,
  4424. 28
  4425. ],
  4426. [
  4427. 8,
  4428. 61
  4429. ],
  4430. [
  4431. 8,
  4432. 61
  4433. ],
  4434. [
  4435. 8,
  4436. 62
  4437. ],
  4438. [
  4439. 8,
  4440. 62
  4441. ],
  4442. [
  4443. 8,
  4444. 63
  4445. ],
  4446. [
  4447. 8,
  4448. 63
  4449. ],
  4450. [
  4451. 8,
  4452. 0
  4453. ],
  4454. [
  4455. 8,
  4456. 0
  4457. ],
  4458. [
  4459. 8,
  4460. 320
  4461. ],
  4462. [
  4463. 8,
  4464. 320
  4465. ],
  4466. [
  4467. 8,
  4468. 384
  4469. ],
  4470. [
  4471. 8,
  4472. 384
  4473. ],
  4474. [
  4475. 5,
  4476. 10
  4477. ],
  4478. [
  4479. 5,
  4480. 10
  4481. ],
  4482. [
  4483. 5,
  4484. 10
  4485. ],
  4486. [
  4487. 5,
  4488. 10
  4489. ],
  4490. [
  4491. 5,
  4492. 10
  4493. ],
  4494. [
  4495. 5,
  4496. 10
  4497. ],
  4498. [
  4499. 5,
  4500. 10
  4501. ],
  4502. [
  4503. 5,
  4504. 10
  4505. ],
  4506. [
  4507. 5,
  4508. 10
  4509. ],
  4510. [
  4511. 5,
  4512. 10
  4513. ],
  4514. [
  4515. 5,
  4516. 10
  4517. ],
  4518. [
  4519. 5,
  4520. 10
  4521. ],
  4522. [
  4523. 5,
  4524. 10
  4525. ],
  4526. [
  4527. 5,
  4528. 10
  4529. ],
  4530. [
  4531. 5,
  4532. 10
  4533. ],
  4534. [
  4535. 5,
  4536. 10
  4537. ],
  4538. [
  4539. 5,
  4540. 11
  4541. ],
  4542. [
  4543. 5,
  4544. 11
  4545. ],
  4546. [
  4547. 5,
  4548. 11
  4549. ],
  4550. [
  4551. 5,
  4552. 11
  4553. ],
  4554. [
  4555. 5,
  4556. 11
  4557. ],
  4558. [
  4559. 5,
  4560. 11
  4561. ],
  4562. [
  4563. 5,
  4564. 11
  4565. ],
  4566. [
  4567. 5,
  4568. 11
  4569. ],
  4570. [
  4571. 5,
  4572. 11
  4573. ],
  4574. [
  4575. 5,
  4576. 11
  4577. ],
  4578. [
  4579. 5,
  4580. 11
  4581. ],
  4582. [
  4583. 5,
  4584. 11
  4585. ],
  4586. [
  4587. 5,
  4588. 11
  4589. ],
  4590. [
  4591. 5,
  4592. 11
  4593. ],
  4594. [
  4595. 5,
  4596. 11
  4597. ],
  4598. [
  4599. 5,
  4600. 11
  4601. ],
  4602. [
  4603. 7,
  4604. 27
  4605. ],
  4606. [
  4607. 7,
  4608. 27
  4609. ],
  4610. [
  4611. 7,
  4612. 27
  4613. ],
  4614. [
  4615. 7,
  4616. 27
  4617. ],
  4618. [
  4619. 8,
  4620. 59
  4621. ],
  4622. [
  4623. 8,
  4624. 59
  4625. ],
  4626. [
  4627. 8,
  4628. 60
  4629. ],
  4630. [
  4631. 8,
  4632. 60
  4633. ],
  4634. [
  4635. 9,
  4636. 1472
  4637. ],
  4638. [
  4639. 9,
  4640. 1536
  4641. ],
  4642. [
  4643. 9,
  4644. 1600
  4645. ],
  4646. [
  4647. 9,
  4648. 1728
  4649. ],
  4650. [
  4651. 7,
  4652. 18
  4653. ],
  4654. [
  4655. 7,
  4656. 18
  4657. ],
  4658. [
  4659. 7,
  4660. 18
  4661. ],
  4662. [
  4663. 7,
  4664. 18
  4665. ],
  4666. [
  4667. 7,
  4668. 24
  4669. ],
  4670. [
  4671. 7,
  4672. 24
  4673. ],
  4674. [
  4675. 7,
  4676. 24
  4677. ],
  4678. [
  4679. 7,
  4680. 24
  4681. ],
  4682. [
  4683. 8,
  4684. 49
  4685. ],
  4686. [
  4687. 8,
  4688. 49
  4689. ],
  4690. [
  4691. 8,
  4692. 50
  4693. ],
  4694. [
  4695. 8,
  4696. 50
  4697. ],
  4698. [
  4699. 8,
  4700. 51
  4701. ],
  4702. [
  4703. 8,
  4704. 51
  4705. ],
  4706. [
  4707. 8,
  4708. 52
  4709. ],
  4710. [
  4711. 8,
  4712. 52
  4713. ],
  4714. [
  4715. 7,
  4716. 25
  4717. ],
  4718. [
  4719. 7,
  4720. 25
  4721. ],
  4722. [
  4723. 7,
  4724. 25
  4725. ],
  4726. [
  4727. 7,
  4728. 25
  4729. ],
  4730. [
  4731. 8,
  4732. 55
  4733. ],
  4734. [
  4735. 8,
  4736. 55
  4737. ],
  4738. [
  4739. 8,
  4740. 56
  4741. ],
  4742. [
  4743. 8,
  4744. 56
  4745. ],
  4746. [
  4747. 8,
  4748. 57
  4749. ],
  4750. [
  4751. 8,
  4752. 57
  4753. ],
  4754. [
  4755. 8,
  4756. 58
  4757. ],
  4758. [
  4759. 8,
  4760. 58
  4761. ],
  4762. [
  4763. 6,
  4764. 192
  4765. ],
  4766. [
  4767. 6,
  4768. 192
  4769. ],
  4770. [
  4771. 6,
  4772. 192
  4773. ],
  4774. [
  4775. 6,
  4776. 192
  4777. ],
  4778. [
  4779. 6,
  4780. 192
  4781. ],
  4782. [
  4783. 6,
  4784. 192
  4785. ],
  4786. [
  4787. 6,
  4788. 192
  4789. ],
  4790. [
  4791. 6,
  4792. 192
  4793. ],
  4794. [
  4795. 6,
  4796. 1664
  4797. ],
  4798. [
  4799. 6,
  4800. 1664
  4801. ],
  4802. [
  4803. 6,
  4804. 1664
  4805. ],
  4806. [
  4807. 6,
  4808. 1664
  4809. ],
  4810. [
  4811. 6,
  4812. 1664
  4813. ],
  4814. [
  4815. 6,
  4816. 1664
  4817. ],
  4818. [
  4819. 6,
  4820. 1664
  4821. ],
  4822. [
  4823. 6,
  4824. 1664
  4825. ],
  4826. [
  4827. 8,
  4828. 448
  4829. ],
  4830. [
  4831. 8,
  4832. 448
  4833. ],
  4834. [
  4835. 8,
  4836. 512
  4837. ],
  4838. [
  4839. 8,
  4840. 512
  4841. ],
  4842. [
  4843. 9,
  4844. 704
  4845. ],
  4846. [
  4847. 9,
  4848. 768
  4849. ],
  4850. [
  4851. 8,
  4852. 640
  4853. ],
  4854. [
  4855. 8,
  4856. 640
  4857. ],
  4858. [
  4859. 8,
  4860. 576
  4861. ],
  4862. [
  4863. 8,
  4864. 576
  4865. ],
  4866. [
  4867. 9,
  4868. 832
  4869. ],
  4870. [
  4871. 9,
  4872. 896
  4873. ],
  4874. [
  4875. 9,
  4876. 960
  4877. ],
  4878. [
  4879. 9,
  4880. 1024
  4881. ],
  4882. [
  4883. 9,
  4884. 1088
  4885. ],
  4886. [
  4887. 9,
  4888. 1152
  4889. ],
  4890. [
  4891. 9,
  4892. 1216
  4893. ],
  4894. [
  4895. 9,
  4896. 1280
  4897. ],
  4898. [
  4899. 9,
  4900. 1344
  4901. ],
  4902. [
  4903. 9,
  4904. 1408
  4905. ],
  4906. [
  4907. 7,
  4908. 256
  4909. ],
  4910. [
  4911. 7,
  4912. 256
  4913. ],
  4914. [
  4915. 7,
  4916. 256
  4917. ],
  4918. [
  4919. 7,
  4920. 256
  4921. ],
  4922. [
  4923. 4,
  4924. 2
  4925. ],
  4926. [
  4927. 4,
  4928. 2
  4929. ],
  4930. [
  4931. 4,
  4932. 2
  4933. ],
  4934. [
  4935. 4,
  4936. 2
  4937. ],
  4938. [
  4939. 4,
  4940. 2
  4941. ],
  4942. [
  4943. 4,
  4944. 2
  4945. ],
  4946. [
  4947. 4,
  4948. 2
  4949. ],
  4950. [
  4951. 4,
  4952. 2
  4953. ],
  4954. [
  4955. 4,
  4956. 2
  4957. ],
  4958. [
  4959. 4,
  4960. 2
  4961. ],
  4962. [
  4963. 4,
  4964. 2
  4965. ],
  4966. [
  4967. 4,
  4968. 2
  4969. ],
  4970. [
  4971. 4,
  4972. 2
  4973. ],
  4974. [
  4975. 4,
  4976. 2
  4977. ],
  4978. [
  4979. 4,
  4980. 2
  4981. ],
  4982. [
  4983. 4,
  4984. 2
  4985. ],
  4986. [
  4987. 4,
  4988. 2
  4989. ],
  4990. [
  4991. 4,
  4992. 2
  4993. ],
  4994. [
  4995. 4,
  4996. 2
  4997. ],
  4998. [
  4999. 4,
  5000. 2
  5001. ],
  5002. [
  5003. 4,
  5004. 2
  5005. ],
  5006. [
  5007. 4,
  5008. 2
  5009. ],
  5010. [
  5011. 4,
  5012. 2
  5013. ],
  5014. [
  5015. 4,
  5016. 2
  5017. ],
  5018. [
  5019. 4,
  5020. 2
  5021. ],
  5022. [
  5023. 4,
  5024. 2
  5025. ],
  5026. [
  5027. 4,
  5028. 2
  5029. ],
  5030. [
  5031. 4,
  5032. 2
  5033. ],
  5034. [
  5035. 4,
  5036. 2
  5037. ],
  5038. [
  5039. 4,
  5040. 2
  5041. ],
  5042. [
  5043. 4,
  5044. 2
  5045. ],
  5046. [
  5047. 4,
  5048. 2
  5049. ],
  5050. [
  5051. 4,
  5052. 3
  5053. ],
  5054. [
  5055. 4,
  5056. 3
  5057. ],
  5058. [
  5059. 4,
  5060. 3
  5061. ],
  5062. [
  5063. 4,
  5064. 3
  5065. ],
  5066. [
  5067. 4,
  5068. 3
  5069. ],
  5070. [
  5071. 4,
  5072. 3
  5073. ],
  5074. [
  5075. 4,
  5076. 3
  5077. ],
  5078. [
  5079. 4,
  5080. 3
  5081. ],
  5082. [
  5083. 4,
  5084. 3
  5085. ],
  5086. [
  5087. 4,
  5088. 3
  5089. ],
  5090. [
  5091. 4,
  5092. 3
  5093. ],
  5094. [
  5095. 4,
  5096. 3
  5097. ],
  5098. [
  5099. 4,
  5100. 3
  5101. ],
  5102. [
  5103. 4,
  5104. 3
  5105. ],
  5106. [
  5107. 4,
  5108. 3
  5109. ],
  5110. [
  5111. 4,
  5112. 3
  5113. ],
  5114. [
  5115. 4,
  5116. 3
  5117. ],
  5118. [
  5119. 4,
  5120. 3
  5121. ],
  5122. [
  5123. 4,
  5124. 3
  5125. ],
  5126. [
  5127. 4,
  5128. 3
  5129. ],
  5130. [
  5131. 4,
  5132. 3
  5133. ],
  5134. [
  5135. 4,
  5136. 3
  5137. ],
  5138. [
  5139. 4,
  5140. 3
  5141. ],
  5142. [
  5143. 4,
  5144. 3
  5145. ],
  5146. [
  5147. 4,
  5148. 3
  5149. ],
  5150. [
  5151. 4,
  5152. 3
  5153. ],
  5154. [
  5155. 4,
  5156. 3
  5157. ],
  5158. [
  5159. 4,
  5160. 3
  5161. ],
  5162. [
  5163. 4,
  5164. 3
  5165. ],
  5166. [
  5167. 4,
  5168. 3
  5169. ],
  5170. [
  5171. 4,
  5172. 3
  5173. ],
  5174. [
  5175. 4,
  5176. 3
  5177. ],
  5178. [
  5179. 5,
  5180. 128
  5181. ],
  5182. [
  5183. 5,
  5184. 128
  5185. ],
  5186. [
  5187. 5,
  5188. 128
  5189. ],
  5190. [
  5191. 5,
  5192. 128
  5193. ],
  5194. [
  5195. 5,
  5196. 128
  5197. ],
  5198. [
  5199. 5,
  5200. 128
  5201. ],
  5202. [
  5203. 5,
  5204. 128
  5205. ],
  5206. [
  5207. 5,
  5208. 128
  5209. ],
  5210. [
  5211. 5,
  5212. 128
  5213. ],
  5214. [
  5215. 5,
  5216. 128
  5217. ],
  5218. [
  5219. 5,
  5220. 128
  5221. ],
  5222. [
  5223. 5,
  5224. 128
  5225. ],
  5226. [
  5227. 5,
  5228. 128
  5229. ],
  5230. [
  5231. 5,
  5232. 128
  5233. ],
  5234. [
  5235. 5,
  5236. 128
  5237. ],
  5238. [
  5239. 5,
  5240. 128
  5241. ],
  5242. [
  5243. 5,
  5244. 8
  5245. ],
  5246. [
  5247. 5,
  5248. 8
  5249. ],
  5250. [
  5251. 5,
  5252. 8
  5253. ],
  5254. [
  5255. 5,
  5256. 8
  5257. ],
  5258. [
  5259. 5,
  5260. 8
  5261. ],
  5262. [
  5263. 5,
  5264. 8
  5265. ],
  5266. [
  5267. 5,
  5268. 8
  5269. ],
  5270. [
  5271. 5,
  5272. 8
  5273. ],
  5274. [
  5275. 5,
  5276. 8
  5277. ],
  5278. [
  5279. 5,
  5280. 8
  5281. ],
  5282. [
  5283. 5,
  5284. 8
  5285. ],
  5286. [
  5287. 5,
  5288. 8
  5289. ],
  5290. [
  5291. 5,
  5292. 8
  5293. ],
  5294. [
  5295. 5,
  5296. 8
  5297. ],
  5298. [
  5299. 5,
  5300. 8
  5301. ],
  5302. [
  5303. 5,
  5304. 8
  5305. ],
  5306. [
  5307. 5,
  5308. 9
  5309. ],
  5310. [
  5311. 5,
  5312. 9
  5313. ],
  5314. [
  5315. 5,
  5316. 9
  5317. ],
  5318. [
  5319. 5,
  5320. 9
  5321. ],
  5322. [
  5323. 5,
  5324. 9
  5325. ],
  5326. [
  5327. 5,
  5328. 9
  5329. ],
  5330. [
  5331. 5,
  5332. 9
  5333. ],
  5334. [
  5335. 5,
  5336. 9
  5337. ],
  5338. [
  5339. 5,
  5340. 9
  5341. ],
  5342. [
  5343. 5,
  5344. 9
  5345. ],
  5346. [
  5347. 5,
  5348. 9
  5349. ],
  5350. [
  5351. 5,
  5352. 9
  5353. ],
  5354. [
  5355. 5,
  5356. 9
  5357. ],
  5358. [
  5359. 5,
  5360. 9
  5361. ],
  5362. [
  5363. 5,
  5364. 9
  5365. ],
  5366. [
  5367. 5,
  5368. 9
  5369. ],
  5370. [
  5371. 6,
  5372. 16
  5373. ],
  5374. [
  5375. 6,
  5376. 16
  5377. ],
  5378. [
  5379. 6,
  5380. 16
  5381. ],
  5382. [
  5383. 6,
  5384. 16
  5385. ],
  5386. [
  5387. 6,
  5388. 16
  5389. ],
  5390. [
  5391. 6,
  5392. 16
  5393. ],
  5394. [
  5395. 6,
  5396. 16
  5397. ],
  5398. [
  5399. 6,
  5400. 16
  5401. ],
  5402. [
  5403. 6,
  5404. 17
  5405. ],
  5406. [
  5407. 6,
  5408. 17
  5409. ],
  5410. [
  5411. 6,
  5412. 17
  5413. ],
  5414. [
  5415. 6,
  5416. 17
  5417. ],
  5418. [
  5419. 6,
  5420. 17
  5421. ],
  5422. [
  5423. 6,
  5424. 17
  5425. ],
  5426. [
  5427. 6,
  5428. 17
  5429. ],
  5430. [
  5431. 6,
  5432. 17
  5433. ],
  5434. [
  5435. 4,
  5436. 4
  5437. ],
  5438. [
  5439. 4,
  5440. 4
  5441. ],
  5442. [
  5443. 4,
  5444. 4
  5445. ],
  5446. [
  5447. 4,
  5448. 4
  5449. ],
  5450. [
  5451. 4,
  5452. 4
  5453. ],
  5454. [
  5455. 4,
  5456. 4
  5457. ],
  5458. [
  5459. 4,
  5460. 4
  5461. ],
  5462. [
  5463. 4,
  5464. 4
  5465. ],
  5466. [
  5467. 4,
  5468. 4
  5469. ],
  5470. [
  5471. 4,
  5472. 4
  5473. ],
  5474. [
  5475. 4,
  5476. 4
  5477. ],
  5478. [
  5479. 4,
  5480. 4
  5481. ],
  5482. [
  5483. 4,
  5484. 4
  5485. ],
  5486. [
  5487. 4,
  5488. 4
  5489. ],
  5490. [
  5491. 4,
  5492. 4
  5493. ],
  5494. [
  5495. 4,
  5496. 4
  5497. ],
  5498. [
  5499. 4,
  5500. 4
  5501. ],
  5502. [
  5503. 4,
  5504. 4
  5505. ],
  5506. [
  5507. 4,
  5508. 4
  5509. ],
  5510. [
  5511. 4,
  5512. 4
  5513. ],
  5514. [
  5515. 4,
  5516. 4
  5517. ],
  5518. [
  5519. 4,
  5520. 4
  5521. ],
  5522. [
  5523. 4,
  5524. 4
  5525. ],
  5526. [
  5527. 4,
  5528. 4
  5529. ],
  5530. [
  5531. 4,
  5532. 4
  5533. ],
  5534. [
  5535. 4,
  5536. 4
  5537. ],
  5538. [
  5539. 4,
  5540. 4
  5541. ],
  5542. [
  5543. 4,
  5544. 4
  5545. ],
  5546. [
  5547. 4,
  5548. 4
  5549. ],
  5550. [
  5551. 4,
  5552. 4
  5553. ],
  5554. [
  5555. 4,
  5556. 4
  5557. ],
  5558. [
  5559. 4,
  5560. 4
  5561. ],
  5562. [
  5563. 4,
  5564. 5
  5565. ],
  5566. [
  5567. 4,
  5568. 5
  5569. ],
  5570. [
  5571. 4,
  5572. 5
  5573. ],
  5574. [
  5575. 4,
  5576. 5
  5577. ],
  5578. [
  5579. 4,
  5580. 5
  5581. ],
  5582. [
  5583. 4,
  5584. 5
  5585. ],
  5586. [
  5587. 4,
  5588. 5
  5589. ],
  5590. [
  5591. 4,
  5592. 5
  5593. ],
  5594. [
  5595. 4,
  5596. 5
  5597. ],
  5598. [
  5599. 4,
  5600. 5
  5601. ],
  5602. [
  5603. 4,
  5604. 5
  5605. ],
  5606. [
  5607. 4,
  5608. 5
  5609. ],
  5610. [
  5611. 4,
  5612. 5
  5613. ],
  5614. [
  5615. 4,
  5616. 5
  5617. ],
  5618. [
  5619. 4,
  5620. 5
  5621. ],
  5622. [
  5623. 4,
  5624. 5
  5625. ],
  5626. [
  5627. 4,
  5628. 5
  5629. ],
  5630. [
  5631. 4,
  5632. 5
  5633. ],
  5634. [
  5635. 4,
  5636. 5
  5637. ],
  5638. [
  5639. 4,
  5640. 5
  5641. ],
  5642. [
  5643. 4,
  5644. 5
  5645. ],
  5646. [
  5647. 4,
  5648. 5
  5649. ],
  5650. [
  5651. 4,
  5652. 5
  5653. ],
  5654. [
  5655. 4,
  5656. 5
  5657. ],
  5658. [
  5659. 4,
  5660. 5
  5661. ],
  5662. [
  5663. 4,
  5664. 5
  5665. ],
  5666. [
  5667. 4,
  5668. 5
  5669. ],
  5670. [
  5671. 4,
  5672. 5
  5673. ],
  5674. [
  5675. 4,
  5676. 5
  5677. ],
  5678. [
  5679. 4,
  5680. 5
  5681. ],
  5682. [
  5683. 4,
  5684. 5
  5685. ],
  5686. [
  5687. 4,
  5688. 5
  5689. ],
  5690. [
  5691. 6,
  5692. 14
  5693. ],
  5694. [
  5695. 6,
  5696. 14
  5697. ],
  5698. [
  5699. 6,
  5700. 14
  5701. ],
  5702. [
  5703. 6,
  5704. 14
  5705. ],
  5706. [
  5707. 6,
  5708. 14
  5709. ],
  5710. [
  5711. 6,
  5712. 14
  5713. ],
  5714. [
  5715. 6,
  5716. 14
  5717. ],
  5718. [
  5719. 6,
  5720. 14
  5721. ],
  5722. [
  5723. 6,
  5724. 15
  5725. ],
  5726. [
  5727. 6,
  5728. 15
  5729. ],
  5730. [
  5731. 6,
  5732. 15
  5733. ],
  5734. [
  5735. 6,
  5736. 15
  5737. ],
  5738. [
  5739. 6,
  5740. 15
  5741. ],
  5742. [
  5743. 6,
  5744. 15
  5745. ],
  5746. [
  5747. 6,
  5748. 15
  5749. ],
  5750. [
  5751. 6,
  5752. 15
  5753. ],
  5754. [
  5755. 5,
  5756. 64
  5757. ],
  5758. [
  5759. 5,
  5760. 64
  5761. ],
  5762. [
  5763. 5,
  5764. 64
  5765. ],
  5766. [
  5767. 5,
  5768. 64
  5769. ],
  5770. [
  5771. 5,
  5772. 64
  5773. ],
  5774. [
  5775. 5,
  5776. 64
  5777. ],
  5778. [
  5779. 5,
  5780. 64
  5781. ],
  5782. [
  5783. 5,
  5784. 64
  5785. ],
  5786. [
  5787. 5,
  5788. 64
  5789. ],
  5790. [
  5791. 5,
  5792. 64
  5793. ],
  5794. [
  5795. 5,
  5796. 64
  5797. ],
  5798. [
  5799. 5,
  5800. 64
  5801. ],
  5802. [
  5803. 5,
  5804. 64
  5805. ],
  5806. [
  5807. 5,
  5808. 64
  5809. ],
  5810. [
  5811. 5,
  5812. 64
  5813. ],
  5814. [
  5815. 5,
  5816. 64
  5817. ],
  5818. [
  5819. 4,
  5820. 6
  5821. ],
  5822. [
  5823. 4,
  5824. 6
  5825. ],
  5826. [
  5827. 4,
  5828. 6
  5829. ],
  5830. [
  5831. 4,
  5832. 6
  5833. ],
  5834. [
  5835. 4,
  5836. 6
  5837. ],
  5838. [
  5839. 4,
  5840. 6
  5841. ],
  5842. [
  5843. 4,
  5844. 6
  5845. ],
  5846. [
  5847. 4,
  5848. 6
  5849. ],
  5850. [
  5851. 4,
  5852. 6
  5853. ],
  5854. [
  5855. 4,
  5856. 6
  5857. ],
  5858. [
  5859. 4,
  5860. 6
  5861. ],
  5862. [
  5863. 4,
  5864. 6
  5865. ],
  5866. [
  5867. 4,
  5868. 6
  5869. ],
  5870. [
  5871. 4,
  5872. 6
  5873. ],
  5874. [
  5875. 4,
  5876. 6
  5877. ],
  5878. [
  5879. 4,
  5880. 6
  5881. ],
  5882. [
  5883. 4,
  5884. 6
  5885. ],
  5886. [
  5887. 4,
  5888. 6
  5889. ],
  5890. [
  5891. 4,
  5892. 6
  5893. ],
  5894. [
  5895. 4,
  5896. 6
  5897. ],
  5898. [
  5899. 4,
  5900. 6
  5901. ],
  5902. [
  5903. 4,
  5904. 6
  5905. ],
  5906. [
  5907. 4,
  5908. 6
  5909. ],
  5910. [
  5911. 4,
  5912. 6
  5913. ],
  5914. [
  5915. 4,
  5916. 6
  5917. ],
  5918. [
  5919. 4,
  5920. 6
  5921. ],
  5922. [
  5923. 4,
  5924. 6
  5925. ],
  5926. [
  5927. 4,
  5928. 6
  5929. ],
  5930. [
  5931. 4,
  5932. 6
  5933. ],
  5934. [
  5935. 4,
  5936. 6
  5937. ],
  5938. [
  5939. 4,
  5940. 6
  5941. ],
  5942. [
  5943. 4,
  5944. 6
  5945. ],
  5946. [
  5947. 4,
  5948. 7
  5949. ],
  5950. [
  5951. 4,
  5952. 7
  5953. ],
  5954. [
  5955. 4,
  5956. 7
  5957. ],
  5958. [
  5959. 4,
  5960. 7
  5961. ],
  5962. [
  5963. 4,
  5964. 7
  5965. ],
  5966. [
  5967. 4,
  5968. 7
  5969. ],
  5970. [
  5971. 4,
  5972. 7
  5973. ],
  5974. [
  5975. 4,
  5976. 7
  5977. ],
  5978. [
  5979. 4,
  5980. 7
  5981. ],
  5982. [
  5983. 4,
  5984. 7
  5985. ],
  5986. [
  5987. 4,
  5988. 7
  5989. ],
  5990. [
  5991. 4,
  5992. 7
  5993. ],
  5994. [
  5995. 4,
  5996. 7
  5997. ],
  5998. [
  5999. 4,
  6000. 7
  6001. ],
  6002. [
  6003. 4,
  6004. 7
  6005. ],
  6006. [
  6007. 4,
  6008. 7
  6009. ],
  6010. [
  6011. 4,
  6012. 7
  6013. ],
  6014. [
  6015. 4,
  6016. 7
  6017. ],
  6018. [
  6019. 4,
  6020. 7
  6021. ],
  6022. [
  6023. 4,
  6024. 7
  6025. ],
  6026. [
  6027. 4,
  6028. 7
  6029. ],
  6030. [
  6031. 4,
  6032. 7
  6033. ],
  6034. [
  6035. 4,
  6036. 7
  6037. ],
  6038. [
  6039. 4,
  6040. 7
  6041. ],
  6042. [
  6043. 4,
  6044. 7
  6045. ],
  6046. [
  6047. 4,
  6048. 7
  6049. ],
  6050. [
  6051. 4,
  6052. 7
  6053. ],
  6054. [
  6055. 4,
  6056. 7
  6057. ],
  6058. [
  6059. 4,
  6060. 7
  6061. ],
  6062. [
  6063. 4,
  6064. 7
  6065. ],
  6066. [
  6067. 4,
  6068. 7
  6069. ],
  6070. [
  6071. 4,
  6072. 7
  6073. ]
  6074. ];
  6075. var blackTable1 = [
  6076. [
  6077. -1,
  6078. -1
  6079. ],
  6080. [
  6081. -1,
  6082. -1
  6083. ],
  6084. [
  6085. 12,
  6086. ccittEOL
  6087. ],
  6088. [
  6089. 12,
  6090. ccittEOL
  6091. ],
  6092. [
  6093. -1,
  6094. -1
  6095. ],
  6096. [
  6097. -1,
  6098. -1
  6099. ],
  6100. [
  6101. -1,
  6102. -1
  6103. ],
  6104. [
  6105. -1,
  6106. -1
  6107. ],
  6108. [
  6109. -1,
  6110. -1
  6111. ],
  6112. [
  6113. -1,
  6114. -1
  6115. ],
  6116. [
  6117. -1,
  6118. -1
  6119. ],
  6120. [
  6121. -1,
  6122. -1
  6123. ],
  6124. [
  6125. -1,
  6126. -1
  6127. ],
  6128. [
  6129. -1,
  6130. -1
  6131. ],
  6132. [
  6133. -1,
  6134. -1
  6135. ],
  6136. [
  6137. -1,
  6138. -1
  6139. ],
  6140. [
  6141. -1,
  6142. -1
  6143. ],
  6144. [
  6145. -1,
  6146. -1
  6147. ],
  6148. [
  6149. -1,
  6150. -1
  6151. ],
  6152. [
  6153. -1,
  6154. -1
  6155. ],
  6156. [
  6157. -1,
  6158. -1
  6159. ],
  6160. [
  6161. -1,
  6162. -1
  6163. ],
  6164. [
  6165. -1,
  6166. -1
  6167. ],
  6168. [
  6169. -1,
  6170. -1
  6171. ],
  6172. [
  6173. -1,
  6174. -1
  6175. ],
  6176. [
  6177. -1,
  6178. -1
  6179. ],
  6180. [
  6181. -1,
  6182. -1
  6183. ],
  6184. [
  6185. -1,
  6186. -1
  6187. ],
  6188. [
  6189. -1,
  6190. -1
  6191. ],
  6192. [
  6193. -1,
  6194. -1
  6195. ],
  6196. [
  6197. -1,
  6198. -1
  6199. ],
  6200. [
  6201. -1,
  6202. -1
  6203. ],
  6204. [
  6205. 11,
  6206. 1792
  6207. ],
  6208. [
  6209. 11,
  6210. 1792
  6211. ],
  6212. [
  6213. 11,
  6214. 1792
  6215. ],
  6216. [
  6217. 11,
  6218. 1792
  6219. ],
  6220. [
  6221. 12,
  6222. 1984
  6223. ],
  6224. [
  6225. 12,
  6226. 1984
  6227. ],
  6228. [
  6229. 12,
  6230. 2048
  6231. ],
  6232. [
  6233. 12,
  6234. 2048
  6235. ],
  6236. [
  6237. 12,
  6238. 2112
  6239. ],
  6240. [
  6241. 12,
  6242. 2112
  6243. ],
  6244. [
  6245. 12,
  6246. 2176
  6247. ],
  6248. [
  6249. 12,
  6250. 2176
  6251. ],
  6252. [
  6253. 12,
  6254. 2240
  6255. ],
  6256. [
  6257. 12,
  6258. 2240
  6259. ],
  6260. [
  6261. 12,
  6262. 2304
  6263. ],
  6264. [
  6265. 12,
  6266. 2304
  6267. ],
  6268. [
  6269. 11,
  6270. 1856
  6271. ],
  6272. [
  6273. 11,
  6274. 1856
  6275. ],
  6276. [
  6277. 11,
  6278. 1856
  6279. ],
  6280. [
  6281. 11,
  6282. 1856
  6283. ],
  6284. [
  6285. 11,
  6286. 1920
  6287. ],
  6288. [
  6289. 11,
  6290. 1920
  6291. ],
  6292. [
  6293. 11,
  6294. 1920
  6295. ],
  6296. [
  6297. 11,
  6298. 1920
  6299. ],
  6300. [
  6301. 12,
  6302. 2368
  6303. ],
  6304. [
  6305. 12,
  6306. 2368
  6307. ],
  6308. [
  6309. 12,
  6310. 2432
  6311. ],
  6312. [
  6313. 12,
  6314. 2432
  6315. ],
  6316. [
  6317. 12,
  6318. 2496
  6319. ],
  6320. [
  6321. 12,
  6322. 2496
  6323. ],
  6324. [
  6325. 12,
  6326. 2560
  6327. ],
  6328. [
  6329. 12,
  6330. 2560
  6331. ],
  6332. [
  6333. 10,
  6334. 18
  6335. ],
  6336. [
  6337. 10,
  6338. 18
  6339. ],
  6340. [
  6341. 10,
  6342. 18
  6343. ],
  6344. [
  6345. 10,
  6346. 18
  6347. ],
  6348. [
  6349. 10,
  6350. 18
  6351. ],
  6352. [
  6353. 10,
  6354. 18
  6355. ],
  6356. [
  6357. 10,
  6358. 18
  6359. ],
  6360. [
  6361. 10,
  6362. 18
  6363. ],
  6364. [
  6365. 12,
  6366. 52
  6367. ],
  6368. [
  6369. 12,
  6370. 52
  6371. ],
  6372. [
  6373. 13,
  6374. 640
  6375. ],
  6376. [
  6377. 13,
  6378. 704
  6379. ],
  6380. [
  6381. 13,
  6382. 768
  6383. ],
  6384. [
  6385. 13,
  6386. 832
  6387. ],
  6388. [
  6389. 12,
  6390. 55
  6391. ],
  6392. [
  6393. 12,
  6394. 55
  6395. ],
  6396. [
  6397. 12,
  6398. 56
  6399. ],
  6400. [
  6401. 12,
  6402. 56
  6403. ],
  6404. [
  6405. 13,
  6406. 1280
  6407. ],
  6408. [
  6409. 13,
  6410. 1344
  6411. ],
  6412. [
  6413. 13,
  6414. 1408
  6415. ],
  6416. [
  6417. 13,
  6418. 1472
  6419. ],
  6420. [
  6421. 12,
  6422. 59
  6423. ],
  6424. [
  6425. 12,
  6426. 59
  6427. ],
  6428. [
  6429. 12,
  6430. 60
  6431. ],
  6432. [
  6433. 12,
  6434. 60
  6435. ],
  6436. [
  6437. 13,
  6438. 1536
  6439. ],
  6440. [
  6441. 13,
  6442. 1600
  6443. ],
  6444. [
  6445. 11,
  6446. 24
  6447. ],
  6448. [
  6449. 11,
  6450. 24
  6451. ],
  6452. [
  6453. 11,
  6454. 24
  6455. ],
  6456. [
  6457. 11,
  6458. 24
  6459. ],
  6460. [
  6461. 11,
  6462. 25
  6463. ],
  6464. [
  6465. 11,
  6466. 25
  6467. ],
  6468. [
  6469. 11,
  6470. 25
  6471. ],
  6472. [
  6473. 11,
  6474. 25
  6475. ],
  6476. [
  6477. 13,
  6478. 1664
  6479. ],
  6480. [
  6481. 13,
  6482. 1728
  6483. ],
  6484. [
  6485. 12,
  6486. 320
  6487. ],
  6488. [
  6489. 12,
  6490. 320
  6491. ],
  6492. [
  6493. 12,
  6494. 384
  6495. ],
  6496. [
  6497. 12,
  6498. 384
  6499. ],
  6500. [
  6501. 12,
  6502. 448
  6503. ],
  6504. [
  6505. 12,
  6506. 448
  6507. ],
  6508. [
  6509. 13,
  6510. 512
  6511. ],
  6512. [
  6513. 13,
  6514. 576
  6515. ],
  6516. [
  6517. 12,
  6518. 53
  6519. ],
  6520. [
  6521. 12,
  6522. 53
  6523. ],
  6524. [
  6525. 12,
  6526. 54
  6527. ],
  6528. [
  6529. 12,
  6530. 54
  6531. ],
  6532. [
  6533. 13,
  6534. 896
  6535. ],
  6536. [
  6537. 13,
  6538. 960
  6539. ],
  6540. [
  6541. 13,
  6542. 1024
  6543. ],
  6544. [
  6545. 13,
  6546. 1088
  6547. ],
  6548. [
  6549. 13,
  6550. 1152
  6551. ],
  6552. [
  6553. 13,
  6554. 1216
  6555. ],
  6556. [
  6557. 10,
  6558. 64
  6559. ],
  6560. [
  6561. 10,
  6562. 64
  6563. ],
  6564. [
  6565. 10,
  6566. 64
  6567. ],
  6568. [
  6569. 10,
  6570. 64
  6571. ],
  6572. [
  6573. 10,
  6574. 64
  6575. ],
  6576. [
  6577. 10,
  6578. 64
  6579. ],
  6580. [
  6581. 10,
  6582. 64
  6583. ],
  6584. [
  6585. 10,
  6586. 64
  6587. ]
  6588. ];
  6589. var blackTable2 = [
  6590. [
  6591. 8,
  6592. 13
  6593. ],
  6594. [
  6595. 8,
  6596. 13
  6597. ],
  6598. [
  6599. 8,
  6600. 13
  6601. ],
  6602. [
  6603. 8,
  6604. 13
  6605. ],
  6606. [
  6607. 8,
  6608. 13
  6609. ],
  6610. [
  6611. 8,
  6612. 13
  6613. ],
  6614. [
  6615. 8,
  6616. 13
  6617. ],
  6618. [
  6619. 8,
  6620. 13
  6621. ],
  6622. [
  6623. 8,
  6624. 13
  6625. ],
  6626. [
  6627. 8,
  6628. 13
  6629. ],
  6630. [
  6631. 8,
  6632. 13
  6633. ],
  6634. [
  6635. 8,
  6636. 13
  6637. ],
  6638. [
  6639. 8,
  6640. 13
  6641. ],
  6642. [
  6643. 8,
  6644. 13
  6645. ],
  6646. [
  6647. 8,
  6648. 13
  6649. ],
  6650. [
  6651. 8,
  6652. 13
  6653. ],
  6654. [
  6655. 11,
  6656. 23
  6657. ],
  6658. [
  6659. 11,
  6660. 23
  6661. ],
  6662. [
  6663. 12,
  6664. 50
  6665. ],
  6666. [
  6667. 12,
  6668. 51
  6669. ],
  6670. [
  6671. 12,
  6672. 44
  6673. ],
  6674. [
  6675. 12,
  6676. 45
  6677. ],
  6678. [
  6679. 12,
  6680. 46
  6681. ],
  6682. [
  6683. 12,
  6684. 47
  6685. ],
  6686. [
  6687. 12,
  6688. 57
  6689. ],
  6690. [
  6691. 12,
  6692. 58
  6693. ],
  6694. [
  6695. 12,
  6696. 61
  6697. ],
  6698. [
  6699. 12,
  6700. 256
  6701. ],
  6702. [
  6703. 10,
  6704. 16
  6705. ],
  6706. [
  6707. 10,
  6708. 16
  6709. ],
  6710. [
  6711. 10,
  6712. 16
  6713. ],
  6714. [
  6715. 10,
  6716. 16
  6717. ],
  6718. [
  6719. 10,
  6720. 17
  6721. ],
  6722. [
  6723. 10,
  6724. 17
  6725. ],
  6726. [
  6727. 10,
  6728. 17
  6729. ],
  6730. [
  6731. 10,
  6732. 17
  6733. ],
  6734. [
  6735. 12,
  6736. 48
  6737. ],
  6738. [
  6739. 12,
  6740. 49
  6741. ],
  6742. [
  6743. 12,
  6744. 62
  6745. ],
  6746. [
  6747. 12,
  6748. 63
  6749. ],
  6750. [
  6751. 12,
  6752. 30
  6753. ],
  6754. [
  6755. 12,
  6756. 31
  6757. ],
  6758. [
  6759. 12,
  6760. 32
  6761. ],
  6762. [
  6763. 12,
  6764. 33
  6765. ],
  6766. [
  6767. 12,
  6768. 40
  6769. ],
  6770. [
  6771. 12,
  6772. 41
  6773. ],
  6774. [
  6775. 11,
  6776. 22
  6777. ],
  6778. [
  6779. 11,
  6780. 22
  6781. ],
  6782. [
  6783. 8,
  6784. 14
  6785. ],
  6786. [
  6787. 8,
  6788. 14
  6789. ],
  6790. [
  6791. 8,
  6792. 14
  6793. ],
  6794. [
  6795. 8,
  6796. 14
  6797. ],
  6798. [
  6799. 8,
  6800. 14
  6801. ],
  6802. [
  6803. 8,
  6804. 14
  6805. ],
  6806. [
  6807. 8,
  6808. 14
  6809. ],
  6810. [
  6811. 8,
  6812. 14
  6813. ],
  6814. [
  6815. 8,
  6816. 14
  6817. ],
  6818. [
  6819. 8,
  6820. 14
  6821. ],
  6822. [
  6823. 8,
  6824. 14
  6825. ],
  6826. [
  6827. 8,
  6828. 14
  6829. ],
  6830. [
  6831. 8,
  6832. 14
  6833. ],
  6834. [
  6835. 8,
  6836. 14
  6837. ],
  6838. [
  6839. 8,
  6840. 14
  6841. ],
  6842. [
  6843. 8,
  6844. 14
  6845. ],
  6846. [
  6847. 7,
  6848. 10
  6849. ],
  6850. [
  6851. 7,
  6852. 10
  6853. ],
  6854. [
  6855. 7,
  6856. 10
  6857. ],
  6858. [
  6859. 7,
  6860. 10
  6861. ],
  6862. [
  6863. 7,
  6864. 10
  6865. ],
  6866. [
  6867. 7,
  6868. 10
  6869. ],
  6870. [
  6871. 7,
  6872. 10
  6873. ],
  6874. [
  6875. 7,
  6876. 10
  6877. ],
  6878. [
  6879. 7,
  6880. 10
  6881. ],
  6882. [
  6883. 7,
  6884. 10
  6885. ],
  6886. [
  6887. 7,
  6888. 10
  6889. ],
  6890. [
  6891. 7,
  6892. 10
  6893. ],
  6894. [
  6895. 7,
  6896. 10
  6897. ],
  6898. [
  6899. 7,
  6900. 10
  6901. ],
  6902. [
  6903. 7,
  6904. 10
  6905. ],
  6906. [
  6907. 7,
  6908. 10
  6909. ],
  6910. [
  6911. 7,
  6912. 10
  6913. ],
  6914. [
  6915. 7,
  6916. 10
  6917. ],
  6918. [
  6919. 7,
  6920. 10
  6921. ],
  6922. [
  6923. 7,
  6924. 10
  6925. ],
  6926. [
  6927. 7,
  6928. 10
  6929. ],
  6930. [
  6931. 7,
  6932. 10
  6933. ],
  6934. [
  6935. 7,
  6936. 10
  6937. ],
  6938. [
  6939. 7,
  6940. 10
  6941. ],
  6942. [
  6943. 7,
  6944. 10
  6945. ],
  6946. [
  6947. 7,
  6948. 10
  6949. ],
  6950. [
  6951. 7,
  6952. 10
  6953. ],
  6954. [
  6955. 7,
  6956. 10
  6957. ],
  6958. [
  6959. 7,
  6960. 10
  6961. ],
  6962. [
  6963. 7,
  6964. 10
  6965. ],
  6966. [
  6967. 7,
  6968. 10
  6969. ],
  6970. [
  6971. 7,
  6972. 10
  6973. ],
  6974. [
  6975. 7,
  6976. 11
  6977. ],
  6978. [
  6979. 7,
  6980. 11
  6981. ],
  6982. [
  6983. 7,
  6984. 11
  6985. ],
  6986. [
  6987. 7,
  6988. 11
  6989. ],
  6990. [
  6991. 7,
  6992. 11
  6993. ],
  6994. [
  6995. 7,
  6996. 11
  6997. ],
  6998. [
  6999. 7,
  7000. 11
  7001. ],
  7002. [
  7003. 7,
  7004. 11
  7005. ],
  7006. [
  7007. 7,
  7008. 11
  7009. ],
  7010. [
  7011. 7,
  7012. 11
  7013. ],
  7014. [
  7015. 7,
  7016. 11
  7017. ],
  7018. [
  7019. 7,
  7020. 11
  7021. ],
  7022. [
  7023. 7,
  7024. 11
  7025. ],
  7026. [
  7027. 7,
  7028. 11
  7029. ],
  7030. [
  7031. 7,
  7032. 11
  7033. ],
  7034. [
  7035. 7,
  7036. 11
  7037. ],
  7038. [
  7039. 7,
  7040. 11
  7041. ],
  7042. [
  7043. 7,
  7044. 11
  7045. ],
  7046. [
  7047. 7,
  7048. 11
  7049. ],
  7050. [
  7051. 7,
  7052. 11
  7053. ],
  7054. [
  7055. 7,
  7056. 11
  7057. ],
  7058. [
  7059. 7,
  7060. 11
  7061. ],
  7062. [
  7063. 7,
  7064. 11
  7065. ],
  7066. [
  7067. 7,
  7068. 11
  7069. ],
  7070. [
  7071. 7,
  7072. 11
  7073. ],
  7074. [
  7075. 7,
  7076. 11
  7077. ],
  7078. [
  7079. 7,
  7080. 11
  7081. ],
  7082. [
  7083. 7,
  7084. 11
  7085. ],
  7086. [
  7087. 7,
  7088. 11
  7089. ],
  7090. [
  7091. 7,
  7092. 11
  7093. ],
  7094. [
  7095. 7,
  7096. 11
  7097. ],
  7098. [
  7099. 7,
  7100. 11
  7101. ],
  7102. [
  7103. 9,
  7104. 15
  7105. ],
  7106. [
  7107. 9,
  7108. 15
  7109. ],
  7110. [
  7111. 9,
  7112. 15
  7113. ],
  7114. [
  7115. 9,
  7116. 15
  7117. ],
  7118. [
  7119. 9,
  7120. 15
  7121. ],
  7122. [
  7123. 9,
  7124. 15
  7125. ],
  7126. [
  7127. 9,
  7128. 15
  7129. ],
  7130. [
  7131. 9,
  7132. 15
  7133. ],
  7134. [
  7135. 12,
  7136. 128
  7137. ],
  7138. [
  7139. 12,
  7140. 192
  7141. ],
  7142. [
  7143. 12,
  7144. 26
  7145. ],
  7146. [
  7147. 12,
  7148. 27
  7149. ],
  7150. [
  7151. 12,
  7152. 28
  7153. ],
  7154. [
  7155. 12,
  7156. 29
  7157. ],
  7158. [
  7159. 11,
  7160. 19
  7161. ],
  7162. [
  7163. 11,
  7164. 19
  7165. ],
  7166. [
  7167. 11,
  7168. 20
  7169. ],
  7170. [
  7171. 11,
  7172. 20
  7173. ],
  7174. [
  7175. 12,
  7176. 34
  7177. ],
  7178. [
  7179. 12,
  7180. 35
  7181. ],
  7182. [
  7183. 12,
  7184. 36
  7185. ],
  7186. [
  7187. 12,
  7188. 37
  7189. ],
  7190. [
  7191. 12,
  7192. 38
  7193. ],
  7194. [
  7195. 12,
  7196. 39
  7197. ],
  7198. [
  7199. 11,
  7200. 21
  7201. ],
  7202. [
  7203. 11,
  7204. 21
  7205. ],
  7206. [
  7207. 12,
  7208. 42
  7209. ],
  7210. [
  7211. 12,
  7212. 43
  7213. ],
  7214. [
  7215. 10,
  7216. 0
  7217. ],
  7218. [
  7219. 10,
  7220. 0
  7221. ],
  7222. [
  7223. 10,
  7224. 0
  7225. ],
  7226. [
  7227. 10,
  7228. 0
  7229. ],
  7230. [
  7231. 7,
  7232. 12
  7233. ],
  7234. [
  7235. 7,
  7236. 12
  7237. ],
  7238. [
  7239. 7,
  7240. 12
  7241. ],
  7242. [
  7243. 7,
  7244. 12
  7245. ],
  7246. [
  7247. 7,
  7248. 12
  7249. ],
  7250. [
  7251. 7,
  7252. 12
  7253. ],
  7254. [
  7255. 7,
  7256. 12
  7257. ],
  7258. [
  7259. 7,
  7260. 12
  7261. ],
  7262. [
  7263. 7,
  7264. 12
  7265. ],
  7266. [
  7267. 7,
  7268. 12
  7269. ],
  7270. [
  7271. 7,
  7272. 12
  7273. ],
  7274. [
  7275. 7,
  7276. 12
  7277. ],
  7278. [
  7279. 7,
  7280. 12
  7281. ],
  7282. [
  7283. 7,
  7284. 12
  7285. ],
  7286. [
  7287. 7,
  7288. 12
  7289. ],
  7290. [
  7291. 7,
  7292. 12
  7293. ],
  7294. [
  7295. 7,
  7296. 12
  7297. ],
  7298. [
  7299. 7,
  7300. 12
  7301. ],
  7302. [
  7303. 7,
  7304. 12
  7305. ],
  7306. [
  7307. 7,
  7308. 12
  7309. ],
  7310. [
  7311. 7,
  7312. 12
  7313. ],
  7314. [
  7315. 7,
  7316. 12
  7317. ],
  7318. [
  7319. 7,
  7320. 12
  7321. ],
  7322. [
  7323. 7,
  7324. 12
  7325. ],
  7326. [
  7327. 7,
  7328. 12
  7329. ],
  7330. [
  7331. 7,
  7332. 12
  7333. ],
  7334. [
  7335. 7,
  7336. 12
  7337. ],
  7338. [
  7339. 7,
  7340. 12
  7341. ],
  7342. [
  7343. 7,
  7344. 12
  7345. ],
  7346. [
  7347. 7,
  7348. 12
  7349. ],
  7350. [
  7351. 7,
  7352. 12
  7353. ],
  7354. [
  7355. 7,
  7356. 12
  7357. ]
  7358. ];
  7359. var blackTable3 = [
  7360. [
  7361. -1,
  7362. -1
  7363. ],
  7364. [
  7365. -1,
  7366. -1
  7367. ],
  7368. [
  7369. -1,
  7370. -1
  7371. ],
  7372. [
  7373. -1,
  7374. -1
  7375. ],
  7376. [
  7377. 6,
  7378. 9
  7379. ],
  7380. [
  7381. 6,
  7382. 8
  7383. ],
  7384. [
  7385. 5,
  7386. 7
  7387. ],
  7388. [
  7389. 5,
  7390. 7
  7391. ],
  7392. [
  7393. 4,
  7394. 6
  7395. ],
  7396. [
  7397. 4,
  7398. 6
  7399. ],
  7400. [
  7401. 4,
  7402. 6
  7403. ],
  7404. [
  7405. 4,
  7406. 6
  7407. ],
  7408. [
  7409. 4,
  7410. 5
  7411. ],
  7412. [
  7413. 4,
  7414. 5
  7415. ],
  7416. [
  7417. 4,
  7418. 5
  7419. ],
  7420. [
  7421. 4,
  7422. 5
  7423. ],
  7424. [
  7425. 3,
  7426. 1
  7427. ],
  7428. [
  7429. 3,
  7430. 1
  7431. ],
  7432. [
  7433. 3,
  7434. 1
  7435. ],
  7436. [
  7437. 3,
  7438. 1
  7439. ],
  7440. [
  7441. 3,
  7442. 1
  7443. ],
  7444. [
  7445. 3,
  7446. 1
  7447. ],
  7448. [
  7449. 3,
  7450. 1
  7451. ],
  7452. [
  7453. 3,
  7454. 1
  7455. ],
  7456. [
  7457. 3,
  7458. 4
  7459. ],
  7460. [
  7461. 3,
  7462. 4
  7463. ],
  7464. [
  7465. 3,
  7466. 4
  7467. ],
  7468. [
  7469. 3,
  7470. 4
  7471. ],
  7472. [
  7473. 3,
  7474. 4
  7475. ],
  7476. [
  7477. 3,
  7478. 4
  7479. ],
  7480. [
  7481. 3,
  7482. 4
  7483. ],
  7484. [
  7485. 3,
  7486. 4
  7487. ],
  7488. [
  7489. 2,
  7490. 3
  7491. ],
  7492. [
  7493. 2,
  7494. 3
  7495. ],
  7496. [
  7497. 2,
  7498. 3
  7499. ],
  7500. [
  7501. 2,
  7502. 3
  7503. ],
  7504. [
  7505. 2,
  7506. 3
  7507. ],
  7508. [
  7509. 2,
  7510. 3
  7511. ],
  7512. [
  7513. 2,
  7514. 3
  7515. ],
  7516. [
  7517. 2,
  7518. 3
  7519. ],
  7520. [
  7521. 2,
  7522. 3
  7523. ],
  7524. [
  7525. 2,
  7526. 3
  7527. ],
  7528. [
  7529. 2,
  7530. 3
  7531. ],
  7532. [
  7533. 2,
  7534. 3
  7535. ],
  7536. [
  7537. 2,
  7538. 3
  7539. ],
  7540. [
  7541. 2,
  7542. 3
  7543. ],
  7544. [
  7545. 2,
  7546. 3
  7547. ],
  7548. [
  7549. 2,
  7550. 3
  7551. ],
  7552. [
  7553. 2,
  7554. 2
  7555. ],
  7556. [
  7557. 2,
  7558. 2
  7559. ],
  7560. [
  7561. 2,
  7562. 2
  7563. ],
  7564. [
  7565. 2,
  7566. 2
  7567. ],
  7568. [
  7569. 2,
  7570. 2
  7571. ],
  7572. [
  7573. 2,
  7574. 2
  7575. ],
  7576. [
  7577. 2,
  7578. 2
  7579. ],
  7580. [
  7581. 2,
  7582. 2
  7583. ],
  7584. [
  7585. 2,
  7586. 2
  7587. ],
  7588. [
  7589. 2,
  7590. 2
  7591. ],
  7592. [
  7593. 2,
  7594. 2
  7595. ],
  7596. [
  7597. 2,
  7598. 2
  7599. ],
  7600. [
  7601. 2,
  7602. 2
  7603. ],
  7604. [
  7605. 2,
  7606. 2
  7607. ],
  7608. [
  7609. 2,
  7610. 2
  7611. ],
  7612. [
  7613. 2,
  7614. 2
  7615. ]
  7616. ];
  7617. function CCITTFaxStream(str, maybeLength, params) {
  7618. this.str = str;
  7619. this.dict = str.dict;
  7620. params = params || Dict.empty;
  7621. this.encoding = params.get('K') || 0;
  7622. this.eoline = params.get('EndOfLine') || false;
  7623. this.byteAlign = params.get('EncodedByteAlign') || false;
  7624. this.columns = params.get('Columns') || 1728;
  7625. this.rows = params.get('Rows') || 0;
  7626. var eoblock = params.get('EndOfBlock');
  7627. if (eoblock === null || eoblock === undefined) {
  7628. eoblock = true;
  7629. }
  7630. this.eoblock = eoblock;
  7631. this.black = params.get('BlackIs1') || false;
  7632. this.codingLine = new Uint32Array(this.columns + 1);
  7633. this.refLine = new Uint32Array(this.columns + 2);
  7634. this.codingLine[0] = this.columns;
  7635. this.codingPos = 0;
  7636. this.row = 0;
  7637. this.nextLine2D = this.encoding < 0;
  7638. this.inputBits = 0;
  7639. this.inputBuf = 0;
  7640. this.outputBits = 0;
  7641. var code1;
  7642. while ((code1 = this.lookBits(12)) === 0) {
  7643. this.eatBits(1);
  7644. }
  7645. if (code1 === 1) {
  7646. this.eatBits(12);
  7647. }
  7648. if (this.encoding > 0) {
  7649. this.nextLine2D = !this.lookBits(1);
  7650. this.eatBits(1);
  7651. }
  7652. DecodeStream.call(this, maybeLength);
  7653. }
  7654. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  7655. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  7656. while (!this.eof) {
  7657. var c = this.lookChar();
  7658. this.ensureBuffer(this.bufferLength + 1);
  7659. this.buffer[this.bufferLength++] = c;
  7660. }
  7661. };
  7662. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  7663. var codingLine = this.codingLine;
  7664. var codingPos = this.codingPos;
  7665. if (a1 > codingLine[codingPos]) {
  7666. if (a1 > this.columns) {
  7667. info('row is wrong length');
  7668. this.err = true;
  7669. a1 = this.columns;
  7670. }
  7671. if (codingPos & 1 ^ blackPixels) {
  7672. ++codingPos;
  7673. }
  7674. codingLine[codingPos] = a1;
  7675. }
  7676. this.codingPos = codingPos;
  7677. };
  7678. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  7679. var codingLine = this.codingLine;
  7680. var codingPos = this.codingPos;
  7681. if (a1 > codingLine[codingPos]) {
  7682. if (a1 > this.columns) {
  7683. info('row is wrong length');
  7684. this.err = true;
  7685. a1 = this.columns;
  7686. }
  7687. if (codingPos & 1 ^ blackPixels) {
  7688. ++codingPos;
  7689. }
  7690. codingLine[codingPos] = a1;
  7691. } else if (a1 < codingLine[codingPos]) {
  7692. if (a1 < 0) {
  7693. info('invalid code');
  7694. this.err = true;
  7695. a1 = 0;
  7696. }
  7697. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7698. --codingPos;
  7699. }
  7700. codingLine[codingPos] = a1;
  7701. }
  7702. this.codingPos = codingPos;
  7703. };
  7704. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  7705. var refLine = this.refLine;
  7706. var codingLine = this.codingLine;
  7707. var columns = this.columns;
  7708. var refPos, blackPixels, bits, i;
  7709. if (this.outputBits === 0) {
  7710. if (this.eof) {
  7711. return null;
  7712. }
  7713. this.err = false;
  7714. var code1, code2, code3;
  7715. if (this.nextLine2D) {
  7716. for (i = 0; codingLine[i] < columns; ++i) {
  7717. refLine[i] = codingLine[i];
  7718. }
  7719. refLine[i++] = columns;
  7720. refLine[i] = columns;
  7721. codingLine[0] = 0;
  7722. this.codingPos = 0;
  7723. refPos = 0;
  7724. blackPixels = 0;
  7725. while (codingLine[this.codingPos] < columns) {
  7726. code1 = this.getTwoDimCode();
  7727. switch (code1) {
  7728. case twoDimPass:
  7729. this.addPixels(refLine[refPos + 1], blackPixels);
  7730. if (refLine[refPos + 1] < columns) {
  7731. refPos += 2;
  7732. }
  7733. break;
  7734. case twoDimHoriz:
  7735. code1 = code2 = 0;
  7736. if (blackPixels) {
  7737. do {
  7738. code1 += code3 = this.getBlackCode();
  7739. } while (code3 >= 64);
  7740. do {
  7741. code2 += code3 = this.getWhiteCode();
  7742. } while (code3 >= 64);
  7743. } else {
  7744. do {
  7745. code1 += code3 = this.getWhiteCode();
  7746. } while (code3 >= 64);
  7747. do {
  7748. code2 += code3 = this.getBlackCode();
  7749. } while (code3 >= 64);
  7750. }
  7751. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7752. if (codingLine[this.codingPos] < columns) {
  7753. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7754. }
  7755. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7756. refPos += 2;
  7757. }
  7758. break;
  7759. case twoDimVertR3:
  7760. this.addPixels(refLine[refPos] + 3, blackPixels);
  7761. blackPixels ^= 1;
  7762. if (codingLine[this.codingPos] < columns) {
  7763. ++refPos;
  7764. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7765. refPos += 2;
  7766. }
  7767. }
  7768. break;
  7769. case twoDimVertR2:
  7770. this.addPixels(refLine[refPos] + 2, blackPixels);
  7771. blackPixels ^= 1;
  7772. if (codingLine[this.codingPos] < columns) {
  7773. ++refPos;
  7774. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7775. refPos += 2;
  7776. }
  7777. }
  7778. break;
  7779. case twoDimVertR1:
  7780. this.addPixels(refLine[refPos] + 1, blackPixels);
  7781. blackPixels ^= 1;
  7782. if (codingLine[this.codingPos] < columns) {
  7783. ++refPos;
  7784. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7785. refPos += 2;
  7786. }
  7787. }
  7788. break;
  7789. case twoDimVert0:
  7790. this.addPixels(refLine[refPos], blackPixels);
  7791. blackPixels ^= 1;
  7792. if (codingLine[this.codingPos] < columns) {
  7793. ++refPos;
  7794. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7795. refPos += 2;
  7796. }
  7797. }
  7798. break;
  7799. case twoDimVertL3:
  7800. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7801. blackPixels ^= 1;
  7802. if (codingLine[this.codingPos] < columns) {
  7803. if (refPos > 0) {
  7804. --refPos;
  7805. } else {
  7806. ++refPos;
  7807. }
  7808. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7809. refPos += 2;
  7810. }
  7811. }
  7812. break;
  7813. case twoDimVertL2:
  7814. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7815. blackPixels ^= 1;
  7816. if (codingLine[this.codingPos] < columns) {
  7817. if (refPos > 0) {
  7818. --refPos;
  7819. } else {
  7820. ++refPos;
  7821. }
  7822. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7823. refPos += 2;
  7824. }
  7825. }
  7826. break;
  7827. case twoDimVertL1:
  7828. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7829. blackPixels ^= 1;
  7830. if (codingLine[this.codingPos] < columns) {
  7831. if (refPos > 0) {
  7832. --refPos;
  7833. } else {
  7834. ++refPos;
  7835. }
  7836. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7837. refPos += 2;
  7838. }
  7839. }
  7840. break;
  7841. case ccittEOF:
  7842. this.addPixels(columns, 0);
  7843. this.eof = true;
  7844. break;
  7845. default:
  7846. info('bad 2d code');
  7847. this.addPixels(columns, 0);
  7848. this.err = true;
  7849. }
  7850. }
  7851. } else {
  7852. codingLine[0] = 0;
  7853. this.codingPos = 0;
  7854. blackPixels = 0;
  7855. while (codingLine[this.codingPos] < columns) {
  7856. code1 = 0;
  7857. if (blackPixels) {
  7858. do {
  7859. code1 += code3 = this.getBlackCode();
  7860. } while (code3 >= 64);
  7861. } else {
  7862. do {
  7863. code1 += code3 = this.getWhiteCode();
  7864. } while (code3 >= 64);
  7865. }
  7866. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7867. blackPixels ^= 1;
  7868. }
  7869. }
  7870. var gotEOL = false;
  7871. if (this.byteAlign) {
  7872. this.inputBits &= ~7;
  7873. }
  7874. if (!this.eoblock && this.row === this.rows - 1) {
  7875. this.eof = true;
  7876. } else {
  7877. code1 = this.lookBits(12);
  7878. if (this.eoline) {
  7879. while (code1 !== ccittEOF && code1 !== 1) {
  7880. this.eatBits(1);
  7881. code1 = this.lookBits(12);
  7882. }
  7883. } else {
  7884. while (code1 === 0) {
  7885. this.eatBits(1);
  7886. code1 = this.lookBits(12);
  7887. }
  7888. }
  7889. if (code1 === 1) {
  7890. this.eatBits(12);
  7891. gotEOL = true;
  7892. } else if (code1 === ccittEOF) {
  7893. this.eof = true;
  7894. }
  7895. }
  7896. if (!this.eof && this.encoding > 0) {
  7897. this.nextLine2D = !this.lookBits(1);
  7898. this.eatBits(1);
  7899. }
  7900. if (this.eoblock && gotEOL && this.byteAlign) {
  7901. code1 = this.lookBits(12);
  7902. if (code1 === 1) {
  7903. this.eatBits(12);
  7904. if (this.encoding > 0) {
  7905. this.lookBits(1);
  7906. this.eatBits(1);
  7907. }
  7908. if (this.encoding >= 0) {
  7909. for (i = 0; i < 4; ++i) {
  7910. code1 = this.lookBits(12);
  7911. if (code1 !== 1) {
  7912. info('bad rtc code: ' + code1);
  7913. }
  7914. this.eatBits(12);
  7915. if (this.encoding > 0) {
  7916. this.lookBits(1);
  7917. this.eatBits(1);
  7918. }
  7919. }
  7920. }
  7921. this.eof = true;
  7922. }
  7923. } else if (this.err && this.eoline) {
  7924. while (true) {
  7925. code1 = this.lookBits(13);
  7926. if (code1 === ccittEOF) {
  7927. this.eof = true;
  7928. return null;
  7929. }
  7930. if (code1 >> 1 === 1) {
  7931. break;
  7932. }
  7933. this.eatBits(1);
  7934. }
  7935. this.eatBits(12);
  7936. if (this.encoding > 0) {
  7937. this.eatBits(1);
  7938. this.nextLine2D = !(code1 & 1);
  7939. }
  7940. }
  7941. if (codingLine[0] > 0) {
  7942. this.outputBits = codingLine[this.codingPos = 0];
  7943. } else {
  7944. this.outputBits = codingLine[this.codingPos = 1];
  7945. }
  7946. this.row++;
  7947. }
  7948. var c;
  7949. if (this.outputBits >= 8) {
  7950. c = this.codingPos & 1 ? 0 : 0xFF;
  7951. this.outputBits -= 8;
  7952. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7953. this.codingPos++;
  7954. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7955. }
  7956. } else {
  7957. bits = 8;
  7958. c = 0;
  7959. do {
  7960. if (this.outputBits > bits) {
  7961. c <<= bits;
  7962. if (!(this.codingPos & 1)) {
  7963. c |= 0xFF >> 8 - bits;
  7964. }
  7965. this.outputBits -= bits;
  7966. bits = 0;
  7967. } else {
  7968. c <<= this.outputBits;
  7969. if (!(this.codingPos & 1)) {
  7970. c |= 0xFF >> 8 - this.outputBits;
  7971. }
  7972. bits -= this.outputBits;
  7973. this.outputBits = 0;
  7974. if (codingLine[this.codingPos] < columns) {
  7975. this.codingPos++;
  7976. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7977. } else if (bits > 0) {
  7978. c <<= bits;
  7979. bits = 0;
  7980. }
  7981. }
  7982. } while (bits);
  7983. }
  7984. if (this.black) {
  7985. c ^= 0xFF;
  7986. }
  7987. return c;
  7988. };
  7989. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  7990. var limitValue = limit || 0;
  7991. for (var i = start; i <= end; ++i) {
  7992. var code = this.lookBits(i);
  7993. if (code === ccittEOF) {
  7994. return [
  7995. true,
  7996. 1,
  7997. false
  7998. ];
  7999. }
  8000. if (i < end) {
  8001. code <<= end - i;
  8002. }
  8003. if (!limitValue || code >= limitValue) {
  8004. var p = table[code - limitValue];
  8005. if (p[0] === i) {
  8006. this.eatBits(i);
  8007. return [
  8008. true,
  8009. p[1],
  8010. true
  8011. ];
  8012. }
  8013. }
  8014. }
  8015. return [
  8016. false,
  8017. 0,
  8018. false
  8019. ];
  8020. };
  8021. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8022. var code = 0;
  8023. var p;
  8024. if (this.eoblock) {
  8025. code = this.lookBits(7);
  8026. p = twoDimTable[code];
  8027. if (p && p[0] > 0) {
  8028. this.eatBits(p[0]);
  8029. return p[1];
  8030. }
  8031. } else {
  8032. var result = this.findTableCode(1, 7, twoDimTable);
  8033. if (result[0] && result[2]) {
  8034. return result[1];
  8035. }
  8036. }
  8037. info('Bad two dim code');
  8038. return ccittEOF;
  8039. };
  8040. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8041. var code = 0;
  8042. var p;
  8043. if (this.eoblock) {
  8044. code = this.lookBits(12);
  8045. if (code === ccittEOF) {
  8046. return 1;
  8047. }
  8048. if (code >> 5 === 0) {
  8049. p = whiteTable1[code];
  8050. } else {
  8051. p = whiteTable2[code >> 3];
  8052. }
  8053. if (p[0] > 0) {
  8054. this.eatBits(p[0]);
  8055. return p[1];
  8056. }
  8057. } else {
  8058. var result = this.findTableCode(1, 9, whiteTable2);
  8059. if (result[0]) {
  8060. return result[1];
  8061. }
  8062. result = this.findTableCode(11, 12, whiteTable1);
  8063. if (result[0]) {
  8064. return result[1];
  8065. }
  8066. }
  8067. info('bad white code');
  8068. this.eatBits(1);
  8069. return 1;
  8070. };
  8071. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8072. var code, p;
  8073. if (this.eoblock) {
  8074. code = this.lookBits(13);
  8075. if (code === ccittEOF) {
  8076. return 1;
  8077. }
  8078. if (code >> 7 === 0) {
  8079. p = blackTable1[code];
  8080. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8081. p = blackTable2[(code >> 1) - 64];
  8082. } else {
  8083. p = blackTable3[code >> 7];
  8084. }
  8085. if (p[0] > 0) {
  8086. this.eatBits(p[0]);
  8087. return p[1];
  8088. }
  8089. } else {
  8090. var result = this.findTableCode(2, 6, blackTable3);
  8091. if (result[0]) {
  8092. return result[1];
  8093. }
  8094. result = this.findTableCode(7, 12, blackTable2, 64);
  8095. if (result[0]) {
  8096. return result[1];
  8097. }
  8098. result = this.findTableCode(10, 13, blackTable1);
  8099. if (result[0]) {
  8100. return result[1];
  8101. }
  8102. }
  8103. info('bad black code');
  8104. this.eatBits(1);
  8105. return 1;
  8106. };
  8107. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8108. var c;
  8109. while (this.inputBits < n) {
  8110. if ((c = this.str.getByte()) === -1) {
  8111. if (this.inputBits === 0) {
  8112. return ccittEOF;
  8113. }
  8114. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8115. }
  8116. this.inputBuf = this.inputBuf << 8 | c;
  8117. this.inputBits += 8;
  8118. }
  8119. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8120. };
  8121. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8122. if ((this.inputBits -= n) < 0) {
  8123. this.inputBits = 0;
  8124. }
  8125. };
  8126. return CCITTFaxStream;
  8127. }();
  8128. var LZWStream = function LZWStreamClosure() {
  8129. function LZWStream(str, maybeLength, earlyChange) {
  8130. this.str = str;
  8131. this.dict = str.dict;
  8132. this.cachedData = 0;
  8133. this.bitsCached = 0;
  8134. var maxLzwDictionarySize = 4096;
  8135. var lzwState = {
  8136. earlyChange: earlyChange,
  8137. codeLength: 9,
  8138. nextCode: 258,
  8139. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8140. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8141. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8142. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8143. currentSequenceLength: 0
  8144. };
  8145. for (var i = 0; i < 256; ++i) {
  8146. lzwState.dictionaryValues[i] = i;
  8147. lzwState.dictionaryLengths[i] = 1;
  8148. }
  8149. this.lzwState = lzwState;
  8150. DecodeStream.call(this, maybeLength);
  8151. }
  8152. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8153. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8154. var bitsCached = this.bitsCached;
  8155. var cachedData = this.cachedData;
  8156. while (bitsCached < n) {
  8157. var c = this.str.getByte();
  8158. if (c === -1) {
  8159. this.eof = true;
  8160. return null;
  8161. }
  8162. cachedData = cachedData << 8 | c;
  8163. bitsCached += 8;
  8164. }
  8165. this.bitsCached = bitsCached -= n;
  8166. this.cachedData = cachedData;
  8167. this.lastCode = null;
  8168. return cachedData >>> bitsCached & (1 << n) - 1;
  8169. };
  8170. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8171. var blockSize = 512;
  8172. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8173. var i, j, q;
  8174. var lzwState = this.lzwState;
  8175. if (!lzwState) {
  8176. return;
  8177. }
  8178. var earlyChange = lzwState.earlyChange;
  8179. var nextCode = lzwState.nextCode;
  8180. var dictionaryValues = lzwState.dictionaryValues;
  8181. var dictionaryLengths = lzwState.dictionaryLengths;
  8182. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  8183. var codeLength = lzwState.codeLength;
  8184. var prevCode = lzwState.prevCode;
  8185. var currentSequence = lzwState.currentSequence;
  8186. var currentSequenceLength = lzwState.currentSequenceLength;
  8187. var decodedLength = 0;
  8188. var currentBufferLength = this.bufferLength;
  8189. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8190. for (i = 0; i < blockSize; i++) {
  8191. var code = this.readBits(codeLength);
  8192. var hasPrev = currentSequenceLength > 0;
  8193. if (code < 256) {
  8194. currentSequence[0] = code;
  8195. currentSequenceLength = 1;
  8196. } else if (code >= 258) {
  8197. if (code < nextCode) {
  8198. currentSequenceLength = dictionaryLengths[code];
  8199. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  8200. currentSequence[j] = dictionaryValues[q];
  8201. q = dictionaryPrevCodes[q];
  8202. }
  8203. } else {
  8204. currentSequence[currentSequenceLength++] = currentSequence[0];
  8205. }
  8206. } else if (code === 256) {
  8207. codeLength = 9;
  8208. nextCode = 258;
  8209. currentSequenceLength = 0;
  8210. continue;
  8211. } else {
  8212. this.eof = true;
  8213. delete this.lzwState;
  8214. break;
  8215. }
  8216. if (hasPrev) {
  8217. dictionaryPrevCodes[nextCode] = prevCode;
  8218. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  8219. dictionaryValues[nextCode] = currentSequence[0];
  8220. nextCode++;
  8221. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  8222. }
  8223. prevCode = code;
  8224. decodedLength += currentSequenceLength;
  8225. if (estimatedDecodedSize < decodedLength) {
  8226. do {
  8227. estimatedDecodedSize += decodedSizeDelta;
  8228. } while (estimatedDecodedSize < decodedLength);
  8229. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8230. }
  8231. for (j = 0; j < currentSequenceLength; j++) {
  8232. buffer[currentBufferLength++] = currentSequence[j];
  8233. }
  8234. }
  8235. lzwState.nextCode = nextCode;
  8236. lzwState.codeLength = codeLength;
  8237. lzwState.prevCode = prevCode;
  8238. lzwState.currentSequenceLength = currentSequenceLength;
  8239. this.bufferLength = currentBufferLength;
  8240. };
  8241. return LZWStream;
  8242. }();
  8243. var NullStream = function NullStreamClosure() {
  8244. function NullStream() {
  8245. Stream.call(this, new Uint8Array(0));
  8246. }
  8247. NullStream.prototype = Stream.prototype;
  8248. return NullStream;
  8249. }();
  8250. exports.Ascii85Stream = Ascii85Stream;
  8251. exports.AsciiHexStream = AsciiHexStream;
  8252. exports.CCITTFaxStream = CCITTFaxStream;
  8253. exports.DecryptStream = DecryptStream;
  8254. exports.DecodeStream = DecodeStream;
  8255. exports.FlateStream = FlateStream;
  8256. exports.Jbig2Stream = Jbig2Stream;
  8257. exports.JpegStream = JpegStream;
  8258. exports.JpxStream = JpxStream;
  8259. exports.NullStream = NullStream;
  8260. exports.PredictorStream = PredictorStream;
  8261. exports.RunLengthStream = RunLengthStream;
  8262. exports.Stream = Stream;
  8263. exports.StreamsSequenceStream = StreamsSequenceStream;
  8264. exports.StringStream = StringStream;
  8265. exports.LZWStream = LZWStream;
  8266. /***/ }),
  8267. /* 3 */
  8268. /***/ (function(module, exports, __w_pdfjs_require__) {
  8269. "use strict";
  8270. var sharedUtil = __w_pdfjs_require__(0);
  8271. var assert = sharedUtil.assert;
  8272. var removeNullCharacters = sharedUtil.removeNullCharacters;
  8273. var warn = sharedUtil.warn;
  8274. var deprecated = sharedUtil.deprecated;
  8275. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  8276. var stringToBytes = sharedUtil.stringToBytes;
  8277. var CMapCompressionType = sharedUtil.CMapCompressionType;
  8278. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  8279. function DOMCanvasFactory() {
  8280. }
  8281. DOMCanvasFactory.prototype = {
  8282. create: function DOMCanvasFactory_create(width, height) {
  8283. assert(width > 0 && height > 0, 'invalid canvas size');
  8284. var canvas = document.createElement('canvas');
  8285. var context = canvas.getContext('2d');
  8286. canvas.width = width;
  8287. canvas.height = height;
  8288. return {
  8289. canvas: canvas,
  8290. context: context
  8291. };
  8292. },
  8293. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  8294. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8295. assert(width > 0 && height > 0, 'invalid canvas size');
  8296. canvasAndContextPair.canvas.width = width;
  8297. canvasAndContextPair.canvas.height = height;
  8298. },
  8299. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  8300. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8301. canvasAndContextPair.canvas.width = 0;
  8302. canvasAndContextPair.canvas.height = 0;
  8303. canvasAndContextPair.canvas = null;
  8304. canvasAndContextPair.context = null;
  8305. }
  8306. };
  8307. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  8308. function DOMCMapReaderFactory(params) {
  8309. this.baseUrl = params.baseUrl || null;
  8310. this.isCompressed = params.isCompressed || false;
  8311. }
  8312. DOMCMapReaderFactory.prototype = {
  8313. fetch: function (params) {
  8314. if (!params.name) {
  8315. return Promise.reject(new Error('CMap name must be specified.'));
  8316. }
  8317. return new Promise(function (resolve, reject) {
  8318. var url = this.baseUrl + params.name;
  8319. var request = new XMLHttpRequest();
  8320. if (this.isCompressed) {
  8321. url += '.bcmap';
  8322. request.responseType = 'arraybuffer';
  8323. }
  8324. request.onreadystatechange = function () {
  8325. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  8326. var data;
  8327. if (this.isCompressed && request.response) {
  8328. data = new Uint8Array(request.response);
  8329. } else if (!this.isCompressed && request.responseText) {
  8330. data = stringToBytes(request.responseText);
  8331. }
  8332. if (data) {
  8333. resolve({
  8334. cMapData: data,
  8335. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  8336. });
  8337. return;
  8338. }
  8339. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  8340. }
  8341. }.bind(this);
  8342. request.open('GET', url, true);
  8343. request.send(null);
  8344. }.bind(this));
  8345. }
  8346. };
  8347. return DOMCMapReaderFactory;
  8348. }();
  8349. var CustomStyle = function CustomStyleClosure() {
  8350. var prefixes = [
  8351. 'ms',
  8352. 'Moz',
  8353. 'Webkit',
  8354. 'O'
  8355. ];
  8356. var _cache = Object.create(null);
  8357. function CustomStyle() {
  8358. }
  8359. CustomStyle.getProp = function get(propName, element) {
  8360. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  8361. return _cache[propName];
  8362. }
  8363. element = element || document.documentElement;
  8364. var style = element.style, prefixed, uPropName;
  8365. if (typeof style[propName] === 'string') {
  8366. return _cache[propName] = propName;
  8367. }
  8368. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  8369. for (var i = 0, l = prefixes.length; i < l; i++) {
  8370. prefixed = prefixes[i] + uPropName;
  8371. if (typeof style[prefixed] === 'string') {
  8372. return _cache[propName] = prefixed;
  8373. }
  8374. }
  8375. return _cache[propName] = 'undefined';
  8376. };
  8377. CustomStyle.setProp = function set(propName, element, str) {
  8378. var prop = this.getProp(propName);
  8379. if (prop !== 'undefined') {
  8380. element.style[prop] = str;
  8381. }
  8382. };
  8383. return CustomStyle;
  8384. }();
  8385. var hasCanvasTypedArrays;
  8386. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  8387. var canvas = document.createElement('canvas');
  8388. canvas.width = canvas.height = 1;
  8389. var ctx = canvas.getContext('2d');
  8390. var imageData = ctx.createImageData(1, 1);
  8391. return typeof imageData.data.buffer !== 'undefined';
  8392. };
  8393. var LinkTarget = {
  8394. NONE: 0,
  8395. SELF: 1,
  8396. BLANK: 2,
  8397. PARENT: 3,
  8398. TOP: 4
  8399. };
  8400. var LinkTargetStringMap = [
  8401. '',
  8402. '_self',
  8403. '_blank',
  8404. '_parent',
  8405. '_top'
  8406. ];
  8407. function addLinkAttributes(link, params) {
  8408. var url = params && params.url;
  8409. link.href = link.title = url ? removeNullCharacters(url) : '';
  8410. if (url) {
  8411. var target = params.target;
  8412. if (typeof target === 'undefined') {
  8413. target = getDefaultSetting('externalLinkTarget');
  8414. }
  8415. link.target = LinkTargetStringMap[target];
  8416. var rel = params.rel;
  8417. if (typeof rel === 'undefined') {
  8418. rel = getDefaultSetting('externalLinkRel');
  8419. }
  8420. link.rel = rel;
  8421. }
  8422. }
  8423. function getFilenameFromUrl(url) {
  8424. var anchor = url.indexOf('#');
  8425. var query = url.indexOf('?');
  8426. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  8427. return url.substring(url.lastIndexOf('/', end) + 1, end);
  8428. }
  8429. function getDefaultSetting(id) {
  8430. var globalSettings = sharedUtil.globalScope.PDFJS;
  8431. switch (id) {
  8432. case 'pdfBug':
  8433. return globalSettings ? globalSettings.pdfBug : false;
  8434. case 'disableAutoFetch':
  8435. return globalSettings ? globalSettings.disableAutoFetch : false;
  8436. case 'disableStream':
  8437. return globalSettings ? globalSettings.disableStream : false;
  8438. case 'disableRange':
  8439. return globalSettings ? globalSettings.disableRange : false;
  8440. case 'disableFontFace':
  8441. return globalSettings ? globalSettings.disableFontFace : false;
  8442. case 'disableCreateObjectURL':
  8443. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  8444. case 'disableWebGL':
  8445. return globalSettings ? globalSettings.disableWebGL : true;
  8446. case 'cMapUrl':
  8447. return globalSettings ? globalSettings.cMapUrl : null;
  8448. case 'cMapPacked':
  8449. return globalSettings ? globalSettings.cMapPacked : false;
  8450. case 'postMessageTransfers':
  8451. return globalSettings ? globalSettings.postMessageTransfers : true;
  8452. case 'workerSrc':
  8453. return globalSettings ? globalSettings.workerSrc : null;
  8454. case 'disableWorker':
  8455. return globalSettings ? globalSettings.disableWorker : false;
  8456. case 'maxImageSize':
  8457. return globalSettings ? globalSettings.maxImageSize : -1;
  8458. case 'imageResourcesPath':
  8459. return globalSettings ? globalSettings.imageResourcesPath : '';
  8460. case 'isEvalSupported':
  8461. return globalSettings ? globalSettings.isEvalSupported : true;
  8462. case 'externalLinkTarget':
  8463. if (!globalSettings) {
  8464. return LinkTarget.NONE;
  8465. }
  8466. switch (globalSettings.externalLinkTarget) {
  8467. case LinkTarget.NONE:
  8468. case LinkTarget.SELF:
  8469. case LinkTarget.BLANK:
  8470. case LinkTarget.PARENT:
  8471. case LinkTarget.TOP:
  8472. return globalSettings.externalLinkTarget;
  8473. }
  8474. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  8475. globalSettings.externalLinkTarget = LinkTarget.NONE;
  8476. return LinkTarget.NONE;
  8477. case 'externalLinkRel':
  8478. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  8479. case 'enableStats':
  8480. return !!(globalSettings && globalSettings.enableStats);
  8481. default:
  8482. throw new Error('Unknown default setting: ' + id);
  8483. }
  8484. }
  8485. function isExternalLinkTargetSet() {
  8486. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  8487. switch (externalLinkTarget) {
  8488. case LinkTarget.NONE:
  8489. return false;
  8490. case LinkTarget.SELF:
  8491. case LinkTarget.BLANK:
  8492. case LinkTarget.PARENT:
  8493. case LinkTarget.TOP:
  8494. return true;
  8495. }
  8496. }
  8497. function isValidUrl(url, allowRelative) {
  8498. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  8499. var baseUrl = allowRelative ? 'http://example.com' : null;
  8500. return createValidAbsoluteUrl(url, baseUrl) !== null;
  8501. }
  8502. exports.CustomStyle = CustomStyle;
  8503. exports.addLinkAttributes = addLinkAttributes;
  8504. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  8505. exports.isValidUrl = isValidUrl;
  8506. exports.getFilenameFromUrl = getFilenameFromUrl;
  8507. exports.LinkTarget = LinkTarget;
  8508. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  8509. exports.getDefaultSetting = getDefaultSetting;
  8510. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  8511. exports.DOMCanvasFactory = DOMCanvasFactory;
  8512. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  8513. /***/ }),
  8514. /* 4 */
  8515. /***/ (function(module, exports, __w_pdfjs_require__) {
  8516. "use strict";
  8517. var sharedUtil = __w_pdfjs_require__(0);
  8518. var corePrimitives = __w_pdfjs_require__(1);
  8519. var coreFunction = __w_pdfjs_require__(7);
  8520. var error = sharedUtil.error;
  8521. var info = sharedUtil.info;
  8522. var isArray = sharedUtil.isArray;
  8523. var isString = sharedUtil.isString;
  8524. var shadow = sharedUtil.shadow;
  8525. var warn = sharedUtil.warn;
  8526. var isDict = corePrimitives.isDict;
  8527. var isName = corePrimitives.isName;
  8528. var isStream = corePrimitives.isStream;
  8529. var PDFFunction = coreFunction.PDFFunction;
  8530. var ColorSpace = function ColorSpaceClosure() {
  8531. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  8532. var COMPONENTS = 3;
  8533. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  8534. var xRatio = w1 / w2;
  8535. var yRatio = h1 / h2;
  8536. var i, j, py, newIndex = 0, oldIndex;
  8537. var xScaled = new Uint16Array(w2);
  8538. var w1Scanline = w1 * COMPONENTS;
  8539. for (i = 0; i < w2; i++) {
  8540. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  8541. }
  8542. for (i = 0; i < h2; i++) {
  8543. py = Math.floor(i * yRatio) * w1Scanline;
  8544. for (j = 0; j < w2; j++) {
  8545. oldIndex = py + xScaled[j];
  8546. dest[newIndex++] = src[oldIndex++];
  8547. dest[newIndex++] = src[oldIndex++];
  8548. dest[newIndex++] = src[oldIndex++];
  8549. newIndex += alpha01;
  8550. }
  8551. }
  8552. }
  8553. function ColorSpace() {
  8554. error('should not call ColorSpace constructor');
  8555. }
  8556. ColorSpace.prototype = {
  8557. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  8558. var rgb = new Uint8Array(3);
  8559. this.getRgbItem(src, srcOffset, rgb, 0);
  8560. return rgb;
  8561. },
  8562. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  8563. error('Should not call ColorSpace.getRgbItem');
  8564. },
  8565. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8566. error('Should not call ColorSpace.getRgbBuffer');
  8567. },
  8568. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  8569. error('Should not call ColorSpace.getOutputLength');
  8570. },
  8571. isPassthrough: function ColorSpace_isPassthrough(bits) {
  8572. return false;
  8573. },
  8574. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  8575. var count = originalWidth * originalHeight;
  8576. var rgbBuf = null;
  8577. var numComponentColors = 1 << bpc;
  8578. var needsResizing = originalHeight !== height || originalWidth !== width;
  8579. var i, ii;
  8580. if (this.isPassthrough(bpc)) {
  8581. rgbBuf = comps;
  8582. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  8583. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  8584. var key;
  8585. for (i = 0; i < numComponentColors; i++) {
  8586. allColors[i] = i;
  8587. }
  8588. var colorMap = new Uint8Array(numComponentColors * 3);
  8589. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  8590. var destPos, rgbPos;
  8591. if (!needsResizing) {
  8592. destPos = 0;
  8593. for (i = 0; i < count; ++i) {
  8594. key = comps[i] * 3;
  8595. dest[destPos++] = colorMap[key];
  8596. dest[destPos++] = colorMap[key + 1];
  8597. dest[destPos++] = colorMap[key + 2];
  8598. destPos += alpha01;
  8599. }
  8600. } else {
  8601. rgbBuf = new Uint8Array(count * 3);
  8602. rgbPos = 0;
  8603. for (i = 0; i < count; ++i) {
  8604. key = comps[i] * 3;
  8605. rgbBuf[rgbPos++] = colorMap[key];
  8606. rgbBuf[rgbPos++] = colorMap[key + 1];
  8607. rgbBuf[rgbPos++] = colorMap[key + 2];
  8608. }
  8609. }
  8610. } else {
  8611. if (!needsResizing) {
  8612. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  8613. } else {
  8614. rgbBuf = new Uint8Array(count * 3);
  8615. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  8616. }
  8617. }
  8618. if (rgbBuf) {
  8619. if (needsResizing) {
  8620. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  8621. } else {
  8622. rgbPos = 0;
  8623. destPos = 0;
  8624. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  8625. dest[destPos++] = rgbBuf[rgbPos++];
  8626. dest[destPos++] = rgbBuf[rgbPos++];
  8627. dest[destPos++] = rgbBuf[rgbPos++];
  8628. destPos += alpha01;
  8629. }
  8630. }
  8631. }
  8632. },
  8633. usesZeroToOneRange: true
  8634. };
  8635. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  8636. var IR = ColorSpace.parseToIR(cs, xref, res);
  8637. if (IR instanceof AlternateCS) {
  8638. return IR;
  8639. }
  8640. return ColorSpace.fromIR(IR);
  8641. };
  8642. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  8643. var name = isArray(IR) ? IR[0] : IR;
  8644. var whitePoint, blackPoint, gamma;
  8645. switch (name) {
  8646. case 'DeviceGrayCS':
  8647. return this.singletons.gray;
  8648. case 'DeviceRgbCS':
  8649. return this.singletons.rgb;
  8650. case 'DeviceCmykCS':
  8651. return this.singletons.cmyk;
  8652. case 'CalGrayCS':
  8653. whitePoint = IR[1];
  8654. blackPoint = IR[2];
  8655. gamma = IR[3];
  8656. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8657. case 'CalRGBCS':
  8658. whitePoint = IR[1];
  8659. blackPoint = IR[2];
  8660. gamma = IR[3];
  8661. var matrix = IR[4];
  8662. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8663. case 'PatternCS':
  8664. var basePatternCS = IR[1];
  8665. if (basePatternCS) {
  8666. basePatternCS = ColorSpace.fromIR(basePatternCS);
  8667. }
  8668. return new PatternCS(basePatternCS);
  8669. case 'IndexedCS':
  8670. var baseIndexedCS = IR[1];
  8671. var hiVal = IR[2];
  8672. var lookup = IR[3];
  8673. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  8674. case 'AlternateCS':
  8675. var numComps = IR[1];
  8676. var alt = IR[2];
  8677. var tintFnIR = IR[3];
  8678. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  8679. case 'LabCS':
  8680. whitePoint = IR[1];
  8681. blackPoint = IR[2];
  8682. var range = IR[3];
  8683. return new LabCS(whitePoint, blackPoint, range);
  8684. default:
  8685. error('Unknown name ' + name);
  8686. }
  8687. return null;
  8688. };
  8689. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  8690. if (isName(cs)) {
  8691. var colorSpaces = res.get('ColorSpace');
  8692. if (isDict(colorSpaces)) {
  8693. var refcs = colorSpaces.get(cs.name);
  8694. if (refcs) {
  8695. cs = refcs;
  8696. }
  8697. }
  8698. }
  8699. cs = xref.fetchIfRef(cs);
  8700. if (isName(cs)) {
  8701. switch (cs.name) {
  8702. case 'DeviceGray':
  8703. case 'G':
  8704. return 'DeviceGrayCS';
  8705. case 'DeviceRGB':
  8706. case 'RGB':
  8707. return 'DeviceRgbCS';
  8708. case 'DeviceCMYK':
  8709. case 'CMYK':
  8710. return 'DeviceCmykCS';
  8711. case 'Pattern':
  8712. return [
  8713. 'PatternCS',
  8714. null
  8715. ];
  8716. default:
  8717. error('unrecognized colorspace ' + cs.name);
  8718. }
  8719. } else if (isArray(cs)) {
  8720. var mode = xref.fetchIfRef(cs[0]).name;
  8721. var numComps, params, alt, whitePoint, blackPoint, gamma;
  8722. switch (mode) {
  8723. case 'DeviceGray':
  8724. case 'G':
  8725. return 'DeviceGrayCS';
  8726. case 'DeviceRGB':
  8727. case 'RGB':
  8728. return 'DeviceRgbCS';
  8729. case 'DeviceCMYK':
  8730. case 'CMYK':
  8731. return 'DeviceCmykCS';
  8732. case 'CalGray':
  8733. params = xref.fetchIfRef(cs[1]);
  8734. whitePoint = params.getArray('WhitePoint');
  8735. blackPoint = params.getArray('BlackPoint');
  8736. gamma = params.get('Gamma');
  8737. return [
  8738. 'CalGrayCS',
  8739. whitePoint,
  8740. blackPoint,
  8741. gamma
  8742. ];
  8743. case 'CalRGB':
  8744. params = xref.fetchIfRef(cs[1]);
  8745. whitePoint = params.getArray('WhitePoint');
  8746. blackPoint = params.getArray('BlackPoint');
  8747. gamma = params.getArray('Gamma');
  8748. var matrix = params.getArray('Matrix');
  8749. return [
  8750. 'CalRGBCS',
  8751. whitePoint,
  8752. blackPoint,
  8753. gamma,
  8754. matrix
  8755. ];
  8756. case 'ICCBased':
  8757. var stream = xref.fetchIfRef(cs[1]);
  8758. var dict = stream.dict;
  8759. numComps = dict.get('N');
  8760. alt = dict.get('Alternate');
  8761. if (alt) {
  8762. var altIR = ColorSpace.parseToIR(alt, xref, res);
  8763. var altCS = ColorSpace.fromIR(altIR);
  8764. if (altCS.numComps === numComps) {
  8765. return altIR;
  8766. }
  8767. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  8768. }
  8769. if (numComps === 1) {
  8770. return 'DeviceGrayCS';
  8771. } else if (numComps === 3) {
  8772. return 'DeviceRgbCS';
  8773. } else if (numComps === 4) {
  8774. return 'DeviceCmykCS';
  8775. }
  8776. break;
  8777. case 'Pattern':
  8778. var basePatternCS = cs[1] || null;
  8779. if (basePatternCS) {
  8780. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  8781. }
  8782. return [
  8783. 'PatternCS',
  8784. basePatternCS
  8785. ];
  8786. case 'Indexed':
  8787. case 'I':
  8788. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  8789. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  8790. var lookup = xref.fetchIfRef(cs[3]);
  8791. if (isStream(lookup)) {
  8792. lookup = lookup.getBytes();
  8793. }
  8794. return [
  8795. 'IndexedCS',
  8796. baseIndexedCS,
  8797. hiVal,
  8798. lookup
  8799. ];
  8800. case 'Separation':
  8801. case 'DeviceN':
  8802. var name = xref.fetchIfRef(cs[1]);
  8803. numComps = isArray(name) ? name.length : 1;
  8804. alt = ColorSpace.parseToIR(cs[2], xref, res);
  8805. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  8806. return [
  8807. 'AlternateCS',
  8808. numComps,
  8809. alt,
  8810. tintFnIR
  8811. ];
  8812. case 'Lab':
  8813. params = xref.fetchIfRef(cs[1]);
  8814. whitePoint = params.getArray('WhitePoint');
  8815. blackPoint = params.getArray('BlackPoint');
  8816. var range = params.getArray('Range');
  8817. return [
  8818. 'LabCS',
  8819. whitePoint,
  8820. blackPoint,
  8821. range
  8822. ];
  8823. default:
  8824. error('unimplemented color space object "' + mode + '"');
  8825. }
  8826. } else {
  8827. error('unrecognized color space object: "' + cs + '"');
  8828. }
  8829. return null;
  8830. };
  8831. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  8832. if (!isArray(decode)) {
  8833. return true;
  8834. }
  8835. if (n * 2 !== decode.length) {
  8836. warn('The decode map is not the correct length');
  8837. return true;
  8838. }
  8839. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  8840. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8841. return false;
  8842. }
  8843. }
  8844. return true;
  8845. };
  8846. ColorSpace.singletons = {
  8847. get gray() {
  8848. return shadow(this, 'gray', new DeviceGrayCS());
  8849. },
  8850. get rgb() {
  8851. return shadow(this, 'rgb', new DeviceRgbCS());
  8852. },
  8853. get cmyk() {
  8854. return shadow(this, 'cmyk', new DeviceCmykCS());
  8855. }
  8856. };
  8857. return ColorSpace;
  8858. }();
  8859. var AlternateCS = function AlternateCSClosure() {
  8860. function AlternateCS(numComps, base, tintFn) {
  8861. this.name = 'Alternate';
  8862. this.numComps = numComps;
  8863. this.defaultColor = new Float32Array(numComps);
  8864. for (var i = 0; i < numComps; ++i) {
  8865. this.defaultColor[i] = 1;
  8866. }
  8867. this.base = base;
  8868. this.tintFn = tintFn;
  8869. this.tmpBuf = new Float32Array(base.numComps);
  8870. }
  8871. AlternateCS.prototype = {
  8872. getRgb: ColorSpace.prototype.getRgb,
  8873. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8874. var tmpBuf = this.tmpBuf;
  8875. this.tintFn(src, srcOffset, tmpBuf, 0);
  8876. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8877. },
  8878. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8879. var tintFn = this.tintFn;
  8880. var base = this.base;
  8881. var scale = 1 / ((1 << bits) - 1);
  8882. var baseNumComps = base.numComps;
  8883. var usesZeroToOneRange = base.usesZeroToOneRange;
  8884. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8885. var pos = isPassthrough ? destOffset : 0;
  8886. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  8887. var numComps = this.numComps;
  8888. var scaled = new Float32Array(numComps);
  8889. var tinted = new Float32Array(baseNumComps);
  8890. var i, j;
  8891. for (i = 0; i < count; i++) {
  8892. for (j = 0; j < numComps; j++) {
  8893. scaled[j] = src[srcOffset++] * scale;
  8894. }
  8895. tintFn(scaled, 0, tinted, 0);
  8896. if (usesZeroToOneRange) {
  8897. for (j = 0; j < baseNumComps; j++) {
  8898. baseBuf[pos++] = tinted[j] * 255;
  8899. }
  8900. } else {
  8901. base.getRgbItem(tinted, 0, baseBuf, pos);
  8902. pos += baseNumComps;
  8903. }
  8904. }
  8905. if (!isPassthrough) {
  8906. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8907. }
  8908. },
  8909. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  8910. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8911. },
  8912. isPassthrough: ColorSpace.prototype.isPassthrough,
  8913. fillRgb: ColorSpace.prototype.fillRgb,
  8914. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  8915. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8916. },
  8917. usesZeroToOneRange: true
  8918. };
  8919. return AlternateCS;
  8920. }();
  8921. var PatternCS = function PatternCSClosure() {
  8922. function PatternCS(baseCS) {
  8923. this.name = 'Pattern';
  8924. this.base = baseCS;
  8925. }
  8926. PatternCS.prototype = {};
  8927. return PatternCS;
  8928. }();
  8929. var IndexedCS = function IndexedCSClosure() {
  8930. function IndexedCS(base, highVal, lookup) {
  8931. this.name = 'Indexed';
  8932. this.numComps = 1;
  8933. this.defaultColor = new Uint8Array(this.numComps);
  8934. this.base = base;
  8935. this.highVal = highVal;
  8936. var baseNumComps = base.numComps;
  8937. var length = baseNumComps * highVal;
  8938. if (isStream(lookup)) {
  8939. this.lookup = new Uint8Array(length);
  8940. var bytes = lookup.getBytes(length);
  8941. this.lookup.set(bytes);
  8942. } else if (isString(lookup)) {
  8943. this.lookup = new Uint8Array(length);
  8944. for (var i = 0; i < length; ++i) {
  8945. this.lookup[i] = lookup.charCodeAt(i);
  8946. }
  8947. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  8948. this.lookup = lookup;
  8949. } else {
  8950. error('Unrecognized lookup table: ' + lookup);
  8951. }
  8952. }
  8953. IndexedCS.prototype = {
  8954. getRgb: ColorSpace.prototype.getRgb,
  8955. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8956. var numComps = this.base.numComps;
  8957. var start = src[srcOffset] * numComps;
  8958. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  8959. },
  8960. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8961. var base = this.base;
  8962. var numComps = base.numComps;
  8963. var outputDelta = base.getOutputLength(numComps, alpha01);
  8964. var lookup = this.lookup;
  8965. for (var i = 0; i < count; ++i) {
  8966. var lookupPos = src[srcOffset++] * numComps;
  8967. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8968. destOffset += outputDelta;
  8969. }
  8970. },
  8971. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  8972. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8973. },
  8974. isPassthrough: ColorSpace.prototype.isPassthrough,
  8975. fillRgb: ColorSpace.prototype.fillRgb,
  8976. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  8977. return true;
  8978. },
  8979. usesZeroToOneRange: true
  8980. };
  8981. return IndexedCS;
  8982. }();
  8983. var DeviceGrayCS = function DeviceGrayCSClosure() {
  8984. function DeviceGrayCS() {
  8985. this.name = 'DeviceGray';
  8986. this.numComps = 1;
  8987. this.defaultColor = new Float32Array(this.numComps);
  8988. }
  8989. DeviceGrayCS.prototype = {
  8990. getRgb: ColorSpace.prototype.getRgb,
  8991. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8992. var c = src[srcOffset] * 255 | 0;
  8993. c = c < 0 ? 0 : c > 255 ? 255 : c;
  8994. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  8995. },
  8996. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8997. var scale = 255 / ((1 << bits) - 1);
  8998. var j = srcOffset, q = destOffset;
  8999. for (var i = 0; i < count; ++i) {
  9000. var c = scale * src[j++] | 0;
  9001. dest[q++] = c;
  9002. dest[q++] = c;
  9003. dest[q++] = c;
  9004. q += alpha01;
  9005. }
  9006. },
  9007. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9008. return inputLength * (3 + alpha01);
  9009. },
  9010. isPassthrough: ColorSpace.prototype.isPassthrough,
  9011. fillRgb: ColorSpace.prototype.fillRgb,
  9012. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9013. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9014. },
  9015. usesZeroToOneRange: true
  9016. };
  9017. return DeviceGrayCS;
  9018. }();
  9019. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9020. function DeviceRgbCS() {
  9021. this.name = 'DeviceRGB';
  9022. this.numComps = 3;
  9023. this.defaultColor = new Float32Array(this.numComps);
  9024. }
  9025. DeviceRgbCS.prototype = {
  9026. getRgb: ColorSpace.prototype.getRgb,
  9027. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9028. var r = src[srcOffset] * 255 | 0;
  9029. var g = src[srcOffset + 1] * 255 | 0;
  9030. var b = src[srcOffset + 2] * 255 | 0;
  9031. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9032. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9033. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9034. },
  9035. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9036. if (bits === 8 && alpha01 === 0) {
  9037. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9038. return;
  9039. }
  9040. var scale = 255 / ((1 << bits) - 1);
  9041. var j = srcOffset, q = destOffset;
  9042. for (var i = 0; i < count; ++i) {
  9043. dest[q++] = scale * src[j++] | 0;
  9044. dest[q++] = scale * src[j++] | 0;
  9045. dest[q++] = scale * src[j++] | 0;
  9046. q += alpha01;
  9047. }
  9048. },
  9049. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9050. return inputLength * (3 + alpha01) / 3 | 0;
  9051. },
  9052. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9053. return bits === 8;
  9054. },
  9055. fillRgb: ColorSpace.prototype.fillRgb,
  9056. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9057. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9058. },
  9059. usesZeroToOneRange: true
  9060. };
  9061. return DeviceRgbCS;
  9062. }();
  9063. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9064. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9065. var c = src[srcOffset + 0] * srcScale;
  9066. var m = src[srcOffset + 1] * srcScale;
  9067. var y = src[srcOffset + 2] * srcScale;
  9068. var k = src[srcOffset + 3] * srcScale;
  9069. 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;
  9070. 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;
  9071. 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;
  9072. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9073. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9074. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9075. }
  9076. function DeviceCmykCS() {
  9077. this.name = 'DeviceCMYK';
  9078. this.numComps = 4;
  9079. this.defaultColor = new Float32Array(this.numComps);
  9080. this.defaultColor[3] = 1;
  9081. }
  9082. DeviceCmykCS.prototype = {
  9083. getRgb: ColorSpace.prototype.getRgb,
  9084. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9085. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9086. },
  9087. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9088. var scale = 1 / ((1 << bits) - 1);
  9089. for (var i = 0; i < count; i++) {
  9090. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9091. srcOffset += 4;
  9092. destOffset += 3 + alpha01;
  9093. }
  9094. },
  9095. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9096. return inputLength / 4 * (3 + alpha01) | 0;
  9097. },
  9098. isPassthrough: ColorSpace.prototype.isPassthrough,
  9099. fillRgb: ColorSpace.prototype.fillRgb,
  9100. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9101. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9102. },
  9103. usesZeroToOneRange: true
  9104. };
  9105. return DeviceCmykCS;
  9106. }();
  9107. var CalGrayCS = function CalGrayCSClosure() {
  9108. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9109. this.name = 'CalGray';
  9110. this.numComps = 1;
  9111. this.defaultColor = new Float32Array(this.numComps);
  9112. if (!whitePoint) {
  9113. error('WhitePoint missing - required for color space CalGray');
  9114. }
  9115. blackPoint = blackPoint || [
  9116. 0,
  9117. 0,
  9118. 0
  9119. ];
  9120. gamma = gamma || 1;
  9121. this.XW = whitePoint[0];
  9122. this.YW = whitePoint[1];
  9123. this.ZW = whitePoint[2];
  9124. this.XB = blackPoint[0];
  9125. this.YB = blackPoint[1];
  9126. this.ZB = blackPoint[2];
  9127. this.G = gamma;
  9128. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9129. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9130. }
  9131. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9132. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9133. this.XB = this.YB = this.ZB = 0;
  9134. }
  9135. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9136. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9137. }
  9138. if (this.G < 1) {
  9139. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9140. this.G = 1;
  9141. }
  9142. }
  9143. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9144. var A = src[srcOffset] * scale;
  9145. var AG = Math.pow(A, cs.G);
  9146. var L = cs.YW * AG;
  9147. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9148. dest[destOffset] = val;
  9149. dest[destOffset + 1] = val;
  9150. dest[destOffset + 2] = val;
  9151. }
  9152. CalGrayCS.prototype = {
  9153. getRgb: ColorSpace.prototype.getRgb,
  9154. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9155. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9156. },
  9157. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9158. var scale = 1 / ((1 << bits) - 1);
  9159. for (var i = 0; i < count; ++i) {
  9160. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9161. srcOffset += 1;
  9162. destOffset += 3 + alpha01;
  9163. }
  9164. },
  9165. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9166. return inputLength * (3 + alpha01);
  9167. },
  9168. isPassthrough: ColorSpace.prototype.isPassthrough,
  9169. fillRgb: ColorSpace.prototype.fillRgb,
  9170. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9171. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9172. },
  9173. usesZeroToOneRange: true
  9174. };
  9175. return CalGrayCS;
  9176. }();
  9177. var CalRGBCS = function CalRGBCSClosure() {
  9178. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9179. 0.8951,
  9180. 0.2664,
  9181. -0.1614,
  9182. -0.7502,
  9183. 1.7135,
  9184. 0.0367,
  9185. 0.0389,
  9186. -0.0685,
  9187. 1.0296
  9188. ]);
  9189. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9190. 0.9869929,
  9191. -0.1470543,
  9192. 0.1599627,
  9193. 0.4323053,
  9194. 0.5183603,
  9195. 0.0492912,
  9196. -0.0085287,
  9197. 0.0400428,
  9198. 0.9684867
  9199. ]);
  9200. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9201. 3.2404542,
  9202. -1.5371385,
  9203. -0.4985314,
  9204. -0.9692660,
  9205. 1.8760108,
  9206. 0.0415560,
  9207. 0.0556434,
  9208. -0.2040259,
  9209. 1.0572252
  9210. ]);
  9211. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9212. 1,
  9213. 1,
  9214. 1
  9215. ]);
  9216. var tempNormalizeMatrix = new Float32Array(3);
  9217. var tempConvertMatrix1 = new Float32Array(3);
  9218. var tempConvertMatrix2 = new Float32Array(3);
  9219. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9220. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9221. this.name = 'CalRGB';
  9222. this.numComps = 3;
  9223. this.defaultColor = new Float32Array(this.numComps);
  9224. if (!whitePoint) {
  9225. error('WhitePoint missing - required for color space CalRGB');
  9226. }
  9227. blackPoint = blackPoint || new Float32Array(3);
  9228. gamma = gamma || new Float32Array([
  9229. 1,
  9230. 1,
  9231. 1
  9232. ]);
  9233. matrix = matrix || new Float32Array([
  9234. 1,
  9235. 0,
  9236. 0,
  9237. 0,
  9238. 1,
  9239. 0,
  9240. 0,
  9241. 0,
  9242. 1
  9243. ]);
  9244. var XW = whitePoint[0];
  9245. var YW = whitePoint[1];
  9246. var ZW = whitePoint[2];
  9247. this.whitePoint = whitePoint;
  9248. var XB = blackPoint[0];
  9249. var YB = blackPoint[1];
  9250. var ZB = blackPoint[2];
  9251. this.blackPoint = blackPoint;
  9252. this.GR = gamma[0];
  9253. this.GG = gamma[1];
  9254. this.GB = gamma[2];
  9255. this.MXA = matrix[0];
  9256. this.MYA = matrix[1];
  9257. this.MZA = matrix[2];
  9258. this.MXB = matrix[3];
  9259. this.MYB = matrix[4];
  9260. this.MZB = matrix[5];
  9261. this.MXC = matrix[6];
  9262. this.MYC = matrix[7];
  9263. this.MZC = matrix[8];
  9264. if (XW < 0 || ZW < 0 || YW !== 1) {
  9265. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9266. }
  9267. if (XB < 0 || YB < 0 || ZB < 0) {
  9268. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  9269. this.blackPoint = new Float32Array(3);
  9270. }
  9271. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  9272. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  9273. this.GR = this.GG = this.GB = 1;
  9274. }
  9275. 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) {
  9276. 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');
  9277. this.MXA = this.MYB = this.MZC = 1;
  9278. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  9279. }
  9280. }
  9281. function matrixProduct(a, b, result) {
  9282. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  9283. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  9284. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  9285. }
  9286. function convertToFlat(sourceWhitePoint, LMS, result) {
  9287. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  9288. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  9289. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  9290. }
  9291. function convertToD65(sourceWhitePoint, LMS, result) {
  9292. var D65X = 0.95047;
  9293. var D65Y = 1;
  9294. var D65Z = 1.08883;
  9295. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  9296. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  9297. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  9298. }
  9299. function sRGBTransferFunction(color) {
  9300. if (color <= 0.0031308) {
  9301. return adjustToRange(0, 1, 12.92 * color);
  9302. }
  9303. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  9304. }
  9305. function adjustToRange(min, max, value) {
  9306. return Math.max(min, Math.min(max, value));
  9307. }
  9308. function decodeL(L) {
  9309. if (L < 0) {
  9310. return -decodeL(-L);
  9311. }
  9312. if (L > 8.0) {
  9313. return Math.pow((L + 16) / 116, 3);
  9314. }
  9315. return L * DECODE_L_CONSTANT;
  9316. }
  9317. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  9318. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  9319. result[0] = XYZ_Flat[0];
  9320. result[1] = XYZ_Flat[1];
  9321. result[2] = XYZ_Flat[2];
  9322. return;
  9323. }
  9324. var zeroDecodeL = decodeL(0);
  9325. var X_DST = zeroDecodeL;
  9326. var X_SRC = decodeL(sourceBlackPoint[0]);
  9327. var Y_DST = zeroDecodeL;
  9328. var Y_SRC = decodeL(sourceBlackPoint[1]);
  9329. var Z_DST = zeroDecodeL;
  9330. var Z_SRC = decodeL(sourceBlackPoint[2]);
  9331. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  9332. var X_Offset = 1 - X_Scale;
  9333. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  9334. var Y_Offset = 1 - Y_Scale;
  9335. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  9336. var Z_Offset = 1 - Z_Scale;
  9337. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  9338. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  9339. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  9340. }
  9341. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  9342. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  9343. result[0] = XYZ_In[0];
  9344. result[1] = XYZ_In[1];
  9345. result[2] = XYZ_In[2];
  9346. return;
  9347. }
  9348. var LMS = result;
  9349. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9350. var LMS_Flat = tempNormalizeMatrix;
  9351. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  9352. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  9353. }
  9354. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  9355. var LMS = result;
  9356. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9357. var LMS_D65 = tempNormalizeMatrix;
  9358. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  9359. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  9360. }
  9361. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9362. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  9363. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  9364. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  9365. var AGR = Math.pow(A, cs.GR);
  9366. var BGG = Math.pow(B, cs.GG);
  9367. var CGB = Math.pow(C, cs.GB);
  9368. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  9369. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  9370. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  9371. var XYZ = tempConvertMatrix1;
  9372. XYZ[0] = X;
  9373. XYZ[1] = Y;
  9374. XYZ[2] = Z;
  9375. var XYZ_Flat = tempConvertMatrix2;
  9376. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  9377. var XYZ_Black = tempConvertMatrix1;
  9378. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  9379. var XYZ_D65 = tempConvertMatrix2;
  9380. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  9381. var SRGB = tempConvertMatrix1;
  9382. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  9383. var sR = sRGBTransferFunction(SRGB[0]);
  9384. var sG = sRGBTransferFunction(SRGB[1]);
  9385. var sB = sRGBTransferFunction(SRGB[2]);
  9386. dest[destOffset] = Math.round(sR * 255);
  9387. dest[destOffset + 1] = Math.round(sG * 255);
  9388. dest[destOffset + 2] = Math.round(sB * 255);
  9389. }
  9390. CalRGBCS.prototype = {
  9391. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  9392. var rgb = new Uint8Array(3);
  9393. this.getRgbItem(src, srcOffset, rgb, 0);
  9394. return rgb;
  9395. },
  9396. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9397. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9398. },
  9399. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9400. var scale = 1 / ((1 << bits) - 1);
  9401. for (var i = 0; i < count; ++i) {
  9402. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9403. srcOffset += 3;
  9404. destOffset += 3 + alpha01;
  9405. }
  9406. },
  9407. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  9408. return inputLength * (3 + alpha01) / 3 | 0;
  9409. },
  9410. isPassthrough: ColorSpace.prototype.isPassthrough,
  9411. fillRgb: ColorSpace.prototype.fillRgb,
  9412. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  9413. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9414. },
  9415. usesZeroToOneRange: true
  9416. };
  9417. return CalRGBCS;
  9418. }();
  9419. var LabCS = function LabCSClosure() {
  9420. function LabCS(whitePoint, blackPoint, range) {
  9421. this.name = 'Lab';
  9422. this.numComps = 3;
  9423. this.defaultColor = new Float32Array(this.numComps);
  9424. if (!whitePoint) {
  9425. error('WhitePoint missing - required for color space Lab');
  9426. }
  9427. blackPoint = blackPoint || [
  9428. 0,
  9429. 0,
  9430. 0
  9431. ];
  9432. range = range || [
  9433. -100,
  9434. 100,
  9435. -100,
  9436. 100
  9437. ];
  9438. this.XW = whitePoint[0];
  9439. this.YW = whitePoint[1];
  9440. this.ZW = whitePoint[2];
  9441. this.amin = range[0];
  9442. this.amax = range[1];
  9443. this.bmin = range[2];
  9444. this.bmax = range[3];
  9445. this.XB = blackPoint[0];
  9446. this.YB = blackPoint[1];
  9447. this.ZB = blackPoint[2];
  9448. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9449. error('Invalid WhitePoint components, no fallback available');
  9450. }
  9451. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9452. info('Invalid BlackPoint, falling back to default');
  9453. this.XB = this.YB = this.ZB = 0;
  9454. }
  9455. if (this.amin > this.amax || this.bmin > this.bmax) {
  9456. info('Invalid Range, falling back to defaults');
  9457. this.amin = -100;
  9458. this.amax = 100;
  9459. this.bmin = -100;
  9460. this.bmax = 100;
  9461. }
  9462. }
  9463. function fn_g(x) {
  9464. var result;
  9465. if (x >= 6 / 29) {
  9466. result = x * x * x;
  9467. } else {
  9468. result = 108 / 841 * (x - 4 / 29);
  9469. }
  9470. return result;
  9471. }
  9472. function decode(value, high1, low2, high2) {
  9473. return low2 + value * (high2 - low2) / high1;
  9474. }
  9475. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  9476. var Ls = src[srcOffset];
  9477. var as = src[srcOffset + 1];
  9478. var bs = src[srcOffset + 2];
  9479. if (maxVal !== false) {
  9480. Ls = decode(Ls, maxVal, 0, 100);
  9481. as = decode(as, maxVal, cs.amin, cs.amax);
  9482. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  9483. }
  9484. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  9485. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  9486. var M = (Ls + 16) / 116;
  9487. var L = M + as / 500;
  9488. var N = M - bs / 200;
  9489. var X = cs.XW * fn_g(L);
  9490. var Y = cs.YW * fn_g(M);
  9491. var Z = cs.ZW * fn_g(N);
  9492. var r, g, b;
  9493. if (cs.ZW < 1) {
  9494. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  9495. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  9496. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  9497. } else {
  9498. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  9499. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  9500. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  9501. }
  9502. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  9503. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  9504. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  9505. }
  9506. LabCS.prototype = {
  9507. getRgb: ColorSpace.prototype.getRgb,
  9508. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9509. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  9510. },
  9511. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9512. var maxVal = (1 << bits) - 1;
  9513. for (var i = 0; i < count; i++) {
  9514. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  9515. srcOffset += 3;
  9516. destOffset += 3 + alpha01;
  9517. }
  9518. },
  9519. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  9520. return inputLength * (3 + alpha01) / 3 | 0;
  9521. },
  9522. isPassthrough: ColorSpace.prototype.isPassthrough,
  9523. fillRgb: ColorSpace.prototype.fillRgb,
  9524. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  9525. return true;
  9526. },
  9527. usesZeroToOneRange: false
  9528. };
  9529. return LabCS;
  9530. }();
  9531. exports.ColorSpace = ColorSpace;
  9532. /***/ }),
  9533. /* 5 */
  9534. /***/ (function(module, exports, __w_pdfjs_require__) {
  9535. "use strict";
  9536. var ExpertEncoding = [
  9537. '',
  9538. '',
  9539. '',
  9540. '',
  9541. '',
  9542. '',
  9543. '',
  9544. '',
  9545. '',
  9546. '',
  9547. '',
  9548. '',
  9549. '',
  9550. '',
  9551. '',
  9552. '',
  9553. '',
  9554. '',
  9555. '',
  9556. '',
  9557. '',
  9558. '',
  9559. '',
  9560. '',
  9561. '',
  9562. '',
  9563. '',
  9564. '',
  9565. '',
  9566. '',
  9567. '',
  9568. '',
  9569. 'space',
  9570. 'exclamsmall',
  9571. 'Hungarumlautsmall',
  9572. '',
  9573. 'dollaroldstyle',
  9574. 'dollarsuperior',
  9575. 'ampersandsmall',
  9576. 'Acutesmall',
  9577. 'parenleftsuperior',
  9578. 'parenrightsuperior',
  9579. 'twodotenleader',
  9580. 'onedotenleader',
  9581. 'comma',
  9582. 'hyphen',
  9583. 'period',
  9584. 'fraction',
  9585. 'zerooldstyle',
  9586. 'oneoldstyle',
  9587. 'twooldstyle',
  9588. 'threeoldstyle',
  9589. 'fouroldstyle',
  9590. 'fiveoldstyle',
  9591. 'sixoldstyle',
  9592. 'sevenoldstyle',
  9593. 'eightoldstyle',
  9594. 'nineoldstyle',
  9595. 'colon',
  9596. 'semicolon',
  9597. 'commasuperior',
  9598. 'threequartersemdash',
  9599. 'periodsuperior',
  9600. 'questionsmall',
  9601. '',
  9602. 'asuperior',
  9603. 'bsuperior',
  9604. 'centsuperior',
  9605. 'dsuperior',
  9606. 'esuperior',
  9607. '',
  9608. '',
  9609. 'isuperior',
  9610. '',
  9611. '',
  9612. 'lsuperior',
  9613. 'msuperior',
  9614. 'nsuperior',
  9615. 'osuperior',
  9616. '',
  9617. '',
  9618. 'rsuperior',
  9619. 'ssuperior',
  9620. 'tsuperior',
  9621. '',
  9622. 'ff',
  9623. 'fi',
  9624. 'fl',
  9625. 'ffi',
  9626. 'ffl',
  9627. 'parenleftinferior',
  9628. '',
  9629. 'parenrightinferior',
  9630. 'Circumflexsmall',
  9631. 'hyphensuperior',
  9632. 'Gravesmall',
  9633. 'Asmall',
  9634. 'Bsmall',
  9635. 'Csmall',
  9636. 'Dsmall',
  9637. 'Esmall',
  9638. 'Fsmall',
  9639. 'Gsmall',
  9640. 'Hsmall',
  9641. 'Ismall',
  9642. 'Jsmall',
  9643. 'Ksmall',
  9644. 'Lsmall',
  9645. 'Msmall',
  9646. 'Nsmall',
  9647. 'Osmall',
  9648. 'Psmall',
  9649. 'Qsmall',
  9650. 'Rsmall',
  9651. 'Ssmall',
  9652. 'Tsmall',
  9653. 'Usmall',
  9654. 'Vsmall',
  9655. 'Wsmall',
  9656. 'Xsmall',
  9657. 'Ysmall',
  9658. 'Zsmall',
  9659. 'colonmonetary',
  9660. 'onefitted',
  9661. 'rupiah',
  9662. 'Tildesmall',
  9663. '',
  9664. '',
  9665. '',
  9666. '',
  9667. '',
  9668. '',
  9669. '',
  9670. '',
  9671. '',
  9672. '',
  9673. '',
  9674. '',
  9675. '',
  9676. '',
  9677. '',
  9678. '',
  9679. '',
  9680. '',
  9681. '',
  9682. '',
  9683. '',
  9684. '',
  9685. '',
  9686. '',
  9687. '',
  9688. '',
  9689. '',
  9690. '',
  9691. '',
  9692. '',
  9693. '',
  9694. '',
  9695. '',
  9696. '',
  9697. 'exclamdownsmall',
  9698. 'centoldstyle',
  9699. 'Lslashsmall',
  9700. '',
  9701. '',
  9702. 'Scaronsmall',
  9703. 'Zcaronsmall',
  9704. 'Dieresissmall',
  9705. 'Brevesmall',
  9706. 'Caronsmall',
  9707. '',
  9708. 'Dotaccentsmall',
  9709. '',
  9710. '',
  9711. 'Macronsmall',
  9712. '',
  9713. '',
  9714. 'figuredash',
  9715. 'hypheninferior',
  9716. '',
  9717. '',
  9718. 'Ogoneksmall',
  9719. 'Ringsmall',
  9720. 'Cedillasmall',
  9721. '',
  9722. '',
  9723. '',
  9724. 'onequarter',
  9725. 'onehalf',
  9726. 'threequarters',
  9727. 'questiondownsmall',
  9728. 'oneeighth',
  9729. 'threeeighths',
  9730. 'fiveeighths',
  9731. 'seveneighths',
  9732. 'onethird',
  9733. 'twothirds',
  9734. '',
  9735. '',
  9736. 'zerosuperior',
  9737. 'onesuperior',
  9738. 'twosuperior',
  9739. 'threesuperior',
  9740. 'foursuperior',
  9741. 'fivesuperior',
  9742. 'sixsuperior',
  9743. 'sevensuperior',
  9744. 'eightsuperior',
  9745. 'ninesuperior',
  9746. 'zeroinferior',
  9747. 'oneinferior',
  9748. 'twoinferior',
  9749. 'threeinferior',
  9750. 'fourinferior',
  9751. 'fiveinferior',
  9752. 'sixinferior',
  9753. 'seveninferior',
  9754. 'eightinferior',
  9755. 'nineinferior',
  9756. 'centinferior',
  9757. 'dollarinferior',
  9758. 'periodinferior',
  9759. 'commainferior',
  9760. 'Agravesmall',
  9761. 'Aacutesmall',
  9762. 'Acircumflexsmall',
  9763. 'Atildesmall',
  9764. 'Adieresissmall',
  9765. 'Aringsmall',
  9766. 'AEsmall',
  9767. 'Ccedillasmall',
  9768. 'Egravesmall',
  9769. 'Eacutesmall',
  9770. 'Ecircumflexsmall',
  9771. 'Edieresissmall',
  9772. 'Igravesmall',
  9773. 'Iacutesmall',
  9774. 'Icircumflexsmall',
  9775. 'Idieresissmall',
  9776. 'Ethsmall',
  9777. 'Ntildesmall',
  9778. 'Ogravesmall',
  9779. 'Oacutesmall',
  9780. 'Ocircumflexsmall',
  9781. 'Otildesmall',
  9782. 'Odieresissmall',
  9783. 'OEsmall',
  9784. 'Oslashsmall',
  9785. 'Ugravesmall',
  9786. 'Uacutesmall',
  9787. 'Ucircumflexsmall',
  9788. 'Udieresissmall',
  9789. 'Yacutesmall',
  9790. 'Thornsmall',
  9791. 'Ydieresissmall'
  9792. ];
  9793. var MacExpertEncoding = [
  9794. '',
  9795. '',
  9796. '',
  9797. '',
  9798. '',
  9799. '',
  9800. '',
  9801. '',
  9802. '',
  9803. '',
  9804. '',
  9805. '',
  9806. '',
  9807. '',
  9808. '',
  9809. '',
  9810. '',
  9811. '',
  9812. '',
  9813. '',
  9814. '',
  9815. '',
  9816. '',
  9817. '',
  9818. '',
  9819. '',
  9820. '',
  9821. '',
  9822. '',
  9823. '',
  9824. '',
  9825. '',
  9826. 'space',
  9827. 'exclamsmall',
  9828. 'Hungarumlautsmall',
  9829. 'centoldstyle',
  9830. 'dollaroldstyle',
  9831. 'dollarsuperior',
  9832. 'ampersandsmall',
  9833. 'Acutesmall',
  9834. 'parenleftsuperior',
  9835. 'parenrightsuperior',
  9836. 'twodotenleader',
  9837. 'onedotenleader',
  9838. 'comma',
  9839. 'hyphen',
  9840. 'period',
  9841. 'fraction',
  9842. 'zerooldstyle',
  9843. 'oneoldstyle',
  9844. 'twooldstyle',
  9845. 'threeoldstyle',
  9846. 'fouroldstyle',
  9847. 'fiveoldstyle',
  9848. 'sixoldstyle',
  9849. 'sevenoldstyle',
  9850. 'eightoldstyle',
  9851. 'nineoldstyle',
  9852. 'colon',
  9853. 'semicolon',
  9854. '',
  9855. 'threequartersemdash',
  9856. '',
  9857. 'questionsmall',
  9858. '',
  9859. '',
  9860. '',
  9861. '',
  9862. 'Ethsmall',
  9863. '',
  9864. '',
  9865. 'onequarter',
  9866. 'onehalf',
  9867. 'threequarters',
  9868. 'oneeighth',
  9869. 'threeeighths',
  9870. 'fiveeighths',
  9871. 'seveneighths',
  9872. 'onethird',
  9873. 'twothirds',
  9874. '',
  9875. '',
  9876. '',
  9877. '',
  9878. '',
  9879. '',
  9880. 'ff',
  9881. 'fi',
  9882. 'fl',
  9883. 'ffi',
  9884. 'ffl',
  9885. 'parenleftinferior',
  9886. '',
  9887. 'parenrightinferior',
  9888. 'Circumflexsmall',
  9889. 'hypheninferior',
  9890. 'Gravesmall',
  9891. 'Asmall',
  9892. 'Bsmall',
  9893. 'Csmall',
  9894. 'Dsmall',
  9895. 'Esmall',
  9896. 'Fsmall',
  9897. 'Gsmall',
  9898. 'Hsmall',
  9899. 'Ismall',
  9900. 'Jsmall',
  9901. 'Ksmall',
  9902. 'Lsmall',
  9903. 'Msmall',
  9904. 'Nsmall',
  9905. 'Osmall',
  9906. 'Psmall',
  9907. 'Qsmall',
  9908. 'Rsmall',
  9909. 'Ssmall',
  9910. 'Tsmall',
  9911. 'Usmall',
  9912. 'Vsmall',
  9913. 'Wsmall',
  9914. 'Xsmall',
  9915. 'Ysmall',
  9916. 'Zsmall',
  9917. 'colonmonetary',
  9918. 'onefitted',
  9919. 'rupiah',
  9920. 'Tildesmall',
  9921. '',
  9922. '',
  9923. 'asuperior',
  9924. 'centsuperior',
  9925. '',
  9926. '',
  9927. '',
  9928. '',
  9929. 'Aacutesmall',
  9930. 'Agravesmall',
  9931. 'Acircumflexsmall',
  9932. 'Adieresissmall',
  9933. 'Atildesmall',
  9934. 'Aringsmall',
  9935. 'Ccedillasmall',
  9936. 'Eacutesmall',
  9937. 'Egravesmall',
  9938. 'Ecircumflexsmall',
  9939. 'Edieresissmall',
  9940. 'Iacutesmall',
  9941. 'Igravesmall',
  9942. 'Icircumflexsmall',
  9943. 'Idieresissmall',
  9944. 'Ntildesmall',
  9945. 'Oacutesmall',
  9946. 'Ogravesmall',
  9947. 'Ocircumflexsmall',
  9948. 'Odieresissmall',
  9949. 'Otildesmall',
  9950. 'Uacutesmall',
  9951. 'Ugravesmall',
  9952. 'Ucircumflexsmall',
  9953. 'Udieresissmall',
  9954. '',
  9955. 'eightsuperior',
  9956. 'fourinferior',
  9957. 'threeinferior',
  9958. 'sixinferior',
  9959. 'eightinferior',
  9960. 'seveninferior',
  9961. 'Scaronsmall',
  9962. '',
  9963. 'centinferior',
  9964. 'twoinferior',
  9965. '',
  9966. 'Dieresissmall',
  9967. '',
  9968. 'Caronsmall',
  9969. 'osuperior',
  9970. 'fiveinferior',
  9971. '',
  9972. 'commainferior',
  9973. 'periodinferior',
  9974. 'Yacutesmall',
  9975. '',
  9976. 'dollarinferior',
  9977. '',
  9978. 'Thornsmall',
  9979. '',
  9980. 'nineinferior',
  9981. 'zeroinferior',
  9982. 'Zcaronsmall',
  9983. 'AEsmall',
  9984. 'Oslashsmall',
  9985. 'questiondownsmall',
  9986. 'oneinferior',
  9987. 'Lslashsmall',
  9988. '',
  9989. '',
  9990. '',
  9991. '',
  9992. '',
  9993. '',
  9994. 'Cedillasmall',
  9995. '',
  9996. '',
  9997. '',
  9998. '',
  9999. '',
  10000. 'OEsmall',
  10001. 'figuredash',
  10002. 'hyphensuperior',
  10003. '',
  10004. '',
  10005. '',
  10006. '',
  10007. 'exclamdownsmall',
  10008. '',
  10009. 'Ydieresissmall',
  10010. '',
  10011. 'onesuperior',
  10012. 'twosuperior',
  10013. 'threesuperior',
  10014. 'foursuperior',
  10015. 'fivesuperior',
  10016. 'sixsuperior',
  10017. 'sevensuperior',
  10018. 'ninesuperior',
  10019. 'zerosuperior',
  10020. '',
  10021. 'esuperior',
  10022. 'rsuperior',
  10023. 'tsuperior',
  10024. '',
  10025. '',
  10026. 'isuperior',
  10027. 'ssuperior',
  10028. 'dsuperior',
  10029. '',
  10030. '',
  10031. '',
  10032. '',
  10033. '',
  10034. 'lsuperior',
  10035. 'Ogoneksmall',
  10036. 'Brevesmall',
  10037. 'Macronsmall',
  10038. 'bsuperior',
  10039. 'nsuperior',
  10040. 'msuperior',
  10041. 'commasuperior',
  10042. 'periodsuperior',
  10043. 'Dotaccentsmall',
  10044. 'Ringsmall'
  10045. ];
  10046. var MacRomanEncoding = [
  10047. '',
  10048. '',
  10049. '',
  10050. '',
  10051. '',
  10052. '',
  10053. '',
  10054. '',
  10055. '',
  10056. '',
  10057. '',
  10058. '',
  10059. '',
  10060. '',
  10061. '',
  10062. '',
  10063. '',
  10064. '',
  10065. '',
  10066. '',
  10067. '',
  10068. '',
  10069. '',
  10070. '',
  10071. '',
  10072. '',
  10073. '',
  10074. '',
  10075. '',
  10076. '',
  10077. '',
  10078. '',
  10079. 'space',
  10080. 'exclam',
  10081. 'quotedbl',
  10082. 'numbersign',
  10083. 'dollar',
  10084. 'percent',
  10085. 'ampersand',
  10086. 'quotesingle',
  10087. 'parenleft',
  10088. 'parenright',
  10089. 'asterisk',
  10090. 'plus',
  10091. 'comma',
  10092. 'hyphen',
  10093. 'period',
  10094. 'slash',
  10095. 'zero',
  10096. 'one',
  10097. 'two',
  10098. 'three',
  10099. 'four',
  10100. 'five',
  10101. 'six',
  10102. 'seven',
  10103. 'eight',
  10104. 'nine',
  10105. 'colon',
  10106. 'semicolon',
  10107. 'less',
  10108. 'equal',
  10109. 'greater',
  10110. 'question',
  10111. 'at',
  10112. 'A',
  10113. 'B',
  10114. 'C',
  10115. 'D',
  10116. 'E',
  10117. 'F',
  10118. 'G',
  10119. 'H',
  10120. 'I',
  10121. 'J',
  10122. 'K',
  10123. 'L',
  10124. 'M',
  10125. 'N',
  10126. 'O',
  10127. 'P',
  10128. 'Q',
  10129. 'R',
  10130. 'S',
  10131. 'T',
  10132. 'U',
  10133. 'V',
  10134. 'W',
  10135. 'X',
  10136. 'Y',
  10137. 'Z',
  10138. 'bracketleft',
  10139. 'backslash',
  10140. 'bracketright',
  10141. 'asciicircum',
  10142. 'underscore',
  10143. 'grave',
  10144. 'a',
  10145. 'b',
  10146. 'c',
  10147. 'd',
  10148. 'e',
  10149. 'f',
  10150. 'g',
  10151. 'h',
  10152. 'i',
  10153. 'j',
  10154. 'k',
  10155. 'l',
  10156. 'm',
  10157. 'n',
  10158. 'o',
  10159. 'p',
  10160. 'q',
  10161. 'r',
  10162. 's',
  10163. 't',
  10164. 'u',
  10165. 'v',
  10166. 'w',
  10167. 'x',
  10168. 'y',
  10169. 'z',
  10170. 'braceleft',
  10171. 'bar',
  10172. 'braceright',
  10173. 'asciitilde',
  10174. '',
  10175. 'Adieresis',
  10176. 'Aring',
  10177. 'Ccedilla',
  10178. 'Eacute',
  10179. 'Ntilde',
  10180. 'Odieresis',
  10181. 'Udieresis',
  10182. 'aacute',
  10183. 'agrave',
  10184. 'acircumflex',
  10185. 'adieresis',
  10186. 'atilde',
  10187. 'aring',
  10188. 'ccedilla',
  10189. 'eacute',
  10190. 'egrave',
  10191. 'ecircumflex',
  10192. 'edieresis',
  10193. 'iacute',
  10194. 'igrave',
  10195. 'icircumflex',
  10196. 'idieresis',
  10197. 'ntilde',
  10198. 'oacute',
  10199. 'ograve',
  10200. 'ocircumflex',
  10201. 'odieresis',
  10202. 'otilde',
  10203. 'uacute',
  10204. 'ugrave',
  10205. 'ucircumflex',
  10206. 'udieresis',
  10207. 'dagger',
  10208. 'degree',
  10209. 'cent',
  10210. 'sterling',
  10211. 'section',
  10212. 'bullet',
  10213. 'paragraph',
  10214. 'germandbls',
  10215. 'registered',
  10216. 'copyright',
  10217. 'trademark',
  10218. 'acute',
  10219. 'dieresis',
  10220. 'notequal',
  10221. 'AE',
  10222. 'Oslash',
  10223. 'infinity',
  10224. 'plusminus',
  10225. 'lessequal',
  10226. 'greaterequal',
  10227. 'yen',
  10228. 'mu',
  10229. 'partialdiff',
  10230. 'summation',
  10231. 'product',
  10232. 'pi',
  10233. 'integral',
  10234. 'ordfeminine',
  10235. 'ordmasculine',
  10236. 'Omega',
  10237. 'ae',
  10238. 'oslash',
  10239. 'questiondown',
  10240. 'exclamdown',
  10241. 'logicalnot',
  10242. 'radical',
  10243. 'florin',
  10244. 'approxequal',
  10245. 'Delta',
  10246. 'guillemotleft',
  10247. 'guillemotright',
  10248. 'ellipsis',
  10249. 'space',
  10250. 'Agrave',
  10251. 'Atilde',
  10252. 'Otilde',
  10253. 'OE',
  10254. 'oe',
  10255. 'endash',
  10256. 'emdash',
  10257. 'quotedblleft',
  10258. 'quotedblright',
  10259. 'quoteleft',
  10260. 'quoteright',
  10261. 'divide',
  10262. 'lozenge',
  10263. 'ydieresis',
  10264. 'Ydieresis',
  10265. 'fraction',
  10266. 'currency',
  10267. 'guilsinglleft',
  10268. 'guilsinglright',
  10269. 'fi',
  10270. 'fl',
  10271. 'daggerdbl',
  10272. 'periodcentered',
  10273. 'quotesinglbase',
  10274. 'quotedblbase',
  10275. 'perthousand',
  10276. 'Acircumflex',
  10277. 'Ecircumflex',
  10278. 'Aacute',
  10279. 'Edieresis',
  10280. 'Egrave',
  10281. 'Iacute',
  10282. 'Icircumflex',
  10283. 'Idieresis',
  10284. 'Igrave',
  10285. 'Oacute',
  10286. 'Ocircumflex',
  10287. 'apple',
  10288. 'Ograve',
  10289. 'Uacute',
  10290. 'Ucircumflex',
  10291. 'Ugrave',
  10292. 'dotlessi',
  10293. 'circumflex',
  10294. 'tilde',
  10295. 'macron',
  10296. 'breve',
  10297. 'dotaccent',
  10298. 'ring',
  10299. 'cedilla',
  10300. 'hungarumlaut',
  10301. 'ogonek',
  10302. 'caron'
  10303. ];
  10304. var StandardEncoding = [
  10305. '',
  10306. '',
  10307. '',
  10308. '',
  10309. '',
  10310. '',
  10311. '',
  10312. '',
  10313. '',
  10314. '',
  10315. '',
  10316. '',
  10317. '',
  10318. '',
  10319. '',
  10320. '',
  10321. '',
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. 'space',
  10338. 'exclam',
  10339. 'quotedbl',
  10340. 'numbersign',
  10341. 'dollar',
  10342. 'percent',
  10343. 'ampersand',
  10344. 'quoteright',
  10345. 'parenleft',
  10346. 'parenright',
  10347. 'asterisk',
  10348. 'plus',
  10349. 'comma',
  10350. 'hyphen',
  10351. 'period',
  10352. 'slash',
  10353. 'zero',
  10354. 'one',
  10355. 'two',
  10356. 'three',
  10357. 'four',
  10358. 'five',
  10359. 'six',
  10360. 'seven',
  10361. 'eight',
  10362. 'nine',
  10363. 'colon',
  10364. 'semicolon',
  10365. 'less',
  10366. 'equal',
  10367. 'greater',
  10368. 'question',
  10369. 'at',
  10370. 'A',
  10371. 'B',
  10372. 'C',
  10373. 'D',
  10374. 'E',
  10375. 'F',
  10376. 'G',
  10377. 'H',
  10378. 'I',
  10379. 'J',
  10380. 'K',
  10381. 'L',
  10382. 'M',
  10383. 'N',
  10384. 'O',
  10385. 'P',
  10386. 'Q',
  10387. 'R',
  10388. 'S',
  10389. 'T',
  10390. 'U',
  10391. 'V',
  10392. 'W',
  10393. 'X',
  10394. 'Y',
  10395. 'Z',
  10396. 'bracketleft',
  10397. 'backslash',
  10398. 'bracketright',
  10399. 'asciicircum',
  10400. 'underscore',
  10401. 'quoteleft',
  10402. 'a',
  10403. 'b',
  10404. 'c',
  10405. 'd',
  10406. 'e',
  10407. 'f',
  10408. 'g',
  10409. 'h',
  10410. 'i',
  10411. 'j',
  10412. 'k',
  10413. 'l',
  10414. 'm',
  10415. 'n',
  10416. 'o',
  10417. 'p',
  10418. 'q',
  10419. 'r',
  10420. 's',
  10421. 't',
  10422. 'u',
  10423. 'v',
  10424. 'w',
  10425. 'x',
  10426. 'y',
  10427. 'z',
  10428. 'braceleft',
  10429. 'bar',
  10430. 'braceright',
  10431. 'asciitilde',
  10432. '',
  10433. '',
  10434. '',
  10435. '',
  10436. '',
  10437. '',
  10438. '',
  10439. '',
  10440. '',
  10441. '',
  10442. '',
  10443. '',
  10444. '',
  10445. '',
  10446. '',
  10447. '',
  10448. '',
  10449. '',
  10450. '',
  10451. '',
  10452. '',
  10453. '',
  10454. '',
  10455. '',
  10456. '',
  10457. '',
  10458. '',
  10459. '',
  10460. '',
  10461. '',
  10462. '',
  10463. '',
  10464. '',
  10465. '',
  10466. 'exclamdown',
  10467. 'cent',
  10468. 'sterling',
  10469. 'fraction',
  10470. 'yen',
  10471. 'florin',
  10472. 'section',
  10473. 'currency',
  10474. 'quotesingle',
  10475. 'quotedblleft',
  10476. 'guillemotleft',
  10477. 'guilsinglleft',
  10478. 'guilsinglright',
  10479. 'fi',
  10480. 'fl',
  10481. '',
  10482. 'endash',
  10483. 'dagger',
  10484. 'daggerdbl',
  10485. 'periodcentered',
  10486. '',
  10487. 'paragraph',
  10488. 'bullet',
  10489. 'quotesinglbase',
  10490. 'quotedblbase',
  10491. 'quotedblright',
  10492. 'guillemotright',
  10493. 'ellipsis',
  10494. 'perthousand',
  10495. '',
  10496. 'questiondown',
  10497. '',
  10498. 'grave',
  10499. 'acute',
  10500. 'circumflex',
  10501. 'tilde',
  10502. 'macron',
  10503. 'breve',
  10504. 'dotaccent',
  10505. 'dieresis',
  10506. '',
  10507. 'ring',
  10508. 'cedilla',
  10509. '',
  10510. 'hungarumlaut',
  10511. 'ogonek',
  10512. 'caron',
  10513. 'emdash',
  10514. '',
  10515. '',
  10516. '',
  10517. '',
  10518. '',
  10519. '',
  10520. '',
  10521. '',
  10522. '',
  10523. '',
  10524. '',
  10525. '',
  10526. '',
  10527. '',
  10528. '',
  10529. '',
  10530. 'AE',
  10531. '',
  10532. 'ordfeminine',
  10533. '',
  10534. '',
  10535. '',
  10536. '',
  10537. 'Lslash',
  10538. 'Oslash',
  10539. 'OE',
  10540. 'ordmasculine',
  10541. '',
  10542. '',
  10543. '',
  10544. '',
  10545. '',
  10546. 'ae',
  10547. '',
  10548. '',
  10549. '',
  10550. 'dotlessi',
  10551. '',
  10552. '',
  10553. 'lslash',
  10554. 'oslash',
  10555. 'oe',
  10556. 'germandbls'
  10557. ];
  10558. var WinAnsiEncoding = [
  10559. '',
  10560. '',
  10561. '',
  10562. '',
  10563. '',
  10564. '',
  10565. '',
  10566. '',
  10567. '',
  10568. '',
  10569. '',
  10570. '',
  10571. '',
  10572. '',
  10573. '',
  10574. '',
  10575. '',
  10576. '',
  10577. '',
  10578. '',
  10579. '',
  10580. '',
  10581. '',
  10582. '',
  10583. '',
  10584. '',
  10585. '',
  10586. '',
  10587. '',
  10588. '',
  10589. '',
  10590. '',
  10591. 'space',
  10592. 'exclam',
  10593. 'quotedbl',
  10594. 'numbersign',
  10595. 'dollar',
  10596. 'percent',
  10597. 'ampersand',
  10598. 'quotesingle',
  10599. 'parenleft',
  10600. 'parenright',
  10601. 'asterisk',
  10602. 'plus',
  10603. 'comma',
  10604. 'hyphen',
  10605. 'period',
  10606. 'slash',
  10607. 'zero',
  10608. 'one',
  10609. 'two',
  10610. 'three',
  10611. 'four',
  10612. 'five',
  10613. 'six',
  10614. 'seven',
  10615. 'eight',
  10616. 'nine',
  10617. 'colon',
  10618. 'semicolon',
  10619. 'less',
  10620. 'equal',
  10621. 'greater',
  10622. 'question',
  10623. 'at',
  10624. 'A',
  10625. 'B',
  10626. 'C',
  10627. 'D',
  10628. 'E',
  10629. 'F',
  10630. 'G',
  10631. 'H',
  10632. 'I',
  10633. 'J',
  10634. 'K',
  10635. 'L',
  10636. 'M',
  10637. 'N',
  10638. 'O',
  10639. 'P',
  10640. 'Q',
  10641. 'R',
  10642. 'S',
  10643. 'T',
  10644. 'U',
  10645. 'V',
  10646. 'W',
  10647. 'X',
  10648. 'Y',
  10649. 'Z',
  10650. 'bracketleft',
  10651. 'backslash',
  10652. 'bracketright',
  10653. 'asciicircum',
  10654. 'underscore',
  10655. 'grave',
  10656. 'a',
  10657. 'b',
  10658. 'c',
  10659. 'd',
  10660. 'e',
  10661. 'f',
  10662. 'g',
  10663. 'h',
  10664. 'i',
  10665. 'j',
  10666. 'k',
  10667. 'l',
  10668. 'm',
  10669. 'n',
  10670. 'o',
  10671. 'p',
  10672. 'q',
  10673. 'r',
  10674. 's',
  10675. 't',
  10676. 'u',
  10677. 'v',
  10678. 'w',
  10679. 'x',
  10680. 'y',
  10681. 'z',
  10682. 'braceleft',
  10683. 'bar',
  10684. 'braceright',
  10685. 'asciitilde',
  10686. 'bullet',
  10687. 'Euro',
  10688. 'bullet',
  10689. 'quotesinglbase',
  10690. 'florin',
  10691. 'quotedblbase',
  10692. 'ellipsis',
  10693. 'dagger',
  10694. 'daggerdbl',
  10695. 'circumflex',
  10696. 'perthousand',
  10697. 'Scaron',
  10698. 'guilsinglleft',
  10699. 'OE',
  10700. 'bullet',
  10701. 'Zcaron',
  10702. 'bullet',
  10703. 'bullet',
  10704. 'quoteleft',
  10705. 'quoteright',
  10706. 'quotedblleft',
  10707. 'quotedblright',
  10708. 'bullet',
  10709. 'endash',
  10710. 'emdash',
  10711. 'tilde',
  10712. 'trademark',
  10713. 'scaron',
  10714. 'guilsinglright',
  10715. 'oe',
  10716. 'bullet',
  10717. 'zcaron',
  10718. 'Ydieresis',
  10719. 'space',
  10720. 'exclamdown',
  10721. 'cent',
  10722. 'sterling',
  10723. 'currency',
  10724. 'yen',
  10725. 'brokenbar',
  10726. 'section',
  10727. 'dieresis',
  10728. 'copyright',
  10729. 'ordfeminine',
  10730. 'guillemotleft',
  10731. 'logicalnot',
  10732. 'hyphen',
  10733. 'registered',
  10734. 'macron',
  10735. 'degree',
  10736. 'plusminus',
  10737. 'twosuperior',
  10738. 'threesuperior',
  10739. 'acute',
  10740. 'mu',
  10741. 'paragraph',
  10742. 'periodcentered',
  10743. 'cedilla',
  10744. 'onesuperior',
  10745. 'ordmasculine',
  10746. 'guillemotright',
  10747. 'onequarter',
  10748. 'onehalf',
  10749. 'threequarters',
  10750. 'questiondown',
  10751. 'Agrave',
  10752. 'Aacute',
  10753. 'Acircumflex',
  10754. 'Atilde',
  10755. 'Adieresis',
  10756. 'Aring',
  10757. 'AE',
  10758. 'Ccedilla',
  10759. 'Egrave',
  10760. 'Eacute',
  10761. 'Ecircumflex',
  10762. 'Edieresis',
  10763. 'Igrave',
  10764. 'Iacute',
  10765. 'Icircumflex',
  10766. 'Idieresis',
  10767. 'Eth',
  10768. 'Ntilde',
  10769. 'Ograve',
  10770. 'Oacute',
  10771. 'Ocircumflex',
  10772. 'Otilde',
  10773. 'Odieresis',
  10774. 'multiply',
  10775. 'Oslash',
  10776. 'Ugrave',
  10777. 'Uacute',
  10778. 'Ucircumflex',
  10779. 'Udieresis',
  10780. 'Yacute',
  10781. 'Thorn',
  10782. 'germandbls',
  10783. 'agrave',
  10784. 'aacute',
  10785. 'acircumflex',
  10786. 'atilde',
  10787. 'adieresis',
  10788. 'aring',
  10789. 'ae',
  10790. 'ccedilla',
  10791. 'egrave',
  10792. 'eacute',
  10793. 'ecircumflex',
  10794. 'edieresis',
  10795. 'igrave',
  10796. 'iacute',
  10797. 'icircumflex',
  10798. 'idieresis',
  10799. 'eth',
  10800. 'ntilde',
  10801. 'ograve',
  10802. 'oacute',
  10803. 'ocircumflex',
  10804. 'otilde',
  10805. 'odieresis',
  10806. 'divide',
  10807. 'oslash',
  10808. 'ugrave',
  10809. 'uacute',
  10810. 'ucircumflex',
  10811. 'udieresis',
  10812. 'yacute',
  10813. 'thorn',
  10814. 'ydieresis'
  10815. ];
  10816. var SymbolSetEncoding = [
  10817. '',
  10818. '',
  10819. '',
  10820. '',
  10821. '',
  10822. '',
  10823. '',
  10824. '',
  10825. '',
  10826. '',
  10827. '',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. '',
  10833. '',
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. 'space',
  10850. 'exclam',
  10851. 'universal',
  10852. 'numbersign',
  10853. 'existential',
  10854. 'percent',
  10855. 'ampersand',
  10856. 'suchthat',
  10857. 'parenleft',
  10858. 'parenright',
  10859. 'asteriskmath',
  10860. 'plus',
  10861. 'comma',
  10862. 'minus',
  10863. 'period',
  10864. 'slash',
  10865. 'zero',
  10866. 'one',
  10867. 'two',
  10868. 'three',
  10869. 'four',
  10870. 'five',
  10871. 'six',
  10872. 'seven',
  10873. 'eight',
  10874. 'nine',
  10875. 'colon',
  10876. 'semicolon',
  10877. 'less',
  10878. 'equal',
  10879. 'greater',
  10880. 'question',
  10881. 'congruent',
  10882. 'Alpha',
  10883. 'Beta',
  10884. 'Chi',
  10885. 'Delta',
  10886. 'Epsilon',
  10887. 'Phi',
  10888. 'Gamma',
  10889. 'Eta',
  10890. 'Iota',
  10891. 'theta1',
  10892. 'Kappa',
  10893. 'Lambda',
  10894. 'Mu',
  10895. 'Nu',
  10896. 'Omicron',
  10897. 'Pi',
  10898. 'Theta',
  10899. 'Rho',
  10900. 'Sigma',
  10901. 'Tau',
  10902. 'Upsilon',
  10903. 'sigma1',
  10904. 'Omega',
  10905. 'Xi',
  10906. 'Psi',
  10907. 'Zeta',
  10908. 'bracketleft',
  10909. 'therefore',
  10910. 'bracketright',
  10911. 'perpendicular',
  10912. 'underscore',
  10913. 'radicalex',
  10914. 'alpha',
  10915. 'beta',
  10916. 'chi',
  10917. 'delta',
  10918. 'epsilon',
  10919. 'phi',
  10920. 'gamma',
  10921. 'eta',
  10922. 'iota',
  10923. 'phi1',
  10924. 'kappa',
  10925. 'lambda',
  10926. 'mu',
  10927. 'nu',
  10928. 'omicron',
  10929. 'pi',
  10930. 'theta',
  10931. 'rho',
  10932. 'sigma',
  10933. 'tau',
  10934. 'upsilon',
  10935. 'omega1',
  10936. 'omega',
  10937. 'xi',
  10938. 'psi',
  10939. 'zeta',
  10940. 'braceleft',
  10941. 'bar',
  10942. 'braceright',
  10943. 'similar',
  10944. '',
  10945. '',
  10946. '',
  10947. '',
  10948. '',
  10949. '',
  10950. '',
  10951. '',
  10952. '',
  10953. '',
  10954. '',
  10955. '',
  10956. '',
  10957. '',
  10958. '',
  10959. '',
  10960. '',
  10961. '',
  10962. '',
  10963. '',
  10964. '',
  10965. '',
  10966. '',
  10967. '',
  10968. '',
  10969. '',
  10970. '',
  10971. '',
  10972. '',
  10973. '',
  10974. '',
  10975. '',
  10976. '',
  10977. 'Euro',
  10978. 'Upsilon1',
  10979. 'minute',
  10980. 'lessequal',
  10981. 'fraction',
  10982. 'infinity',
  10983. 'florin',
  10984. 'club',
  10985. 'diamond',
  10986. 'heart',
  10987. 'spade',
  10988. 'arrowboth',
  10989. 'arrowleft',
  10990. 'arrowup',
  10991. 'arrowright',
  10992. 'arrowdown',
  10993. 'degree',
  10994. 'plusminus',
  10995. 'second',
  10996. 'greaterequal',
  10997. 'multiply',
  10998. 'proportional',
  10999. 'partialdiff',
  11000. 'bullet',
  11001. 'divide',
  11002. 'notequal',
  11003. 'equivalence',
  11004. 'approxequal',
  11005. 'ellipsis',
  11006. 'arrowvertex',
  11007. 'arrowhorizex',
  11008. 'carriagereturn',
  11009. 'aleph',
  11010. 'Ifraktur',
  11011. 'Rfraktur',
  11012. 'weierstrass',
  11013. 'circlemultiply',
  11014. 'circleplus',
  11015. 'emptyset',
  11016. 'intersection',
  11017. 'union',
  11018. 'propersuperset',
  11019. 'reflexsuperset',
  11020. 'notsubset',
  11021. 'propersubset',
  11022. 'reflexsubset',
  11023. 'element',
  11024. 'notelement',
  11025. 'angle',
  11026. 'gradient',
  11027. 'registerserif',
  11028. 'copyrightserif',
  11029. 'trademarkserif',
  11030. 'product',
  11031. 'radical',
  11032. 'dotmath',
  11033. 'logicalnot',
  11034. 'logicaland',
  11035. 'logicalor',
  11036. 'arrowdblboth',
  11037. 'arrowdblleft',
  11038. 'arrowdblup',
  11039. 'arrowdblright',
  11040. 'arrowdbldown',
  11041. 'lozenge',
  11042. 'angleleft',
  11043. 'registersans',
  11044. 'copyrightsans',
  11045. 'trademarksans',
  11046. 'summation',
  11047. 'parenlefttp',
  11048. 'parenleftex',
  11049. 'parenleftbt',
  11050. 'bracketlefttp',
  11051. 'bracketleftex',
  11052. 'bracketleftbt',
  11053. 'bracelefttp',
  11054. 'braceleftmid',
  11055. 'braceleftbt',
  11056. 'braceex',
  11057. '',
  11058. 'angleright',
  11059. 'integral',
  11060. 'integraltp',
  11061. 'integralex',
  11062. 'integralbt',
  11063. 'parenrighttp',
  11064. 'parenrightex',
  11065. 'parenrightbt',
  11066. 'bracketrighttp',
  11067. 'bracketrightex',
  11068. 'bracketrightbt',
  11069. 'bracerighttp',
  11070. 'bracerightmid',
  11071. 'bracerightbt'
  11072. ];
  11073. var ZapfDingbatsEncoding = [
  11074. '',
  11075. '',
  11076. '',
  11077. '',
  11078. '',
  11079. '',
  11080. '',
  11081. '',
  11082. '',
  11083. '',
  11084. '',
  11085. '',
  11086. '',
  11087. '',
  11088. '',
  11089. '',
  11090. '',
  11091. '',
  11092. '',
  11093. '',
  11094. '',
  11095. '',
  11096. '',
  11097. '',
  11098. '',
  11099. '',
  11100. '',
  11101. '',
  11102. '',
  11103. '',
  11104. '',
  11105. '',
  11106. 'space',
  11107. 'a1',
  11108. 'a2',
  11109. 'a202',
  11110. 'a3',
  11111. 'a4',
  11112. 'a5',
  11113. 'a119',
  11114. 'a118',
  11115. 'a117',
  11116. 'a11',
  11117. 'a12',
  11118. 'a13',
  11119. 'a14',
  11120. 'a15',
  11121. 'a16',
  11122. 'a105',
  11123. 'a17',
  11124. 'a18',
  11125. 'a19',
  11126. 'a20',
  11127. 'a21',
  11128. 'a22',
  11129. 'a23',
  11130. 'a24',
  11131. 'a25',
  11132. 'a26',
  11133. 'a27',
  11134. 'a28',
  11135. 'a6',
  11136. 'a7',
  11137. 'a8',
  11138. 'a9',
  11139. 'a10',
  11140. 'a29',
  11141. 'a30',
  11142. 'a31',
  11143. 'a32',
  11144. 'a33',
  11145. 'a34',
  11146. 'a35',
  11147. 'a36',
  11148. 'a37',
  11149. 'a38',
  11150. 'a39',
  11151. 'a40',
  11152. 'a41',
  11153. 'a42',
  11154. 'a43',
  11155. 'a44',
  11156. 'a45',
  11157. 'a46',
  11158. 'a47',
  11159. 'a48',
  11160. 'a49',
  11161. 'a50',
  11162. 'a51',
  11163. 'a52',
  11164. 'a53',
  11165. 'a54',
  11166. 'a55',
  11167. 'a56',
  11168. 'a57',
  11169. 'a58',
  11170. 'a59',
  11171. 'a60',
  11172. 'a61',
  11173. 'a62',
  11174. 'a63',
  11175. 'a64',
  11176. 'a65',
  11177. 'a66',
  11178. 'a67',
  11179. 'a68',
  11180. 'a69',
  11181. 'a70',
  11182. 'a71',
  11183. 'a72',
  11184. 'a73',
  11185. 'a74',
  11186. 'a203',
  11187. 'a75',
  11188. 'a204',
  11189. 'a76',
  11190. 'a77',
  11191. 'a78',
  11192. 'a79',
  11193. 'a81',
  11194. 'a82',
  11195. 'a83',
  11196. 'a84',
  11197. 'a97',
  11198. 'a98',
  11199. 'a99',
  11200. 'a100',
  11201. '',
  11202. 'a89',
  11203. 'a90',
  11204. 'a93',
  11205. 'a94',
  11206. 'a91',
  11207. 'a92',
  11208. 'a205',
  11209. 'a85',
  11210. 'a206',
  11211. 'a86',
  11212. 'a87',
  11213. 'a88',
  11214. 'a95',
  11215. 'a96',
  11216. '',
  11217. '',
  11218. '',
  11219. '',
  11220. '',
  11221. '',
  11222. '',
  11223. '',
  11224. '',
  11225. '',
  11226. '',
  11227. '',
  11228. '',
  11229. '',
  11230. '',
  11231. '',
  11232. '',
  11233. '',
  11234. '',
  11235. 'a101',
  11236. 'a102',
  11237. 'a103',
  11238. 'a104',
  11239. 'a106',
  11240. 'a107',
  11241. 'a108',
  11242. 'a112',
  11243. 'a111',
  11244. 'a110',
  11245. 'a109',
  11246. 'a120',
  11247. 'a121',
  11248. 'a122',
  11249. 'a123',
  11250. 'a124',
  11251. 'a125',
  11252. 'a126',
  11253. 'a127',
  11254. 'a128',
  11255. 'a129',
  11256. 'a130',
  11257. 'a131',
  11258. 'a132',
  11259. 'a133',
  11260. 'a134',
  11261. 'a135',
  11262. 'a136',
  11263. 'a137',
  11264. 'a138',
  11265. 'a139',
  11266. 'a140',
  11267. 'a141',
  11268. 'a142',
  11269. 'a143',
  11270. 'a144',
  11271. 'a145',
  11272. 'a146',
  11273. 'a147',
  11274. 'a148',
  11275. 'a149',
  11276. 'a150',
  11277. 'a151',
  11278. 'a152',
  11279. 'a153',
  11280. 'a154',
  11281. 'a155',
  11282. 'a156',
  11283. 'a157',
  11284. 'a158',
  11285. 'a159',
  11286. 'a160',
  11287. 'a161',
  11288. 'a163',
  11289. 'a164',
  11290. 'a196',
  11291. 'a165',
  11292. 'a192',
  11293. 'a166',
  11294. 'a167',
  11295. 'a168',
  11296. 'a169',
  11297. 'a170',
  11298. 'a171',
  11299. 'a172',
  11300. 'a173',
  11301. 'a162',
  11302. 'a174',
  11303. 'a175',
  11304. 'a176',
  11305. 'a177',
  11306. 'a178',
  11307. 'a179',
  11308. 'a193',
  11309. 'a180',
  11310. 'a199',
  11311. 'a181',
  11312. 'a200',
  11313. 'a182',
  11314. '',
  11315. 'a201',
  11316. 'a183',
  11317. 'a184',
  11318. 'a197',
  11319. 'a185',
  11320. 'a194',
  11321. 'a198',
  11322. 'a186',
  11323. 'a195',
  11324. 'a187',
  11325. 'a188',
  11326. 'a189',
  11327. 'a190',
  11328. 'a191'
  11329. ];
  11330. function getEncoding(encodingName) {
  11331. switch (encodingName) {
  11332. case 'WinAnsiEncoding':
  11333. return WinAnsiEncoding;
  11334. case 'StandardEncoding':
  11335. return StandardEncoding;
  11336. case 'MacRomanEncoding':
  11337. return MacRomanEncoding;
  11338. case 'SymbolSetEncoding':
  11339. return SymbolSetEncoding;
  11340. case 'ZapfDingbatsEncoding':
  11341. return ZapfDingbatsEncoding;
  11342. case 'ExpertEncoding':
  11343. return ExpertEncoding;
  11344. case 'MacExpertEncoding':
  11345. return MacExpertEncoding;
  11346. default:
  11347. return null;
  11348. }
  11349. }
  11350. exports.WinAnsiEncoding = WinAnsiEncoding;
  11351. exports.StandardEncoding = StandardEncoding;
  11352. exports.MacRomanEncoding = MacRomanEncoding;
  11353. exports.SymbolSetEncoding = SymbolSetEncoding;
  11354. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  11355. exports.ExpertEncoding = ExpertEncoding;
  11356. exports.getEncoding = getEncoding;
  11357. /***/ }),
  11358. /* 6 */
  11359. /***/ (function(module, exports, __w_pdfjs_require__) {
  11360. "use strict";
  11361. var sharedUtil = __w_pdfjs_require__(0);
  11362. var corePrimitives = __w_pdfjs_require__(1);
  11363. var coreStream = __w_pdfjs_require__(2);
  11364. var MissingDataException = sharedUtil.MissingDataException;
  11365. var StreamType = sharedUtil.StreamType;
  11366. var assert = sharedUtil.assert;
  11367. var error = sharedUtil.error;
  11368. var info = sharedUtil.info;
  11369. var isArray = sharedUtil.isArray;
  11370. var isInt = sharedUtil.isInt;
  11371. var isNum = sharedUtil.isNum;
  11372. var isString = sharedUtil.isString;
  11373. var warn = sharedUtil.warn;
  11374. var EOF = corePrimitives.EOF;
  11375. var Cmd = corePrimitives.Cmd;
  11376. var Dict = corePrimitives.Dict;
  11377. var Name = corePrimitives.Name;
  11378. var Ref = corePrimitives.Ref;
  11379. var isEOF = corePrimitives.isEOF;
  11380. var isCmd = corePrimitives.isCmd;
  11381. var isDict = corePrimitives.isDict;
  11382. var isName = corePrimitives.isName;
  11383. var Ascii85Stream = coreStream.Ascii85Stream;
  11384. var AsciiHexStream = coreStream.AsciiHexStream;
  11385. var CCITTFaxStream = coreStream.CCITTFaxStream;
  11386. var FlateStream = coreStream.FlateStream;
  11387. var Jbig2Stream = coreStream.Jbig2Stream;
  11388. var JpegStream = coreStream.JpegStream;
  11389. var JpxStream = coreStream.JpxStream;
  11390. var LZWStream = coreStream.LZWStream;
  11391. var NullStream = coreStream.NullStream;
  11392. var PredictorStream = coreStream.PredictorStream;
  11393. var RunLengthStream = coreStream.RunLengthStream;
  11394. var MAX_LENGTH_TO_CACHE = 1000;
  11395. var Parser = function ParserClosure() {
  11396. function Parser(lexer, allowStreams, xref, recoveryMode) {
  11397. this.lexer = lexer;
  11398. this.allowStreams = allowStreams;
  11399. this.xref = xref;
  11400. this.recoveryMode = recoveryMode || false;
  11401. this.imageCache = Object.create(null);
  11402. this.refill();
  11403. }
  11404. Parser.prototype = {
  11405. refill: function Parser_refill() {
  11406. this.buf1 = this.lexer.getObj();
  11407. this.buf2 = this.lexer.getObj();
  11408. },
  11409. shift: function Parser_shift() {
  11410. if (isCmd(this.buf2, 'ID')) {
  11411. this.buf1 = this.buf2;
  11412. this.buf2 = null;
  11413. } else {
  11414. this.buf1 = this.buf2;
  11415. this.buf2 = this.lexer.getObj();
  11416. }
  11417. },
  11418. tryShift: function Parser_tryShift() {
  11419. try {
  11420. this.shift();
  11421. return true;
  11422. } catch (e) {
  11423. if (e instanceof MissingDataException) {
  11424. throw e;
  11425. }
  11426. return false;
  11427. }
  11428. },
  11429. getObj: function Parser_getObj(cipherTransform) {
  11430. var buf1 = this.buf1;
  11431. this.shift();
  11432. if (buf1 instanceof Cmd) {
  11433. switch (buf1.cmd) {
  11434. case 'BI':
  11435. return this.makeInlineImage(cipherTransform);
  11436. case '[':
  11437. var array = [];
  11438. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  11439. array.push(this.getObj(cipherTransform));
  11440. }
  11441. if (isEOF(this.buf1)) {
  11442. if (!this.recoveryMode) {
  11443. error('End of file inside array');
  11444. }
  11445. return array;
  11446. }
  11447. this.shift();
  11448. return array;
  11449. case '<<':
  11450. var dict = new Dict(this.xref);
  11451. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  11452. if (!isName(this.buf1)) {
  11453. info('Malformed dictionary: key must be a name object');
  11454. this.shift();
  11455. continue;
  11456. }
  11457. var key = this.buf1.name;
  11458. this.shift();
  11459. if (isEOF(this.buf1)) {
  11460. break;
  11461. }
  11462. dict.set(key, this.getObj(cipherTransform));
  11463. }
  11464. if (isEOF(this.buf1)) {
  11465. if (!this.recoveryMode) {
  11466. error('End of file inside dictionary');
  11467. }
  11468. return dict;
  11469. }
  11470. if (isCmd(this.buf2, 'stream')) {
  11471. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  11472. }
  11473. this.shift();
  11474. return dict;
  11475. default:
  11476. return buf1;
  11477. }
  11478. }
  11479. if (isInt(buf1)) {
  11480. var num = buf1;
  11481. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  11482. var ref = new Ref(num, this.buf1);
  11483. this.shift();
  11484. this.shift();
  11485. return ref;
  11486. }
  11487. return num;
  11488. }
  11489. if (isString(buf1)) {
  11490. var str = buf1;
  11491. if (cipherTransform) {
  11492. str = cipherTransform.decryptString(str);
  11493. }
  11494. return str;
  11495. }
  11496. return buf1;
  11497. },
  11498. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  11499. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  11500. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  11501. while ((ch = stream.getByte()) !== -1) {
  11502. if (state === 0) {
  11503. state = ch === E ? 1 : 0;
  11504. } else if (state === 1) {
  11505. state = ch === I ? 2 : 0;
  11506. } else {
  11507. assert(state === 2);
  11508. if (ch === SPACE || ch === LF || ch === CR) {
  11509. n = 5;
  11510. followingBytes = stream.peekBytes(n);
  11511. for (i = 0; i < n; i++) {
  11512. ch = followingBytes[i];
  11513. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  11514. state = 0;
  11515. break;
  11516. }
  11517. }
  11518. if (state === 2) {
  11519. break;
  11520. }
  11521. } else {
  11522. state = 0;
  11523. }
  11524. }
  11525. }
  11526. return stream.pos - 4 - startPos;
  11527. },
  11528. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  11529. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  11530. while ((b = stream.getByte()) !== -1) {
  11531. if (b !== 0xFF) {
  11532. continue;
  11533. }
  11534. switch (stream.getByte()) {
  11535. case 0x00:
  11536. break;
  11537. case 0xFF:
  11538. stream.skip(-1);
  11539. break;
  11540. case 0xD9:
  11541. foundEOI = true;
  11542. break;
  11543. case 0xC0:
  11544. case 0xC1:
  11545. case 0xC2:
  11546. case 0xC3:
  11547. case 0xC5:
  11548. case 0xC6:
  11549. case 0xC7:
  11550. case 0xC9:
  11551. case 0xCA:
  11552. case 0xCB:
  11553. case 0xCD:
  11554. case 0xCE:
  11555. case 0xCF:
  11556. case 0xC4:
  11557. case 0xCC:
  11558. case 0xDA:
  11559. case 0xDB:
  11560. case 0xDC:
  11561. case 0xDD:
  11562. case 0xDE:
  11563. case 0xDF:
  11564. case 0xE0:
  11565. case 0xE1:
  11566. case 0xE2:
  11567. case 0xE3:
  11568. case 0xE4:
  11569. case 0xE5:
  11570. case 0xE6:
  11571. case 0xE7:
  11572. case 0xE8:
  11573. case 0xE9:
  11574. case 0xEA:
  11575. case 0xEB:
  11576. case 0xEC:
  11577. case 0xED:
  11578. case 0xEE:
  11579. case 0xEF:
  11580. case 0xFE:
  11581. markerLength = stream.getUint16();
  11582. if (markerLength > 2) {
  11583. stream.skip(markerLength - 2);
  11584. } else {
  11585. stream.skip(-2);
  11586. }
  11587. break;
  11588. }
  11589. if (foundEOI) {
  11590. break;
  11591. }
  11592. }
  11593. length = stream.pos - startPos;
  11594. if (b === -1) {
  11595. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  11596. stream.skip(-length);
  11597. return this.findDefaultInlineStreamEnd(stream);
  11598. }
  11599. this.inlineStreamSkipEI(stream);
  11600. return length;
  11601. },
  11602. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  11603. var TILDE = 0x7E, GT = 0x3E;
  11604. var startPos = stream.pos, ch, length;
  11605. while ((ch = stream.getByte()) !== -1) {
  11606. if (ch === TILDE && stream.peekByte() === GT) {
  11607. stream.skip();
  11608. break;
  11609. }
  11610. }
  11611. length = stream.pos - startPos;
  11612. if (ch === -1) {
  11613. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11614. stream.skip(-length);
  11615. return this.findDefaultInlineStreamEnd(stream);
  11616. }
  11617. this.inlineStreamSkipEI(stream);
  11618. return length;
  11619. },
  11620. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  11621. var GT = 0x3E;
  11622. var startPos = stream.pos, ch, length;
  11623. while ((ch = stream.getByte()) !== -1) {
  11624. if (ch === GT) {
  11625. break;
  11626. }
  11627. }
  11628. length = stream.pos - startPos;
  11629. if (ch === -1) {
  11630. warn('Inline ASCIIHexDecode 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. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  11638. var E = 0x45, I = 0x49;
  11639. var state = 0, ch;
  11640. while ((ch = stream.getByte()) !== -1) {
  11641. if (state === 0) {
  11642. state = ch === E ? 1 : 0;
  11643. } else if (state === 1) {
  11644. state = ch === I ? 2 : 0;
  11645. } else if (state === 2) {
  11646. break;
  11647. }
  11648. }
  11649. },
  11650. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  11651. var lexer = this.lexer;
  11652. var stream = lexer.stream;
  11653. var dict = new Dict(this.xref);
  11654. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  11655. if (!isName(this.buf1)) {
  11656. error('Dictionary key must be a name object');
  11657. }
  11658. var key = this.buf1.name;
  11659. this.shift();
  11660. if (isEOF(this.buf1)) {
  11661. break;
  11662. }
  11663. dict.set(key, this.getObj(cipherTransform));
  11664. }
  11665. var filter = dict.get('Filter', 'F'), filterName;
  11666. if (isName(filter)) {
  11667. filterName = filter.name;
  11668. } else if (isArray(filter)) {
  11669. var filterZero = this.xref.fetchIfRef(filter[0]);
  11670. if (isName(filterZero)) {
  11671. filterName = filterZero.name;
  11672. }
  11673. }
  11674. var startPos = stream.pos, length, i, ii;
  11675. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  11676. length = this.findDCTDecodeInlineStreamEnd(stream);
  11677. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  11678. length = this.findASCII85DecodeInlineStreamEnd(stream);
  11679. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  11680. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  11681. } else {
  11682. length = this.findDefaultInlineStreamEnd(stream);
  11683. }
  11684. var imageStream = stream.makeSubStream(startPos, length, dict);
  11685. var adler32;
  11686. if (length < MAX_LENGTH_TO_CACHE) {
  11687. var imageBytes = imageStream.getBytes();
  11688. imageStream.reset();
  11689. var a = 1;
  11690. var b = 0;
  11691. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  11692. a += imageBytes[i] & 0xff;
  11693. b += a;
  11694. }
  11695. adler32 = b % 65521 << 16 | a % 65521;
  11696. if (this.imageCache.adler32 === adler32) {
  11697. this.buf2 = Cmd.get('EI');
  11698. this.shift();
  11699. this.imageCache[adler32].reset();
  11700. return this.imageCache[adler32];
  11701. }
  11702. }
  11703. if (cipherTransform) {
  11704. imageStream = cipherTransform.createStream(imageStream, length);
  11705. }
  11706. imageStream = this.filter(imageStream, dict, length);
  11707. imageStream.dict = dict;
  11708. if (adler32 !== undefined) {
  11709. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  11710. this.imageCache[adler32] = imageStream;
  11711. }
  11712. this.buf2 = Cmd.get('EI');
  11713. this.shift();
  11714. return imageStream;
  11715. },
  11716. makeStream: function Parser_makeStream(dict, cipherTransform) {
  11717. var lexer = this.lexer;
  11718. var stream = lexer.stream;
  11719. lexer.skipToNextLine();
  11720. var pos = stream.pos - 1;
  11721. var length = dict.get('Length');
  11722. if (!isInt(length)) {
  11723. info('Bad ' + length + ' attribute in stream');
  11724. length = 0;
  11725. }
  11726. stream.pos = pos + length;
  11727. lexer.nextChar();
  11728. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  11729. this.shift();
  11730. } else {
  11731. stream.pos = pos;
  11732. var SCAN_BLOCK_SIZE = 2048;
  11733. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  11734. var ENDSTREAM_SIGNATURE = [
  11735. 0x65,
  11736. 0x6E,
  11737. 0x64,
  11738. 0x73,
  11739. 0x74,
  11740. 0x72,
  11741. 0x65,
  11742. 0x61,
  11743. 0x6D
  11744. ];
  11745. var skipped = 0, found = false, i, j;
  11746. while (stream.pos < stream.end) {
  11747. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  11748. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  11749. if (scanLength <= 0) {
  11750. break;
  11751. }
  11752. found = false;
  11753. i = 0;
  11754. while (i < scanLength) {
  11755. j = 0;
  11756. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  11757. j++;
  11758. }
  11759. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  11760. found = true;
  11761. break;
  11762. }
  11763. i++;
  11764. }
  11765. if (found) {
  11766. skipped += i;
  11767. stream.pos += i;
  11768. break;
  11769. }
  11770. skipped += scanLength;
  11771. stream.pos += scanLength;
  11772. }
  11773. if (!found) {
  11774. error('Missing endstream');
  11775. }
  11776. length = skipped;
  11777. lexer.nextChar();
  11778. this.shift();
  11779. this.shift();
  11780. }
  11781. this.shift();
  11782. stream = stream.makeSubStream(pos, length, dict);
  11783. if (cipherTransform) {
  11784. stream = cipherTransform.createStream(stream, length);
  11785. }
  11786. stream = this.filter(stream, dict, length);
  11787. stream.dict = dict;
  11788. return stream;
  11789. },
  11790. filter: function Parser_filter(stream, dict, length) {
  11791. var filter = dict.get('Filter', 'F');
  11792. var params = dict.get('DecodeParms', 'DP');
  11793. if (isName(filter)) {
  11794. if (isArray(params)) {
  11795. params = this.xref.fetchIfRef(params[0]);
  11796. }
  11797. return this.makeFilter(stream, filter.name, length, params);
  11798. }
  11799. var maybeLength = length;
  11800. if (isArray(filter)) {
  11801. var filterArray = filter;
  11802. var paramsArray = params;
  11803. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  11804. filter = this.xref.fetchIfRef(filterArray[i]);
  11805. if (!isName(filter)) {
  11806. error('Bad filter name: ' + filter);
  11807. }
  11808. params = null;
  11809. if (isArray(paramsArray) && i in paramsArray) {
  11810. params = this.xref.fetchIfRef(paramsArray[i]);
  11811. }
  11812. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  11813. maybeLength = null;
  11814. }
  11815. }
  11816. return stream;
  11817. },
  11818. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  11819. if (maybeLength === 0) {
  11820. warn('Empty "' + name + '" stream.');
  11821. return new NullStream(stream);
  11822. }
  11823. try {
  11824. var xrefStreamStats = this.xref.stats.streamTypes;
  11825. if (name === 'FlateDecode' || name === 'Fl') {
  11826. xrefStreamStats[StreamType.FLATE] = true;
  11827. if (params) {
  11828. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  11829. }
  11830. return new FlateStream(stream, maybeLength);
  11831. }
  11832. if (name === 'LZWDecode' || name === 'LZW') {
  11833. xrefStreamStats[StreamType.LZW] = true;
  11834. var earlyChange = 1;
  11835. if (params) {
  11836. if (params.has('EarlyChange')) {
  11837. earlyChange = params.get('EarlyChange');
  11838. }
  11839. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  11840. }
  11841. return new LZWStream(stream, maybeLength, earlyChange);
  11842. }
  11843. if (name === 'DCTDecode' || name === 'DCT') {
  11844. xrefStreamStats[StreamType.DCT] = true;
  11845. return new JpegStream(stream, maybeLength, stream.dict, params);
  11846. }
  11847. if (name === 'JPXDecode' || name === 'JPX') {
  11848. xrefStreamStats[StreamType.JPX] = true;
  11849. return new JpxStream(stream, maybeLength, stream.dict, params);
  11850. }
  11851. if (name === 'ASCII85Decode' || name === 'A85') {
  11852. xrefStreamStats[StreamType.A85] = true;
  11853. return new Ascii85Stream(stream, maybeLength);
  11854. }
  11855. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  11856. xrefStreamStats[StreamType.AHX] = true;
  11857. return new AsciiHexStream(stream, maybeLength);
  11858. }
  11859. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  11860. xrefStreamStats[StreamType.CCF] = true;
  11861. return new CCITTFaxStream(stream, maybeLength, params);
  11862. }
  11863. if (name === 'RunLengthDecode' || name === 'RL') {
  11864. xrefStreamStats[StreamType.RL] = true;
  11865. return new RunLengthStream(stream, maybeLength);
  11866. }
  11867. if (name === 'JBIG2Decode') {
  11868. xrefStreamStats[StreamType.JBIG] = true;
  11869. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  11870. }
  11871. warn('filter "' + name + '" not supported yet');
  11872. return stream;
  11873. } catch (ex) {
  11874. if (ex instanceof MissingDataException) {
  11875. throw ex;
  11876. }
  11877. warn('Invalid stream: \"' + ex + '\"');
  11878. return new NullStream(stream);
  11879. }
  11880. }
  11881. };
  11882. return Parser;
  11883. }();
  11884. var Lexer = function LexerClosure() {
  11885. function Lexer(stream, knownCommands) {
  11886. this.stream = stream;
  11887. this.nextChar();
  11888. this.strBuf = [];
  11889. this.knownCommands = knownCommands;
  11890. }
  11891. var specialChars = [
  11892. 1,
  11893. 0,
  11894. 0,
  11895. 0,
  11896. 0,
  11897. 0,
  11898. 0,
  11899. 0,
  11900. 0,
  11901. 1,
  11902. 1,
  11903. 0,
  11904. 1,
  11905. 1,
  11906. 0,
  11907. 0,
  11908. 0,
  11909. 0,
  11910. 0,
  11911. 0,
  11912. 0,
  11913. 0,
  11914. 0,
  11915. 0,
  11916. 0,
  11917. 0,
  11918. 0,
  11919. 0,
  11920. 0,
  11921. 0,
  11922. 0,
  11923. 0,
  11924. 1,
  11925. 0,
  11926. 0,
  11927. 0,
  11928. 0,
  11929. 2,
  11930. 0,
  11931. 0,
  11932. 2,
  11933. 2,
  11934. 0,
  11935. 0,
  11936. 0,
  11937. 0,
  11938. 0,
  11939. 2,
  11940. 0,
  11941. 0,
  11942. 0,
  11943. 0,
  11944. 0,
  11945. 0,
  11946. 0,
  11947. 0,
  11948. 0,
  11949. 0,
  11950. 0,
  11951. 0,
  11952. 2,
  11953. 0,
  11954. 2,
  11955. 0,
  11956. 0,
  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. 0,
  11970. 0,
  11971. 0,
  11972. 0,
  11973. 0,
  11974. 0,
  11975. 0,
  11976. 0,
  11977. 0,
  11978. 0,
  11979. 0,
  11980. 0,
  11981. 0,
  11982. 0,
  11983. 2,
  11984. 0,
  11985. 2,
  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. 0,
  12001. 0,
  12002. 0,
  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. 2,
  12016. 0,
  12017. 2,
  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. 0,
  12033. 0,
  12034. 0,
  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. ];
  12149. function toHexDigit(ch) {
  12150. if (ch >= 0x30 && ch <= 0x39) {
  12151. return ch & 0x0F;
  12152. }
  12153. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12154. return (ch & 0x0F) + 9;
  12155. }
  12156. return -1;
  12157. }
  12158. Lexer.prototype = {
  12159. nextChar: function Lexer_nextChar() {
  12160. return this.currentChar = this.stream.getByte();
  12161. },
  12162. peekChar: function Lexer_peekChar() {
  12163. return this.stream.peekByte();
  12164. },
  12165. getNumber: function Lexer_getNumber() {
  12166. var ch = this.currentChar;
  12167. var eNotation = false;
  12168. var divideBy = 0;
  12169. var sign = 1;
  12170. if (ch === 0x2D) {
  12171. sign = -1;
  12172. ch = this.nextChar();
  12173. if (ch === 0x2D) {
  12174. ch = this.nextChar();
  12175. }
  12176. } else if (ch === 0x2B) {
  12177. ch = this.nextChar();
  12178. }
  12179. if (ch === 0x2E) {
  12180. divideBy = 10;
  12181. ch = this.nextChar();
  12182. }
  12183. if (ch < 0x30 || ch > 0x39) {
  12184. error('Invalid number: ' + String.fromCharCode(ch));
  12185. return 0;
  12186. }
  12187. var baseValue = ch - 0x30;
  12188. var powerValue = 0;
  12189. var powerValueSign = 1;
  12190. while ((ch = this.nextChar()) >= 0) {
  12191. if (0x30 <= ch && ch <= 0x39) {
  12192. var currentDigit = ch - 0x30;
  12193. if (eNotation) {
  12194. powerValue = powerValue * 10 + currentDigit;
  12195. } else {
  12196. if (divideBy !== 0) {
  12197. divideBy *= 10;
  12198. }
  12199. baseValue = baseValue * 10 + currentDigit;
  12200. }
  12201. } else if (ch === 0x2E) {
  12202. if (divideBy === 0) {
  12203. divideBy = 1;
  12204. } else {
  12205. break;
  12206. }
  12207. } else if (ch === 0x2D) {
  12208. warn('Badly formatted number');
  12209. } else if (ch === 0x45 || ch === 0x65) {
  12210. ch = this.peekChar();
  12211. if (ch === 0x2B || ch === 0x2D) {
  12212. powerValueSign = ch === 0x2D ? -1 : 1;
  12213. this.nextChar();
  12214. } else if (ch < 0x30 || ch > 0x39) {
  12215. break;
  12216. }
  12217. eNotation = true;
  12218. } else {
  12219. break;
  12220. }
  12221. }
  12222. if (divideBy !== 0) {
  12223. baseValue /= divideBy;
  12224. }
  12225. if (eNotation) {
  12226. baseValue *= Math.pow(10, powerValueSign * powerValue);
  12227. }
  12228. return sign * baseValue;
  12229. },
  12230. getString: function Lexer_getString() {
  12231. var numParen = 1;
  12232. var done = false;
  12233. var strBuf = this.strBuf;
  12234. strBuf.length = 0;
  12235. var ch = this.nextChar();
  12236. while (true) {
  12237. var charBuffered = false;
  12238. switch (ch | 0) {
  12239. case -1:
  12240. warn('Unterminated string');
  12241. done = true;
  12242. break;
  12243. case 0x28:
  12244. ++numParen;
  12245. strBuf.push('(');
  12246. break;
  12247. case 0x29:
  12248. if (--numParen === 0) {
  12249. this.nextChar();
  12250. done = true;
  12251. } else {
  12252. strBuf.push(')');
  12253. }
  12254. break;
  12255. case 0x5C:
  12256. ch = this.nextChar();
  12257. switch (ch) {
  12258. case -1:
  12259. warn('Unterminated string');
  12260. done = true;
  12261. break;
  12262. case 0x6E:
  12263. strBuf.push('\n');
  12264. break;
  12265. case 0x72:
  12266. strBuf.push('\r');
  12267. break;
  12268. case 0x74:
  12269. strBuf.push('\t');
  12270. break;
  12271. case 0x62:
  12272. strBuf.push('\b');
  12273. break;
  12274. case 0x66:
  12275. strBuf.push('\f');
  12276. break;
  12277. case 0x5C:
  12278. case 0x28:
  12279. case 0x29:
  12280. strBuf.push(String.fromCharCode(ch));
  12281. break;
  12282. case 0x30:
  12283. case 0x31:
  12284. case 0x32:
  12285. case 0x33:
  12286. case 0x34:
  12287. case 0x35:
  12288. case 0x36:
  12289. case 0x37:
  12290. var x = ch & 0x0F;
  12291. ch = this.nextChar();
  12292. charBuffered = true;
  12293. if (ch >= 0x30 && ch <= 0x37) {
  12294. x = (x << 3) + (ch & 0x0F);
  12295. ch = this.nextChar();
  12296. if (ch >= 0x30 && ch <= 0x37) {
  12297. charBuffered = false;
  12298. x = (x << 3) + (ch & 0x0F);
  12299. }
  12300. }
  12301. strBuf.push(String.fromCharCode(x));
  12302. break;
  12303. case 0x0D:
  12304. if (this.peekChar() === 0x0A) {
  12305. this.nextChar();
  12306. }
  12307. break;
  12308. case 0x0A:
  12309. break;
  12310. default:
  12311. strBuf.push(String.fromCharCode(ch));
  12312. break;
  12313. }
  12314. break;
  12315. default:
  12316. strBuf.push(String.fromCharCode(ch));
  12317. break;
  12318. }
  12319. if (done) {
  12320. break;
  12321. }
  12322. if (!charBuffered) {
  12323. ch = this.nextChar();
  12324. }
  12325. }
  12326. return strBuf.join('');
  12327. },
  12328. getName: function Lexer_getName() {
  12329. var ch, previousCh;
  12330. var strBuf = this.strBuf;
  12331. strBuf.length = 0;
  12332. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12333. if (ch === 0x23) {
  12334. ch = this.nextChar();
  12335. if (specialChars[ch]) {
  12336. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  12337. strBuf.push('#');
  12338. break;
  12339. }
  12340. var x = toHexDigit(ch);
  12341. if (x !== -1) {
  12342. previousCh = ch;
  12343. ch = this.nextChar();
  12344. var x2 = toHexDigit(ch);
  12345. if (x2 === -1) {
  12346. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  12347. strBuf.push('#', String.fromCharCode(previousCh));
  12348. if (specialChars[ch]) {
  12349. break;
  12350. }
  12351. strBuf.push(String.fromCharCode(ch));
  12352. continue;
  12353. }
  12354. strBuf.push(String.fromCharCode(x << 4 | x2));
  12355. } else {
  12356. strBuf.push('#', String.fromCharCode(ch));
  12357. }
  12358. } else {
  12359. strBuf.push(String.fromCharCode(ch));
  12360. }
  12361. }
  12362. if (strBuf.length > 127) {
  12363. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  12364. }
  12365. return Name.get(strBuf.join(''));
  12366. },
  12367. getHexString: function Lexer_getHexString() {
  12368. var strBuf = this.strBuf;
  12369. strBuf.length = 0;
  12370. var ch = this.currentChar;
  12371. var isFirstHex = true;
  12372. var firstDigit;
  12373. var secondDigit;
  12374. while (true) {
  12375. if (ch < 0) {
  12376. warn('Unterminated hex string');
  12377. break;
  12378. } else if (ch === 0x3E) {
  12379. this.nextChar();
  12380. break;
  12381. } else if (specialChars[ch] === 1) {
  12382. ch = this.nextChar();
  12383. continue;
  12384. } else {
  12385. if (isFirstHex) {
  12386. firstDigit = toHexDigit(ch);
  12387. if (firstDigit === -1) {
  12388. warn('Ignoring invalid character "' + ch + '" in hex string');
  12389. ch = this.nextChar();
  12390. continue;
  12391. }
  12392. } else {
  12393. secondDigit = toHexDigit(ch);
  12394. if (secondDigit === -1) {
  12395. warn('Ignoring invalid character "' + ch + '" in hex string');
  12396. ch = this.nextChar();
  12397. continue;
  12398. }
  12399. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  12400. }
  12401. isFirstHex = !isFirstHex;
  12402. ch = this.nextChar();
  12403. }
  12404. }
  12405. return strBuf.join('');
  12406. },
  12407. getObj: function Lexer_getObj() {
  12408. var comment = false;
  12409. var ch = this.currentChar;
  12410. while (true) {
  12411. if (ch < 0) {
  12412. return EOF;
  12413. }
  12414. if (comment) {
  12415. if (ch === 0x0A || ch === 0x0D) {
  12416. comment = false;
  12417. }
  12418. } else if (ch === 0x25) {
  12419. comment = true;
  12420. } else if (specialChars[ch] !== 1) {
  12421. break;
  12422. }
  12423. ch = this.nextChar();
  12424. }
  12425. switch (ch | 0) {
  12426. case 0x30:
  12427. case 0x31:
  12428. case 0x32:
  12429. case 0x33:
  12430. case 0x34:
  12431. case 0x35:
  12432. case 0x36:
  12433. case 0x37:
  12434. case 0x38:
  12435. case 0x39:
  12436. case 0x2B:
  12437. case 0x2D:
  12438. case 0x2E:
  12439. return this.getNumber();
  12440. case 0x28:
  12441. return this.getString();
  12442. case 0x2F:
  12443. return this.getName();
  12444. case 0x5B:
  12445. this.nextChar();
  12446. return Cmd.get('[');
  12447. case 0x5D:
  12448. this.nextChar();
  12449. return Cmd.get(']');
  12450. case 0x3C:
  12451. ch = this.nextChar();
  12452. if (ch === 0x3C) {
  12453. this.nextChar();
  12454. return Cmd.get('<<');
  12455. }
  12456. return this.getHexString();
  12457. case 0x3E:
  12458. ch = this.nextChar();
  12459. if (ch === 0x3E) {
  12460. this.nextChar();
  12461. return Cmd.get('>>');
  12462. }
  12463. return Cmd.get('>');
  12464. case 0x7B:
  12465. this.nextChar();
  12466. return Cmd.get('{');
  12467. case 0x7D:
  12468. this.nextChar();
  12469. return Cmd.get('}');
  12470. case 0x29:
  12471. this.nextChar();
  12472. error('Illegal character: ' + ch);
  12473. break;
  12474. }
  12475. var str = String.fromCharCode(ch);
  12476. var knownCommands = this.knownCommands;
  12477. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12478. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12479. var possibleCommand = str + String.fromCharCode(ch);
  12480. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  12481. break;
  12482. }
  12483. if (str.length === 128) {
  12484. error('Command token too long: ' + str.length);
  12485. }
  12486. str = possibleCommand;
  12487. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12488. }
  12489. if (str === 'true') {
  12490. return true;
  12491. }
  12492. if (str === 'false') {
  12493. return false;
  12494. }
  12495. if (str === 'null') {
  12496. return null;
  12497. }
  12498. return Cmd.get(str);
  12499. },
  12500. skipToNextLine: function Lexer_skipToNextLine() {
  12501. var ch = this.currentChar;
  12502. while (ch >= 0) {
  12503. if (ch === 0x0D) {
  12504. ch = this.nextChar();
  12505. if (ch === 0x0A) {
  12506. this.nextChar();
  12507. }
  12508. break;
  12509. } else if (ch === 0x0A) {
  12510. this.nextChar();
  12511. break;
  12512. }
  12513. ch = this.nextChar();
  12514. }
  12515. }
  12516. };
  12517. return Lexer;
  12518. }();
  12519. var Linearization = {
  12520. create: function LinearizationCreate(stream) {
  12521. function getInt(name, allowZeroValue) {
  12522. var obj = linDict.get(name);
  12523. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  12524. return obj;
  12525. }
  12526. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  12527. }
  12528. function getHints() {
  12529. var hints = linDict.get('H'), hintsLength, item;
  12530. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  12531. for (var index = 0; index < hintsLength; index++) {
  12532. if (!(isInt(item = hints[index]) && item > 0)) {
  12533. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  12534. }
  12535. }
  12536. return hints;
  12537. }
  12538. throw new Error('Hint array in the linearization dictionary is invalid.');
  12539. }
  12540. var parser = new Parser(new Lexer(stream), false, null);
  12541. var obj1 = parser.getObj();
  12542. var obj2 = parser.getObj();
  12543. var obj3 = parser.getObj();
  12544. var linDict = parser.getObj();
  12545. var obj, length;
  12546. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  12547. return null;
  12548. } else if ((length = getInt('L')) !== stream.length) {
  12549. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  12550. }
  12551. return {
  12552. length: length,
  12553. hints: getHints(),
  12554. objectNumberFirst: getInt('O'),
  12555. endFirst: getInt('E'),
  12556. numPages: getInt('N'),
  12557. mainXRefEntriesOffset: getInt('T'),
  12558. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  12559. };
  12560. }
  12561. };
  12562. exports.Lexer = Lexer;
  12563. exports.Linearization = Linearization;
  12564. exports.Parser = Parser;
  12565. /***/ }),
  12566. /* 7 */
  12567. /***/ (function(module, exports, __w_pdfjs_require__) {
  12568. "use strict";
  12569. var sharedUtil = __w_pdfjs_require__(0);
  12570. var corePrimitives = __w_pdfjs_require__(1);
  12571. var corePsParser = __w_pdfjs_require__(42);
  12572. var error = sharedUtil.error;
  12573. var info = sharedUtil.info;
  12574. var isArray = sharedUtil.isArray;
  12575. var isBool = sharedUtil.isBool;
  12576. var isDict = corePrimitives.isDict;
  12577. var isStream = corePrimitives.isStream;
  12578. var PostScriptLexer = corePsParser.PostScriptLexer;
  12579. var PostScriptParser = corePsParser.PostScriptParser;
  12580. var PDFFunction = function PDFFunctionClosure() {
  12581. var CONSTRUCT_SAMPLED = 0;
  12582. var CONSTRUCT_INTERPOLATED = 2;
  12583. var CONSTRUCT_STICHED = 3;
  12584. var CONSTRUCT_POSTSCRIPT = 4;
  12585. return {
  12586. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  12587. var i, ii;
  12588. var length = 1;
  12589. for (i = 0, ii = size.length; i < ii; i++) {
  12590. length *= size[i];
  12591. }
  12592. length *= outputSize;
  12593. var array = new Array(length);
  12594. var codeSize = 0;
  12595. var codeBuf = 0;
  12596. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  12597. var strBytes = str.getBytes((length * bps + 7) / 8);
  12598. var strIdx = 0;
  12599. for (i = 0; i < length; i++) {
  12600. while (codeSize < bps) {
  12601. codeBuf <<= 8;
  12602. codeBuf |= strBytes[strIdx++];
  12603. codeSize += 8;
  12604. }
  12605. codeSize -= bps;
  12606. array[i] = (codeBuf >> codeSize) * sampleMul;
  12607. codeBuf &= (1 << codeSize) - 1;
  12608. }
  12609. return array;
  12610. },
  12611. getIR: function PDFFunction_getIR(xref, fn) {
  12612. var dict = fn.dict;
  12613. if (!dict) {
  12614. dict = fn;
  12615. }
  12616. var types = [
  12617. this.constructSampled,
  12618. null,
  12619. this.constructInterpolated,
  12620. this.constructStiched,
  12621. this.constructPostScript
  12622. ];
  12623. var typeNum = dict.get('FunctionType');
  12624. var typeFn = types[typeNum];
  12625. if (!typeFn) {
  12626. error('Unknown type of function');
  12627. }
  12628. return typeFn.call(this, fn, dict, xref);
  12629. },
  12630. fromIR: function PDFFunction_fromIR(IR) {
  12631. var type = IR[0];
  12632. switch (type) {
  12633. case CONSTRUCT_SAMPLED:
  12634. return this.constructSampledFromIR(IR);
  12635. case CONSTRUCT_INTERPOLATED:
  12636. return this.constructInterpolatedFromIR(IR);
  12637. case CONSTRUCT_STICHED:
  12638. return this.constructStichedFromIR(IR);
  12639. default:
  12640. return this.constructPostScriptFromIR(IR);
  12641. }
  12642. },
  12643. parse: function PDFFunction_parse(xref, fn) {
  12644. var IR = this.getIR(xref, fn);
  12645. return this.fromIR(IR);
  12646. },
  12647. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  12648. if (!isArray(fnObj)) {
  12649. return this.parse(xref, fnObj);
  12650. }
  12651. var fnArray = [];
  12652. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  12653. var obj = xref.fetchIfRef(fnObj[j]);
  12654. fnArray.push(PDFFunction.parse(xref, obj));
  12655. }
  12656. return function (src, srcOffset, dest, destOffset) {
  12657. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  12658. fnArray[i](src, srcOffset, dest, destOffset + i);
  12659. }
  12660. };
  12661. },
  12662. constructSampled: function PDFFunction_constructSampled(str, dict) {
  12663. function toMultiArray(arr) {
  12664. var inputLength = arr.length;
  12665. var out = [];
  12666. var index = 0;
  12667. for (var i = 0; i < inputLength; i += 2) {
  12668. out[index] = [
  12669. arr[i],
  12670. arr[i + 1]
  12671. ];
  12672. ++index;
  12673. }
  12674. return out;
  12675. }
  12676. var domain = dict.getArray('Domain');
  12677. var range = dict.getArray('Range');
  12678. if (!domain || !range) {
  12679. error('No domain or range');
  12680. }
  12681. var inputSize = domain.length / 2;
  12682. var outputSize = range.length / 2;
  12683. domain = toMultiArray(domain);
  12684. range = toMultiArray(range);
  12685. var size = dict.get('Size');
  12686. var bps = dict.get('BitsPerSample');
  12687. var order = dict.get('Order') || 1;
  12688. if (order !== 1) {
  12689. info('No support for cubic spline interpolation: ' + order);
  12690. }
  12691. var encode = dict.getArray('Encode');
  12692. if (!encode) {
  12693. encode = [];
  12694. for (var i = 0; i < inputSize; ++i) {
  12695. encode.push(0);
  12696. encode.push(size[i] - 1);
  12697. }
  12698. }
  12699. encode = toMultiArray(encode);
  12700. var decode = dict.getArray('Decode');
  12701. if (!decode) {
  12702. decode = range;
  12703. } else {
  12704. decode = toMultiArray(decode);
  12705. }
  12706. var samples = this.getSampleArray(size, outputSize, bps, str);
  12707. return [
  12708. CONSTRUCT_SAMPLED,
  12709. inputSize,
  12710. domain,
  12711. encode,
  12712. decode,
  12713. samples,
  12714. size,
  12715. outputSize,
  12716. Math.pow(2, bps) - 1,
  12717. range
  12718. ];
  12719. },
  12720. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  12721. function interpolate(x, xmin, xmax, ymin, ymax) {
  12722. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  12723. }
  12724. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  12725. var m = IR[1];
  12726. var domain = IR[2];
  12727. var encode = IR[3];
  12728. var decode = IR[4];
  12729. var samples = IR[5];
  12730. var size = IR[6];
  12731. var n = IR[7];
  12732. var range = IR[9];
  12733. var cubeVertices = 1 << m;
  12734. var cubeN = new Float64Array(cubeVertices);
  12735. var cubeVertex = new Uint32Array(cubeVertices);
  12736. var i, j;
  12737. for (j = 0; j < cubeVertices; j++) {
  12738. cubeN[j] = 1;
  12739. }
  12740. var k = n, pos = 1;
  12741. for (i = 0; i < m; ++i) {
  12742. var domain_2i = domain[i][0];
  12743. var domain_2i_1 = domain[i][1];
  12744. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  12745. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  12746. var size_i = size[i];
  12747. e = Math.min(Math.max(e, 0), size_i - 1);
  12748. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  12749. var n0 = e0 + 1 - e;
  12750. var n1 = e - e0;
  12751. var offset0 = e0 * k;
  12752. var offset1 = offset0 + k;
  12753. for (j = 0; j < cubeVertices; j++) {
  12754. if (j & pos) {
  12755. cubeN[j] *= n1;
  12756. cubeVertex[j] += offset1;
  12757. } else {
  12758. cubeN[j] *= n0;
  12759. cubeVertex[j] += offset0;
  12760. }
  12761. }
  12762. k *= size_i;
  12763. pos <<= 1;
  12764. }
  12765. for (j = 0; j < n; ++j) {
  12766. var rj = 0;
  12767. for (i = 0; i < cubeVertices; i++) {
  12768. rj += samples[cubeVertex[i] + j] * cubeN[i];
  12769. }
  12770. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  12771. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  12772. }
  12773. };
  12774. },
  12775. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  12776. var c0 = dict.getArray('C0') || [0];
  12777. var c1 = dict.getArray('C1') || [1];
  12778. var n = dict.get('N');
  12779. if (!isArray(c0) || !isArray(c1)) {
  12780. error('Illegal dictionary for interpolated function');
  12781. }
  12782. var length = c0.length;
  12783. var diff = [];
  12784. for (var i = 0; i < length; ++i) {
  12785. diff.push(c1[i] - c0[i]);
  12786. }
  12787. return [
  12788. CONSTRUCT_INTERPOLATED,
  12789. c0,
  12790. diff,
  12791. n
  12792. ];
  12793. },
  12794. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  12795. var c0 = IR[1];
  12796. var diff = IR[2];
  12797. var n = IR[3];
  12798. var length = diff.length;
  12799. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  12800. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  12801. for (var j = 0; j < length; ++j) {
  12802. dest[destOffset + j] = c0[j] + x * diff[j];
  12803. }
  12804. };
  12805. },
  12806. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  12807. var domain = dict.getArray('Domain');
  12808. if (!domain) {
  12809. error('No domain');
  12810. }
  12811. var inputSize = domain.length / 2;
  12812. if (inputSize !== 1) {
  12813. error('Bad domain for stiched function');
  12814. }
  12815. var fnRefs = dict.get('Functions');
  12816. var fns = [];
  12817. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  12818. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  12819. }
  12820. var bounds = dict.getArray('Bounds');
  12821. var encode = dict.getArray('Encode');
  12822. return [
  12823. CONSTRUCT_STICHED,
  12824. domain,
  12825. bounds,
  12826. encode,
  12827. fns
  12828. ];
  12829. },
  12830. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  12831. var domain = IR[1];
  12832. var bounds = IR[2];
  12833. var encode = IR[3];
  12834. var fnsIR = IR[4];
  12835. var fns = [];
  12836. var tmpBuf = new Float32Array(1);
  12837. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  12838. fns.push(PDFFunction.fromIR(fnsIR[i]));
  12839. }
  12840. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  12841. var clip = function constructStichedFromIRClip(v, min, max) {
  12842. if (v > max) {
  12843. v = max;
  12844. } else if (v < min) {
  12845. v = min;
  12846. }
  12847. return v;
  12848. };
  12849. var v = clip(src[srcOffset], domain[0], domain[1]);
  12850. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  12851. if (v < bounds[i]) {
  12852. break;
  12853. }
  12854. }
  12855. var dmin = domain[0];
  12856. if (i > 0) {
  12857. dmin = bounds[i - 1];
  12858. }
  12859. var dmax = domain[1];
  12860. if (i < bounds.length) {
  12861. dmax = bounds[i];
  12862. }
  12863. var rmin = encode[2 * i];
  12864. var rmax = encode[2 * i + 1];
  12865. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  12866. fns[i](tmpBuf, 0, dest, destOffset);
  12867. };
  12868. },
  12869. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  12870. var domain = dict.getArray('Domain');
  12871. var range = dict.getArray('Range');
  12872. if (!domain) {
  12873. error('No domain.');
  12874. }
  12875. if (!range) {
  12876. error('No range.');
  12877. }
  12878. var lexer = new PostScriptLexer(fn);
  12879. var parser = new PostScriptParser(lexer);
  12880. var code = parser.parse();
  12881. return [
  12882. CONSTRUCT_POSTSCRIPT,
  12883. domain,
  12884. range,
  12885. code
  12886. ];
  12887. },
  12888. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  12889. var domain = IR[1];
  12890. var range = IR[2];
  12891. var code = IR[3];
  12892. var compiled = new PostScriptCompiler().compile(code, domain, range);
  12893. if (compiled) {
  12894. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  12895. }
  12896. info('Unable to compile PS function');
  12897. var numOutputs = range.length >> 1;
  12898. var numInputs = domain.length >> 1;
  12899. var evaluator = new PostScriptEvaluator(code);
  12900. var cache = Object.create(null);
  12901. var MAX_CACHE_SIZE = 2048 * 4;
  12902. var cache_available = MAX_CACHE_SIZE;
  12903. var tmpBuf = new Float32Array(numInputs);
  12904. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  12905. var i, value;
  12906. var key = '';
  12907. var input = tmpBuf;
  12908. for (i = 0; i < numInputs; i++) {
  12909. value = src[srcOffset + i];
  12910. input[i] = value;
  12911. key += value + '_';
  12912. }
  12913. var cachedValue = cache[key];
  12914. if (cachedValue !== undefined) {
  12915. dest.set(cachedValue, destOffset);
  12916. return;
  12917. }
  12918. var output = new Float32Array(numOutputs);
  12919. var stack = evaluator.execute(input);
  12920. var stackIndex = stack.length - numOutputs;
  12921. for (i = 0; i < numOutputs; i++) {
  12922. value = stack[stackIndex + i];
  12923. var bound = range[i * 2];
  12924. if (value < bound) {
  12925. value = bound;
  12926. } else {
  12927. bound = range[i * 2 + 1];
  12928. if (value > bound) {
  12929. value = bound;
  12930. }
  12931. }
  12932. output[i] = value;
  12933. }
  12934. if (cache_available > 0) {
  12935. cache_available--;
  12936. cache[key] = output;
  12937. }
  12938. dest.set(output, destOffset);
  12939. };
  12940. }
  12941. };
  12942. }();
  12943. function isPDFFunction(v) {
  12944. var fnDict;
  12945. if (typeof v !== 'object') {
  12946. return false;
  12947. } else if (isDict(v)) {
  12948. fnDict = v;
  12949. } else if (isStream(v)) {
  12950. fnDict = v.dict;
  12951. } else {
  12952. return false;
  12953. }
  12954. return fnDict.has('FunctionType');
  12955. }
  12956. var PostScriptStack = function PostScriptStackClosure() {
  12957. var MAX_STACK_SIZE = 100;
  12958. function PostScriptStack(initialStack) {
  12959. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  12960. }
  12961. PostScriptStack.prototype = {
  12962. push: function PostScriptStack_push(value) {
  12963. if (this.stack.length >= MAX_STACK_SIZE) {
  12964. error('PostScript function stack overflow.');
  12965. }
  12966. this.stack.push(value);
  12967. },
  12968. pop: function PostScriptStack_pop() {
  12969. if (this.stack.length <= 0) {
  12970. error('PostScript function stack underflow.');
  12971. }
  12972. return this.stack.pop();
  12973. },
  12974. copy: function PostScriptStack_copy(n) {
  12975. if (this.stack.length + n >= MAX_STACK_SIZE) {
  12976. error('PostScript function stack overflow.');
  12977. }
  12978. var stack = this.stack;
  12979. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  12980. stack.push(stack[i]);
  12981. }
  12982. },
  12983. index: function PostScriptStack_index(n) {
  12984. this.push(this.stack[this.stack.length - n - 1]);
  12985. },
  12986. roll: function PostScriptStack_roll(n, p) {
  12987. var stack = this.stack;
  12988. var l = stack.length - n;
  12989. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  12990. for (i = l, j = r; i < j; i++, j--) {
  12991. t = stack[i];
  12992. stack[i] = stack[j];
  12993. stack[j] = t;
  12994. }
  12995. for (i = l, j = c - 1; i < j; i++, j--) {
  12996. t = stack[i];
  12997. stack[i] = stack[j];
  12998. stack[j] = t;
  12999. }
  13000. for (i = c, j = r; i < j; i++, j--) {
  13001. t = stack[i];
  13002. stack[i] = stack[j];
  13003. stack[j] = t;
  13004. }
  13005. }
  13006. };
  13007. return PostScriptStack;
  13008. }();
  13009. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13010. function PostScriptEvaluator(operators) {
  13011. this.operators = operators;
  13012. }
  13013. PostScriptEvaluator.prototype = {
  13014. execute: function PostScriptEvaluator_execute(initialStack) {
  13015. var stack = new PostScriptStack(initialStack);
  13016. var counter = 0;
  13017. var operators = this.operators;
  13018. var length = operators.length;
  13019. var operator, a, b;
  13020. while (counter < length) {
  13021. operator = operators[counter++];
  13022. if (typeof operator === 'number') {
  13023. stack.push(operator);
  13024. continue;
  13025. }
  13026. switch (operator) {
  13027. case 'jz':
  13028. b = stack.pop();
  13029. a = stack.pop();
  13030. if (!a) {
  13031. counter = b;
  13032. }
  13033. break;
  13034. case 'j':
  13035. a = stack.pop();
  13036. counter = a;
  13037. break;
  13038. case 'abs':
  13039. a = stack.pop();
  13040. stack.push(Math.abs(a));
  13041. break;
  13042. case 'add':
  13043. b = stack.pop();
  13044. a = stack.pop();
  13045. stack.push(a + b);
  13046. break;
  13047. case 'and':
  13048. b = stack.pop();
  13049. a = stack.pop();
  13050. if (isBool(a) && isBool(b)) {
  13051. stack.push(a && b);
  13052. } else {
  13053. stack.push(a & b);
  13054. }
  13055. break;
  13056. case 'atan':
  13057. a = stack.pop();
  13058. stack.push(Math.atan(a));
  13059. break;
  13060. case 'bitshift':
  13061. b = stack.pop();
  13062. a = stack.pop();
  13063. if (a > 0) {
  13064. stack.push(a << b);
  13065. } else {
  13066. stack.push(a >> b);
  13067. }
  13068. break;
  13069. case 'ceiling':
  13070. a = stack.pop();
  13071. stack.push(Math.ceil(a));
  13072. break;
  13073. case 'copy':
  13074. a = stack.pop();
  13075. stack.copy(a);
  13076. break;
  13077. case 'cos':
  13078. a = stack.pop();
  13079. stack.push(Math.cos(a));
  13080. break;
  13081. case 'cvi':
  13082. a = stack.pop() | 0;
  13083. stack.push(a);
  13084. break;
  13085. case 'cvr':
  13086. break;
  13087. case 'div':
  13088. b = stack.pop();
  13089. a = stack.pop();
  13090. stack.push(a / b);
  13091. break;
  13092. case 'dup':
  13093. stack.copy(1);
  13094. break;
  13095. case 'eq':
  13096. b = stack.pop();
  13097. a = stack.pop();
  13098. stack.push(a === b);
  13099. break;
  13100. case 'exch':
  13101. stack.roll(2, 1);
  13102. break;
  13103. case 'exp':
  13104. b = stack.pop();
  13105. a = stack.pop();
  13106. stack.push(Math.pow(a, b));
  13107. break;
  13108. case 'false':
  13109. stack.push(false);
  13110. break;
  13111. case 'floor':
  13112. a = stack.pop();
  13113. stack.push(Math.floor(a));
  13114. break;
  13115. case 'ge':
  13116. b = stack.pop();
  13117. a = stack.pop();
  13118. stack.push(a >= b);
  13119. break;
  13120. case 'gt':
  13121. b = stack.pop();
  13122. a = stack.pop();
  13123. stack.push(a > b);
  13124. break;
  13125. case 'idiv':
  13126. b = stack.pop();
  13127. a = stack.pop();
  13128. stack.push(a / b | 0);
  13129. break;
  13130. case 'index':
  13131. a = stack.pop();
  13132. stack.index(a);
  13133. break;
  13134. case 'le':
  13135. b = stack.pop();
  13136. a = stack.pop();
  13137. stack.push(a <= b);
  13138. break;
  13139. case 'ln':
  13140. a = stack.pop();
  13141. stack.push(Math.log(a));
  13142. break;
  13143. case 'log':
  13144. a = stack.pop();
  13145. stack.push(Math.log(a) / Math.LN10);
  13146. break;
  13147. case 'lt':
  13148. b = stack.pop();
  13149. a = stack.pop();
  13150. stack.push(a < b);
  13151. break;
  13152. case 'mod':
  13153. b = stack.pop();
  13154. a = stack.pop();
  13155. stack.push(a % b);
  13156. break;
  13157. case 'mul':
  13158. b = stack.pop();
  13159. a = stack.pop();
  13160. stack.push(a * b);
  13161. break;
  13162. case 'ne':
  13163. b = stack.pop();
  13164. a = stack.pop();
  13165. stack.push(a !== b);
  13166. break;
  13167. case 'neg':
  13168. a = stack.pop();
  13169. stack.push(-a);
  13170. break;
  13171. case 'not':
  13172. a = stack.pop();
  13173. if (isBool(a)) {
  13174. stack.push(!a);
  13175. } else {
  13176. stack.push(~a);
  13177. }
  13178. break;
  13179. case 'or':
  13180. b = stack.pop();
  13181. a = stack.pop();
  13182. if (isBool(a) && isBool(b)) {
  13183. stack.push(a || b);
  13184. } else {
  13185. stack.push(a | b);
  13186. }
  13187. break;
  13188. case 'pop':
  13189. stack.pop();
  13190. break;
  13191. case 'roll':
  13192. b = stack.pop();
  13193. a = stack.pop();
  13194. stack.roll(a, b);
  13195. break;
  13196. case 'round':
  13197. a = stack.pop();
  13198. stack.push(Math.round(a));
  13199. break;
  13200. case 'sin':
  13201. a = stack.pop();
  13202. stack.push(Math.sin(a));
  13203. break;
  13204. case 'sqrt':
  13205. a = stack.pop();
  13206. stack.push(Math.sqrt(a));
  13207. break;
  13208. case 'sub':
  13209. b = stack.pop();
  13210. a = stack.pop();
  13211. stack.push(a - b);
  13212. break;
  13213. case 'true':
  13214. stack.push(true);
  13215. break;
  13216. case 'truncate':
  13217. a = stack.pop();
  13218. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13219. stack.push(a);
  13220. break;
  13221. case 'xor':
  13222. b = stack.pop();
  13223. a = stack.pop();
  13224. if (isBool(a) && isBool(b)) {
  13225. stack.push(a !== b);
  13226. } else {
  13227. stack.push(a ^ b);
  13228. }
  13229. break;
  13230. default:
  13231. error('Unknown operator ' + operator);
  13232. break;
  13233. }
  13234. }
  13235. return stack.stack;
  13236. }
  13237. };
  13238. return PostScriptEvaluator;
  13239. }();
  13240. var PostScriptCompiler = function PostScriptCompilerClosure() {
  13241. function AstNode(type) {
  13242. this.type = type;
  13243. }
  13244. AstNode.prototype.visit = function (visitor) {
  13245. throw new Error('abstract method');
  13246. };
  13247. function AstArgument(index, min, max) {
  13248. AstNode.call(this, 'args');
  13249. this.index = index;
  13250. this.min = min;
  13251. this.max = max;
  13252. }
  13253. AstArgument.prototype = Object.create(AstNode.prototype);
  13254. AstArgument.prototype.visit = function (visitor) {
  13255. visitor.visitArgument(this);
  13256. };
  13257. function AstLiteral(number) {
  13258. AstNode.call(this, 'literal');
  13259. this.number = number;
  13260. this.min = number;
  13261. this.max = number;
  13262. }
  13263. AstLiteral.prototype = Object.create(AstNode.prototype);
  13264. AstLiteral.prototype.visit = function (visitor) {
  13265. visitor.visitLiteral(this);
  13266. };
  13267. function AstBinaryOperation(op, arg1, arg2, min, max) {
  13268. AstNode.call(this, 'binary');
  13269. this.op = op;
  13270. this.arg1 = arg1;
  13271. this.arg2 = arg2;
  13272. this.min = min;
  13273. this.max = max;
  13274. }
  13275. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  13276. AstBinaryOperation.prototype.visit = function (visitor) {
  13277. visitor.visitBinaryOperation(this);
  13278. };
  13279. function AstMin(arg, max) {
  13280. AstNode.call(this, 'max');
  13281. this.arg = arg;
  13282. this.min = arg.min;
  13283. this.max = max;
  13284. }
  13285. AstMin.prototype = Object.create(AstNode.prototype);
  13286. AstMin.prototype.visit = function (visitor) {
  13287. visitor.visitMin(this);
  13288. };
  13289. function AstVariable(index, min, max) {
  13290. AstNode.call(this, 'var');
  13291. this.index = index;
  13292. this.min = min;
  13293. this.max = max;
  13294. }
  13295. AstVariable.prototype = Object.create(AstNode.prototype);
  13296. AstVariable.prototype.visit = function (visitor) {
  13297. visitor.visitVariable(this);
  13298. };
  13299. function AstVariableDefinition(variable, arg) {
  13300. AstNode.call(this, 'definition');
  13301. this.variable = variable;
  13302. this.arg = arg;
  13303. }
  13304. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  13305. AstVariableDefinition.prototype.visit = function (visitor) {
  13306. visitor.visitVariableDefinition(this);
  13307. };
  13308. function ExpressionBuilderVisitor() {
  13309. this.parts = [];
  13310. }
  13311. ExpressionBuilderVisitor.prototype = {
  13312. visitArgument: function (arg) {
  13313. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  13314. },
  13315. visitVariable: function (variable) {
  13316. this.parts.push('v', variable.index);
  13317. },
  13318. visitLiteral: function (literal) {
  13319. this.parts.push(literal.number);
  13320. },
  13321. visitBinaryOperation: function (operation) {
  13322. this.parts.push('(');
  13323. operation.arg1.visit(this);
  13324. this.parts.push(' ', operation.op, ' ');
  13325. operation.arg2.visit(this);
  13326. this.parts.push(')');
  13327. },
  13328. visitVariableDefinition: function (definition) {
  13329. this.parts.push('var ');
  13330. definition.variable.visit(this);
  13331. this.parts.push(' = ');
  13332. definition.arg.visit(this);
  13333. this.parts.push(';');
  13334. },
  13335. visitMin: function (max) {
  13336. this.parts.push('Math.min(');
  13337. max.arg.visit(this);
  13338. this.parts.push(', ', max.max, ')');
  13339. },
  13340. toString: function () {
  13341. return this.parts.join('');
  13342. }
  13343. };
  13344. function buildAddOperation(num1, num2) {
  13345. if (num2.type === 'literal' && num2.number === 0) {
  13346. return num1;
  13347. }
  13348. if (num1.type === 'literal' && num1.number === 0) {
  13349. return num2;
  13350. }
  13351. if (num2.type === 'literal' && num1.type === 'literal') {
  13352. return new AstLiteral(num1.number + num2.number);
  13353. }
  13354. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  13355. }
  13356. function buildMulOperation(num1, num2) {
  13357. if (num2.type === 'literal') {
  13358. if (num2.number === 0) {
  13359. return new AstLiteral(0);
  13360. } else if (num2.number === 1) {
  13361. return num1;
  13362. } else if (num1.type === 'literal') {
  13363. return new AstLiteral(num1.number * num2.number);
  13364. }
  13365. }
  13366. if (num1.type === 'literal') {
  13367. if (num1.number === 0) {
  13368. return new AstLiteral(0);
  13369. } else if (num1.number === 1) {
  13370. return num2;
  13371. }
  13372. }
  13373. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13374. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13375. return new AstBinaryOperation('*', num1, num2, min, max);
  13376. }
  13377. function buildSubOperation(num1, num2) {
  13378. if (num2.type === 'literal') {
  13379. if (num2.number === 0) {
  13380. return num1;
  13381. } else if (num1.type === 'literal') {
  13382. return new AstLiteral(num1.number - num2.number);
  13383. }
  13384. }
  13385. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  13386. return num2.arg2;
  13387. }
  13388. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  13389. }
  13390. function buildMinOperation(num1, max) {
  13391. if (num1.min >= max) {
  13392. return new AstLiteral(max);
  13393. } else if (num1.max <= max) {
  13394. return num1;
  13395. }
  13396. return new AstMin(num1, max);
  13397. }
  13398. function PostScriptCompiler() {
  13399. }
  13400. PostScriptCompiler.prototype = {
  13401. compile: function PostScriptCompiler_compile(code, domain, range) {
  13402. var stack = [];
  13403. var i, ii;
  13404. var instructions = [];
  13405. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  13406. var lastRegister = 0;
  13407. var n, j;
  13408. var num1, num2, ast1, ast2, tmpVar, item;
  13409. for (i = 0; i < inputSize; i++) {
  13410. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  13411. }
  13412. for (i = 0, ii = code.length; i < ii; i++) {
  13413. item = code[i];
  13414. if (typeof item === 'number') {
  13415. stack.push(new AstLiteral(item));
  13416. continue;
  13417. }
  13418. switch (item) {
  13419. case 'add':
  13420. if (stack.length < 2) {
  13421. return null;
  13422. }
  13423. num2 = stack.pop();
  13424. num1 = stack.pop();
  13425. stack.push(buildAddOperation(num1, num2));
  13426. break;
  13427. case 'cvr':
  13428. if (stack.length < 1) {
  13429. return null;
  13430. }
  13431. break;
  13432. case 'mul':
  13433. if (stack.length < 2) {
  13434. return null;
  13435. }
  13436. num2 = stack.pop();
  13437. num1 = stack.pop();
  13438. stack.push(buildMulOperation(num1, num2));
  13439. break;
  13440. case 'sub':
  13441. if (stack.length < 2) {
  13442. return null;
  13443. }
  13444. num2 = stack.pop();
  13445. num1 = stack.pop();
  13446. stack.push(buildSubOperation(num1, num2));
  13447. break;
  13448. case 'exch':
  13449. if (stack.length < 2) {
  13450. return null;
  13451. }
  13452. ast1 = stack.pop();
  13453. ast2 = stack.pop();
  13454. stack.push(ast1, ast2);
  13455. break;
  13456. case 'pop':
  13457. if (stack.length < 1) {
  13458. return null;
  13459. }
  13460. stack.pop();
  13461. break;
  13462. case 'index':
  13463. if (stack.length < 1) {
  13464. return null;
  13465. }
  13466. num1 = stack.pop();
  13467. if (num1.type !== 'literal') {
  13468. return null;
  13469. }
  13470. n = num1.number;
  13471. if (n < 0 || (n | 0) !== n || stack.length < n) {
  13472. return null;
  13473. }
  13474. ast1 = stack[stack.length - n - 1];
  13475. if (ast1.type === 'literal' || ast1.type === 'var') {
  13476. stack.push(ast1);
  13477. break;
  13478. }
  13479. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13480. stack[stack.length - n - 1] = tmpVar;
  13481. stack.push(tmpVar);
  13482. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13483. break;
  13484. case 'dup':
  13485. if (stack.length < 1) {
  13486. return null;
  13487. }
  13488. 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]) {
  13489. num1 = stack.pop();
  13490. stack.push(buildMinOperation(num1, code[i + 1]));
  13491. i += 6;
  13492. break;
  13493. }
  13494. ast1 = stack[stack.length - 1];
  13495. if (ast1.type === 'literal' || ast1.type === 'var') {
  13496. stack.push(ast1);
  13497. break;
  13498. }
  13499. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13500. stack[stack.length - 1] = tmpVar;
  13501. stack.push(tmpVar);
  13502. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13503. break;
  13504. case 'roll':
  13505. if (stack.length < 2) {
  13506. return null;
  13507. }
  13508. num2 = stack.pop();
  13509. num1 = stack.pop();
  13510. if (num2.type !== 'literal' || num1.type !== 'literal') {
  13511. return null;
  13512. }
  13513. j = num2.number;
  13514. n = num1.number;
  13515. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  13516. return null;
  13517. }
  13518. j = (j % n + n) % n;
  13519. if (j === 0) {
  13520. break;
  13521. }
  13522. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  13523. break;
  13524. default:
  13525. return null;
  13526. }
  13527. }
  13528. if (stack.length !== outputSize) {
  13529. return null;
  13530. }
  13531. var result = [];
  13532. instructions.forEach(function (instruction) {
  13533. var statementBuilder = new ExpressionBuilderVisitor();
  13534. instruction.visit(statementBuilder);
  13535. result.push(statementBuilder.toString());
  13536. });
  13537. stack.forEach(function (expr, i) {
  13538. var statementBuilder = new ExpressionBuilderVisitor();
  13539. expr.visit(statementBuilder);
  13540. var min = range[i * 2], max = range[i * 2 + 1];
  13541. var out = [statementBuilder.toString()];
  13542. if (min > expr.min) {
  13543. out.unshift('Math.max(', min, ', ');
  13544. out.push(')');
  13545. }
  13546. if (max < expr.max) {
  13547. out.unshift('Math.min(', max, ', ');
  13548. out.push(')');
  13549. }
  13550. out.unshift('dest[destOffset + ', i, '] = ');
  13551. out.push(';');
  13552. result.push(out.join(''));
  13553. });
  13554. return result.join('\n');
  13555. }
  13556. };
  13557. return PostScriptCompiler;
  13558. }();
  13559. exports.isPDFFunction = isPDFFunction;
  13560. exports.PDFFunction = PDFFunction;
  13561. exports.PostScriptEvaluator = PostScriptEvaluator;
  13562. exports.PostScriptCompiler = PostScriptCompiler;
  13563. /***/ }),
  13564. /* 8 */
  13565. /***/ (function(module, exports, __w_pdfjs_require__) {
  13566. "use strict";
  13567. var sharedUtil = __w_pdfjs_require__(0);
  13568. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  13569. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  13570. t['A'] = 0x0041;
  13571. t['AE'] = 0x00C6;
  13572. t['AEacute'] = 0x01FC;
  13573. t['AEmacron'] = 0x01E2;
  13574. t['AEsmall'] = 0xF7E6;
  13575. t['Aacute'] = 0x00C1;
  13576. t['Aacutesmall'] = 0xF7E1;
  13577. t['Abreve'] = 0x0102;
  13578. t['Abreveacute'] = 0x1EAE;
  13579. t['Abrevecyrillic'] = 0x04D0;
  13580. t['Abrevedotbelow'] = 0x1EB6;
  13581. t['Abrevegrave'] = 0x1EB0;
  13582. t['Abrevehookabove'] = 0x1EB2;
  13583. t['Abrevetilde'] = 0x1EB4;
  13584. t['Acaron'] = 0x01CD;
  13585. t['Acircle'] = 0x24B6;
  13586. t['Acircumflex'] = 0x00C2;
  13587. t['Acircumflexacute'] = 0x1EA4;
  13588. t['Acircumflexdotbelow'] = 0x1EAC;
  13589. t['Acircumflexgrave'] = 0x1EA6;
  13590. t['Acircumflexhookabove'] = 0x1EA8;
  13591. t['Acircumflexsmall'] = 0xF7E2;
  13592. t['Acircumflextilde'] = 0x1EAA;
  13593. t['Acute'] = 0xF6C9;
  13594. t['Acutesmall'] = 0xF7B4;
  13595. t['Acyrillic'] = 0x0410;
  13596. t['Adblgrave'] = 0x0200;
  13597. t['Adieresis'] = 0x00C4;
  13598. t['Adieresiscyrillic'] = 0x04D2;
  13599. t['Adieresismacron'] = 0x01DE;
  13600. t['Adieresissmall'] = 0xF7E4;
  13601. t['Adotbelow'] = 0x1EA0;
  13602. t['Adotmacron'] = 0x01E0;
  13603. t['Agrave'] = 0x00C0;
  13604. t['Agravesmall'] = 0xF7E0;
  13605. t['Ahookabove'] = 0x1EA2;
  13606. t['Aiecyrillic'] = 0x04D4;
  13607. t['Ainvertedbreve'] = 0x0202;
  13608. t['Alpha'] = 0x0391;
  13609. t['Alphatonos'] = 0x0386;
  13610. t['Amacron'] = 0x0100;
  13611. t['Amonospace'] = 0xFF21;
  13612. t['Aogonek'] = 0x0104;
  13613. t['Aring'] = 0x00C5;
  13614. t['Aringacute'] = 0x01FA;
  13615. t['Aringbelow'] = 0x1E00;
  13616. t['Aringsmall'] = 0xF7E5;
  13617. t['Asmall'] = 0xF761;
  13618. t['Atilde'] = 0x00C3;
  13619. t['Atildesmall'] = 0xF7E3;
  13620. t['Aybarmenian'] = 0x0531;
  13621. t['B'] = 0x0042;
  13622. t['Bcircle'] = 0x24B7;
  13623. t['Bdotaccent'] = 0x1E02;
  13624. t['Bdotbelow'] = 0x1E04;
  13625. t['Becyrillic'] = 0x0411;
  13626. t['Benarmenian'] = 0x0532;
  13627. t['Beta'] = 0x0392;
  13628. t['Bhook'] = 0x0181;
  13629. t['Blinebelow'] = 0x1E06;
  13630. t['Bmonospace'] = 0xFF22;
  13631. t['Brevesmall'] = 0xF6F4;
  13632. t['Bsmall'] = 0xF762;
  13633. t['Btopbar'] = 0x0182;
  13634. t['C'] = 0x0043;
  13635. t['Caarmenian'] = 0x053E;
  13636. t['Cacute'] = 0x0106;
  13637. t['Caron'] = 0xF6CA;
  13638. t['Caronsmall'] = 0xF6F5;
  13639. t['Ccaron'] = 0x010C;
  13640. t['Ccedilla'] = 0x00C7;
  13641. t['Ccedillaacute'] = 0x1E08;
  13642. t['Ccedillasmall'] = 0xF7E7;
  13643. t['Ccircle'] = 0x24B8;
  13644. t['Ccircumflex'] = 0x0108;
  13645. t['Cdot'] = 0x010A;
  13646. t['Cdotaccent'] = 0x010A;
  13647. t['Cedillasmall'] = 0xF7B8;
  13648. t['Chaarmenian'] = 0x0549;
  13649. t['Cheabkhasiancyrillic'] = 0x04BC;
  13650. t['Checyrillic'] = 0x0427;
  13651. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  13652. t['Chedescendercyrillic'] = 0x04B6;
  13653. t['Chedieresiscyrillic'] = 0x04F4;
  13654. t['Cheharmenian'] = 0x0543;
  13655. t['Chekhakassiancyrillic'] = 0x04CB;
  13656. t['Cheverticalstrokecyrillic'] = 0x04B8;
  13657. t['Chi'] = 0x03A7;
  13658. t['Chook'] = 0x0187;
  13659. t['Circumflexsmall'] = 0xF6F6;
  13660. t['Cmonospace'] = 0xFF23;
  13661. t['Coarmenian'] = 0x0551;
  13662. t['Csmall'] = 0xF763;
  13663. t['D'] = 0x0044;
  13664. t['DZ'] = 0x01F1;
  13665. t['DZcaron'] = 0x01C4;
  13666. t['Daarmenian'] = 0x0534;
  13667. t['Dafrican'] = 0x0189;
  13668. t['Dcaron'] = 0x010E;
  13669. t['Dcedilla'] = 0x1E10;
  13670. t['Dcircle'] = 0x24B9;
  13671. t['Dcircumflexbelow'] = 0x1E12;
  13672. t['Dcroat'] = 0x0110;
  13673. t['Ddotaccent'] = 0x1E0A;
  13674. t['Ddotbelow'] = 0x1E0C;
  13675. t['Decyrillic'] = 0x0414;
  13676. t['Deicoptic'] = 0x03EE;
  13677. t['Delta'] = 0x2206;
  13678. t['Deltagreek'] = 0x0394;
  13679. t['Dhook'] = 0x018A;
  13680. t['Dieresis'] = 0xF6CB;
  13681. t['DieresisAcute'] = 0xF6CC;
  13682. t['DieresisGrave'] = 0xF6CD;
  13683. t['Dieresissmall'] = 0xF7A8;
  13684. t['Digammagreek'] = 0x03DC;
  13685. t['Djecyrillic'] = 0x0402;
  13686. t['Dlinebelow'] = 0x1E0E;
  13687. t['Dmonospace'] = 0xFF24;
  13688. t['Dotaccentsmall'] = 0xF6F7;
  13689. t['Dslash'] = 0x0110;
  13690. t['Dsmall'] = 0xF764;
  13691. t['Dtopbar'] = 0x018B;
  13692. t['Dz'] = 0x01F2;
  13693. t['Dzcaron'] = 0x01C5;
  13694. t['Dzeabkhasiancyrillic'] = 0x04E0;
  13695. t['Dzecyrillic'] = 0x0405;
  13696. t['Dzhecyrillic'] = 0x040F;
  13697. t['E'] = 0x0045;
  13698. t['Eacute'] = 0x00C9;
  13699. t['Eacutesmall'] = 0xF7E9;
  13700. t['Ebreve'] = 0x0114;
  13701. t['Ecaron'] = 0x011A;
  13702. t['Ecedillabreve'] = 0x1E1C;
  13703. t['Echarmenian'] = 0x0535;
  13704. t['Ecircle'] = 0x24BA;
  13705. t['Ecircumflex'] = 0x00CA;
  13706. t['Ecircumflexacute'] = 0x1EBE;
  13707. t['Ecircumflexbelow'] = 0x1E18;
  13708. t['Ecircumflexdotbelow'] = 0x1EC6;
  13709. t['Ecircumflexgrave'] = 0x1EC0;
  13710. t['Ecircumflexhookabove'] = 0x1EC2;
  13711. t['Ecircumflexsmall'] = 0xF7EA;
  13712. t['Ecircumflextilde'] = 0x1EC4;
  13713. t['Ecyrillic'] = 0x0404;
  13714. t['Edblgrave'] = 0x0204;
  13715. t['Edieresis'] = 0x00CB;
  13716. t['Edieresissmall'] = 0xF7EB;
  13717. t['Edot'] = 0x0116;
  13718. t['Edotaccent'] = 0x0116;
  13719. t['Edotbelow'] = 0x1EB8;
  13720. t['Efcyrillic'] = 0x0424;
  13721. t['Egrave'] = 0x00C8;
  13722. t['Egravesmall'] = 0xF7E8;
  13723. t['Eharmenian'] = 0x0537;
  13724. t['Ehookabove'] = 0x1EBA;
  13725. t['Eightroman'] = 0x2167;
  13726. t['Einvertedbreve'] = 0x0206;
  13727. t['Eiotifiedcyrillic'] = 0x0464;
  13728. t['Elcyrillic'] = 0x041B;
  13729. t['Elevenroman'] = 0x216A;
  13730. t['Emacron'] = 0x0112;
  13731. t['Emacronacute'] = 0x1E16;
  13732. t['Emacrongrave'] = 0x1E14;
  13733. t['Emcyrillic'] = 0x041C;
  13734. t['Emonospace'] = 0xFF25;
  13735. t['Encyrillic'] = 0x041D;
  13736. t['Endescendercyrillic'] = 0x04A2;
  13737. t['Eng'] = 0x014A;
  13738. t['Enghecyrillic'] = 0x04A4;
  13739. t['Enhookcyrillic'] = 0x04C7;
  13740. t['Eogonek'] = 0x0118;
  13741. t['Eopen'] = 0x0190;
  13742. t['Epsilon'] = 0x0395;
  13743. t['Epsilontonos'] = 0x0388;
  13744. t['Ercyrillic'] = 0x0420;
  13745. t['Ereversed'] = 0x018E;
  13746. t['Ereversedcyrillic'] = 0x042D;
  13747. t['Escyrillic'] = 0x0421;
  13748. t['Esdescendercyrillic'] = 0x04AA;
  13749. t['Esh'] = 0x01A9;
  13750. t['Esmall'] = 0xF765;
  13751. t['Eta'] = 0x0397;
  13752. t['Etarmenian'] = 0x0538;
  13753. t['Etatonos'] = 0x0389;
  13754. t['Eth'] = 0x00D0;
  13755. t['Ethsmall'] = 0xF7F0;
  13756. t['Etilde'] = 0x1EBC;
  13757. t['Etildebelow'] = 0x1E1A;
  13758. t['Euro'] = 0x20AC;
  13759. t['Ezh'] = 0x01B7;
  13760. t['Ezhcaron'] = 0x01EE;
  13761. t['Ezhreversed'] = 0x01B8;
  13762. t['F'] = 0x0046;
  13763. t['Fcircle'] = 0x24BB;
  13764. t['Fdotaccent'] = 0x1E1E;
  13765. t['Feharmenian'] = 0x0556;
  13766. t['Feicoptic'] = 0x03E4;
  13767. t['Fhook'] = 0x0191;
  13768. t['Fitacyrillic'] = 0x0472;
  13769. t['Fiveroman'] = 0x2164;
  13770. t['Fmonospace'] = 0xFF26;
  13771. t['Fourroman'] = 0x2163;
  13772. t['Fsmall'] = 0xF766;
  13773. t['G'] = 0x0047;
  13774. t['GBsquare'] = 0x3387;
  13775. t['Gacute'] = 0x01F4;
  13776. t['Gamma'] = 0x0393;
  13777. t['Gammaafrican'] = 0x0194;
  13778. t['Gangiacoptic'] = 0x03EA;
  13779. t['Gbreve'] = 0x011E;
  13780. t['Gcaron'] = 0x01E6;
  13781. t['Gcedilla'] = 0x0122;
  13782. t['Gcircle'] = 0x24BC;
  13783. t['Gcircumflex'] = 0x011C;
  13784. t['Gcommaaccent'] = 0x0122;
  13785. t['Gdot'] = 0x0120;
  13786. t['Gdotaccent'] = 0x0120;
  13787. t['Gecyrillic'] = 0x0413;
  13788. t['Ghadarmenian'] = 0x0542;
  13789. t['Ghemiddlehookcyrillic'] = 0x0494;
  13790. t['Ghestrokecyrillic'] = 0x0492;
  13791. t['Gheupturncyrillic'] = 0x0490;
  13792. t['Ghook'] = 0x0193;
  13793. t['Gimarmenian'] = 0x0533;
  13794. t['Gjecyrillic'] = 0x0403;
  13795. t['Gmacron'] = 0x1E20;
  13796. t['Gmonospace'] = 0xFF27;
  13797. t['Grave'] = 0xF6CE;
  13798. t['Gravesmall'] = 0xF760;
  13799. t['Gsmall'] = 0xF767;
  13800. t['Gsmallhook'] = 0x029B;
  13801. t['Gstroke'] = 0x01E4;
  13802. t['H'] = 0x0048;
  13803. t['H18533'] = 0x25CF;
  13804. t['H18543'] = 0x25AA;
  13805. t['H18551'] = 0x25AB;
  13806. t['H22073'] = 0x25A1;
  13807. t['HPsquare'] = 0x33CB;
  13808. t['Haabkhasiancyrillic'] = 0x04A8;
  13809. t['Hadescendercyrillic'] = 0x04B2;
  13810. t['Hardsigncyrillic'] = 0x042A;
  13811. t['Hbar'] = 0x0126;
  13812. t['Hbrevebelow'] = 0x1E2A;
  13813. t['Hcedilla'] = 0x1E28;
  13814. t['Hcircle'] = 0x24BD;
  13815. t['Hcircumflex'] = 0x0124;
  13816. t['Hdieresis'] = 0x1E26;
  13817. t['Hdotaccent'] = 0x1E22;
  13818. t['Hdotbelow'] = 0x1E24;
  13819. t['Hmonospace'] = 0xFF28;
  13820. t['Hoarmenian'] = 0x0540;
  13821. t['Horicoptic'] = 0x03E8;
  13822. t['Hsmall'] = 0xF768;
  13823. t['Hungarumlaut'] = 0xF6CF;
  13824. t['Hungarumlautsmall'] = 0xF6F8;
  13825. t['Hzsquare'] = 0x3390;
  13826. t['I'] = 0x0049;
  13827. t['IAcyrillic'] = 0x042F;
  13828. t['IJ'] = 0x0132;
  13829. t['IUcyrillic'] = 0x042E;
  13830. t['Iacute'] = 0x00CD;
  13831. t['Iacutesmall'] = 0xF7ED;
  13832. t['Ibreve'] = 0x012C;
  13833. t['Icaron'] = 0x01CF;
  13834. t['Icircle'] = 0x24BE;
  13835. t['Icircumflex'] = 0x00CE;
  13836. t['Icircumflexsmall'] = 0xF7EE;
  13837. t['Icyrillic'] = 0x0406;
  13838. t['Idblgrave'] = 0x0208;
  13839. t['Idieresis'] = 0x00CF;
  13840. t['Idieresisacute'] = 0x1E2E;
  13841. t['Idieresiscyrillic'] = 0x04E4;
  13842. t['Idieresissmall'] = 0xF7EF;
  13843. t['Idot'] = 0x0130;
  13844. t['Idotaccent'] = 0x0130;
  13845. t['Idotbelow'] = 0x1ECA;
  13846. t['Iebrevecyrillic'] = 0x04D6;
  13847. t['Iecyrillic'] = 0x0415;
  13848. t['Ifraktur'] = 0x2111;
  13849. t['Igrave'] = 0x00CC;
  13850. t['Igravesmall'] = 0xF7EC;
  13851. t['Ihookabove'] = 0x1EC8;
  13852. t['Iicyrillic'] = 0x0418;
  13853. t['Iinvertedbreve'] = 0x020A;
  13854. t['Iishortcyrillic'] = 0x0419;
  13855. t['Imacron'] = 0x012A;
  13856. t['Imacroncyrillic'] = 0x04E2;
  13857. t['Imonospace'] = 0xFF29;
  13858. t['Iniarmenian'] = 0x053B;
  13859. t['Iocyrillic'] = 0x0401;
  13860. t['Iogonek'] = 0x012E;
  13861. t['Iota'] = 0x0399;
  13862. t['Iotaafrican'] = 0x0196;
  13863. t['Iotadieresis'] = 0x03AA;
  13864. t['Iotatonos'] = 0x038A;
  13865. t['Ismall'] = 0xF769;
  13866. t['Istroke'] = 0x0197;
  13867. t['Itilde'] = 0x0128;
  13868. t['Itildebelow'] = 0x1E2C;
  13869. t['Izhitsacyrillic'] = 0x0474;
  13870. t['Izhitsadblgravecyrillic'] = 0x0476;
  13871. t['J'] = 0x004A;
  13872. t['Jaarmenian'] = 0x0541;
  13873. t['Jcircle'] = 0x24BF;
  13874. t['Jcircumflex'] = 0x0134;
  13875. t['Jecyrillic'] = 0x0408;
  13876. t['Jheharmenian'] = 0x054B;
  13877. t['Jmonospace'] = 0xFF2A;
  13878. t['Jsmall'] = 0xF76A;
  13879. t['K'] = 0x004B;
  13880. t['KBsquare'] = 0x3385;
  13881. t['KKsquare'] = 0x33CD;
  13882. t['Kabashkircyrillic'] = 0x04A0;
  13883. t['Kacute'] = 0x1E30;
  13884. t['Kacyrillic'] = 0x041A;
  13885. t['Kadescendercyrillic'] = 0x049A;
  13886. t['Kahookcyrillic'] = 0x04C3;
  13887. t['Kappa'] = 0x039A;
  13888. t['Kastrokecyrillic'] = 0x049E;
  13889. t['Kaverticalstrokecyrillic'] = 0x049C;
  13890. t['Kcaron'] = 0x01E8;
  13891. t['Kcedilla'] = 0x0136;
  13892. t['Kcircle'] = 0x24C0;
  13893. t['Kcommaaccent'] = 0x0136;
  13894. t['Kdotbelow'] = 0x1E32;
  13895. t['Keharmenian'] = 0x0554;
  13896. t['Kenarmenian'] = 0x053F;
  13897. t['Khacyrillic'] = 0x0425;
  13898. t['Kheicoptic'] = 0x03E6;
  13899. t['Khook'] = 0x0198;
  13900. t['Kjecyrillic'] = 0x040C;
  13901. t['Klinebelow'] = 0x1E34;
  13902. t['Kmonospace'] = 0xFF2B;
  13903. t['Koppacyrillic'] = 0x0480;
  13904. t['Koppagreek'] = 0x03DE;
  13905. t['Ksicyrillic'] = 0x046E;
  13906. t['Ksmall'] = 0xF76B;
  13907. t['L'] = 0x004C;
  13908. t['LJ'] = 0x01C7;
  13909. t['LL'] = 0xF6BF;
  13910. t['Lacute'] = 0x0139;
  13911. t['Lambda'] = 0x039B;
  13912. t['Lcaron'] = 0x013D;
  13913. t['Lcedilla'] = 0x013B;
  13914. t['Lcircle'] = 0x24C1;
  13915. t['Lcircumflexbelow'] = 0x1E3C;
  13916. t['Lcommaaccent'] = 0x013B;
  13917. t['Ldot'] = 0x013F;
  13918. t['Ldotaccent'] = 0x013F;
  13919. t['Ldotbelow'] = 0x1E36;
  13920. t['Ldotbelowmacron'] = 0x1E38;
  13921. t['Liwnarmenian'] = 0x053C;
  13922. t['Lj'] = 0x01C8;
  13923. t['Ljecyrillic'] = 0x0409;
  13924. t['Llinebelow'] = 0x1E3A;
  13925. t['Lmonospace'] = 0xFF2C;
  13926. t['Lslash'] = 0x0141;
  13927. t['Lslashsmall'] = 0xF6F9;
  13928. t['Lsmall'] = 0xF76C;
  13929. t['M'] = 0x004D;
  13930. t['MBsquare'] = 0x3386;
  13931. t['Macron'] = 0xF6D0;
  13932. t['Macronsmall'] = 0xF7AF;
  13933. t['Macute'] = 0x1E3E;
  13934. t['Mcircle'] = 0x24C2;
  13935. t['Mdotaccent'] = 0x1E40;
  13936. t['Mdotbelow'] = 0x1E42;
  13937. t['Menarmenian'] = 0x0544;
  13938. t['Mmonospace'] = 0xFF2D;
  13939. t['Msmall'] = 0xF76D;
  13940. t['Mturned'] = 0x019C;
  13941. t['Mu'] = 0x039C;
  13942. t['N'] = 0x004E;
  13943. t['NJ'] = 0x01CA;
  13944. t['Nacute'] = 0x0143;
  13945. t['Ncaron'] = 0x0147;
  13946. t['Ncedilla'] = 0x0145;
  13947. t['Ncircle'] = 0x24C3;
  13948. t['Ncircumflexbelow'] = 0x1E4A;
  13949. t['Ncommaaccent'] = 0x0145;
  13950. t['Ndotaccent'] = 0x1E44;
  13951. t['Ndotbelow'] = 0x1E46;
  13952. t['Nhookleft'] = 0x019D;
  13953. t['Nineroman'] = 0x2168;
  13954. t['Nj'] = 0x01CB;
  13955. t['Njecyrillic'] = 0x040A;
  13956. t['Nlinebelow'] = 0x1E48;
  13957. t['Nmonospace'] = 0xFF2E;
  13958. t['Nowarmenian'] = 0x0546;
  13959. t['Nsmall'] = 0xF76E;
  13960. t['Ntilde'] = 0x00D1;
  13961. t['Ntildesmall'] = 0xF7F1;
  13962. t['Nu'] = 0x039D;
  13963. t['O'] = 0x004F;
  13964. t['OE'] = 0x0152;
  13965. t['OEsmall'] = 0xF6FA;
  13966. t['Oacute'] = 0x00D3;
  13967. t['Oacutesmall'] = 0xF7F3;
  13968. t['Obarredcyrillic'] = 0x04E8;
  13969. t['Obarreddieresiscyrillic'] = 0x04EA;
  13970. t['Obreve'] = 0x014E;
  13971. t['Ocaron'] = 0x01D1;
  13972. t['Ocenteredtilde'] = 0x019F;
  13973. t['Ocircle'] = 0x24C4;
  13974. t['Ocircumflex'] = 0x00D4;
  13975. t['Ocircumflexacute'] = 0x1ED0;
  13976. t['Ocircumflexdotbelow'] = 0x1ED8;
  13977. t['Ocircumflexgrave'] = 0x1ED2;
  13978. t['Ocircumflexhookabove'] = 0x1ED4;
  13979. t['Ocircumflexsmall'] = 0xF7F4;
  13980. t['Ocircumflextilde'] = 0x1ED6;
  13981. t['Ocyrillic'] = 0x041E;
  13982. t['Odblacute'] = 0x0150;
  13983. t['Odblgrave'] = 0x020C;
  13984. t['Odieresis'] = 0x00D6;
  13985. t['Odieresiscyrillic'] = 0x04E6;
  13986. t['Odieresissmall'] = 0xF7F6;
  13987. t['Odotbelow'] = 0x1ECC;
  13988. t['Ogoneksmall'] = 0xF6FB;
  13989. t['Ograve'] = 0x00D2;
  13990. t['Ogravesmall'] = 0xF7F2;
  13991. t['Oharmenian'] = 0x0555;
  13992. t['Ohm'] = 0x2126;
  13993. t['Ohookabove'] = 0x1ECE;
  13994. t['Ohorn'] = 0x01A0;
  13995. t['Ohornacute'] = 0x1EDA;
  13996. t['Ohorndotbelow'] = 0x1EE2;
  13997. t['Ohorngrave'] = 0x1EDC;
  13998. t['Ohornhookabove'] = 0x1EDE;
  13999. t['Ohorntilde'] = 0x1EE0;
  14000. t['Ohungarumlaut'] = 0x0150;
  14001. t['Oi'] = 0x01A2;
  14002. t['Oinvertedbreve'] = 0x020E;
  14003. t['Omacron'] = 0x014C;
  14004. t['Omacronacute'] = 0x1E52;
  14005. t['Omacrongrave'] = 0x1E50;
  14006. t['Omega'] = 0x2126;
  14007. t['Omegacyrillic'] = 0x0460;
  14008. t['Omegagreek'] = 0x03A9;
  14009. t['Omegaroundcyrillic'] = 0x047A;
  14010. t['Omegatitlocyrillic'] = 0x047C;
  14011. t['Omegatonos'] = 0x038F;
  14012. t['Omicron'] = 0x039F;
  14013. t['Omicrontonos'] = 0x038C;
  14014. t['Omonospace'] = 0xFF2F;
  14015. t['Oneroman'] = 0x2160;
  14016. t['Oogonek'] = 0x01EA;
  14017. t['Oogonekmacron'] = 0x01EC;
  14018. t['Oopen'] = 0x0186;
  14019. t['Oslash'] = 0x00D8;
  14020. t['Oslashacute'] = 0x01FE;
  14021. t['Oslashsmall'] = 0xF7F8;
  14022. t['Osmall'] = 0xF76F;
  14023. t['Ostrokeacute'] = 0x01FE;
  14024. t['Otcyrillic'] = 0x047E;
  14025. t['Otilde'] = 0x00D5;
  14026. t['Otildeacute'] = 0x1E4C;
  14027. t['Otildedieresis'] = 0x1E4E;
  14028. t['Otildesmall'] = 0xF7F5;
  14029. t['P'] = 0x0050;
  14030. t['Pacute'] = 0x1E54;
  14031. t['Pcircle'] = 0x24C5;
  14032. t['Pdotaccent'] = 0x1E56;
  14033. t['Pecyrillic'] = 0x041F;
  14034. t['Peharmenian'] = 0x054A;
  14035. t['Pemiddlehookcyrillic'] = 0x04A6;
  14036. t['Phi'] = 0x03A6;
  14037. t['Phook'] = 0x01A4;
  14038. t['Pi'] = 0x03A0;
  14039. t['Piwrarmenian'] = 0x0553;
  14040. t['Pmonospace'] = 0xFF30;
  14041. t['Psi'] = 0x03A8;
  14042. t['Psicyrillic'] = 0x0470;
  14043. t['Psmall'] = 0xF770;
  14044. t['Q'] = 0x0051;
  14045. t['Qcircle'] = 0x24C6;
  14046. t['Qmonospace'] = 0xFF31;
  14047. t['Qsmall'] = 0xF771;
  14048. t['R'] = 0x0052;
  14049. t['Raarmenian'] = 0x054C;
  14050. t['Racute'] = 0x0154;
  14051. t['Rcaron'] = 0x0158;
  14052. t['Rcedilla'] = 0x0156;
  14053. t['Rcircle'] = 0x24C7;
  14054. t['Rcommaaccent'] = 0x0156;
  14055. t['Rdblgrave'] = 0x0210;
  14056. t['Rdotaccent'] = 0x1E58;
  14057. t['Rdotbelow'] = 0x1E5A;
  14058. t['Rdotbelowmacron'] = 0x1E5C;
  14059. t['Reharmenian'] = 0x0550;
  14060. t['Rfraktur'] = 0x211C;
  14061. t['Rho'] = 0x03A1;
  14062. t['Ringsmall'] = 0xF6FC;
  14063. t['Rinvertedbreve'] = 0x0212;
  14064. t['Rlinebelow'] = 0x1E5E;
  14065. t['Rmonospace'] = 0xFF32;
  14066. t['Rsmall'] = 0xF772;
  14067. t['Rsmallinverted'] = 0x0281;
  14068. t['Rsmallinvertedsuperior'] = 0x02B6;
  14069. t['S'] = 0x0053;
  14070. t['SF010000'] = 0x250C;
  14071. t['SF020000'] = 0x2514;
  14072. t['SF030000'] = 0x2510;
  14073. t['SF040000'] = 0x2518;
  14074. t['SF050000'] = 0x253C;
  14075. t['SF060000'] = 0x252C;
  14076. t['SF070000'] = 0x2534;
  14077. t['SF080000'] = 0x251C;
  14078. t['SF090000'] = 0x2524;
  14079. t['SF100000'] = 0x2500;
  14080. t['SF110000'] = 0x2502;
  14081. t['SF190000'] = 0x2561;
  14082. t['SF200000'] = 0x2562;
  14083. t['SF210000'] = 0x2556;
  14084. t['SF220000'] = 0x2555;
  14085. t['SF230000'] = 0x2563;
  14086. t['SF240000'] = 0x2551;
  14087. t['SF250000'] = 0x2557;
  14088. t['SF260000'] = 0x255D;
  14089. t['SF270000'] = 0x255C;
  14090. t['SF280000'] = 0x255B;
  14091. t['SF360000'] = 0x255E;
  14092. t['SF370000'] = 0x255F;
  14093. t['SF380000'] = 0x255A;
  14094. t['SF390000'] = 0x2554;
  14095. t['SF400000'] = 0x2569;
  14096. t['SF410000'] = 0x2566;
  14097. t['SF420000'] = 0x2560;
  14098. t['SF430000'] = 0x2550;
  14099. t['SF440000'] = 0x256C;
  14100. t['SF450000'] = 0x2567;
  14101. t['SF460000'] = 0x2568;
  14102. t['SF470000'] = 0x2564;
  14103. t['SF480000'] = 0x2565;
  14104. t['SF490000'] = 0x2559;
  14105. t['SF500000'] = 0x2558;
  14106. t['SF510000'] = 0x2552;
  14107. t['SF520000'] = 0x2553;
  14108. t['SF530000'] = 0x256B;
  14109. t['SF540000'] = 0x256A;
  14110. t['Sacute'] = 0x015A;
  14111. t['Sacutedotaccent'] = 0x1E64;
  14112. t['Sampigreek'] = 0x03E0;
  14113. t['Scaron'] = 0x0160;
  14114. t['Scarondotaccent'] = 0x1E66;
  14115. t['Scaronsmall'] = 0xF6FD;
  14116. t['Scedilla'] = 0x015E;
  14117. t['Schwa'] = 0x018F;
  14118. t['Schwacyrillic'] = 0x04D8;
  14119. t['Schwadieresiscyrillic'] = 0x04DA;
  14120. t['Scircle'] = 0x24C8;
  14121. t['Scircumflex'] = 0x015C;
  14122. t['Scommaaccent'] = 0x0218;
  14123. t['Sdotaccent'] = 0x1E60;
  14124. t['Sdotbelow'] = 0x1E62;
  14125. t['Sdotbelowdotaccent'] = 0x1E68;
  14126. t['Seharmenian'] = 0x054D;
  14127. t['Sevenroman'] = 0x2166;
  14128. t['Shaarmenian'] = 0x0547;
  14129. t['Shacyrillic'] = 0x0428;
  14130. t['Shchacyrillic'] = 0x0429;
  14131. t['Sheicoptic'] = 0x03E2;
  14132. t['Shhacyrillic'] = 0x04BA;
  14133. t['Shimacoptic'] = 0x03EC;
  14134. t['Sigma'] = 0x03A3;
  14135. t['Sixroman'] = 0x2165;
  14136. t['Smonospace'] = 0xFF33;
  14137. t['Softsigncyrillic'] = 0x042C;
  14138. t['Ssmall'] = 0xF773;
  14139. t['Stigmagreek'] = 0x03DA;
  14140. t['T'] = 0x0054;
  14141. t['Tau'] = 0x03A4;
  14142. t['Tbar'] = 0x0166;
  14143. t['Tcaron'] = 0x0164;
  14144. t['Tcedilla'] = 0x0162;
  14145. t['Tcircle'] = 0x24C9;
  14146. t['Tcircumflexbelow'] = 0x1E70;
  14147. t['Tcommaaccent'] = 0x0162;
  14148. t['Tdotaccent'] = 0x1E6A;
  14149. t['Tdotbelow'] = 0x1E6C;
  14150. t['Tecyrillic'] = 0x0422;
  14151. t['Tedescendercyrillic'] = 0x04AC;
  14152. t['Tenroman'] = 0x2169;
  14153. t['Tetsecyrillic'] = 0x04B4;
  14154. t['Theta'] = 0x0398;
  14155. t['Thook'] = 0x01AC;
  14156. t['Thorn'] = 0x00DE;
  14157. t['Thornsmall'] = 0xF7FE;
  14158. t['Threeroman'] = 0x2162;
  14159. t['Tildesmall'] = 0xF6FE;
  14160. t['Tiwnarmenian'] = 0x054F;
  14161. t['Tlinebelow'] = 0x1E6E;
  14162. t['Tmonospace'] = 0xFF34;
  14163. t['Toarmenian'] = 0x0539;
  14164. t['Tonefive'] = 0x01BC;
  14165. t['Tonesix'] = 0x0184;
  14166. t['Tonetwo'] = 0x01A7;
  14167. t['Tretroflexhook'] = 0x01AE;
  14168. t['Tsecyrillic'] = 0x0426;
  14169. t['Tshecyrillic'] = 0x040B;
  14170. t['Tsmall'] = 0xF774;
  14171. t['Twelveroman'] = 0x216B;
  14172. t['Tworoman'] = 0x2161;
  14173. t['U'] = 0x0055;
  14174. t['Uacute'] = 0x00DA;
  14175. t['Uacutesmall'] = 0xF7FA;
  14176. t['Ubreve'] = 0x016C;
  14177. t['Ucaron'] = 0x01D3;
  14178. t['Ucircle'] = 0x24CA;
  14179. t['Ucircumflex'] = 0x00DB;
  14180. t['Ucircumflexbelow'] = 0x1E76;
  14181. t['Ucircumflexsmall'] = 0xF7FB;
  14182. t['Ucyrillic'] = 0x0423;
  14183. t['Udblacute'] = 0x0170;
  14184. t['Udblgrave'] = 0x0214;
  14185. t['Udieresis'] = 0x00DC;
  14186. t['Udieresisacute'] = 0x01D7;
  14187. t['Udieresisbelow'] = 0x1E72;
  14188. t['Udieresiscaron'] = 0x01D9;
  14189. t['Udieresiscyrillic'] = 0x04F0;
  14190. t['Udieresisgrave'] = 0x01DB;
  14191. t['Udieresismacron'] = 0x01D5;
  14192. t['Udieresissmall'] = 0xF7FC;
  14193. t['Udotbelow'] = 0x1EE4;
  14194. t['Ugrave'] = 0x00D9;
  14195. t['Ugravesmall'] = 0xF7F9;
  14196. t['Uhookabove'] = 0x1EE6;
  14197. t['Uhorn'] = 0x01AF;
  14198. t['Uhornacute'] = 0x1EE8;
  14199. t['Uhorndotbelow'] = 0x1EF0;
  14200. t['Uhorngrave'] = 0x1EEA;
  14201. t['Uhornhookabove'] = 0x1EEC;
  14202. t['Uhorntilde'] = 0x1EEE;
  14203. t['Uhungarumlaut'] = 0x0170;
  14204. t['Uhungarumlautcyrillic'] = 0x04F2;
  14205. t['Uinvertedbreve'] = 0x0216;
  14206. t['Ukcyrillic'] = 0x0478;
  14207. t['Umacron'] = 0x016A;
  14208. t['Umacroncyrillic'] = 0x04EE;
  14209. t['Umacrondieresis'] = 0x1E7A;
  14210. t['Umonospace'] = 0xFF35;
  14211. t['Uogonek'] = 0x0172;
  14212. t['Upsilon'] = 0x03A5;
  14213. t['Upsilon1'] = 0x03D2;
  14214. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14215. t['Upsilonafrican'] = 0x01B1;
  14216. t['Upsilondieresis'] = 0x03AB;
  14217. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14218. t['Upsilonhooksymbol'] = 0x03D2;
  14219. t['Upsilontonos'] = 0x038E;
  14220. t['Uring'] = 0x016E;
  14221. t['Ushortcyrillic'] = 0x040E;
  14222. t['Usmall'] = 0xF775;
  14223. t['Ustraightcyrillic'] = 0x04AE;
  14224. t['Ustraightstrokecyrillic'] = 0x04B0;
  14225. t['Utilde'] = 0x0168;
  14226. t['Utildeacute'] = 0x1E78;
  14227. t['Utildebelow'] = 0x1E74;
  14228. t['V'] = 0x0056;
  14229. t['Vcircle'] = 0x24CB;
  14230. t['Vdotbelow'] = 0x1E7E;
  14231. t['Vecyrillic'] = 0x0412;
  14232. t['Vewarmenian'] = 0x054E;
  14233. t['Vhook'] = 0x01B2;
  14234. t['Vmonospace'] = 0xFF36;
  14235. t['Voarmenian'] = 0x0548;
  14236. t['Vsmall'] = 0xF776;
  14237. t['Vtilde'] = 0x1E7C;
  14238. t['W'] = 0x0057;
  14239. t['Wacute'] = 0x1E82;
  14240. t['Wcircle'] = 0x24CC;
  14241. t['Wcircumflex'] = 0x0174;
  14242. t['Wdieresis'] = 0x1E84;
  14243. t['Wdotaccent'] = 0x1E86;
  14244. t['Wdotbelow'] = 0x1E88;
  14245. t['Wgrave'] = 0x1E80;
  14246. t['Wmonospace'] = 0xFF37;
  14247. t['Wsmall'] = 0xF777;
  14248. t['X'] = 0x0058;
  14249. t['Xcircle'] = 0x24CD;
  14250. t['Xdieresis'] = 0x1E8C;
  14251. t['Xdotaccent'] = 0x1E8A;
  14252. t['Xeharmenian'] = 0x053D;
  14253. t['Xi'] = 0x039E;
  14254. t['Xmonospace'] = 0xFF38;
  14255. t['Xsmall'] = 0xF778;
  14256. t['Y'] = 0x0059;
  14257. t['Yacute'] = 0x00DD;
  14258. t['Yacutesmall'] = 0xF7FD;
  14259. t['Yatcyrillic'] = 0x0462;
  14260. t['Ycircle'] = 0x24CE;
  14261. t['Ycircumflex'] = 0x0176;
  14262. t['Ydieresis'] = 0x0178;
  14263. t['Ydieresissmall'] = 0xF7FF;
  14264. t['Ydotaccent'] = 0x1E8E;
  14265. t['Ydotbelow'] = 0x1EF4;
  14266. t['Yericyrillic'] = 0x042B;
  14267. t['Yerudieresiscyrillic'] = 0x04F8;
  14268. t['Ygrave'] = 0x1EF2;
  14269. t['Yhook'] = 0x01B3;
  14270. t['Yhookabove'] = 0x1EF6;
  14271. t['Yiarmenian'] = 0x0545;
  14272. t['Yicyrillic'] = 0x0407;
  14273. t['Yiwnarmenian'] = 0x0552;
  14274. t['Ymonospace'] = 0xFF39;
  14275. t['Ysmall'] = 0xF779;
  14276. t['Ytilde'] = 0x1EF8;
  14277. t['Yusbigcyrillic'] = 0x046A;
  14278. t['Yusbigiotifiedcyrillic'] = 0x046C;
  14279. t['Yuslittlecyrillic'] = 0x0466;
  14280. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  14281. t['Z'] = 0x005A;
  14282. t['Zaarmenian'] = 0x0536;
  14283. t['Zacute'] = 0x0179;
  14284. t['Zcaron'] = 0x017D;
  14285. t['Zcaronsmall'] = 0xF6FF;
  14286. t['Zcircle'] = 0x24CF;
  14287. t['Zcircumflex'] = 0x1E90;
  14288. t['Zdot'] = 0x017B;
  14289. t['Zdotaccent'] = 0x017B;
  14290. t['Zdotbelow'] = 0x1E92;
  14291. t['Zecyrillic'] = 0x0417;
  14292. t['Zedescendercyrillic'] = 0x0498;
  14293. t['Zedieresiscyrillic'] = 0x04DE;
  14294. t['Zeta'] = 0x0396;
  14295. t['Zhearmenian'] = 0x053A;
  14296. t['Zhebrevecyrillic'] = 0x04C1;
  14297. t['Zhecyrillic'] = 0x0416;
  14298. t['Zhedescendercyrillic'] = 0x0496;
  14299. t['Zhedieresiscyrillic'] = 0x04DC;
  14300. t['Zlinebelow'] = 0x1E94;
  14301. t['Zmonospace'] = 0xFF3A;
  14302. t['Zsmall'] = 0xF77A;
  14303. t['Zstroke'] = 0x01B5;
  14304. t['a'] = 0x0061;
  14305. t['aabengali'] = 0x0986;
  14306. t['aacute'] = 0x00E1;
  14307. t['aadeva'] = 0x0906;
  14308. t['aagujarati'] = 0x0A86;
  14309. t['aagurmukhi'] = 0x0A06;
  14310. t['aamatragurmukhi'] = 0x0A3E;
  14311. t['aarusquare'] = 0x3303;
  14312. t['aavowelsignbengali'] = 0x09BE;
  14313. t['aavowelsigndeva'] = 0x093E;
  14314. t['aavowelsigngujarati'] = 0x0ABE;
  14315. t['abbreviationmarkarmenian'] = 0x055F;
  14316. t['abbreviationsigndeva'] = 0x0970;
  14317. t['abengali'] = 0x0985;
  14318. t['abopomofo'] = 0x311A;
  14319. t['abreve'] = 0x0103;
  14320. t['abreveacute'] = 0x1EAF;
  14321. t['abrevecyrillic'] = 0x04D1;
  14322. t['abrevedotbelow'] = 0x1EB7;
  14323. t['abrevegrave'] = 0x1EB1;
  14324. t['abrevehookabove'] = 0x1EB3;
  14325. t['abrevetilde'] = 0x1EB5;
  14326. t['acaron'] = 0x01CE;
  14327. t['acircle'] = 0x24D0;
  14328. t['acircumflex'] = 0x00E2;
  14329. t['acircumflexacute'] = 0x1EA5;
  14330. t['acircumflexdotbelow'] = 0x1EAD;
  14331. t['acircumflexgrave'] = 0x1EA7;
  14332. t['acircumflexhookabove'] = 0x1EA9;
  14333. t['acircumflextilde'] = 0x1EAB;
  14334. t['acute'] = 0x00B4;
  14335. t['acutebelowcmb'] = 0x0317;
  14336. t['acutecmb'] = 0x0301;
  14337. t['acutecomb'] = 0x0301;
  14338. t['acutedeva'] = 0x0954;
  14339. t['acutelowmod'] = 0x02CF;
  14340. t['acutetonecmb'] = 0x0341;
  14341. t['acyrillic'] = 0x0430;
  14342. t['adblgrave'] = 0x0201;
  14343. t['addakgurmukhi'] = 0x0A71;
  14344. t['adeva'] = 0x0905;
  14345. t['adieresis'] = 0x00E4;
  14346. t['adieresiscyrillic'] = 0x04D3;
  14347. t['adieresismacron'] = 0x01DF;
  14348. t['adotbelow'] = 0x1EA1;
  14349. t['adotmacron'] = 0x01E1;
  14350. t['ae'] = 0x00E6;
  14351. t['aeacute'] = 0x01FD;
  14352. t['aekorean'] = 0x3150;
  14353. t['aemacron'] = 0x01E3;
  14354. t['afii00208'] = 0x2015;
  14355. t['afii08941'] = 0x20A4;
  14356. t['afii10017'] = 0x0410;
  14357. t['afii10018'] = 0x0411;
  14358. t['afii10019'] = 0x0412;
  14359. t['afii10020'] = 0x0413;
  14360. t['afii10021'] = 0x0414;
  14361. t['afii10022'] = 0x0415;
  14362. t['afii10023'] = 0x0401;
  14363. t['afii10024'] = 0x0416;
  14364. t['afii10025'] = 0x0417;
  14365. t['afii10026'] = 0x0418;
  14366. t['afii10027'] = 0x0419;
  14367. t['afii10028'] = 0x041A;
  14368. t['afii10029'] = 0x041B;
  14369. t['afii10030'] = 0x041C;
  14370. t['afii10031'] = 0x041D;
  14371. t['afii10032'] = 0x041E;
  14372. t['afii10033'] = 0x041F;
  14373. t['afii10034'] = 0x0420;
  14374. t['afii10035'] = 0x0421;
  14375. t['afii10036'] = 0x0422;
  14376. t['afii10037'] = 0x0423;
  14377. t['afii10038'] = 0x0424;
  14378. t['afii10039'] = 0x0425;
  14379. t['afii10040'] = 0x0426;
  14380. t['afii10041'] = 0x0427;
  14381. t['afii10042'] = 0x0428;
  14382. t['afii10043'] = 0x0429;
  14383. t['afii10044'] = 0x042A;
  14384. t['afii10045'] = 0x042B;
  14385. t['afii10046'] = 0x042C;
  14386. t['afii10047'] = 0x042D;
  14387. t['afii10048'] = 0x042E;
  14388. t['afii10049'] = 0x042F;
  14389. t['afii10050'] = 0x0490;
  14390. t['afii10051'] = 0x0402;
  14391. t['afii10052'] = 0x0403;
  14392. t['afii10053'] = 0x0404;
  14393. t['afii10054'] = 0x0405;
  14394. t['afii10055'] = 0x0406;
  14395. t['afii10056'] = 0x0407;
  14396. t['afii10057'] = 0x0408;
  14397. t['afii10058'] = 0x0409;
  14398. t['afii10059'] = 0x040A;
  14399. t['afii10060'] = 0x040B;
  14400. t['afii10061'] = 0x040C;
  14401. t['afii10062'] = 0x040E;
  14402. t['afii10063'] = 0xF6C4;
  14403. t['afii10064'] = 0xF6C5;
  14404. t['afii10065'] = 0x0430;
  14405. t['afii10066'] = 0x0431;
  14406. t['afii10067'] = 0x0432;
  14407. t['afii10068'] = 0x0433;
  14408. t['afii10069'] = 0x0434;
  14409. t['afii10070'] = 0x0435;
  14410. t['afii10071'] = 0x0451;
  14411. t['afii10072'] = 0x0436;
  14412. t['afii10073'] = 0x0437;
  14413. t['afii10074'] = 0x0438;
  14414. t['afii10075'] = 0x0439;
  14415. t['afii10076'] = 0x043A;
  14416. t['afii10077'] = 0x043B;
  14417. t['afii10078'] = 0x043C;
  14418. t['afii10079'] = 0x043D;
  14419. t['afii10080'] = 0x043E;
  14420. t['afii10081'] = 0x043F;
  14421. t['afii10082'] = 0x0440;
  14422. t['afii10083'] = 0x0441;
  14423. t['afii10084'] = 0x0442;
  14424. t['afii10085'] = 0x0443;
  14425. t['afii10086'] = 0x0444;
  14426. t['afii10087'] = 0x0445;
  14427. t['afii10088'] = 0x0446;
  14428. t['afii10089'] = 0x0447;
  14429. t['afii10090'] = 0x0448;
  14430. t['afii10091'] = 0x0449;
  14431. t['afii10092'] = 0x044A;
  14432. t['afii10093'] = 0x044B;
  14433. t['afii10094'] = 0x044C;
  14434. t['afii10095'] = 0x044D;
  14435. t['afii10096'] = 0x044E;
  14436. t['afii10097'] = 0x044F;
  14437. t['afii10098'] = 0x0491;
  14438. t['afii10099'] = 0x0452;
  14439. t['afii10100'] = 0x0453;
  14440. t['afii10101'] = 0x0454;
  14441. t['afii10102'] = 0x0455;
  14442. t['afii10103'] = 0x0456;
  14443. t['afii10104'] = 0x0457;
  14444. t['afii10105'] = 0x0458;
  14445. t['afii10106'] = 0x0459;
  14446. t['afii10107'] = 0x045A;
  14447. t['afii10108'] = 0x045B;
  14448. t['afii10109'] = 0x045C;
  14449. t['afii10110'] = 0x045E;
  14450. t['afii10145'] = 0x040F;
  14451. t['afii10146'] = 0x0462;
  14452. t['afii10147'] = 0x0472;
  14453. t['afii10148'] = 0x0474;
  14454. t['afii10192'] = 0xF6C6;
  14455. t['afii10193'] = 0x045F;
  14456. t['afii10194'] = 0x0463;
  14457. t['afii10195'] = 0x0473;
  14458. t['afii10196'] = 0x0475;
  14459. t['afii10831'] = 0xF6C7;
  14460. t['afii10832'] = 0xF6C8;
  14461. t['afii10846'] = 0x04D9;
  14462. t['afii299'] = 0x200E;
  14463. t['afii300'] = 0x200F;
  14464. t['afii301'] = 0x200D;
  14465. t['afii57381'] = 0x066A;
  14466. t['afii57388'] = 0x060C;
  14467. t['afii57392'] = 0x0660;
  14468. t['afii57393'] = 0x0661;
  14469. t['afii57394'] = 0x0662;
  14470. t['afii57395'] = 0x0663;
  14471. t['afii57396'] = 0x0664;
  14472. t['afii57397'] = 0x0665;
  14473. t['afii57398'] = 0x0666;
  14474. t['afii57399'] = 0x0667;
  14475. t['afii57400'] = 0x0668;
  14476. t['afii57401'] = 0x0669;
  14477. t['afii57403'] = 0x061B;
  14478. t['afii57407'] = 0x061F;
  14479. t['afii57409'] = 0x0621;
  14480. t['afii57410'] = 0x0622;
  14481. t['afii57411'] = 0x0623;
  14482. t['afii57412'] = 0x0624;
  14483. t['afii57413'] = 0x0625;
  14484. t['afii57414'] = 0x0626;
  14485. t['afii57415'] = 0x0627;
  14486. t['afii57416'] = 0x0628;
  14487. t['afii57417'] = 0x0629;
  14488. t['afii57418'] = 0x062A;
  14489. t['afii57419'] = 0x062B;
  14490. t['afii57420'] = 0x062C;
  14491. t['afii57421'] = 0x062D;
  14492. t['afii57422'] = 0x062E;
  14493. t['afii57423'] = 0x062F;
  14494. t['afii57424'] = 0x0630;
  14495. t['afii57425'] = 0x0631;
  14496. t['afii57426'] = 0x0632;
  14497. t['afii57427'] = 0x0633;
  14498. t['afii57428'] = 0x0634;
  14499. t['afii57429'] = 0x0635;
  14500. t['afii57430'] = 0x0636;
  14501. t['afii57431'] = 0x0637;
  14502. t['afii57432'] = 0x0638;
  14503. t['afii57433'] = 0x0639;
  14504. t['afii57434'] = 0x063A;
  14505. t['afii57440'] = 0x0640;
  14506. t['afii57441'] = 0x0641;
  14507. t['afii57442'] = 0x0642;
  14508. t['afii57443'] = 0x0643;
  14509. t['afii57444'] = 0x0644;
  14510. t['afii57445'] = 0x0645;
  14511. t['afii57446'] = 0x0646;
  14512. t['afii57448'] = 0x0648;
  14513. t['afii57449'] = 0x0649;
  14514. t['afii57450'] = 0x064A;
  14515. t['afii57451'] = 0x064B;
  14516. t['afii57452'] = 0x064C;
  14517. t['afii57453'] = 0x064D;
  14518. t['afii57454'] = 0x064E;
  14519. t['afii57455'] = 0x064F;
  14520. t['afii57456'] = 0x0650;
  14521. t['afii57457'] = 0x0651;
  14522. t['afii57458'] = 0x0652;
  14523. t['afii57470'] = 0x0647;
  14524. t['afii57505'] = 0x06A4;
  14525. t['afii57506'] = 0x067E;
  14526. t['afii57507'] = 0x0686;
  14527. t['afii57508'] = 0x0698;
  14528. t['afii57509'] = 0x06AF;
  14529. t['afii57511'] = 0x0679;
  14530. t['afii57512'] = 0x0688;
  14531. t['afii57513'] = 0x0691;
  14532. t['afii57514'] = 0x06BA;
  14533. t['afii57519'] = 0x06D2;
  14534. t['afii57534'] = 0x06D5;
  14535. t['afii57636'] = 0x20AA;
  14536. t['afii57645'] = 0x05BE;
  14537. t['afii57658'] = 0x05C3;
  14538. t['afii57664'] = 0x05D0;
  14539. t['afii57665'] = 0x05D1;
  14540. t['afii57666'] = 0x05D2;
  14541. t['afii57667'] = 0x05D3;
  14542. t['afii57668'] = 0x05D4;
  14543. t['afii57669'] = 0x05D5;
  14544. t['afii57670'] = 0x05D6;
  14545. t['afii57671'] = 0x05D7;
  14546. t['afii57672'] = 0x05D8;
  14547. t['afii57673'] = 0x05D9;
  14548. t['afii57674'] = 0x05DA;
  14549. t['afii57675'] = 0x05DB;
  14550. t['afii57676'] = 0x05DC;
  14551. t['afii57677'] = 0x05DD;
  14552. t['afii57678'] = 0x05DE;
  14553. t['afii57679'] = 0x05DF;
  14554. t['afii57680'] = 0x05E0;
  14555. t['afii57681'] = 0x05E1;
  14556. t['afii57682'] = 0x05E2;
  14557. t['afii57683'] = 0x05E3;
  14558. t['afii57684'] = 0x05E4;
  14559. t['afii57685'] = 0x05E5;
  14560. t['afii57686'] = 0x05E6;
  14561. t['afii57687'] = 0x05E7;
  14562. t['afii57688'] = 0x05E8;
  14563. t['afii57689'] = 0x05E9;
  14564. t['afii57690'] = 0x05EA;
  14565. t['afii57694'] = 0xFB2A;
  14566. t['afii57695'] = 0xFB2B;
  14567. t['afii57700'] = 0xFB4B;
  14568. t['afii57705'] = 0xFB1F;
  14569. t['afii57716'] = 0x05F0;
  14570. t['afii57717'] = 0x05F1;
  14571. t['afii57718'] = 0x05F2;
  14572. t['afii57723'] = 0xFB35;
  14573. t['afii57793'] = 0x05B4;
  14574. t['afii57794'] = 0x05B5;
  14575. t['afii57795'] = 0x05B6;
  14576. t['afii57796'] = 0x05BB;
  14577. t['afii57797'] = 0x05B8;
  14578. t['afii57798'] = 0x05B7;
  14579. t['afii57799'] = 0x05B0;
  14580. t['afii57800'] = 0x05B2;
  14581. t['afii57801'] = 0x05B1;
  14582. t['afii57802'] = 0x05B3;
  14583. t['afii57803'] = 0x05C2;
  14584. t['afii57804'] = 0x05C1;
  14585. t['afii57806'] = 0x05B9;
  14586. t['afii57807'] = 0x05BC;
  14587. t['afii57839'] = 0x05BD;
  14588. t['afii57841'] = 0x05BF;
  14589. t['afii57842'] = 0x05C0;
  14590. t['afii57929'] = 0x02BC;
  14591. t['afii61248'] = 0x2105;
  14592. t['afii61289'] = 0x2113;
  14593. t['afii61352'] = 0x2116;
  14594. t['afii61573'] = 0x202C;
  14595. t['afii61574'] = 0x202D;
  14596. t['afii61575'] = 0x202E;
  14597. t['afii61664'] = 0x200C;
  14598. t['afii63167'] = 0x066D;
  14599. t['afii64937'] = 0x02BD;
  14600. t['agrave'] = 0x00E0;
  14601. t['agujarati'] = 0x0A85;
  14602. t['agurmukhi'] = 0x0A05;
  14603. t['ahiragana'] = 0x3042;
  14604. t['ahookabove'] = 0x1EA3;
  14605. t['aibengali'] = 0x0990;
  14606. t['aibopomofo'] = 0x311E;
  14607. t['aideva'] = 0x0910;
  14608. t['aiecyrillic'] = 0x04D5;
  14609. t['aigujarati'] = 0x0A90;
  14610. t['aigurmukhi'] = 0x0A10;
  14611. t['aimatragurmukhi'] = 0x0A48;
  14612. t['ainarabic'] = 0x0639;
  14613. t['ainfinalarabic'] = 0xFECA;
  14614. t['aininitialarabic'] = 0xFECB;
  14615. t['ainmedialarabic'] = 0xFECC;
  14616. t['ainvertedbreve'] = 0x0203;
  14617. t['aivowelsignbengali'] = 0x09C8;
  14618. t['aivowelsigndeva'] = 0x0948;
  14619. t['aivowelsigngujarati'] = 0x0AC8;
  14620. t['akatakana'] = 0x30A2;
  14621. t['akatakanahalfwidth'] = 0xFF71;
  14622. t['akorean'] = 0x314F;
  14623. t['alef'] = 0x05D0;
  14624. t['alefarabic'] = 0x0627;
  14625. t['alefdageshhebrew'] = 0xFB30;
  14626. t['aleffinalarabic'] = 0xFE8E;
  14627. t['alefhamzaabovearabic'] = 0x0623;
  14628. t['alefhamzaabovefinalarabic'] = 0xFE84;
  14629. t['alefhamzabelowarabic'] = 0x0625;
  14630. t['alefhamzabelowfinalarabic'] = 0xFE88;
  14631. t['alefhebrew'] = 0x05D0;
  14632. t['aleflamedhebrew'] = 0xFB4F;
  14633. t['alefmaddaabovearabic'] = 0x0622;
  14634. t['alefmaddaabovefinalarabic'] = 0xFE82;
  14635. t['alefmaksuraarabic'] = 0x0649;
  14636. t['alefmaksurafinalarabic'] = 0xFEF0;
  14637. t['alefmaksurainitialarabic'] = 0xFEF3;
  14638. t['alefmaksuramedialarabic'] = 0xFEF4;
  14639. t['alefpatahhebrew'] = 0xFB2E;
  14640. t['alefqamatshebrew'] = 0xFB2F;
  14641. t['aleph'] = 0x2135;
  14642. t['allequal'] = 0x224C;
  14643. t['alpha'] = 0x03B1;
  14644. t['alphatonos'] = 0x03AC;
  14645. t['amacron'] = 0x0101;
  14646. t['amonospace'] = 0xFF41;
  14647. t['ampersand'] = 0x0026;
  14648. t['ampersandmonospace'] = 0xFF06;
  14649. t['ampersandsmall'] = 0xF726;
  14650. t['amsquare'] = 0x33C2;
  14651. t['anbopomofo'] = 0x3122;
  14652. t['angbopomofo'] = 0x3124;
  14653. t['angbracketleft'] = 0x3008;
  14654. t['angbracketright'] = 0x3009;
  14655. t['angkhankhuthai'] = 0x0E5A;
  14656. t['angle'] = 0x2220;
  14657. t['anglebracketleft'] = 0x3008;
  14658. t['anglebracketleftvertical'] = 0xFE3F;
  14659. t['anglebracketright'] = 0x3009;
  14660. t['anglebracketrightvertical'] = 0xFE40;
  14661. t['angleleft'] = 0x2329;
  14662. t['angleright'] = 0x232A;
  14663. t['angstrom'] = 0x212B;
  14664. t['anoteleia'] = 0x0387;
  14665. t['anudattadeva'] = 0x0952;
  14666. t['anusvarabengali'] = 0x0982;
  14667. t['anusvaradeva'] = 0x0902;
  14668. t['anusvaragujarati'] = 0x0A82;
  14669. t['aogonek'] = 0x0105;
  14670. t['apaatosquare'] = 0x3300;
  14671. t['aparen'] = 0x249C;
  14672. t['apostrophearmenian'] = 0x055A;
  14673. t['apostrophemod'] = 0x02BC;
  14674. t['apple'] = 0xF8FF;
  14675. t['approaches'] = 0x2250;
  14676. t['approxequal'] = 0x2248;
  14677. t['approxequalorimage'] = 0x2252;
  14678. t['approximatelyequal'] = 0x2245;
  14679. t['araeaekorean'] = 0x318E;
  14680. t['araeakorean'] = 0x318D;
  14681. t['arc'] = 0x2312;
  14682. t['arighthalfring'] = 0x1E9A;
  14683. t['aring'] = 0x00E5;
  14684. t['aringacute'] = 0x01FB;
  14685. t['aringbelow'] = 0x1E01;
  14686. t['arrowboth'] = 0x2194;
  14687. t['arrowdashdown'] = 0x21E3;
  14688. t['arrowdashleft'] = 0x21E0;
  14689. t['arrowdashright'] = 0x21E2;
  14690. t['arrowdashup'] = 0x21E1;
  14691. t['arrowdblboth'] = 0x21D4;
  14692. t['arrowdbldown'] = 0x21D3;
  14693. t['arrowdblleft'] = 0x21D0;
  14694. t['arrowdblright'] = 0x21D2;
  14695. t['arrowdblup'] = 0x21D1;
  14696. t['arrowdown'] = 0x2193;
  14697. t['arrowdownleft'] = 0x2199;
  14698. t['arrowdownright'] = 0x2198;
  14699. t['arrowdownwhite'] = 0x21E9;
  14700. t['arrowheaddownmod'] = 0x02C5;
  14701. t['arrowheadleftmod'] = 0x02C2;
  14702. t['arrowheadrightmod'] = 0x02C3;
  14703. t['arrowheadupmod'] = 0x02C4;
  14704. t['arrowhorizex'] = 0xF8E7;
  14705. t['arrowleft'] = 0x2190;
  14706. t['arrowleftdbl'] = 0x21D0;
  14707. t['arrowleftdblstroke'] = 0x21CD;
  14708. t['arrowleftoverright'] = 0x21C6;
  14709. t['arrowleftwhite'] = 0x21E6;
  14710. t['arrowright'] = 0x2192;
  14711. t['arrowrightdblstroke'] = 0x21CF;
  14712. t['arrowrightheavy'] = 0x279E;
  14713. t['arrowrightoverleft'] = 0x21C4;
  14714. t['arrowrightwhite'] = 0x21E8;
  14715. t['arrowtableft'] = 0x21E4;
  14716. t['arrowtabright'] = 0x21E5;
  14717. t['arrowup'] = 0x2191;
  14718. t['arrowupdn'] = 0x2195;
  14719. t['arrowupdnbse'] = 0x21A8;
  14720. t['arrowupdownbase'] = 0x21A8;
  14721. t['arrowupleft'] = 0x2196;
  14722. t['arrowupleftofdown'] = 0x21C5;
  14723. t['arrowupright'] = 0x2197;
  14724. t['arrowupwhite'] = 0x21E7;
  14725. t['arrowvertex'] = 0xF8E6;
  14726. t['asciicircum'] = 0x005E;
  14727. t['asciicircummonospace'] = 0xFF3E;
  14728. t['asciitilde'] = 0x007E;
  14729. t['asciitildemonospace'] = 0xFF5E;
  14730. t['ascript'] = 0x0251;
  14731. t['ascriptturned'] = 0x0252;
  14732. t['asmallhiragana'] = 0x3041;
  14733. t['asmallkatakana'] = 0x30A1;
  14734. t['asmallkatakanahalfwidth'] = 0xFF67;
  14735. t['asterisk'] = 0x002A;
  14736. t['asteriskaltonearabic'] = 0x066D;
  14737. t['asteriskarabic'] = 0x066D;
  14738. t['asteriskmath'] = 0x2217;
  14739. t['asteriskmonospace'] = 0xFF0A;
  14740. t['asterisksmall'] = 0xFE61;
  14741. t['asterism'] = 0x2042;
  14742. t['asuperior'] = 0xF6E9;
  14743. t['asymptoticallyequal'] = 0x2243;
  14744. t['at'] = 0x0040;
  14745. t['atilde'] = 0x00E3;
  14746. t['atmonospace'] = 0xFF20;
  14747. t['atsmall'] = 0xFE6B;
  14748. t['aturned'] = 0x0250;
  14749. t['aubengali'] = 0x0994;
  14750. t['aubopomofo'] = 0x3120;
  14751. t['audeva'] = 0x0914;
  14752. t['augujarati'] = 0x0A94;
  14753. t['augurmukhi'] = 0x0A14;
  14754. t['aulengthmarkbengali'] = 0x09D7;
  14755. t['aumatragurmukhi'] = 0x0A4C;
  14756. t['auvowelsignbengali'] = 0x09CC;
  14757. t['auvowelsigndeva'] = 0x094C;
  14758. t['auvowelsigngujarati'] = 0x0ACC;
  14759. t['avagrahadeva'] = 0x093D;
  14760. t['aybarmenian'] = 0x0561;
  14761. t['ayin'] = 0x05E2;
  14762. t['ayinaltonehebrew'] = 0xFB20;
  14763. t['ayinhebrew'] = 0x05E2;
  14764. t['b'] = 0x0062;
  14765. t['babengali'] = 0x09AC;
  14766. t['backslash'] = 0x005C;
  14767. t['backslashmonospace'] = 0xFF3C;
  14768. t['badeva'] = 0x092C;
  14769. t['bagujarati'] = 0x0AAC;
  14770. t['bagurmukhi'] = 0x0A2C;
  14771. t['bahiragana'] = 0x3070;
  14772. t['bahtthai'] = 0x0E3F;
  14773. t['bakatakana'] = 0x30D0;
  14774. t['bar'] = 0x007C;
  14775. t['barmonospace'] = 0xFF5C;
  14776. t['bbopomofo'] = 0x3105;
  14777. t['bcircle'] = 0x24D1;
  14778. t['bdotaccent'] = 0x1E03;
  14779. t['bdotbelow'] = 0x1E05;
  14780. t['beamedsixteenthnotes'] = 0x266C;
  14781. t['because'] = 0x2235;
  14782. t['becyrillic'] = 0x0431;
  14783. t['beharabic'] = 0x0628;
  14784. t['behfinalarabic'] = 0xFE90;
  14785. t['behinitialarabic'] = 0xFE91;
  14786. t['behiragana'] = 0x3079;
  14787. t['behmedialarabic'] = 0xFE92;
  14788. t['behmeeminitialarabic'] = 0xFC9F;
  14789. t['behmeemisolatedarabic'] = 0xFC08;
  14790. t['behnoonfinalarabic'] = 0xFC6D;
  14791. t['bekatakana'] = 0x30D9;
  14792. t['benarmenian'] = 0x0562;
  14793. t['bet'] = 0x05D1;
  14794. t['beta'] = 0x03B2;
  14795. t['betasymbolgreek'] = 0x03D0;
  14796. t['betdagesh'] = 0xFB31;
  14797. t['betdageshhebrew'] = 0xFB31;
  14798. t['bethebrew'] = 0x05D1;
  14799. t['betrafehebrew'] = 0xFB4C;
  14800. t['bhabengali'] = 0x09AD;
  14801. t['bhadeva'] = 0x092D;
  14802. t['bhagujarati'] = 0x0AAD;
  14803. t['bhagurmukhi'] = 0x0A2D;
  14804. t['bhook'] = 0x0253;
  14805. t['bihiragana'] = 0x3073;
  14806. t['bikatakana'] = 0x30D3;
  14807. t['bilabialclick'] = 0x0298;
  14808. t['bindigurmukhi'] = 0x0A02;
  14809. t['birusquare'] = 0x3331;
  14810. t['blackcircle'] = 0x25CF;
  14811. t['blackdiamond'] = 0x25C6;
  14812. t['blackdownpointingtriangle'] = 0x25BC;
  14813. t['blackleftpointingpointer'] = 0x25C4;
  14814. t['blackleftpointingtriangle'] = 0x25C0;
  14815. t['blacklenticularbracketleft'] = 0x3010;
  14816. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  14817. t['blacklenticularbracketright'] = 0x3011;
  14818. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  14819. t['blacklowerlefttriangle'] = 0x25E3;
  14820. t['blacklowerrighttriangle'] = 0x25E2;
  14821. t['blackrectangle'] = 0x25AC;
  14822. t['blackrightpointingpointer'] = 0x25BA;
  14823. t['blackrightpointingtriangle'] = 0x25B6;
  14824. t['blacksmallsquare'] = 0x25AA;
  14825. t['blacksmilingface'] = 0x263B;
  14826. t['blacksquare'] = 0x25A0;
  14827. t['blackstar'] = 0x2605;
  14828. t['blackupperlefttriangle'] = 0x25E4;
  14829. t['blackupperrighttriangle'] = 0x25E5;
  14830. t['blackuppointingsmalltriangle'] = 0x25B4;
  14831. t['blackuppointingtriangle'] = 0x25B2;
  14832. t['blank'] = 0x2423;
  14833. t['blinebelow'] = 0x1E07;
  14834. t['block'] = 0x2588;
  14835. t['bmonospace'] = 0xFF42;
  14836. t['bobaimaithai'] = 0x0E1A;
  14837. t['bohiragana'] = 0x307C;
  14838. t['bokatakana'] = 0x30DC;
  14839. t['bparen'] = 0x249D;
  14840. t['bqsquare'] = 0x33C3;
  14841. t['braceex'] = 0xF8F4;
  14842. t['braceleft'] = 0x007B;
  14843. t['braceleftbt'] = 0xF8F3;
  14844. t['braceleftmid'] = 0xF8F2;
  14845. t['braceleftmonospace'] = 0xFF5B;
  14846. t['braceleftsmall'] = 0xFE5B;
  14847. t['bracelefttp'] = 0xF8F1;
  14848. t['braceleftvertical'] = 0xFE37;
  14849. t['braceright'] = 0x007D;
  14850. t['bracerightbt'] = 0xF8FE;
  14851. t['bracerightmid'] = 0xF8FD;
  14852. t['bracerightmonospace'] = 0xFF5D;
  14853. t['bracerightsmall'] = 0xFE5C;
  14854. t['bracerighttp'] = 0xF8FC;
  14855. t['bracerightvertical'] = 0xFE38;
  14856. t['bracketleft'] = 0x005B;
  14857. t['bracketleftbt'] = 0xF8F0;
  14858. t['bracketleftex'] = 0xF8EF;
  14859. t['bracketleftmonospace'] = 0xFF3B;
  14860. t['bracketlefttp'] = 0xF8EE;
  14861. t['bracketright'] = 0x005D;
  14862. t['bracketrightbt'] = 0xF8FB;
  14863. t['bracketrightex'] = 0xF8FA;
  14864. t['bracketrightmonospace'] = 0xFF3D;
  14865. t['bracketrighttp'] = 0xF8F9;
  14866. t['breve'] = 0x02D8;
  14867. t['brevebelowcmb'] = 0x032E;
  14868. t['brevecmb'] = 0x0306;
  14869. t['breveinvertedbelowcmb'] = 0x032F;
  14870. t['breveinvertedcmb'] = 0x0311;
  14871. t['breveinverteddoublecmb'] = 0x0361;
  14872. t['bridgebelowcmb'] = 0x032A;
  14873. t['bridgeinvertedbelowcmb'] = 0x033A;
  14874. t['brokenbar'] = 0x00A6;
  14875. t['bstroke'] = 0x0180;
  14876. t['bsuperior'] = 0xF6EA;
  14877. t['btopbar'] = 0x0183;
  14878. t['buhiragana'] = 0x3076;
  14879. t['bukatakana'] = 0x30D6;
  14880. t['bullet'] = 0x2022;
  14881. t['bulletinverse'] = 0x25D8;
  14882. t['bulletoperator'] = 0x2219;
  14883. t['bullseye'] = 0x25CE;
  14884. t['c'] = 0x0063;
  14885. t['caarmenian'] = 0x056E;
  14886. t['cabengali'] = 0x099A;
  14887. t['cacute'] = 0x0107;
  14888. t['cadeva'] = 0x091A;
  14889. t['cagujarati'] = 0x0A9A;
  14890. t['cagurmukhi'] = 0x0A1A;
  14891. t['calsquare'] = 0x3388;
  14892. t['candrabindubengali'] = 0x0981;
  14893. t['candrabinducmb'] = 0x0310;
  14894. t['candrabindudeva'] = 0x0901;
  14895. t['candrabindugujarati'] = 0x0A81;
  14896. t['capslock'] = 0x21EA;
  14897. t['careof'] = 0x2105;
  14898. t['caron'] = 0x02C7;
  14899. t['caronbelowcmb'] = 0x032C;
  14900. t['caroncmb'] = 0x030C;
  14901. t['carriagereturn'] = 0x21B5;
  14902. t['cbopomofo'] = 0x3118;
  14903. t['ccaron'] = 0x010D;
  14904. t['ccedilla'] = 0x00E7;
  14905. t['ccedillaacute'] = 0x1E09;
  14906. t['ccircle'] = 0x24D2;
  14907. t['ccircumflex'] = 0x0109;
  14908. t['ccurl'] = 0x0255;
  14909. t['cdot'] = 0x010B;
  14910. t['cdotaccent'] = 0x010B;
  14911. t['cdsquare'] = 0x33C5;
  14912. t['cedilla'] = 0x00B8;
  14913. t['cedillacmb'] = 0x0327;
  14914. t['cent'] = 0x00A2;
  14915. t['centigrade'] = 0x2103;
  14916. t['centinferior'] = 0xF6DF;
  14917. t['centmonospace'] = 0xFFE0;
  14918. t['centoldstyle'] = 0xF7A2;
  14919. t['centsuperior'] = 0xF6E0;
  14920. t['chaarmenian'] = 0x0579;
  14921. t['chabengali'] = 0x099B;
  14922. t['chadeva'] = 0x091B;
  14923. t['chagujarati'] = 0x0A9B;
  14924. t['chagurmukhi'] = 0x0A1B;
  14925. t['chbopomofo'] = 0x3114;
  14926. t['cheabkhasiancyrillic'] = 0x04BD;
  14927. t['checkmark'] = 0x2713;
  14928. t['checyrillic'] = 0x0447;
  14929. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  14930. t['chedescendercyrillic'] = 0x04B7;
  14931. t['chedieresiscyrillic'] = 0x04F5;
  14932. t['cheharmenian'] = 0x0573;
  14933. t['chekhakassiancyrillic'] = 0x04CC;
  14934. t['cheverticalstrokecyrillic'] = 0x04B9;
  14935. t['chi'] = 0x03C7;
  14936. t['chieuchacirclekorean'] = 0x3277;
  14937. t['chieuchaparenkorean'] = 0x3217;
  14938. t['chieuchcirclekorean'] = 0x3269;
  14939. t['chieuchkorean'] = 0x314A;
  14940. t['chieuchparenkorean'] = 0x3209;
  14941. t['chochangthai'] = 0x0E0A;
  14942. t['chochanthai'] = 0x0E08;
  14943. t['chochingthai'] = 0x0E09;
  14944. t['chochoethai'] = 0x0E0C;
  14945. t['chook'] = 0x0188;
  14946. t['cieucacirclekorean'] = 0x3276;
  14947. t['cieucaparenkorean'] = 0x3216;
  14948. t['cieuccirclekorean'] = 0x3268;
  14949. t['cieuckorean'] = 0x3148;
  14950. t['cieucparenkorean'] = 0x3208;
  14951. t['cieucuparenkorean'] = 0x321C;
  14952. t['circle'] = 0x25CB;
  14953. t['circlecopyrt'] = 0x00A9;
  14954. t['circlemultiply'] = 0x2297;
  14955. t['circleot'] = 0x2299;
  14956. t['circleplus'] = 0x2295;
  14957. t['circlepostalmark'] = 0x3036;
  14958. t['circlewithlefthalfblack'] = 0x25D0;
  14959. t['circlewithrighthalfblack'] = 0x25D1;
  14960. t['circumflex'] = 0x02C6;
  14961. t['circumflexbelowcmb'] = 0x032D;
  14962. t['circumflexcmb'] = 0x0302;
  14963. t['clear'] = 0x2327;
  14964. t['clickalveolar'] = 0x01C2;
  14965. t['clickdental'] = 0x01C0;
  14966. t['clicklateral'] = 0x01C1;
  14967. t['clickretroflex'] = 0x01C3;
  14968. t['club'] = 0x2663;
  14969. t['clubsuitblack'] = 0x2663;
  14970. t['clubsuitwhite'] = 0x2667;
  14971. t['cmcubedsquare'] = 0x33A4;
  14972. t['cmonospace'] = 0xFF43;
  14973. t['cmsquaredsquare'] = 0x33A0;
  14974. t['coarmenian'] = 0x0581;
  14975. t['colon'] = 0x003A;
  14976. t['colonmonetary'] = 0x20A1;
  14977. t['colonmonospace'] = 0xFF1A;
  14978. t['colonsign'] = 0x20A1;
  14979. t['colonsmall'] = 0xFE55;
  14980. t['colontriangularhalfmod'] = 0x02D1;
  14981. t['colontriangularmod'] = 0x02D0;
  14982. t['comma'] = 0x002C;
  14983. t['commaabovecmb'] = 0x0313;
  14984. t['commaaboverightcmb'] = 0x0315;
  14985. t['commaaccent'] = 0xF6C3;
  14986. t['commaarabic'] = 0x060C;
  14987. t['commaarmenian'] = 0x055D;
  14988. t['commainferior'] = 0xF6E1;
  14989. t['commamonospace'] = 0xFF0C;
  14990. t['commareversedabovecmb'] = 0x0314;
  14991. t['commareversedmod'] = 0x02BD;
  14992. t['commasmall'] = 0xFE50;
  14993. t['commasuperior'] = 0xF6E2;
  14994. t['commaturnedabovecmb'] = 0x0312;
  14995. t['commaturnedmod'] = 0x02BB;
  14996. t['compass'] = 0x263C;
  14997. t['congruent'] = 0x2245;
  14998. t['contourintegral'] = 0x222E;
  14999. t['control'] = 0x2303;
  15000. t['controlACK'] = 0x0006;
  15001. t['controlBEL'] = 0x0007;
  15002. t['controlBS'] = 0x0008;
  15003. t['controlCAN'] = 0x0018;
  15004. t['controlCR'] = 0x000D;
  15005. t['controlDC1'] = 0x0011;
  15006. t['controlDC2'] = 0x0012;
  15007. t['controlDC3'] = 0x0013;
  15008. t['controlDC4'] = 0x0014;
  15009. t['controlDEL'] = 0x007F;
  15010. t['controlDLE'] = 0x0010;
  15011. t['controlEM'] = 0x0019;
  15012. t['controlENQ'] = 0x0005;
  15013. t['controlEOT'] = 0x0004;
  15014. t['controlESC'] = 0x001B;
  15015. t['controlETB'] = 0x0017;
  15016. t['controlETX'] = 0x0003;
  15017. t['controlFF'] = 0x000C;
  15018. t['controlFS'] = 0x001C;
  15019. t['controlGS'] = 0x001D;
  15020. t['controlHT'] = 0x0009;
  15021. t['controlLF'] = 0x000A;
  15022. t['controlNAK'] = 0x0015;
  15023. t['controlNULL'] = 0x0000;
  15024. t['controlRS'] = 0x001E;
  15025. t['controlSI'] = 0x000F;
  15026. t['controlSO'] = 0x000E;
  15027. t['controlSOT'] = 0x0002;
  15028. t['controlSTX'] = 0x0001;
  15029. t['controlSUB'] = 0x001A;
  15030. t['controlSYN'] = 0x0016;
  15031. t['controlUS'] = 0x001F;
  15032. t['controlVT'] = 0x000B;
  15033. t['copyright'] = 0x00A9;
  15034. t['copyrightsans'] = 0xF8E9;
  15035. t['copyrightserif'] = 0xF6D9;
  15036. t['cornerbracketleft'] = 0x300C;
  15037. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15038. t['cornerbracketleftvertical'] = 0xFE41;
  15039. t['cornerbracketright'] = 0x300D;
  15040. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15041. t['cornerbracketrightvertical'] = 0xFE42;
  15042. t['corporationsquare'] = 0x337F;
  15043. t['cosquare'] = 0x33C7;
  15044. t['coverkgsquare'] = 0x33C6;
  15045. t['cparen'] = 0x249E;
  15046. t['cruzeiro'] = 0x20A2;
  15047. t['cstretched'] = 0x0297;
  15048. t['curlyand'] = 0x22CF;
  15049. t['curlyor'] = 0x22CE;
  15050. t['currency'] = 0x00A4;
  15051. t['cyrBreve'] = 0xF6D1;
  15052. t['cyrFlex'] = 0xF6D2;
  15053. t['cyrbreve'] = 0xF6D4;
  15054. t['cyrflex'] = 0xF6D5;
  15055. t['d'] = 0x0064;
  15056. t['daarmenian'] = 0x0564;
  15057. t['dabengali'] = 0x09A6;
  15058. t['dadarabic'] = 0x0636;
  15059. t['dadeva'] = 0x0926;
  15060. t['dadfinalarabic'] = 0xFEBE;
  15061. t['dadinitialarabic'] = 0xFEBF;
  15062. t['dadmedialarabic'] = 0xFEC0;
  15063. t['dagesh'] = 0x05BC;
  15064. t['dageshhebrew'] = 0x05BC;
  15065. t['dagger'] = 0x2020;
  15066. t['daggerdbl'] = 0x2021;
  15067. t['dagujarati'] = 0x0AA6;
  15068. t['dagurmukhi'] = 0x0A26;
  15069. t['dahiragana'] = 0x3060;
  15070. t['dakatakana'] = 0x30C0;
  15071. t['dalarabic'] = 0x062F;
  15072. t['dalet'] = 0x05D3;
  15073. t['daletdagesh'] = 0xFB33;
  15074. t['daletdageshhebrew'] = 0xFB33;
  15075. t['dalethebrew'] = 0x05D3;
  15076. t['dalfinalarabic'] = 0xFEAA;
  15077. t['dammaarabic'] = 0x064F;
  15078. t['dammalowarabic'] = 0x064F;
  15079. t['dammatanaltonearabic'] = 0x064C;
  15080. t['dammatanarabic'] = 0x064C;
  15081. t['danda'] = 0x0964;
  15082. t['dargahebrew'] = 0x05A7;
  15083. t['dargalefthebrew'] = 0x05A7;
  15084. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15085. t['dblGrave'] = 0xF6D3;
  15086. t['dblanglebracketleft'] = 0x300A;
  15087. t['dblanglebracketleftvertical'] = 0xFE3D;
  15088. t['dblanglebracketright'] = 0x300B;
  15089. t['dblanglebracketrightvertical'] = 0xFE3E;
  15090. t['dblarchinvertedbelowcmb'] = 0x032B;
  15091. t['dblarrowleft'] = 0x21D4;
  15092. t['dblarrowright'] = 0x21D2;
  15093. t['dbldanda'] = 0x0965;
  15094. t['dblgrave'] = 0xF6D6;
  15095. t['dblgravecmb'] = 0x030F;
  15096. t['dblintegral'] = 0x222C;
  15097. t['dbllowline'] = 0x2017;
  15098. t['dbllowlinecmb'] = 0x0333;
  15099. t['dbloverlinecmb'] = 0x033F;
  15100. t['dblprimemod'] = 0x02BA;
  15101. t['dblverticalbar'] = 0x2016;
  15102. t['dblverticallineabovecmb'] = 0x030E;
  15103. t['dbopomofo'] = 0x3109;
  15104. t['dbsquare'] = 0x33C8;
  15105. t['dcaron'] = 0x010F;
  15106. t['dcedilla'] = 0x1E11;
  15107. t['dcircle'] = 0x24D3;
  15108. t['dcircumflexbelow'] = 0x1E13;
  15109. t['dcroat'] = 0x0111;
  15110. t['ddabengali'] = 0x09A1;
  15111. t['ddadeva'] = 0x0921;
  15112. t['ddagujarati'] = 0x0AA1;
  15113. t['ddagurmukhi'] = 0x0A21;
  15114. t['ddalarabic'] = 0x0688;
  15115. t['ddalfinalarabic'] = 0xFB89;
  15116. t['dddhadeva'] = 0x095C;
  15117. t['ddhabengali'] = 0x09A2;
  15118. t['ddhadeva'] = 0x0922;
  15119. t['ddhagujarati'] = 0x0AA2;
  15120. t['ddhagurmukhi'] = 0x0A22;
  15121. t['ddotaccent'] = 0x1E0B;
  15122. t['ddotbelow'] = 0x1E0D;
  15123. t['decimalseparatorarabic'] = 0x066B;
  15124. t['decimalseparatorpersian'] = 0x066B;
  15125. t['decyrillic'] = 0x0434;
  15126. t['degree'] = 0x00B0;
  15127. t['dehihebrew'] = 0x05AD;
  15128. t['dehiragana'] = 0x3067;
  15129. t['deicoptic'] = 0x03EF;
  15130. t['dekatakana'] = 0x30C7;
  15131. t['deleteleft'] = 0x232B;
  15132. t['deleteright'] = 0x2326;
  15133. t['delta'] = 0x03B4;
  15134. t['deltaturned'] = 0x018D;
  15135. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15136. t['dezh'] = 0x02A4;
  15137. t['dhabengali'] = 0x09A7;
  15138. t['dhadeva'] = 0x0927;
  15139. t['dhagujarati'] = 0x0AA7;
  15140. t['dhagurmukhi'] = 0x0A27;
  15141. t['dhook'] = 0x0257;
  15142. t['dialytikatonos'] = 0x0385;
  15143. t['dialytikatonoscmb'] = 0x0344;
  15144. t['diamond'] = 0x2666;
  15145. t['diamondsuitwhite'] = 0x2662;
  15146. t['dieresis'] = 0x00A8;
  15147. t['dieresisacute'] = 0xF6D7;
  15148. t['dieresisbelowcmb'] = 0x0324;
  15149. t['dieresiscmb'] = 0x0308;
  15150. t['dieresisgrave'] = 0xF6D8;
  15151. t['dieresistonos'] = 0x0385;
  15152. t['dihiragana'] = 0x3062;
  15153. t['dikatakana'] = 0x30C2;
  15154. t['dittomark'] = 0x3003;
  15155. t['divide'] = 0x00F7;
  15156. t['divides'] = 0x2223;
  15157. t['divisionslash'] = 0x2215;
  15158. t['djecyrillic'] = 0x0452;
  15159. t['dkshade'] = 0x2593;
  15160. t['dlinebelow'] = 0x1E0F;
  15161. t['dlsquare'] = 0x3397;
  15162. t['dmacron'] = 0x0111;
  15163. t['dmonospace'] = 0xFF44;
  15164. t['dnblock'] = 0x2584;
  15165. t['dochadathai'] = 0x0E0E;
  15166. t['dodekthai'] = 0x0E14;
  15167. t['dohiragana'] = 0x3069;
  15168. t['dokatakana'] = 0x30C9;
  15169. t['dollar'] = 0x0024;
  15170. t['dollarinferior'] = 0xF6E3;
  15171. t['dollarmonospace'] = 0xFF04;
  15172. t['dollaroldstyle'] = 0xF724;
  15173. t['dollarsmall'] = 0xFE69;
  15174. t['dollarsuperior'] = 0xF6E4;
  15175. t['dong'] = 0x20AB;
  15176. t['dorusquare'] = 0x3326;
  15177. t['dotaccent'] = 0x02D9;
  15178. t['dotaccentcmb'] = 0x0307;
  15179. t['dotbelowcmb'] = 0x0323;
  15180. t['dotbelowcomb'] = 0x0323;
  15181. t['dotkatakana'] = 0x30FB;
  15182. t['dotlessi'] = 0x0131;
  15183. t['dotlessj'] = 0xF6BE;
  15184. t['dotlessjstrokehook'] = 0x0284;
  15185. t['dotmath'] = 0x22C5;
  15186. t['dottedcircle'] = 0x25CC;
  15187. t['doubleyodpatah'] = 0xFB1F;
  15188. t['doubleyodpatahhebrew'] = 0xFB1F;
  15189. t['downtackbelowcmb'] = 0x031E;
  15190. t['downtackmod'] = 0x02D5;
  15191. t['dparen'] = 0x249F;
  15192. t['dsuperior'] = 0xF6EB;
  15193. t['dtail'] = 0x0256;
  15194. t['dtopbar'] = 0x018C;
  15195. t['duhiragana'] = 0x3065;
  15196. t['dukatakana'] = 0x30C5;
  15197. t['dz'] = 0x01F3;
  15198. t['dzaltone'] = 0x02A3;
  15199. t['dzcaron'] = 0x01C6;
  15200. t['dzcurl'] = 0x02A5;
  15201. t['dzeabkhasiancyrillic'] = 0x04E1;
  15202. t['dzecyrillic'] = 0x0455;
  15203. t['dzhecyrillic'] = 0x045F;
  15204. t['e'] = 0x0065;
  15205. t['eacute'] = 0x00E9;
  15206. t['earth'] = 0x2641;
  15207. t['ebengali'] = 0x098F;
  15208. t['ebopomofo'] = 0x311C;
  15209. t['ebreve'] = 0x0115;
  15210. t['ecandradeva'] = 0x090D;
  15211. t['ecandragujarati'] = 0x0A8D;
  15212. t['ecandravowelsigndeva'] = 0x0945;
  15213. t['ecandravowelsigngujarati'] = 0x0AC5;
  15214. t['ecaron'] = 0x011B;
  15215. t['ecedillabreve'] = 0x1E1D;
  15216. t['echarmenian'] = 0x0565;
  15217. t['echyiwnarmenian'] = 0x0587;
  15218. t['ecircle'] = 0x24D4;
  15219. t['ecircumflex'] = 0x00EA;
  15220. t['ecircumflexacute'] = 0x1EBF;
  15221. t['ecircumflexbelow'] = 0x1E19;
  15222. t['ecircumflexdotbelow'] = 0x1EC7;
  15223. t['ecircumflexgrave'] = 0x1EC1;
  15224. t['ecircumflexhookabove'] = 0x1EC3;
  15225. t['ecircumflextilde'] = 0x1EC5;
  15226. t['ecyrillic'] = 0x0454;
  15227. t['edblgrave'] = 0x0205;
  15228. t['edeva'] = 0x090F;
  15229. t['edieresis'] = 0x00EB;
  15230. t['edot'] = 0x0117;
  15231. t['edotaccent'] = 0x0117;
  15232. t['edotbelow'] = 0x1EB9;
  15233. t['eegurmukhi'] = 0x0A0F;
  15234. t['eematragurmukhi'] = 0x0A47;
  15235. t['efcyrillic'] = 0x0444;
  15236. t['egrave'] = 0x00E8;
  15237. t['egujarati'] = 0x0A8F;
  15238. t['eharmenian'] = 0x0567;
  15239. t['ehbopomofo'] = 0x311D;
  15240. t['ehiragana'] = 0x3048;
  15241. t['ehookabove'] = 0x1EBB;
  15242. t['eibopomofo'] = 0x311F;
  15243. t['eight'] = 0x0038;
  15244. t['eightarabic'] = 0x0668;
  15245. t['eightbengali'] = 0x09EE;
  15246. t['eightcircle'] = 0x2467;
  15247. t['eightcircleinversesansserif'] = 0x2791;
  15248. t['eightdeva'] = 0x096E;
  15249. t['eighteencircle'] = 0x2471;
  15250. t['eighteenparen'] = 0x2485;
  15251. t['eighteenperiod'] = 0x2499;
  15252. t['eightgujarati'] = 0x0AEE;
  15253. t['eightgurmukhi'] = 0x0A6E;
  15254. t['eighthackarabic'] = 0x0668;
  15255. t['eighthangzhou'] = 0x3028;
  15256. t['eighthnotebeamed'] = 0x266B;
  15257. t['eightideographicparen'] = 0x3227;
  15258. t['eightinferior'] = 0x2088;
  15259. t['eightmonospace'] = 0xFF18;
  15260. t['eightoldstyle'] = 0xF738;
  15261. t['eightparen'] = 0x247B;
  15262. t['eightperiod'] = 0x248F;
  15263. t['eightpersian'] = 0x06F8;
  15264. t['eightroman'] = 0x2177;
  15265. t['eightsuperior'] = 0x2078;
  15266. t['eightthai'] = 0x0E58;
  15267. t['einvertedbreve'] = 0x0207;
  15268. t['eiotifiedcyrillic'] = 0x0465;
  15269. t['ekatakana'] = 0x30A8;
  15270. t['ekatakanahalfwidth'] = 0xFF74;
  15271. t['ekonkargurmukhi'] = 0x0A74;
  15272. t['ekorean'] = 0x3154;
  15273. t['elcyrillic'] = 0x043B;
  15274. t['element'] = 0x2208;
  15275. t['elevencircle'] = 0x246A;
  15276. t['elevenparen'] = 0x247E;
  15277. t['elevenperiod'] = 0x2492;
  15278. t['elevenroman'] = 0x217A;
  15279. t['ellipsis'] = 0x2026;
  15280. t['ellipsisvertical'] = 0x22EE;
  15281. t['emacron'] = 0x0113;
  15282. t['emacronacute'] = 0x1E17;
  15283. t['emacrongrave'] = 0x1E15;
  15284. t['emcyrillic'] = 0x043C;
  15285. t['emdash'] = 0x2014;
  15286. t['emdashvertical'] = 0xFE31;
  15287. t['emonospace'] = 0xFF45;
  15288. t['emphasismarkarmenian'] = 0x055B;
  15289. t['emptyset'] = 0x2205;
  15290. t['enbopomofo'] = 0x3123;
  15291. t['encyrillic'] = 0x043D;
  15292. t['endash'] = 0x2013;
  15293. t['endashvertical'] = 0xFE32;
  15294. t['endescendercyrillic'] = 0x04A3;
  15295. t['eng'] = 0x014B;
  15296. t['engbopomofo'] = 0x3125;
  15297. t['enghecyrillic'] = 0x04A5;
  15298. t['enhookcyrillic'] = 0x04C8;
  15299. t['enspace'] = 0x2002;
  15300. t['eogonek'] = 0x0119;
  15301. t['eokorean'] = 0x3153;
  15302. t['eopen'] = 0x025B;
  15303. t['eopenclosed'] = 0x029A;
  15304. t['eopenreversed'] = 0x025C;
  15305. t['eopenreversedclosed'] = 0x025E;
  15306. t['eopenreversedhook'] = 0x025D;
  15307. t['eparen'] = 0x24A0;
  15308. t['epsilon'] = 0x03B5;
  15309. t['epsilontonos'] = 0x03AD;
  15310. t['equal'] = 0x003D;
  15311. t['equalmonospace'] = 0xFF1D;
  15312. t['equalsmall'] = 0xFE66;
  15313. t['equalsuperior'] = 0x207C;
  15314. t['equivalence'] = 0x2261;
  15315. t['erbopomofo'] = 0x3126;
  15316. t['ercyrillic'] = 0x0440;
  15317. t['ereversed'] = 0x0258;
  15318. t['ereversedcyrillic'] = 0x044D;
  15319. t['escyrillic'] = 0x0441;
  15320. t['esdescendercyrillic'] = 0x04AB;
  15321. t['esh'] = 0x0283;
  15322. t['eshcurl'] = 0x0286;
  15323. t['eshortdeva'] = 0x090E;
  15324. t['eshortvowelsigndeva'] = 0x0946;
  15325. t['eshreversedloop'] = 0x01AA;
  15326. t['eshsquatreversed'] = 0x0285;
  15327. t['esmallhiragana'] = 0x3047;
  15328. t['esmallkatakana'] = 0x30A7;
  15329. t['esmallkatakanahalfwidth'] = 0xFF6A;
  15330. t['estimated'] = 0x212E;
  15331. t['esuperior'] = 0xF6EC;
  15332. t['eta'] = 0x03B7;
  15333. t['etarmenian'] = 0x0568;
  15334. t['etatonos'] = 0x03AE;
  15335. t['eth'] = 0x00F0;
  15336. t['etilde'] = 0x1EBD;
  15337. t['etildebelow'] = 0x1E1B;
  15338. t['etnahtafoukhhebrew'] = 0x0591;
  15339. t['etnahtafoukhlefthebrew'] = 0x0591;
  15340. t['etnahtahebrew'] = 0x0591;
  15341. t['etnahtalefthebrew'] = 0x0591;
  15342. t['eturned'] = 0x01DD;
  15343. t['eukorean'] = 0x3161;
  15344. t['euro'] = 0x20AC;
  15345. t['evowelsignbengali'] = 0x09C7;
  15346. t['evowelsigndeva'] = 0x0947;
  15347. t['evowelsigngujarati'] = 0x0AC7;
  15348. t['exclam'] = 0x0021;
  15349. t['exclamarmenian'] = 0x055C;
  15350. t['exclamdbl'] = 0x203C;
  15351. t['exclamdown'] = 0x00A1;
  15352. t['exclamdownsmall'] = 0xF7A1;
  15353. t['exclammonospace'] = 0xFF01;
  15354. t['exclamsmall'] = 0xF721;
  15355. t['existential'] = 0x2203;
  15356. t['ezh'] = 0x0292;
  15357. t['ezhcaron'] = 0x01EF;
  15358. t['ezhcurl'] = 0x0293;
  15359. t['ezhreversed'] = 0x01B9;
  15360. t['ezhtail'] = 0x01BA;
  15361. t['f'] = 0x0066;
  15362. t['fadeva'] = 0x095E;
  15363. t['fagurmukhi'] = 0x0A5E;
  15364. t['fahrenheit'] = 0x2109;
  15365. t['fathaarabic'] = 0x064E;
  15366. t['fathalowarabic'] = 0x064E;
  15367. t['fathatanarabic'] = 0x064B;
  15368. t['fbopomofo'] = 0x3108;
  15369. t['fcircle'] = 0x24D5;
  15370. t['fdotaccent'] = 0x1E1F;
  15371. t['feharabic'] = 0x0641;
  15372. t['feharmenian'] = 0x0586;
  15373. t['fehfinalarabic'] = 0xFED2;
  15374. t['fehinitialarabic'] = 0xFED3;
  15375. t['fehmedialarabic'] = 0xFED4;
  15376. t['feicoptic'] = 0x03E5;
  15377. t['female'] = 0x2640;
  15378. t['ff'] = 0xFB00;
  15379. t['ffi'] = 0xFB03;
  15380. t['ffl'] = 0xFB04;
  15381. t['fi'] = 0xFB01;
  15382. t['fifteencircle'] = 0x246E;
  15383. t['fifteenparen'] = 0x2482;
  15384. t['fifteenperiod'] = 0x2496;
  15385. t['figuredash'] = 0x2012;
  15386. t['filledbox'] = 0x25A0;
  15387. t['filledrect'] = 0x25AC;
  15388. t['finalkaf'] = 0x05DA;
  15389. t['finalkafdagesh'] = 0xFB3A;
  15390. t['finalkafdageshhebrew'] = 0xFB3A;
  15391. t['finalkafhebrew'] = 0x05DA;
  15392. t['finalmem'] = 0x05DD;
  15393. t['finalmemhebrew'] = 0x05DD;
  15394. t['finalnun'] = 0x05DF;
  15395. t['finalnunhebrew'] = 0x05DF;
  15396. t['finalpe'] = 0x05E3;
  15397. t['finalpehebrew'] = 0x05E3;
  15398. t['finaltsadi'] = 0x05E5;
  15399. t['finaltsadihebrew'] = 0x05E5;
  15400. t['firsttonechinese'] = 0x02C9;
  15401. t['fisheye'] = 0x25C9;
  15402. t['fitacyrillic'] = 0x0473;
  15403. t['five'] = 0x0035;
  15404. t['fivearabic'] = 0x0665;
  15405. t['fivebengali'] = 0x09EB;
  15406. t['fivecircle'] = 0x2464;
  15407. t['fivecircleinversesansserif'] = 0x278E;
  15408. t['fivedeva'] = 0x096B;
  15409. t['fiveeighths'] = 0x215D;
  15410. t['fivegujarati'] = 0x0AEB;
  15411. t['fivegurmukhi'] = 0x0A6B;
  15412. t['fivehackarabic'] = 0x0665;
  15413. t['fivehangzhou'] = 0x3025;
  15414. t['fiveideographicparen'] = 0x3224;
  15415. t['fiveinferior'] = 0x2085;
  15416. t['fivemonospace'] = 0xFF15;
  15417. t['fiveoldstyle'] = 0xF735;
  15418. t['fiveparen'] = 0x2478;
  15419. t['fiveperiod'] = 0x248C;
  15420. t['fivepersian'] = 0x06F5;
  15421. t['fiveroman'] = 0x2174;
  15422. t['fivesuperior'] = 0x2075;
  15423. t['fivethai'] = 0x0E55;
  15424. t['fl'] = 0xFB02;
  15425. t['florin'] = 0x0192;
  15426. t['fmonospace'] = 0xFF46;
  15427. t['fmsquare'] = 0x3399;
  15428. t['fofanthai'] = 0x0E1F;
  15429. t['fofathai'] = 0x0E1D;
  15430. t['fongmanthai'] = 0x0E4F;
  15431. t['forall'] = 0x2200;
  15432. t['four'] = 0x0034;
  15433. t['fourarabic'] = 0x0664;
  15434. t['fourbengali'] = 0x09EA;
  15435. t['fourcircle'] = 0x2463;
  15436. t['fourcircleinversesansserif'] = 0x278D;
  15437. t['fourdeva'] = 0x096A;
  15438. t['fourgujarati'] = 0x0AEA;
  15439. t['fourgurmukhi'] = 0x0A6A;
  15440. t['fourhackarabic'] = 0x0664;
  15441. t['fourhangzhou'] = 0x3024;
  15442. t['fourideographicparen'] = 0x3223;
  15443. t['fourinferior'] = 0x2084;
  15444. t['fourmonospace'] = 0xFF14;
  15445. t['fournumeratorbengali'] = 0x09F7;
  15446. t['fouroldstyle'] = 0xF734;
  15447. t['fourparen'] = 0x2477;
  15448. t['fourperiod'] = 0x248B;
  15449. t['fourpersian'] = 0x06F4;
  15450. t['fourroman'] = 0x2173;
  15451. t['foursuperior'] = 0x2074;
  15452. t['fourteencircle'] = 0x246D;
  15453. t['fourteenparen'] = 0x2481;
  15454. t['fourteenperiod'] = 0x2495;
  15455. t['fourthai'] = 0x0E54;
  15456. t['fourthtonechinese'] = 0x02CB;
  15457. t['fparen'] = 0x24A1;
  15458. t['fraction'] = 0x2044;
  15459. t['franc'] = 0x20A3;
  15460. t['g'] = 0x0067;
  15461. t['gabengali'] = 0x0997;
  15462. t['gacute'] = 0x01F5;
  15463. t['gadeva'] = 0x0917;
  15464. t['gafarabic'] = 0x06AF;
  15465. t['gaffinalarabic'] = 0xFB93;
  15466. t['gafinitialarabic'] = 0xFB94;
  15467. t['gafmedialarabic'] = 0xFB95;
  15468. t['gagujarati'] = 0x0A97;
  15469. t['gagurmukhi'] = 0x0A17;
  15470. t['gahiragana'] = 0x304C;
  15471. t['gakatakana'] = 0x30AC;
  15472. t['gamma'] = 0x03B3;
  15473. t['gammalatinsmall'] = 0x0263;
  15474. t['gammasuperior'] = 0x02E0;
  15475. t['gangiacoptic'] = 0x03EB;
  15476. t['gbopomofo'] = 0x310D;
  15477. t['gbreve'] = 0x011F;
  15478. t['gcaron'] = 0x01E7;
  15479. t['gcedilla'] = 0x0123;
  15480. t['gcircle'] = 0x24D6;
  15481. t['gcircumflex'] = 0x011D;
  15482. t['gcommaaccent'] = 0x0123;
  15483. t['gdot'] = 0x0121;
  15484. t['gdotaccent'] = 0x0121;
  15485. t['gecyrillic'] = 0x0433;
  15486. t['gehiragana'] = 0x3052;
  15487. t['gekatakana'] = 0x30B2;
  15488. t['geometricallyequal'] = 0x2251;
  15489. t['gereshaccenthebrew'] = 0x059C;
  15490. t['gereshhebrew'] = 0x05F3;
  15491. t['gereshmuqdamhebrew'] = 0x059D;
  15492. t['germandbls'] = 0x00DF;
  15493. t['gershayimaccenthebrew'] = 0x059E;
  15494. t['gershayimhebrew'] = 0x05F4;
  15495. t['getamark'] = 0x3013;
  15496. t['ghabengali'] = 0x0998;
  15497. t['ghadarmenian'] = 0x0572;
  15498. t['ghadeva'] = 0x0918;
  15499. t['ghagujarati'] = 0x0A98;
  15500. t['ghagurmukhi'] = 0x0A18;
  15501. t['ghainarabic'] = 0x063A;
  15502. t['ghainfinalarabic'] = 0xFECE;
  15503. t['ghaininitialarabic'] = 0xFECF;
  15504. t['ghainmedialarabic'] = 0xFED0;
  15505. t['ghemiddlehookcyrillic'] = 0x0495;
  15506. t['ghestrokecyrillic'] = 0x0493;
  15507. t['gheupturncyrillic'] = 0x0491;
  15508. t['ghhadeva'] = 0x095A;
  15509. t['ghhagurmukhi'] = 0x0A5A;
  15510. t['ghook'] = 0x0260;
  15511. t['ghzsquare'] = 0x3393;
  15512. t['gihiragana'] = 0x304E;
  15513. t['gikatakana'] = 0x30AE;
  15514. t['gimarmenian'] = 0x0563;
  15515. t['gimel'] = 0x05D2;
  15516. t['gimeldagesh'] = 0xFB32;
  15517. t['gimeldageshhebrew'] = 0xFB32;
  15518. t['gimelhebrew'] = 0x05D2;
  15519. t['gjecyrillic'] = 0x0453;
  15520. t['glottalinvertedstroke'] = 0x01BE;
  15521. t['glottalstop'] = 0x0294;
  15522. t['glottalstopinverted'] = 0x0296;
  15523. t['glottalstopmod'] = 0x02C0;
  15524. t['glottalstopreversed'] = 0x0295;
  15525. t['glottalstopreversedmod'] = 0x02C1;
  15526. t['glottalstopreversedsuperior'] = 0x02E4;
  15527. t['glottalstopstroke'] = 0x02A1;
  15528. t['glottalstopstrokereversed'] = 0x02A2;
  15529. t['gmacron'] = 0x1E21;
  15530. t['gmonospace'] = 0xFF47;
  15531. t['gohiragana'] = 0x3054;
  15532. t['gokatakana'] = 0x30B4;
  15533. t['gparen'] = 0x24A2;
  15534. t['gpasquare'] = 0x33AC;
  15535. t['gradient'] = 0x2207;
  15536. t['grave'] = 0x0060;
  15537. t['gravebelowcmb'] = 0x0316;
  15538. t['gravecmb'] = 0x0300;
  15539. t['gravecomb'] = 0x0300;
  15540. t['gravedeva'] = 0x0953;
  15541. t['gravelowmod'] = 0x02CE;
  15542. t['gravemonospace'] = 0xFF40;
  15543. t['gravetonecmb'] = 0x0340;
  15544. t['greater'] = 0x003E;
  15545. t['greaterequal'] = 0x2265;
  15546. t['greaterequalorless'] = 0x22DB;
  15547. t['greatermonospace'] = 0xFF1E;
  15548. t['greaterorequivalent'] = 0x2273;
  15549. t['greaterorless'] = 0x2277;
  15550. t['greateroverequal'] = 0x2267;
  15551. t['greatersmall'] = 0xFE65;
  15552. t['gscript'] = 0x0261;
  15553. t['gstroke'] = 0x01E5;
  15554. t['guhiragana'] = 0x3050;
  15555. t['guillemotleft'] = 0x00AB;
  15556. t['guillemotright'] = 0x00BB;
  15557. t['guilsinglleft'] = 0x2039;
  15558. t['guilsinglright'] = 0x203A;
  15559. t['gukatakana'] = 0x30B0;
  15560. t['guramusquare'] = 0x3318;
  15561. t['gysquare'] = 0x33C9;
  15562. t['h'] = 0x0068;
  15563. t['haabkhasiancyrillic'] = 0x04A9;
  15564. t['haaltonearabic'] = 0x06C1;
  15565. t['habengali'] = 0x09B9;
  15566. t['hadescendercyrillic'] = 0x04B3;
  15567. t['hadeva'] = 0x0939;
  15568. t['hagujarati'] = 0x0AB9;
  15569. t['hagurmukhi'] = 0x0A39;
  15570. t['haharabic'] = 0x062D;
  15571. t['hahfinalarabic'] = 0xFEA2;
  15572. t['hahinitialarabic'] = 0xFEA3;
  15573. t['hahiragana'] = 0x306F;
  15574. t['hahmedialarabic'] = 0xFEA4;
  15575. t['haitusquare'] = 0x332A;
  15576. t['hakatakana'] = 0x30CF;
  15577. t['hakatakanahalfwidth'] = 0xFF8A;
  15578. t['halantgurmukhi'] = 0x0A4D;
  15579. t['hamzaarabic'] = 0x0621;
  15580. t['hamzalowarabic'] = 0x0621;
  15581. t['hangulfiller'] = 0x3164;
  15582. t['hardsigncyrillic'] = 0x044A;
  15583. t['harpoonleftbarbup'] = 0x21BC;
  15584. t['harpoonrightbarbup'] = 0x21C0;
  15585. t['hasquare'] = 0x33CA;
  15586. t['hatafpatah'] = 0x05B2;
  15587. t['hatafpatah16'] = 0x05B2;
  15588. t['hatafpatah23'] = 0x05B2;
  15589. t['hatafpatah2f'] = 0x05B2;
  15590. t['hatafpatahhebrew'] = 0x05B2;
  15591. t['hatafpatahnarrowhebrew'] = 0x05B2;
  15592. t['hatafpatahquarterhebrew'] = 0x05B2;
  15593. t['hatafpatahwidehebrew'] = 0x05B2;
  15594. t['hatafqamats'] = 0x05B3;
  15595. t['hatafqamats1b'] = 0x05B3;
  15596. t['hatafqamats28'] = 0x05B3;
  15597. t['hatafqamats34'] = 0x05B3;
  15598. t['hatafqamatshebrew'] = 0x05B3;
  15599. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  15600. t['hatafqamatsquarterhebrew'] = 0x05B3;
  15601. t['hatafqamatswidehebrew'] = 0x05B3;
  15602. t['hatafsegol'] = 0x05B1;
  15603. t['hatafsegol17'] = 0x05B1;
  15604. t['hatafsegol24'] = 0x05B1;
  15605. t['hatafsegol30'] = 0x05B1;
  15606. t['hatafsegolhebrew'] = 0x05B1;
  15607. t['hatafsegolnarrowhebrew'] = 0x05B1;
  15608. t['hatafsegolquarterhebrew'] = 0x05B1;
  15609. t['hatafsegolwidehebrew'] = 0x05B1;
  15610. t['hbar'] = 0x0127;
  15611. t['hbopomofo'] = 0x310F;
  15612. t['hbrevebelow'] = 0x1E2B;
  15613. t['hcedilla'] = 0x1E29;
  15614. t['hcircle'] = 0x24D7;
  15615. t['hcircumflex'] = 0x0125;
  15616. t['hdieresis'] = 0x1E27;
  15617. t['hdotaccent'] = 0x1E23;
  15618. t['hdotbelow'] = 0x1E25;
  15619. t['he'] = 0x05D4;
  15620. t['heart'] = 0x2665;
  15621. t['heartsuitblack'] = 0x2665;
  15622. t['heartsuitwhite'] = 0x2661;
  15623. t['hedagesh'] = 0xFB34;
  15624. t['hedageshhebrew'] = 0xFB34;
  15625. t['hehaltonearabic'] = 0x06C1;
  15626. t['heharabic'] = 0x0647;
  15627. t['hehebrew'] = 0x05D4;
  15628. t['hehfinalaltonearabic'] = 0xFBA7;
  15629. t['hehfinalalttwoarabic'] = 0xFEEA;
  15630. t['hehfinalarabic'] = 0xFEEA;
  15631. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  15632. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  15633. t['hehinitialaltonearabic'] = 0xFBA8;
  15634. t['hehinitialarabic'] = 0xFEEB;
  15635. t['hehiragana'] = 0x3078;
  15636. t['hehmedialaltonearabic'] = 0xFBA9;
  15637. t['hehmedialarabic'] = 0xFEEC;
  15638. t['heiseierasquare'] = 0x337B;
  15639. t['hekatakana'] = 0x30D8;
  15640. t['hekatakanahalfwidth'] = 0xFF8D;
  15641. t['hekutaarusquare'] = 0x3336;
  15642. t['henghook'] = 0x0267;
  15643. t['herutusquare'] = 0x3339;
  15644. t['het'] = 0x05D7;
  15645. t['hethebrew'] = 0x05D7;
  15646. t['hhook'] = 0x0266;
  15647. t['hhooksuperior'] = 0x02B1;
  15648. t['hieuhacirclekorean'] = 0x327B;
  15649. t['hieuhaparenkorean'] = 0x321B;
  15650. t['hieuhcirclekorean'] = 0x326D;
  15651. t['hieuhkorean'] = 0x314E;
  15652. t['hieuhparenkorean'] = 0x320D;
  15653. t['hihiragana'] = 0x3072;
  15654. t['hikatakana'] = 0x30D2;
  15655. t['hikatakanahalfwidth'] = 0xFF8B;
  15656. t['hiriq'] = 0x05B4;
  15657. t['hiriq14'] = 0x05B4;
  15658. t['hiriq21'] = 0x05B4;
  15659. t['hiriq2d'] = 0x05B4;
  15660. t['hiriqhebrew'] = 0x05B4;
  15661. t['hiriqnarrowhebrew'] = 0x05B4;
  15662. t['hiriqquarterhebrew'] = 0x05B4;
  15663. t['hiriqwidehebrew'] = 0x05B4;
  15664. t['hlinebelow'] = 0x1E96;
  15665. t['hmonospace'] = 0xFF48;
  15666. t['hoarmenian'] = 0x0570;
  15667. t['hohipthai'] = 0x0E2B;
  15668. t['hohiragana'] = 0x307B;
  15669. t['hokatakana'] = 0x30DB;
  15670. t['hokatakanahalfwidth'] = 0xFF8E;
  15671. t['holam'] = 0x05B9;
  15672. t['holam19'] = 0x05B9;
  15673. t['holam26'] = 0x05B9;
  15674. t['holam32'] = 0x05B9;
  15675. t['holamhebrew'] = 0x05B9;
  15676. t['holamnarrowhebrew'] = 0x05B9;
  15677. t['holamquarterhebrew'] = 0x05B9;
  15678. t['holamwidehebrew'] = 0x05B9;
  15679. t['honokhukthai'] = 0x0E2E;
  15680. t['hookabovecomb'] = 0x0309;
  15681. t['hookcmb'] = 0x0309;
  15682. t['hookpalatalizedbelowcmb'] = 0x0321;
  15683. t['hookretroflexbelowcmb'] = 0x0322;
  15684. t['hoonsquare'] = 0x3342;
  15685. t['horicoptic'] = 0x03E9;
  15686. t['horizontalbar'] = 0x2015;
  15687. t['horncmb'] = 0x031B;
  15688. t['hotsprings'] = 0x2668;
  15689. t['house'] = 0x2302;
  15690. t['hparen'] = 0x24A3;
  15691. t['hsuperior'] = 0x02B0;
  15692. t['hturned'] = 0x0265;
  15693. t['huhiragana'] = 0x3075;
  15694. t['huiitosquare'] = 0x3333;
  15695. t['hukatakana'] = 0x30D5;
  15696. t['hukatakanahalfwidth'] = 0xFF8C;
  15697. t['hungarumlaut'] = 0x02DD;
  15698. t['hungarumlautcmb'] = 0x030B;
  15699. t['hv'] = 0x0195;
  15700. t['hyphen'] = 0x002D;
  15701. t['hypheninferior'] = 0xF6E5;
  15702. t['hyphenmonospace'] = 0xFF0D;
  15703. t['hyphensmall'] = 0xFE63;
  15704. t['hyphensuperior'] = 0xF6E6;
  15705. t['hyphentwo'] = 0x2010;
  15706. t['i'] = 0x0069;
  15707. t['iacute'] = 0x00ED;
  15708. t['iacyrillic'] = 0x044F;
  15709. t['ibengali'] = 0x0987;
  15710. t['ibopomofo'] = 0x3127;
  15711. t['ibreve'] = 0x012D;
  15712. t['icaron'] = 0x01D0;
  15713. t['icircle'] = 0x24D8;
  15714. t['icircumflex'] = 0x00EE;
  15715. t['icyrillic'] = 0x0456;
  15716. t['idblgrave'] = 0x0209;
  15717. t['ideographearthcircle'] = 0x328F;
  15718. t['ideographfirecircle'] = 0x328B;
  15719. t['ideographicallianceparen'] = 0x323F;
  15720. t['ideographiccallparen'] = 0x323A;
  15721. t['ideographiccentrecircle'] = 0x32A5;
  15722. t['ideographicclose'] = 0x3006;
  15723. t['ideographiccomma'] = 0x3001;
  15724. t['ideographiccommaleft'] = 0xFF64;
  15725. t['ideographiccongratulationparen'] = 0x3237;
  15726. t['ideographiccorrectcircle'] = 0x32A3;
  15727. t['ideographicearthparen'] = 0x322F;
  15728. t['ideographicenterpriseparen'] = 0x323D;
  15729. t['ideographicexcellentcircle'] = 0x329D;
  15730. t['ideographicfestivalparen'] = 0x3240;
  15731. t['ideographicfinancialcircle'] = 0x3296;
  15732. t['ideographicfinancialparen'] = 0x3236;
  15733. t['ideographicfireparen'] = 0x322B;
  15734. t['ideographichaveparen'] = 0x3232;
  15735. t['ideographichighcircle'] = 0x32A4;
  15736. t['ideographiciterationmark'] = 0x3005;
  15737. t['ideographiclaborcircle'] = 0x3298;
  15738. t['ideographiclaborparen'] = 0x3238;
  15739. t['ideographicleftcircle'] = 0x32A7;
  15740. t['ideographiclowcircle'] = 0x32A6;
  15741. t['ideographicmedicinecircle'] = 0x32A9;
  15742. t['ideographicmetalparen'] = 0x322E;
  15743. t['ideographicmoonparen'] = 0x322A;
  15744. t['ideographicnameparen'] = 0x3234;
  15745. t['ideographicperiod'] = 0x3002;
  15746. t['ideographicprintcircle'] = 0x329E;
  15747. t['ideographicreachparen'] = 0x3243;
  15748. t['ideographicrepresentparen'] = 0x3239;
  15749. t['ideographicresourceparen'] = 0x323E;
  15750. t['ideographicrightcircle'] = 0x32A8;
  15751. t['ideographicsecretcircle'] = 0x3299;
  15752. t['ideographicselfparen'] = 0x3242;
  15753. t['ideographicsocietyparen'] = 0x3233;
  15754. t['ideographicspace'] = 0x3000;
  15755. t['ideographicspecialparen'] = 0x3235;
  15756. t['ideographicstockparen'] = 0x3231;
  15757. t['ideographicstudyparen'] = 0x323B;
  15758. t['ideographicsunparen'] = 0x3230;
  15759. t['ideographicsuperviseparen'] = 0x323C;
  15760. t['ideographicwaterparen'] = 0x322C;
  15761. t['ideographicwoodparen'] = 0x322D;
  15762. t['ideographiczero'] = 0x3007;
  15763. t['ideographmetalcircle'] = 0x328E;
  15764. t['ideographmooncircle'] = 0x328A;
  15765. t['ideographnamecircle'] = 0x3294;
  15766. t['ideographsuncircle'] = 0x3290;
  15767. t['ideographwatercircle'] = 0x328C;
  15768. t['ideographwoodcircle'] = 0x328D;
  15769. t['ideva'] = 0x0907;
  15770. t['idieresis'] = 0x00EF;
  15771. t['idieresisacute'] = 0x1E2F;
  15772. t['idieresiscyrillic'] = 0x04E5;
  15773. t['idotbelow'] = 0x1ECB;
  15774. t['iebrevecyrillic'] = 0x04D7;
  15775. t['iecyrillic'] = 0x0435;
  15776. t['ieungacirclekorean'] = 0x3275;
  15777. t['ieungaparenkorean'] = 0x3215;
  15778. t['ieungcirclekorean'] = 0x3267;
  15779. t['ieungkorean'] = 0x3147;
  15780. t['ieungparenkorean'] = 0x3207;
  15781. t['igrave'] = 0x00EC;
  15782. t['igujarati'] = 0x0A87;
  15783. t['igurmukhi'] = 0x0A07;
  15784. t['ihiragana'] = 0x3044;
  15785. t['ihookabove'] = 0x1EC9;
  15786. t['iibengali'] = 0x0988;
  15787. t['iicyrillic'] = 0x0438;
  15788. t['iideva'] = 0x0908;
  15789. t['iigujarati'] = 0x0A88;
  15790. t['iigurmukhi'] = 0x0A08;
  15791. t['iimatragurmukhi'] = 0x0A40;
  15792. t['iinvertedbreve'] = 0x020B;
  15793. t['iishortcyrillic'] = 0x0439;
  15794. t['iivowelsignbengali'] = 0x09C0;
  15795. t['iivowelsigndeva'] = 0x0940;
  15796. t['iivowelsigngujarati'] = 0x0AC0;
  15797. t['ij'] = 0x0133;
  15798. t['ikatakana'] = 0x30A4;
  15799. t['ikatakanahalfwidth'] = 0xFF72;
  15800. t['ikorean'] = 0x3163;
  15801. t['ilde'] = 0x02DC;
  15802. t['iluyhebrew'] = 0x05AC;
  15803. t['imacron'] = 0x012B;
  15804. t['imacroncyrillic'] = 0x04E3;
  15805. t['imageorapproximatelyequal'] = 0x2253;
  15806. t['imatragurmukhi'] = 0x0A3F;
  15807. t['imonospace'] = 0xFF49;
  15808. t['increment'] = 0x2206;
  15809. t['infinity'] = 0x221E;
  15810. t['iniarmenian'] = 0x056B;
  15811. t['integral'] = 0x222B;
  15812. t['integralbottom'] = 0x2321;
  15813. t['integralbt'] = 0x2321;
  15814. t['integralex'] = 0xF8F5;
  15815. t['integraltop'] = 0x2320;
  15816. t['integraltp'] = 0x2320;
  15817. t['intersection'] = 0x2229;
  15818. t['intisquare'] = 0x3305;
  15819. t['invbullet'] = 0x25D8;
  15820. t['invcircle'] = 0x25D9;
  15821. t['invsmileface'] = 0x263B;
  15822. t['iocyrillic'] = 0x0451;
  15823. t['iogonek'] = 0x012F;
  15824. t['iota'] = 0x03B9;
  15825. t['iotadieresis'] = 0x03CA;
  15826. t['iotadieresistonos'] = 0x0390;
  15827. t['iotalatin'] = 0x0269;
  15828. t['iotatonos'] = 0x03AF;
  15829. t['iparen'] = 0x24A4;
  15830. t['irigurmukhi'] = 0x0A72;
  15831. t['ismallhiragana'] = 0x3043;
  15832. t['ismallkatakana'] = 0x30A3;
  15833. t['ismallkatakanahalfwidth'] = 0xFF68;
  15834. t['issharbengali'] = 0x09FA;
  15835. t['istroke'] = 0x0268;
  15836. t['isuperior'] = 0xF6ED;
  15837. t['iterationhiragana'] = 0x309D;
  15838. t['iterationkatakana'] = 0x30FD;
  15839. t['itilde'] = 0x0129;
  15840. t['itildebelow'] = 0x1E2D;
  15841. t['iubopomofo'] = 0x3129;
  15842. t['iucyrillic'] = 0x044E;
  15843. t['ivowelsignbengali'] = 0x09BF;
  15844. t['ivowelsigndeva'] = 0x093F;
  15845. t['ivowelsigngujarati'] = 0x0ABF;
  15846. t['izhitsacyrillic'] = 0x0475;
  15847. t['izhitsadblgravecyrillic'] = 0x0477;
  15848. t['j'] = 0x006A;
  15849. t['jaarmenian'] = 0x0571;
  15850. t['jabengali'] = 0x099C;
  15851. t['jadeva'] = 0x091C;
  15852. t['jagujarati'] = 0x0A9C;
  15853. t['jagurmukhi'] = 0x0A1C;
  15854. t['jbopomofo'] = 0x3110;
  15855. t['jcaron'] = 0x01F0;
  15856. t['jcircle'] = 0x24D9;
  15857. t['jcircumflex'] = 0x0135;
  15858. t['jcrossedtail'] = 0x029D;
  15859. t['jdotlessstroke'] = 0x025F;
  15860. t['jecyrillic'] = 0x0458;
  15861. t['jeemarabic'] = 0x062C;
  15862. t['jeemfinalarabic'] = 0xFE9E;
  15863. t['jeeminitialarabic'] = 0xFE9F;
  15864. t['jeemmedialarabic'] = 0xFEA0;
  15865. t['jeharabic'] = 0x0698;
  15866. t['jehfinalarabic'] = 0xFB8B;
  15867. t['jhabengali'] = 0x099D;
  15868. t['jhadeva'] = 0x091D;
  15869. t['jhagujarati'] = 0x0A9D;
  15870. t['jhagurmukhi'] = 0x0A1D;
  15871. t['jheharmenian'] = 0x057B;
  15872. t['jis'] = 0x3004;
  15873. t['jmonospace'] = 0xFF4A;
  15874. t['jparen'] = 0x24A5;
  15875. t['jsuperior'] = 0x02B2;
  15876. t['k'] = 0x006B;
  15877. t['kabashkircyrillic'] = 0x04A1;
  15878. t['kabengali'] = 0x0995;
  15879. t['kacute'] = 0x1E31;
  15880. t['kacyrillic'] = 0x043A;
  15881. t['kadescendercyrillic'] = 0x049B;
  15882. t['kadeva'] = 0x0915;
  15883. t['kaf'] = 0x05DB;
  15884. t['kafarabic'] = 0x0643;
  15885. t['kafdagesh'] = 0xFB3B;
  15886. t['kafdageshhebrew'] = 0xFB3B;
  15887. t['kaffinalarabic'] = 0xFEDA;
  15888. t['kafhebrew'] = 0x05DB;
  15889. t['kafinitialarabic'] = 0xFEDB;
  15890. t['kafmedialarabic'] = 0xFEDC;
  15891. t['kafrafehebrew'] = 0xFB4D;
  15892. t['kagujarati'] = 0x0A95;
  15893. t['kagurmukhi'] = 0x0A15;
  15894. t['kahiragana'] = 0x304B;
  15895. t['kahookcyrillic'] = 0x04C4;
  15896. t['kakatakana'] = 0x30AB;
  15897. t['kakatakanahalfwidth'] = 0xFF76;
  15898. t['kappa'] = 0x03BA;
  15899. t['kappasymbolgreek'] = 0x03F0;
  15900. t['kapyeounmieumkorean'] = 0x3171;
  15901. t['kapyeounphieuphkorean'] = 0x3184;
  15902. t['kapyeounpieupkorean'] = 0x3178;
  15903. t['kapyeounssangpieupkorean'] = 0x3179;
  15904. t['karoriisquare'] = 0x330D;
  15905. t['kashidaautoarabic'] = 0x0640;
  15906. t['kashidaautonosidebearingarabic'] = 0x0640;
  15907. t['kasmallkatakana'] = 0x30F5;
  15908. t['kasquare'] = 0x3384;
  15909. t['kasraarabic'] = 0x0650;
  15910. t['kasratanarabic'] = 0x064D;
  15911. t['kastrokecyrillic'] = 0x049F;
  15912. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  15913. t['kaverticalstrokecyrillic'] = 0x049D;
  15914. t['kbopomofo'] = 0x310E;
  15915. t['kcalsquare'] = 0x3389;
  15916. t['kcaron'] = 0x01E9;
  15917. t['kcedilla'] = 0x0137;
  15918. t['kcircle'] = 0x24DA;
  15919. t['kcommaaccent'] = 0x0137;
  15920. t['kdotbelow'] = 0x1E33;
  15921. t['keharmenian'] = 0x0584;
  15922. t['kehiragana'] = 0x3051;
  15923. t['kekatakana'] = 0x30B1;
  15924. t['kekatakanahalfwidth'] = 0xFF79;
  15925. t['kenarmenian'] = 0x056F;
  15926. t['kesmallkatakana'] = 0x30F6;
  15927. t['kgreenlandic'] = 0x0138;
  15928. t['khabengali'] = 0x0996;
  15929. t['khacyrillic'] = 0x0445;
  15930. t['khadeva'] = 0x0916;
  15931. t['khagujarati'] = 0x0A96;
  15932. t['khagurmukhi'] = 0x0A16;
  15933. t['khaharabic'] = 0x062E;
  15934. t['khahfinalarabic'] = 0xFEA6;
  15935. t['khahinitialarabic'] = 0xFEA7;
  15936. t['khahmedialarabic'] = 0xFEA8;
  15937. t['kheicoptic'] = 0x03E7;
  15938. t['khhadeva'] = 0x0959;
  15939. t['khhagurmukhi'] = 0x0A59;
  15940. t['khieukhacirclekorean'] = 0x3278;
  15941. t['khieukhaparenkorean'] = 0x3218;
  15942. t['khieukhcirclekorean'] = 0x326A;
  15943. t['khieukhkorean'] = 0x314B;
  15944. t['khieukhparenkorean'] = 0x320A;
  15945. t['khokhaithai'] = 0x0E02;
  15946. t['khokhonthai'] = 0x0E05;
  15947. t['khokhuatthai'] = 0x0E03;
  15948. t['khokhwaithai'] = 0x0E04;
  15949. t['khomutthai'] = 0x0E5B;
  15950. t['khook'] = 0x0199;
  15951. t['khorakhangthai'] = 0x0E06;
  15952. t['khzsquare'] = 0x3391;
  15953. t['kihiragana'] = 0x304D;
  15954. t['kikatakana'] = 0x30AD;
  15955. t['kikatakanahalfwidth'] = 0xFF77;
  15956. t['kiroguramusquare'] = 0x3315;
  15957. t['kiromeetorusquare'] = 0x3316;
  15958. t['kirosquare'] = 0x3314;
  15959. t['kiyeokacirclekorean'] = 0x326E;
  15960. t['kiyeokaparenkorean'] = 0x320E;
  15961. t['kiyeokcirclekorean'] = 0x3260;
  15962. t['kiyeokkorean'] = 0x3131;
  15963. t['kiyeokparenkorean'] = 0x3200;
  15964. t['kiyeoksioskorean'] = 0x3133;
  15965. t['kjecyrillic'] = 0x045C;
  15966. t['klinebelow'] = 0x1E35;
  15967. t['klsquare'] = 0x3398;
  15968. t['kmcubedsquare'] = 0x33A6;
  15969. t['kmonospace'] = 0xFF4B;
  15970. t['kmsquaredsquare'] = 0x33A2;
  15971. t['kohiragana'] = 0x3053;
  15972. t['kohmsquare'] = 0x33C0;
  15973. t['kokaithai'] = 0x0E01;
  15974. t['kokatakana'] = 0x30B3;
  15975. t['kokatakanahalfwidth'] = 0xFF7A;
  15976. t['kooposquare'] = 0x331E;
  15977. t['koppacyrillic'] = 0x0481;
  15978. t['koreanstandardsymbol'] = 0x327F;
  15979. t['koroniscmb'] = 0x0343;
  15980. t['kparen'] = 0x24A6;
  15981. t['kpasquare'] = 0x33AA;
  15982. t['ksicyrillic'] = 0x046F;
  15983. t['ktsquare'] = 0x33CF;
  15984. t['kturned'] = 0x029E;
  15985. t['kuhiragana'] = 0x304F;
  15986. t['kukatakana'] = 0x30AF;
  15987. t['kukatakanahalfwidth'] = 0xFF78;
  15988. t['kvsquare'] = 0x33B8;
  15989. t['kwsquare'] = 0x33BE;
  15990. t['l'] = 0x006C;
  15991. t['labengali'] = 0x09B2;
  15992. t['lacute'] = 0x013A;
  15993. t['ladeva'] = 0x0932;
  15994. t['lagujarati'] = 0x0AB2;
  15995. t['lagurmukhi'] = 0x0A32;
  15996. t['lakkhangyaothai'] = 0x0E45;
  15997. t['lamaleffinalarabic'] = 0xFEFC;
  15998. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  15999. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16000. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16001. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16002. t['lamalefisolatedarabic'] = 0xFEFB;
  16003. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16004. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16005. t['lamarabic'] = 0x0644;
  16006. t['lambda'] = 0x03BB;
  16007. t['lambdastroke'] = 0x019B;
  16008. t['lamed'] = 0x05DC;
  16009. t['lameddagesh'] = 0xFB3C;
  16010. t['lameddageshhebrew'] = 0xFB3C;
  16011. t['lamedhebrew'] = 0x05DC;
  16012. t['lamfinalarabic'] = 0xFEDE;
  16013. t['lamhahinitialarabic'] = 0xFCCA;
  16014. t['laminitialarabic'] = 0xFEDF;
  16015. t['lamjeeminitialarabic'] = 0xFCC9;
  16016. t['lamkhahinitialarabic'] = 0xFCCB;
  16017. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16018. t['lammedialarabic'] = 0xFEE0;
  16019. t['lammeemhahinitialarabic'] = 0xFD88;
  16020. t['lammeeminitialarabic'] = 0xFCCC;
  16021. t['largecircle'] = 0x25EF;
  16022. t['lbar'] = 0x019A;
  16023. t['lbelt'] = 0x026C;
  16024. t['lbopomofo'] = 0x310C;
  16025. t['lcaron'] = 0x013E;
  16026. t['lcedilla'] = 0x013C;
  16027. t['lcircle'] = 0x24DB;
  16028. t['lcircumflexbelow'] = 0x1E3D;
  16029. t['lcommaaccent'] = 0x013C;
  16030. t['ldot'] = 0x0140;
  16031. t['ldotaccent'] = 0x0140;
  16032. t['ldotbelow'] = 0x1E37;
  16033. t['ldotbelowmacron'] = 0x1E39;
  16034. t['leftangleabovecmb'] = 0x031A;
  16035. t['lefttackbelowcmb'] = 0x0318;
  16036. t['less'] = 0x003C;
  16037. t['lessequal'] = 0x2264;
  16038. t['lessequalorgreater'] = 0x22DA;
  16039. t['lessmonospace'] = 0xFF1C;
  16040. t['lessorequivalent'] = 0x2272;
  16041. t['lessorgreater'] = 0x2276;
  16042. t['lessoverequal'] = 0x2266;
  16043. t['lesssmall'] = 0xFE64;
  16044. t['lezh'] = 0x026E;
  16045. t['lfblock'] = 0x258C;
  16046. t['lhookretroflex'] = 0x026D;
  16047. t['lira'] = 0x20A4;
  16048. t['liwnarmenian'] = 0x056C;
  16049. t['lj'] = 0x01C9;
  16050. t['ljecyrillic'] = 0x0459;
  16051. t['ll'] = 0xF6C0;
  16052. t['lladeva'] = 0x0933;
  16053. t['llagujarati'] = 0x0AB3;
  16054. t['llinebelow'] = 0x1E3B;
  16055. t['llladeva'] = 0x0934;
  16056. t['llvocalicbengali'] = 0x09E1;
  16057. t['llvocalicdeva'] = 0x0961;
  16058. t['llvocalicvowelsignbengali'] = 0x09E3;
  16059. t['llvocalicvowelsigndeva'] = 0x0963;
  16060. t['lmiddletilde'] = 0x026B;
  16061. t['lmonospace'] = 0xFF4C;
  16062. t['lmsquare'] = 0x33D0;
  16063. t['lochulathai'] = 0x0E2C;
  16064. t['logicaland'] = 0x2227;
  16065. t['logicalnot'] = 0x00AC;
  16066. t['logicalnotreversed'] = 0x2310;
  16067. t['logicalor'] = 0x2228;
  16068. t['lolingthai'] = 0x0E25;
  16069. t['longs'] = 0x017F;
  16070. t['lowlinecenterline'] = 0xFE4E;
  16071. t['lowlinecmb'] = 0x0332;
  16072. t['lowlinedashed'] = 0xFE4D;
  16073. t['lozenge'] = 0x25CA;
  16074. t['lparen'] = 0x24A7;
  16075. t['lslash'] = 0x0142;
  16076. t['lsquare'] = 0x2113;
  16077. t['lsuperior'] = 0xF6EE;
  16078. t['ltshade'] = 0x2591;
  16079. t['luthai'] = 0x0E26;
  16080. t['lvocalicbengali'] = 0x098C;
  16081. t['lvocalicdeva'] = 0x090C;
  16082. t['lvocalicvowelsignbengali'] = 0x09E2;
  16083. t['lvocalicvowelsigndeva'] = 0x0962;
  16084. t['lxsquare'] = 0x33D3;
  16085. t['m'] = 0x006D;
  16086. t['mabengali'] = 0x09AE;
  16087. t['macron'] = 0x00AF;
  16088. t['macronbelowcmb'] = 0x0331;
  16089. t['macroncmb'] = 0x0304;
  16090. t['macronlowmod'] = 0x02CD;
  16091. t['macronmonospace'] = 0xFFE3;
  16092. t['macute'] = 0x1E3F;
  16093. t['madeva'] = 0x092E;
  16094. t['magujarati'] = 0x0AAE;
  16095. t['magurmukhi'] = 0x0A2E;
  16096. t['mahapakhhebrew'] = 0x05A4;
  16097. t['mahapakhlefthebrew'] = 0x05A4;
  16098. t['mahiragana'] = 0x307E;
  16099. t['maichattawalowleftthai'] = 0xF895;
  16100. t['maichattawalowrightthai'] = 0xF894;
  16101. t['maichattawathai'] = 0x0E4B;
  16102. t['maichattawaupperleftthai'] = 0xF893;
  16103. t['maieklowleftthai'] = 0xF88C;
  16104. t['maieklowrightthai'] = 0xF88B;
  16105. t['maiekthai'] = 0x0E48;
  16106. t['maiekupperleftthai'] = 0xF88A;
  16107. t['maihanakatleftthai'] = 0xF884;
  16108. t['maihanakatthai'] = 0x0E31;
  16109. t['maitaikhuleftthai'] = 0xF889;
  16110. t['maitaikhuthai'] = 0x0E47;
  16111. t['maitholowleftthai'] = 0xF88F;
  16112. t['maitholowrightthai'] = 0xF88E;
  16113. t['maithothai'] = 0x0E49;
  16114. t['maithoupperleftthai'] = 0xF88D;
  16115. t['maitrilowleftthai'] = 0xF892;
  16116. t['maitrilowrightthai'] = 0xF891;
  16117. t['maitrithai'] = 0x0E4A;
  16118. t['maitriupperleftthai'] = 0xF890;
  16119. t['maiyamokthai'] = 0x0E46;
  16120. t['makatakana'] = 0x30DE;
  16121. t['makatakanahalfwidth'] = 0xFF8F;
  16122. t['male'] = 0x2642;
  16123. t['mansyonsquare'] = 0x3347;
  16124. t['maqafhebrew'] = 0x05BE;
  16125. t['mars'] = 0x2642;
  16126. t['masoracirclehebrew'] = 0x05AF;
  16127. t['masquare'] = 0x3383;
  16128. t['mbopomofo'] = 0x3107;
  16129. t['mbsquare'] = 0x33D4;
  16130. t['mcircle'] = 0x24DC;
  16131. t['mcubedsquare'] = 0x33A5;
  16132. t['mdotaccent'] = 0x1E41;
  16133. t['mdotbelow'] = 0x1E43;
  16134. t['meemarabic'] = 0x0645;
  16135. t['meemfinalarabic'] = 0xFEE2;
  16136. t['meeminitialarabic'] = 0xFEE3;
  16137. t['meemmedialarabic'] = 0xFEE4;
  16138. t['meemmeeminitialarabic'] = 0xFCD1;
  16139. t['meemmeemisolatedarabic'] = 0xFC48;
  16140. t['meetorusquare'] = 0x334D;
  16141. t['mehiragana'] = 0x3081;
  16142. t['meizierasquare'] = 0x337E;
  16143. t['mekatakana'] = 0x30E1;
  16144. t['mekatakanahalfwidth'] = 0xFF92;
  16145. t['mem'] = 0x05DE;
  16146. t['memdagesh'] = 0xFB3E;
  16147. t['memdageshhebrew'] = 0xFB3E;
  16148. t['memhebrew'] = 0x05DE;
  16149. t['menarmenian'] = 0x0574;
  16150. t['merkhahebrew'] = 0x05A5;
  16151. t['merkhakefulahebrew'] = 0x05A6;
  16152. t['merkhakefulalefthebrew'] = 0x05A6;
  16153. t['merkhalefthebrew'] = 0x05A5;
  16154. t['mhook'] = 0x0271;
  16155. t['mhzsquare'] = 0x3392;
  16156. t['middledotkatakanahalfwidth'] = 0xFF65;
  16157. t['middot'] = 0x00B7;
  16158. t['mieumacirclekorean'] = 0x3272;
  16159. t['mieumaparenkorean'] = 0x3212;
  16160. t['mieumcirclekorean'] = 0x3264;
  16161. t['mieumkorean'] = 0x3141;
  16162. t['mieumpansioskorean'] = 0x3170;
  16163. t['mieumparenkorean'] = 0x3204;
  16164. t['mieumpieupkorean'] = 0x316E;
  16165. t['mieumsioskorean'] = 0x316F;
  16166. t['mihiragana'] = 0x307F;
  16167. t['mikatakana'] = 0x30DF;
  16168. t['mikatakanahalfwidth'] = 0xFF90;
  16169. t['minus'] = 0x2212;
  16170. t['minusbelowcmb'] = 0x0320;
  16171. t['minuscircle'] = 0x2296;
  16172. t['minusmod'] = 0x02D7;
  16173. t['minusplus'] = 0x2213;
  16174. t['minute'] = 0x2032;
  16175. t['miribaarusquare'] = 0x334A;
  16176. t['mirisquare'] = 0x3349;
  16177. t['mlonglegturned'] = 0x0270;
  16178. t['mlsquare'] = 0x3396;
  16179. t['mmcubedsquare'] = 0x33A3;
  16180. t['mmonospace'] = 0xFF4D;
  16181. t['mmsquaredsquare'] = 0x339F;
  16182. t['mohiragana'] = 0x3082;
  16183. t['mohmsquare'] = 0x33C1;
  16184. t['mokatakana'] = 0x30E2;
  16185. t['mokatakanahalfwidth'] = 0xFF93;
  16186. t['molsquare'] = 0x33D6;
  16187. t['momathai'] = 0x0E21;
  16188. t['moverssquare'] = 0x33A7;
  16189. t['moverssquaredsquare'] = 0x33A8;
  16190. t['mparen'] = 0x24A8;
  16191. t['mpasquare'] = 0x33AB;
  16192. t['mssquare'] = 0x33B3;
  16193. t['msuperior'] = 0xF6EF;
  16194. t['mturned'] = 0x026F;
  16195. t['mu'] = 0x00B5;
  16196. t['mu1'] = 0x00B5;
  16197. t['muasquare'] = 0x3382;
  16198. t['muchgreater'] = 0x226B;
  16199. t['muchless'] = 0x226A;
  16200. t['mufsquare'] = 0x338C;
  16201. t['mugreek'] = 0x03BC;
  16202. t['mugsquare'] = 0x338D;
  16203. t['muhiragana'] = 0x3080;
  16204. t['mukatakana'] = 0x30E0;
  16205. t['mukatakanahalfwidth'] = 0xFF91;
  16206. t['mulsquare'] = 0x3395;
  16207. t['multiply'] = 0x00D7;
  16208. t['mumsquare'] = 0x339B;
  16209. t['munahhebrew'] = 0x05A3;
  16210. t['munahlefthebrew'] = 0x05A3;
  16211. t['musicalnote'] = 0x266A;
  16212. t['musicalnotedbl'] = 0x266B;
  16213. t['musicflatsign'] = 0x266D;
  16214. t['musicsharpsign'] = 0x266F;
  16215. t['mussquare'] = 0x33B2;
  16216. t['muvsquare'] = 0x33B6;
  16217. t['muwsquare'] = 0x33BC;
  16218. t['mvmegasquare'] = 0x33B9;
  16219. t['mvsquare'] = 0x33B7;
  16220. t['mwmegasquare'] = 0x33BF;
  16221. t['mwsquare'] = 0x33BD;
  16222. t['n'] = 0x006E;
  16223. t['nabengali'] = 0x09A8;
  16224. t['nabla'] = 0x2207;
  16225. t['nacute'] = 0x0144;
  16226. t['nadeva'] = 0x0928;
  16227. t['nagujarati'] = 0x0AA8;
  16228. t['nagurmukhi'] = 0x0A28;
  16229. t['nahiragana'] = 0x306A;
  16230. t['nakatakana'] = 0x30CA;
  16231. t['nakatakanahalfwidth'] = 0xFF85;
  16232. t['napostrophe'] = 0x0149;
  16233. t['nasquare'] = 0x3381;
  16234. t['nbopomofo'] = 0x310B;
  16235. t['nbspace'] = 0x00A0;
  16236. t['ncaron'] = 0x0148;
  16237. t['ncedilla'] = 0x0146;
  16238. t['ncircle'] = 0x24DD;
  16239. t['ncircumflexbelow'] = 0x1E4B;
  16240. t['ncommaaccent'] = 0x0146;
  16241. t['ndotaccent'] = 0x1E45;
  16242. t['ndotbelow'] = 0x1E47;
  16243. t['nehiragana'] = 0x306D;
  16244. t['nekatakana'] = 0x30CD;
  16245. t['nekatakanahalfwidth'] = 0xFF88;
  16246. t['newsheqelsign'] = 0x20AA;
  16247. t['nfsquare'] = 0x338B;
  16248. t['ngabengali'] = 0x0999;
  16249. t['ngadeva'] = 0x0919;
  16250. t['ngagujarati'] = 0x0A99;
  16251. t['ngagurmukhi'] = 0x0A19;
  16252. t['ngonguthai'] = 0x0E07;
  16253. t['nhiragana'] = 0x3093;
  16254. t['nhookleft'] = 0x0272;
  16255. t['nhookretroflex'] = 0x0273;
  16256. t['nieunacirclekorean'] = 0x326F;
  16257. t['nieunaparenkorean'] = 0x320F;
  16258. t['nieuncieuckorean'] = 0x3135;
  16259. t['nieuncirclekorean'] = 0x3261;
  16260. t['nieunhieuhkorean'] = 0x3136;
  16261. t['nieunkorean'] = 0x3134;
  16262. t['nieunpansioskorean'] = 0x3168;
  16263. t['nieunparenkorean'] = 0x3201;
  16264. t['nieunsioskorean'] = 0x3167;
  16265. t['nieuntikeutkorean'] = 0x3166;
  16266. t['nihiragana'] = 0x306B;
  16267. t['nikatakana'] = 0x30CB;
  16268. t['nikatakanahalfwidth'] = 0xFF86;
  16269. t['nikhahitleftthai'] = 0xF899;
  16270. t['nikhahitthai'] = 0x0E4D;
  16271. t['nine'] = 0x0039;
  16272. t['ninearabic'] = 0x0669;
  16273. t['ninebengali'] = 0x09EF;
  16274. t['ninecircle'] = 0x2468;
  16275. t['ninecircleinversesansserif'] = 0x2792;
  16276. t['ninedeva'] = 0x096F;
  16277. t['ninegujarati'] = 0x0AEF;
  16278. t['ninegurmukhi'] = 0x0A6F;
  16279. t['ninehackarabic'] = 0x0669;
  16280. t['ninehangzhou'] = 0x3029;
  16281. t['nineideographicparen'] = 0x3228;
  16282. t['nineinferior'] = 0x2089;
  16283. t['ninemonospace'] = 0xFF19;
  16284. t['nineoldstyle'] = 0xF739;
  16285. t['nineparen'] = 0x247C;
  16286. t['nineperiod'] = 0x2490;
  16287. t['ninepersian'] = 0x06F9;
  16288. t['nineroman'] = 0x2178;
  16289. t['ninesuperior'] = 0x2079;
  16290. t['nineteencircle'] = 0x2472;
  16291. t['nineteenparen'] = 0x2486;
  16292. t['nineteenperiod'] = 0x249A;
  16293. t['ninethai'] = 0x0E59;
  16294. t['nj'] = 0x01CC;
  16295. t['njecyrillic'] = 0x045A;
  16296. t['nkatakana'] = 0x30F3;
  16297. t['nkatakanahalfwidth'] = 0xFF9D;
  16298. t['nlegrightlong'] = 0x019E;
  16299. t['nlinebelow'] = 0x1E49;
  16300. t['nmonospace'] = 0xFF4E;
  16301. t['nmsquare'] = 0x339A;
  16302. t['nnabengali'] = 0x09A3;
  16303. t['nnadeva'] = 0x0923;
  16304. t['nnagujarati'] = 0x0AA3;
  16305. t['nnagurmukhi'] = 0x0A23;
  16306. t['nnnadeva'] = 0x0929;
  16307. t['nohiragana'] = 0x306E;
  16308. t['nokatakana'] = 0x30CE;
  16309. t['nokatakanahalfwidth'] = 0xFF89;
  16310. t['nonbreakingspace'] = 0x00A0;
  16311. t['nonenthai'] = 0x0E13;
  16312. t['nonuthai'] = 0x0E19;
  16313. t['noonarabic'] = 0x0646;
  16314. t['noonfinalarabic'] = 0xFEE6;
  16315. t['noonghunnaarabic'] = 0x06BA;
  16316. t['noonghunnafinalarabic'] = 0xFB9F;
  16317. t['nooninitialarabic'] = 0xFEE7;
  16318. t['noonjeeminitialarabic'] = 0xFCD2;
  16319. t['noonjeemisolatedarabic'] = 0xFC4B;
  16320. t['noonmedialarabic'] = 0xFEE8;
  16321. t['noonmeeminitialarabic'] = 0xFCD5;
  16322. t['noonmeemisolatedarabic'] = 0xFC4E;
  16323. t['noonnoonfinalarabic'] = 0xFC8D;
  16324. t['notcontains'] = 0x220C;
  16325. t['notelement'] = 0x2209;
  16326. t['notelementof'] = 0x2209;
  16327. t['notequal'] = 0x2260;
  16328. t['notgreater'] = 0x226F;
  16329. t['notgreaternorequal'] = 0x2271;
  16330. t['notgreaternorless'] = 0x2279;
  16331. t['notidentical'] = 0x2262;
  16332. t['notless'] = 0x226E;
  16333. t['notlessnorequal'] = 0x2270;
  16334. t['notparallel'] = 0x2226;
  16335. t['notprecedes'] = 0x2280;
  16336. t['notsubset'] = 0x2284;
  16337. t['notsucceeds'] = 0x2281;
  16338. t['notsuperset'] = 0x2285;
  16339. t['nowarmenian'] = 0x0576;
  16340. t['nparen'] = 0x24A9;
  16341. t['nssquare'] = 0x33B1;
  16342. t['nsuperior'] = 0x207F;
  16343. t['ntilde'] = 0x00F1;
  16344. t['nu'] = 0x03BD;
  16345. t['nuhiragana'] = 0x306C;
  16346. t['nukatakana'] = 0x30CC;
  16347. t['nukatakanahalfwidth'] = 0xFF87;
  16348. t['nuktabengali'] = 0x09BC;
  16349. t['nuktadeva'] = 0x093C;
  16350. t['nuktagujarati'] = 0x0ABC;
  16351. t['nuktagurmukhi'] = 0x0A3C;
  16352. t['numbersign'] = 0x0023;
  16353. t['numbersignmonospace'] = 0xFF03;
  16354. t['numbersignsmall'] = 0xFE5F;
  16355. t['numeralsigngreek'] = 0x0374;
  16356. t['numeralsignlowergreek'] = 0x0375;
  16357. t['numero'] = 0x2116;
  16358. t['nun'] = 0x05E0;
  16359. t['nundagesh'] = 0xFB40;
  16360. t['nundageshhebrew'] = 0xFB40;
  16361. t['nunhebrew'] = 0x05E0;
  16362. t['nvsquare'] = 0x33B5;
  16363. t['nwsquare'] = 0x33BB;
  16364. t['nyabengali'] = 0x099E;
  16365. t['nyadeva'] = 0x091E;
  16366. t['nyagujarati'] = 0x0A9E;
  16367. t['nyagurmukhi'] = 0x0A1E;
  16368. t['o'] = 0x006F;
  16369. t['oacute'] = 0x00F3;
  16370. t['oangthai'] = 0x0E2D;
  16371. t['obarred'] = 0x0275;
  16372. t['obarredcyrillic'] = 0x04E9;
  16373. t['obarreddieresiscyrillic'] = 0x04EB;
  16374. t['obengali'] = 0x0993;
  16375. t['obopomofo'] = 0x311B;
  16376. t['obreve'] = 0x014F;
  16377. t['ocandradeva'] = 0x0911;
  16378. t['ocandragujarati'] = 0x0A91;
  16379. t['ocandravowelsigndeva'] = 0x0949;
  16380. t['ocandravowelsigngujarati'] = 0x0AC9;
  16381. t['ocaron'] = 0x01D2;
  16382. t['ocircle'] = 0x24DE;
  16383. t['ocircumflex'] = 0x00F4;
  16384. t['ocircumflexacute'] = 0x1ED1;
  16385. t['ocircumflexdotbelow'] = 0x1ED9;
  16386. t['ocircumflexgrave'] = 0x1ED3;
  16387. t['ocircumflexhookabove'] = 0x1ED5;
  16388. t['ocircumflextilde'] = 0x1ED7;
  16389. t['ocyrillic'] = 0x043E;
  16390. t['odblacute'] = 0x0151;
  16391. t['odblgrave'] = 0x020D;
  16392. t['odeva'] = 0x0913;
  16393. t['odieresis'] = 0x00F6;
  16394. t['odieresiscyrillic'] = 0x04E7;
  16395. t['odotbelow'] = 0x1ECD;
  16396. t['oe'] = 0x0153;
  16397. t['oekorean'] = 0x315A;
  16398. t['ogonek'] = 0x02DB;
  16399. t['ogonekcmb'] = 0x0328;
  16400. t['ograve'] = 0x00F2;
  16401. t['ogujarati'] = 0x0A93;
  16402. t['oharmenian'] = 0x0585;
  16403. t['ohiragana'] = 0x304A;
  16404. t['ohookabove'] = 0x1ECF;
  16405. t['ohorn'] = 0x01A1;
  16406. t['ohornacute'] = 0x1EDB;
  16407. t['ohorndotbelow'] = 0x1EE3;
  16408. t['ohorngrave'] = 0x1EDD;
  16409. t['ohornhookabove'] = 0x1EDF;
  16410. t['ohorntilde'] = 0x1EE1;
  16411. t['ohungarumlaut'] = 0x0151;
  16412. t['oi'] = 0x01A3;
  16413. t['oinvertedbreve'] = 0x020F;
  16414. t['okatakana'] = 0x30AA;
  16415. t['okatakanahalfwidth'] = 0xFF75;
  16416. t['okorean'] = 0x3157;
  16417. t['olehebrew'] = 0x05AB;
  16418. t['omacron'] = 0x014D;
  16419. t['omacronacute'] = 0x1E53;
  16420. t['omacrongrave'] = 0x1E51;
  16421. t['omdeva'] = 0x0950;
  16422. t['omega'] = 0x03C9;
  16423. t['omega1'] = 0x03D6;
  16424. t['omegacyrillic'] = 0x0461;
  16425. t['omegalatinclosed'] = 0x0277;
  16426. t['omegaroundcyrillic'] = 0x047B;
  16427. t['omegatitlocyrillic'] = 0x047D;
  16428. t['omegatonos'] = 0x03CE;
  16429. t['omgujarati'] = 0x0AD0;
  16430. t['omicron'] = 0x03BF;
  16431. t['omicrontonos'] = 0x03CC;
  16432. t['omonospace'] = 0xFF4F;
  16433. t['one'] = 0x0031;
  16434. t['onearabic'] = 0x0661;
  16435. t['onebengali'] = 0x09E7;
  16436. t['onecircle'] = 0x2460;
  16437. t['onecircleinversesansserif'] = 0x278A;
  16438. t['onedeva'] = 0x0967;
  16439. t['onedotenleader'] = 0x2024;
  16440. t['oneeighth'] = 0x215B;
  16441. t['onefitted'] = 0xF6DC;
  16442. t['onegujarati'] = 0x0AE7;
  16443. t['onegurmukhi'] = 0x0A67;
  16444. t['onehackarabic'] = 0x0661;
  16445. t['onehalf'] = 0x00BD;
  16446. t['onehangzhou'] = 0x3021;
  16447. t['oneideographicparen'] = 0x3220;
  16448. t['oneinferior'] = 0x2081;
  16449. t['onemonospace'] = 0xFF11;
  16450. t['onenumeratorbengali'] = 0x09F4;
  16451. t['oneoldstyle'] = 0xF731;
  16452. t['oneparen'] = 0x2474;
  16453. t['oneperiod'] = 0x2488;
  16454. t['onepersian'] = 0x06F1;
  16455. t['onequarter'] = 0x00BC;
  16456. t['oneroman'] = 0x2170;
  16457. t['onesuperior'] = 0x00B9;
  16458. t['onethai'] = 0x0E51;
  16459. t['onethird'] = 0x2153;
  16460. t['oogonek'] = 0x01EB;
  16461. t['oogonekmacron'] = 0x01ED;
  16462. t['oogurmukhi'] = 0x0A13;
  16463. t['oomatragurmukhi'] = 0x0A4B;
  16464. t['oopen'] = 0x0254;
  16465. t['oparen'] = 0x24AA;
  16466. t['openbullet'] = 0x25E6;
  16467. t['option'] = 0x2325;
  16468. t['ordfeminine'] = 0x00AA;
  16469. t['ordmasculine'] = 0x00BA;
  16470. t['orthogonal'] = 0x221F;
  16471. t['oshortdeva'] = 0x0912;
  16472. t['oshortvowelsigndeva'] = 0x094A;
  16473. t['oslash'] = 0x00F8;
  16474. t['oslashacute'] = 0x01FF;
  16475. t['osmallhiragana'] = 0x3049;
  16476. t['osmallkatakana'] = 0x30A9;
  16477. t['osmallkatakanahalfwidth'] = 0xFF6B;
  16478. t['ostrokeacute'] = 0x01FF;
  16479. t['osuperior'] = 0xF6F0;
  16480. t['otcyrillic'] = 0x047F;
  16481. t['otilde'] = 0x00F5;
  16482. t['otildeacute'] = 0x1E4D;
  16483. t['otildedieresis'] = 0x1E4F;
  16484. t['oubopomofo'] = 0x3121;
  16485. t['overline'] = 0x203E;
  16486. t['overlinecenterline'] = 0xFE4A;
  16487. t['overlinecmb'] = 0x0305;
  16488. t['overlinedashed'] = 0xFE49;
  16489. t['overlinedblwavy'] = 0xFE4C;
  16490. t['overlinewavy'] = 0xFE4B;
  16491. t['overscore'] = 0x00AF;
  16492. t['ovowelsignbengali'] = 0x09CB;
  16493. t['ovowelsigndeva'] = 0x094B;
  16494. t['ovowelsigngujarati'] = 0x0ACB;
  16495. t['p'] = 0x0070;
  16496. t['paampssquare'] = 0x3380;
  16497. t['paasentosquare'] = 0x332B;
  16498. t['pabengali'] = 0x09AA;
  16499. t['pacute'] = 0x1E55;
  16500. t['padeva'] = 0x092A;
  16501. t['pagedown'] = 0x21DF;
  16502. t['pageup'] = 0x21DE;
  16503. t['pagujarati'] = 0x0AAA;
  16504. t['pagurmukhi'] = 0x0A2A;
  16505. t['pahiragana'] = 0x3071;
  16506. t['paiyannoithai'] = 0x0E2F;
  16507. t['pakatakana'] = 0x30D1;
  16508. t['palatalizationcyrilliccmb'] = 0x0484;
  16509. t['palochkacyrillic'] = 0x04C0;
  16510. t['pansioskorean'] = 0x317F;
  16511. t['paragraph'] = 0x00B6;
  16512. t['parallel'] = 0x2225;
  16513. t['parenleft'] = 0x0028;
  16514. t['parenleftaltonearabic'] = 0xFD3E;
  16515. t['parenleftbt'] = 0xF8ED;
  16516. t['parenleftex'] = 0xF8EC;
  16517. t['parenleftinferior'] = 0x208D;
  16518. t['parenleftmonospace'] = 0xFF08;
  16519. t['parenleftsmall'] = 0xFE59;
  16520. t['parenleftsuperior'] = 0x207D;
  16521. t['parenlefttp'] = 0xF8EB;
  16522. t['parenleftvertical'] = 0xFE35;
  16523. t['parenright'] = 0x0029;
  16524. t['parenrightaltonearabic'] = 0xFD3F;
  16525. t['parenrightbt'] = 0xF8F8;
  16526. t['parenrightex'] = 0xF8F7;
  16527. t['parenrightinferior'] = 0x208E;
  16528. t['parenrightmonospace'] = 0xFF09;
  16529. t['parenrightsmall'] = 0xFE5A;
  16530. t['parenrightsuperior'] = 0x207E;
  16531. t['parenrighttp'] = 0xF8F6;
  16532. t['parenrightvertical'] = 0xFE36;
  16533. t['partialdiff'] = 0x2202;
  16534. t['paseqhebrew'] = 0x05C0;
  16535. t['pashtahebrew'] = 0x0599;
  16536. t['pasquare'] = 0x33A9;
  16537. t['patah'] = 0x05B7;
  16538. t['patah11'] = 0x05B7;
  16539. t['patah1d'] = 0x05B7;
  16540. t['patah2a'] = 0x05B7;
  16541. t['patahhebrew'] = 0x05B7;
  16542. t['patahnarrowhebrew'] = 0x05B7;
  16543. t['patahquarterhebrew'] = 0x05B7;
  16544. t['patahwidehebrew'] = 0x05B7;
  16545. t['pazerhebrew'] = 0x05A1;
  16546. t['pbopomofo'] = 0x3106;
  16547. t['pcircle'] = 0x24DF;
  16548. t['pdotaccent'] = 0x1E57;
  16549. t['pe'] = 0x05E4;
  16550. t['pecyrillic'] = 0x043F;
  16551. t['pedagesh'] = 0xFB44;
  16552. t['pedageshhebrew'] = 0xFB44;
  16553. t['peezisquare'] = 0x333B;
  16554. t['pefinaldageshhebrew'] = 0xFB43;
  16555. t['peharabic'] = 0x067E;
  16556. t['peharmenian'] = 0x057A;
  16557. t['pehebrew'] = 0x05E4;
  16558. t['pehfinalarabic'] = 0xFB57;
  16559. t['pehinitialarabic'] = 0xFB58;
  16560. t['pehiragana'] = 0x307A;
  16561. t['pehmedialarabic'] = 0xFB59;
  16562. t['pekatakana'] = 0x30DA;
  16563. t['pemiddlehookcyrillic'] = 0x04A7;
  16564. t['perafehebrew'] = 0xFB4E;
  16565. t['percent'] = 0x0025;
  16566. t['percentarabic'] = 0x066A;
  16567. t['percentmonospace'] = 0xFF05;
  16568. t['percentsmall'] = 0xFE6A;
  16569. t['period'] = 0x002E;
  16570. t['periodarmenian'] = 0x0589;
  16571. t['periodcentered'] = 0x00B7;
  16572. t['periodhalfwidth'] = 0xFF61;
  16573. t['periodinferior'] = 0xF6E7;
  16574. t['periodmonospace'] = 0xFF0E;
  16575. t['periodsmall'] = 0xFE52;
  16576. t['periodsuperior'] = 0xF6E8;
  16577. t['perispomenigreekcmb'] = 0x0342;
  16578. t['perpendicular'] = 0x22A5;
  16579. t['perthousand'] = 0x2030;
  16580. t['peseta'] = 0x20A7;
  16581. t['pfsquare'] = 0x338A;
  16582. t['phabengali'] = 0x09AB;
  16583. t['phadeva'] = 0x092B;
  16584. t['phagujarati'] = 0x0AAB;
  16585. t['phagurmukhi'] = 0x0A2B;
  16586. t['phi'] = 0x03C6;
  16587. t['phi1'] = 0x03D5;
  16588. t['phieuphacirclekorean'] = 0x327A;
  16589. t['phieuphaparenkorean'] = 0x321A;
  16590. t['phieuphcirclekorean'] = 0x326C;
  16591. t['phieuphkorean'] = 0x314D;
  16592. t['phieuphparenkorean'] = 0x320C;
  16593. t['philatin'] = 0x0278;
  16594. t['phinthuthai'] = 0x0E3A;
  16595. t['phisymbolgreek'] = 0x03D5;
  16596. t['phook'] = 0x01A5;
  16597. t['phophanthai'] = 0x0E1E;
  16598. t['phophungthai'] = 0x0E1C;
  16599. t['phosamphaothai'] = 0x0E20;
  16600. t['pi'] = 0x03C0;
  16601. t['pieupacirclekorean'] = 0x3273;
  16602. t['pieupaparenkorean'] = 0x3213;
  16603. t['pieupcieuckorean'] = 0x3176;
  16604. t['pieupcirclekorean'] = 0x3265;
  16605. t['pieupkiyeokkorean'] = 0x3172;
  16606. t['pieupkorean'] = 0x3142;
  16607. t['pieupparenkorean'] = 0x3205;
  16608. t['pieupsioskiyeokkorean'] = 0x3174;
  16609. t['pieupsioskorean'] = 0x3144;
  16610. t['pieupsiostikeutkorean'] = 0x3175;
  16611. t['pieupthieuthkorean'] = 0x3177;
  16612. t['pieuptikeutkorean'] = 0x3173;
  16613. t['pihiragana'] = 0x3074;
  16614. t['pikatakana'] = 0x30D4;
  16615. t['pisymbolgreek'] = 0x03D6;
  16616. t['piwrarmenian'] = 0x0583;
  16617. t['plus'] = 0x002B;
  16618. t['plusbelowcmb'] = 0x031F;
  16619. t['pluscircle'] = 0x2295;
  16620. t['plusminus'] = 0x00B1;
  16621. t['plusmod'] = 0x02D6;
  16622. t['plusmonospace'] = 0xFF0B;
  16623. t['plussmall'] = 0xFE62;
  16624. t['plussuperior'] = 0x207A;
  16625. t['pmonospace'] = 0xFF50;
  16626. t['pmsquare'] = 0x33D8;
  16627. t['pohiragana'] = 0x307D;
  16628. t['pointingindexdownwhite'] = 0x261F;
  16629. t['pointingindexleftwhite'] = 0x261C;
  16630. t['pointingindexrightwhite'] = 0x261E;
  16631. t['pointingindexupwhite'] = 0x261D;
  16632. t['pokatakana'] = 0x30DD;
  16633. t['poplathai'] = 0x0E1B;
  16634. t['postalmark'] = 0x3012;
  16635. t['postalmarkface'] = 0x3020;
  16636. t['pparen'] = 0x24AB;
  16637. t['precedes'] = 0x227A;
  16638. t['prescription'] = 0x211E;
  16639. t['primemod'] = 0x02B9;
  16640. t['primereversed'] = 0x2035;
  16641. t['product'] = 0x220F;
  16642. t['projective'] = 0x2305;
  16643. t['prolongedkana'] = 0x30FC;
  16644. t['propellor'] = 0x2318;
  16645. t['propersubset'] = 0x2282;
  16646. t['propersuperset'] = 0x2283;
  16647. t['proportion'] = 0x2237;
  16648. t['proportional'] = 0x221D;
  16649. t['psi'] = 0x03C8;
  16650. t['psicyrillic'] = 0x0471;
  16651. t['psilipneumatacyrilliccmb'] = 0x0486;
  16652. t['pssquare'] = 0x33B0;
  16653. t['puhiragana'] = 0x3077;
  16654. t['pukatakana'] = 0x30D7;
  16655. t['pvsquare'] = 0x33B4;
  16656. t['pwsquare'] = 0x33BA;
  16657. t['q'] = 0x0071;
  16658. t['qadeva'] = 0x0958;
  16659. t['qadmahebrew'] = 0x05A8;
  16660. t['qafarabic'] = 0x0642;
  16661. t['qaffinalarabic'] = 0xFED6;
  16662. t['qafinitialarabic'] = 0xFED7;
  16663. t['qafmedialarabic'] = 0xFED8;
  16664. t['qamats'] = 0x05B8;
  16665. t['qamats10'] = 0x05B8;
  16666. t['qamats1a'] = 0x05B8;
  16667. t['qamats1c'] = 0x05B8;
  16668. t['qamats27'] = 0x05B8;
  16669. t['qamats29'] = 0x05B8;
  16670. t['qamats33'] = 0x05B8;
  16671. t['qamatsde'] = 0x05B8;
  16672. t['qamatshebrew'] = 0x05B8;
  16673. t['qamatsnarrowhebrew'] = 0x05B8;
  16674. t['qamatsqatanhebrew'] = 0x05B8;
  16675. t['qamatsqatannarrowhebrew'] = 0x05B8;
  16676. t['qamatsqatanquarterhebrew'] = 0x05B8;
  16677. t['qamatsqatanwidehebrew'] = 0x05B8;
  16678. t['qamatsquarterhebrew'] = 0x05B8;
  16679. t['qamatswidehebrew'] = 0x05B8;
  16680. t['qarneyparahebrew'] = 0x059F;
  16681. t['qbopomofo'] = 0x3111;
  16682. t['qcircle'] = 0x24E0;
  16683. t['qhook'] = 0x02A0;
  16684. t['qmonospace'] = 0xFF51;
  16685. t['qof'] = 0x05E7;
  16686. t['qofdagesh'] = 0xFB47;
  16687. t['qofdageshhebrew'] = 0xFB47;
  16688. t['qofhebrew'] = 0x05E7;
  16689. t['qparen'] = 0x24AC;
  16690. t['quarternote'] = 0x2669;
  16691. t['qubuts'] = 0x05BB;
  16692. t['qubuts18'] = 0x05BB;
  16693. t['qubuts25'] = 0x05BB;
  16694. t['qubuts31'] = 0x05BB;
  16695. t['qubutshebrew'] = 0x05BB;
  16696. t['qubutsnarrowhebrew'] = 0x05BB;
  16697. t['qubutsquarterhebrew'] = 0x05BB;
  16698. t['qubutswidehebrew'] = 0x05BB;
  16699. t['question'] = 0x003F;
  16700. t['questionarabic'] = 0x061F;
  16701. t['questionarmenian'] = 0x055E;
  16702. t['questiondown'] = 0x00BF;
  16703. t['questiondownsmall'] = 0xF7BF;
  16704. t['questiongreek'] = 0x037E;
  16705. t['questionmonospace'] = 0xFF1F;
  16706. t['questionsmall'] = 0xF73F;
  16707. t['quotedbl'] = 0x0022;
  16708. t['quotedblbase'] = 0x201E;
  16709. t['quotedblleft'] = 0x201C;
  16710. t['quotedblmonospace'] = 0xFF02;
  16711. t['quotedblprime'] = 0x301E;
  16712. t['quotedblprimereversed'] = 0x301D;
  16713. t['quotedblright'] = 0x201D;
  16714. t['quoteleft'] = 0x2018;
  16715. t['quoteleftreversed'] = 0x201B;
  16716. t['quotereversed'] = 0x201B;
  16717. t['quoteright'] = 0x2019;
  16718. t['quoterightn'] = 0x0149;
  16719. t['quotesinglbase'] = 0x201A;
  16720. t['quotesingle'] = 0x0027;
  16721. t['quotesinglemonospace'] = 0xFF07;
  16722. t['r'] = 0x0072;
  16723. t['raarmenian'] = 0x057C;
  16724. t['rabengali'] = 0x09B0;
  16725. t['racute'] = 0x0155;
  16726. t['radeva'] = 0x0930;
  16727. t['radical'] = 0x221A;
  16728. t['radicalex'] = 0xF8E5;
  16729. t['radoverssquare'] = 0x33AE;
  16730. t['radoverssquaredsquare'] = 0x33AF;
  16731. t['radsquare'] = 0x33AD;
  16732. t['rafe'] = 0x05BF;
  16733. t['rafehebrew'] = 0x05BF;
  16734. t['ragujarati'] = 0x0AB0;
  16735. t['ragurmukhi'] = 0x0A30;
  16736. t['rahiragana'] = 0x3089;
  16737. t['rakatakana'] = 0x30E9;
  16738. t['rakatakanahalfwidth'] = 0xFF97;
  16739. t['ralowerdiagonalbengali'] = 0x09F1;
  16740. t['ramiddlediagonalbengali'] = 0x09F0;
  16741. t['ramshorn'] = 0x0264;
  16742. t['ratio'] = 0x2236;
  16743. t['rbopomofo'] = 0x3116;
  16744. t['rcaron'] = 0x0159;
  16745. t['rcedilla'] = 0x0157;
  16746. t['rcircle'] = 0x24E1;
  16747. t['rcommaaccent'] = 0x0157;
  16748. t['rdblgrave'] = 0x0211;
  16749. t['rdotaccent'] = 0x1E59;
  16750. t['rdotbelow'] = 0x1E5B;
  16751. t['rdotbelowmacron'] = 0x1E5D;
  16752. t['referencemark'] = 0x203B;
  16753. t['reflexsubset'] = 0x2286;
  16754. t['reflexsuperset'] = 0x2287;
  16755. t['registered'] = 0x00AE;
  16756. t['registersans'] = 0xF8E8;
  16757. t['registerserif'] = 0xF6DA;
  16758. t['reharabic'] = 0x0631;
  16759. t['reharmenian'] = 0x0580;
  16760. t['rehfinalarabic'] = 0xFEAE;
  16761. t['rehiragana'] = 0x308C;
  16762. t['rekatakana'] = 0x30EC;
  16763. t['rekatakanahalfwidth'] = 0xFF9A;
  16764. t['resh'] = 0x05E8;
  16765. t['reshdageshhebrew'] = 0xFB48;
  16766. t['reshhebrew'] = 0x05E8;
  16767. t['reversedtilde'] = 0x223D;
  16768. t['reviahebrew'] = 0x0597;
  16769. t['reviamugrashhebrew'] = 0x0597;
  16770. t['revlogicalnot'] = 0x2310;
  16771. t['rfishhook'] = 0x027E;
  16772. t['rfishhookreversed'] = 0x027F;
  16773. t['rhabengali'] = 0x09DD;
  16774. t['rhadeva'] = 0x095D;
  16775. t['rho'] = 0x03C1;
  16776. t['rhook'] = 0x027D;
  16777. t['rhookturned'] = 0x027B;
  16778. t['rhookturnedsuperior'] = 0x02B5;
  16779. t['rhosymbolgreek'] = 0x03F1;
  16780. t['rhotichookmod'] = 0x02DE;
  16781. t['rieulacirclekorean'] = 0x3271;
  16782. t['rieulaparenkorean'] = 0x3211;
  16783. t['rieulcirclekorean'] = 0x3263;
  16784. t['rieulhieuhkorean'] = 0x3140;
  16785. t['rieulkiyeokkorean'] = 0x313A;
  16786. t['rieulkiyeoksioskorean'] = 0x3169;
  16787. t['rieulkorean'] = 0x3139;
  16788. t['rieulmieumkorean'] = 0x313B;
  16789. t['rieulpansioskorean'] = 0x316C;
  16790. t['rieulparenkorean'] = 0x3203;
  16791. t['rieulphieuphkorean'] = 0x313F;
  16792. t['rieulpieupkorean'] = 0x313C;
  16793. t['rieulpieupsioskorean'] = 0x316B;
  16794. t['rieulsioskorean'] = 0x313D;
  16795. t['rieulthieuthkorean'] = 0x313E;
  16796. t['rieultikeutkorean'] = 0x316A;
  16797. t['rieulyeorinhieuhkorean'] = 0x316D;
  16798. t['rightangle'] = 0x221F;
  16799. t['righttackbelowcmb'] = 0x0319;
  16800. t['righttriangle'] = 0x22BF;
  16801. t['rihiragana'] = 0x308A;
  16802. t['rikatakana'] = 0x30EA;
  16803. t['rikatakanahalfwidth'] = 0xFF98;
  16804. t['ring'] = 0x02DA;
  16805. t['ringbelowcmb'] = 0x0325;
  16806. t['ringcmb'] = 0x030A;
  16807. t['ringhalfleft'] = 0x02BF;
  16808. t['ringhalfleftarmenian'] = 0x0559;
  16809. t['ringhalfleftbelowcmb'] = 0x031C;
  16810. t['ringhalfleftcentered'] = 0x02D3;
  16811. t['ringhalfright'] = 0x02BE;
  16812. t['ringhalfrightbelowcmb'] = 0x0339;
  16813. t['ringhalfrightcentered'] = 0x02D2;
  16814. t['rinvertedbreve'] = 0x0213;
  16815. t['rittorusquare'] = 0x3351;
  16816. t['rlinebelow'] = 0x1E5F;
  16817. t['rlongleg'] = 0x027C;
  16818. t['rlonglegturned'] = 0x027A;
  16819. t['rmonospace'] = 0xFF52;
  16820. t['rohiragana'] = 0x308D;
  16821. t['rokatakana'] = 0x30ED;
  16822. t['rokatakanahalfwidth'] = 0xFF9B;
  16823. t['roruathai'] = 0x0E23;
  16824. t['rparen'] = 0x24AD;
  16825. t['rrabengali'] = 0x09DC;
  16826. t['rradeva'] = 0x0931;
  16827. t['rragurmukhi'] = 0x0A5C;
  16828. t['rreharabic'] = 0x0691;
  16829. t['rrehfinalarabic'] = 0xFB8D;
  16830. t['rrvocalicbengali'] = 0x09E0;
  16831. t['rrvocalicdeva'] = 0x0960;
  16832. t['rrvocalicgujarati'] = 0x0AE0;
  16833. t['rrvocalicvowelsignbengali'] = 0x09C4;
  16834. t['rrvocalicvowelsigndeva'] = 0x0944;
  16835. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  16836. t['rsuperior'] = 0xF6F1;
  16837. t['rtblock'] = 0x2590;
  16838. t['rturned'] = 0x0279;
  16839. t['rturnedsuperior'] = 0x02B4;
  16840. t['ruhiragana'] = 0x308B;
  16841. t['rukatakana'] = 0x30EB;
  16842. t['rukatakanahalfwidth'] = 0xFF99;
  16843. t['rupeemarkbengali'] = 0x09F2;
  16844. t['rupeesignbengali'] = 0x09F3;
  16845. t['rupiah'] = 0xF6DD;
  16846. t['ruthai'] = 0x0E24;
  16847. t['rvocalicbengali'] = 0x098B;
  16848. t['rvocalicdeva'] = 0x090B;
  16849. t['rvocalicgujarati'] = 0x0A8B;
  16850. t['rvocalicvowelsignbengali'] = 0x09C3;
  16851. t['rvocalicvowelsigndeva'] = 0x0943;
  16852. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  16853. t['s'] = 0x0073;
  16854. t['sabengali'] = 0x09B8;
  16855. t['sacute'] = 0x015B;
  16856. t['sacutedotaccent'] = 0x1E65;
  16857. t['sadarabic'] = 0x0635;
  16858. t['sadeva'] = 0x0938;
  16859. t['sadfinalarabic'] = 0xFEBA;
  16860. t['sadinitialarabic'] = 0xFEBB;
  16861. t['sadmedialarabic'] = 0xFEBC;
  16862. t['sagujarati'] = 0x0AB8;
  16863. t['sagurmukhi'] = 0x0A38;
  16864. t['sahiragana'] = 0x3055;
  16865. t['sakatakana'] = 0x30B5;
  16866. t['sakatakanahalfwidth'] = 0xFF7B;
  16867. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  16868. t['samekh'] = 0x05E1;
  16869. t['samekhdagesh'] = 0xFB41;
  16870. t['samekhdageshhebrew'] = 0xFB41;
  16871. t['samekhhebrew'] = 0x05E1;
  16872. t['saraaathai'] = 0x0E32;
  16873. t['saraaethai'] = 0x0E41;
  16874. t['saraaimaimalaithai'] = 0x0E44;
  16875. t['saraaimaimuanthai'] = 0x0E43;
  16876. t['saraamthai'] = 0x0E33;
  16877. t['saraathai'] = 0x0E30;
  16878. t['saraethai'] = 0x0E40;
  16879. t['saraiileftthai'] = 0xF886;
  16880. t['saraiithai'] = 0x0E35;
  16881. t['saraileftthai'] = 0xF885;
  16882. t['saraithai'] = 0x0E34;
  16883. t['saraothai'] = 0x0E42;
  16884. t['saraueeleftthai'] = 0xF888;
  16885. t['saraueethai'] = 0x0E37;
  16886. t['saraueleftthai'] = 0xF887;
  16887. t['sarauethai'] = 0x0E36;
  16888. t['sarauthai'] = 0x0E38;
  16889. t['sarauuthai'] = 0x0E39;
  16890. t['sbopomofo'] = 0x3119;
  16891. t['scaron'] = 0x0161;
  16892. t['scarondotaccent'] = 0x1E67;
  16893. t['scedilla'] = 0x015F;
  16894. t['schwa'] = 0x0259;
  16895. t['schwacyrillic'] = 0x04D9;
  16896. t['schwadieresiscyrillic'] = 0x04DB;
  16897. t['schwahook'] = 0x025A;
  16898. t['scircle'] = 0x24E2;
  16899. t['scircumflex'] = 0x015D;
  16900. t['scommaaccent'] = 0x0219;
  16901. t['sdotaccent'] = 0x1E61;
  16902. t['sdotbelow'] = 0x1E63;
  16903. t['sdotbelowdotaccent'] = 0x1E69;
  16904. t['seagullbelowcmb'] = 0x033C;
  16905. t['second'] = 0x2033;
  16906. t['secondtonechinese'] = 0x02CA;
  16907. t['section'] = 0x00A7;
  16908. t['seenarabic'] = 0x0633;
  16909. t['seenfinalarabic'] = 0xFEB2;
  16910. t['seeninitialarabic'] = 0xFEB3;
  16911. t['seenmedialarabic'] = 0xFEB4;
  16912. t['segol'] = 0x05B6;
  16913. t['segol13'] = 0x05B6;
  16914. t['segol1f'] = 0x05B6;
  16915. t['segol2c'] = 0x05B6;
  16916. t['segolhebrew'] = 0x05B6;
  16917. t['segolnarrowhebrew'] = 0x05B6;
  16918. t['segolquarterhebrew'] = 0x05B6;
  16919. t['segoltahebrew'] = 0x0592;
  16920. t['segolwidehebrew'] = 0x05B6;
  16921. t['seharmenian'] = 0x057D;
  16922. t['sehiragana'] = 0x305B;
  16923. t['sekatakana'] = 0x30BB;
  16924. t['sekatakanahalfwidth'] = 0xFF7E;
  16925. t['semicolon'] = 0x003B;
  16926. t['semicolonarabic'] = 0x061B;
  16927. t['semicolonmonospace'] = 0xFF1B;
  16928. t['semicolonsmall'] = 0xFE54;
  16929. t['semivoicedmarkkana'] = 0x309C;
  16930. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  16931. t['sentisquare'] = 0x3322;
  16932. t['sentosquare'] = 0x3323;
  16933. t['seven'] = 0x0037;
  16934. t['sevenarabic'] = 0x0667;
  16935. t['sevenbengali'] = 0x09ED;
  16936. t['sevencircle'] = 0x2466;
  16937. t['sevencircleinversesansserif'] = 0x2790;
  16938. t['sevendeva'] = 0x096D;
  16939. t['seveneighths'] = 0x215E;
  16940. t['sevengujarati'] = 0x0AED;
  16941. t['sevengurmukhi'] = 0x0A6D;
  16942. t['sevenhackarabic'] = 0x0667;
  16943. t['sevenhangzhou'] = 0x3027;
  16944. t['sevenideographicparen'] = 0x3226;
  16945. t['seveninferior'] = 0x2087;
  16946. t['sevenmonospace'] = 0xFF17;
  16947. t['sevenoldstyle'] = 0xF737;
  16948. t['sevenparen'] = 0x247A;
  16949. t['sevenperiod'] = 0x248E;
  16950. t['sevenpersian'] = 0x06F7;
  16951. t['sevenroman'] = 0x2176;
  16952. t['sevensuperior'] = 0x2077;
  16953. t['seventeencircle'] = 0x2470;
  16954. t['seventeenparen'] = 0x2484;
  16955. t['seventeenperiod'] = 0x2498;
  16956. t['seventhai'] = 0x0E57;
  16957. t['sfthyphen'] = 0x00AD;
  16958. t['shaarmenian'] = 0x0577;
  16959. t['shabengali'] = 0x09B6;
  16960. t['shacyrillic'] = 0x0448;
  16961. t['shaddaarabic'] = 0x0651;
  16962. t['shaddadammaarabic'] = 0xFC61;
  16963. t['shaddadammatanarabic'] = 0xFC5E;
  16964. t['shaddafathaarabic'] = 0xFC60;
  16965. t['shaddakasraarabic'] = 0xFC62;
  16966. t['shaddakasratanarabic'] = 0xFC5F;
  16967. t['shade'] = 0x2592;
  16968. t['shadedark'] = 0x2593;
  16969. t['shadelight'] = 0x2591;
  16970. t['shademedium'] = 0x2592;
  16971. t['shadeva'] = 0x0936;
  16972. t['shagujarati'] = 0x0AB6;
  16973. t['shagurmukhi'] = 0x0A36;
  16974. t['shalshelethebrew'] = 0x0593;
  16975. t['shbopomofo'] = 0x3115;
  16976. t['shchacyrillic'] = 0x0449;
  16977. t['sheenarabic'] = 0x0634;
  16978. t['sheenfinalarabic'] = 0xFEB6;
  16979. t['sheeninitialarabic'] = 0xFEB7;
  16980. t['sheenmedialarabic'] = 0xFEB8;
  16981. t['sheicoptic'] = 0x03E3;
  16982. t['sheqel'] = 0x20AA;
  16983. t['sheqelhebrew'] = 0x20AA;
  16984. t['sheva'] = 0x05B0;
  16985. t['sheva115'] = 0x05B0;
  16986. t['sheva15'] = 0x05B0;
  16987. t['sheva22'] = 0x05B0;
  16988. t['sheva2e'] = 0x05B0;
  16989. t['shevahebrew'] = 0x05B0;
  16990. t['shevanarrowhebrew'] = 0x05B0;
  16991. t['shevaquarterhebrew'] = 0x05B0;
  16992. t['shevawidehebrew'] = 0x05B0;
  16993. t['shhacyrillic'] = 0x04BB;
  16994. t['shimacoptic'] = 0x03ED;
  16995. t['shin'] = 0x05E9;
  16996. t['shindagesh'] = 0xFB49;
  16997. t['shindageshhebrew'] = 0xFB49;
  16998. t['shindageshshindot'] = 0xFB2C;
  16999. t['shindageshshindothebrew'] = 0xFB2C;
  17000. t['shindageshsindot'] = 0xFB2D;
  17001. t['shindageshsindothebrew'] = 0xFB2D;
  17002. t['shindothebrew'] = 0x05C1;
  17003. t['shinhebrew'] = 0x05E9;
  17004. t['shinshindot'] = 0xFB2A;
  17005. t['shinshindothebrew'] = 0xFB2A;
  17006. t['shinsindot'] = 0xFB2B;
  17007. t['shinsindothebrew'] = 0xFB2B;
  17008. t['shook'] = 0x0282;
  17009. t['sigma'] = 0x03C3;
  17010. t['sigma1'] = 0x03C2;
  17011. t['sigmafinal'] = 0x03C2;
  17012. t['sigmalunatesymbolgreek'] = 0x03F2;
  17013. t['sihiragana'] = 0x3057;
  17014. t['sikatakana'] = 0x30B7;
  17015. t['sikatakanahalfwidth'] = 0xFF7C;
  17016. t['siluqhebrew'] = 0x05BD;
  17017. t['siluqlefthebrew'] = 0x05BD;
  17018. t['similar'] = 0x223C;
  17019. t['sindothebrew'] = 0x05C2;
  17020. t['siosacirclekorean'] = 0x3274;
  17021. t['siosaparenkorean'] = 0x3214;
  17022. t['sioscieuckorean'] = 0x317E;
  17023. t['sioscirclekorean'] = 0x3266;
  17024. t['sioskiyeokkorean'] = 0x317A;
  17025. t['sioskorean'] = 0x3145;
  17026. t['siosnieunkorean'] = 0x317B;
  17027. t['siosparenkorean'] = 0x3206;
  17028. t['siospieupkorean'] = 0x317D;
  17029. t['siostikeutkorean'] = 0x317C;
  17030. t['six'] = 0x0036;
  17031. t['sixarabic'] = 0x0666;
  17032. t['sixbengali'] = 0x09EC;
  17033. t['sixcircle'] = 0x2465;
  17034. t['sixcircleinversesansserif'] = 0x278F;
  17035. t['sixdeva'] = 0x096C;
  17036. t['sixgujarati'] = 0x0AEC;
  17037. t['sixgurmukhi'] = 0x0A6C;
  17038. t['sixhackarabic'] = 0x0666;
  17039. t['sixhangzhou'] = 0x3026;
  17040. t['sixideographicparen'] = 0x3225;
  17041. t['sixinferior'] = 0x2086;
  17042. t['sixmonospace'] = 0xFF16;
  17043. t['sixoldstyle'] = 0xF736;
  17044. t['sixparen'] = 0x2479;
  17045. t['sixperiod'] = 0x248D;
  17046. t['sixpersian'] = 0x06F6;
  17047. t['sixroman'] = 0x2175;
  17048. t['sixsuperior'] = 0x2076;
  17049. t['sixteencircle'] = 0x246F;
  17050. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17051. t['sixteenparen'] = 0x2483;
  17052. t['sixteenperiod'] = 0x2497;
  17053. t['sixthai'] = 0x0E56;
  17054. t['slash'] = 0x002F;
  17055. t['slashmonospace'] = 0xFF0F;
  17056. t['slong'] = 0x017F;
  17057. t['slongdotaccent'] = 0x1E9B;
  17058. t['smileface'] = 0x263A;
  17059. t['smonospace'] = 0xFF53;
  17060. t['sofpasuqhebrew'] = 0x05C3;
  17061. t['softhyphen'] = 0x00AD;
  17062. t['softsigncyrillic'] = 0x044C;
  17063. t['sohiragana'] = 0x305D;
  17064. t['sokatakana'] = 0x30BD;
  17065. t['sokatakanahalfwidth'] = 0xFF7F;
  17066. t['soliduslongoverlaycmb'] = 0x0338;
  17067. t['solidusshortoverlaycmb'] = 0x0337;
  17068. t['sorusithai'] = 0x0E29;
  17069. t['sosalathai'] = 0x0E28;
  17070. t['sosothai'] = 0x0E0B;
  17071. t['sosuathai'] = 0x0E2A;
  17072. t['space'] = 0x0020;
  17073. t['spacehackarabic'] = 0x0020;
  17074. t['spade'] = 0x2660;
  17075. t['spadesuitblack'] = 0x2660;
  17076. t['spadesuitwhite'] = 0x2664;
  17077. t['sparen'] = 0x24AE;
  17078. t['squarebelowcmb'] = 0x033B;
  17079. t['squarecc'] = 0x33C4;
  17080. t['squarecm'] = 0x339D;
  17081. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17082. t['squarehorizontalfill'] = 0x25A4;
  17083. t['squarekg'] = 0x338F;
  17084. t['squarekm'] = 0x339E;
  17085. t['squarekmcapital'] = 0x33CE;
  17086. t['squareln'] = 0x33D1;
  17087. t['squarelog'] = 0x33D2;
  17088. t['squaremg'] = 0x338E;
  17089. t['squaremil'] = 0x33D5;
  17090. t['squaremm'] = 0x339C;
  17091. t['squaremsquared'] = 0x33A1;
  17092. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17093. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17094. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17095. t['squareverticalfill'] = 0x25A5;
  17096. t['squarewhitewithsmallblack'] = 0x25A3;
  17097. t['srsquare'] = 0x33DB;
  17098. t['ssabengali'] = 0x09B7;
  17099. t['ssadeva'] = 0x0937;
  17100. t['ssagujarati'] = 0x0AB7;
  17101. t['ssangcieuckorean'] = 0x3149;
  17102. t['ssanghieuhkorean'] = 0x3185;
  17103. t['ssangieungkorean'] = 0x3180;
  17104. t['ssangkiyeokkorean'] = 0x3132;
  17105. t['ssangnieunkorean'] = 0x3165;
  17106. t['ssangpieupkorean'] = 0x3143;
  17107. t['ssangsioskorean'] = 0x3146;
  17108. t['ssangtikeutkorean'] = 0x3138;
  17109. t['ssuperior'] = 0xF6F2;
  17110. t['sterling'] = 0x00A3;
  17111. t['sterlingmonospace'] = 0xFFE1;
  17112. t['strokelongoverlaycmb'] = 0x0336;
  17113. t['strokeshortoverlaycmb'] = 0x0335;
  17114. t['subset'] = 0x2282;
  17115. t['subsetnotequal'] = 0x228A;
  17116. t['subsetorequal'] = 0x2286;
  17117. t['succeeds'] = 0x227B;
  17118. t['suchthat'] = 0x220B;
  17119. t['suhiragana'] = 0x3059;
  17120. t['sukatakana'] = 0x30B9;
  17121. t['sukatakanahalfwidth'] = 0xFF7D;
  17122. t['sukunarabic'] = 0x0652;
  17123. t['summation'] = 0x2211;
  17124. t['sun'] = 0x263C;
  17125. t['superset'] = 0x2283;
  17126. t['supersetnotequal'] = 0x228B;
  17127. t['supersetorequal'] = 0x2287;
  17128. t['svsquare'] = 0x33DC;
  17129. t['syouwaerasquare'] = 0x337C;
  17130. t['t'] = 0x0074;
  17131. t['tabengali'] = 0x09A4;
  17132. t['tackdown'] = 0x22A4;
  17133. t['tackleft'] = 0x22A3;
  17134. t['tadeva'] = 0x0924;
  17135. t['tagujarati'] = 0x0AA4;
  17136. t['tagurmukhi'] = 0x0A24;
  17137. t['taharabic'] = 0x0637;
  17138. t['tahfinalarabic'] = 0xFEC2;
  17139. t['tahinitialarabic'] = 0xFEC3;
  17140. t['tahiragana'] = 0x305F;
  17141. t['tahmedialarabic'] = 0xFEC4;
  17142. t['taisyouerasquare'] = 0x337D;
  17143. t['takatakana'] = 0x30BF;
  17144. t['takatakanahalfwidth'] = 0xFF80;
  17145. t['tatweelarabic'] = 0x0640;
  17146. t['tau'] = 0x03C4;
  17147. t['tav'] = 0x05EA;
  17148. t['tavdages'] = 0xFB4A;
  17149. t['tavdagesh'] = 0xFB4A;
  17150. t['tavdageshhebrew'] = 0xFB4A;
  17151. t['tavhebrew'] = 0x05EA;
  17152. t['tbar'] = 0x0167;
  17153. t['tbopomofo'] = 0x310A;
  17154. t['tcaron'] = 0x0165;
  17155. t['tccurl'] = 0x02A8;
  17156. t['tcedilla'] = 0x0163;
  17157. t['tcheharabic'] = 0x0686;
  17158. t['tchehfinalarabic'] = 0xFB7B;
  17159. t['tchehinitialarabic'] = 0xFB7C;
  17160. t['tchehmedialarabic'] = 0xFB7D;
  17161. t['tcircle'] = 0x24E3;
  17162. t['tcircumflexbelow'] = 0x1E71;
  17163. t['tcommaaccent'] = 0x0163;
  17164. t['tdieresis'] = 0x1E97;
  17165. t['tdotaccent'] = 0x1E6B;
  17166. t['tdotbelow'] = 0x1E6D;
  17167. t['tecyrillic'] = 0x0442;
  17168. t['tedescendercyrillic'] = 0x04AD;
  17169. t['teharabic'] = 0x062A;
  17170. t['tehfinalarabic'] = 0xFE96;
  17171. t['tehhahinitialarabic'] = 0xFCA2;
  17172. t['tehhahisolatedarabic'] = 0xFC0C;
  17173. t['tehinitialarabic'] = 0xFE97;
  17174. t['tehiragana'] = 0x3066;
  17175. t['tehjeeminitialarabic'] = 0xFCA1;
  17176. t['tehjeemisolatedarabic'] = 0xFC0B;
  17177. t['tehmarbutaarabic'] = 0x0629;
  17178. t['tehmarbutafinalarabic'] = 0xFE94;
  17179. t['tehmedialarabic'] = 0xFE98;
  17180. t['tehmeeminitialarabic'] = 0xFCA4;
  17181. t['tehmeemisolatedarabic'] = 0xFC0E;
  17182. t['tehnoonfinalarabic'] = 0xFC73;
  17183. t['tekatakana'] = 0x30C6;
  17184. t['tekatakanahalfwidth'] = 0xFF83;
  17185. t['telephone'] = 0x2121;
  17186. t['telephoneblack'] = 0x260E;
  17187. t['telishagedolahebrew'] = 0x05A0;
  17188. t['telishaqetanahebrew'] = 0x05A9;
  17189. t['tencircle'] = 0x2469;
  17190. t['tenideographicparen'] = 0x3229;
  17191. t['tenparen'] = 0x247D;
  17192. t['tenperiod'] = 0x2491;
  17193. t['tenroman'] = 0x2179;
  17194. t['tesh'] = 0x02A7;
  17195. t['tet'] = 0x05D8;
  17196. t['tetdagesh'] = 0xFB38;
  17197. t['tetdageshhebrew'] = 0xFB38;
  17198. t['tethebrew'] = 0x05D8;
  17199. t['tetsecyrillic'] = 0x04B5;
  17200. t['tevirhebrew'] = 0x059B;
  17201. t['tevirlefthebrew'] = 0x059B;
  17202. t['thabengali'] = 0x09A5;
  17203. t['thadeva'] = 0x0925;
  17204. t['thagujarati'] = 0x0AA5;
  17205. t['thagurmukhi'] = 0x0A25;
  17206. t['thalarabic'] = 0x0630;
  17207. t['thalfinalarabic'] = 0xFEAC;
  17208. t['thanthakhatlowleftthai'] = 0xF898;
  17209. t['thanthakhatlowrightthai'] = 0xF897;
  17210. t['thanthakhatthai'] = 0x0E4C;
  17211. t['thanthakhatupperleftthai'] = 0xF896;
  17212. t['theharabic'] = 0x062B;
  17213. t['thehfinalarabic'] = 0xFE9A;
  17214. t['thehinitialarabic'] = 0xFE9B;
  17215. t['thehmedialarabic'] = 0xFE9C;
  17216. t['thereexists'] = 0x2203;
  17217. t['therefore'] = 0x2234;
  17218. t['theta'] = 0x03B8;
  17219. t['theta1'] = 0x03D1;
  17220. t['thetasymbolgreek'] = 0x03D1;
  17221. t['thieuthacirclekorean'] = 0x3279;
  17222. t['thieuthaparenkorean'] = 0x3219;
  17223. t['thieuthcirclekorean'] = 0x326B;
  17224. t['thieuthkorean'] = 0x314C;
  17225. t['thieuthparenkorean'] = 0x320B;
  17226. t['thirteencircle'] = 0x246C;
  17227. t['thirteenparen'] = 0x2480;
  17228. t['thirteenperiod'] = 0x2494;
  17229. t['thonangmonthothai'] = 0x0E11;
  17230. t['thook'] = 0x01AD;
  17231. t['thophuthaothai'] = 0x0E12;
  17232. t['thorn'] = 0x00FE;
  17233. t['thothahanthai'] = 0x0E17;
  17234. t['thothanthai'] = 0x0E10;
  17235. t['thothongthai'] = 0x0E18;
  17236. t['thothungthai'] = 0x0E16;
  17237. t['thousandcyrillic'] = 0x0482;
  17238. t['thousandsseparatorarabic'] = 0x066C;
  17239. t['thousandsseparatorpersian'] = 0x066C;
  17240. t['three'] = 0x0033;
  17241. t['threearabic'] = 0x0663;
  17242. t['threebengali'] = 0x09E9;
  17243. t['threecircle'] = 0x2462;
  17244. t['threecircleinversesansserif'] = 0x278C;
  17245. t['threedeva'] = 0x0969;
  17246. t['threeeighths'] = 0x215C;
  17247. t['threegujarati'] = 0x0AE9;
  17248. t['threegurmukhi'] = 0x0A69;
  17249. t['threehackarabic'] = 0x0663;
  17250. t['threehangzhou'] = 0x3023;
  17251. t['threeideographicparen'] = 0x3222;
  17252. t['threeinferior'] = 0x2083;
  17253. t['threemonospace'] = 0xFF13;
  17254. t['threenumeratorbengali'] = 0x09F6;
  17255. t['threeoldstyle'] = 0xF733;
  17256. t['threeparen'] = 0x2476;
  17257. t['threeperiod'] = 0x248A;
  17258. t['threepersian'] = 0x06F3;
  17259. t['threequarters'] = 0x00BE;
  17260. t['threequartersemdash'] = 0xF6DE;
  17261. t['threeroman'] = 0x2172;
  17262. t['threesuperior'] = 0x00B3;
  17263. t['threethai'] = 0x0E53;
  17264. t['thzsquare'] = 0x3394;
  17265. t['tihiragana'] = 0x3061;
  17266. t['tikatakana'] = 0x30C1;
  17267. t['tikatakanahalfwidth'] = 0xFF81;
  17268. t['tikeutacirclekorean'] = 0x3270;
  17269. t['tikeutaparenkorean'] = 0x3210;
  17270. t['tikeutcirclekorean'] = 0x3262;
  17271. t['tikeutkorean'] = 0x3137;
  17272. t['tikeutparenkorean'] = 0x3202;
  17273. t['tilde'] = 0x02DC;
  17274. t['tildebelowcmb'] = 0x0330;
  17275. t['tildecmb'] = 0x0303;
  17276. t['tildecomb'] = 0x0303;
  17277. t['tildedoublecmb'] = 0x0360;
  17278. t['tildeoperator'] = 0x223C;
  17279. t['tildeoverlaycmb'] = 0x0334;
  17280. t['tildeverticalcmb'] = 0x033E;
  17281. t['timescircle'] = 0x2297;
  17282. t['tipehahebrew'] = 0x0596;
  17283. t['tipehalefthebrew'] = 0x0596;
  17284. t['tippigurmukhi'] = 0x0A70;
  17285. t['titlocyrilliccmb'] = 0x0483;
  17286. t['tiwnarmenian'] = 0x057F;
  17287. t['tlinebelow'] = 0x1E6F;
  17288. t['tmonospace'] = 0xFF54;
  17289. t['toarmenian'] = 0x0569;
  17290. t['tohiragana'] = 0x3068;
  17291. t['tokatakana'] = 0x30C8;
  17292. t['tokatakanahalfwidth'] = 0xFF84;
  17293. t['tonebarextrahighmod'] = 0x02E5;
  17294. t['tonebarextralowmod'] = 0x02E9;
  17295. t['tonebarhighmod'] = 0x02E6;
  17296. t['tonebarlowmod'] = 0x02E8;
  17297. t['tonebarmidmod'] = 0x02E7;
  17298. t['tonefive'] = 0x01BD;
  17299. t['tonesix'] = 0x0185;
  17300. t['tonetwo'] = 0x01A8;
  17301. t['tonos'] = 0x0384;
  17302. t['tonsquare'] = 0x3327;
  17303. t['topatakthai'] = 0x0E0F;
  17304. t['tortoiseshellbracketleft'] = 0x3014;
  17305. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  17306. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  17307. t['tortoiseshellbracketright'] = 0x3015;
  17308. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  17309. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  17310. t['totaothai'] = 0x0E15;
  17311. t['tpalatalhook'] = 0x01AB;
  17312. t['tparen'] = 0x24AF;
  17313. t['trademark'] = 0x2122;
  17314. t['trademarksans'] = 0xF8EA;
  17315. t['trademarkserif'] = 0xF6DB;
  17316. t['tretroflexhook'] = 0x0288;
  17317. t['triagdn'] = 0x25BC;
  17318. t['triaglf'] = 0x25C4;
  17319. t['triagrt'] = 0x25BA;
  17320. t['triagup'] = 0x25B2;
  17321. t['ts'] = 0x02A6;
  17322. t['tsadi'] = 0x05E6;
  17323. t['tsadidagesh'] = 0xFB46;
  17324. t['tsadidageshhebrew'] = 0xFB46;
  17325. t['tsadihebrew'] = 0x05E6;
  17326. t['tsecyrillic'] = 0x0446;
  17327. t['tsere'] = 0x05B5;
  17328. t['tsere12'] = 0x05B5;
  17329. t['tsere1e'] = 0x05B5;
  17330. t['tsere2b'] = 0x05B5;
  17331. t['tserehebrew'] = 0x05B5;
  17332. t['tserenarrowhebrew'] = 0x05B5;
  17333. t['tserequarterhebrew'] = 0x05B5;
  17334. t['tserewidehebrew'] = 0x05B5;
  17335. t['tshecyrillic'] = 0x045B;
  17336. t['tsuperior'] = 0xF6F3;
  17337. t['ttabengali'] = 0x099F;
  17338. t['ttadeva'] = 0x091F;
  17339. t['ttagujarati'] = 0x0A9F;
  17340. t['ttagurmukhi'] = 0x0A1F;
  17341. t['tteharabic'] = 0x0679;
  17342. t['ttehfinalarabic'] = 0xFB67;
  17343. t['ttehinitialarabic'] = 0xFB68;
  17344. t['ttehmedialarabic'] = 0xFB69;
  17345. t['tthabengali'] = 0x09A0;
  17346. t['tthadeva'] = 0x0920;
  17347. t['tthagujarati'] = 0x0AA0;
  17348. t['tthagurmukhi'] = 0x0A20;
  17349. t['tturned'] = 0x0287;
  17350. t['tuhiragana'] = 0x3064;
  17351. t['tukatakana'] = 0x30C4;
  17352. t['tukatakanahalfwidth'] = 0xFF82;
  17353. t['tusmallhiragana'] = 0x3063;
  17354. t['tusmallkatakana'] = 0x30C3;
  17355. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  17356. t['twelvecircle'] = 0x246B;
  17357. t['twelveparen'] = 0x247F;
  17358. t['twelveperiod'] = 0x2493;
  17359. t['twelveroman'] = 0x217B;
  17360. t['twentycircle'] = 0x2473;
  17361. t['twentyhangzhou'] = 0x5344;
  17362. t['twentyparen'] = 0x2487;
  17363. t['twentyperiod'] = 0x249B;
  17364. t['two'] = 0x0032;
  17365. t['twoarabic'] = 0x0662;
  17366. t['twobengali'] = 0x09E8;
  17367. t['twocircle'] = 0x2461;
  17368. t['twocircleinversesansserif'] = 0x278B;
  17369. t['twodeva'] = 0x0968;
  17370. t['twodotenleader'] = 0x2025;
  17371. t['twodotleader'] = 0x2025;
  17372. t['twodotleadervertical'] = 0xFE30;
  17373. t['twogujarati'] = 0x0AE8;
  17374. t['twogurmukhi'] = 0x0A68;
  17375. t['twohackarabic'] = 0x0662;
  17376. t['twohangzhou'] = 0x3022;
  17377. t['twoideographicparen'] = 0x3221;
  17378. t['twoinferior'] = 0x2082;
  17379. t['twomonospace'] = 0xFF12;
  17380. t['twonumeratorbengali'] = 0x09F5;
  17381. t['twooldstyle'] = 0xF732;
  17382. t['twoparen'] = 0x2475;
  17383. t['twoperiod'] = 0x2489;
  17384. t['twopersian'] = 0x06F2;
  17385. t['tworoman'] = 0x2171;
  17386. t['twostroke'] = 0x01BB;
  17387. t['twosuperior'] = 0x00B2;
  17388. t['twothai'] = 0x0E52;
  17389. t['twothirds'] = 0x2154;
  17390. t['u'] = 0x0075;
  17391. t['uacute'] = 0x00FA;
  17392. t['ubar'] = 0x0289;
  17393. t['ubengali'] = 0x0989;
  17394. t['ubopomofo'] = 0x3128;
  17395. t['ubreve'] = 0x016D;
  17396. t['ucaron'] = 0x01D4;
  17397. t['ucircle'] = 0x24E4;
  17398. t['ucircumflex'] = 0x00FB;
  17399. t['ucircumflexbelow'] = 0x1E77;
  17400. t['ucyrillic'] = 0x0443;
  17401. t['udattadeva'] = 0x0951;
  17402. t['udblacute'] = 0x0171;
  17403. t['udblgrave'] = 0x0215;
  17404. t['udeva'] = 0x0909;
  17405. t['udieresis'] = 0x00FC;
  17406. t['udieresisacute'] = 0x01D8;
  17407. t['udieresisbelow'] = 0x1E73;
  17408. t['udieresiscaron'] = 0x01DA;
  17409. t['udieresiscyrillic'] = 0x04F1;
  17410. t['udieresisgrave'] = 0x01DC;
  17411. t['udieresismacron'] = 0x01D6;
  17412. t['udotbelow'] = 0x1EE5;
  17413. t['ugrave'] = 0x00F9;
  17414. t['ugujarati'] = 0x0A89;
  17415. t['ugurmukhi'] = 0x0A09;
  17416. t['uhiragana'] = 0x3046;
  17417. t['uhookabove'] = 0x1EE7;
  17418. t['uhorn'] = 0x01B0;
  17419. t['uhornacute'] = 0x1EE9;
  17420. t['uhorndotbelow'] = 0x1EF1;
  17421. t['uhorngrave'] = 0x1EEB;
  17422. t['uhornhookabove'] = 0x1EED;
  17423. t['uhorntilde'] = 0x1EEF;
  17424. t['uhungarumlaut'] = 0x0171;
  17425. t['uhungarumlautcyrillic'] = 0x04F3;
  17426. t['uinvertedbreve'] = 0x0217;
  17427. t['ukatakana'] = 0x30A6;
  17428. t['ukatakanahalfwidth'] = 0xFF73;
  17429. t['ukcyrillic'] = 0x0479;
  17430. t['ukorean'] = 0x315C;
  17431. t['umacron'] = 0x016B;
  17432. t['umacroncyrillic'] = 0x04EF;
  17433. t['umacrondieresis'] = 0x1E7B;
  17434. t['umatragurmukhi'] = 0x0A41;
  17435. t['umonospace'] = 0xFF55;
  17436. t['underscore'] = 0x005F;
  17437. t['underscoredbl'] = 0x2017;
  17438. t['underscoremonospace'] = 0xFF3F;
  17439. t['underscorevertical'] = 0xFE33;
  17440. t['underscorewavy'] = 0xFE4F;
  17441. t['union'] = 0x222A;
  17442. t['universal'] = 0x2200;
  17443. t['uogonek'] = 0x0173;
  17444. t['uparen'] = 0x24B0;
  17445. t['upblock'] = 0x2580;
  17446. t['upperdothebrew'] = 0x05C4;
  17447. t['upsilon'] = 0x03C5;
  17448. t['upsilondieresis'] = 0x03CB;
  17449. t['upsilondieresistonos'] = 0x03B0;
  17450. t['upsilonlatin'] = 0x028A;
  17451. t['upsilontonos'] = 0x03CD;
  17452. t['uptackbelowcmb'] = 0x031D;
  17453. t['uptackmod'] = 0x02D4;
  17454. t['uragurmukhi'] = 0x0A73;
  17455. t['uring'] = 0x016F;
  17456. t['ushortcyrillic'] = 0x045E;
  17457. t['usmallhiragana'] = 0x3045;
  17458. t['usmallkatakana'] = 0x30A5;
  17459. t['usmallkatakanahalfwidth'] = 0xFF69;
  17460. t['ustraightcyrillic'] = 0x04AF;
  17461. t['ustraightstrokecyrillic'] = 0x04B1;
  17462. t['utilde'] = 0x0169;
  17463. t['utildeacute'] = 0x1E79;
  17464. t['utildebelow'] = 0x1E75;
  17465. t['uubengali'] = 0x098A;
  17466. t['uudeva'] = 0x090A;
  17467. t['uugujarati'] = 0x0A8A;
  17468. t['uugurmukhi'] = 0x0A0A;
  17469. t['uumatragurmukhi'] = 0x0A42;
  17470. t['uuvowelsignbengali'] = 0x09C2;
  17471. t['uuvowelsigndeva'] = 0x0942;
  17472. t['uuvowelsigngujarati'] = 0x0AC2;
  17473. t['uvowelsignbengali'] = 0x09C1;
  17474. t['uvowelsigndeva'] = 0x0941;
  17475. t['uvowelsigngujarati'] = 0x0AC1;
  17476. t['v'] = 0x0076;
  17477. t['vadeva'] = 0x0935;
  17478. t['vagujarati'] = 0x0AB5;
  17479. t['vagurmukhi'] = 0x0A35;
  17480. t['vakatakana'] = 0x30F7;
  17481. t['vav'] = 0x05D5;
  17482. t['vavdagesh'] = 0xFB35;
  17483. t['vavdagesh65'] = 0xFB35;
  17484. t['vavdageshhebrew'] = 0xFB35;
  17485. t['vavhebrew'] = 0x05D5;
  17486. t['vavholam'] = 0xFB4B;
  17487. t['vavholamhebrew'] = 0xFB4B;
  17488. t['vavvavhebrew'] = 0x05F0;
  17489. t['vavyodhebrew'] = 0x05F1;
  17490. t['vcircle'] = 0x24E5;
  17491. t['vdotbelow'] = 0x1E7F;
  17492. t['vecyrillic'] = 0x0432;
  17493. t['veharabic'] = 0x06A4;
  17494. t['vehfinalarabic'] = 0xFB6B;
  17495. t['vehinitialarabic'] = 0xFB6C;
  17496. t['vehmedialarabic'] = 0xFB6D;
  17497. t['vekatakana'] = 0x30F9;
  17498. t['venus'] = 0x2640;
  17499. t['verticalbar'] = 0x007C;
  17500. t['verticallineabovecmb'] = 0x030D;
  17501. t['verticallinebelowcmb'] = 0x0329;
  17502. t['verticallinelowmod'] = 0x02CC;
  17503. t['verticallinemod'] = 0x02C8;
  17504. t['vewarmenian'] = 0x057E;
  17505. t['vhook'] = 0x028B;
  17506. t['vikatakana'] = 0x30F8;
  17507. t['viramabengali'] = 0x09CD;
  17508. t['viramadeva'] = 0x094D;
  17509. t['viramagujarati'] = 0x0ACD;
  17510. t['visargabengali'] = 0x0983;
  17511. t['visargadeva'] = 0x0903;
  17512. t['visargagujarati'] = 0x0A83;
  17513. t['vmonospace'] = 0xFF56;
  17514. t['voarmenian'] = 0x0578;
  17515. t['voicediterationhiragana'] = 0x309E;
  17516. t['voicediterationkatakana'] = 0x30FE;
  17517. t['voicedmarkkana'] = 0x309B;
  17518. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  17519. t['vokatakana'] = 0x30FA;
  17520. t['vparen'] = 0x24B1;
  17521. t['vtilde'] = 0x1E7D;
  17522. t['vturned'] = 0x028C;
  17523. t['vuhiragana'] = 0x3094;
  17524. t['vukatakana'] = 0x30F4;
  17525. t['w'] = 0x0077;
  17526. t['wacute'] = 0x1E83;
  17527. t['waekorean'] = 0x3159;
  17528. t['wahiragana'] = 0x308F;
  17529. t['wakatakana'] = 0x30EF;
  17530. t['wakatakanahalfwidth'] = 0xFF9C;
  17531. t['wakorean'] = 0x3158;
  17532. t['wasmallhiragana'] = 0x308E;
  17533. t['wasmallkatakana'] = 0x30EE;
  17534. t['wattosquare'] = 0x3357;
  17535. t['wavedash'] = 0x301C;
  17536. t['wavyunderscorevertical'] = 0xFE34;
  17537. t['wawarabic'] = 0x0648;
  17538. t['wawfinalarabic'] = 0xFEEE;
  17539. t['wawhamzaabovearabic'] = 0x0624;
  17540. t['wawhamzaabovefinalarabic'] = 0xFE86;
  17541. t['wbsquare'] = 0x33DD;
  17542. t['wcircle'] = 0x24E6;
  17543. t['wcircumflex'] = 0x0175;
  17544. t['wdieresis'] = 0x1E85;
  17545. t['wdotaccent'] = 0x1E87;
  17546. t['wdotbelow'] = 0x1E89;
  17547. t['wehiragana'] = 0x3091;
  17548. t['weierstrass'] = 0x2118;
  17549. t['wekatakana'] = 0x30F1;
  17550. t['wekorean'] = 0x315E;
  17551. t['weokorean'] = 0x315D;
  17552. t['wgrave'] = 0x1E81;
  17553. t['whitebullet'] = 0x25E6;
  17554. t['whitecircle'] = 0x25CB;
  17555. t['whitecircleinverse'] = 0x25D9;
  17556. t['whitecornerbracketleft'] = 0x300E;
  17557. t['whitecornerbracketleftvertical'] = 0xFE43;
  17558. t['whitecornerbracketright'] = 0x300F;
  17559. t['whitecornerbracketrightvertical'] = 0xFE44;
  17560. t['whitediamond'] = 0x25C7;
  17561. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  17562. t['whitedownpointingsmalltriangle'] = 0x25BF;
  17563. t['whitedownpointingtriangle'] = 0x25BD;
  17564. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  17565. t['whiteleftpointingtriangle'] = 0x25C1;
  17566. t['whitelenticularbracketleft'] = 0x3016;
  17567. t['whitelenticularbracketright'] = 0x3017;
  17568. t['whiterightpointingsmalltriangle'] = 0x25B9;
  17569. t['whiterightpointingtriangle'] = 0x25B7;
  17570. t['whitesmallsquare'] = 0x25AB;
  17571. t['whitesmilingface'] = 0x263A;
  17572. t['whitesquare'] = 0x25A1;
  17573. t['whitestar'] = 0x2606;
  17574. t['whitetelephone'] = 0x260F;
  17575. t['whitetortoiseshellbracketleft'] = 0x3018;
  17576. t['whitetortoiseshellbracketright'] = 0x3019;
  17577. t['whiteuppointingsmalltriangle'] = 0x25B5;
  17578. t['whiteuppointingtriangle'] = 0x25B3;
  17579. t['wihiragana'] = 0x3090;
  17580. t['wikatakana'] = 0x30F0;
  17581. t['wikorean'] = 0x315F;
  17582. t['wmonospace'] = 0xFF57;
  17583. t['wohiragana'] = 0x3092;
  17584. t['wokatakana'] = 0x30F2;
  17585. t['wokatakanahalfwidth'] = 0xFF66;
  17586. t['won'] = 0x20A9;
  17587. t['wonmonospace'] = 0xFFE6;
  17588. t['wowaenthai'] = 0x0E27;
  17589. t['wparen'] = 0x24B2;
  17590. t['wring'] = 0x1E98;
  17591. t['wsuperior'] = 0x02B7;
  17592. t['wturned'] = 0x028D;
  17593. t['wynn'] = 0x01BF;
  17594. t['x'] = 0x0078;
  17595. t['xabovecmb'] = 0x033D;
  17596. t['xbopomofo'] = 0x3112;
  17597. t['xcircle'] = 0x24E7;
  17598. t['xdieresis'] = 0x1E8D;
  17599. t['xdotaccent'] = 0x1E8B;
  17600. t['xeharmenian'] = 0x056D;
  17601. t['xi'] = 0x03BE;
  17602. t['xmonospace'] = 0xFF58;
  17603. t['xparen'] = 0x24B3;
  17604. t['xsuperior'] = 0x02E3;
  17605. t['y'] = 0x0079;
  17606. t['yaadosquare'] = 0x334E;
  17607. t['yabengali'] = 0x09AF;
  17608. t['yacute'] = 0x00FD;
  17609. t['yadeva'] = 0x092F;
  17610. t['yaekorean'] = 0x3152;
  17611. t['yagujarati'] = 0x0AAF;
  17612. t['yagurmukhi'] = 0x0A2F;
  17613. t['yahiragana'] = 0x3084;
  17614. t['yakatakana'] = 0x30E4;
  17615. t['yakatakanahalfwidth'] = 0xFF94;
  17616. t['yakorean'] = 0x3151;
  17617. t['yamakkanthai'] = 0x0E4E;
  17618. t['yasmallhiragana'] = 0x3083;
  17619. t['yasmallkatakana'] = 0x30E3;
  17620. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  17621. t['yatcyrillic'] = 0x0463;
  17622. t['ycircle'] = 0x24E8;
  17623. t['ycircumflex'] = 0x0177;
  17624. t['ydieresis'] = 0x00FF;
  17625. t['ydotaccent'] = 0x1E8F;
  17626. t['ydotbelow'] = 0x1EF5;
  17627. t['yeharabic'] = 0x064A;
  17628. t['yehbarreearabic'] = 0x06D2;
  17629. t['yehbarreefinalarabic'] = 0xFBAF;
  17630. t['yehfinalarabic'] = 0xFEF2;
  17631. t['yehhamzaabovearabic'] = 0x0626;
  17632. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  17633. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  17634. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  17635. t['yehinitialarabic'] = 0xFEF3;
  17636. t['yehmedialarabic'] = 0xFEF4;
  17637. t['yehmeeminitialarabic'] = 0xFCDD;
  17638. t['yehmeemisolatedarabic'] = 0xFC58;
  17639. t['yehnoonfinalarabic'] = 0xFC94;
  17640. t['yehthreedotsbelowarabic'] = 0x06D1;
  17641. t['yekorean'] = 0x3156;
  17642. t['yen'] = 0x00A5;
  17643. t['yenmonospace'] = 0xFFE5;
  17644. t['yeokorean'] = 0x3155;
  17645. t['yeorinhieuhkorean'] = 0x3186;
  17646. t['yerahbenyomohebrew'] = 0x05AA;
  17647. t['yerahbenyomolefthebrew'] = 0x05AA;
  17648. t['yericyrillic'] = 0x044B;
  17649. t['yerudieresiscyrillic'] = 0x04F9;
  17650. t['yesieungkorean'] = 0x3181;
  17651. t['yesieungpansioskorean'] = 0x3183;
  17652. t['yesieungsioskorean'] = 0x3182;
  17653. t['yetivhebrew'] = 0x059A;
  17654. t['ygrave'] = 0x1EF3;
  17655. t['yhook'] = 0x01B4;
  17656. t['yhookabove'] = 0x1EF7;
  17657. t['yiarmenian'] = 0x0575;
  17658. t['yicyrillic'] = 0x0457;
  17659. t['yikorean'] = 0x3162;
  17660. t['yinyang'] = 0x262F;
  17661. t['yiwnarmenian'] = 0x0582;
  17662. t['ymonospace'] = 0xFF59;
  17663. t['yod'] = 0x05D9;
  17664. t['yoddagesh'] = 0xFB39;
  17665. t['yoddageshhebrew'] = 0xFB39;
  17666. t['yodhebrew'] = 0x05D9;
  17667. t['yodyodhebrew'] = 0x05F2;
  17668. t['yodyodpatahhebrew'] = 0xFB1F;
  17669. t['yohiragana'] = 0x3088;
  17670. t['yoikorean'] = 0x3189;
  17671. t['yokatakana'] = 0x30E8;
  17672. t['yokatakanahalfwidth'] = 0xFF96;
  17673. t['yokorean'] = 0x315B;
  17674. t['yosmallhiragana'] = 0x3087;
  17675. t['yosmallkatakana'] = 0x30E7;
  17676. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  17677. t['yotgreek'] = 0x03F3;
  17678. t['yoyaekorean'] = 0x3188;
  17679. t['yoyakorean'] = 0x3187;
  17680. t['yoyakthai'] = 0x0E22;
  17681. t['yoyingthai'] = 0x0E0D;
  17682. t['yparen'] = 0x24B4;
  17683. t['ypogegrammeni'] = 0x037A;
  17684. t['ypogegrammenigreekcmb'] = 0x0345;
  17685. t['yr'] = 0x01A6;
  17686. t['yring'] = 0x1E99;
  17687. t['ysuperior'] = 0x02B8;
  17688. t['ytilde'] = 0x1EF9;
  17689. t['yturned'] = 0x028E;
  17690. t['yuhiragana'] = 0x3086;
  17691. t['yuikorean'] = 0x318C;
  17692. t['yukatakana'] = 0x30E6;
  17693. t['yukatakanahalfwidth'] = 0xFF95;
  17694. t['yukorean'] = 0x3160;
  17695. t['yusbigcyrillic'] = 0x046B;
  17696. t['yusbigiotifiedcyrillic'] = 0x046D;
  17697. t['yuslittlecyrillic'] = 0x0467;
  17698. t['yuslittleiotifiedcyrillic'] = 0x0469;
  17699. t['yusmallhiragana'] = 0x3085;
  17700. t['yusmallkatakana'] = 0x30E5;
  17701. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  17702. t['yuyekorean'] = 0x318B;
  17703. t['yuyeokorean'] = 0x318A;
  17704. t['yyabengali'] = 0x09DF;
  17705. t['yyadeva'] = 0x095F;
  17706. t['z'] = 0x007A;
  17707. t['zaarmenian'] = 0x0566;
  17708. t['zacute'] = 0x017A;
  17709. t['zadeva'] = 0x095B;
  17710. t['zagurmukhi'] = 0x0A5B;
  17711. t['zaharabic'] = 0x0638;
  17712. t['zahfinalarabic'] = 0xFEC6;
  17713. t['zahinitialarabic'] = 0xFEC7;
  17714. t['zahiragana'] = 0x3056;
  17715. t['zahmedialarabic'] = 0xFEC8;
  17716. t['zainarabic'] = 0x0632;
  17717. t['zainfinalarabic'] = 0xFEB0;
  17718. t['zakatakana'] = 0x30B6;
  17719. t['zaqefgadolhebrew'] = 0x0595;
  17720. t['zaqefqatanhebrew'] = 0x0594;
  17721. t['zarqahebrew'] = 0x0598;
  17722. t['zayin'] = 0x05D6;
  17723. t['zayindagesh'] = 0xFB36;
  17724. t['zayindageshhebrew'] = 0xFB36;
  17725. t['zayinhebrew'] = 0x05D6;
  17726. t['zbopomofo'] = 0x3117;
  17727. t['zcaron'] = 0x017E;
  17728. t['zcircle'] = 0x24E9;
  17729. t['zcircumflex'] = 0x1E91;
  17730. t['zcurl'] = 0x0291;
  17731. t['zdot'] = 0x017C;
  17732. t['zdotaccent'] = 0x017C;
  17733. t['zdotbelow'] = 0x1E93;
  17734. t['zecyrillic'] = 0x0437;
  17735. t['zedescendercyrillic'] = 0x0499;
  17736. t['zedieresiscyrillic'] = 0x04DF;
  17737. t['zehiragana'] = 0x305C;
  17738. t['zekatakana'] = 0x30BC;
  17739. t['zero'] = 0x0030;
  17740. t['zeroarabic'] = 0x0660;
  17741. t['zerobengali'] = 0x09E6;
  17742. t['zerodeva'] = 0x0966;
  17743. t['zerogujarati'] = 0x0AE6;
  17744. t['zerogurmukhi'] = 0x0A66;
  17745. t['zerohackarabic'] = 0x0660;
  17746. t['zeroinferior'] = 0x2080;
  17747. t['zeromonospace'] = 0xFF10;
  17748. t['zerooldstyle'] = 0xF730;
  17749. t['zeropersian'] = 0x06F0;
  17750. t['zerosuperior'] = 0x2070;
  17751. t['zerothai'] = 0x0E50;
  17752. t['zerowidthjoiner'] = 0xFEFF;
  17753. t['zerowidthnonjoiner'] = 0x200C;
  17754. t['zerowidthspace'] = 0x200B;
  17755. t['zeta'] = 0x03B6;
  17756. t['zhbopomofo'] = 0x3113;
  17757. t['zhearmenian'] = 0x056A;
  17758. t['zhebrevecyrillic'] = 0x04C2;
  17759. t['zhecyrillic'] = 0x0436;
  17760. t['zhedescendercyrillic'] = 0x0497;
  17761. t['zhedieresiscyrillic'] = 0x04DD;
  17762. t['zihiragana'] = 0x3058;
  17763. t['zikatakana'] = 0x30B8;
  17764. t['zinorhebrew'] = 0x05AE;
  17765. t['zlinebelow'] = 0x1E95;
  17766. t['zmonospace'] = 0xFF5A;
  17767. t['zohiragana'] = 0x305E;
  17768. t['zokatakana'] = 0x30BE;
  17769. t['zparen'] = 0x24B5;
  17770. t['zretroflexhook'] = 0x0290;
  17771. t['zstroke'] = 0x01B6;
  17772. t['zuhiragana'] = 0x305A;
  17773. t['zukatakana'] = 0x30BA;
  17774. t['.notdef'] = 0x0000;
  17775. t['angbracketleftbig'] = 0x2329;
  17776. t['angbracketleftBig'] = 0x2329;
  17777. t['angbracketleftbigg'] = 0x2329;
  17778. t['angbracketleftBigg'] = 0x2329;
  17779. t['angbracketrightBig'] = 0x232A;
  17780. t['angbracketrightbig'] = 0x232A;
  17781. t['angbracketrightBigg'] = 0x232A;
  17782. t['angbracketrightbigg'] = 0x232A;
  17783. t['arrowhookleft'] = 0x21AA;
  17784. t['arrowhookright'] = 0x21A9;
  17785. t['arrowlefttophalf'] = 0x21BC;
  17786. t['arrowleftbothalf'] = 0x21BD;
  17787. t['arrownortheast'] = 0x2197;
  17788. t['arrownorthwest'] = 0x2196;
  17789. t['arrowrighttophalf'] = 0x21C0;
  17790. t['arrowrightbothalf'] = 0x21C1;
  17791. t['arrowsoutheast'] = 0x2198;
  17792. t['arrowsouthwest'] = 0x2199;
  17793. t['backslashbig'] = 0x2216;
  17794. t['backslashBig'] = 0x2216;
  17795. t['backslashBigg'] = 0x2216;
  17796. t['backslashbigg'] = 0x2216;
  17797. t['bardbl'] = 0x2016;
  17798. t['bracehtipdownleft'] = 0xFE37;
  17799. t['bracehtipdownright'] = 0xFE37;
  17800. t['bracehtipupleft'] = 0xFE38;
  17801. t['bracehtipupright'] = 0xFE38;
  17802. t['braceleftBig'] = 0x007B;
  17803. t['braceleftbig'] = 0x007B;
  17804. t['braceleftbigg'] = 0x007B;
  17805. t['braceleftBigg'] = 0x007B;
  17806. t['bracerightBig'] = 0x007D;
  17807. t['bracerightbig'] = 0x007D;
  17808. t['bracerightbigg'] = 0x007D;
  17809. t['bracerightBigg'] = 0x007D;
  17810. t['bracketleftbig'] = 0x005B;
  17811. t['bracketleftBig'] = 0x005B;
  17812. t['bracketleftbigg'] = 0x005B;
  17813. t['bracketleftBigg'] = 0x005B;
  17814. t['bracketrightBig'] = 0x005D;
  17815. t['bracketrightbig'] = 0x005D;
  17816. t['bracketrightbigg'] = 0x005D;
  17817. t['bracketrightBigg'] = 0x005D;
  17818. t['ceilingleftbig'] = 0x2308;
  17819. t['ceilingleftBig'] = 0x2308;
  17820. t['ceilingleftBigg'] = 0x2308;
  17821. t['ceilingleftbigg'] = 0x2308;
  17822. t['ceilingrightbig'] = 0x2309;
  17823. t['ceilingrightBig'] = 0x2309;
  17824. t['ceilingrightbigg'] = 0x2309;
  17825. t['ceilingrightBigg'] = 0x2309;
  17826. t['circledotdisplay'] = 0x2299;
  17827. t['circledottext'] = 0x2299;
  17828. t['circlemultiplydisplay'] = 0x2297;
  17829. t['circlemultiplytext'] = 0x2297;
  17830. t['circleplusdisplay'] = 0x2295;
  17831. t['circleplustext'] = 0x2295;
  17832. t['contintegraldisplay'] = 0x222E;
  17833. t['contintegraltext'] = 0x222E;
  17834. t['coproductdisplay'] = 0x2210;
  17835. t['coproducttext'] = 0x2210;
  17836. t['floorleftBig'] = 0x230A;
  17837. t['floorleftbig'] = 0x230A;
  17838. t['floorleftbigg'] = 0x230A;
  17839. t['floorleftBigg'] = 0x230A;
  17840. t['floorrightbig'] = 0x230B;
  17841. t['floorrightBig'] = 0x230B;
  17842. t['floorrightBigg'] = 0x230B;
  17843. t['floorrightbigg'] = 0x230B;
  17844. t['hatwide'] = 0x0302;
  17845. t['hatwider'] = 0x0302;
  17846. t['hatwidest'] = 0x0302;
  17847. t['intercal'] = 0x1D40;
  17848. t['integraldisplay'] = 0x222B;
  17849. t['integraltext'] = 0x222B;
  17850. t['intersectiondisplay'] = 0x22C2;
  17851. t['intersectiontext'] = 0x22C2;
  17852. t['logicalanddisplay'] = 0x2227;
  17853. t['logicalandtext'] = 0x2227;
  17854. t['logicalordisplay'] = 0x2228;
  17855. t['logicalortext'] = 0x2228;
  17856. t['parenleftBig'] = 0x0028;
  17857. t['parenleftbig'] = 0x0028;
  17858. t['parenleftBigg'] = 0x0028;
  17859. t['parenleftbigg'] = 0x0028;
  17860. t['parenrightBig'] = 0x0029;
  17861. t['parenrightbig'] = 0x0029;
  17862. t['parenrightBigg'] = 0x0029;
  17863. t['parenrightbigg'] = 0x0029;
  17864. t['prime'] = 0x2032;
  17865. t['productdisplay'] = 0x220F;
  17866. t['producttext'] = 0x220F;
  17867. t['radicalbig'] = 0x221A;
  17868. t['radicalBig'] = 0x221A;
  17869. t['radicalBigg'] = 0x221A;
  17870. t['radicalbigg'] = 0x221A;
  17871. t['radicalbt'] = 0x221A;
  17872. t['radicaltp'] = 0x221A;
  17873. t['radicalvertex'] = 0x221A;
  17874. t['slashbig'] = 0x002F;
  17875. t['slashBig'] = 0x002F;
  17876. t['slashBigg'] = 0x002F;
  17877. t['slashbigg'] = 0x002F;
  17878. t['summationdisplay'] = 0x2211;
  17879. t['summationtext'] = 0x2211;
  17880. t['tildewide'] = 0x02DC;
  17881. t['tildewider'] = 0x02DC;
  17882. t['tildewidest'] = 0x02DC;
  17883. t['uniondisplay'] = 0x22C3;
  17884. t['unionmultidisplay'] = 0x228E;
  17885. t['unionmultitext'] = 0x228E;
  17886. t['unionsqdisplay'] = 0x2294;
  17887. t['unionsqtext'] = 0x2294;
  17888. t['uniontext'] = 0x22C3;
  17889. t['vextenddouble'] = 0x2225;
  17890. t['vextendsingle'] = 0x2223;
  17891. });
  17892. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  17893. t['space'] = 0x0020;
  17894. t['a1'] = 0x2701;
  17895. t['a2'] = 0x2702;
  17896. t['a202'] = 0x2703;
  17897. t['a3'] = 0x2704;
  17898. t['a4'] = 0x260E;
  17899. t['a5'] = 0x2706;
  17900. t['a119'] = 0x2707;
  17901. t['a118'] = 0x2708;
  17902. t['a117'] = 0x2709;
  17903. t['a11'] = 0x261B;
  17904. t['a12'] = 0x261E;
  17905. t['a13'] = 0x270C;
  17906. t['a14'] = 0x270D;
  17907. t['a15'] = 0x270E;
  17908. t['a16'] = 0x270F;
  17909. t['a105'] = 0x2710;
  17910. t['a17'] = 0x2711;
  17911. t['a18'] = 0x2712;
  17912. t['a19'] = 0x2713;
  17913. t['a20'] = 0x2714;
  17914. t['a21'] = 0x2715;
  17915. t['a22'] = 0x2716;
  17916. t['a23'] = 0x2717;
  17917. t['a24'] = 0x2718;
  17918. t['a25'] = 0x2719;
  17919. t['a26'] = 0x271A;
  17920. t['a27'] = 0x271B;
  17921. t['a28'] = 0x271C;
  17922. t['a6'] = 0x271D;
  17923. t['a7'] = 0x271E;
  17924. t['a8'] = 0x271F;
  17925. t['a9'] = 0x2720;
  17926. t['a10'] = 0x2721;
  17927. t['a29'] = 0x2722;
  17928. t['a30'] = 0x2723;
  17929. t['a31'] = 0x2724;
  17930. t['a32'] = 0x2725;
  17931. t['a33'] = 0x2726;
  17932. t['a34'] = 0x2727;
  17933. t['a35'] = 0x2605;
  17934. t['a36'] = 0x2729;
  17935. t['a37'] = 0x272A;
  17936. t['a38'] = 0x272B;
  17937. t['a39'] = 0x272C;
  17938. t['a40'] = 0x272D;
  17939. t['a41'] = 0x272E;
  17940. t['a42'] = 0x272F;
  17941. t['a43'] = 0x2730;
  17942. t['a44'] = 0x2731;
  17943. t['a45'] = 0x2732;
  17944. t['a46'] = 0x2733;
  17945. t['a47'] = 0x2734;
  17946. t['a48'] = 0x2735;
  17947. t['a49'] = 0x2736;
  17948. t['a50'] = 0x2737;
  17949. t['a51'] = 0x2738;
  17950. t['a52'] = 0x2739;
  17951. t['a53'] = 0x273A;
  17952. t['a54'] = 0x273B;
  17953. t['a55'] = 0x273C;
  17954. t['a56'] = 0x273D;
  17955. t['a57'] = 0x273E;
  17956. t['a58'] = 0x273F;
  17957. t['a59'] = 0x2740;
  17958. t['a60'] = 0x2741;
  17959. t['a61'] = 0x2742;
  17960. t['a62'] = 0x2743;
  17961. t['a63'] = 0x2744;
  17962. t['a64'] = 0x2745;
  17963. t['a65'] = 0x2746;
  17964. t['a66'] = 0x2747;
  17965. t['a67'] = 0x2748;
  17966. t['a68'] = 0x2749;
  17967. t['a69'] = 0x274A;
  17968. t['a70'] = 0x274B;
  17969. t['a71'] = 0x25CF;
  17970. t['a72'] = 0x274D;
  17971. t['a73'] = 0x25A0;
  17972. t['a74'] = 0x274F;
  17973. t['a203'] = 0x2750;
  17974. t['a75'] = 0x2751;
  17975. t['a204'] = 0x2752;
  17976. t['a76'] = 0x25B2;
  17977. t['a77'] = 0x25BC;
  17978. t['a78'] = 0x25C6;
  17979. t['a79'] = 0x2756;
  17980. t['a81'] = 0x25D7;
  17981. t['a82'] = 0x2758;
  17982. t['a83'] = 0x2759;
  17983. t['a84'] = 0x275A;
  17984. t['a97'] = 0x275B;
  17985. t['a98'] = 0x275C;
  17986. t['a99'] = 0x275D;
  17987. t['a100'] = 0x275E;
  17988. t['a101'] = 0x2761;
  17989. t['a102'] = 0x2762;
  17990. t['a103'] = 0x2763;
  17991. t['a104'] = 0x2764;
  17992. t['a106'] = 0x2765;
  17993. t['a107'] = 0x2766;
  17994. t['a108'] = 0x2767;
  17995. t['a112'] = 0x2663;
  17996. t['a111'] = 0x2666;
  17997. t['a110'] = 0x2665;
  17998. t['a109'] = 0x2660;
  17999. t['a120'] = 0x2460;
  18000. t['a121'] = 0x2461;
  18001. t['a122'] = 0x2462;
  18002. t['a123'] = 0x2463;
  18003. t['a124'] = 0x2464;
  18004. t['a125'] = 0x2465;
  18005. t['a126'] = 0x2466;
  18006. t['a127'] = 0x2467;
  18007. t['a128'] = 0x2468;
  18008. t['a129'] = 0x2469;
  18009. t['a130'] = 0x2776;
  18010. t['a131'] = 0x2777;
  18011. t['a132'] = 0x2778;
  18012. t['a133'] = 0x2779;
  18013. t['a134'] = 0x277A;
  18014. t['a135'] = 0x277B;
  18015. t['a136'] = 0x277C;
  18016. t['a137'] = 0x277D;
  18017. t['a138'] = 0x277E;
  18018. t['a139'] = 0x277F;
  18019. t['a140'] = 0x2780;
  18020. t['a141'] = 0x2781;
  18021. t['a142'] = 0x2782;
  18022. t['a143'] = 0x2783;
  18023. t['a144'] = 0x2784;
  18024. t['a145'] = 0x2785;
  18025. t['a146'] = 0x2786;
  18026. t['a147'] = 0x2787;
  18027. t['a148'] = 0x2788;
  18028. t['a149'] = 0x2789;
  18029. t['a150'] = 0x278A;
  18030. t['a151'] = 0x278B;
  18031. t['a152'] = 0x278C;
  18032. t['a153'] = 0x278D;
  18033. t['a154'] = 0x278E;
  18034. t['a155'] = 0x278F;
  18035. t['a156'] = 0x2790;
  18036. t['a157'] = 0x2791;
  18037. t['a158'] = 0x2792;
  18038. t['a159'] = 0x2793;
  18039. t['a160'] = 0x2794;
  18040. t['a161'] = 0x2192;
  18041. t['a163'] = 0x2194;
  18042. t['a164'] = 0x2195;
  18043. t['a196'] = 0x2798;
  18044. t['a165'] = 0x2799;
  18045. t['a192'] = 0x279A;
  18046. t['a166'] = 0x279B;
  18047. t['a167'] = 0x279C;
  18048. t['a168'] = 0x279D;
  18049. t['a169'] = 0x279E;
  18050. t['a170'] = 0x279F;
  18051. t['a171'] = 0x27A0;
  18052. t['a172'] = 0x27A1;
  18053. t['a173'] = 0x27A2;
  18054. t['a162'] = 0x27A3;
  18055. t['a174'] = 0x27A4;
  18056. t['a175'] = 0x27A5;
  18057. t['a176'] = 0x27A6;
  18058. t['a177'] = 0x27A7;
  18059. t['a178'] = 0x27A8;
  18060. t['a179'] = 0x27A9;
  18061. t['a193'] = 0x27AA;
  18062. t['a180'] = 0x27AB;
  18063. t['a199'] = 0x27AC;
  18064. t['a181'] = 0x27AD;
  18065. t['a200'] = 0x27AE;
  18066. t['a182'] = 0x27AF;
  18067. t['a201'] = 0x27B1;
  18068. t['a183'] = 0x27B2;
  18069. t['a184'] = 0x27B3;
  18070. t['a197'] = 0x27B4;
  18071. t['a185'] = 0x27B5;
  18072. t['a194'] = 0x27B6;
  18073. t['a198'] = 0x27B7;
  18074. t['a186'] = 0x27B8;
  18075. t['a195'] = 0x27B9;
  18076. t['a187'] = 0x27BA;
  18077. t['a188'] = 0x27BB;
  18078. t['a189'] = 0x27BC;
  18079. t['a190'] = 0x27BD;
  18080. t['a191'] = 0x27BE;
  18081. t['a89'] = 0x2768;
  18082. t['a90'] = 0x2769;
  18083. t['a93'] = 0x276A;
  18084. t['a94'] = 0x276B;
  18085. t['a91'] = 0x276C;
  18086. t['a92'] = 0x276D;
  18087. t['a205'] = 0x276E;
  18088. t['a85'] = 0x276F;
  18089. t['a206'] = 0x2770;
  18090. t['a86'] = 0x2771;
  18091. t['a87'] = 0x2772;
  18092. t['a88'] = 0x2773;
  18093. t['a95'] = 0x2774;
  18094. t['a96'] = 0x2775;
  18095. t['.notdef'] = 0x0000;
  18096. });
  18097. exports.getGlyphsUnicode = getGlyphsUnicode;
  18098. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18099. /***/ }),
  18100. /* 9 */
  18101. /***/ (function(module, exports, __w_pdfjs_require__) {
  18102. "use strict";
  18103. var sharedUtil = __w_pdfjs_require__(0);
  18104. var displayDOMUtils = __w_pdfjs_require__(3);
  18105. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18106. var AnnotationType = sharedUtil.AnnotationType;
  18107. var stringToPDFString = sharedUtil.stringToPDFString;
  18108. var Util = sharedUtil.Util;
  18109. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18110. var LinkTarget = displayDOMUtils.LinkTarget;
  18111. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18112. var warn = sharedUtil.warn;
  18113. var CustomStyle = displayDOMUtils.CustomStyle;
  18114. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18115. function AnnotationElementFactory() {
  18116. }
  18117. AnnotationElementFactory.prototype = {
  18118. create: function AnnotationElementFactory_create(parameters) {
  18119. var subtype = parameters.data.annotationType;
  18120. switch (subtype) {
  18121. case AnnotationType.LINK:
  18122. return new LinkAnnotationElement(parameters);
  18123. case AnnotationType.TEXT:
  18124. return new TextAnnotationElement(parameters);
  18125. case AnnotationType.WIDGET:
  18126. var fieldType = parameters.data.fieldType;
  18127. switch (fieldType) {
  18128. case 'Tx':
  18129. return new TextWidgetAnnotationElement(parameters);
  18130. case 'Btn':
  18131. if (parameters.data.radioButton) {
  18132. return new RadioButtonWidgetAnnotationElement(parameters);
  18133. } else if (parameters.data.checkBox) {
  18134. return new CheckboxWidgetAnnotationElement(parameters);
  18135. }
  18136. warn('Unimplemented button widget annotation: pushbutton');
  18137. break;
  18138. case 'Ch':
  18139. return new ChoiceWidgetAnnotationElement(parameters);
  18140. }
  18141. return new WidgetAnnotationElement(parameters);
  18142. case AnnotationType.POPUP:
  18143. return new PopupAnnotationElement(parameters);
  18144. case AnnotationType.HIGHLIGHT:
  18145. return new HighlightAnnotationElement(parameters);
  18146. case AnnotationType.UNDERLINE:
  18147. return new UnderlineAnnotationElement(parameters);
  18148. case AnnotationType.SQUIGGLY:
  18149. return new SquigglyAnnotationElement(parameters);
  18150. case AnnotationType.STRIKEOUT:
  18151. return new StrikeOutAnnotationElement(parameters);
  18152. case AnnotationType.FILEATTACHMENT:
  18153. return new FileAttachmentAnnotationElement(parameters);
  18154. default:
  18155. return new AnnotationElement(parameters);
  18156. }
  18157. }
  18158. };
  18159. var AnnotationElement = function AnnotationElementClosure() {
  18160. function AnnotationElement(parameters, isRenderable) {
  18161. this.isRenderable = isRenderable || false;
  18162. this.data = parameters.data;
  18163. this.layer = parameters.layer;
  18164. this.page = parameters.page;
  18165. this.viewport = parameters.viewport;
  18166. this.linkService = parameters.linkService;
  18167. this.downloadManager = parameters.downloadManager;
  18168. this.imageResourcesPath = parameters.imageResourcesPath;
  18169. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18170. if (isRenderable) {
  18171. this.container = this._createContainer();
  18172. }
  18173. }
  18174. AnnotationElement.prototype = {
  18175. _createContainer: function AnnotationElement_createContainer() {
  18176. var data = this.data, page = this.page, viewport = this.viewport;
  18177. var container = document.createElement('section');
  18178. var width = data.rect[2] - data.rect[0];
  18179. var height = data.rect[3] - data.rect[1];
  18180. container.setAttribute('data-annotation-id', data.id);
  18181. var rect = Util.normalizeRect([
  18182. data.rect[0],
  18183. page.view[3] - data.rect[1] + page.view[1],
  18184. data.rect[2],
  18185. page.view[3] - data.rect[3] + page.view[1]
  18186. ]);
  18187. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18188. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18189. if (data.borderStyle.width > 0) {
  18190. container.style.borderWidth = data.borderStyle.width + 'px';
  18191. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18192. width = width - 2 * data.borderStyle.width;
  18193. height = height - 2 * data.borderStyle.width;
  18194. }
  18195. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18196. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18197. if (horizontalRadius > 0 || verticalRadius > 0) {
  18198. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18199. CustomStyle.setProp('borderRadius', container, radius);
  18200. }
  18201. switch (data.borderStyle.style) {
  18202. case AnnotationBorderStyleType.SOLID:
  18203. container.style.borderStyle = 'solid';
  18204. break;
  18205. case AnnotationBorderStyleType.DASHED:
  18206. container.style.borderStyle = 'dashed';
  18207. break;
  18208. case AnnotationBorderStyleType.BEVELED:
  18209. warn('Unimplemented border style: beveled');
  18210. break;
  18211. case AnnotationBorderStyleType.INSET:
  18212. warn('Unimplemented border style: inset');
  18213. break;
  18214. case AnnotationBorderStyleType.UNDERLINE:
  18215. container.style.borderBottomStyle = 'solid';
  18216. break;
  18217. default:
  18218. break;
  18219. }
  18220. if (data.color) {
  18221. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18222. } else {
  18223. container.style.borderWidth = 0;
  18224. }
  18225. }
  18226. container.style.left = rect[0] + 'px';
  18227. container.style.top = rect[1] + 'px';
  18228. container.style.width = width + 'px';
  18229. container.style.height = height + 'px';
  18230. return container;
  18231. },
  18232. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  18233. if (!trigger) {
  18234. trigger = document.createElement('div');
  18235. trigger.style.height = container.style.height;
  18236. trigger.style.width = container.style.width;
  18237. container.appendChild(trigger);
  18238. }
  18239. var popupElement = new PopupElement({
  18240. container: container,
  18241. trigger: trigger,
  18242. color: data.color,
  18243. title: data.title,
  18244. contents: data.contents,
  18245. hideWrapper: true
  18246. });
  18247. var popup = popupElement.render();
  18248. popup.style.left = container.style.width;
  18249. container.appendChild(popup);
  18250. },
  18251. render: function AnnotationElement_render() {
  18252. throw new Error('Abstract method AnnotationElement.render called');
  18253. }
  18254. };
  18255. return AnnotationElement;
  18256. }();
  18257. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  18258. function LinkAnnotationElement(parameters) {
  18259. AnnotationElement.call(this, parameters, true);
  18260. }
  18261. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  18262. render: function LinkAnnotationElement_render() {
  18263. this.container.className = 'linkAnnotation';
  18264. var link = document.createElement('a');
  18265. addLinkAttributes(link, {
  18266. url: this.data.url,
  18267. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  18268. });
  18269. if (!this.data.url) {
  18270. if (this.data.action) {
  18271. this._bindNamedAction(link, this.data.action);
  18272. } else {
  18273. this._bindLink(link, this.data.dest);
  18274. }
  18275. }
  18276. this.container.appendChild(link);
  18277. return this.container;
  18278. },
  18279. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  18280. var self = this;
  18281. link.href = this.linkService.getDestinationHash(destination);
  18282. link.onclick = function () {
  18283. if (destination) {
  18284. self.linkService.navigateTo(destination);
  18285. }
  18286. return false;
  18287. };
  18288. if (destination) {
  18289. link.className = 'internalLink';
  18290. }
  18291. },
  18292. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  18293. var self = this;
  18294. link.href = this.linkService.getAnchorUrl('');
  18295. link.onclick = function () {
  18296. self.linkService.executeNamedAction(action);
  18297. return false;
  18298. };
  18299. link.className = 'internalLink';
  18300. }
  18301. });
  18302. return LinkAnnotationElement;
  18303. }();
  18304. var TextAnnotationElement = function TextAnnotationElementClosure() {
  18305. function TextAnnotationElement(parameters) {
  18306. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18307. AnnotationElement.call(this, parameters, isRenderable);
  18308. }
  18309. Util.inherit(TextAnnotationElement, AnnotationElement, {
  18310. render: function TextAnnotationElement_render() {
  18311. this.container.className = 'textAnnotation';
  18312. var image = document.createElement('img');
  18313. image.style.height = this.container.style.height;
  18314. image.style.width = this.container.style.width;
  18315. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  18316. image.alt = '[{{type}} Annotation]';
  18317. image.dataset.l10nId = 'text_annotation_type';
  18318. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  18319. if (!this.data.hasPopup) {
  18320. this._createPopup(this.container, image, this.data);
  18321. }
  18322. this.container.appendChild(image);
  18323. return this.container;
  18324. }
  18325. });
  18326. return TextAnnotationElement;
  18327. }();
  18328. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  18329. function WidgetAnnotationElement(parameters, isRenderable) {
  18330. AnnotationElement.call(this, parameters, isRenderable);
  18331. }
  18332. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  18333. render: function WidgetAnnotationElement_render() {
  18334. return this.container;
  18335. }
  18336. });
  18337. return WidgetAnnotationElement;
  18338. }();
  18339. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  18340. var TEXT_ALIGNMENT = [
  18341. 'left',
  18342. 'center',
  18343. 'right'
  18344. ];
  18345. function TextWidgetAnnotationElement(parameters) {
  18346. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18347. WidgetAnnotationElement.call(this, parameters, isRenderable);
  18348. }
  18349. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  18350. render: function TextWidgetAnnotationElement_render() {
  18351. this.container.className = 'textWidgetAnnotation';
  18352. var element = null;
  18353. if (this.renderInteractiveForms) {
  18354. if (this.data.multiLine) {
  18355. element = document.createElement('textarea');
  18356. element.textContent = this.data.fieldValue;
  18357. } else {
  18358. element = document.createElement('input');
  18359. element.type = 'text';
  18360. element.setAttribute('value', this.data.fieldValue);
  18361. }
  18362. element.disabled = this.data.readOnly;
  18363. if (this.data.maxLen !== null) {
  18364. element.maxLength = this.data.maxLen;
  18365. }
  18366. if (this.data.comb) {
  18367. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18368. var combWidth = fieldWidth / this.data.maxLen;
  18369. element.classList.add('comb');
  18370. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  18371. }
  18372. } else {
  18373. element = document.createElement('div');
  18374. element.textContent = this.data.fieldValue;
  18375. element.style.verticalAlign = 'middle';
  18376. element.style.display = 'table-cell';
  18377. var font = null;
  18378. if (this.data.fontRefName) {
  18379. font = this.page.commonObjs.getData(this.data.fontRefName);
  18380. }
  18381. this._setTextStyle(element, font);
  18382. }
  18383. if (this.data.textAlignment !== null) {
  18384. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18385. }
  18386. this.container.appendChild(element);
  18387. return this.container;
  18388. },
  18389. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  18390. var style = element.style;
  18391. style.fontSize = this.data.fontSize + 'px';
  18392. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  18393. if (!font) {
  18394. return;
  18395. }
  18396. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  18397. style.fontStyle = font.italic ? 'italic' : 'normal';
  18398. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  18399. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  18400. style.fontFamily = fontFamily + fallbackName;
  18401. }
  18402. });
  18403. return TextWidgetAnnotationElement;
  18404. }();
  18405. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  18406. function CheckboxWidgetAnnotationElement(parameters) {
  18407. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18408. }
  18409. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  18410. render: function CheckboxWidgetAnnotationElement_render() {
  18411. this.container.className = 'buttonWidgetAnnotation checkBox';
  18412. var element = document.createElement('input');
  18413. element.disabled = this.data.readOnly;
  18414. element.type = 'checkbox';
  18415. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  18416. element.setAttribute('checked', true);
  18417. }
  18418. this.container.appendChild(element);
  18419. return this.container;
  18420. }
  18421. });
  18422. return CheckboxWidgetAnnotationElement;
  18423. }();
  18424. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  18425. function RadioButtonWidgetAnnotationElement(parameters) {
  18426. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18427. }
  18428. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  18429. render: function RadioButtonWidgetAnnotationElement_render() {
  18430. this.container.className = 'buttonWidgetAnnotation radioButton';
  18431. var element = document.createElement('input');
  18432. element.disabled = this.data.readOnly;
  18433. element.type = 'radio';
  18434. element.name = this.data.fieldName;
  18435. if (this.data.fieldValue === this.data.buttonValue) {
  18436. element.setAttribute('checked', true);
  18437. }
  18438. this.container.appendChild(element);
  18439. return this.container;
  18440. }
  18441. });
  18442. return RadioButtonWidgetAnnotationElement;
  18443. }();
  18444. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  18445. function ChoiceWidgetAnnotationElement(parameters) {
  18446. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18447. }
  18448. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  18449. render: function ChoiceWidgetAnnotationElement_render() {
  18450. this.container.className = 'choiceWidgetAnnotation';
  18451. var selectElement = document.createElement('select');
  18452. selectElement.disabled = this.data.readOnly;
  18453. if (!this.data.combo) {
  18454. selectElement.size = this.data.options.length;
  18455. if (this.data.multiSelect) {
  18456. selectElement.multiple = true;
  18457. }
  18458. }
  18459. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  18460. var option = this.data.options[i];
  18461. var optionElement = document.createElement('option');
  18462. optionElement.textContent = option.displayValue;
  18463. optionElement.value = option.exportValue;
  18464. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  18465. optionElement.setAttribute('selected', true);
  18466. }
  18467. selectElement.appendChild(optionElement);
  18468. }
  18469. this.container.appendChild(selectElement);
  18470. return this.container;
  18471. }
  18472. });
  18473. return ChoiceWidgetAnnotationElement;
  18474. }();
  18475. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  18476. function PopupAnnotationElement(parameters) {
  18477. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18478. AnnotationElement.call(this, parameters, isRenderable);
  18479. }
  18480. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  18481. render: function PopupAnnotationElement_render() {
  18482. this.container.className = 'popupAnnotation';
  18483. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  18484. var parentElement = this.layer.querySelector(selector);
  18485. if (!parentElement) {
  18486. return this.container;
  18487. }
  18488. var popup = new PopupElement({
  18489. container: this.container,
  18490. trigger: parentElement,
  18491. color: this.data.color,
  18492. title: this.data.title,
  18493. contents: this.data.contents
  18494. });
  18495. var parentLeft = parseFloat(parentElement.style.left);
  18496. var parentWidth = parseFloat(parentElement.style.width);
  18497. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  18498. this.container.style.left = parentLeft + parentWidth + 'px';
  18499. this.container.appendChild(popup.render());
  18500. return this.container;
  18501. }
  18502. });
  18503. return PopupAnnotationElement;
  18504. }();
  18505. var PopupElement = function PopupElementClosure() {
  18506. var BACKGROUND_ENLIGHT = 0.7;
  18507. function PopupElement(parameters) {
  18508. this.container = parameters.container;
  18509. this.trigger = parameters.trigger;
  18510. this.color = parameters.color;
  18511. this.title = parameters.title;
  18512. this.contents = parameters.contents;
  18513. this.hideWrapper = parameters.hideWrapper || false;
  18514. this.pinned = false;
  18515. }
  18516. PopupElement.prototype = {
  18517. render: function PopupElement_render() {
  18518. var wrapper = document.createElement('div');
  18519. wrapper.className = 'popupWrapper';
  18520. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18521. this.hideElement.setAttribute('hidden', true);
  18522. var popup = document.createElement('div');
  18523. popup.className = 'popup';
  18524. var color = this.color;
  18525. if (color) {
  18526. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18527. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18528. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18529. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  18530. }
  18531. var contents = this._formatContents(this.contents);
  18532. var title = document.createElement('h1');
  18533. title.textContent = this.title;
  18534. this.trigger.addEventListener('click', this._toggle.bind(this));
  18535. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  18536. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  18537. popup.addEventListener('click', this._hide.bind(this, true));
  18538. popup.appendChild(title);
  18539. popup.appendChild(contents);
  18540. wrapper.appendChild(popup);
  18541. return wrapper;
  18542. },
  18543. _formatContents: function PopupElement_formatContents(contents) {
  18544. var p = document.createElement('p');
  18545. var lines = contents.split(/(?:\r\n?|\n)/);
  18546. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18547. var line = lines[i];
  18548. p.appendChild(document.createTextNode(line));
  18549. if (i < ii - 1) {
  18550. p.appendChild(document.createElement('br'));
  18551. }
  18552. }
  18553. return p;
  18554. },
  18555. _toggle: function PopupElement_toggle() {
  18556. if (this.pinned) {
  18557. this._hide(true);
  18558. } else {
  18559. this._show(true);
  18560. }
  18561. },
  18562. _show: function PopupElement_show(pin) {
  18563. if (pin) {
  18564. this.pinned = true;
  18565. }
  18566. if (this.hideElement.hasAttribute('hidden')) {
  18567. this.hideElement.removeAttribute('hidden');
  18568. this.container.style.zIndex += 1;
  18569. }
  18570. },
  18571. _hide: function PopupElement_hide(unpin) {
  18572. if (unpin) {
  18573. this.pinned = false;
  18574. }
  18575. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  18576. this.hideElement.setAttribute('hidden', true);
  18577. this.container.style.zIndex -= 1;
  18578. }
  18579. }
  18580. };
  18581. return PopupElement;
  18582. }();
  18583. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  18584. function HighlightAnnotationElement(parameters) {
  18585. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18586. AnnotationElement.call(this, parameters, isRenderable);
  18587. }
  18588. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  18589. render: function HighlightAnnotationElement_render() {
  18590. this.container.className = 'highlightAnnotation';
  18591. if (!this.data.hasPopup) {
  18592. this._createPopup(this.container, null, this.data);
  18593. }
  18594. return this.container;
  18595. }
  18596. });
  18597. return HighlightAnnotationElement;
  18598. }();
  18599. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  18600. function UnderlineAnnotationElement(parameters) {
  18601. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18602. AnnotationElement.call(this, parameters, isRenderable);
  18603. }
  18604. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  18605. render: function UnderlineAnnotationElement_render() {
  18606. this.container.className = 'underlineAnnotation';
  18607. if (!this.data.hasPopup) {
  18608. this._createPopup(this.container, null, this.data);
  18609. }
  18610. return this.container;
  18611. }
  18612. });
  18613. return UnderlineAnnotationElement;
  18614. }();
  18615. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  18616. function SquigglyAnnotationElement(parameters) {
  18617. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18618. AnnotationElement.call(this, parameters, isRenderable);
  18619. }
  18620. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  18621. render: function SquigglyAnnotationElement_render() {
  18622. this.container.className = 'squigglyAnnotation';
  18623. if (!this.data.hasPopup) {
  18624. this._createPopup(this.container, null, this.data);
  18625. }
  18626. return this.container;
  18627. }
  18628. });
  18629. return SquigglyAnnotationElement;
  18630. }();
  18631. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  18632. function StrikeOutAnnotationElement(parameters) {
  18633. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18634. AnnotationElement.call(this, parameters, isRenderable);
  18635. }
  18636. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  18637. render: function StrikeOutAnnotationElement_render() {
  18638. this.container.className = 'strikeoutAnnotation';
  18639. if (!this.data.hasPopup) {
  18640. this._createPopup(this.container, null, this.data);
  18641. }
  18642. return this.container;
  18643. }
  18644. });
  18645. return StrikeOutAnnotationElement;
  18646. }();
  18647. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  18648. function FileAttachmentAnnotationElement(parameters) {
  18649. AnnotationElement.call(this, parameters, true);
  18650. var file = this.data.file;
  18651. this.filename = getFilenameFromUrl(file.filename);
  18652. this.content = file.content;
  18653. this.linkService.onFileAttachmentAnnotation({
  18654. id: stringToPDFString(file.filename),
  18655. filename: file.filename,
  18656. content: file.content
  18657. });
  18658. }
  18659. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  18660. render: function FileAttachmentAnnotationElement_render() {
  18661. this.container.className = 'fileAttachmentAnnotation';
  18662. var trigger = document.createElement('div');
  18663. trigger.style.height = this.container.style.height;
  18664. trigger.style.width = this.container.style.width;
  18665. trigger.addEventListener('dblclick', this._download.bind(this));
  18666. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  18667. this._createPopup(this.container, trigger, this.data);
  18668. }
  18669. this.container.appendChild(trigger);
  18670. return this.container;
  18671. },
  18672. _download: function FileAttachmentAnnotationElement_download() {
  18673. if (!this.downloadManager) {
  18674. warn('Download cannot be started due to unavailable download manager');
  18675. return;
  18676. }
  18677. this.downloadManager.downloadData(this.content, this.filename, '');
  18678. }
  18679. });
  18680. return FileAttachmentAnnotationElement;
  18681. }();
  18682. var AnnotationLayer = function AnnotationLayerClosure() {
  18683. return {
  18684. render: function AnnotationLayer_render(parameters) {
  18685. var annotationElementFactory = new AnnotationElementFactory();
  18686. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18687. var data = parameters.annotations[i];
  18688. if (!data) {
  18689. continue;
  18690. }
  18691. var element = annotationElementFactory.create({
  18692. data: data,
  18693. layer: parameters.div,
  18694. page: parameters.page,
  18695. viewport: parameters.viewport,
  18696. linkService: parameters.linkService,
  18697. downloadManager: parameters.downloadManager,
  18698. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  18699. renderInteractiveForms: parameters.renderInteractiveForms || false
  18700. });
  18701. if (element.isRenderable) {
  18702. parameters.div.appendChild(element.render());
  18703. }
  18704. }
  18705. },
  18706. update: function AnnotationLayer_update(parameters) {
  18707. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18708. var data = parameters.annotations[i];
  18709. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  18710. if (element) {
  18711. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  18712. }
  18713. }
  18714. parameters.div.removeAttribute('hidden');
  18715. }
  18716. };
  18717. }();
  18718. exports.AnnotationLayer = AnnotationLayer;
  18719. /***/ }),
  18720. /* 10 */
  18721. /***/ (function(module, exports, __w_pdfjs_require__) {
  18722. "use strict";
  18723. var sharedUtil = __w_pdfjs_require__(0);
  18724. var displayFontLoader = __w_pdfjs_require__(45);
  18725. var displayCanvas = __w_pdfjs_require__(44);
  18726. var displayMetadata = __w_pdfjs_require__(24);
  18727. var displayDOMUtils = __w_pdfjs_require__(3);
  18728. var amdRequire;
  18729. var InvalidPDFException = sharedUtil.InvalidPDFException;
  18730. var MessageHandler = sharedUtil.MessageHandler;
  18731. var MissingPDFException = sharedUtil.MissingPDFException;
  18732. var PageViewport = sharedUtil.PageViewport;
  18733. var PasswordException = sharedUtil.PasswordException;
  18734. var StatTimer = sharedUtil.StatTimer;
  18735. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  18736. var UnknownErrorException = sharedUtil.UnknownErrorException;
  18737. var Util = sharedUtil.Util;
  18738. var createPromiseCapability = sharedUtil.createPromiseCapability;
  18739. var error = sharedUtil.error;
  18740. var deprecated = sharedUtil.deprecated;
  18741. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  18742. var info = sharedUtil.info;
  18743. var isInt = sharedUtil.isInt;
  18744. var isArray = sharedUtil.isArray;
  18745. var isArrayBuffer = sharedUtil.isArrayBuffer;
  18746. var isSameOrigin = sharedUtil.isSameOrigin;
  18747. var loadJpegStream = sharedUtil.loadJpegStream;
  18748. var stringToBytes = sharedUtil.stringToBytes;
  18749. var globalScope = sharedUtil.globalScope;
  18750. var warn = sharedUtil.warn;
  18751. var FontFaceObject = displayFontLoader.FontFaceObject;
  18752. var FontLoader = displayFontLoader.FontLoader;
  18753. var CanvasGraphics = displayCanvas.CanvasGraphics;
  18754. var Metadata = displayMetadata.Metadata;
  18755. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18756. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  18757. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  18758. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  18759. var isWorkerDisabled = false;
  18760. var workerSrc;
  18761. var isPostMessageTransfersDisabled = false;
  18762. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  18763. var fakeWorkerFilesLoader = null;
  18764. var useRequireEnsure = false;
  18765. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  18766. var task = new PDFDocumentLoadingTask();
  18767. if (arguments.length > 1) {
  18768. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  18769. }
  18770. if (pdfDataRangeTransport) {
  18771. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  18772. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  18773. pdfDataRangeTransport.length = src.length;
  18774. pdfDataRangeTransport.initialData = src.initialData;
  18775. if (!pdfDataRangeTransport.abort) {
  18776. pdfDataRangeTransport.abort = function () {
  18777. };
  18778. }
  18779. }
  18780. src = Object.create(src);
  18781. src.range = pdfDataRangeTransport;
  18782. }
  18783. task.onPassword = passwordCallback || null;
  18784. task.onProgress = progressCallback || null;
  18785. var source;
  18786. if (typeof src === 'string') {
  18787. source = { url: src };
  18788. } else if (isArrayBuffer(src)) {
  18789. source = { data: src };
  18790. } else if (src instanceof PDFDataRangeTransport) {
  18791. source = { range: src };
  18792. } else {
  18793. if (typeof src !== 'object') {
  18794. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  18795. }
  18796. if (!src.url && !src.data && !src.range) {
  18797. error('Invalid parameter object: need either .data, .range or .url');
  18798. }
  18799. source = src;
  18800. }
  18801. var params = {};
  18802. var rangeTransport = null;
  18803. var worker = null;
  18804. for (var key in source) {
  18805. if (key === 'url' && typeof window !== 'undefined') {
  18806. params[key] = new URL(source[key], window.location).href;
  18807. continue;
  18808. } else if (key === 'range') {
  18809. rangeTransport = source[key];
  18810. continue;
  18811. } else if (key === 'worker') {
  18812. worker = source[key];
  18813. continue;
  18814. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  18815. var pdfBytes = source[key];
  18816. if (typeof pdfBytes === 'string') {
  18817. params[key] = stringToBytes(pdfBytes);
  18818. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  18819. params[key] = new Uint8Array(pdfBytes);
  18820. } else if (isArrayBuffer(pdfBytes)) {
  18821. params[key] = new Uint8Array(pdfBytes);
  18822. } else {
  18823. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  18824. }
  18825. continue;
  18826. }
  18827. params[key] = source[key];
  18828. }
  18829. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  18830. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  18831. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  18832. if (!worker) {
  18833. worker = new PDFWorker();
  18834. task._worker = worker;
  18835. }
  18836. var docId = task.docId;
  18837. worker.promise.then(function () {
  18838. if (task.destroyed) {
  18839. throw new Error('Loading aborted');
  18840. }
  18841. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  18842. if (task.destroyed) {
  18843. throw new Error('Loading aborted');
  18844. }
  18845. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  18846. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  18847. task._transport = transport;
  18848. messageHandler.send('Ready', null);
  18849. });
  18850. }).catch(task._capability.reject);
  18851. return task;
  18852. }
  18853. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  18854. if (worker.destroyed) {
  18855. return Promise.reject(new Error('Worker was destroyed'));
  18856. }
  18857. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  18858. source.disableStream = getDefaultSetting('disableStream');
  18859. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  18860. if (pdfDataRangeTransport) {
  18861. source.length = pdfDataRangeTransport.length;
  18862. source.initialData = pdfDataRangeTransport.initialData;
  18863. }
  18864. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  18865. docId: docId,
  18866. source: source,
  18867. disableRange: getDefaultSetting('disableRange'),
  18868. maxImageSize: getDefaultSetting('maxImageSize'),
  18869. disableFontFace: getDefaultSetting('disableFontFace'),
  18870. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  18871. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  18872. docBaseUrl: source.docBaseUrl,
  18873. disableNativeImageDecoder: source.disableNativeImageDecoder
  18874. }).then(function (workerId) {
  18875. if (worker.destroyed) {
  18876. throw new Error('Worker was destroyed');
  18877. }
  18878. return workerId;
  18879. });
  18880. }
  18881. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  18882. var nextDocumentId = 0;
  18883. function PDFDocumentLoadingTask() {
  18884. this._capability = createPromiseCapability();
  18885. this._transport = null;
  18886. this._worker = null;
  18887. this.docId = 'd' + nextDocumentId++;
  18888. this.destroyed = false;
  18889. this.onPassword = null;
  18890. this.onProgress = null;
  18891. this.onUnsupportedFeature = null;
  18892. }
  18893. PDFDocumentLoadingTask.prototype = {
  18894. get promise() {
  18895. return this._capability.promise;
  18896. },
  18897. destroy: function () {
  18898. this.destroyed = true;
  18899. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  18900. return transportDestroyed.then(function () {
  18901. this._transport = null;
  18902. if (this._worker) {
  18903. this._worker.destroy();
  18904. this._worker = null;
  18905. }
  18906. }.bind(this));
  18907. },
  18908. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  18909. return this.promise.then.apply(this.promise, arguments);
  18910. }
  18911. };
  18912. return PDFDocumentLoadingTask;
  18913. }();
  18914. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  18915. function PDFDataRangeTransport(length, initialData) {
  18916. this.length = length;
  18917. this.initialData = initialData;
  18918. this._rangeListeners = [];
  18919. this._progressListeners = [];
  18920. this._progressiveReadListeners = [];
  18921. this._readyCapability = createPromiseCapability();
  18922. }
  18923. PDFDataRangeTransport.prototype = {
  18924. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  18925. this._rangeListeners.push(listener);
  18926. },
  18927. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  18928. this._progressListeners.push(listener);
  18929. },
  18930. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  18931. this._progressiveReadListeners.push(listener);
  18932. },
  18933. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  18934. var listeners = this._rangeListeners;
  18935. for (var i = 0, n = listeners.length; i < n; ++i) {
  18936. listeners[i](begin, chunk);
  18937. }
  18938. },
  18939. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  18940. this._readyCapability.promise.then(function () {
  18941. var listeners = this._progressListeners;
  18942. for (var i = 0, n = listeners.length; i < n; ++i) {
  18943. listeners[i](loaded);
  18944. }
  18945. }.bind(this));
  18946. },
  18947. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  18948. this._readyCapability.promise.then(function () {
  18949. var listeners = this._progressiveReadListeners;
  18950. for (var i = 0, n = listeners.length; i < n; ++i) {
  18951. listeners[i](chunk);
  18952. }
  18953. }.bind(this));
  18954. },
  18955. transportReady: function PDFDataRangeTransport_transportReady() {
  18956. this._readyCapability.resolve();
  18957. },
  18958. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  18959. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  18960. },
  18961. abort: function PDFDataRangeTransport_abort() {
  18962. }
  18963. };
  18964. return PDFDataRangeTransport;
  18965. }();
  18966. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  18967. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  18968. this.pdfInfo = pdfInfo;
  18969. this.transport = transport;
  18970. this.loadingTask = loadingTask;
  18971. }
  18972. PDFDocumentProxy.prototype = {
  18973. get numPages() {
  18974. return this.pdfInfo.numPages;
  18975. },
  18976. get fingerprint() {
  18977. return this.pdfInfo.fingerprint;
  18978. },
  18979. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  18980. return this.transport.getPage(pageNumber);
  18981. },
  18982. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  18983. return this.transport.getPageIndex(ref);
  18984. },
  18985. getDestinations: function PDFDocumentProxy_getDestinations() {
  18986. return this.transport.getDestinations();
  18987. },
  18988. getDestination: function PDFDocumentProxy_getDestination(id) {
  18989. return this.transport.getDestination(id);
  18990. },
  18991. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  18992. return this.transport.getPageLabels();
  18993. },
  18994. getAttachments: function PDFDocumentProxy_getAttachments() {
  18995. return this.transport.getAttachments();
  18996. },
  18997. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  18998. return this.transport.getJavaScript();
  18999. },
  19000. getOutline: function PDFDocumentProxy_getOutline() {
  19001. return this.transport.getOutline();
  19002. },
  19003. getMetadata: function PDFDocumentProxy_getMetadata() {
  19004. return this.transport.getMetadata();
  19005. },
  19006. getData: function PDFDocumentProxy_getData() {
  19007. return this.transport.getData();
  19008. },
  19009. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19010. return this.transport.downloadInfoCapability.promise;
  19011. },
  19012. getStats: function PDFDocumentProxy_getStats() {
  19013. return this.transport.getStats();
  19014. },
  19015. cleanup: function PDFDocumentProxy_cleanup() {
  19016. this.transport.startCleanup();
  19017. },
  19018. destroy: function PDFDocumentProxy_destroy() {
  19019. return this.loadingTask.destroy();
  19020. }
  19021. };
  19022. return PDFDocumentProxy;
  19023. }();
  19024. var PDFPageProxy = function PDFPageProxyClosure() {
  19025. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19026. this.pageIndex = pageIndex;
  19027. this.pageInfo = pageInfo;
  19028. this.transport = transport;
  19029. this.stats = new StatTimer();
  19030. this.stats.enabled = getDefaultSetting('enableStats');
  19031. this.commonObjs = transport.commonObjs;
  19032. this.objs = new PDFObjects();
  19033. this.cleanupAfterRender = false;
  19034. this.pendingCleanup = false;
  19035. this.intentStates = Object.create(null);
  19036. this.destroyed = false;
  19037. }
  19038. PDFPageProxy.prototype = {
  19039. get pageNumber() {
  19040. return this.pageIndex + 1;
  19041. },
  19042. get rotate() {
  19043. return this.pageInfo.rotate;
  19044. },
  19045. get ref() {
  19046. return this.pageInfo.ref;
  19047. },
  19048. get userUnit() {
  19049. return this.pageInfo.userUnit;
  19050. },
  19051. get view() {
  19052. return this.pageInfo.view;
  19053. },
  19054. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19055. if (arguments.length < 2) {
  19056. rotate = this.rotate;
  19057. }
  19058. return new PageViewport(this.view, scale, rotate, 0, 0);
  19059. },
  19060. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19061. var intent = params && params.intent || null;
  19062. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19063. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19064. this.annotationsIntent = intent;
  19065. }
  19066. return this.annotationsPromise;
  19067. },
  19068. render: function PDFPageProxy_render(params) {
  19069. var stats = this.stats;
  19070. stats.time('Overall');
  19071. this.pendingCleanup = false;
  19072. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19073. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19074. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19075. if (!this.intentStates[renderingIntent]) {
  19076. this.intentStates[renderingIntent] = Object.create(null);
  19077. }
  19078. var intentState = this.intentStates[renderingIntent];
  19079. if (!intentState.displayReadyCapability) {
  19080. intentState.receivingOperatorList = true;
  19081. intentState.displayReadyCapability = createPromiseCapability();
  19082. intentState.operatorList = {
  19083. fnArray: [],
  19084. argsArray: [],
  19085. lastChunk: false
  19086. };
  19087. this.stats.time('Page Request');
  19088. this.transport.messageHandler.send('RenderPageRequest', {
  19089. pageIndex: this.pageNumber - 1,
  19090. intent: renderingIntent,
  19091. renderInteractiveForms: renderInteractiveForms
  19092. });
  19093. }
  19094. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19095. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19096. if (!intentState.renderTasks) {
  19097. intentState.renderTasks = [];
  19098. }
  19099. intentState.renderTasks.push(internalRenderTask);
  19100. var renderTask = internalRenderTask.task;
  19101. if (params.continueCallback) {
  19102. deprecated('render is used with continueCallback parameter');
  19103. renderTask.onContinue = params.continueCallback;
  19104. }
  19105. var self = this;
  19106. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19107. if (self.pendingCleanup) {
  19108. complete();
  19109. return;
  19110. }
  19111. stats.time('Rendering');
  19112. internalRenderTask.initializeGraphics(transparency);
  19113. internalRenderTask.operatorListChanged();
  19114. }, function pageDisplayReadPromiseError(reason) {
  19115. complete(reason);
  19116. });
  19117. function complete(error) {
  19118. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19119. if (i >= 0) {
  19120. intentState.renderTasks.splice(i, 1);
  19121. }
  19122. if (self.cleanupAfterRender) {
  19123. self.pendingCleanup = true;
  19124. }
  19125. self._tryCleanup();
  19126. if (error) {
  19127. internalRenderTask.capability.reject(error);
  19128. } else {
  19129. internalRenderTask.capability.resolve();
  19130. }
  19131. stats.timeEnd('Rendering');
  19132. stats.timeEnd('Overall');
  19133. }
  19134. return renderTask;
  19135. },
  19136. getOperatorList: function PDFPageProxy_getOperatorList() {
  19137. function operatorListChanged() {
  19138. if (intentState.operatorList.lastChunk) {
  19139. intentState.opListReadCapability.resolve(intentState.operatorList);
  19140. var i = intentState.renderTasks.indexOf(opListTask);
  19141. if (i >= 0) {
  19142. intentState.renderTasks.splice(i, 1);
  19143. }
  19144. }
  19145. }
  19146. var renderingIntent = 'oplist';
  19147. if (!this.intentStates[renderingIntent]) {
  19148. this.intentStates[renderingIntent] = Object.create(null);
  19149. }
  19150. var intentState = this.intentStates[renderingIntent];
  19151. var opListTask;
  19152. if (!intentState.opListReadCapability) {
  19153. opListTask = {};
  19154. opListTask.operatorListChanged = operatorListChanged;
  19155. intentState.receivingOperatorList = true;
  19156. intentState.opListReadCapability = createPromiseCapability();
  19157. intentState.renderTasks = [];
  19158. intentState.renderTasks.push(opListTask);
  19159. intentState.operatorList = {
  19160. fnArray: [],
  19161. argsArray: [],
  19162. lastChunk: false
  19163. };
  19164. this.transport.messageHandler.send('RenderPageRequest', {
  19165. pageIndex: this.pageIndex,
  19166. intent: renderingIntent
  19167. });
  19168. }
  19169. return intentState.opListReadCapability.promise;
  19170. },
  19171. getTextContent: function PDFPageProxy_getTextContent(params) {
  19172. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19173. pageIndex: this.pageNumber - 1,
  19174. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19175. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19176. });
  19177. },
  19178. _destroy: function PDFPageProxy_destroy() {
  19179. this.destroyed = true;
  19180. this.transport.pageCache[this.pageIndex] = null;
  19181. var waitOn = [];
  19182. Object.keys(this.intentStates).forEach(function (intent) {
  19183. if (intent === 'oplist') {
  19184. return;
  19185. }
  19186. var intentState = this.intentStates[intent];
  19187. intentState.renderTasks.forEach(function (renderTask) {
  19188. var renderCompleted = renderTask.capability.promise.catch(function () {
  19189. });
  19190. waitOn.push(renderCompleted);
  19191. renderTask.cancel();
  19192. });
  19193. }, this);
  19194. this.objs.clear();
  19195. this.annotationsPromise = null;
  19196. this.pendingCleanup = false;
  19197. return Promise.all(waitOn);
  19198. },
  19199. destroy: function () {
  19200. deprecated('page destroy method, use cleanup() instead');
  19201. this.cleanup();
  19202. },
  19203. cleanup: function PDFPageProxy_cleanup() {
  19204. this.pendingCleanup = true;
  19205. this._tryCleanup();
  19206. },
  19207. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19208. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19209. var intentState = this.intentStates[intent];
  19210. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19211. }, this)) {
  19212. return;
  19213. }
  19214. Object.keys(this.intentStates).forEach(function (intent) {
  19215. delete this.intentStates[intent];
  19216. }, this);
  19217. this.objs.clear();
  19218. this.annotationsPromise = null;
  19219. this.pendingCleanup = false;
  19220. },
  19221. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19222. var intentState = this.intentStates[intent];
  19223. if (intentState.displayReadyCapability) {
  19224. intentState.displayReadyCapability.resolve(transparency);
  19225. }
  19226. },
  19227. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  19228. var intentState = this.intentStates[intent];
  19229. var i, ii;
  19230. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  19231. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  19232. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  19233. }
  19234. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  19235. for (i = 0; i < intentState.renderTasks.length; i++) {
  19236. intentState.renderTasks[i].operatorListChanged();
  19237. }
  19238. if (operatorListChunk.lastChunk) {
  19239. intentState.receivingOperatorList = false;
  19240. this._tryCleanup();
  19241. }
  19242. }
  19243. };
  19244. return PDFPageProxy;
  19245. }();
  19246. var PDFWorker = function PDFWorkerClosure() {
  19247. var nextFakeWorkerId = 0;
  19248. function getWorkerSrc() {
  19249. if (typeof workerSrc !== 'undefined') {
  19250. return workerSrc;
  19251. }
  19252. if (getDefaultSetting('workerSrc')) {
  19253. return getDefaultSetting('workerSrc');
  19254. }
  19255. if (pdfjsFilePath) {
  19256. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  19257. }
  19258. error('No PDFJS.workerSrc specified');
  19259. }
  19260. var fakeWorkerFilesLoadedCapability;
  19261. function setupFakeWorkerGlobal() {
  19262. var WorkerMessageHandler;
  19263. if (fakeWorkerFilesLoadedCapability) {
  19264. return fakeWorkerFilesLoadedCapability.promise;
  19265. }
  19266. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  19267. var pdfjsCoreWorker = __w_pdfjs_require__(23);
  19268. __w_pdfjs_require__(39);
  19269. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  19270. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  19271. return fakeWorkerFilesLoadedCapability.promise;
  19272. }
  19273. function FakeWorkerPort(defer) {
  19274. this._listeners = [];
  19275. this._defer = defer;
  19276. this._deferred = Promise.resolve(undefined);
  19277. }
  19278. FakeWorkerPort.prototype = {
  19279. postMessage: function (obj, transfers) {
  19280. function cloneValue(value) {
  19281. if (typeof value !== 'object' || value === null) {
  19282. return value;
  19283. }
  19284. if (cloned.has(value)) {
  19285. return cloned.get(value);
  19286. }
  19287. var result;
  19288. var buffer;
  19289. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  19290. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  19291. if (value === buffer) {
  19292. result = value;
  19293. } else if (transferable) {
  19294. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  19295. } else {
  19296. result = new value.constructor(value);
  19297. }
  19298. cloned.set(value, result);
  19299. return result;
  19300. }
  19301. result = isArray(value) ? [] : {};
  19302. cloned.set(value, result);
  19303. for (var i in value) {
  19304. var desc, p = value;
  19305. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  19306. p = Object.getPrototypeOf(p);
  19307. }
  19308. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  19309. continue;
  19310. }
  19311. result[i] = cloneValue(desc.value);
  19312. }
  19313. return result;
  19314. }
  19315. if (!this._defer) {
  19316. this._listeners.forEach(function (listener) {
  19317. listener.call(this, { data: obj });
  19318. }, this);
  19319. return;
  19320. }
  19321. var cloned = new WeakMap();
  19322. var e = { data: cloneValue(obj) };
  19323. this._deferred.then(function () {
  19324. this._listeners.forEach(function (listener) {
  19325. listener.call(this, e);
  19326. }, this);
  19327. }.bind(this));
  19328. },
  19329. addEventListener: function (name, listener) {
  19330. this._listeners.push(listener);
  19331. },
  19332. removeEventListener: function (name, listener) {
  19333. var i = this._listeners.indexOf(listener);
  19334. this._listeners.splice(i, 1);
  19335. },
  19336. terminate: function () {
  19337. this._listeners = [];
  19338. }
  19339. };
  19340. function createCDNWrapper(url) {
  19341. var wrapper = 'importScripts(\'' + url + '\');';
  19342. return URL.createObjectURL(new Blob([wrapper]));
  19343. }
  19344. function PDFWorker(name) {
  19345. this.name = name;
  19346. this.destroyed = false;
  19347. this._readyCapability = createPromiseCapability();
  19348. this._port = null;
  19349. this._webWorker = null;
  19350. this._messageHandler = null;
  19351. this._initialize();
  19352. }
  19353. PDFWorker.prototype = {
  19354. get promise() {
  19355. return this._readyCapability.promise;
  19356. },
  19357. get port() {
  19358. return this._port;
  19359. },
  19360. get messageHandler() {
  19361. return this._messageHandler;
  19362. },
  19363. _initialize: function PDFWorker_initialize() {
  19364. this._setupFakeWorker();
  19365. },
  19366. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  19367. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  19368. warn('Setting up fake worker.');
  19369. isWorkerDisabled = true;
  19370. }
  19371. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  19372. if (this.destroyed) {
  19373. this._readyCapability.reject(new Error('Worker was destroyed'));
  19374. return;
  19375. }
  19376. var isTypedArraysPresent = Uint8Array !== Float32Array;
  19377. var port = new FakeWorkerPort(isTypedArraysPresent);
  19378. this._port = port;
  19379. var id = 'fake' + nextFakeWorkerId++;
  19380. var workerHandler = new MessageHandler(id + '_worker', id, port);
  19381. WorkerMessageHandler.setup(workerHandler, port);
  19382. var messageHandler = new MessageHandler(id, id + '_worker', port);
  19383. this._messageHandler = messageHandler;
  19384. this._readyCapability.resolve();
  19385. }.bind(this));
  19386. },
  19387. destroy: function PDFWorker_destroy() {
  19388. this.destroyed = true;
  19389. if (this._webWorker) {
  19390. this._webWorker.terminate();
  19391. this._webWorker = null;
  19392. }
  19393. this._port = null;
  19394. if (this._messageHandler) {
  19395. this._messageHandler.destroy();
  19396. this._messageHandler = null;
  19397. }
  19398. }
  19399. };
  19400. return PDFWorker;
  19401. }();
  19402. var WorkerTransport = function WorkerTransportClosure() {
  19403. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  19404. this.messageHandler = messageHandler;
  19405. this.loadingTask = loadingTask;
  19406. this.pdfDataRangeTransport = pdfDataRangeTransport;
  19407. this.commonObjs = new PDFObjects();
  19408. this.fontLoader = new FontLoader(loadingTask.docId);
  19409. this.CMapReaderFactory = new CMapReaderFactory({
  19410. baseUrl: getDefaultSetting('cMapUrl'),
  19411. isCompressed: getDefaultSetting('cMapPacked')
  19412. });
  19413. this.destroyed = false;
  19414. this.destroyCapability = null;
  19415. this._passwordCapability = null;
  19416. this.pageCache = [];
  19417. this.pagePromises = [];
  19418. this.downloadInfoCapability = createPromiseCapability();
  19419. this.setupMessageHandler();
  19420. }
  19421. WorkerTransport.prototype = {
  19422. destroy: function WorkerTransport_destroy() {
  19423. if (this.destroyCapability) {
  19424. return this.destroyCapability.promise;
  19425. }
  19426. this.destroyed = true;
  19427. this.destroyCapability = createPromiseCapability();
  19428. if (this._passwordCapability) {
  19429. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  19430. }
  19431. var waitOn = [];
  19432. this.pageCache.forEach(function (page) {
  19433. if (page) {
  19434. waitOn.push(page._destroy());
  19435. }
  19436. });
  19437. this.pageCache = [];
  19438. this.pagePromises = [];
  19439. var self = this;
  19440. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  19441. waitOn.push(terminated);
  19442. Promise.all(waitOn).then(function () {
  19443. self.fontLoader.clear();
  19444. if (self.pdfDataRangeTransport) {
  19445. self.pdfDataRangeTransport.abort();
  19446. self.pdfDataRangeTransport = null;
  19447. }
  19448. if (self.messageHandler) {
  19449. self.messageHandler.destroy();
  19450. self.messageHandler = null;
  19451. }
  19452. self.destroyCapability.resolve();
  19453. }, this.destroyCapability.reject);
  19454. return this.destroyCapability.promise;
  19455. },
  19456. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  19457. var messageHandler = this.messageHandler;
  19458. var loadingTask = this.loadingTask;
  19459. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  19460. if (pdfDataRangeTransport) {
  19461. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  19462. messageHandler.send('OnDataRange', {
  19463. begin: begin,
  19464. chunk: chunk
  19465. });
  19466. });
  19467. pdfDataRangeTransport.addProgressListener(function (loaded) {
  19468. messageHandler.send('OnDataProgress', { loaded: loaded });
  19469. });
  19470. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  19471. messageHandler.send('OnDataRange', { chunk: chunk });
  19472. });
  19473. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  19474. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  19475. }, this);
  19476. }
  19477. messageHandler.on('GetDoc', function transportDoc(data) {
  19478. var pdfInfo = data.pdfInfo;
  19479. this.numPages = data.pdfInfo.numPages;
  19480. var loadingTask = this.loadingTask;
  19481. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  19482. this.pdfDocument = pdfDocument;
  19483. loadingTask._capability.resolve(pdfDocument);
  19484. }, this);
  19485. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  19486. this._passwordCapability = createPromiseCapability();
  19487. if (loadingTask.onPassword) {
  19488. var updatePassword = function (password) {
  19489. this._passwordCapability.resolve({ password: password });
  19490. }.bind(this);
  19491. loadingTask.onPassword(updatePassword, exception.code);
  19492. } else {
  19493. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  19494. }
  19495. return this._passwordCapability.promise;
  19496. }, this);
  19497. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  19498. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  19499. }, this);
  19500. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  19501. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  19502. }, this);
  19503. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  19504. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  19505. }, this);
  19506. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  19507. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  19508. }, this);
  19509. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  19510. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  19511. }, this);
  19512. messageHandler.on('DataLoaded', function transportPage(data) {
  19513. this.downloadInfoCapability.resolve(data);
  19514. }, this);
  19515. messageHandler.on('PDFManagerReady', function transportPage(data) {
  19516. if (this.pdfDataRangeTransport) {
  19517. this.pdfDataRangeTransport.transportReady();
  19518. }
  19519. }, this);
  19520. messageHandler.on('StartRenderPage', function transportRender(data) {
  19521. if (this.destroyed) {
  19522. return;
  19523. }
  19524. var page = this.pageCache[data.pageIndex];
  19525. page.stats.timeEnd('Page Request');
  19526. page._startRenderPage(data.transparency, data.intent);
  19527. }, this);
  19528. messageHandler.on('RenderPageChunk', function transportRender(data) {
  19529. if (this.destroyed) {
  19530. return;
  19531. }
  19532. var page = this.pageCache[data.pageIndex];
  19533. page._renderPageChunk(data.operatorList, data.intent);
  19534. }, this);
  19535. messageHandler.on('commonobj', function transportObj(data) {
  19536. if (this.destroyed) {
  19537. return;
  19538. }
  19539. var id = data[0];
  19540. var type = data[1];
  19541. if (this.commonObjs.hasData(id)) {
  19542. return;
  19543. }
  19544. switch (type) {
  19545. case 'Font':
  19546. var exportedData = data[2];
  19547. if ('error' in exportedData) {
  19548. var exportedError = exportedData.error;
  19549. warn('Error during font loading: ' + exportedError);
  19550. this.commonObjs.resolve(id, exportedError);
  19551. break;
  19552. }
  19553. var fontRegistry = null;
  19554. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  19555. fontRegistry = {
  19556. registerFont: function (font, url) {
  19557. globalScope['FontInspector'].fontAdded(font, url);
  19558. }
  19559. };
  19560. }
  19561. var font = new FontFaceObject(exportedData, {
  19562. isEvalSuported: getDefaultSetting('isEvalSupported'),
  19563. disableFontFace: getDefaultSetting('disableFontFace'),
  19564. fontRegistry: fontRegistry
  19565. });
  19566. this.fontLoader.bind([font], function fontReady(fontObjs) {
  19567. this.commonObjs.resolve(id, font);
  19568. }.bind(this));
  19569. break;
  19570. case 'FontPath':
  19571. this.commonObjs.resolve(id, data[2]);
  19572. break;
  19573. default:
  19574. error('Got unknown common object type ' + type);
  19575. }
  19576. }, this);
  19577. messageHandler.on('obj', function transportObj(data) {
  19578. if (this.destroyed) {
  19579. return;
  19580. }
  19581. var id = data[0];
  19582. var pageIndex = data[1];
  19583. var type = data[2];
  19584. var pageProxy = this.pageCache[pageIndex];
  19585. var imageData;
  19586. if (pageProxy.objs.hasData(id)) {
  19587. return;
  19588. }
  19589. switch (type) {
  19590. case 'JpegStream':
  19591. imageData = data[3];
  19592. loadJpegStream(id, imageData, pageProxy.objs);
  19593. break;
  19594. case 'Image':
  19595. imageData = data[3];
  19596. pageProxy.objs.resolve(id, imageData);
  19597. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  19598. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  19599. pageProxy.cleanupAfterRender = true;
  19600. }
  19601. break;
  19602. default:
  19603. error('Got unknown object type ' + type);
  19604. }
  19605. }, this);
  19606. messageHandler.on('DocProgress', function transportDocProgress(data) {
  19607. if (this.destroyed) {
  19608. return;
  19609. }
  19610. var loadingTask = this.loadingTask;
  19611. if (loadingTask.onProgress) {
  19612. loadingTask.onProgress({
  19613. loaded: data.loaded,
  19614. total: data.total
  19615. });
  19616. }
  19617. }, this);
  19618. messageHandler.on('PageError', function transportError(data) {
  19619. if (this.destroyed) {
  19620. return;
  19621. }
  19622. var page = this.pageCache[data.pageNum - 1];
  19623. var intentState = page.intentStates[data.intent];
  19624. if (intentState.displayReadyCapability) {
  19625. intentState.displayReadyCapability.reject(data.error);
  19626. } else {
  19627. error(data.error);
  19628. }
  19629. if (intentState.operatorList) {
  19630. intentState.operatorList.lastChunk = true;
  19631. for (var i = 0; i < intentState.renderTasks.length; i++) {
  19632. intentState.renderTasks[i].operatorListChanged();
  19633. }
  19634. }
  19635. }, this);
  19636. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  19637. if (this.destroyed) {
  19638. return;
  19639. }
  19640. var featureId = data.featureId;
  19641. var loadingTask = this.loadingTask;
  19642. if (loadingTask.onUnsupportedFeature) {
  19643. loadingTask.onUnsupportedFeature(featureId);
  19644. }
  19645. _UnsupportedManager.notify(featureId);
  19646. }, this);
  19647. messageHandler.on('JpegDecode', function (data) {
  19648. if (this.destroyed) {
  19649. return Promise.reject(new Error('Worker was destroyed'));
  19650. }
  19651. if (typeof document === 'undefined') {
  19652. return Promise.reject(new Error('"document" is not defined.'));
  19653. }
  19654. var imageUrl = data[0];
  19655. var components = data[1];
  19656. if (components !== 3 && components !== 1) {
  19657. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  19658. }
  19659. return new Promise(function (resolve, reject) {
  19660. var img = new Image();
  19661. img.onload = function () {
  19662. var width = img.width;
  19663. var height = img.height;
  19664. var size = width * height;
  19665. var rgbaLength = size * 4;
  19666. var buf = new Uint8Array(size * components);
  19667. var tmpCanvas = document.createElement('canvas');
  19668. tmpCanvas.width = width;
  19669. tmpCanvas.height = height;
  19670. var tmpCtx = tmpCanvas.getContext('2d');
  19671. tmpCtx.drawImage(img, 0, 0);
  19672. var data = tmpCtx.getImageData(0, 0, width, height).data;
  19673. var i, j;
  19674. if (components === 3) {
  19675. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  19676. buf[j] = data[i];
  19677. buf[j + 1] = data[i + 1];
  19678. buf[j + 2] = data[i + 2];
  19679. }
  19680. } else if (components === 1) {
  19681. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  19682. buf[j] = data[i];
  19683. }
  19684. }
  19685. resolve({
  19686. data: buf,
  19687. width: width,
  19688. height: height
  19689. });
  19690. };
  19691. img.onerror = function () {
  19692. reject(new Error('JpegDecode failed to load image'));
  19693. };
  19694. img.src = imageUrl;
  19695. });
  19696. }, this);
  19697. messageHandler.on('FetchBuiltInCMap', function (data) {
  19698. if (this.destroyed) {
  19699. return Promise.reject(new Error('Worker was destroyed'));
  19700. }
  19701. return this.CMapReaderFactory.fetch({ name: data.name });
  19702. }, this);
  19703. },
  19704. getData: function WorkerTransport_getData() {
  19705. return this.messageHandler.sendWithPromise('GetData', null);
  19706. },
  19707. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  19708. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  19709. return Promise.reject(new Error('Invalid page request'));
  19710. }
  19711. var pageIndex = pageNumber - 1;
  19712. if (pageIndex in this.pagePromises) {
  19713. return this.pagePromises[pageIndex];
  19714. }
  19715. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  19716. if (this.destroyed) {
  19717. throw new Error('Transport destroyed');
  19718. }
  19719. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  19720. this.pageCache[pageIndex] = page;
  19721. return page;
  19722. }.bind(this));
  19723. this.pagePromises[pageIndex] = promise;
  19724. return promise;
  19725. },
  19726. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  19727. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  19728. return Promise.reject(new Error(reason));
  19729. });
  19730. },
  19731. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  19732. return this.messageHandler.sendWithPromise('GetAnnotations', {
  19733. pageIndex: pageIndex,
  19734. intent: intent
  19735. });
  19736. },
  19737. getDestinations: function WorkerTransport_getDestinations() {
  19738. return this.messageHandler.sendWithPromise('GetDestinations', null);
  19739. },
  19740. getDestination: function WorkerTransport_getDestination(id) {
  19741. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  19742. },
  19743. getPageLabels: function WorkerTransport_getPageLabels() {
  19744. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  19745. },
  19746. getAttachments: function WorkerTransport_getAttachments() {
  19747. return this.messageHandler.sendWithPromise('GetAttachments', null);
  19748. },
  19749. getJavaScript: function WorkerTransport_getJavaScript() {
  19750. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  19751. },
  19752. getOutline: function WorkerTransport_getOutline() {
  19753. return this.messageHandler.sendWithPromise('GetOutline', null);
  19754. },
  19755. getMetadata: function WorkerTransport_getMetadata() {
  19756. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  19757. return {
  19758. info: results[0],
  19759. metadata: results[1] ? new Metadata(results[1]) : null
  19760. };
  19761. });
  19762. },
  19763. getStats: function WorkerTransport_getStats() {
  19764. return this.messageHandler.sendWithPromise('GetStats', null);
  19765. },
  19766. startCleanup: function WorkerTransport_startCleanup() {
  19767. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  19768. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  19769. var page = this.pageCache[i];
  19770. if (page) {
  19771. page.cleanup();
  19772. }
  19773. }
  19774. this.commonObjs.clear();
  19775. this.fontLoader.clear();
  19776. }.bind(this));
  19777. }
  19778. };
  19779. return WorkerTransport;
  19780. }();
  19781. var PDFObjects = function PDFObjectsClosure() {
  19782. function PDFObjects() {
  19783. this.objs = Object.create(null);
  19784. }
  19785. PDFObjects.prototype = {
  19786. ensureObj: function PDFObjects_ensureObj(objId) {
  19787. if (this.objs[objId]) {
  19788. return this.objs[objId];
  19789. }
  19790. var obj = {
  19791. capability: createPromiseCapability(),
  19792. data: null,
  19793. resolved: false
  19794. };
  19795. this.objs[objId] = obj;
  19796. return obj;
  19797. },
  19798. get: function PDFObjects_get(objId, callback) {
  19799. if (callback) {
  19800. this.ensureObj(objId).capability.promise.then(callback);
  19801. return null;
  19802. }
  19803. var obj = this.objs[objId];
  19804. if (!obj || !obj.resolved) {
  19805. error('Requesting object that isn\'t resolved yet ' + objId);
  19806. }
  19807. return obj.data;
  19808. },
  19809. resolve: function PDFObjects_resolve(objId, data) {
  19810. var obj = this.ensureObj(objId);
  19811. obj.resolved = true;
  19812. obj.data = data;
  19813. obj.capability.resolve(data);
  19814. },
  19815. isResolved: function PDFObjects_isResolved(objId) {
  19816. var objs = this.objs;
  19817. if (!objs[objId]) {
  19818. return false;
  19819. }
  19820. return objs[objId].resolved;
  19821. },
  19822. hasData: function PDFObjects_hasData(objId) {
  19823. return this.isResolved(objId);
  19824. },
  19825. getData: function PDFObjects_getData(objId) {
  19826. var objs = this.objs;
  19827. if (!objs[objId] || !objs[objId].resolved) {
  19828. return null;
  19829. }
  19830. return objs[objId].data;
  19831. },
  19832. clear: function PDFObjects_clear() {
  19833. this.objs = Object.create(null);
  19834. }
  19835. };
  19836. return PDFObjects;
  19837. }();
  19838. var RenderTask = function RenderTaskClosure() {
  19839. function RenderTask(internalRenderTask) {
  19840. this._internalRenderTask = internalRenderTask;
  19841. this.onContinue = null;
  19842. }
  19843. RenderTask.prototype = {
  19844. get promise() {
  19845. return this._internalRenderTask.capability.promise;
  19846. },
  19847. cancel: function RenderTask_cancel() {
  19848. this._internalRenderTask.cancel();
  19849. },
  19850. then: function RenderTask_then(onFulfilled, onRejected) {
  19851. return this.promise.then.apply(this.promise, arguments);
  19852. }
  19853. };
  19854. return RenderTask;
  19855. }();
  19856. var InternalRenderTask = function InternalRenderTaskClosure() {
  19857. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  19858. this.callback = callback;
  19859. this.params = params;
  19860. this.objs = objs;
  19861. this.commonObjs = commonObjs;
  19862. this.operatorListIdx = null;
  19863. this.operatorList = operatorList;
  19864. this.pageNumber = pageNumber;
  19865. this.canvasFactory = canvasFactory;
  19866. this.running = false;
  19867. this.graphicsReadyCallback = null;
  19868. this.graphicsReady = false;
  19869. this.useRequestAnimationFrame = false;
  19870. this.cancelled = false;
  19871. this.capability = createPromiseCapability();
  19872. this.task = new RenderTask(this);
  19873. this._continueBound = this._continue.bind(this);
  19874. this._scheduleNextBound = this._scheduleNext.bind(this);
  19875. this._nextBound = this._next.bind(this);
  19876. }
  19877. InternalRenderTask.prototype = {
  19878. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  19879. if (this.cancelled) {
  19880. return;
  19881. }
  19882. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  19883. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  19884. this.stepper.init(this.operatorList);
  19885. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  19886. }
  19887. var params = this.params;
  19888. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  19889. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  19890. this.operatorListIdx = 0;
  19891. this.graphicsReady = true;
  19892. if (this.graphicsReadyCallback) {
  19893. this.graphicsReadyCallback();
  19894. }
  19895. },
  19896. cancel: function InternalRenderTask_cancel() {
  19897. this.running = false;
  19898. this.cancelled = true;
  19899. this.callback('cancelled');
  19900. },
  19901. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  19902. if (!this.graphicsReady) {
  19903. if (!this.graphicsReadyCallback) {
  19904. this.graphicsReadyCallback = this._continueBound;
  19905. }
  19906. return;
  19907. }
  19908. if (this.stepper) {
  19909. this.stepper.updateOperatorList(this.operatorList);
  19910. }
  19911. if (this.running) {
  19912. return;
  19913. }
  19914. this._continue();
  19915. },
  19916. _continue: function InternalRenderTask__continue() {
  19917. this.running = true;
  19918. if (this.cancelled) {
  19919. return;
  19920. }
  19921. if (this.task.onContinue) {
  19922. this.task.onContinue(this._scheduleNextBound);
  19923. } else {
  19924. this._scheduleNext();
  19925. }
  19926. },
  19927. _scheduleNext: function InternalRenderTask__scheduleNext() {
  19928. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  19929. window.requestAnimationFrame(this._nextBound);
  19930. } else {
  19931. Promise.resolve(undefined).then(this._nextBound);
  19932. }
  19933. },
  19934. _next: function InternalRenderTask__next() {
  19935. if (this.cancelled) {
  19936. return;
  19937. }
  19938. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  19939. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  19940. this.running = false;
  19941. if (this.operatorList.lastChunk) {
  19942. this.gfx.endDrawing();
  19943. this.callback();
  19944. }
  19945. }
  19946. }
  19947. };
  19948. return InternalRenderTask;
  19949. }();
  19950. var _UnsupportedManager = function UnsupportedManagerClosure() {
  19951. var listeners = [];
  19952. return {
  19953. listen: function (cb) {
  19954. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  19955. listeners.push(cb);
  19956. },
  19957. notify: function (featureId) {
  19958. for (var i = 0, ii = listeners.length; i < ii; i++) {
  19959. listeners[i](featureId);
  19960. }
  19961. }
  19962. };
  19963. }();
  19964. exports.version = '1.7.316';
  19965. exports.build = '59392fd5';
  19966. exports.getDocument = getDocument;
  19967. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  19968. exports.PDFWorker = PDFWorker;
  19969. exports.PDFDocumentProxy = PDFDocumentProxy;
  19970. exports.PDFPageProxy = PDFPageProxy;
  19971. exports._UnsupportedManager = _UnsupportedManager;
  19972. /***/ }),
  19973. /* 11 */
  19974. /***/ (function(module, exports, __w_pdfjs_require__) {
  19975. "use strict";
  19976. var sharedUtil = __w_pdfjs_require__(0);
  19977. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  19978. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  19979. var ImageKind = sharedUtil.ImageKind;
  19980. var OPS = sharedUtil.OPS;
  19981. var Util = sharedUtil.Util;
  19982. var isNum = sharedUtil.isNum;
  19983. var isArray = sharedUtil.isArray;
  19984. var warn = sharedUtil.warn;
  19985. var createObjectURL = sharedUtil.createObjectURL;
  19986. var SVG_DEFAULTS = {
  19987. fontStyle: 'normal',
  19988. fontWeight: 'normal',
  19989. fillColor: '#000000'
  19990. };
  19991. var convertImgDataToPng = function convertImgDataToPngClosure() {
  19992. var PNG_HEADER = new Uint8Array([
  19993. 0x89,
  19994. 0x50,
  19995. 0x4e,
  19996. 0x47,
  19997. 0x0d,
  19998. 0x0a,
  19999. 0x1a,
  20000. 0x0a
  20001. ]);
  20002. var CHUNK_WRAPPER_SIZE = 12;
  20003. var crcTable = new Int32Array(256);
  20004. for (var i = 0; i < 256; i++) {
  20005. var c = i;
  20006. for (var h = 0; h < 8; h++) {
  20007. if (c & 1) {
  20008. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20009. } else {
  20010. c = c >> 1 & 0x7fffffff;
  20011. }
  20012. }
  20013. crcTable[i] = c;
  20014. }
  20015. function crc32(data, start, end) {
  20016. var crc = -1;
  20017. for (var i = start; i < end; i++) {
  20018. var a = (crc ^ data[i]) & 0xff;
  20019. var b = crcTable[a];
  20020. crc = crc >>> 8 ^ b;
  20021. }
  20022. return crc ^ -1;
  20023. }
  20024. function writePngChunk(type, body, data, offset) {
  20025. var p = offset;
  20026. var len = body.length;
  20027. data[p] = len >> 24 & 0xff;
  20028. data[p + 1] = len >> 16 & 0xff;
  20029. data[p + 2] = len >> 8 & 0xff;
  20030. data[p + 3] = len & 0xff;
  20031. p += 4;
  20032. data[p] = type.charCodeAt(0) & 0xff;
  20033. data[p + 1] = type.charCodeAt(1) & 0xff;
  20034. data[p + 2] = type.charCodeAt(2) & 0xff;
  20035. data[p + 3] = type.charCodeAt(3) & 0xff;
  20036. p += 4;
  20037. data.set(body, p);
  20038. p += body.length;
  20039. var crc = crc32(data, offset + 4, p);
  20040. data[p] = crc >> 24 & 0xff;
  20041. data[p + 1] = crc >> 16 & 0xff;
  20042. data[p + 2] = crc >> 8 & 0xff;
  20043. data[p + 3] = crc & 0xff;
  20044. }
  20045. function adler32(data, start, end) {
  20046. var a = 1;
  20047. var b = 0;
  20048. for (var i = start; i < end; ++i) {
  20049. a = (a + (data[i] & 0xff)) % 65521;
  20050. b = (b + a) % 65521;
  20051. }
  20052. return b << 16 | a;
  20053. }
  20054. function encode(imgData, kind, forceDataSchema) {
  20055. var width = imgData.width;
  20056. var height = imgData.height;
  20057. var bitDepth, colorType, lineSize;
  20058. var bytes = imgData.data;
  20059. switch (kind) {
  20060. case ImageKind.GRAYSCALE_1BPP:
  20061. colorType = 0;
  20062. bitDepth = 1;
  20063. lineSize = width + 7 >> 3;
  20064. break;
  20065. case ImageKind.RGB_24BPP:
  20066. colorType = 2;
  20067. bitDepth = 8;
  20068. lineSize = width * 3;
  20069. break;
  20070. case ImageKind.RGBA_32BPP:
  20071. colorType = 6;
  20072. bitDepth = 8;
  20073. lineSize = width * 4;
  20074. break;
  20075. default:
  20076. throw new Error('invalid format');
  20077. }
  20078. var literals = new Uint8Array((1 + lineSize) * height);
  20079. var offsetLiterals = 0, offsetBytes = 0;
  20080. var y, i;
  20081. for (y = 0; y < height; ++y) {
  20082. literals[offsetLiterals++] = 0;
  20083. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20084. offsetBytes += lineSize;
  20085. offsetLiterals += lineSize;
  20086. }
  20087. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20088. offsetLiterals = 0;
  20089. for (y = 0; y < height; y++) {
  20090. offsetLiterals++;
  20091. for (i = 0; i < lineSize; i++) {
  20092. literals[offsetLiterals++] ^= 0xFF;
  20093. }
  20094. }
  20095. }
  20096. var ihdr = new Uint8Array([
  20097. width >> 24 & 0xff,
  20098. width >> 16 & 0xff,
  20099. width >> 8 & 0xff,
  20100. width & 0xff,
  20101. height >> 24 & 0xff,
  20102. height >> 16 & 0xff,
  20103. height >> 8 & 0xff,
  20104. height & 0xff,
  20105. bitDepth,
  20106. colorType,
  20107. 0x00,
  20108. 0x00,
  20109. 0x00
  20110. ]);
  20111. var len = literals.length;
  20112. var maxBlockLength = 0xFFFF;
  20113. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20114. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20115. var pi = 0;
  20116. idat[pi++] = 0x78;
  20117. idat[pi++] = 0x9c;
  20118. var pos = 0;
  20119. while (len > maxBlockLength) {
  20120. idat[pi++] = 0x00;
  20121. idat[pi++] = 0xff;
  20122. idat[pi++] = 0xff;
  20123. idat[pi++] = 0x00;
  20124. idat[pi++] = 0x00;
  20125. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20126. pi += maxBlockLength;
  20127. pos += maxBlockLength;
  20128. len -= maxBlockLength;
  20129. }
  20130. idat[pi++] = 0x01;
  20131. idat[pi++] = len & 0xff;
  20132. idat[pi++] = len >> 8 & 0xff;
  20133. idat[pi++] = ~len & 0xffff & 0xff;
  20134. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20135. idat.set(literals.subarray(pos), pi);
  20136. pi += literals.length - pos;
  20137. var adler = adler32(literals, 0, literals.length);
  20138. idat[pi++] = adler >> 24 & 0xff;
  20139. idat[pi++] = adler >> 16 & 0xff;
  20140. idat[pi++] = adler >> 8 & 0xff;
  20141. idat[pi++] = adler & 0xff;
  20142. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20143. var data = new Uint8Array(pngLength);
  20144. var offset = 0;
  20145. data.set(PNG_HEADER, offset);
  20146. offset += PNG_HEADER.length;
  20147. writePngChunk('IHDR', ihdr, data, offset);
  20148. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20149. writePngChunk('IDATA', idat, data, offset);
  20150. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20151. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20152. return createObjectURL(data, 'image/png', forceDataSchema);
  20153. }
  20154. return function convertImgDataToPng(imgData, forceDataSchema) {
  20155. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20156. return encode(imgData, kind, forceDataSchema);
  20157. };
  20158. }();
  20159. var SVGExtraState = function SVGExtraStateClosure() {
  20160. function SVGExtraState() {
  20161. this.fontSizeScale = 1;
  20162. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20163. this.fontSize = 0;
  20164. this.textMatrix = IDENTITY_MATRIX;
  20165. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20166. this.leading = 0;
  20167. this.x = 0;
  20168. this.y = 0;
  20169. this.lineX = 0;
  20170. this.lineY = 0;
  20171. this.charSpacing = 0;
  20172. this.wordSpacing = 0;
  20173. this.textHScale = 1;
  20174. this.textRise = 0;
  20175. this.fillColor = SVG_DEFAULTS.fillColor;
  20176. this.strokeColor = '#000000';
  20177. this.fillAlpha = 1;
  20178. this.strokeAlpha = 1;
  20179. this.lineWidth = 1;
  20180. this.lineJoin = '';
  20181. this.lineCap = '';
  20182. this.miterLimit = 0;
  20183. this.dashArray = [];
  20184. this.dashPhase = 0;
  20185. this.dependencies = [];
  20186. this.activeClipUrl = null;
  20187. this.clipGroup = null;
  20188. this.maskId = '';
  20189. }
  20190. SVGExtraState.prototype = {
  20191. clone: function SVGExtraState_clone() {
  20192. return Object.create(this);
  20193. },
  20194. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20195. this.x = x;
  20196. this.y = y;
  20197. }
  20198. };
  20199. return SVGExtraState;
  20200. }();
  20201. var SVGGraphics = function SVGGraphicsClosure() {
  20202. function opListToTree(opList) {
  20203. var opTree = [];
  20204. var tmp = [];
  20205. var opListLen = opList.length;
  20206. for (var x = 0; x < opListLen; x++) {
  20207. if (opList[x].fn === 'save') {
  20208. opTree.push({
  20209. 'fnId': 92,
  20210. 'fn': 'group',
  20211. 'items': []
  20212. });
  20213. tmp.push(opTree);
  20214. opTree = opTree[opTree.length - 1].items;
  20215. continue;
  20216. }
  20217. if (opList[x].fn === 'restore') {
  20218. opTree = tmp.pop();
  20219. } else {
  20220. opTree.push(opList[x]);
  20221. }
  20222. }
  20223. return opTree;
  20224. }
  20225. function pf(value) {
  20226. if (value === (value | 0)) {
  20227. return value.toString();
  20228. }
  20229. var s = value.toFixed(10);
  20230. var i = s.length - 1;
  20231. if (s[i] !== '0') {
  20232. return s;
  20233. }
  20234. do {
  20235. i--;
  20236. } while (s[i] === '0');
  20237. return s.substr(0, s[i] === '.' ? i : i + 1);
  20238. }
  20239. function pm(m) {
  20240. if (m[4] === 0 && m[5] === 0) {
  20241. if (m[1] === 0 && m[2] === 0) {
  20242. if (m[0] === 1 && m[3] === 1) {
  20243. return '';
  20244. }
  20245. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  20246. }
  20247. if (m[0] === m[3] && m[1] === -m[2]) {
  20248. var a = Math.acos(m[0]) * 180 / Math.PI;
  20249. return 'rotate(' + pf(a) + ')';
  20250. }
  20251. } else {
  20252. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20253. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20254. }
  20255. }
  20256. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20257. }
  20258. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  20259. this.current = new SVGExtraState();
  20260. this.transformMatrix = IDENTITY_MATRIX;
  20261. this.transformStack = [];
  20262. this.extraStack = [];
  20263. this.commonObjs = commonObjs;
  20264. this.objs = objs;
  20265. this.pendingEOFill = false;
  20266. this.embedFonts = false;
  20267. this.embeddedFonts = Object.create(null);
  20268. this.cssStyle = null;
  20269. this.forceDataSchema = !!forceDataSchema;
  20270. }
  20271. var NS = 'http://www.w3.org/2000/svg';
  20272. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  20273. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  20274. var LINE_CAP_STYLES = [
  20275. 'butt',
  20276. 'round',
  20277. 'square'
  20278. ];
  20279. var LINE_JOIN_STYLES = [
  20280. 'miter',
  20281. 'round',
  20282. 'bevel'
  20283. ];
  20284. var clipCount = 0;
  20285. var maskCount = 0;
  20286. SVGGraphics.prototype = {
  20287. save: function SVGGraphics_save() {
  20288. this.transformStack.push(this.transformMatrix);
  20289. var old = this.current;
  20290. this.extraStack.push(old);
  20291. this.current = old.clone();
  20292. },
  20293. restore: function SVGGraphics_restore() {
  20294. this.transformMatrix = this.transformStack.pop();
  20295. this.current = this.extraStack.pop();
  20296. this.tgrp = null;
  20297. },
  20298. group: function SVGGraphics_group(items) {
  20299. this.save();
  20300. this.executeOpTree(items);
  20301. this.restore();
  20302. },
  20303. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  20304. var fnArray = operatorList.fnArray;
  20305. var fnArrayLen = fnArray.length;
  20306. var argsArray = operatorList.argsArray;
  20307. var self = this;
  20308. for (var i = 0; i < fnArrayLen; i++) {
  20309. if (OPS.dependency === fnArray[i]) {
  20310. var deps = argsArray[i];
  20311. for (var n = 0, nn = deps.length; n < nn; n++) {
  20312. var obj = deps[n];
  20313. var common = obj.substring(0, 2) === 'g_';
  20314. var promise;
  20315. if (common) {
  20316. promise = new Promise(function (resolve) {
  20317. self.commonObjs.get(obj, resolve);
  20318. });
  20319. } else {
  20320. promise = new Promise(function (resolve) {
  20321. self.objs.get(obj, resolve);
  20322. });
  20323. }
  20324. this.current.dependencies.push(promise);
  20325. }
  20326. }
  20327. }
  20328. return Promise.all(this.current.dependencies);
  20329. },
  20330. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  20331. var transformMatrix = [
  20332. a,
  20333. b,
  20334. c,
  20335. d,
  20336. e,
  20337. f
  20338. ];
  20339. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  20340. this.tgrp = null;
  20341. },
  20342. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  20343. this.viewport = viewport;
  20344. var svgElement = this._initialize(viewport);
  20345. return this.loadDependencies(operatorList).then(function () {
  20346. this.transformMatrix = IDENTITY_MATRIX;
  20347. var opTree = this.convertOpList(operatorList);
  20348. this.executeOpTree(opTree);
  20349. return svgElement;
  20350. }.bind(this));
  20351. },
  20352. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  20353. var argsArray = operatorList.argsArray;
  20354. var fnArray = operatorList.fnArray;
  20355. var fnArrayLen = fnArray.length;
  20356. var REVOPS = [];
  20357. var opList = [];
  20358. for (var op in OPS) {
  20359. REVOPS[OPS[op]] = op;
  20360. }
  20361. for (var x = 0; x < fnArrayLen; x++) {
  20362. var fnId = fnArray[x];
  20363. opList.push({
  20364. 'fnId': fnId,
  20365. 'fn': REVOPS[fnId],
  20366. 'args': argsArray[x]
  20367. });
  20368. }
  20369. return opListToTree(opList);
  20370. },
  20371. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  20372. var opTreeLen = opTree.length;
  20373. for (var x = 0; x < opTreeLen; x++) {
  20374. var fn = opTree[x].fn;
  20375. var fnId = opTree[x].fnId;
  20376. var args = opTree[x].args;
  20377. switch (fnId | 0) {
  20378. case OPS.beginText:
  20379. this.beginText();
  20380. break;
  20381. case OPS.setLeading:
  20382. this.setLeading(args);
  20383. break;
  20384. case OPS.setLeadingMoveText:
  20385. this.setLeadingMoveText(args[0], args[1]);
  20386. break;
  20387. case OPS.setFont:
  20388. this.setFont(args);
  20389. break;
  20390. case OPS.showText:
  20391. this.showText(args[0]);
  20392. break;
  20393. case OPS.showSpacedText:
  20394. this.showText(args[0]);
  20395. break;
  20396. case OPS.endText:
  20397. this.endText();
  20398. break;
  20399. case OPS.moveText:
  20400. this.moveText(args[0], args[1]);
  20401. break;
  20402. case OPS.setCharSpacing:
  20403. this.setCharSpacing(args[0]);
  20404. break;
  20405. case OPS.setWordSpacing:
  20406. this.setWordSpacing(args[0]);
  20407. break;
  20408. case OPS.setHScale:
  20409. this.setHScale(args[0]);
  20410. break;
  20411. case OPS.setTextMatrix:
  20412. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20413. break;
  20414. case OPS.setLineWidth:
  20415. this.setLineWidth(args[0]);
  20416. break;
  20417. case OPS.setLineJoin:
  20418. this.setLineJoin(args[0]);
  20419. break;
  20420. case OPS.setLineCap:
  20421. this.setLineCap(args[0]);
  20422. break;
  20423. case OPS.setMiterLimit:
  20424. this.setMiterLimit(args[0]);
  20425. break;
  20426. case OPS.setFillRGBColor:
  20427. this.setFillRGBColor(args[0], args[1], args[2]);
  20428. break;
  20429. case OPS.setStrokeRGBColor:
  20430. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20431. break;
  20432. case OPS.setDash:
  20433. this.setDash(args[0], args[1]);
  20434. break;
  20435. case OPS.setGState:
  20436. this.setGState(args[0]);
  20437. break;
  20438. case OPS.fill:
  20439. this.fill();
  20440. break;
  20441. case OPS.eoFill:
  20442. this.eoFill();
  20443. break;
  20444. case OPS.stroke:
  20445. this.stroke();
  20446. break;
  20447. case OPS.fillStroke:
  20448. this.fillStroke();
  20449. break;
  20450. case OPS.eoFillStroke:
  20451. this.eoFillStroke();
  20452. break;
  20453. case OPS.clip:
  20454. this.clip('nonzero');
  20455. break;
  20456. case OPS.eoClip:
  20457. this.clip('evenodd');
  20458. break;
  20459. case OPS.paintSolidColorImageMask:
  20460. this.paintSolidColorImageMask();
  20461. break;
  20462. case OPS.paintJpegXObject:
  20463. this.paintJpegXObject(args[0], args[1], args[2]);
  20464. break;
  20465. case OPS.paintImageXObject:
  20466. this.paintImageXObject(args[0]);
  20467. break;
  20468. case OPS.paintInlineImageXObject:
  20469. this.paintInlineImageXObject(args[0]);
  20470. break;
  20471. case OPS.paintImageMaskXObject:
  20472. this.paintImageMaskXObject(args[0]);
  20473. break;
  20474. case OPS.paintFormXObjectBegin:
  20475. this.paintFormXObjectBegin(args[0], args[1]);
  20476. break;
  20477. case OPS.paintFormXObjectEnd:
  20478. this.paintFormXObjectEnd();
  20479. break;
  20480. case OPS.closePath:
  20481. this.closePath();
  20482. break;
  20483. case OPS.closeStroke:
  20484. this.closeStroke();
  20485. break;
  20486. case OPS.closeFillStroke:
  20487. this.closeFillStroke();
  20488. break;
  20489. case OPS.nextLine:
  20490. this.nextLine();
  20491. break;
  20492. case OPS.transform:
  20493. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20494. break;
  20495. case OPS.constructPath:
  20496. this.constructPath(args[0], args[1]);
  20497. break;
  20498. case OPS.endPath:
  20499. this.endPath();
  20500. break;
  20501. case 92:
  20502. this.group(opTree[x].items);
  20503. break;
  20504. default:
  20505. warn('Unimplemented operator ' + fn);
  20506. break;
  20507. }
  20508. }
  20509. },
  20510. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  20511. this.current.wordSpacing = wordSpacing;
  20512. },
  20513. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  20514. this.current.charSpacing = charSpacing;
  20515. },
  20516. nextLine: function SVGGraphics_nextLine() {
  20517. this.moveText(0, this.current.leading);
  20518. },
  20519. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  20520. var current = this.current;
  20521. this.current.textMatrix = this.current.lineMatrix = [
  20522. a,
  20523. b,
  20524. c,
  20525. d,
  20526. e,
  20527. f
  20528. ];
  20529. this.current.x = this.current.lineX = 0;
  20530. this.current.y = this.current.lineY = 0;
  20531. current.xcoords = [];
  20532. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20533. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20534. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20535. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20536. current.txtElement = document.createElementNS(NS, 'svg:text');
  20537. current.txtElement.appendChild(current.tspan);
  20538. },
  20539. beginText: function SVGGraphics_beginText() {
  20540. this.current.x = this.current.lineX = 0;
  20541. this.current.y = this.current.lineY = 0;
  20542. this.current.textMatrix = IDENTITY_MATRIX;
  20543. this.current.lineMatrix = IDENTITY_MATRIX;
  20544. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20545. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  20546. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  20547. this.current.xcoords = [];
  20548. },
  20549. moveText: function SVGGraphics_moveText(x, y) {
  20550. var current = this.current;
  20551. this.current.x = this.current.lineX += x;
  20552. this.current.y = this.current.lineY += y;
  20553. current.xcoords = [];
  20554. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20555. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20556. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20557. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20558. },
  20559. showText: function SVGGraphics_showText(glyphs) {
  20560. var current = this.current;
  20561. var font = current.font;
  20562. var fontSize = current.fontSize;
  20563. if (fontSize === 0) {
  20564. return;
  20565. }
  20566. var charSpacing = current.charSpacing;
  20567. var wordSpacing = current.wordSpacing;
  20568. var fontDirection = current.fontDirection;
  20569. var textHScale = current.textHScale * fontDirection;
  20570. var glyphsLength = glyphs.length;
  20571. var vertical = font.vertical;
  20572. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20573. var x = 0, i;
  20574. for (i = 0; i < glyphsLength; ++i) {
  20575. var glyph = glyphs[i];
  20576. if (glyph === null) {
  20577. x += fontDirection * wordSpacing;
  20578. continue;
  20579. } else if (isNum(glyph)) {
  20580. x += -glyph * fontSize * 0.001;
  20581. continue;
  20582. }
  20583. current.xcoords.push(current.x + x * textHScale);
  20584. var width = glyph.width;
  20585. var character = glyph.fontChar;
  20586. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  20587. x += charWidth;
  20588. current.tspan.textContent += character;
  20589. }
  20590. if (vertical) {
  20591. current.y -= x * textHScale;
  20592. } else {
  20593. current.x += x * textHScale;
  20594. }
  20595. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  20596. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20597. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20598. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20599. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20600. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  20601. }
  20602. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20603. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  20604. }
  20605. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20606. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  20607. }
  20608. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  20609. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  20610. current.txtElement.appendChild(current.tspan);
  20611. current.txtgrp.appendChild(current.txtElement);
  20612. this._ensureTransformGroup().appendChild(current.txtElement);
  20613. },
  20614. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  20615. this.setLeading(-y);
  20616. this.moveText(x, y);
  20617. },
  20618. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  20619. if (!this.cssStyle) {
  20620. this.cssStyle = document.createElementNS(NS, 'svg:style');
  20621. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  20622. this.defs.appendChild(this.cssStyle);
  20623. }
  20624. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20625. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  20626. },
  20627. setFont: function SVGGraphics_setFont(details) {
  20628. var current = this.current;
  20629. var fontObj = this.commonObjs.get(details[0]);
  20630. var size = details[1];
  20631. this.current.font = fontObj;
  20632. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  20633. this.addFontStyle(fontObj);
  20634. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20635. }
  20636. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  20637. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  20638. var italic = fontObj.italic ? 'italic' : 'normal';
  20639. if (size < 0) {
  20640. size = -size;
  20641. current.fontDirection = -1;
  20642. } else {
  20643. current.fontDirection = 1;
  20644. }
  20645. current.fontSize = size;
  20646. current.fontFamily = fontObj.loadedName;
  20647. current.fontWeight = bold;
  20648. current.fontStyle = italic;
  20649. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20650. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20651. current.xcoords = [];
  20652. },
  20653. endText: function SVGGraphics_endText() {
  20654. },
  20655. setLineWidth: function SVGGraphics_setLineWidth(width) {
  20656. this.current.lineWidth = width;
  20657. },
  20658. setLineCap: function SVGGraphics_setLineCap(style) {
  20659. this.current.lineCap = LINE_CAP_STYLES[style];
  20660. },
  20661. setLineJoin: function SVGGraphics_setLineJoin(style) {
  20662. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20663. },
  20664. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  20665. this.current.miterLimit = limit;
  20666. },
  20667. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  20668. var color = Util.makeCssRgb(r, g, b);
  20669. this.current.strokeColor = color;
  20670. },
  20671. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  20672. var color = Util.makeCssRgb(r, g, b);
  20673. this.current.fillColor = color;
  20674. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20675. this.current.xcoords = [];
  20676. },
  20677. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  20678. this.current.dashArray = dashArray;
  20679. this.current.dashPhase = dashPhase;
  20680. },
  20681. constructPath: function SVGGraphics_constructPath(ops, args) {
  20682. var current = this.current;
  20683. var x = current.x, y = current.y;
  20684. current.path = document.createElementNS(NS, 'svg:path');
  20685. var d = [];
  20686. var opLength = ops.length;
  20687. for (var i = 0, j = 0; i < opLength; i++) {
  20688. switch (ops[i] | 0) {
  20689. case OPS.rectangle:
  20690. x = args[j++];
  20691. y = args[j++];
  20692. var width = args[j++];
  20693. var height = args[j++];
  20694. var xw = x + width;
  20695. var yh = y + height;
  20696. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  20697. break;
  20698. case OPS.moveTo:
  20699. x = args[j++];
  20700. y = args[j++];
  20701. d.push('M', pf(x), pf(y));
  20702. break;
  20703. case OPS.lineTo:
  20704. x = args[j++];
  20705. y = args[j++];
  20706. d.push('L', pf(x), pf(y));
  20707. break;
  20708. case OPS.curveTo:
  20709. x = args[j + 4];
  20710. y = args[j + 5];
  20711. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  20712. j += 6;
  20713. break;
  20714. case OPS.curveTo2:
  20715. x = args[j + 2];
  20716. y = args[j + 3];
  20717. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  20718. j += 4;
  20719. break;
  20720. case OPS.curveTo3:
  20721. x = args[j + 2];
  20722. y = args[j + 3];
  20723. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  20724. j += 4;
  20725. break;
  20726. case OPS.closePath:
  20727. d.push('Z');
  20728. break;
  20729. }
  20730. }
  20731. current.path.setAttributeNS(null, 'd', d.join(' '));
  20732. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  20733. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  20734. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  20735. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  20736. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  20737. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  20738. current.path.setAttributeNS(null, 'fill', 'none');
  20739. this._ensureTransformGroup().appendChild(current.path);
  20740. current.element = current.path;
  20741. current.setCurrentPoint(x, y);
  20742. },
  20743. endPath: function SVGGraphics_endPath() {
  20744. },
  20745. clip: function SVGGraphics_clip(type) {
  20746. var current = this.current;
  20747. var clipId = 'clippath' + clipCount;
  20748. clipCount++;
  20749. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  20750. clipPath.setAttributeNS(null, 'id', clipId);
  20751. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20752. var clipElement = current.element.cloneNode();
  20753. if (type === 'evenodd') {
  20754. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  20755. } else {
  20756. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  20757. }
  20758. clipPath.appendChild(clipElement);
  20759. this.defs.appendChild(clipPath);
  20760. if (current.activeClipUrl) {
  20761. current.clipGroup = null;
  20762. this.extraStack.forEach(function (prev) {
  20763. prev.clipGroup = null;
  20764. });
  20765. }
  20766. current.activeClipUrl = 'url(#' + clipId + ')';
  20767. this.tgrp = null;
  20768. },
  20769. closePath: function SVGGraphics_closePath() {
  20770. var current = this.current;
  20771. var d = current.path.getAttributeNS(null, 'd');
  20772. d += 'Z';
  20773. current.path.setAttributeNS(null, 'd', d);
  20774. },
  20775. setLeading: function SVGGraphics_setLeading(leading) {
  20776. this.current.leading = -leading;
  20777. },
  20778. setTextRise: function SVGGraphics_setTextRise(textRise) {
  20779. this.current.textRise = textRise;
  20780. },
  20781. setHScale: function SVGGraphics_setHScale(scale) {
  20782. this.current.textHScale = scale / 100;
  20783. },
  20784. setGState: function SVGGraphics_setGState(states) {
  20785. for (var i = 0, ii = states.length; i < ii; i++) {
  20786. var state = states[i];
  20787. var key = state[0];
  20788. var value = state[1];
  20789. switch (key) {
  20790. case 'LW':
  20791. this.setLineWidth(value);
  20792. break;
  20793. case 'LC':
  20794. this.setLineCap(value);
  20795. break;
  20796. case 'LJ':
  20797. this.setLineJoin(value);
  20798. break;
  20799. case 'ML':
  20800. this.setMiterLimit(value);
  20801. break;
  20802. case 'D':
  20803. this.setDash(value[0], value[1]);
  20804. break;
  20805. case 'Font':
  20806. this.setFont(value);
  20807. break;
  20808. default:
  20809. warn('Unimplemented graphic state ' + key);
  20810. break;
  20811. }
  20812. }
  20813. },
  20814. fill: function SVGGraphics_fill() {
  20815. var current = this.current;
  20816. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20817. },
  20818. stroke: function SVGGraphics_stroke() {
  20819. var current = this.current;
  20820. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  20821. current.element.setAttributeNS(null, 'fill', 'none');
  20822. },
  20823. eoFill: function SVGGraphics_eoFill() {
  20824. var current = this.current;
  20825. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20826. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20827. },
  20828. fillStroke: function SVGGraphics_fillStroke() {
  20829. this.stroke();
  20830. this.fill();
  20831. },
  20832. eoFillStroke: function SVGGraphics_eoFillStroke() {
  20833. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20834. this.fillStroke();
  20835. },
  20836. closeStroke: function SVGGraphics_closeStroke() {
  20837. this.closePath();
  20838. this.stroke();
  20839. },
  20840. closeFillStroke: function SVGGraphics_closeFillStroke() {
  20841. this.closePath();
  20842. this.fillStroke();
  20843. },
  20844. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  20845. var current = this.current;
  20846. var rect = document.createElementNS(NS, 'svg:rect');
  20847. rect.setAttributeNS(null, 'x', '0');
  20848. rect.setAttributeNS(null, 'y', '0');
  20849. rect.setAttributeNS(null, 'width', '1px');
  20850. rect.setAttributeNS(null, 'height', '1px');
  20851. rect.setAttributeNS(null, 'fill', current.fillColor);
  20852. this._ensureTransformGroup().appendChild(rect);
  20853. },
  20854. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  20855. var imgObj = this.objs.get(objId);
  20856. var imgEl = document.createElementNS(NS, 'svg:image');
  20857. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  20858. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  20859. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  20860. imgEl.setAttributeNS(null, 'x', '0');
  20861. imgEl.setAttributeNS(null, 'y', pf(-h));
  20862. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  20863. this._ensureTransformGroup().appendChild(imgEl);
  20864. },
  20865. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  20866. var imgData = this.objs.get(objId);
  20867. if (!imgData) {
  20868. warn('Dependent image isn\'t ready yet');
  20869. return;
  20870. }
  20871. this.paintInlineImageXObject(imgData);
  20872. },
  20873. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  20874. var width = imgData.width;
  20875. var height = imgData.height;
  20876. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  20877. var cliprect = document.createElementNS(NS, 'svg:rect');
  20878. cliprect.setAttributeNS(null, 'x', '0');
  20879. cliprect.setAttributeNS(null, 'y', '0');
  20880. cliprect.setAttributeNS(null, 'width', pf(width));
  20881. cliprect.setAttributeNS(null, 'height', pf(height));
  20882. this.current.element = cliprect;
  20883. this.clip('nonzero');
  20884. var imgEl = document.createElementNS(NS, 'svg:image');
  20885. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  20886. imgEl.setAttributeNS(null, 'x', '0');
  20887. imgEl.setAttributeNS(null, 'y', pf(-height));
  20888. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  20889. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  20890. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  20891. if (mask) {
  20892. mask.appendChild(imgEl);
  20893. } else {
  20894. this._ensureTransformGroup().appendChild(imgEl);
  20895. }
  20896. },
  20897. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  20898. var current = this.current;
  20899. var width = imgData.width;
  20900. var height = imgData.height;
  20901. var fillColor = current.fillColor;
  20902. current.maskId = 'mask' + maskCount++;
  20903. var mask = document.createElementNS(NS, 'svg:mask');
  20904. mask.setAttributeNS(null, 'id', current.maskId);
  20905. var rect = document.createElementNS(NS, 'svg:rect');
  20906. rect.setAttributeNS(null, 'x', '0');
  20907. rect.setAttributeNS(null, 'y', '0');
  20908. rect.setAttributeNS(null, 'width', pf(width));
  20909. rect.setAttributeNS(null, 'height', pf(height));
  20910. rect.setAttributeNS(null, 'fill', fillColor);
  20911. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  20912. this.defs.appendChild(mask);
  20913. this._ensureTransformGroup().appendChild(rect);
  20914. this.paintInlineImageXObject(imgData, mask);
  20915. },
  20916. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  20917. if (isArray(matrix) && matrix.length === 6) {
  20918. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  20919. }
  20920. if (isArray(bbox) && bbox.length === 4) {
  20921. var width = bbox[2] - bbox[0];
  20922. var height = bbox[3] - bbox[1];
  20923. var cliprect = document.createElementNS(NS, 'svg:rect');
  20924. cliprect.setAttributeNS(null, 'x', bbox[0]);
  20925. cliprect.setAttributeNS(null, 'y', bbox[1]);
  20926. cliprect.setAttributeNS(null, 'width', pf(width));
  20927. cliprect.setAttributeNS(null, 'height', pf(height));
  20928. this.current.element = cliprect;
  20929. this.clip('nonzero');
  20930. this.endPath();
  20931. }
  20932. },
  20933. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  20934. },
  20935. _initialize: function SVGGraphics_initialize(viewport) {
  20936. var svg = document.createElementNS(NS, 'svg:svg');
  20937. svg.setAttributeNS(null, 'version', '1.1');
  20938. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  20939. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  20940. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  20941. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  20942. var definitions = document.createElementNS(NS, 'svg:defs');
  20943. svg.appendChild(definitions);
  20944. this.defs = definitions;
  20945. var rootGroup = document.createElementNS(NS, 'svg:g');
  20946. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  20947. svg.appendChild(rootGroup);
  20948. this.svg = rootGroup;
  20949. return svg;
  20950. },
  20951. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  20952. if (!this.current.clipGroup) {
  20953. var clipGroup = document.createElementNS(NS, 'svg:g');
  20954. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  20955. this.svg.appendChild(clipGroup);
  20956. this.current.clipGroup = clipGroup;
  20957. }
  20958. return this.current.clipGroup;
  20959. },
  20960. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  20961. if (!this.tgrp) {
  20962. this.tgrp = document.createElementNS(NS, 'svg:g');
  20963. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20964. if (this.current.activeClipUrl) {
  20965. this._ensureClipGroup().appendChild(this.tgrp);
  20966. } else {
  20967. this.svg.appendChild(this.tgrp);
  20968. }
  20969. }
  20970. return this.tgrp;
  20971. }
  20972. };
  20973. return SVGGraphics;
  20974. }();
  20975. exports.SVGGraphics = SVGGraphics;
  20976. /***/ }),
  20977. /* 12 */
  20978. /***/ (function(module, exports, __w_pdfjs_require__) {
  20979. "use strict";
  20980. var sharedUtil = __w_pdfjs_require__(0);
  20981. var displayDOMUtils = __w_pdfjs_require__(3);
  20982. var Util = sharedUtil.Util;
  20983. var createPromiseCapability = sharedUtil.createPromiseCapability;
  20984. var CustomStyle = displayDOMUtils.CustomStyle;
  20985. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  20986. var renderTextLayer = function renderTextLayerClosure() {
  20987. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  20988. var NonWhitespaceRegexp = /\S/;
  20989. function isAllWhitespace(str) {
  20990. return !NonWhitespaceRegexp.test(str);
  20991. }
  20992. var styleBuf = [
  20993. 'left: ',
  20994. 0,
  20995. 'px; top: ',
  20996. 0,
  20997. 'px; font-size: ',
  20998. 0,
  20999. 'px; font-family: ',
  21000. '',
  21001. ';'
  21002. ];
  21003. function appendText(task, geom, styles) {
  21004. var textDiv = document.createElement('div');
  21005. var textDivProperties = {
  21006. style: null,
  21007. angle: 0,
  21008. canvasWidth: 0,
  21009. isWhitespace: false,
  21010. originalTransform: null,
  21011. paddingBottom: 0,
  21012. paddingLeft: 0,
  21013. paddingRight: 0,
  21014. paddingTop: 0,
  21015. scale: 1
  21016. };
  21017. task._textDivs.push(textDiv);
  21018. if (isAllWhitespace(geom.str)) {
  21019. textDivProperties.isWhitespace = true;
  21020. task._textDivProperties.set(textDiv, textDivProperties);
  21021. return;
  21022. }
  21023. var tx = Util.transform(task._viewport.transform, geom.transform);
  21024. var angle = Math.atan2(tx[1], tx[0]);
  21025. var style = styles[geom.fontName];
  21026. if (style.vertical) {
  21027. angle += Math.PI / 2;
  21028. }
  21029. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21030. var fontAscent = fontHeight;
  21031. if (style.ascent) {
  21032. fontAscent = style.ascent * fontAscent;
  21033. } else if (style.descent) {
  21034. fontAscent = (1 + style.descent) * fontAscent;
  21035. }
  21036. var left;
  21037. var top;
  21038. if (angle === 0) {
  21039. left = tx[4];
  21040. top = tx[5] - fontAscent;
  21041. } else {
  21042. left = tx[4] + fontAscent * Math.sin(angle);
  21043. top = tx[5] - fontAscent * Math.cos(angle);
  21044. }
  21045. styleBuf[1] = left;
  21046. styleBuf[3] = top;
  21047. styleBuf[5] = fontHeight;
  21048. styleBuf[7] = style.fontFamily;
  21049. textDivProperties.style = styleBuf.join('');
  21050. textDiv.setAttribute('style', textDivProperties.style);
  21051. textDiv.textContent = geom.str;
  21052. if (getDefaultSetting('pdfBug')) {
  21053. textDiv.dataset.fontName = geom.fontName;
  21054. }
  21055. if (angle !== 0) {
  21056. textDivProperties.angle = angle * (180 / Math.PI);
  21057. }
  21058. if (geom.str.length > 1) {
  21059. if (style.vertical) {
  21060. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21061. } else {
  21062. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21063. }
  21064. }
  21065. task._textDivProperties.set(textDiv, textDivProperties);
  21066. if (task._enhanceTextSelection) {
  21067. var angleCos = 1, angleSin = 0;
  21068. if (angle !== 0) {
  21069. angleCos = Math.cos(angle);
  21070. angleSin = Math.sin(angle);
  21071. }
  21072. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21073. var divHeight = fontHeight;
  21074. var m, b;
  21075. if (angle !== 0) {
  21076. m = [
  21077. angleCos,
  21078. angleSin,
  21079. -angleSin,
  21080. angleCos,
  21081. left,
  21082. top
  21083. ];
  21084. b = Util.getAxialAlignedBoundingBox([
  21085. 0,
  21086. 0,
  21087. divWidth,
  21088. divHeight
  21089. ], m);
  21090. } else {
  21091. b = [
  21092. left,
  21093. top,
  21094. left + divWidth,
  21095. top + divHeight
  21096. ];
  21097. }
  21098. task._bounds.push({
  21099. left: b[0],
  21100. top: b[1],
  21101. right: b[2],
  21102. bottom: b[3],
  21103. div: textDiv,
  21104. size: [
  21105. divWidth,
  21106. divHeight
  21107. ],
  21108. m: m
  21109. });
  21110. }
  21111. }
  21112. function render(task) {
  21113. if (task._canceled) {
  21114. return;
  21115. }
  21116. var textLayerFrag = task._container;
  21117. var textDivs = task._textDivs;
  21118. var capability = task._capability;
  21119. var textDivsLength = textDivs.length;
  21120. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21121. task._renderingDone = true;
  21122. capability.resolve();
  21123. return;
  21124. }
  21125. var canvas = document.createElement('canvas');
  21126. var ctx = canvas.getContext('2d', { alpha: false });
  21127. var lastFontSize;
  21128. var lastFontFamily;
  21129. for (var i = 0; i < textDivsLength; i++) {
  21130. var textDiv = textDivs[i];
  21131. var textDivProperties = task._textDivProperties.get(textDiv);
  21132. if (textDivProperties.isWhitespace) {
  21133. continue;
  21134. }
  21135. var fontSize = textDiv.style.fontSize;
  21136. var fontFamily = textDiv.style.fontFamily;
  21137. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21138. ctx.font = fontSize + ' ' + fontFamily;
  21139. lastFontSize = fontSize;
  21140. lastFontFamily = fontFamily;
  21141. }
  21142. var width = ctx.measureText(textDiv.textContent).width;
  21143. textLayerFrag.appendChild(textDiv);
  21144. var transform = '';
  21145. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21146. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21147. transform = 'scaleX(' + textDivProperties.scale + ')';
  21148. }
  21149. if (textDivProperties.angle !== 0) {
  21150. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21151. }
  21152. if (transform !== '') {
  21153. textDivProperties.originalTransform = transform;
  21154. CustomStyle.setProp('transform', textDiv, transform);
  21155. }
  21156. task._textDivProperties.set(textDiv, textDivProperties);
  21157. }
  21158. task._renderingDone = true;
  21159. capability.resolve();
  21160. }
  21161. function expand(task) {
  21162. var bounds = task._bounds;
  21163. var viewport = task._viewport;
  21164. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21165. for (var i = 0; i < expanded.length; i++) {
  21166. var div = bounds[i].div;
  21167. var divProperties = task._textDivProperties.get(div);
  21168. if (divProperties.angle === 0) {
  21169. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21170. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21171. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21172. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21173. task._textDivProperties.set(div, divProperties);
  21174. continue;
  21175. }
  21176. var e = expanded[i], b = bounds[i];
  21177. var m = b.m, c = m[0], s = m[1];
  21178. var points = [
  21179. [
  21180. 0,
  21181. 0
  21182. ],
  21183. [
  21184. 0,
  21185. b.size[1]
  21186. ],
  21187. [
  21188. b.size[0],
  21189. 0
  21190. ],
  21191. b.size
  21192. ];
  21193. var ts = new Float64Array(64);
  21194. points.forEach(function (p, i) {
  21195. var t = Util.applyTransform(p, m);
  21196. ts[i + 0] = c && (e.left - t[0]) / c;
  21197. ts[i + 4] = s && (e.top - t[1]) / s;
  21198. ts[i + 8] = c && (e.right - t[0]) / c;
  21199. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21200. ts[i + 16] = s && (e.left - t[0]) / -s;
  21201. ts[i + 20] = c && (e.top - t[1]) / c;
  21202. ts[i + 24] = s && (e.right - t[0]) / -s;
  21203. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21204. ts[i + 32] = c && (e.left - t[0]) / -c;
  21205. ts[i + 36] = s && (e.top - t[1]) / -s;
  21206. ts[i + 40] = c && (e.right - t[0]) / -c;
  21207. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21208. ts[i + 48] = s && (e.left - t[0]) / s;
  21209. ts[i + 52] = c && (e.top - t[1]) / -c;
  21210. ts[i + 56] = s && (e.right - t[0]) / s;
  21211. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21212. });
  21213. var findPositiveMin = function (ts, offset, count) {
  21214. var result = 0;
  21215. for (var i = 0; i < count; i++) {
  21216. var t = ts[offset++];
  21217. if (t > 0) {
  21218. result = result ? Math.min(t, result) : t;
  21219. }
  21220. }
  21221. return result;
  21222. };
  21223. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21224. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21225. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21226. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21227. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21228. task._textDivProperties.set(div, divProperties);
  21229. }
  21230. }
  21231. function expandBounds(width, height, boxes) {
  21232. var bounds = boxes.map(function (box, i) {
  21233. return {
  21234. x1: box.left,
  21235. y1: box.top,
  21236. x2: box.right,
  21237. y2: box.bottom,
  21238. index: i,
  21239. x1New: undefined,
  21240. x2New: undefined
  21241. };
  21242. });
  21243. expandBoundsLTR(width, bounds);
  21244. var expanded = new Array(boxes.length);
  21245. bounds.forEach(function (b) {
  21246. var i = b.index;
  21247. expanded[i] = {
  21248. left: b.x1New,
  21249. top: 0,
  21250. right: b.x2New,
  21251. bottom: 0
  21252. };
  21253. });
  21254. boxes.map(function (box, i) {
  21255. var e = expanded[i], b = bounds[i];
  21256. b.x1 = box.top;
  21257. b.y1 = width - e.right;
  21258. b.x2 = box.bottom;
  21259. b.y2 = width - e.left;
  21260. b.index = i;
  21261. b.x1New = undefined;
  21262. b.x2New = undefined;
  21263. });
  21264. expandBoundsLTR(height, bounds);
  21265. bounds.forEach(function (b) {
  21266. var i = b.index;
  21267. expanded[i].top = b.x1New;
  21268. expanded[i].bottom = b.x2New;
  21269. });
  21270. return expanded;
  21271. }
  21272. function expandBoundsLTR(width, bounds) {
  21273. bounds.sort(function (a, b) {
  21274. return a.x1 - b.x1 || a.index - b.index;
  21275. });
  21276. var fakeBoundary = {
  21277. x1: -Infinity,
  21278. y1: -Infinity,
  21279. x2: 0,
  21280. y2: Infinity,
  21281. index: -1,
  21282. x1New: 0,
  21283. x2New: 0
  21284. };
  21285. var horizon = [{
  21286. start: -Infinity,
  21287. end: Infinity,
  21288. boundary: fakeBoundary
  21289. }];
  21290. bounds.forEach(function (boundary) {
  21291. var i = 0;
  21292. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  21293. i++;
  21294. }
  21295. var j = horizon.length - 1;
  21296. while (j >= 0 && horizon[j].start >= boundary.y2) {
  21297. j--;
  21298. }
  21299. var horizonPart, affectedBoundary;
  21300. var q, k, maxXNew = -Infinity;
  21301. for (q = i; q <= j; q++) {
  21302. horizonPart = horizon[q];
  21303. affectedBoundary = horizonPart.boundary;
  21304. var xNew;
  21305. if (affectedBoundary.x2 > boundary.x1) {
  21306. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  21307. } else if (affectedBoundary.x2New === undefined) {
  21308. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  21309. } else {
  21310. xNew = affectedBoundary.x2New;
  21311. }
  21312. if (xNew > maxXNew) {
  21313. maxXNew = xNew;
  21314. }
  21315. }
  21316. boundary.x1New = maxXNew;
  21317. for (q = i; q <= j; q++) {
  21318. horizonPart = horizon[q];
  21319. affectedBoundary = horizonPart.boundary;
  21320. if (affectedBoundary.x2New === undefined) {
  21321. if (affectedBoundary.x2 > boundary.x1) {
  21322. if (affectedBoundary.index > boundary.index) {
  21323. affectedBoundary.x2New = affectedBoundary.x2;
  21324. }
  21325. } else {
  21326. affectedBoundary.x2New = maxXNew;
  21327. }
  21328. } else if (affectedBoundary.x2New > maxXNew) {
  21329. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  21330. }
  21331. }
  21332. var changedHorizon = [], lastBoundary = null;
  21333. for (q = i; q <= j; q++) {
  21334. horizonPart = horizon[q];
  21335. affectedBoundary = horizonPart.boundary;
  21336. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  21337. if (lastBoundary === useBoundary) {
  21338. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  21339. } else {
  21340. changedHorizon.push({
  21341. start: horizonPart.start,
  21342. end: horizonPart.end,
  21343. boundary: useBoundary
  21344. });
  21345. lastBoundary = useBoundary;
  21346. }
  21347. }
  21348. if (horizon[i].start < boundary.y1) {
  21349. changedHorizon[0].start = boundary.y1;
  21350. changedHorizon.unshift({
  21351. start: horizon[i].start,
  21352. end: boundary.y1,
  21353. boundary: horizon[i].boundary
  21354. });
  21355. }
  21356. if (boundary.y2 < horizon[j].end) {
  21357. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  21358. changedHorizon.push({
  21359. start: boundary.y2,
  21360. end: horizon[j].end,
  21361. boundary: horizon[j].boundary
  21362. });
  21363. }
  21364. for (q = i; q <= j; q++) {
  21365. horizonPart = horizon[q];
  21366. affectedBoundary = horizonPart.boundary;
  21367. if (affectedBoundary.x2New !== undefined) {
  21368. continue;
  21369. }
  21370. var used = false;
  21371. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  21372. used = horizon[k].boundary === affectedBoundary;
  21373. }
  21374. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  21375. used = horizon[k].boundary === affectedBoundary;
  21376. }
  21377. for (k = 0; !used && k < changedHorizon.length; k++) {
  21378. used = changedHorizon[k].boundary === affectedBoundary;
  21379. }
  21380. if (!used) {
  21381. affectedBoundary.x2New = maxXNew;
  21382. }
  21383. }
  21384. Array.prototype.splice.apply(horizon, [
  21385. i,
  21386. j - i + 1
  21387. ].concat(changedHorizon));
  21388. });
  21389. horizon.forEach(function (horizonPart) {
  21390. var affectedBoundary = horizonPart.boundary;
  21391. if (affectedBoundary.x2New === undefined) {
  21392. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  21393. }
  21394. });
  21395. }
  21396. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  21397. this._textContent = textContent;
  21398. this._container = container;
  21399. this._viewport = viewport;
  21400. this._textDivs = textDivs || [];
  21401. this._textDivProperties = new WeakMap();
  21402. this._renderingDone = false;
  21403. this._canceled = false;
  21404. this._capability = createPromiseCapability();
  21405. this._renderTimer = null;
  21406. this._bounds = [];
  21407. this._enhanceTextSelection = !!enhanceTextSelection;
  21408. }
  21409. TextLayerRenderTask.prototype = {
  21410. get promise() {
  21411. return this._capability.promise;
  21412. },
  21413. cancel: function TextLayer_cancel() {
  21414. this._canceled = true;
  21415. if (this._renderTimer !== null) {
  21416. clearTimeout(this._renderTimer);
  21417. this._renderTimer = null;
  21418. }
  21419. this._capability.reject('canceled');
  21420. },
  21421. _render: function TextLayer_render(timeout) {
  21422. var textItems = this._textContent.items;
  21423. var textStyles = this._textContent.styles;
  21424. for (var i = 0, len = textItems.length; i < len; i++) {
  21425. appendText(this, textItems[i], textStyles);
  21426. }
  21427. if (!timeout) {
  21428. render(this);
  21429. } else {
  21430. var self = this;
  21431. this._renderTimer = setTimeout(function () {
  21432. render(self);
  21433. self._renderTimer = null;
  21434. }, timeout);
  21435. }
  21436. },
  21437. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  21438. if (!this._enhanceTextSelection || !this._renderingDone) {
  21439. return;
  21440. }
  21441. if (this._bounds !== null) {
  21442. expand(this);
  21443. this._bounds = null;
  21444. }
  21445. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  21446. var div = this._textDivs[i];
  21447. var divProperties = this._textDivProperties.get(div);
  21448. if (divProperties.isWhitespace) {
  21449. continue;
  21450. }
  21451. if (expandDivs) {
  21452. var transform = '', padding = '';
  21453. if (divProperties.scale !== 1) {
  21454. transform = 'scaleX(' + divProperties.scale + ')';
  21455. }
  21456. if (divProperties.angle !== 0) {
  21457. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  21458. }
  21459. if (divProperties.paddingLeft !== 0) {
  21460. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  21461. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  21462. }
  21463. if (divProperties.paddingTop !== 0) {
  21464. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  21465. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  21466. }
  21467. if (divProperties.paddingRight !== 0) {
  21468. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  21469. }
  21470. if (divProperties.paddingBottom !== 0) {
  21471. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  21472. }
  21473. if (padding !== '') {
  21474. div.setAttribute('style', divProperties.style + padding);
  21475. }
  21476. if (transform !== '') {
  21477. CustomStyle.setProp('transform', div, transform);
  21478. }
  21479. } else {
  21480. div.style.padding = 0;
  21481. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  21482. }
  21483. }
  21484. }
  21485. };
  21486. function renderTextLayer(renderParameters) {
  21487. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  21488. task._render(renderParameters.timeout);
  21489. return task;
  21490. }
  21491. return renderTextLayer;
  21492. }();
  21493. exports.renderTextLayer = renderTextLayer;
  21494. /***/ }),
  21495. /* 13 */
  21496. /***/ (function(module, exports) {
  21497. var g;
  21498. g = function () {
  21499. return this;
  21500. }();
  21501. try {
  21502. g = g || Function("return this")() || (1, eval)("this");
  21503. } catch (e) {
  21504. if (typeof window === "object")
  21505. g = window;
  21506. }
  21507. module.exports = g;
  21508. /***/ }),
  21509. /* 14 */
  21510. /***/ (function(module, exports, __w_pdfjs_require__) {
  21511. "use strict";
  21512. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  21513. var QeTable = [
  21514. {
  21515. qe: 0x5601,
  21516. nmps: 1,
  21517. nlps: 1,
  21518. switchFlag: 1
  21519. },
  21520. {
  21521. qe: 0x3401,
  21522. nmps: 2,
  21523. nlps: 6,
  21524. switchFlag: 0
  21525. },
  21526. {
  21527. qe: 0x1801,
  21528. nmps: 3,
  21529. nlps: 9,
  21530. switchFlag: 0
  21531. },
  21532. {
  21533. qe: 0x0AC1,
  21534. nmps: 4,
  21535. nlps: 12,
  21536. switchFlag: 0
  21537. },
  21538. {
  21539. qe: 0x0521,
  21540. nmps: 5,
  21541. nlps: 29,
  21542. switchFlag: 0
  21543. },
  21544. {
  21545. qe: 0x0221,
  21546. nmps: 38,
  21547. nlps: 33,
  21548. switchFlag: 0
  21549. },
  21550. {
  21551. qe: 0x5601,
  21552. nmps: 7,
  21553. nlps: 6,
  21554. switchFlag: 1
  21555. },
  21556. {
  21557. qe: 0x5401,
  21558. nmps: 8,
  21559. nlps: 14,
  21560. switchFlag: 0
  21561. },
  21562. {
  21563. qe: 0x4801,
  21564. nmps: 9,
  21565. nlps: 14,
  21566. switchFlag: 0
  21567. },
  21568. {
  21569. qe: 0x3801,
  21570. nmps: 10,
  21571. nlps: 14,
  21572. switchFlag: 0
  21573. },
  21574. {
  21575. qe: 0x3001,
  21576. nmps: 11,
  21577. nlps: 17,
  21578. switchFlag: 0
  21579. },
  21580. {
  21581. qe: 0x2401,
  21582. nmps: 12,
  21583. nlps: 18,
  21584. switchFlag: 0
  21585. },
  21586. {
  21587. qe: 0x1C01,
  21588. nmps: 13,
  21589. nlps: 20,
  21590. switchFlag: 0
  21591. },
  21592. {
  21593. qe: 0x1601,
  21594. nmps: 29,
  21595. nlps: 21,
  21596. switchFlag: 0
  21597. },
  21598. {
  21599. qe: 0x5601,
  21600. nmps: 15,
  21601. nlps: 14,
  21602. switchFlag: 1
  21603. },
  21604. {
  21605. qe: 0x5401,
  21606. nmps: 16,
  21607. nlps: 14,
  21608. switchFlag: 0
  21609. },
  21610. {
  21611. qe: 0x5101,
  21612. nmps: 17,
  21613. nlps: 15,
  21614. switchFlag: 0
  21615. },
  21616. {
  21617. qe: 0x4801,
  21618. nmps: 18,
  21619. nlps: 16,
  21620. switchFlag: 0
  21621. },
  21622. {
  21623. qe: 0x3801,
  21624. nmps: 19,
  21625. nlps: 17,
  21626. switchFlag: 0
  21627. },
  21628. {
  21629. qe: 0x3401,
  21630. nmps: 20,
  21631. nlps: 18,
  21632. switchFlag: 0
  21633. },
  21634. {
  21635. qe: 0x3001,
  21636. nmps: 21,
  21637. nlps: 19,
  21638. switchFlag: 0
  21639. },
  21640. {
  21641. qe: 0x2801,
  21642. nmps: 22,
  21643. nlps: 19,
  21644. switchFlag: 0
  21645. },
  21646. {
  21647. qe: 0x2401,
  21648. nmps: 23,
  21649. nlps: 20,
  21650. switchFlag: 0
  21651. },
  21652. {
  21653. qe: 0x2201,
  21654. nmps: 24,
  21655. nlps: 21,
  21656. switchFlag: 0
  21657. },
  21658. {
  21659. qe: 0x1C01,
  21660. nmps: 25,
  21661. nlps: 22,
  21662. switchFlag: 0
  21663. },
  21664. {
  21665. qe: 0x1801,
  21666. nmps: 26,
  21667. nlps: 23,
  21668. switchFlag: 0
  21669. },
  21670. {
  21671. qe: 0x1601,
  21672. nmps: 27,
  21673. nlps: 24,
  21674. switchFlag: 0
  21675. },
  21676. {
  21677. qe: 0x1401,
  21678. nmps: 28,
  21679. nlps: 25,
  21680. switchFlag: 0
  21681. },
  21682. {
  21683. qe: 0x1201,
  21684. nmps: 29,
  21685. nlps: 26,
  21686. switchFlag: 0
  21687. },
  21688. {
  21689. qe: 0x1101,
  21690. nmps: 30,
  21691. nlps: 27,
  21692. switchFlag: 0
  21693. },
  21694. {
  21695. qe: 0x0AC1,
  21696. nmps: 31,
  21697. nlps: 28,
  21698. switchFlag: 0
  21699. },
  21700. {
  21701. qe: 0x09C1,
  21702. nmps: 32,
  21703. nlps: 29,
  21704. switchFlag: 0
  21705. },
  21706. {
  21707. qe: 0x08A1,
  21708. nmps: 33,
  21709. nlps: 30,
  21710. switchFlag: 0
  21711. },
  21712. {
  21713. qe: 0x0521,
  21714. nmps: 34,
  21715. nlps: 31,
  21716. switchFlag: 0
  21717. },
  21718. {
  21719. qe: 0x0441,
  21720. nmps: 35,
  21721. nlps: 32,
  21722. switchFlag: 0
  21723. },
  21724. {
  21725. qe: 0x02A1,
  21726. nmps: 36,
  21727. nlps: 33,
  21728. switchFlag: 0
  21729. },
  21730. {
  21731. qe: 0x0221,
  21732. nmps: 37,
  21733. nlps: 34,
  21734. switchFlag: 0
  21735. },
  21736. {
  21737. qe: 0x0141,
  21738. nmps: 38,
  21739. nlps: 35,
  21740. switchFlag: 0
  21741. },
  21742. {
  21743. qe: 0x0111,
  21744. nmps: 39,
  21745. nlps: 36,
  21746. switchFlag: 0
  21747. },
  21748. {
  21749. qe: 0x0085,
  21750. nmps: 40,
  21751. nlps: 37,
  21752. switchFlag: 0
  21753. },
  21754. {
  21755. qe: 0x0049,
  21756. nmps: 41,
  21757. nlps: 38,
  21758. switchFlag: 0
  21759. },
  21760. {
  21761. qe: 0x0025,
  21762. nmps: 42,
  21763. nlps: 39,
  21764. switchFlag: 0
  21765. },
  21766. {
  21767. qe: 0x0015,
  21768. nmps: 43,
  21769. nlps: 40,
  21770. switchFlag: 0
  21771. },
  21772. {
  21773. qe: 0x0009,
  21774. nmps: 44,
  21775. nlps: 41,
  21776. switchFlag: 0
  21777. },
  21778. {
  21779. qe: 0x0005,
  21780. nmps: 45,
  21781. nlps: 42,
  21782. switchFlag: 0
  21783. },
  21784. {
  21785. qe: 0x0001,
  21786. nmps: 45,
  21787. nlps: 43,
  21788. switchFlag: 0
  21789. },
  21790. {
  21791. qe: 0x5601,
  21792. nmps: 46,
  21793. nlps: 46,
  21794. switchFlag: 0
  21795. }
  21796. ];
  21797. function ArithmeticDecoder(data, start, end) {
  21798. this.data = data;
  21799. this.bp = start;
  21800. this.dataEnd = end;
  21801. this.chigh = data[start];
  21802. this.clow = 0;
  21803. this.byteIn();
  21804. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  21805. this.clow = this.clow << 7 & 0xFFFF;
  21806. this.ct -= 7;
  21807. this.a = 0x8000;
  21808. }
  21809. ArithmeticDecoder.prototype = {
  21810. byteIn: function ArithmeticDecoder_byteIn() {
  21811. var data = this.data;
  21812. var bp = this.bp;
  21813. if (data[bp] === 0xFF) {
  21814. var b1 = data[bp + 1];
  21815. if (b1 > 0x8F) {
  21816. this.clow += 0xFF00;
  21817. this.ct = 8;
  21818. } else {
  21819. bp++;
  21820. this.clow += data[bp] << 9;
  21821. this.ct = 7;
  21822. this.bp = bp;
  21823. }
  21824. } else {
  21825. bp++;
  21826. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  21827. this.ct = 8;
  21828. this.bp = bp;
  21829. }
  21830. if (this.clow > 0xFFFF) {
  21831. this.chigh += this.clow >> 16;
  21832. this.clow &= 0xFFFF;
  21833. }
  21834. },
  21835. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  21836. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  21837. var qeTableIcx = QeTable[cx_index];
  21838. var qeIcx = qeTableIcx.qe;
  21839. var d;
  21840. var a = this.a - qeIcx;
  21841. if (this.chigh < qeIcx) {
  21842. if (a < qeIcx) {
  21843. a = qeIcx;
  21844. d = cx_mps;
  21845. cx_index = qeTableIcx.nmps;
  21846. } else {
  21847. a = qeIcx;
  21848. d = 1 ^ cx_mps;
  21849. if (qeTableIcx.switchFlag === 1) {
  21850. cx_mps = d;
  21851. }
  21852. cx_index = qeTableIcx.nlps;
  21853. }
  21854. } else {
  21855. this.chigh -= qeIcx;
  21856. if ((a & 0x8000) !== 0) {
  21857. this.a = a;
  21858. return cx_mps;
  21859. }
  21860. if (a < qeIcx) {
  21861. d = 1 ^ cx_mps;
  21862. if (qeTableIcx.switchFlag === 1) {
  21863. cx_mps = d;
  21864. }
  21865. cx_index = qeTableIcx.nlps;
  21866. } else {
  21867. d = cx_mps;
  21868. cx_index = qeTableIcx.nmps;
  21869. }
  21870. }
  21871. do {
  21872. if (this.ct === 0) {
  21873. this.byteIn();
  21874. }
  21875. a <<= 1;
  21876. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  21877. this.clow = this.clow << 1 & 0xFFFF;
  21878. this.ct--;
  21879. } while ((a & 0x8000) === 0);
  21880. this.a = a;
  21881. contexts[pos] = cx_index << 1 | cx_mps;
  21882. return d;
  21883. }
  21884. };
  21885. return ArithmeticDecoder;
  21886. }();
  21887. exports.ArithmeticDecoder = ArithmeticDecoder;
  21888. /***/ }),
  21889. /* 15 */
  21890. /***/ (function(module, exports, __w_pdfjs_require__) {
  21891. "use strict";
  21892. var sharedUtil = __w_pdfjs_require__(0);
  21893. var coreCharsets = __w_pdfjs_require__(29);
  21894. var coreEncodings = __w_pdfjs_require__(5);
  21895. var error = sharedUtil.error;
  21896. var info = sharedUtil.info;
  21897. var bytesToString = sharedUtil.bytesToString;
  21898. var warn = sharedUtil.warn;
  21899. var isArray = sharedUtil.isArray;
  21900. var Util = sharedUtil.Util;
  21901. var stringToBytes = sharedUtil.stringToBytes;
  21902. var assert = sharedUtil.assert;
  21903. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  21904. var ExpertCharset = coreCharsets.ExpertCharset;
  21905. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  21906. var StandardEncoding = coreEncodings.StandardEncoding;
  21907. var ExpertEncoding = coreEncodings.ExpertEncoding;
  21908. var MAX_SUBR_NESTING = 10;
  21909. var CFFStandardStrings = [
  21910. '.notdef',
  21911. 'space',
  21912. 'exclam',
  21913. 'quotedbl',
  21914. 'numbersign',
  21915. 'dollar',
  21916. 'percent',
  21917. 'ampersand',
  21918. 'quoteright',
  21919. 'parenleft',
  21920. 'parenright',
  21921. 'asterisk',
  21922. 'plus',
  21923. 'comma',
  21924. 'hyphen',
  21925. 'period',
  21926. 'slash',
  21927. 'zero',
  21928. 'one',
  21929. 'two',
  21930. 'three',
  21931. 'four',
  21932. 'five',
  21933. 'six',
  21934. 'seven',
  21935. 'eight',
  21936. 'nine',
  21937. 'colon',
  21938. 'semicolon',
  21939. 'less',
  21940. 'equal',
  21941. 'greater',
  21942. 'question',
  21943. 'at',
  21944. 'A',
  21945. 'B',
  21946. 'C',
  21947. 'D',
  21948. 'E',
  21949. 'F',
  21950. 'G',
  21951. 'H',
  21952. 'I',
  21953. 'J',
  21954. 'K',
  21955. 'L',
  21956. 'M',
  21957. 'N',
  21958. 'O',
  21959. 'P',
  21960. 'Q',
  21961. 'R',
  21962. 'S',
  21963. 'T',
  21964. 'U',
  21965. 'V',
  21966. 'W',
  21967. 'X',
  21968. 'Y',
  21969. 'Z',
  21970. 'bracketleft',
  21971. 'backslash',
  21972. 'bracketright',
  21973. 'asciicircum',
  21974. 'underscore',
  21975. 'quoteleft',
  21976. 'a',
  21977. 'b',
  21978. 'c',
  21979. 'd',
  21980. 'e',
  21981. 'f',
  21982. 'g',
  21983. 'h',
  21984. 'i',
  21985. 'j',
  21986. 'k',
  21987. 'l',
  21988. 'm',
  21989. 'n',
  21990. 'o',
  21991. 'p',
  21992. 'q',
  21993. 'r',
  21994. 's',
  21995. 't',
  21996. 'u',
  21997. 'v',
  21998. 'w',
  21999. 'x',
  22000. 'y',
  22001. 'z',
  22002. 'braceleft',
  22003. 'bar',
  22004. 'braceright',
  22005. 'asciitilde',
  22006. 'exclamdown',
  22007. 'cent',
  22008. 'sterling',
  22009. 'fraction',
  22010. 'yen',
  22011. 'florin',
  22012. 'section',
  22013. 'currency',
  22014. 'quotesingle',
  22015. 'quotedblleft',
  22016. 'guillemotleft',
  22017. 'guilsinglleft',
  22018. 'guilsinglright',
  22019. 'fi',
  22020. 'fl',
  22021. 'endash',
  22022. 'dagger',
  22023. 'daggerdbl',
  22024. 'periodcentered',
  22025. 'paragraph',
  22026. 'bullet',
  22027. 'quotesinglbase',
  22028. 'quotedblbase',
  22029. 'quotedblright',
  22030. 'guillemotright',
  22031. 'ellipsis',
  22032. 'perthousand',
  22033. 'questiondown',
  22034. 'grave',
  22035. 'acute',
  22036. 'circumflex',
  22037. 'tilde',
  22038. 'macron',
  22039. 'breve',
  22040. 'dotaccent',
  22041. 'dieresis',
  22042. 'ring',
  22043. 'cedilla',
  22044. 'hungarumlaut',
  22045. 'ogonek',
  22046. 'caron',
  22047. 'emdash',
  22048. 'AE',
  22049. 'ordfeminine',
  22050. 'Lslash',
  22051. 'Oslash',
  22052. 'OE',
  22053. 'ordmasculine',
  22054. 'ae',
  22055. 'dotlessi',
  22056. 'lslash',
  22057. 'oslash',
  22058. 'oe',
  22059. 'germandbls',
  22060. 'onesuperior',
  22061. 'logicalnot',
  22062. 'mu',
  22063. 'trademark',
  22064. 'Eth',
  22065. 'onehalf',
  22066. 'plusminus',
  22067. 'Thorn',
  22068. 'onequarter',
  22069. 'divide',
  22070. 'brokenbar',
  22071. 'degree',
  22072. 'thorn',
  22073. 'threequarters',
  22074. 'twosuperior',
  22075. 'registered',
  22076. 'minus',
  22077. 'eth',
  22078. 'multiply',
  22079. 'threesuperior',
  22080. 'copyright',
  22081. 'Aacute',
  22082. 'Acircumflex',
  22083. 'Adieresis',
  22084. 'Agrave',
  22085. 'Aring',
  22086. 'Atilde',
  22087. 'Ccedilla',
  22088. 'Eacute',
  22089. 'Ecircumflex',
  22090. 'Edieresis',
  22091. 'Egrave',
  22092. 'Iacute',
  22093. 'Icircumflex',
  22094. 'Idieresis',
  22095. 'Igrave',
  22096. 'Ntilde',
  22097. 'Oacute',
  22098. 'Ocircumflex',
  22099. 'Odieresis',
  22100. 'Ograve',
  22101. 'Otilde',
  22102. 'Scaron',
  22103. 'Uacute',
  22104. 'Ucircumflex',
  22105. 'Udieresis',
  22106. 'Ugrave',
  22107. 'Yacute',
  22108. 'Ydieresis',
  22109. 'Zcaron',
  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. 'exclamsmall',
  22140. 'Hungarumlautsmall',
  22141. 'dollaroldstyle',
  22142. 'dollarsuperior',
  22143. 'ampersandsmall',
  22144. 'Acutesmall',
  22145. 'parenleftsuperior',
  22146. 'parenrightsuperior',
  22147. 'twodotenleader',
  22148. 'onedotenleader',
  22149. 'zerooldstyle',
  22150. 'oneoldstyle',
  22151. 'twooldstyle',
  22152. 'threeoldstyle',
  22153. 'fouroldstyle',
  22154. 'fiveoldstyle',
  22155. 'sixoldstyle',
  22156. 'sevenoldstyle',
  22157. 'eightoldstyle',
  22158. 'nineoldstyle',
  22159. 'commasuperior',
  22160. 'threequartersemdash',
  22161. 'periodsuperior',
  22162. 'questionsmall',
  22163. 'asuperior',
  22164. 'bsuperior',
  22165. 'centsuperior',
  22166. 'dsuperior',
  22167. 'esuperior',
  22168. 'isuperior',
  22169. 'lsuperior',
  22170. 'msuperior',
  22171. 'nsuperior',
  22172. 'osuperior',
  22173. 'rsuperior',
  22174. 'ssuperior',
  22175. 'tsuperior',
  22176. 'ff',
  22177. 'ffi',
  22178. 'ffl',
  22179. 'parenleftinferior',
  22180. 'parenrightinferior',
  22181. 'Circumflexsmall',
  22182. 'hyphensuperior',
  22183. 'Gravesmall',
  22184. 'Asmall',
  22185. 'Bsmall',
  22186. 'Csmall',
  22187. 'Dsmall',
  22188. 'Esmall',
  22189. 'Fsmall',
  22190. 'Gsmall',
  22191. 'Hsmall',
  22192. 'Ismall',
  22193. 'Jsmall',
  22194. 'Ksmall',
  22195. 'Lsmall',
  22196. 'Msmall',
  22197. 'Nsmall',
  22198. 'Osmall',
  22199. 'Psmall',
  22200. 'Qsmall',
  22201. 'Rsmall',
  22202. 'Ssmall',
  22203. 'Tsmall',
  22204. 'Usmall',
  22205. 'Vsmall',
  22206. 'Wsmall',
  22207. 'Xsmall',
  22208. 'Ysmall',
  22209. 'Zsmall',
  22210. 'colonmonetary',
  22211. 'onefitted',
  22212. 'rupiah',
  22213. 'Tildesmall',
  22214. 'exclamdownsmall',
  22215. 'centoldstyle',
  22216. 'Lslashsmall',
  22217. 'Scaronsmall',
  22218. 'Zcaronsmall',
  22219. 'Dieresissmall',
  22220. 'Brevesmall',
  22221. 'Caronsmall',
  22222. 'Dotaccentsmall',
  22223. 'Macronsmall',
  22224. 'figuredash',
  22225. 'hypheninferior',
  22226. 'Ogoneksmall',
  22227. 'Ringsmall',
  22228. 'Cedillasmall',
  22229. 'questiondownsmall',
  22230. 'oneeighth',
  22231. 'threeeighths',
  22232. 'fiveeighths',
  22233. 'seveneighths',
  22234. 'onethird',
  22235. 'twothirds',
  22236. 'zerosuperior',
  22237. 'foursuperior',
  22238. 'fivesuperior',
  22239. 'sixsuperior',
  22240. 'sevensuperior',
  22241. 'eightsuperior',
  22242. 'ninesuperior',
  22243. 'zeroinferior',
  22244. 'oneinferior',
  22245. 'twoinferior',
  22246. 'threeinferior',
  22247. 'fourinferior',
  22248. 'fiveinferior',
  22249. 'sixinferior',
  22250. 'seveninferior',
  22251. 'eightinferior',
  22252. 'nineinferior',
  22253. 'centinferior',
  22254. 'dollarinferior',
  22255. 'periodinferior',
  22256. 'commainferior',
  22257. 'Agravesmall',
  22258. 'Aacutesmall',
  22259. 'Acircumflexsmall',
  22260. 'Atildesmall',
  22261. 'Adieresissmall',
  22262. 'Aringsmall',
  22263. 'AEsmall',
  22264. 'Ccedillasmall',
  22265. 'Egravesmall',
  22266. 'Eacutesmall',
  22267. 'Ecircumflexsmall',
  22268. 'Edieresissmall',
  22269. 'Igravesmall',
  22270. 'Iacutesmall',
  22271. 'Icircumflexsmall',
  22272. 'Idieresissmall',
  22273. 'Ethsmall',
  22274. 'Ntildesmall',
  22275. 'Ogravesmall',
  22276. 'Oacutesmall',
  22277. 'Ocircumflexsmall',
  22278. 'Otildesmall',
  22279. 'Odieresissmall',
  22280. 'OEsmall',
  22281. 'Oslashsmall',
  22282. 'Ugravesmall',
  22283. 'Uacutesmall',
  22284. 'Ucircumflexsmall',
  22285. 'Udieresissmall',
  22286. 'Yacutesmall',
  22287. 'Thornsmall',
  22288. 'Ydieresissmall',
  22289. '001.000',
  22290. '001.001',
  22291. '001.002',
  22292. '001.003',
  22293. 'Black',
  22294. 'Bold',
  22295. 'Book',
  22296. 'Light',
  22297. 'Medium',
  22298. 'Regular',
  22299. 'Roman',
  22300. 'Semibold'
  22301. ];
  22302. var CFFParser = function CFFParserClosure() {
  22303. var CharstringValidationData = [
  22304. null,
  22305. {
  22306. id: 'hstem',
  22307. min: 2,
  22308. stackClearing: true,
  22309. stem: true
  22310. },
  22311. null,
  22312. {
  22313. id: 'vstem',
  22314. min: 2,
  22315. stackClearing: true,
  22316. stem: true
  22317. },
  22318. {
  22319. id: 'vmoveto',
  22320. min: 1,
  22321. stackClearing: true
  22322. },
  22323. {
  22324. id: 'rlineto',
  22325. min: 2,
  22326. resetStack: true
  22327. },
  22328. {
  22329. id: 'hlineto',
  22330. min: 1,
  22331. resetStack: true
  22332. },
  22333. {
  22334. id: 'vlineto',
  22335. min: 1,
  22336. resetStack: true
  22337. },
  22338. {
  22339. id: 'rrcurveto',
  22340. min: 6,
  22341. resetStack: true
  22342. },
  22343. null,
  22344. {
  22345. id: 'callsubr',
  22346. min: 1,
  22347. undefStack: true
  22348. },
  22349. {
  22350. id: 'return',
  22351. min: 0,
  22352. undefStack: true
  22353. },
  22354. null,
  22355. null,
  22356. {
  22357. id: 'endchar',
  22358. min: 0,
  22359. stackClearing: true
  22360. },
  22361. null,
  22362. null,
  22363. null,
  22364. {
  22365. id: 'hstemhm',
  22366. min: 2,
  22367. stackClearing: true,
  22368. stem: true
  22369. },
  22370. {
  22371. id: 'hintmask',
  22372. min: 0,
  22373. stackClearing: true
  22374. },
  22375. {
  22376. id: 'cntrmask',
  22377. min: 0,
  22378. stackClearing: true
  22379. },
  22380. {
  22381. id: 'rmoveto',
  22382. min: 2,
  22383. stackClearing: true
  22384. },
  22385. {
  22386. id: 'hmoveto',
  22387. min: 1,
  22388. stackClearing: true
  22389. },
  22390. {
  22391. id: 'vstemhm',
  22392. min: 2,
  22393. stackClearing: true,
  22394. stem: true
  22395. },
  22396. {
  22397. id: 'rcurveline',
  22398. min: 8,
  22399. resetStack: true
  22400. },
  22401. {
  22402. id: 'rlinecurve',
  22403. min: 8,
  22404. resetStack: true
  22405. },
  22406. {
  22407. id: 'vvcurveto',
  22408. min: 4,
  22409. resetStack: true
  22410. },
  22411. {
  22412. id: 'hhcurveto',
  22413. min: 4,
  22414. resetStack: true
  22415. },
  22416. null,
  22417. {
  22418. id: 'callgsubr',
  22419. min: 1,
  22420. undefStack: true
  22421. },
  22422. {
  22423. id: 'vhcurveto',
  22424. min: 4,
  22425. resetStack: true
  22426. },
  22427. {
  22428. id: 'hvcurveto',
  22429. min: 4,
  22430. resetStack: true
  22431. }
  22432. ];
  22433. var CharstringValidationData12 = [
  22434. null,
  22435. null,
  22436. null,
  22437. {
  22438. id: 'and',
  22439. min: 2,
  22440. stackDelta: -1
  22441. },
  22442. {
  22443. id: 'or',
  22444. min: 2,
  22445. stackDelta: -1
  22446. },
  22447. {
  22448. id: 'not',
  22449. min: 1,
  22450. stackDelta: 0
  22451. },
  22452. null,
  22453. null,
  22454. null,
  22455. {
  22456. id: 'abs',
  22457. min: 1,
  22458. stackDelta: 0
  22459. },
  22460. {
  22461. id: 'add',
  22462. min: 2,
  22463. stackDelta: -1,
  22464. stackFn: function stack_div(stack, index) {
  22465. stack[index - 2] = stack[index - 2] + stack[index - 1];
  22466. }
  22467. },
  22468. {
  22469. id: 'sub',
  22470. min: 2,
  22471. stackDelta: -1,
  22472. stackFn: function stack_div(stack, index) {
  22473. stack[index - 2] = stack[index - 2] - stack[index - 1];
  22474. }
  22475. },
  22476. {
  22477. id: 'div',
  22478. min: 2,
  22479. stackDelta: -1,
  22480. stackFn: function stack_div(stack, index) {
  22481. stack[index - 2] = stack[index - 2] / stack[index - 1];
  22482. }
  22483. },
  22484. null,
  22485. {
  22486. id: 'neg',
  22487. min: 1,
  22488. stackDelta: 0,
  22489. stackFn: function stack_div(stack, index) {
  22490. stack[index - 1] = -stack[index - 1];
  22491. }
  22492. },
  22493. {
  22494. id: 'eq',
  22495. min: 2,
  22496. stackDelta: -1
  22497. },
  22498. null,
  22499. null,
  22500. {
  22501. id: 'drop',
  22502. min: 1,
  22503. stackDelta: -1
  22504. },
  22505. null,
  22506. {
  22507. id: 'put',
  22508. min: 2,
  22509. stackDelta: -2
  22510. },
  22511. {
  22512. id: 'get',
  22513. min: 1,
  22514. stackDelta: 0
  22515. },
  22516. {
  22517. id: 'ifelse',
  22518. min: 4,
  22519. stackDelta: -3
  22520. },
  22521. {
  22522. id: 'random',
  22523. min: 0,
  22524. stackDelta: 1
  22525. },
  22526. {
  22527. id: 'mul',
  22528. min: 2,
  22529. stackDelta: -1,
  22530. stackFn: function stack_div(stack, index) {
  22531. stack[index - 2] = stack[index - 2] * stack[index - 1];
  22532. }
  22533. },
  22534. null,
  22535. {
  22536. id: 'sqrt',
  22537. min: 1,
  22538. stackDelta: 0
  22539. },
  22540. {
  22541. id: 'dup',
  22542. min: 1,
  22543. stackDelta: 1
  22544. },
  22545. {
  22546. id: 'exch',
  22547. min: 2,
  22548. stackDelta: 0
  22549. },
  22550. {
  22551. id: 'index',
  22552. min: 2,
  22553. stackDelta: 0
  22554. },
  22555. {
  22556. id: 'roll',
  22557. min: 3,
  22558. stackDelta: -2
  22559. },
  22560. null,
  22561. null,
  22562. null,
  22563. {
  22564. id: 'hflex',
  22565. min: 7,
  22566. resetStack: true
  22567. },
  22568. {
  22569. id: 'flex',
  22570. min: 13,
  22571. resetStack: true
  22572. },
  22573. {
  22574. id: 'hflex1',
  22575. min: 9,
  22576. resetStack: true
  22577. },
  22578. {
  22579. id: 'flex1',
  22580. min: 11,
  22581. resetStack: true
  22582. }
  22583. ];
  22584. function CFFParser(file, properties, seacAnalysisEnabled) {
  22585. this.bytes = file.getBytes();
  22586. this.properties = properties;
  22587. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  22588. }
  22589. CFFParser.prototype = {
  22590. parse: function CFFParser_parse() {
  22591. var properties = this.properties;
  22592. var cff = new CFF();
  22593. this.cff = cff;
  22594. var header = this.parseHeader();
  22595. var nameIndex = this.parseIndex(header.endPos);
  22596. var topDictIndex = this.parseIndex(nameIndex.endPos);
  22597. var stringIndex = this.parseIndex(topDictIndex.endPos);
  22598. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  22599. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  22600. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  22601. cff.header = header.obj;
  22602. cff.names = this.parseNameIndex(nameIndex.obj);
  22603. cff.strings = this.parseStringIndex(stringIndex.obj);
  22604. cff.topDict = topDict;
  22605. cff.globalSubrIndex = globalSubrIndex.obj;
  22606. this.parsePrivateDict(cff.topDict);
  22607. cff.isCIDFont = topDict.hasName('ROS');
  22608. var charStringOffset = topDict.getByName('CharStrings');
  22609. var charStringIndex = this.parseIndex(charStringOffset).obj;
  22610. var fontMatrix = topDict.getByName('FontMatrix');
  22611. if (fontMatrix) {
  22612. properties.fontMatrix = fontMatrix;
  22613. }
  22614. var fontBBox = topDict.getByName('FontBBox');
  22615. if (fontBBox) {
  22616. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  22617. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  22618. properties.ascentScaled = true;
  22619. }
  22620. var charset, encoding;
  22621. if (cff.isCIDFont) {
  22622. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  22623. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  22624. var dictRaw = fdArrayIndex.get(i);
  22625. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  22626. this.parsePrivateDict(fontDict);
  22627. cff.fdArray.push(fontDict);
  22628. }
  22629. encoding = null;
  22630. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  22631. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  22632. } else {
  22633. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  22634. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  22635. }
  22636. cff.charset = charset;
  22637. cff.encoding = encoding;
  22638. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  22639. cff.charStrings = charStringsAndSeacs.charStrings;
  22640. cff.seacs = charStringsAndSeacs.seacs;
  22641. cff.widths = charStringsAndSeacs.widths;
  22642. return cff;
  22643. },
  22644. parseHeader: function CFFParser_parseHeader() {
  22645. var bytes = this.bytes;
  22646. var bytesLength = bytes.length;
  22647. var offset = 0;
  22648. while (offset < bytesLength && bytes[offset] !== 1) {
  22649. ++offset;
  22650. }
  22651. if (offset >= bytesLength) {
  22652. error('Invalid CFF header');
  22653. } else if (offset !== 0) {
  22654. info('cff data is shifted');
  22655. bytes = bytes.subarray(offset);
  22656. this.bytes = bytes;
  22657. }
  22658. var major = bytes[0];
  22659. var minor = bytes[1];
  22660. var hdrSize = bytes[2];
  22661. var offSize = bytes[3];
  22662. var header = new CFFHeader(major, minor, hdrSize, offSize);
  22663. return {
  22664. obj: header,
  22665. endPos: hdrSize
  22666. };
  22667. },
  22668. parseDict: function CFFParser_parseDict(dict) {
  22669. var pos = 0;
  22670. function parseOperand() {
  22671. var value = dict[pos++];
  22672. if (value === 30) {
  22673. return parseFloatOperand();
  22674. } else if (value === 28) {
  22675. value = dict[pos++];
  22676. value = (value << 24 | dict[pos++] << 16) >> 16;
  22677. return value;
  22678. } else if (value === 29) {
  22679. value = dict[pos++];
  22680. value = value << 8 | dict[pos++];
  22681. value = value << 8 | dict[pos++];
  22682. value = value << 8 | dict[pos++];
  22683. return value;
  22684. } else if (value >= 32 && value <= 246) {
  22685. return value - 139;
  22686. } else if (value >= 247 && value <= 250) {
  22687. return (value - 247) * 256 + dict[pos++] + 108;
  22688. } else if (value >= 251 && value <= 254) {
  22689. return -((value - 251) * 256) - dict[pos++] - 108;
  22690. }
  22691. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  22692. return NaN;
  22693. }
  22694. function parseFloatOperand() {
  22695. var str = '';
  22696. var eof = 15;
  22697. var lookup = [
  22698. '0',
  22699. '1',
  22700. '2',
  22701. '3',
  22702. '4',
  22703. '5',
  22704. '6',
  22705. '7',
  22706. '8',
  22707. '9',
  22708. '.',
  22709. 'E',
  22710. 'E-',
  22711. null,
  22712. '-'
  22713. ];
  22714. var length = dict.length;
  22715. while (pos < length) {
  22716. var b = dict[pos++];
  22717. var b1 = b >> 4;
  22718. var b2 = b & 15;
  22719. if (b1 === eof) {
  22720. break;
  22721. }
  22722. str += lookup[b1];
  22723. if (b2 === eof) {
  22724. break;
  22725. }
  22726. str += lookup[b2];
  22727. }
  22728. return parseFloat(str);
  22729. }
  22730. var operands = [];
  22731. var entries = [];
  22732. pos = 0;
  22733. var end = dict.length;
  22734. while (pos < end) {
  22735. var b = dict[pos];
  22736. if (b <= 21) {
  22737. if (b === 12) {
  22738. b = b << 8 | dict[++pos];
  22739. }
  22740. entries.push([
  22741. b,
  22742. operands
  22743. ]);
  22744. operands = [];
  22745. ++pos;
  22746. } else {
  22747. operands.push(parseOperand());
  22748. }
  22749. }
  22750. return entries;
  22751. },
  22752. parseIndex: function CFFParser_parseIndex(pos) {
  22753. var cffIndex = new CFFIndex();
  22754. var bytes = this.bytes;
  22755. var count = bytes[pos++] << 8 | bytes[pos++];
  22756. var offsets = [];
  22757. var end = pos;
  22758. var i, ii;
  22759. if (count !== 0) {
  22760. var offsetSize = bytes[pos++];
  22761. var startPos = pos + (count + 1) * offsetSize - 1;
  22762. for (i = 0, ii = count + 1; i < ii; ++i) {
  22763. var offset = 0;
  22764. for (var j = 0; j < offsetSize; ++j) {
  22765. offset <<= 8;
  22766. offset += bytes[pos++];
  22767. }
  22768. offsets.push(startPos + offset);
  22769. }
  22770. end = offsets[count];
  22771. }
  22772. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  22773. var offsetStart = offsets[i];
  22774. var offsetEnd = offsets[i + 1];
  22775. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  22776. }
  22777. return {
  22778. obj: cffIndex,
  22779. endPos: end
  22780. };
  22781. },
  22782. parseNameIndex: function CFFParser_parseNameIndex(index) {
  22783. var names = [];
  22784. for (var i = 0, ii = index.count; i < ii; ++i) {
  22785. var name = index.get(i);
  22786. var length = Math.min(name.length, 127);
  22787. var data = [];
  22788. for (var j = 0; j < length; ++j) {
  22789. var c = name[j];
  22790. if (j === 0 && c === 0) {
  22791. data[j] = c;
  22792. continue;
  22793. }
  22794. 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) {
  22795. data[j] = 95;
  22796. continue;
  22797. }
  22798. data[j] = c;
  22799. }
  22800. names.push(bytesToString(data));
  22801. }
  22802. return names;
  22803. },
  22804. parseStringIndex: function CFFParser_parseStringIndex(index) {
  22805. var strings = new CFFStrings();
  22806. for (var i = 0, ii = index.count; i < ii; ++i) {
  22807. var data = index.get(i);
  22808. strings.add(bytesToString(data));
  22809. }
  22810. return strings;
  22811. },
  22812. createDict: function CFFParser_createDict(Type, dict, strings) {
  22813. var cffDict = new Type(strings);
  22814. for (var i = 0, ii = dict.length; i < ii; ++i) {
  22815. var pair = dict[i];
  22816. var key = pair[0];
  22817. var value = pair[1];
  22818. cffDict.setByKey(key, value);
  22819. }
  22820. return cffDict;
  22821. },
  22822. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  22823. if (state.callDepth > MAX_SUBR_NESTING) {
  22824. return false;
  22825. }
  22826. var stackSize = state.stackSize;
  22827. var stack = state.stack;
  22828. var length = data.length;
  22829. for (var j = 0; j < length;) {
  22830. var value = data[j++];
  22831. var validationCommand = null;
  22832. if (value === 12) {
  22833. var q = data[j++];
  22834. if (q === 0) {
  22835. data[j - 2] = 139;
  22836. data[j - 1] = 22;
  22837. stackSize = 0;
  22838. } else {
  22839. validationCommand = CharstringValidationData12[q];
  22840. }
  22841. } else if (value === 28) {
  22842. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  22843. j += 2;
  22844. stackSize++;
  22845. } else if (value === 14) {
  22846. if (stackSize >= 4) {
  22847. stackSize -= 4;
  22848. if (this.seacAnalysisEnabled) {
  22849. state.seac = stack.slice(stackSize, stackSize + 4);
  22850. return false;
  22851. }
  22852. }
  22853. validationCommand = CharstringValidationData[value];
  22854. } else if (value >= 32 && value <= 246) {
  22855. stack[stackSize] = value - 139;
  22856. stackSize++;
  22857. } else if (value >= 247 && value <= 254) {
  22858. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  22859. j++;
  22860. stackSize++;
  22861. } else if (value === 255) {
  22862. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  22863. j += 4;
  22864. stackSize++;
  22865. } else if (value === 19 || value === 20) {
  22866. state.hints += stackSize >> 1;
  22867. j += state.hints + 7 >> 3;
  22868. stackSize %= 2;
  22869. validationCommand = CharstringValidationData[value];
  22870. } else if (value === 10 || value === 29) {
  22871. var subrsIndex;
  22872. if (value === 10) {
  22873. subrsIndex = localSubrIndex;
  22874. } else {
  22875. subrsIndex = globalSubrIndex;
  22876. }
  22877. if (!subrsIndex) {
  22878. validationCommand = CharstringValidationData[value];
  22879. warn('Missing subrsIndex for ' + validationCommand.id);
  22880. return false;
  22881. }
  22882. var bias = 32768;
  22883. if (subrsIndex.count < 1240) {
  22884. bias = 107;
  22885. } else if (subrsIndex.count < 33900) {
  22886. bias = 1131;
  22887. }
  22888. var subrNumber = stack[--stackSize] + bias;
  22889. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  22890. validationCommand = CharstringValidationData[value];
  22891. warn('Out of bounds subrIndex for ' + validationCommand.id);
  22892. return false;
  22893. }
  22894. state.stackSize = stackSize;
  22895. state.callDepth++;
  22896. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  22897. if (!valid) {
  22898. return false;
  22899. }
  22900. state.callDepth--;
  22901. stackSize = state.stackSize;
  22902. continue;
  22903. } else if (value === 11) {
  22904. state.stackSize = stackSize;
  22905. return true;
  22906. } else {
  22907. validationCommand = CharstringValidationData[value];
  22908. }
  22909. if (validationCommand) {
  22910. if (validationCommand.stem) {
  22911. state.hints += stackSize >> 1;
  22912. }
  22913. if ('min' in validationCommand) {
  22914. if (!state.undefStack && stackSize < validationCommand.min) {
  22915. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  22916. return false;
  22917. }
  22918. }
  22919. if (state.firstStackClearing && validationCommand.stackClearing) {
  22920. state.firstStackClearing = false;
  22921. stackSize -= validationCommand.min;
  22922. if (stackSize >= 2 && validationCommand.stem) {
  22923. stackSize %= 2;
  22924. } else if (stackSize > 1) {
  22925. warn('Found too many parameters for stack-clearing command');
  22926. }
  22927. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  22928. state.width = stack[stackSize - 1];
  22929. }
  22930. }
  22931. if ('stackDelta' in validationCommand) {
  22932. if ('stackFn' in validationCommand) {
  22933. validationCommand.stackFn(stack, stackSize);
  22934. }
  22935. stackSize += validationCommand.stackDelta;
  22936. } else if (validationCommand.stackClearing) {
  22937. stackSize = 0;
  22938. } else if (validationCommand.resetStack) {
  22939. stackSize = 0;
  22940. state.undefStack = false;
  22941. } else if (validationCommand.undefStack) {
  22942. stackSize = 0;
  22943. state.undefStack = true;
  22944. state.firstStackClearing = false;
  22945. }
  22946. }
  22947. }
  22948. state.stackSize = stackSize;
  22949. return true;
  22950. },
  22951. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  22952. var seacs = [];
  22953. var widths = [];
  22954. var count = charStrings.count;
  22955. for (var i = 0; i < count; i++) {
  22956. var charstring = charStrings.get(i);
  22957. var state = {
  22958. callDepth: 0,
  22959. stackSize: 0,
  22960. stack: [],
  22961. undefStack: true,
  22962. hints: 0,
  22963. firstStackClearing: true,
  22964. seac: null,
  22965. width: null
  22966. };
  22967. var valid = true;
  22968. var localSubrToUse = null;
  22969. if (fdSelect && fdArray.length) {
  22970. var fdIndex = fdSelect.getFDIndex(i);
  22971. if (fdIndex === -1) {
  22972. warn('Glyph index is not in fd select.');
  22973. valid = false;
  22974. }
  22975. if (fdIndex >= fdArray.length) {
  22976. warn('Invalid fd index for glyph index.');
  22977. valid = false;
  22978. }
  22979. if (valid) {
  22980. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  22981. }
  22982. } else if (localSubrIndex) {
  22983. localSubrToUse = localSubrIndex;
  22984. }
  22985. if (valid) {
  22986. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  22987. }
  22988. if (state.width !== null) {
  22989. widths[i] = state.width;
  22990. }
  22991. if (state.seac !== null) {
  22992. seacs[i] = state.seac;
  22993. }
  22994. if (!valid) {
  22995. charStrings.set(i, new Uint8Array([14]));
  22996. }
  22997. }
  22998. return {
  22999. charStrings: charStrings,
  23000. seacs: seacs,
  23001. widths: widths
  23002. };
  23003. },
  23004. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23005. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23006. parentDict.setByKey(18, [
  23007. 0,
  23008. 0
  23009. ]);
  23010. parentDict.privateDict = privateDict;
  23011. },
  23012. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23013. if (!parentDict.hasName('Private')) {
  23014. this.emptyPrivateDictionary(parentDict);
  23015. return;
  23016. }
  23017. var privateOffset = parentDict.getByName('Private');
  23018. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23019. parentDict.removeByName('Private');
  23020. return;
  23021. }
  23022. var size = privateOffset[0];
  23023. var offset = privateOffset[1];
  23024. if (size === 0 || offset >= this.bytes.length) {
  23025. this.emptyPrivateDictionary(parentDict);
  23026. return;
  23027. }
  23028. var privateDictEnd = offset + size;
  23029. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23030. var dict = this.parseDict(dictData);
  23031. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23032. parentDict.privateDict = privateDict;
  23033. if (!privateDict.getByName('Subrs')) {
  23034. return;
  23035. }
  23036. var subrsOffset = privateDict.getByName('Subrs');
  23037. var relativeOffset = offset + subrsOffset;
  23038. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23039. this.emptyPrivateDictionary(parentDict);
  23040. return;
  23041. }
  23042. var subrsIndex = this.parseIndex(relativeOffset);
  23043. privateDict.subrsIndex = subrsIndex.obj;
  23044. },
  23045. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23046. if (pos === 0) {
  23047. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23048. } else if (pos === 1) {
  23049. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23050. } else if (pos === 2) {
  23051. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23052. }
  23053. var bytes = this.bytes;
  23054. var start = pos;
  23055. var format = bytes[pos++];
  23056. var charset = ['.notdef'];
  23057. var id, count, i;
  23058. length -= 1;
  23059. switch (format) {
  23060. case 0:
  23061. for (i = 0; i < length; i++) {
  23062. id = bytes[pos++] << 8 | bytes[pos++];
  23063. charset.push(cid ? id : strings.get(id));
  23064. }
  23065. break;
  23066. case 1:
  23067. while (charset.length <= length) {
  23068. id = bytes[pos++] << 8 | bytes[pos++];
  23069. count = bytes[pos++];
  23070. for (i = 0; i <= count; i++) {
  23071. charset.push(cid ? id++ : strings.get(id++));
  23072. }
  23073. }
  23074. break;
  23075. case 2:
  23076. while (charset.length <= length) {
  23077. id = bytes[pos++] << 8 | bytes[pos++];
  23078. count = bytes[pos++] << 8 | bytes[pos++];
  23079. for (i = 0; i <= count; i++) {
  23080. charset.push(cid ? id++ : strings.get(id++));
  23081. }
  23082. }
  23083. break;
  23084. default:
  23085. error('Unknown charset format');
  23086. }
  23087. var end = pos;
  23088. var raw = bytes.subarray(start, end);
  23089. return new CFFCharset(false, format, charset, raw);
  23090. },
  23091. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23092. var encoding = Object.create(null);
  23093. var bytes = this.bytes;
  23094. var predefined = false;
  23095. var format, i, ii;
  23096. var raw = null;
  23097. function readSupplement() {
  23098. var supplementsCount = bytes[pos++];
  23099. for (i = 0; i < supplementsCount; i++) {
  23100. var code = bytes[pos++];
  23101. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23102. encoding[code] = charset.indexOf(strings.get(sid));
  23103. }
  23104. }
  23105. if (pos === 0 || pos === 1) {
  23106. predefined = true;
  23107. format = pos;
  23108. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23109. for (i = 0, ii = charset.length; i < ii; i++) {
  23110. var index = baseEncoding.indexOf(charset[i]);
  23111. if (index !== -1) {
  23112. encoding[index] = i;
  23113. }
  23114. }
  23115. } else {
  23116. var dataStart = pos;
  23117. format = bytes[pos++];
  23118. switch (format & 0x7f) {
  23119. case 0:
  23120. var glyphsCount = bytes[pos++];
  23121. for (i = 1; i <= glyphsCount; i++) {
  23122. encoding[bytes[pos++]] = i;
  23123. }
  23124. break;
  23125. case 1:
  23126. var rangesCount = bytes[pos++];
  23127. var gid = 1;
  23128. for (i = 0; i < rangesCount; i++) {
  23129. var start = bytes[pos++];
  23130. var left = bytes[pos++];
  23131. for (var j = start; j <= start + left; j++) {
  23132. encoding[j] = gid++;
  23133. }
  23134. }
  23135. break;
  23136. default:
  23137. error('Unknown encoding format: ' + format + ' in CFF');
  23138. break;
  23139. }
  23140. var dataEnd = pos;
  23141. if (format & 0x80) {
  23142. bytes[dataStart] &= 0x7f;
  23143. readSupplement();
  23144. }
  23145. raw = bytes.subarray(dataStart, dataEnd);
  23146. }
  23147. format = format & 0x7f;
  23148. return new CFFEncoding(predefined, format, encoding, raw);
  23149. },
  23150. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23151. var start = pos;
  23152. var bytes = this.bytes;
  23153. var format = bytes[pos++];
  23154. var fdSelect = [], rawBytes;
  23155. var i, invalidFirstGID = false;
  23156. switch (format) {
  23157. case 0:
  23158. for (i = 0; i < length; ++i) {
  23159. var id = bytes[pos++];
  23160. fdSelect.push(id);
  23161. }
  23162. rawBytes = bytes.subarray(start, pos);
  23163. break;
  23164. case 3:
  23165. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23166. for (i = 0; i < rangesCount; ++i) {
  23167. var first = bytes[pos++] << 8 | bytes[pos++];
  23168. if (i === 0 && first !== 0) {
  23169. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23170. invalidFirstGID = true;
  23171. first = 0;
  23172. }
  23173. var fdIndex = bytes[pos++];
  23174. var next = bytes[pos] << 8 | bytes[pos + 1];
  23175. for (var j = first; j < next; ++j) {
  23176. fdSelect.push(fdIndex);
  23177. }
  23178. }
  23179. pos += 2;
  23180. rawBytes = bytes.subarray(start, pos);
  23181. if (invalidFirstGID) {
  23182. rawBytes[3] = rawBytes[4] = 0;
  23183. }
  23184. break;
  23185. default:
  23186. error('parseFDSelect: Unknown format "' + format + '".');
  23187. break;
  23188. }
  23189. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23190. return new CFFFDSelect(fdSelect, rawBytes);
  23191. }
  23192. };
  23193. return CFFParser;
  23194. }();
  23195. var CFF = function CFFClosure() {
  23196. function CFF() {
  23197. this.header = null;
  23198. this.names = [];
  23199. this.topDict = null;
  23200. this.strings = new CFFStrings();
  23201. this.globalSubrIndex = null;
  23202. this.encoding = null;
  23203. this.charset = null;
  23204. this.charStrings = null;
  23205. this.fdArray = [];
  23206. this.fdSelect = null;
  23207. this.isCIDFont = false;
  23208. }
  23209. return CFF;
  23210. }();
  23211. var CFFHeader = function CFFHeaderClosure() {
  23212. function CFFHeader(major, minor, hdrSize, offSize) {
  23213. this.major = major;
  23214. this.minor = minor;
  23215. this.hdrSize = hdrSize;
  23216. this.offSize = offSize;
  23217. }
  23218. return CFFHeader;
  23219. }();
  23220. var CFFStrings = function CFFStringsClosure() {
  23221. function CFFStrings() {
  23222. this.strings = [];
  23223. }
  23224. CFFStrings.prototype = {
  23225. get: function CFFStrings_get(index) {
  23226. if (index >= 0 && index <= 390) {
  23227. return CFFStandardStrings[index];
  23228. }
  23229. if (index - 391 <= this.strings.length) {
  23230. return this.strings[index - 391];
  23231. }
  23232. return CFFStandardStrings[0];
  23233. },
  23234. add: function CFFStrings_add(value) {
  23235. this.strings.push(value);
  23236. },
  23237. get count() {
  23238. return this.strings.length;
  23239. }
  23240. };
  23241. return CFFStrings;
  23242. }();
  23243. var CFFIndex = function CFFIndexClosure() {
  23244. function CFFIndex() {
  23245. this.objects = [];
  23246. this.length = 0;
  23247. }
  23248. CFFIndex.prototype = {
  23249. add: function CFFIndex_add(data) {
  23250. this.length += data.length;
  23251. this.objects.push(data);
  23252. },
  23253. set: function CFFIndex_set(index, data) {
  23254. this.length += data.length - this.objects[index].length;
  23255. this.objects[index] = data;
  23256. },
  23257. get: function CFFIndex_get(index) {
  23258. return this.objects[index];
  23259. },
  23260. get count() {
  23261. return this.objects.length;
  23262. }
  23263. };
  23264. return CFFIndex;
  23265. }();
  23266. var CFFDict = function CFFDictClosure() {
  23267. function CFFDict(tables, strings) {
  23268. this.keyToNameMap = tables.keyToNameMap;
  23269. this.nameToKeyMap = tables.nameToKeyMap;
  23270. this.defaults = tables.defaults;
  23271. this.types = tables.types;
  23272. this.opcodes = tables.opcodes;
  23273. this.order = tables.order;
  23274. this.strings = strings;
  23275. this.values = Object.create(null);
  23276. }
  23277. CFFDict.prototype = {
  23278. setByKey: function CFFDict_setByKey(key, value) {
  23279. if (!(key in this.keyToNameMap)) {
  23280. return false;
  23281. }
  23282. var valueLength = value.length;
  23283. if (valueLength === 0) {
  23284. return true;
  23285. }
  23286. for (var i = 0; i < valueLength; i++) {
  23287. if (isNaN(value[i])) {
  23288. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  23289. return true;
  23290. }
  23291. }
  23292. var type = this.types[key];
  23293. if (type === 'num' || type === 'sid' || type === 'offset') {
  23294. value = value[0];
  23295. }
  23296. this.values[key] = value;
  23297. return true;
  23298. },
  23299. setByName: function CFFDict_setByName(name, value) {
  23300. if (!(name in this.nameToKeyMap)) {
  23301. error('Invalid dictionary name "' + name + '"');
  23302. }
  23303. this.values[this.nameToKeyMap[name]] = value;
  23304. },
  23305. hasName: function CFFDict_hasName(name) {
  23306. return this.nameToKeyMap[name] in this.values;
  23307. },
  23308. getByName: function CFFDict_getByName(name) {
  23309. if (!(name in this.nameToKeyMap)) {
  23310. error('Invalid dictionary name "' + name + '"');
  23311. }
  23312. var key = this.nameToKeyMap[name];
  23313. if (!(key in this.values)) {
  23314. return this.defaults[key];
  23315. }
  23316. return this.values[key];
  23317. },
  23318. removeByName: function CFFDict_removeByName(name) {
  23319. delete this.values[this.nameToKeyMap[name]];
  23320. }
  23321. };
  23322. CFFDict.createTables = function CFFDict_createTables(layout) {
  23323. var tables = {
  23324. keyToNameMap: {},
  23325. nameToKeyMap: {},
  23326. defaults: {},
  23327. types: {},
  23328. opcodes: {},
  23329. order: []
  23330. };
  23331. for (var i = 0, ii = layout.length; i < ii; ++i) {
  23332. var entry = layout[i];
  23333. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  23334. tables.keyToNameMap[key] = entry[1];
  23335. tables.nameToKeyMap[entry[1]] = key;
  23336. tables.types[key] = entry[2];
  23337. tables.defaults[key] = entry[3];
  23338. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  23339. tables.order.push(key);
  23340. }
  23341. return tables;
  23342. };
  23343. return CFFDict;
  23344. }();
  23345. var CFFTopDict = function CFFTopDictClosure() {
  23346. var layout = [
  23347. [
  23348. [
  23349. 12,
  23350. 30
  23351. ],
  23352. 'ROS',
  23353. [
  23354. 'sid',
  23355. 'sid',
  23356. 'num'
  23357. ],
  23358. null
  23359. ],
  23360. [
  23361. [
  23362. 12,
  23363. 20
  23364. ],
  23365. 'SyntheticBase',
  23366. 'num',
  23367. null
  23368. ],
  23369. [
  23370. 0,
  23371. 'version',
  23372. 'sid',
  23373. null
  23374. ],
  23375. [
  23376. 1,
  23377. 'Notice',
  23378. 'sid',
  23379. null
  23380. ],
  23381. [
  23382. [
  23383. 12,
  23384. 0
  23385. ],
  23386. 'Copyright',
  23387. 'sid',
  23388. null
  23389. ],
  23390. [
  23391. 2,
  23392. 'FullName',
  23393. 'sid',
  23394. null
  23395. ],
  23396. [
  23397. 3,
  23398. 'FamilyName',
  23399. 'sid',
  23400. null
  23401. ],
  23402. [
  23403. 4,
  23404. 'Weight',
  23405. 'sid',
  23406. null
  23407. ],
  23408. [
  23409. [
  23410. 12,
  23411. 1
  23412. ],
  23413. 'isFixedPitch',
  23414. 'num',
  23415. 0
  23416. ],
  23417. [
  23418. [
  23419. 12,
  23420. 2
  23421. ],
  23422. 'ItalicAngle',
  23423. 'num',
  23424. 0
  23425. ],
  23426. [
  23427. [
  23428. 12,
  23429. 3
  23430. ],
  23431. 'UnderlinePosition',
  23432. 'num',
  23433. -100
  23434. ],
  23435. [
  23436. [
  23437. 12,
  23438. 4
  23439. ],
  23440. 'UnderlineThickness',
  23441. 'num',
  23442. 50
  23443. ],
  23444. [
  23445. [
  23446. 12,
  23447. 5
  23448. ],
  23449. 'PaintType',
  23450. 'num',
  23451. 0
  23452. ],
  23453. [
  23454. [
  23455. 12,
  23456. 6
  23457. ],
  23458. 'CharstringType',
  23459. 'num',
  23460. 2
  23461. ],
  23462. [
  23463. [
  23464. 12,
  23465. 7
  23466. ],
  23467. 'FontMatrix',
  23468. [
  23469. 'num',
  23470. 'num',
  23471. 'num',
  23472. 'num',
  23473. 'num',
  23474. 'num'
  23475. ],
  23476. [
  23477. 0.001,
  23478. 0,
  23479. 0,
  23480. 0.001,
  23481. 0,
  23482. 0
  23483. ]
  23484. ],
  23485. [
  23486. 13,
  23487. 'UniqueID',
  23488. 'num',
  23489. null
  23490. ],
  23491. [
  23492. 5,
  23493. 'FontBBox',
  23494. [
  23495. 'num',
  23496. 'num',
  23497. 'num',
  23498. 'num'
  23499. ],
  23500. [
  23501. 0,
  23502. 0,
  23503. 0,
  23504. 0
  23505. ]
  23506. ],
  23507. [
  23508. [
  23509. 12,
  23510. 8
  23511. ],
  23512. 'StrokeWidth',
  23513. 'num',
  23514. 0
  23515. ],
  23516. [
  23517. 14,
  23518. 'XUID',
  23519. 'array',
  23520. null
  23521. ],
  23522. [
  23523. 15,
  23524. 'charset',
  23525. 'offset',
  23526. 0
  23527. ],
  23528. [
  23529. 16,
  23530. 'Encoding',
  23531. 'offset',
  23532. 0
  23533. ],
  23534. [
  23535. 17,
  23536. 'CharStrings',
  23537. 'offset',
  23538. 0
  23539. ],
  23540. [
  23541. 18,
  23542. 'Private',
  23543. [
  23544. 'offset',
  23545. 'offset'
  23546. ],
  23547. null
  23548. ],
  23549. [
  23550. [
  23551. 12,
  23552. 21
  23553. ],
  23554. 'PostScript',
  23555. 'sid',
  23556. null
  23557. ],
  23558. [
  23559. [
  23560. 12,
  23561. 22
  23562. ],
  23563. 'BaseFontName',
  23564. 'sid',
  23565. null
  23566. ],
  23567. [
  23568. [
  23569. 12,
  23570. 23
  23571. ],
  23572. 'BaseFontBlend',
  23573. 'delta',
  23574. null
  23575. ],
  23576. [
  23577. [
  23578. 12,
  23579. 31
  23580. ],
  23581. 'CIDFontVersion',
  23582. 'num',
  23583. 0
  23584. ],
  23585. [
  23586. [
  23587. 12,
  23588. 32
  23589. ],
  23590. 'CIDFontRevision',
  23591. 'num',
  23592. 0
  23593. ],
  23594. [
  23595. [
  23596. 12,
  23597. 33
  23598. ],
  23599. 'CIDFontType',
  23600. 'num',
  23601. 0
  23602. ],
  23603. [
  23604. [
  23605. 12,
  23606. 34
  23607. ],
  23608. 'CIDCount',
  23609. 'num',
  23610. 8720
  23611. ],
  23612. [
  23613. [
  23614. 12,
  23615. 35
  23616. ],
  23617. 'UIDBase',
  23618. 'num',
  23619. null
  23620. ],
  23621. [
  23622. [
  23623. 12,
  23624. 37
  23625. ],
  23626. 'FDSelect',
  23627. 'offset',
  23628. null
  23629. ],
  23630. [
  23631. [
  23632. 12,
  23633. 36
  23634. ],
  23635. 'FDArray',
  23636. 'offset',
  23637. null
  23638. ],
  23639. [
  23640. [
  23641. 12,
  23642. 38
  23643. ],
  23644. 'FontName',
  23645. 'sid',
  23646. null
  23647. ]
  23648. ];
  23649. var tables = null;
  23650. function CFFTopDict(strings) {
  23651. if (tables === null) {
  23652. tables = CFFDict.createTables(layout);
  23653. }
  23654. CFFDict.call(this, tables, strings);
  23655. this.privateDict = null;
  23656. }
  23657. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  23658. return CFFTopDict;
  23659. }();
  23660. var CFFPrivateDict = function CFFPrivateDictClosure() {
  23661. var layout = [
  23662. [
  23663. 6,
  23664. 'BlueValues',
  23665. 'delta',
  23666. null
  23667. ],
  23668. [
  23669. 7,
  23670. 'OtherBlues',
  23671. 'delta',
  23672. null
  23673. ],
  23674. [
  23675. 8,
  23676. 'FamilyBlues',
  23677. 'delta',
  23678. null
  23679. ],
  23680. [
  23681. 9,
  23682. 'FamilyOtherBlues',
  23683. 'delta',
  23684. null
  23685. ],
  23686. [
  23687. [
  23688. 12,
  23689. 9
  23690. ],
  23691. 'BlueScale',
  23692. 'num',
  23693. 0.039625
  23694. ],
  23695. [
  23696. [
  23697. 12,
  23698. 10
  23699. ],
  23700. 'BlueShift',
  23701. 'num',
  23702. 7
  23703. ],
  23704. [
  23705. [
  23706. 12,
  23707. 11
  23708. ],
  23709. 'BlueFuzz',
  23710. 'num',
  23711. 1
  23712. ],
  23713. [
  23714. 10,
  23715. 'StdHW',
  23716. 'num',
  23717. null
  23718. ],
  23719. [
  23720. 11,
  23721. 'StdVW',
  23722. 'num',
  23723. null
  23724. ],
  23725. [
  23726. [
  23727. 12,
  23728. 12
  23729. ],
  23730. 'StemSnapH',
  23731. 'delta',
  23732. null
  23733. ],
  23734. [
  23735. [
  23736. 12,
  23737. 13
  23738. ],
  23739. 'StemSnapV',
  23740. 'delta',
  23741. null
  23742. ],
  23743. [
  23744. [
  23745. 12,
  23746. 14
  23747. ],
  23748. 'ForceBold',
  23749. 'num',
  23750. 0
  23751. ],
  23752. [
  23753. [
  23754. 12,
  23755. 17
  23756. ],
  23757. 'LanguageGroup',
  23758. 'num',
  23759. 0
  23760. ],
  23761. [
  23762. [
  23763. 12,
  23764. 18
  23765. ],
  23766. 'ExpansionFactor',
  23767. 'num',
  23768. 0.06
  23769. ],
  23770. [
  23771. [
  23772. 12,
  23773. 19
  23774. ],
  23775. 'initialRandomSeed',
  23776. 'num',
  23777. 0
  23778. ],
  23779. [
  23780. 20,
  23781. 'defaultWidthX',
  23782. 'num',
  23783. 0
  23784. ],
  23785. [
  23786. 21,
  23787. 'nominalWidthX',
  23788. 'num',
  23789. 0
  23790. ],
  23791. [
  23792. 19,
  23793. 'Subrs',
  23794. 'offset',
  23795. null
  23796. ]
  23797. ];
  23798. var tables = null;
  23799. function CFFPrivateDict(strings) {
  23800. if (tables === null) {
  23801. tables = CFFDict.createTables(layout);
  23802. }
  23803. CFFDict.call(this, tables, strings);
  23804. this.subrsIndex = null;
  23805. }
  23806. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  23807. return CFFPrivateDict;
  23808. }();
  23809. var CFFCharsetPredefinedTypes = {
  23810. ISO_ADOBE: 0,
  23811. EXPERT: 1,
  23812. EXPERT_SUBSET: 2
  23813. };
  23814. var CFFCharset = function CFFCharsetClosure() {
  23815. function CFFCharset(predefined, format, charset, raw) {
  23816. this.predefined = predefined;
  23817. this.format = format;
  23818. this.charset = charset;
  23819. this.raw = raw;
  23820. }
  23821. return CFFCharset;
  23822. }();
  23823. var CFFEncoding = function CFFEncodingClosure() {
  23824. function CFFEncoding(predefined, format, encoding, raw) {
  23825. this.predefined = predefined;
  23826. this.format = format;
  23827. this.encoding = encoding;
  23828. this.raw = raw;
  23829. }
  23830. return CFFEncoding;
  23831. }();
  23832. var CFFFDSelect = function CFFFDSelectClosure() {
  23833. function CFFFDSelect(fdSelect, raw) {
  23834. this.fdSelect = fdSelect;
  23835. this.raw = raw;
  23836. }
  23837. CFFFDSelect.prototype = {
  23838. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  23839. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  23840. return -1;
  23841. }
  23842. return this.fdSelect[glyphIndex];
  23843. }
  23844. };
  23845. return CFFFDSelect;
  23846. }();
  23847. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  23848. function CFFOffsetTracker() {
  23849. this.offsets = Object.create(null);
  23850. }
  23851. CFFOffsetTracker.prototype = {
  23852. isTracking: function CFFOffsetTracker_isTracking(key) {
  23853. return key in this.offsets;
  23854. },
  23855. track: function CFFOffsetTracker_track(key, location) {
  23856. if (key in this.offsets) {
  23857. error('Already tracking location of ' + key);
  23858. }
  23859. this.offsets[key] = location;
  23860. },
  23861. offset: function CFFOffsetTracker_offset(value) {
  23862. for (var key in this.offsets) {
  23863. this.offsets[key] += value;
  23864. }
  23865. },
  23866. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  23867. if (!(key in this.offsets)) {
  23868. error('Not tracking location of ' + key);
  23869. }
  23870. var data = output.data;
  23871. var dataOffset = this.offsets[key];
  23872. var size = 5;
  23873. for (var i = 0, ii = values.length; i < ii; ++i) {
  23874. var offset0 = i * size + dataOffset;
  23875. var offset1 = offset0 + 1;
  23876. var offset2 = offset0 + 2;
  23877. var offset3 = offset0 + 3;
  23878. var offset4 = offset0 + 4;
  23879. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  23880. error('writing to an offset that is not empty');
  23881. }
  23882. var value = values[i];
  23883. data[offset0] = 0x1d;
  23884. data[offset1] = value >> 24 & 0xFF;
  23885. data[offset2] = value >> 16 & 0xFF;
  23886. data[offset3] = value >> 8 & 0xFF;
  23887. data[offset4] = value & 0xFF;
  23888. }
  23889. }
  23890. };
  23891. return CFFOffsetTracker;
  23892. }();
  23893. var CFFCompiler = function CFFCompilerClosure() {
  23894. function CFFCompiler(cff) {
  23895. this.cff = cff;
  23896. }
  23897. CFFCompiler.prototype = {
  23898. compile: function CFFCompiler_compile() {
  23899. var cff = this.cff;
  23900. var output = {
  23901. data: [],
  23902. length: 0,
  23903. add: function CFFCompiler_add(data) {
  23904. this.data = this.data.concat(data);
  23905. this.length = this.data.length;
  23906. }
  23907. };
  23908. var header = this.compileHeader(cff.header);
  23909. output.add(header);
  23910. var nameIndex = this.compileNameIndex(cff.names);
  23911. output.add(nameIndex);
  23912. if (cff.isCIDFont) {
  23913. if (cff.topDict.hasName('FontMatrix')) {
  23914. var base = cff.topDict.getByName('FontMatrix');
  23915. cff.topDict.removeByName('FontMatrix');
  23916. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  23917. var subDict = cff.fdArray[i];
  23918. var matrix = base.slice(0);
  23919. if (subDict.hasName('FontMatrix')) {
  23920. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  23921. }
  23922. subDict.setByName('FontMatrix', matrix);
  23923. }
  23924. }
  23925. }
  23926. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  23927. output.add(compiled.output);
  23928. var topDictTracker = compiled.trackers[0];
  23929. var stringIndex = this.compileStringIndex(cff.strings.strings);
  23930. output.add(stringIndex);
  23931. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  23932. output.add(globalSubrIndex);
  23933. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  23934. if (cff.encoding.predefined) {
  23935. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  23936. } else {
  23937. var encoding = this.compileEncoding(cff.encoding);
  23938. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  23939. output.add(encoding);
  23940. }
  23941. }
  23942. if (cff.charset && cff.topDict.hasName('charset')) {
  23943. if (cff.charset.predefined) {
  23944. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  23945. } else {
  23946. var charset = this.compileCharset(cff.charset);
  23947. topDictTracker.setEntryLocation('charset', [output.length], output);
  23948. output.add(charset);
  23949. }
  23950. }
  23951. var charStrings = this.compileCharStrings(cff.charStrings);
  23952. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  23953. output.add(charStrings);
  23954. if (cff.isCIDFont) {
  23955. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  23956. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  23957. output.add(fdSelect);
  23958. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  23959. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  23960. output.add(compiled.output);
  23961. var fontDictTrackers = compiled.trackers;
  23962. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  23963. }
  23964. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  23965. output.add([0]);
  23966. return output.data;
  23967. },
  23968. encodeNumber: function CFFCompiler_encodeNumber(value) {
  23969. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  23970. return this.encodeInteger(value);
  23971. }
  23972. return this.encodeFloat(value);
  23973. },
  23974. encodeFloat: function CFFCompiler_encodeFloat(num) {
  23975. var value = num.toString();
  23976. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  23977. if (m) {
  23978. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  23979. value = (Math.round(num * epsilon) / epsilon).toString();
  23980. }
  23981. var nibbles = '';
  23982. var i, ii;
  23983. for (i = 0, ii = value.length; i < ii; ++i) {
  23984. var a = value[i];
  23985. if (a === 'e') {
  23986. nibbles += value[++i] === '-' ? 'c' : 'b';
  23987. } else if (a === '.') {
  23988. nibbles += 'a';
  23989. } else if (a === '-') {
  23990. nibbles += 'e';
  23991. } else {
  23992. nibbles += a;
  23993. }
  23994. }
  23995. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  23996. var out = [30];
  23997. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  23998. out.push(parseInt(nibbles.substr(i, 2), 16));
  23999. }
  24000. return out;
  24001. },
  24002. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24003. var code;
  24004. if (value >= -107 && value <= 107) {
  24005. code = [value + 139];
  24006. } else if (value >= 108 && value <= 1131) {
  24007. value = value - 108;
  24008. code = [
  24009. (value >> 8) + 247,
  24010. value & 0xFF
  24011. ];
  24012. } else if (value >= -1131 && value <= -108) {
  24013. value = -value - 108;
  24014. code = [
  24015. (value >> 8) + 251,
  24016. value & 0xFF
  24017. ];
  24018. } else if (value >= -32768 && value <= 32767) {
  24019. code = [
  24020. 0x1c,
  24021. value >> 8 & 0xFF,
  24022. value & 0xFF
  24023. ];
  24024. } else {
  24025. code = [
  24026. 0x1d,
  24027. value >> 24 & 0xFF,
  24028. value >> 16 & 0xFF,
  24029. value >> 8 & 0xFF,
  24030. value & 0xFF
  24031. ];
  24032. }
  24033. return code;
  24034. },
  24035. compileHeader: function CFFCompiler_compileHeader(header) {
  24036. return [
  24037. header.major,
  24038. header.minor,
  24039. header.hdrSize,
  24040. header.offSize
  24041. ];
  24042. },
  24043. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24044. var nameIndex = new CFFIndex();
  24045. for (var i = 0, ii = names.length; i < ii; ++i) {
  24046. nameIndex.add(stringToBytes(names[i]));
  24047. }
  24048. return this.compileIndex(nameIndex);
  24049. },
  24050. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24051. var fontDictTrackers = [];
  24052. var fdArrayIndex = new CFFIndex();
  24053. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24054. var fontDict = dicts[i];
  24055. if (removeCidKeys) {
  24056. fontDict.removeByName('CIDFontVersion');
  24057. fontDict.removeByName('CIDFontRevision');
  24058. fontDict.removeByName('CIDFontType');
  24059. fontDict.removeByName('CIDCount');
  24060. fontDict.removeByName('UIDBase');
  24061. }
  24062. var fontDictTracker = new CFFOffsetTracker();
  24063. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24064. fontDictTrackers.push(fontDictTracker);
  24065. fdArrayIndex.add(fontDictData);
  24066. fontDictTracker.offset(length);
  24067. }
  24068. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24069. return {
  24070. trackers: fontDictTrackers,
  24071. output: fdArrayIndex
  24072. };
  24073. },
  24074. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24075. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24076. var fontDict = dicts[i];
  24077. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24078. var privateDict = fontDict.privateDict;
  24079. var privateDictTracker = new CFFOffsetTracker();
  24080. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24081. var outputLength = output.length;
  24082. privateDictTracker.offset(outputLength);
  24083. if (!privateDictData.length) {
  24084. outputLength = 0;
  24085. }
  24086. trackers[i].setEntryLocation('Private', [
  24087. privateDictData.length,
  24088. outputLength
  24089. ], output);
  24090. output.add(privateDictData);
  24091. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24092. var subrs = this.compileIndex(privateDict.subrsIndex);
  24093. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24094. output.add(subrs);
  24095. }
  24096. }
  24097. },
  24098. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24099. var out = [];
  24100. var order = dict.order;
  24101. for (var i = 0; i < order.length; ++i) {
  24102. var key = order[i];
  24103. if (!(key in dict.values)) {
  24104. continue;
  24105. }
  24106. var values = dict.values[key];
  24107. var types = dict.types[key];
  24108. if (!isArray(types)) {
  24109. types = [types];
  24110. }
  24111. if (!isArray(values)) {
  24112. values = [values];
  24113. }
  24114. if (values.length === 0) {
  24115. continue;
  24116. }
  24117. for (var j = 0, jj = types.length; j < jj; ++j) {
  24118. var type = types[j];
  24119. var value = values[j];
  24120. switch (type) {
  24121. case 'num':
  24122. case 'sid':
  24123. out = out.concat(this.encodeNumber(value));
  24124. break;
  24125. case 'offset':
  24126. var name = dict.keyToNameMap[key];
  24127. if (!offsetTracker.isTracking(name)) {
  24128. offsetTracker.track(name, out.length);
  24129. }
  24130. out = out.concat([
  24131. 0x1d,
  24132. 0,
  24133. 0,
  24134. 0,
  24135. 0
  24136. ]);
  24137. break;
  24138. case 'array':
  24139. case 'delta':
  24140. out = out.concat(this.encodeNumber(value));
  24141. for (var k = 1, kk = values.length; k < kk; ++k) {
  24142. out = out.concat(this.encodeNumber(values[k]));
  24143. }
  24144. break;
  24145. default:
  24146. error('Unknown data type of ' + type);
  24147. break;
  24148. }
  24149. }
  24150. out = out.concat(dict.opcodes[key]);
  24151. }
  24152. return out;
  24153. },
  24154. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24155. var stringIndex = new CFFIndex();
  24156. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24157. stringIndex.add(stringToBytes(strings[i]));
  24158. }
  24159. return this.compileIndex(stringIndex);
  24160. },
  24161. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24162. var globalSubrIndex = this.cff.globalSubrIndex;
  24163. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24164. },
  24165. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24166. return this.compileIndex(charStrings);
  24167. },
  24168. compileCharset: function CFFCompiler_compileCharset(charset) {
  24169. return this.compileTypedArray(charset.raw);
  24170. },
  24171. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24172. return this.compileTypedArray(encoding.raw);
  24173. },
  24174. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24175. return this.compileTypedArray(fdSelect);
  24176. },
  24177. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24178. var out = [];
  24179. for (var i = 0, ii = data.length; i < ii; ++i) {
  24180. out[i] = data[i];
  24181. }
  24182. return out;
  24183. },
  24184. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24185. trackers = trackers || [];
  24186. var objects = index.objects;
  24187. var count = objects.length;
  24188. if (count === 0) {
  24189. return [
  24190. 0,
  24191. 0,
  24192. 0
  24193. ];
  24194. }
  24195. var data = [
  24196. count >> 8 & 0xFF,
  24197. count & 0xff
  24198. ];
  24199. var lastOffset = 1, i;
  24200. for (i = 0; i < count; ++i) {
  24201. lastOffset += objects[i].length;
  24202. }
  24203. var offsetSize;
  24204. if (lastOffset < 0x100) {
  24205. offsetSize = 1;
  24206. } else if (lastOffset < 0x10000) {
  24207. offsetSize = 2;
  24208. } else if (lastOffset < 0x1000000) {
  24209. offsetSize = 3;
  24210. } else {
  24211. offsetSize = 4;
  24212. }
  24213. data.push(offsetSize);
  24214. var relativeOffset = 1;
  24215. for (i = 0; i < count + 1; i++) {
  24216. if (offsetSize === 1) {
  24217. data.push(relativeOffset & 0xFF);
  24218. } else if (offsetSize === 2) {
  24219. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24220. } else if (offsetSize === 3) {
  24221. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24222. } else {
  24223. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24224. }
  24225. if (objects[i]) {
  24226. relativeOffset += objects[i].length;
  24227. }
  24228. }
  24229. for (i = 0; i < count; i++) {
  24230. if (trackers[i]) {
  24231. trackers[i].offset(data.length);
  24232. }
  24233. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24234. data.push(objects[i][j]);
  24235. }
  24236. }
  24237. return data;
  24238. }
  24239. };
  24240. return CFFCompiler;
  24241. }();
  24242. exports.CFFStandardStrings = CFFStandardStrings;
  24243. exports.CFFParser = CFFParser;
  24244. exports.CFF = CFF;
  24245. exports.CFFHeader = CFFHeader;
  24246. exports.CFFStrings = CFFStrings;
  24247. exports.CFFIndex = CFFIndex;
  24248. exports.CFFCharset = CFFCharset;
  24249. exports.CFFTopDict = CFFTopDict;
  24250. exports.CFFPrivateDict = CFFPrivateDict;
  24251. exports.CFFCompiler = CFFCompiler;
  24252. /***/ }),
  24253. /* 16 */
  24254. /***/ (function(module, exports, __w_pdfjs_require__) {
  24255. "use strict";
  24256. var sharedUtil = __w_pdfjs_require__(0);
  24257. var MissingDataException = sharedUtil.MissingDataException;
  24258. var arrayByteLength = sharedUtil.arrayByteLength;
  24259. var arraysToBytes = sharedUtil.arraysToBytes;
  24260. var assert = sharedUtil.assert;
  24261. var createPromiseCapability = sharedUtil.createPromiseCapability;
  24262. var isInt = sharedUtil.isInt;
  24263. var isEmptyObj = sharedUtil.isEmptyObj;
  24264. var ChunkedStream = function ChunkedStreamClosure() {
  24265. function ChunkedStream(length, chunkSize, manager) {
  24266. this.bytes = new Uint8Array(length);
  24267. this.start = 0;
  24268. this.pos = 0;
  24269. this.end = length;
  24270. this.chunkSize = chunkSize;
  24271. this.loadedChunks = [];
  24272. this.numChunksLoaded = 0;
  24273. this.numChunks = Math.ceil(length / chunkSize);
  24274. this.manager = manager;
  24275. this.progressiveDataLength = 0;
  24276. this.lastSuccessfulEnsureByteChunk = -1;
  24277. }
  24278. ChunkedStream.prototype = {
  24279. getMissingChunks: function ChunkedStream_getMissingChunks() {
  24280. var chunks = [];
  24281. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  24282. if (!this.loadedChunks[chunk]) {
  24283. chunks.push(chunk);
  24284. }
  24285. }
  24286. return chunks;
  24287. },
  24288. getBaseStreams: function ChunkedStream_getBaseStreams() {
  24289. return [this];
  24290. },
  24291. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  24292. return this.numChunksLoaded === this.numChunks;
  24293. },
  24294. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  24295. var end = begin + chunk.byteLength;
  24296. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  24297. var length = this.bytes.length;
  24298. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  24299. this.bytes.set(new Uint8Array(chunk), begin);
  24300. var chunkSize = this.chunkSize;
  24301. var beginChunk = Math.floor(begin / chunkSize);
  24302. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24303. var curChunk;
  24304. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24305. if (!this.loadedChunks[curChunk]) {
  24306. this.loadedChunks[curChunk] = true;
  24307. ++this.numChunksLoaded;
  24308. }
  24309. }
  24310. },
  24311. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  24312. var position = this.progressiveDataLength;
  24313. var beginChunk = Math.floor(position / this.chunkSize);
  24314. this.bytes.set(new Uint8Array(data), position);
  24315. position += data.byteLength;
  24316. this.progressiveDataLength = position;
  24317. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  24318. var curChunk;
  24319. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24320. if (!this.loadedChunks[curChunk]) {
  24321. this.loadedChunks[curChunk] = true;
  24322. ++this.numChunksLoaded;
  24323. }
  24324. }
  24325. },
  24326. ensureByte: function ChunkedStream_ensureByte(pos) {
  24327. var chunk = Math.floor(pos / this.chunkSize);
  24328. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  24329. return;
  24330. }
  24331. if (!this.loadedChunks[chunk]) {
  24332. throw new MissingDataException(pos, pos + 1);
  24333. }
  24334. this.lastSuccessfulEnsureByteChunk = chunk;
  24335. },
  24336. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  24337. if (begin >= end) {
  24338. return;
  24339. }
  24340. if (end <= this.progressiveDataLength) {
  24341. return;
  24342. }
  24343. var chunkSize = this.chunkSize;
  24344. var beginChunk = Math.floor(begin / chunkSize);
  24345. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24346. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24347. if (!this.loadedChunks[chunk]) {
  24348. throw new MissingDataException(begin, end);
  24349. }
  24350. }
  24351. },
  24352. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  24353. var chunk, numChunks = this.numChunks;
  24354. for (var i = 0; i < numChunks; ++i) {
  24355. chunk = (beginChunk + i) % numChunks;
  24356. if (!this.loadedChunks[chunk]) {
  24357. return chunk;
  24358. }
  24359. }
  24360. return null;
  24361. },
  24362. hasChunk: function ChunkedStream_hasChunk(chunk) {
  24363. return !!this.loadedChunks[chunk];
  24364. },
  24365. get length() {
  24366. return this.end - this.start;
  24367. },
  24368. get isEmpty() {
  24369. return this.length === 0;
  24370. },
  24371. getByte: function ChunkedStream_getByte() {
  24372. var pos = this.pos;
  24373. if (pos >= this.end) {
  24374. return -1;
  24375. }
  24376. this.ensureByte(pos);
  24377. return this.bytes[this.pos++];
  24378. },
  24379. getUint16: function ChunkedStream_getUint16() {
  24380. var b0 = this.getByte();
  24381. var b1 = this.getByte();
  24382. if (b0 === -1 || b1 === -1) {
  24383. return -1;
  24384. }
  24385. return (b0 << 8) + b1;
  24386. },
  24387. getInt32: function ChunkedStream_getInt32() {
  24388. var b0 = this.getByte();
  24389. var b1 = this.getByte();
  24390. var b2 = this.getByte();
  24391. var b3 = this.getByte();
  24392. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24393. },
  24394. getBytes: function ChunkedStream_getBytes(length) {
  24395. var bytes = this.bytes;
  24396. var pos = this.pos;
  24397. var strEnd = this.end;
  24398. if (!length) {
  24399. this.ensureRange(pos, strEnd);
  24400. return bytes.subarray(pos, strEnd);
  24401. }
  24402. var end = pos + length;
  24403. if (end > strEnd) {
  24404. end = strEnd;
  24405. }
  24406. this.ensureRange(pos, end);
  24407. this.pos = end;
  24408. return bytes.subarray(pos, end);
  24409. },
  24410. peekByte: function ChunkedStream_peekByte() {
  24411. var peekedByte = this.getByte();
  24412. this.pos--;
  24413. return peekedByte;
  24414. },
  24415. peekBytes: function ChunkedStream_peekBytes(length) {
  24416. var bytes = this.getBytes(length);
  24417. this.pos -= bytes.length;
  24418. return bytes;
  24419. },
  24420. getByteRange: function ChunkedStream_getBytes(begin, end) {
  24421. this.ensureRange(begin, end);
  24422. return this.bytes.subarray(begin, end);
  24423. },
  24424. skip: function ChunkedStream_skip(n) {
  24425. if (!n) {
  24426. n = 1;
  24427. }
  24428. this.pos += n;
  24429. },
  24430. reset: function ChunkedStream_reset() {
  24431. this.pos = this.start;
  24432. },
  24433. moveStart: function ChunkedStream_moveStart() {
  24434. this.start = this.pos;
  24435. },
  24436. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  24437. this.ensureRange(start, start + length);
  24438. function ChunkedStreamSubstream() {
  24439. }
  24440. ChunkedStreamSubstream.prototype = Object.create(this);
  24441. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  24442. var chunkSize = this.chunkSize;
  24443. var beginChunk = Math.floor(this.start / chunkSize);
  24444. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  24445. var missingChunks = [];
  24446. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24447. if (!this.loadedChunks[chunk]) {
  24448. missingChunks.push(chunk);
  24449. }
  24450. }
  24451. return missingChunks;
  24452. };
  24453. var subStream = new ChunkedStreamSubstream();
  24454. subStream.pos = subStream.start = start;
  24455. subStream.end = start + length || this.end;
  24456. subStream.dict = dict;
  24457. return subStream;
  24458. }
  24459. };
  24460. return ChunkedStream;
  24461. }();
  24462. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  24463. function ChunkedStreamManager(pdfNetworkStream, args) {
  24464. var chunkSize = args.rangeChunkSize;
  24465. var length = args.length;
  24466. this.stream = new ChunkedStream(length, chunkSize, this);
  24467. this.length = length;
  24468. this.chunkSize = chunkSize;
  24469. this.pdfNetworkStream = pdfNetworkStream;
  24470. this.url = args.url;
  24471. this.disableAutoFetch = args.disableAutoFetch;
  24472. this.msgHandler = args.msgHandler;
  24473. this.currRequestId = 0;
  24474. this.chunksNeededByRequest = Object.create(null);
  24475. this.requestsByChunk = Object.create(null);
  24476. this.promisesByRequest = Object.create(null);
  24477. this.progressiveDataLength = 0;
  24478. this.aborted = false;
  24479. this._loadedStreamCapability = createPromiseCapability();
  24480. }
  24481. ChunkedStreamManager.prototype = {
  24482. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  24483. return this._loadedStreamCapability.promise;
  24484. },
  24485. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  24486. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  24487. if (!rangeReader.isStreamingSupported) {
  24488. rangeReader.onProgress = this.onProgress.bind(this);
  24489. }
  24490. var chunks = [], loaded = 0;
  24491. var manager = this;
  24492. var promise = new Promise(function (resolve, reject) {
  24493. var readChunk = function (chunk) {
  24494. try {
  24495. if (!chunk.done) {
  24496. var data = chunk.value;
  24497. chunks.push(data);
  24498. loaded += arrayByteLength(data);
  24499. if (rangeReader.isStreamingSupported) {
  24500. manager.onProgress({ loaded: loaded });
  24501. }
  24502. rangeReader.read().then(readChunk, reject);
  24503. return;
  24504. }
  24505. var chunkData = arraysToBytes(chunks);
  24506. chunks = null;
  24507. resolve(chunkData);
  24508. } catch (e) {
  24509. reject(e);
  24510. }
  24511. };
  24512. rangeReader.read().then(readChunk, reject);
  24513. });
  24514. promise.then(function (data) {
  24515. if (this.aborted) {
  24516. return;
  24517. }
  24518. this.onReceiveData({
  24519. chunk: data,
  24520. begin: begin
  24521. });
  24522. }.bind(this));
  24523. },
  24524. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  24525. var missingChunks = this.stream.getMissingChunks();
  24526. this._requestChunks(missingChunks);
  24527. return this._loadedStreamCapability.promise;
  24528. },
  24529. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  24530. var requestId = this.currRequestId++;
  24531. var i, ii;
  24532. var chunksNeeded = Object.create(null);
  24533. this.chunksNeededByRequest[requestId] = chunksNeeded;
  24534. for (i = 0, ii = chunks.length; i < ii; i++) {
  24535. if (!this.stream.hasChunk(chunks[i])) {
  24536. chunksNeeded[chunks[i]] = true;
  24537. }
  24538. }
  24539. if (isEmptyObj(chunksNeeded)) {
  24540. return Promise.resolve();
  24541. }
  24542. var capability = createPromiseCapability();
  24543. this.promisesByRequest[requestId] = capability;
  24544. var chunksToRequest = [];
  24545. for (var chunk in chunksNeeded) {
  24546. chunk = chunk | 0;
  24547. if (!(chunk in this.requestsByChunk)) {
  24548. this.requestsByChunk[chunk] = [];
  24549. chunksToRequest.push(chunk);
  24550. }
  24551. this.requestsByChunk[chunk].push(requestId);
  24552. }
  24553. if (!chunksToRequest.length) {
  24554. return capability.promise;
  24555. }
  24556. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  24557. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  24558. var groupedChunk = groupedChunksToRequest[i];
  24559. var begin = groupedChunk.beginChunk * this.chunkSize;
  24560. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  24561. this.sendRequest(begin, end);
  24562. }
  24563. return capability.promise;
  24564. },
  24565. getStream: function ChunkedStreamManager_getStream() {
  24566. return this.stream;
  24567. },
  24568. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  24569. end = Math.min(end, this.length);
  24570. var beginChunk = this.getBeginChunk(begin);
  24571. var endChunk = this.getEndChunk(end);
  24572. var chunks = [];
  24573. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24574. chunks.push(chunk);
  24575. }
  24576. return this._requestChunks(chunks);
  24577. },
  24578. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  24579. ranges = ranges || [];
  24580. var chunksToRequest = [];
  24581. for (var i = 0; i < ranges.length; i++) {
  24582. var beginChunk = this.getBeginChunk(ranges[i].begin);
  24583. var endChunk = this.getEndChunk(ranges[i].end);
  24584. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24585. if (chunksToRequest.indexOf(chunk) < 0) {
  24586. chunksToRequest.push(chunk);
  24587. }
  24588. }
  24589. }
  24590. chunksToRequest.sort(function (a, b) {
  24591. return a - b;
  24592. });
  24593. return this._requestChunks(chunksToRequest);
  24594. },
  24595. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  24596. var groupedChunks = [];
  24597. var beginChunk = -1;
  24598. var prevChunk = -1;
  24599. for (var i = 0; i < chunks.length; ++i) {
  24600. var chunk = chunks[i];
  24601. if (beginChunk < 0) {
  24602. beginChunk = chunk;
  24603. }
  24604. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  24605. groupedChunks.push({
  24606. beginChunk: beginChunk,
  24607. endChunk: prevChunk + 1
  24608. });
  24609. beginChunk = chunk;
  24610. }
  24611. if (i + 1 === chunks.length) {
  24612. groupedChunks.push({
  24613. beginChunk: beginChunk,
  24614. endChunk: chunk + 1
  24615. });
  24616. }
  24617. prevChunk = chunk;
  24618. }
  24619. return groupedChunks;
  24620. },
  24621. onProgress: function ChunkedStreamManager_onProgress(args) {
  24622. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  24623. this.msgHandler.send('DocProgress', {
  24624. loaded: bytesLoaded,
  24625. total: this.length
  24626. });
  24627. },
  24628. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  24629. var chunk = args.chunk;
  24630. var isProgressive = args.begin === undefined;
  24631. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  24632. var end = begin + chunk.byteLength;
  24633. var beginChunk = Math.floor(begin / this.chunkSize);
  24634. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  24635. if (isProgressive) {
  24636. this.stream.onReceiveProgressiveData(chunk);
  24637. this.progressiveDataLength = end;
  24638. } else {
  24639. this.stream.onReceiveData(begin, chunk);
  24640. }
  24641. if (this.stream.allChunksLoaded()) {
  24642. this._loadedStreamCapability.resolve(this.stream);
  24643. }
  24644. var loadedRequests = [];
  24645. var i, requestId;
  24646. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  24647. var requestIds = this.requestsByChunk[chunk] || [];
  24648. delete this.requestsByChunk[chunk];
  24649. for (i = 0; i < requestIds.length; ++i) {
  24650. requestId = requestIds[i];
  24651. var chunksNeeded = this.chunksNeededByRequest[requestId];
  24652. if (chunk in chunksNeeded) {
  24653. delete chunksNeeded[chunk];
  24654. }
  24655. if (!isEmptyObj(chunksNeeded)) {
  24656. continue;
  24657. }
  24658. loadedRequests.push(requestId);
  24659. }
  24660. }
  24661. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  24662. var nextEmptyChunk;
  24663. if (this.stream.numChunksLoaded === 1) {
  24664. var lastChunk = this.stream.numChunks - 1;
  24665. if (!this.stream.hasChunk(lastChunk)) {
  24666. nextEmptyChunk = lastChunk;
  24667. }
  24668. } else {
  24669. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  24670. }
  24671. if (isInt(nextEmptyChunk)) {
  24672. this._requestChunks([nextEmptyChunk]);
  24673. }
  24674. }
  24675. for (i = 0; i < loadedRequests.length; ++i) {
  24676. requestId = loadedRequests[i];
  24677. var capability = this.promisesByRequest[requestId];
  24678. delete this.promisesByRequest[requestId];
  24679. capability.resolve();
  24680. }
  24681. this.msgHandler.send('DocProgress', {
  24682. loaded: this.stream.numChunksLoaded * this.chunkSize,
  24683. total: this.length
  24684. });
  24685. },
  24686. onError: function ChunkedStreamManager_onError(err) {
  24687. this._loadedStreamCapability.reject(err);
  24688. },
  24689. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  24690. var chunk = Math.floor(begin / this.chunkSize);
  24691. return chunk;
  24692. },
  24693. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  24694. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  24695. return chunk;
  24696. },
  24697. abort: function ChunkedStreamManager_abort() {
  24698. this.aborted = true;
  24699. if (this.pdfNetworkStream) {
  24700. this.pdfNetworkStream.cancelAllRequests('abort');
  24701. }
  24702. for (var requestId in this.promisesByRequest) {
  24703. var capability = this.promisesByRequest[requestId];
  24704. capability.reject(new Error('Request was aborted'));
  24705. }
  24706. }
  24707. };
  24708. return ChunkedStreamManager;
  24709. }();
  24710. exports.ChunkedStream = ChunkedStream;
  24711. exports.ChunkedStreamManager = ChunkedStreamManager;
  24712. /***/ }),
  24713. /* 17 */
  24714. /***/ (function(module, exports, __w_pdfjs_require__) {
  24715. "use strict";
  24716. var sharedUtil = __w_pdfjs_require__(0);
  24717. var corePrimitives = __w_pdfjs_require__(1);
  24718. var coreStream = __w_pdfjs_require__(2);
  24719. var PasswordException = sharedUtil.PasswordException;
  24720. var PasswordResponses = sharedUtil.PasswordResponses;
  24721. var bytesToString = sharedUtil.bytesToString;
  24722. var warn = sharedUtil.warn;
  24723. var error = sharedUtil.error;
  24724. var assert = sharedUtil.assert;
  24725. var isInt = sharedUtil.isInt;
  24726. var stringToBytes = sharedUtil.stringToBytes;
  24727. var utf8StringToString = sharedUtil.utf8StringToString;
  24728. var Name = corePrimitives.Name;
  24729. var isName = corePrimitives.isName;
  24730. var isDict = corePrimitives.isDict;
  24731. var DecryptStream = coreStream.DecryptStream;
  24732. var ARCFourCipher = function ARCFourCipherClosure() {
  24733. function ARCFourCipher(key) {
  24734. this.a = 0;
  24735. this.b = 0;
  24736. var s = new Uint8Array(256);
  24737. var i, j = 0, tmp, keyLength = key.length;
  24738. for (i = 0; i < 256; ++i) {
  24739. s[i] = i;
  24740. }
  24741. for (i = 0; i < 256; ++i) {
  24742. tmp = s[i];
  24743. j = j + tmp + key[i % keyLength] & 0xFF;
  24744. s[i] = s[j];
  24745. s[j] = tmp;
  24746. }
  24747. this.s = s;
  24748. }
  24749. ARCFourCipher.prototype = {
  24750. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  24751. var i, n = data.length, tmp, tmp2;
  24752. var a = this.a, b = this.b, s = this.s;
  24753. var output = new Uint8Array(n);
  24754. for (i = 0; i < n; ++i) {
  24755. a = a + 1 & 0xFF;
  24756. tmp = s[a];
  24757. b = b + tmp & 0xFF;
  24758. tmp2 = s[b];
  24759. s[a] = tmp2;
  24760. s[b] = tmp;
  24761. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  24762. }
  24763. this.a = a;
  24764. this.b = b;
  24765. return output;
  24766. }
  24767. };
  24768. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  24769. return ARCFourCipher;
  24770. }();
  24771. var calculateMD5 = function calculateMD5Closure() {
  24772. var r = new Uint8Array([
  24773. 7,
  24774. 12,
  24775. 17,
  24776. 22,
  24777. 7,
  24778. 12,
  24779. 17,
  24780. 22,
  24781. 7,
  24782. 12,
  24783. 17,
  24784. 22,
  24785. 7,
  24786. 12,
  24787. 17,
  24788. 22,
  24789. 5,
  24790. 9,
  24791. 14,
  24792. 20,
  24793. 5,
  24794. 9,
  24795. 14,
  24796. 20,
  24797. 5,
  24798. 9,
  24799. 14,
  24800. 20,
  24801. 5,
  24802. 9,
  24803. 14,
  24804. 20,
  24805. 4,
  24806. 11,
  24807. 16,
  24808. 23,
  24809. 4,
  24810. 11,
  24811. 16,
  24812. 23,
  24813. 4,
  24814. 11,
  24815. 16,
  24816. 23,
  24817. 4,
  24818. 11,
  24819. 16,
  24820. 23,
  24821. 6,
  24822. 10,
  24823. 15,
  24824. 21,
  24825. 6,
  24826. 10,
  24827. 15,
  24828. 21,
  24829. 6,
  24830. 10,
  24831. 15,
  24832. 21,
  24833. 6,
  24834. 10,
  24835. 15,
  24836. 21
  24837. ]);
  24838. var k = new Int32Array([
  24839. -680876936,
  24840. -389564586,
  24841. 606105819,
  24842. -1044525330,
  24843. -176418897,
  24844. 1200080426,
  24845. -1473231341,
  24846. -45705983,
  24847. 1770035416,
  24848. -1958414417,
  24849. -42063,
  24850. -1990404162,
  24851. 1804603682,
  24852. -40341101,
  24853. -1502002290,
  24854. 1236535329,
  24855. -165796510,
  24856. -1069501632,
  24857. 643717713,
  24858. -373897302,
  24859. -701558691,
  24860. 38016083,
  24861. -660478335,
  24862. -405537848,
  24863. 568446438,
  24864. -1019803690,
  24865. -187363961,
  24866. 1163531501,
  24867. -1444681467,
  24868. -51403784,
  24869. 1735328473,
  24870. -1926607734,
  24871. -378558,
  24872. -2022574463,
  24873. 1839030562,
  24874. -35309556,
  24875. -1530992060,
  24876. 1272893353,
  24877. -155497632,
  24878. -1094730640,
  24879. 681279174,
  24880. -358537222,
  24881. -722521979,
  24882. 76029189,
  24883. -640364487,
  24884. -421815835,
  24885. 530742520,
  24886. -995338651,
  24887. -198630844,
  24888. 1126891415,
  24889. -1416354905,
  24890. -57434055,
  24891. 1700485571,
  24892. -1894986606,
  24893. -1051523,
  24894. -2054922799,
  24895. 1873313359,
  24896. -30611744,
  24897. -1560198380,
  24898. 1309151649,
  24899. -145523070,
  24900. -1120210379,
  24901. 718787259,
  24902. -343485551
  24903. ]);
  24904. function hash(data, offset, length) {
  24905. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  24906. var paddedLength = length + 72 & ~63;
  24907. var padded = new Uint8Array(paddedLength);
  24908. var i, j, n;
  24909. for (i = 0; i < length; ++i) {
  24910. padded[i] = data[offset++];
  24911. }
  24912. padded[i++] = 0x80;
  24913. n = paddedLength - 8;
  24914. while (i < n) {
  24915. padded[i++] = 0;
  24916. }
  24917. padded[i++] = length << 3 & 0xFF;
  24918. padded[i++] = length >> 5 & 0xFF;
  24919. padded[i++] = length >> 13 & 0xFF;
  24920. padded[i++] = length >> 21 & 0xFF;
  24921. padded[i++] = length >>> 29 & 0xFF;
  24922. padded[i++] = 0;
  24923. padded[i++] = 0;
  24924. padded[i++] = 0;
  24925. var w = new Int32Array(16);
  24926. for (i = 0; i < paddedLength;) {
  24927. for (j = 0; j < 16; ++j, i += 4) {
  24928. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  24929. }
  24930. var a = h0, b = h1, c = h2, d = h3, f, g;
  24931. for (j = 0; j < 64; ++j) {
  24932. if (j < 16) {
  24933. f = b & c | ~b & d;
  24934. g = j;
  24935. } else if (j < 32) {
  24936. f = d & b | ~d & c;
  24937. g = 5 * j + 1 & 15;
  24938. } else if (j < 48) {
  24939. f = b ^ c ^ d;
  24940. g = 3 * j + 5 & 15;
  24941. } else {
  24942. f = c ^ (b | ~d);
  24943. g = 7 * j & 15;
  24944. }
  24945. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  24946. d = c;
  24947. c = b;
  24948. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  24949. a = tmp;
  24950. }
  24951. h0 = h0 + a | 0;
  24952. h1 = h1 + b | 0;
  24953. h2 = h2 + c | 0;
  24954. h3 = h3 + d | 0;
  24955. }
  24956. return new Uint8Array([
  24957. h0 & 0xFF,
  24958. h0 >> 8 & 0xFF,
  24959. h0 >> 16 & 0xFF,
  24960. h0 >>> 24 & 0xFF,
  24961. h1 & 0xFF,
  24962. h1 >> 8 & 0xFF,
  24963. h1 >> 16 & 0xFF,
  24964. h1 >>> 24 & 0xFF,
  24965. h2 & 0xFF,
  24966. h2 >> 8 & 0xFF,
  24967. h2 >> 16 & 0xFF,
  24968. h2 >>> 24 & 0xFF,
  24969. h3 & 0xFF,
  24970. h3 >> 8 & 0xFF,
  24971. h3 >> 16 & 0xFF,
  24972. h3 >>> 24 & 0xFF
  24973. ]);
  24974. }
  24975. return hash;
  24976. }();
  24977. var Word64 = function Word64Closure() {
  24978. function Word64(highInteger, lowInteger) {
  24979. this.high = highInteger | 0;
  24980. this.low = lowInteger | 0;
  24981. }
  24982. Word64.prototype = {
  24983. and: function Word64_and(word) {
  24984. this.high &= word.high;
  24985. this.low &= word.low;
  24986. },
  24987. xor: function Word64_xor(word) {
  24988. this.high ^= word.high;
  24989. this.low ^= word.low;
  24990. },
  24991. or: function Word64_or(word) {
  24992. this.high |= word.high;
  24993. this.low |= word.low;
  24994. },
  24995. shiftRight: function Word64_shiftRight(places) {
  24996. if (places >= 32) {
  24997. this.low = this.high >>> places - 32 | 0;
  24998. this.high = 0;
  24999. } else {
  25000. this.low = this.low >>> places | this.high << 32 - places;
  25001. this.high = this.high >>> places | 0;
  25002. }
  25003. },
  25004. shiftLeft: function Word64_shiftLeft(places) {
  25005. if (places >= 32) {
  25006. this.high = this.low << places - 32;
  25007. this.low = 0;
  25008. } else {
  25009. this.high = this.high << places | this.low >>> 32 - places;
  25010. this.low = this.low << places;
  25011. }
  25012. },
  25013. rotateRight: function Word64_rotateRight(places) {
  25014. var low, high;
  25015. if (places & 32) {
  25016. high = this.low;
  25017. low = this.high;
  25018. } else {
  25019. low = this.low;
  25020. high = this.high;
  25021. }
  25022. places &= 31;
  25023. this.low = low >>> places | high << 32 - places;
  25024. this.high = high >>> places | low << 32 - places;
  25025. },
  25026. not: function Word64_not() {
  25027. this.high = ~this.high;
  25028. this.low = ~this.low;
  25029. },
  25030. add: function Word64_add(word) {
  25031. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25032. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25033. if (lowAdd > 0xFFFFFFFF) {
  25034. highAdd += 1;
  25035. }
  25036. this.low = lowAdd | 0;
  25037. this.high = highAdd | 0;
  25038. },
  25039. copyTo: function Word64_copyTo(bytes, offset) {
  25040. bytes[offset] = this.high >>> 24 & 0xFF;
  25041. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25042. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25043. bytes[offset + 3] = this.high & 0xFF;
  25044. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25045. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25046. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25047. bytes[offset + 7] = this.low & 0xFF;
  25048. },
  25049. assign: function Word64_assign(word) {
  25050. this.high = word.high;
  25051. this.low = word.low;
  25052. }
  25053. };
  25054. return Word64;
  25055. }();
  25056. var calculateSHA256 = function calculateSHA256Closure() {
  25057. function rotr(x, n) {
  25058. return x >>> n | x << 32 - n;
  25059. }
  25060. function ch(x, y, z) {
  25061. return x & y ^ ~x & z;
  25062. }
  25063. function maj(x, y, z) {
  25064. return x & y ^ x & z ^ y & z;
  25065. }
  25066. function sigma(x) {
  25067. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25068. }
  25069. function sigmaPrime(x) {
  25070. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25071. }
  25072. function littleSigma(x) {
  25073. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25074. }
  25075. function littleSigmaPrime(x) {
  25076. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25077. }
  25078. var k = [
  25079. 0x428a2f98,
  25080. 0x71374491,
  25081. 0xb5c0fbcf,
  25082. 0xe9b5dba5,
  25083. 0x3956c25b,
  25084. 0x59f111f1,
  25085. 0x923f82a4,
  25086. 0xab1c5ed5,
  25087. 0xd807aa98,
  25088. 0x12835b01,
  25089. 0x243185be,
  25090. 0x550c7dc3,
  25091. 0x72be5d74,
  25092. 0x80deb1fe,
  25093. 0x9bdc06a7,
  25094. 0xc19bf174,
  25095. 0xe49b69c1,
  25096. 0xefbe4786,
  25097. 0x0fc19dc6,
  25098. 0x240ca1cc,
  25099. 0x2de92c6f,
  25100. 0x4a7484aa,
  25101. 0x5cb0a9dc,
  25102. 0x76f988da,
  25103. 0x983e5152,
  25104. 0xa831c66d,
  25105. 0xb00327c8,
  25106. 0xbf597fc7,
  25107. 0xc6e00bf3,
  25108. 0xd5a79147,
  25109. 0x06ca6351,
  25110. 0x14292967,
  25111. 0x27b70a85,
  25112. 0x2e1b2138,
  25113. 0x4d2c6dfc,
  25114. 0x53380d13,
  25115. 0x650a7354,
  25116. 0x766a0abb,
  25117. 0x81c2c92e,
  25118. 0x92722c85,
  25119. 0xa2bfe8a1,
  25120. 0xa81a664b,
  25121. 0xc24b8b70,
  25122. 0xc76c51a3,
  25123. 0xd192e819,
  25124. 0xd6990624,
  25125. 0xf40e3585,
  25126. 0x106aa070,
  25127. 0x19a4c116,
  25128. 0x1e376c08,
  25129. 0x2748774c,
  25130. 0x34b0bcb5,
  25131. 0x391c0cb3,
  25132. 0x4ed8aa4a,
  25133. 0x5b9cca4f,
  25134. 0x682e6ff3,
  25135. 0x748f82ee,
  25136. 0x78a5636f,
  25137. 0x84c87814,
  25138. 0x8cc70208,
  25139. 0x90befffa,
  25140. 0xa4506ceb,
  25141. 0xbef9a3f7,
  25142. 0xc67178f2
  25143. ];
  25144. function hash(data, offset, length) {
  25145. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25146. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25147. var padded = new Uint8Array(paddedLength);
  25148. var i, j, n;
  25149. for (i = 0; i < length; ++i) {
  25150. padded[i] = data[offset++];
  25151. }
  25152. padded[i++] = 0x80;
  25153. n = paddedLength - 8;
  25154. while (i < n) {
  25155. padded[i++] = 0;
  25156. }
  25157. padded[i++] = 0;
  25158. padded[i++] = 0;
  25159. padded[i++] = 0;
  25160. padded[i++] = length >>> 29 & 0xFF;
  25161. padded[i++] = length >> 21 & 0xFF;
  25162. padded[i++] = length >> 13 & 0xFF;
  25163. padded[i++] = length >> 5 & 0xFF;
  25164. padded[i++] = length << 3 & 0xFF;
  25165. var w = new Uint32Array(64);
  25166. for (i = 0; i < paddedLength;) {
  25167. for (j = 0; j < 16; ++j) {
  25168. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25169. i += 4;
  25170. }
  25171. for (j = 16; j < 64; ++j) {
  25172. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25173. }
  25174. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25175. for (j = 0; j < 64; ++j) {
  25176. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25177. t2 = sigma(a) + maj(a, b, c);
  25178. h = g;
  25179. g = f;
  25180. f = e;
  25181. e = d + t1 | 0;
  25182. d = c;
  25183. c = b;
  25184. b = a;
  25185. a = t1 + t2 | 0;
  25186. }
  25187. h0 = h0 + a | 0;
  25188. h1 = h1 + b | 0;
  25189. h2 = h2 + c | 0;
  25190. h3 = h3 + d | 0;
  25191. h4 = h4 + e | 0;
  25192. h5 = h5 + f | 0;
  25193. h6 = h6 + g | 0;
  25194. h7 = h7 + h | 0;
  25195. }
  25196. return new Uint8Array([
  25197. h0 >> 24 & 0xFF,
  25198. h0 >> 16 & 0xFF,
  25199. h0 >> 8 & 0xFF,
  25200. h0 & 0xFF,
  25201. h1 >> 24 & 0xFF,
  25202. h1 >> 16 & 0xFF,
  25203. h1 >> 8 & 0xFF,
  25204. h1 & 0xFF,
  25205. h2 >> 24 & 0xFF,
  25206. h2 >> 16 & 0xFF,
  25207. h2 >> 8 & 0xFF,
  25208. h2 & 0xFF,
  25209. h3 >> 24 & 0xFF,
  25210. h3 >> 16 & 0xFF,
  25211. h3 >> 8 & 0xFF,
  25212. h3 & 0xFF,
  25213. h4 >> 24 & 0xFF,
  25214. h4 >> 16 & 0xFF,
  25215. h4 >> 8 & 0xFF,
  25216. h4 & 0xFF,
  25217. h5 >> 24 & 0xFF,
  25218. h5 >> 16 & 0xFF,
  25219. h5 >> 8 & 0xFF,
  25220. h5 & 0xFF,
  25221. h6 >> 24 & 0xFF,
  25222. h6 >> 16 & 0xFF,
  25223. h6 >> 8 & 0xFF,
  25224. h6 & 0xFF,
  25225. h7 >> 24 & 0xFF,
  25226. h7 >> 16 & 0xFF,
  25227. h7 >> 8 & 0xFF,
  25228. h7 & 0xFF
  25229. ]);
  25230. }
  25231. return hash;
  25232. }();
  25233. var calculateSHA512 = function calculateSHA512Closure() {
  25234. function ch(result, x, y, z, tmp) {
  25235. result.assign(x);
  25236. result.and(y);
  25237. tmp.assign(x);
  25238. tmp.not();
  25239. tmp.and(z);
  25240. result.xor(tmp);
  25241. }
  25242. function maj(result, x, y, z, tmp) {
  25243. result.assign(x);
  25244. result.and(y);
  25245. tmp.assign(x);
  25246. tmp.and(z);
  25247. result.xor(tmp);
  25248. tmp.assign(y);
  25249. tmp.and(z);
  25250. result.xor(tmp);
  25251. }
  25252. function sigma(result, x, tmp) {
  25253. result.assign(x);
  25254. result.rotateRight(28);
  25255. tmp.assign(x);
  25256. tmp.rotateRight(34);
  25257. result.xor(tmp);
  25258. tmp.assign(x);
  25259. tmp.rotateRight(39);
  25260. result.xor(tmp);
  25261. }
  25262. function sigmaPrime(result, x, tmp) {
  25263. result.assign(x);
  25264. result.rotateRight(14);
  25265. tmp.assign(x);
  25266. tmp.rotateRight(18);
  25267. result.xor(tmp);
  25268. tmp.assign(x);
  25269. tmp.rotateRight(41);
  25270. result.xor(tmp);
  25271. }
  25272. function littleSigma(result, x, tmp) {
  25273. result.assign(x);
  25274. result.rotateRight(1);
  25275. tmp.assign(x);
  25276. tmp.rotateRight(8);
  25277. result.xor(tmp);
  25278. tmp.assign(x);
  25279. tmp.shiftRight(7);
  25280. result.xor(tmp);
  25281. }
  25282. function littleSigmaPrime(result, x, tmp) {
  25283. result.assign(x);
  25284. result.rotateRight(19);
  25285. tmp.assign(x);
  25286. tmp.rotateRight(61);
  25287. result.xor(tmp);
  25288. tmp.assign(x);
  25289. tmp.shiftRight(6);
  25290. result.xor(tmp);
  25291. }
  25292. var k = [
  25293. new Word64(0x428a2f98, 0xd728ae22),
  25294. new Word64(0x71374491, 0x23ef65cd),
  25295. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  25296. new Word64(0xe9b5dba5, 0x8189dbbc),
  25297. new Word64(0x3956c25b, 0xf348b538),
  25298. new Word64(0x59f111f1, 0xb605d019),
  25299. new Word64(0x923f82a4, 0xaf194f9b),
  25300. new Word64(0xab1c5ed5, 0xda6d8118),
  25301. new Word64(0xd807aa98, 0xa3030242),
  25302. new Word64(0x12835b01, 0x45706fbe),
  25303. new Word64(0x243185be, 0x4ee4b28c),
  25304. new Word64(0x550c7dc3, 0xd5ffb4e2),
  25305. new Word64(0x72be5d74, 0xf27b896f),
  25306. new Word64(0x80deb1fe, 0x3b1696b1),
  25307. new Word64(0x9bdc06a7, 0x25c71235),
  25308. new Word64(0xc19bf174, 0xcf692694),
  25309. new Word64(0xe49b69c1, 0x9ef14ad2),
  25310. new Word64(0xefbe4786, 0x384f25e3),
  25311. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  25312. new Word64(0x240ca1cc, 0x77ac9c65),
  25313. new Word64(0x2de92c6f, 0x592b0275),
  25314. new Word64(0x4a7484aa, 0x6ea6e483),
  25315. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  25316. new Word64(0x76f988da, 0x831153b5),
  25317. new Word64(0x983e5152, 0xee66dfab),
  25318. new Word64(0xa831c66d, 0x2db43210),
  25319. new Word64(0xb00327c8, 0x98fb213f),
  25320. new Word64(0xbf597fc7, 0xbeef0ee4),
  25321. new Word64(0xc6e00bf3, 0x3da88fc2),
  25322. new Word64(0xd5a79147, 0x930aa725),
  25323. new Word64(0x06ca6351, 0xe003826f),
  25324. new Word64(0x14292967, 0x0a0e6e70),
  25325. new Word64(0x27b70a85, 0x46d22ffc),
  25326. new Word64(0x2e1b2138, 0x5c26c926),
  25327. new Word64(0x4d2c6dfc, 0x5ac42aed),
  25328. new Word64(0x53380d13, 0x9d95b3df),
  25329. new Word64(0x650a7354, 0x8baf63de),
  25330. new Word64(0x766a0abb, 0x3c77b2a8),
  25331. new Word64(0x81c2c92e, 0x47edaee6),
  25332. new Word64(0x92722c85, 0x1482353b),
  25333. new Word64(0xa2bfe8a1, 0x4cf10364),
  25334. new Word64(0xa81a664b, 0xbc423001),
  25335. new Word64(0xc24b8b70, 0xd0f89791),
  25336. new Word64(0xc76c51a3, 0x0654be30),
  25337. new Word64(0xd192e819, 0xd6ef5218),
  25338. new Word64(0xd6990624, 0x5565a910),
  25339. new Word64(0xf40e3585, 0x5771202a),
  25340. new Word64(0x106aa070, 0x32bbd1b8),
  25341. new Word64(0x19a4c116, 0xb8d2d0c8),
  25342. new Word64(0x1e376c08, 0x5141ab53),
  25343. new Word64(0x2748774c, 0xdf8eeb99),
  25344. new Word64(0x34b0bcb5, 0xe19b48a8),
  25345. new Word64(0x391c0cb3, 0xc5c95a63),
  25346. new Word64(0x4ed8aa4a, 0xe3418acb),
  25347. new Word64(0x5b9cca4f, 0x7763e373),
  25348. new Word64(0x682e6ff3, 0xd6b2b8a3),
  25349. new Word64(0x748f82ee, 0x5defb2fc),
  25350. new Word64(0x78a5636f, 0x43172f60),
  25351. new Word64(0x84c87814, 0xa1f0ab72),
  25352. new Word64(0x8cc70208, 0x1a6439ec),
  25353. new Word64(0x90befffa, 0x23631e28),
  25354. new Word64(0xa4506ceb, 0xde82bde9),
  25355. new Word64(0xbef9a3f7, 0xb2c67915),
  25356. new Word64(0xc67178f2, 0xe372532b),
  25357. new Word64(0xca273ece, 0xea26619c),
  25358. new Word64(0xd186b8c7, 0x21c0c207),
  25359. new Word64(0xeada7dd6, 0xcde0eb1e),
  25360. new Word64(0xf57d4f7f, 0xee6ed178),
  25361. new Word64(0x06f067aa, 0x72176fba),
  25362. new Word64(0x0a637dc5, 0xa2c898a6),
  25363. new Word64(0x113f9804, 0xbef90dae),
  25364. new Word64(0x1b710b35, 0x131c471b),
  25365. new Word64(0x28db77f5, 0x23047d84),
  25366. new Word64(0x32caab7b, 0x40c72493),
  25367. new Word64(0x3c9ebe0a, 0x15c9bebc),
  25368. new Word64(0x431d67c4, 0x9c100d4c),
  25369. new Word64(0x4cc5d4be, 0xcb3e42b6),
  25370. new Word64(0x597f299c, 0xfc657e2a),
  25371. new Word64(0x5fcb6fab, 0x3ad6faec),
  25372. new Word64(0x6c44198c, 0x4a475817)
  25373. ];
  25374. function hash(data, offset, length, mode384) {
  25375. mode384 = !!mode384;
  25376. var h0, h1, h2, h3, h4, h5, h6, h7;
  25377. if (!mode384) {
  25378. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  25379. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  25380. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  25381. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  25382. h4 = new Word64(0x510e527f, 0xade682d1);
  25383. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  25384. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  25385. h7 = new Word64(0x5be0cd19, 0x137e2179);
  25386. } else {
  25387. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  25388. h1 = new Word64(0x629a292a, 0x367cd507);
  25389. h2 = new Word64(0x9159015a, 0x3070dd17);
  25390. h3 = new Word64(0x152fecd8, 0xf70e5939);
  25391. h4 = new Word64(0x67332667, 0xffc00b31);
  25392. h5 = new Word64(0x8eb44a87, 0x68581511);
  25393. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  25394. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  25395. }
  25396. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  25397. var padded = new Uint8Array(paddedLength);
  25398. var i, j, n;
  25399. for (i = 0; i < length; ++i) {
  25400. padded[i] = data[offset++];
  25401. }
  25402. padded[i++] = 0x80;
  25403. n = paddedLength - 16;
  25404. while (i < n) {
  25405. padded[i++] = 0;
  25406. }
  25407. padded[i++] = 0;
  25408. padded[i++] = 0;
  25409. padded[i++] = 0;
  25410. padded[i++] = 0;
  25411. padded[i++] = 0;
  25412. padded[i++] = 0;
  25413. padded[i++] = 0;
  25414. padded[i++] = 0;
  25415. padded[i++] = 0;
  25416. padded[i++] = 0;
  25417. padded[i++] = 0;
  25418. padded[i++] = length >>> 29 & 0xFF;
  25419. padded[i++] = length >> 21 & 0xFF;
  25420. padded[i++] = length >> 13 & 0xFF;
  25421. padded[i++] = length >> 5 & 0xFF;
  25422. padded[i++] = length << 3 & 0xFF;
  25423. var w = new Array(80);
  25424. for (i = 0; i < 80; i++) {
  25425. w[i] = new Word64(0, 0);
  25426. }
  25427. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  25428. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  25429. var g = new Word64(0, 0), h = new Word64(0, 0);
  25430. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  25431. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  25432. for (i = 0; i < paddedLength;) {
  25433. for (j = 0; j < 16; ++j) {
  25434. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25435. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  25436. i += 8;
  25437. }
  25438. for (j = 16; j < 80; ++j) {
  25439. tmp3 = w[j];
  25440. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  25441. tmp3.add(w[j - 7]);
  25442. littleSigma(tmp1, w[j - 15], tmp2);
  25443. tmp3.add(tmp1);
  25444. tmp3.add(w[j - 16]);
  25445. }
  25446. a.assign(h0);
  25447. b.assign(h1);
  25448. c.assign(h2);
  25449. d.assign(h3);
  25450. e.assign(h4);
  25451. f.assign(h5);
  25452. g.assign(h6);
  25453. h.assign(h7);
  25454. for (j = 0; j < 80; ++j) {
  25455. t1.assign(h);
  25456. sigmaPrime(tmp1, e, tmp2);
  25457. t1.add(tmp1);
  25458. ch(tmp1, e, f, g, tmp2);
  25459. t1.add(tmp1);
  25460. t1.add(k[j]);
  25461. t1.add(w[j]);
  25462. sigma(t2, a, tmp2);
  25463. maj(tmp1, a, b, c, tmp2);
  25464. t2.add(tmp1);
  25465. tmp3 = h;
  25466. h = g;
  25467. g = f;
  25468. f = e;
  25469. d.add(t1);
  25470. e = d;
  25471. d = c;
  25472. c = b;
  25473. b = a;
  25474. tmp3.assign(t1);
  25475. tmp3.add(t2);
  25476. a = tmp3;
  25477. }
  25478. h0.add(a);
  25479. h1.add(b);
  25480. h2.add(c);
  25481. h3.add(d);
  25482. h4.add(e);
  25483. h5.add(f);
  25484. h6.add(g);
  25485. h7.add(h);
  25486. }
  25487. var result;
  25488. if (!mode384) {
  25489. result = new Uint8Array(64);
  25490. h0.copyTo(result, 0);
  25491. h1.copyTo(result, 8);
  25492. h2.copyTo(result, 16);
  25493. h3.copyTo(result, 24);
  25494. h4.copyTo(result, 32);
  25495. h5.copyTo(result, 40);
  25496. h6.copyTo(result, 48);
  25497. h7.copyTo(result, 56);
  25498. } else {
  25499. result = new Uint8Array(48);
  25500. h0.copyTo(result, 0);
  25501. h1.copyTo(result, 8);
  25502. h2.copyTo(result, 16);
  25503. h3.copyTo(result, 24);
  25504. h4.copyTo(result, 32);
  25505. h5.copyTo(result, 40);
  25506. }
  25507. return result;
  25508. }
  25509. return hash;
  25510. }();
  25511. var calculateSHA384 = function calculateSHA384Closure() {
  25512. function hash(data, offset, length) {
  25513. return calculateSHA512(data, offset, length, true);
  25514. }
  25515. return hash;
  25516. }();
  25517. var NullCipher = function NullCipherClosure() {
  25518. function NullCipher() {
  25519. }
  25520. NullCipher.prototype = {
  25521. decryptBlock: function NullCipher_decryptBlock(data) {
  25522. return data;
  25523. }
  25524. };
  25525. return NullCipher;
  25526. }();
  25527. var AES128Cipher = function AES128CipherClosure() {
  25528. var rcon = new Uint8Array([
  25529. 0x8d,
  25530. 0x01,
  25531. 0x02,
  25532. 0x04,
  25533. 0x08,
  25534. 0x10,
  25535. 0x20,
  25536. 0x40,
  25537. 0x80,
  25538. 0x1b,
  25539. 0x36,
  25540. 0x6c,
  25541. 0xd8,
  25542. 0xab,
  25543. 0x4d,
  25544. 0x9a,
  25545. 0x2f,
  25546. 0x5e,
  25547. 0xbc,
  25548. 0x63,
  25549. 0xc6,
  25550. 0x97,
  25551. 0x35,
  25552. 0x6a,
  25553. 0xd4,
  25554. 0xb3,
  25555. 0x7d,
  25556. 0xfa,
  25557. 0xef,
  25558. 0xc5,
  25559. 0x91,
  25560. 0x39,
  25561. 0x72,
  25562. 0xe4,
  25563. 0xd3,
  25564. 0xbd,
  25565. 0x61,
  25566. 0xc2,
  25567. 0x9f,
  25568. 0x25,
  25569. 0x4a,
  25570. 0x94,
  25571. 0x33,
  25572. 0x66,
  25573. 0xcc,
  25574. 0x83,
  25575. 0x1d,
  25576. 0x3a,
  25577. 0x74,
  25578. 0xe8,
  25579. 0xcb,
  25580. 0x8d,
  25581. 0x01,
  25582. 0x02,
  25583. 0x04,
  25584. 0x08,
  25585. 0x10,
  25586. 0x20,
  25587. 0x40,
  25588. 0x80,
  25589. 0x1b,
  25590. 0x36,
  25591. 0x6c,
  25592. 0xd8,
  25593. 0xab,
  25594. 0x4d,
  25595. 0x9a,
  25596. 0x2f,
  25597. 0x5e,
  25598. 0xbc,
  25599. 0x63,
  25600. 0xc6,
  25601. 0x97,
  25602. 0x35,
  25603. 0x6a,
  25604. 0xd4,
  25605. 0xb3,
  25606. 0x7d,
  25607. 0xfa,
  25608. 0xef,
  25609. 0xc5,
  25610. 0x91,
  25611. 0x39,
  25612. 0x72,
  25613. 0xe4,
  25614. 0xd3,
  25615. 0xbd,
  25616. 0x61,
  25617. 0xc2,
  25618. 0x9f,
  25619. 0x25,
  25620. 0x4a,
  25621. 0x94,
  25622. 0x33,
  25623. 0x66,
  25624. 0xcc,
  25625. 0x83,
  25626. 0x1d,
  25627. 0x3a,
  25628. 0x74,
  25629. 0xe8,
  25630. 0xcb,
  25631. 0x8d,
  25632. 0x01,
  25633. 0x02,
  25634. 0x04,
  25635. 0x08,
  25636. 0x10,
  25637. 0x20,
  25638. 0x40,
  25639. 0x80,
  25640. 0x1b,
  25641. 0x36,
  25642. 0x6c,
  25643. 0xd8,
  25644. 0xab,
  25645. 0x4d,
  25646. 0x9a,
  25647. 0x2f,
  25648. 0x5e,
  25649. 0xbc,
  25650. 0x63,
  25651. 0xc6,
  25652. 0x97,
  25653. 0x35,
  25654. 0x6a,
  25655. 0xd4,
  25656. 0xb3,
  25657. 0x7d,
  25658. 0xfa,
  25659. 0xef,
  25660. 0xc5,
  25661. 0x91,
  25662. 0x39,
  25663. 0x72,
  25664. 0xe4,
  25665. 0xd3,
  25666. 0xbd,
  25667. 0x61,
  25668. 0xc2,
  25669. 0x9f,
  25670. 0x25,
  25671. 0x4a,
  25672. 0x94,
  25673. 0x33,
  25674. 0x66,
  25675. 0xcc,
  25676. 0x83,
  25677. 0x1d,
  25678. 0x3a,
  25679. 0x74,
  25680. 0xe8,
  25681. 0xcb,
  25682. 0x8d,
  25683. 0x01,
  25684. 0x02,
  25685. 0x04,
  25686. 0x08,
  25687. 0x10,
  25688. 0x20,
  25689. 0x40,
  25690. 0x80,
  25691. 0x1b,
  25692. 0x36,
  25693. 0x6c,
  25694. 0xd8,
  25695. 0xab,
  25696. 0x4d,
  25697. 0x9a,
  25698. 0x2f,
  25699. 0x5e,
  25700. 0xbc,
  25701. 0x63,
  25702. 0xc6,
  25703. 0x97,
  25704. 0x35,
  25705. 0x6a,
  25706. 0xd4,
  25707. 0xb3,
  25708. 0x7d,
  25709. 0xfa,
  25710. 0xef,
  25711. 0xc5,
  25712. 0x91,
  25713. 0x39,
  25714. 0x72,
  25715. 0xe4,
  25716. 0xd3,
  25717. 0xbd,
  25718. 0x61,
  25719. 0xc2,
  25720. 0x9f,
  25721. 0x25,
  25722. 0x4a,
  25723. 0x94,
  25724. 0x33,
  25725. 0x66,
  25726. 0xcc,
  25727. 0x83,
  25728. 0x1d,
  25729. 0x3a,
  25730. 0x74,
  25731. 0xe8,
  25732. 0xcb,
  25733. 0x8d,
  25734. 0x01,
  25735. 0x02,
  25736. 0x04,
  25737. 0x08,
  25738. 0x10,
  25739. 0x20,
  25740. 0x40,
  25741. 0x80,
  25742. 0x1b,
  25743. 0x36,
  25744. 0x6c,
  25745. 0xd8,
  25746. 0xab,
  25747. 0x4d,
  25748. 0x9a,
  25749. 0x2f,
  25750. 0x5e,
  25751. 0xbc,
  25752. 0x63,
  25753. 0xc6,
  25754. 0x97,
  25755. 0x35,
  25756. 0x6a,
  25757. 0xd4,
  25758. 0xb3,
  25759. 0x7d,
  25760. 0xfa,
  25761. 0xef,
  25762. 0xc5,
  25763. 0x91,
  25764. 0x39,
  25765. 0x72,
  25766. 0xe4,
  25767. 0xd3,
  25768. 0xbd,
  25769. 0x61,
  25770. 0xc2,
  25771. 0x9f,
  25772. 0x25,
  25773. 0x4a,
  25774. 0x94,
  25775. 0x33,
  25776. 0x66,
  25777. 0xcc,
  25778. 0x83,
  25779. 0x1d,
  25780. 0x3a,
  25781. 0x74,
  25782. 0xe8,
  25783. 0xcb,
  25784. 0x8d
  25785. ]);
  25786. var s = new Uint8Array([
  25787. 0x63,
  25788. 0x7c,
  25789. 0x77,
  25790. 0x7b,
  25791. 0xf2,
  25792. 0x6b,
  25793. 0x6f,
  25794. 0xc5,
  25795. 0x30,
  25796. 0x01,
  25797. 0x67,
  25798. 0x2b,
  25799. 0xfe,
  25800. 0xd7,
  25801. 0xab,
  25802. 0x76,
  25803. 0xca,
  25804. 0x82,
  25805. 0xc9,
  25806. 0x7d,
  25807. 0xfa,
  25808. 0x59,
  25809. 0x47,
  25810. 0xf0,
  25811. 0xad,
  25812. 0xd4,
  25813. 0xa2,
  25814. 0xaf,
  25815. 0x9c,
  25816. 0xa4,
  25817. 0x72,
  25818. 0xc0,
  25819. 0xb7,
  25820. 0xfd,
  25821. 0x93,
  25822. 0x26,
  25823. 0x36,
  25824. 0x3f,
  25825. 0xf7,
  25826. 0xcc,
  25827. 0x34,
  25828. 0xa5,
  25829. 0xe5,
  25830. 0xf1,
  25831. 0x71,
  25832. 0xd8,
  25833. 0x31,
  25834. 0x15,
  25835. 0x04,
  25836. 0xc7,
  25837. 0x23,
  25838. 0xc3,
  25839. 0x18,
  25840. 0x96,
  25841. 0x05,
  25842. 0x9a,
  25843. 0x07,
  25844. 0x12,
  25845. 0x80,
  25846. 0xe2,
  25847. 0xeb,
  25848. 0x27,
  25849. 0xb2,
  25850. 0x75,
  25851. 0x09,
  25852. 0x83,
  25853. 0x2c,
  25854. 0x1a,
  25855. 0x1b,
  25856. 0x6e,
  25857. 0x5a,
  25858. 0xa0,
  25859. 0x52,
  25860. 0x3b,
  25861. 0xd6,
  25862. 0xb3,
  25863. 0x29,
  25864. 0xe3,
  25865. 0x2f,
  25866. 0x84,
  25867. 0x53,
  25868. 0xd1,
  25869. 0x00,
  25870. 0xed,
  25871. 0x20,
  25872. 0xfc,
  25873. 0xb1,
  25874. 0x5b,
  25875. 0x6a,
  25876. 0xcb,
  25877. 0xbe,
  25878. 0x39,
  25879. 0x4a,
  25880. 0x4c,
  25881. 0x58,
  25882. 0xcf,
  25883. 0xd0,
  25884. 0xef,
  25885. 0xaa,
  25886. 0xfb,
  25887. 0x43,
  25888. 0x4d,
  25889. 0x33,
  25890. 0x85,
  25891. 0x45,
  25892. 0xf9,
  25893. 0x02,
  25894. 0x7f,
  25895. 0x50,
  25896. 0x3c,
  25897. 0x9f,
  25898. 0xa8,
  25899. 0x51,
  25900. 0xa3,
  25901. 0x40,
  25902. 0x8f,
  25903. 0x92,
  25904. 0x9d,
  25905. 0x38,
  25906. 0xf5,
  25907. 0xbc,
  25908. 0xb6,
  25909. 0xda,
  25910. 0x21,
  25911. 0x10,
  25912. 0xff,
  25913. 0xf3,
  25914. 0xd2,
  25915. 0xcd,
  25916. 0x0c,
  25917. 0x13,
  25918. 0xec,
  25919. 0x5f,
  25920. 0x97,
  25921. 0x44,
  25922. 0x17,
  25923. 0xc4,
  25924. 0xa7,
  25925. 0x7e,
  25926. 0x3d,
  25927. 0x64,
  25928. 0x5d,
  25929. 0x19,
  25930. 0x73,
  25931. 0x60,
  25932. 0x81,
  25933. 0x4f,
  25934. 0xdc,
  25935. 0x22,
  25936. 0x2a,
  25937. 0x90,
  25938. 0x88,
  25939. 0x46,
  25940. 0xee,
  25941. 0xb8,
  25942. 0x14,
  25943. 0xde,
  25944. 0x5e,
  25945. 0x0b,
  25946. 0xdb,
  25947. 0xe0,
  25948. 0x32,
  25949. 0x3a,
  25950. 0x0a,
  25951. 0x49,
  25952. 0x06,
  25953. 0x24,
  25954. 0x5c,
  25955. 0xc2,
  25956. 0xd3,
  25957. 0xac,
  25958. 0x62,
  25959. 0x91,
  25960. 0x95,
  25961. 0xe4,
  25962. 0x79,
  25963. 0xe7,
  25964. 0xc8,
  25965. 0x37,
  25966. 0x6d,
  25967. 0x8d,
  25968. 0xd5,
  25969. 0x4e,
  25970. 0xa9,
  25971. 0x6c,
  25972. 0x56,
  25973. 0xf4,
  25974. 0xea,
  25975. 0x65,
  25976. 0x7a,
  25977. 0xae,
  25978. 0x08,
  25979. 0xba,
  25980. 0x78,
  25981. 0x25,
  25982. 0x2e,
  25983. 0x1c,
  25984. 0xa6,
  25985. 0xb4,
  25986. 0xc6,
  25987. 0xe8,
  25988. 0xdd,
  25989. 0x74,
  25990. 0x1f,
  25991. 0x4b,
  25992. 0xbd,
  25993. 0x8b,
  25994. 0x8a,
  25995. 0x70,
  25996. 0x3e,
  25997. 0xb5,
  25998. 0x66,
  25999. 0x48,
  26000. 0x03,
  26001. 0xf6,
  26002. 0x0e,
  26003. 0x61,
  26004. 0x35,
  26005. 0x57,
  26006. 0xb9,
  26007. 0x86,
  26008. 0xc1,
  26009. 0x1d,
  26010. 0x9e,
  26011. 0xe1,
  26012. 0xf8,
  26013. 0x98,
  26014. 0x11,
  26015. 0x69,
  26016. 0xd9,
  26017. 0x8e,
  26018. 0x94,
  26019. 0x9b,
  26020. 0x1e,
  26021. 0x87,
  26022. 0xe9,
  26023. 0xce,
  26024. 0x55,
  26025. 0x28,
  26026. 0xdf,
  26027. 0x8c,
  26028. 0xa1,
  26029. 0x89,
  26030. 0x0d,
  26031. 0xbf,
  26032. 0xe6,
  26033. 0x42,
  26034. 0x68,
  26035. 0x41,
  26036. 0x99,
  26037. 0x2d,
  26038. 0x0f,
  26039. 0xb0,
  26040. 0x54,
  26041. 0xbb,
  26042. 0x16
  26043. ]);
  26044. var inv_s = new Uint8Array([
  26045. 0x52,
  26046. 0x09,
  26047. 0x6a,
  26048. 0xd5,
  26049. 0x30,
  26050. 0x36,
  26051. 0xa5,
  26052. 0x38,
  26053. 0xbf,
  26054. 0x40,
  26055. 0xa3,
  26056. 0x9e,
  26057. 0x81,
  26058. 0xf3,
  26059. 0xd7,
  26060. 0xfb,
  26061. 0x7c,
  26062. 0xe3,
  26063. 0x39,
  26064. 0x82,
  26065. 0x9b,
  26066. 0x2f,
  26067. 0xff,
  26068. 0x87,
  26069. 0x34,
  26070. 0x8e,
  26071. 0x43,
  26072. 0x44,
  26073. 0xc4,
  26074. 0xde,
  26075. 0xe9,
  26076. 0xcb,
  26077. 0x54,
  26078. 0x7b,
  26079. 0x94,
  26080. 0x32,
  26081. 0xa6,
  26082. 0xc2,
  26083. 0x23,
  26084. 0x3d,
  26085. 0xee,
  26086. 0x4c,
  26087. 0x95,
  26088. 0x0b,
  26089. 0x42,
  26090. 0xfa,
  26091. 0xc3,
  26092. 0x4e,
  26093. 0x08,
  26094. 0x2e,
  26095. 0xa1,
  26096. 0x66,
  26097. 0x28,
  26098. 0xd9,
  26099. 0x24,
  26100. 0xb2,
  26101. 0x76,
  26102. 0x5b,
  26103. 0xa2,
  26104. 0x49,
  26105. 0x6d,
  26106. 0x8b,
  26107. 0xd1,
  26108. 0x25,
  26109. 0x72,
  26110. 0xf8,
  26111. 0xf6,
  26112. 0x64,
  26113. 0x86,
  26114. 0x68,
  26115. 0x98,
  26116. 0x16,
  26117. 0xd4,
  26118. 0xa4,
  26119. 0x5c,
  26120. 0xcc,
  26121. 0x5d,
  26122. 0x65,
  26123. 0xb6,
  26124. 0x92,
  26125. 0x6c,
  26126. 0x70,
  26127. 0x48,
  26128. 0x50,
  26129. 0xfd,
  26130. 0xed,
  26131. 0xb9,
  26132. 0xda,
  26133. 0x5e,
  26134. 0x15,
  26135. 0x46,
  26136. 0x57,
  26137. 0xa7,
  26138. 0x8d,
  26139. 0x9d,
  26140. 0x84,
  26141. 0x90,
  26142. 0xd8,
  26143. 0xab,
  26144. 0x00,
  26145. 0x8c,
  26146. 0xbc,
  26147. 0xd3,
  26148. 0x0a,
  26149. 0xf7,
  26150. 0xe4,
  26151. 0x58,
  26152. 0x05,
  26153. 0xb8,
  26154. 0xb3,
  26155. 0x45,
  26156. 0x06,
  26157. 0xd0,
  26158. 0x2c,
  26159. 0x1e,
  26160. 0x8f,
  26161. 0xca,
  26162. 0x3f,
  26163. 0x0f,
  26164. 0x02,
  26165. 0xc1,
  26166. 0xaf,
  26167. 0xbd,
  26168. 0x03,
  26169. 0x01,
  26170. 0x13,
  26171. 0x8a,
  26172. 0x6b,
  26173. 0x3a,
  26174. 0x91,
  26175. 0x11,
  26176. 0x41,
  26177. 0x4f,
  26178. 0x67,
  26179. 0xdc,
  26180. 0xea,
  26181. 0x97,
  26182. 0xf2,
  26183. 0xcf,
  26184. 0xce,
  26185. 0xf0,
  26186. 0xb4,
  26187. 0xe6,
  26188. 0x73,
  26189. 0x96,
  26190. 0xac,
  26191. 0x74,
  26192. 0x22,
  26193. 0xe7,
  26194. 0xad,
  26195. 0x35,
  26196. 0x85,
  26197. 0xe2,
  26198. 0xf9,
  26199. 0x37,
  26200. 0xe8,
  26201. 0x1c,
  26202. 0x75,
  26203. 0xdf,
  26204. 0x6e,
  26205. 0x47,
  26206. 0xf1,
  26207. 0x1a,
  26208. 0x71,
  26209. 0x1d,
  26210. 0x29,
  26211. 0xc5,
  26212. 0x89,
  26213. 0x6f,
  26214. 0xb7,
  26215. 0x62,
  26216. 0x0e,
  26217. 0xaa,
  26218. 0x18,
  26219. 0xbe,
  26220. 0x1b,
  26221. 0xfc,
  26222. 0x56,
  26223. 0x3e,
  26224. 0x4b,
  26225. 0xc6,
  26226. 0xd2,
  26227. 0x79,
  26228. 0x20,
  26229. 0x9a,
  26230. 0xdb,
  26231. 0xc0,
  26232. 0xfe,
  26233. 0x78,
  26234. 0xcd,
  26235. 0x5a,
  26236. 0xf4,
  26237. 0x1f,
  26238. 0xdd,
  26239. 0xa8,
  26240. 0x33,
  26241. 0x88,
  26242. 0x07,
  26243. 0xc7,
  26244. 0x31,
  26245. 0xb1,
  26246. 0x12,
  26247. 0x10,
  26248. 0x59,
  26249. 0x27,
  26250. 0x80,
  26251. 0xec,
  26252. 0x5f,
  26253. 0x60,
  26254. 0x51,
  26255. 0x7f,
  26256. 0xa9,
  26257. 0x19,
  26258. 0xb5,
  26259. 0x4a,
  26260. 0x0d,
  26261. 0x2d,
  26262. 0xe5,
  26263. 0x7a,
  26264. 0x9f,
  26265. 0x93,
  26266. 0xc9,
  26267. 0x9c,
  26268. 0xef,
  26269. 0xa0,
  26270. 0xe0,
  26271. 0x3b,
  26272. 0x4d,
  26273. 0xae,
  26274. 0x2a,
  26275. 0xf5,
  26276. 0xb0,
  26277. 0xc8,
  26278. 0xeb,
  26279. 0xbb,
  26280. 0x3c,
  26281. 0x83,
  26282. 0x53,
  26283. 0x99,
  26284. 0x61,
  26285. 0x17,
  26286. 0x2b,
  26287. 0x04,
  26288. 0x7e,
  26289. 0xba,
  26290. 0x77,
  26291. 0xd6,
  26292. 0x26,
  26293. 0xe1,
  26294. 0x69,
  26295. 0x14,
  26296. 0x63,
  26297. 0x55,
  26298. 0x21,
  26299. 0x0c,
  26300. 0x7d
  26301. ]);
  26302. var mixCol = new Uint8Array(256);
  26303. for (var i = 0; i < 256; i++) {
  26304. if (i < 128) {
  26305. mixCol[i] = i << 1;
  26306. } else {
  26307. mixCol[i] = i << 1 ^ 0x1b;
  26308. }
  26309. }
  26310. var mix = new Uint32Array([
  26311. 0x00000000,
  26312. 0x0e090d0b,
  26313. 0x1c121a16,
  26314. 0x121b171d,
  26315. 0x3824342c,
  26316. 0x362d3927,
  26317. 0x24362e3a,
  26318. 0x2a3f2331,
  26319. 0x70486858,
  26320. 0x7e416553,
  26321. 0x6c5a724e,
  26322. 0x62537f45,
  26323. 0x486c5c74,
  26324. 0x4665517f,
  26325. 0x547e4662,
  26326. 0x5a774b69,
  26327. 0xe090d0b0,
  26328. 0xee99ddbb,
  26329. 0xfc82caa6,
  26330. 0xf28bc7ad,
  26331. 0xd8b4e49c,
  26332. 0xd6bde997,
  26333. 0xc4a6fe8a,
  26334. 0xcaaff381,
  26335. 0x90d8b8e8,
  26336. 0x9ed1b5e3,
  26337. 0x8ccaa2fe,
  26338. 0x82c3aff5,
  26339. 0xa8fc8cc4,
  26340. 0xa6f581cf,
  26341. 0xb4ee96d2,
  26342. 0xbae79bd9,
  26343. 0xdb3bbb7b,
  26344. 0xd532b670,
  26345. 0xc729a16d,
  26346. 0xc920ac66,
  26347. 0xe31f8f57,
  26348. 0xed16825c,
  26349. 0xff0d9541,
  26350. 0xf104984a,
  26351. 0xab73d323,
  26352. 0xa57ade28,
  26353. 0xb761c935,
  26354. 0xb968c43e,
  26355. 0x9357e70f,
  26356. 0x9d5eea04,
  26357. 0x8f45fd19,
  26358. 0x814cf012,
  26359. 0x3bab6bcb,
  26360. 0x35a266c0,
  26361. 0x27b971dd,
  26362. 0x29b07cd6,
  26363. 0x038f5fe7,
  26364. 0x0d8652ec,
  26365. 0x1f9d45f1,
  26366. 0x119448fa,
  26367. 0x4be30393,
  26368. 0x45ea0e98,
  26369. 0x57f11985,
  26370. 0x59f8148e,
  26371. 0x73c737bf,
  26372. 0x7dce3ab4,
  26373. 0x6fd52da9,
  26374. 0x61dc20a2,
  26375. 0xad766df6,
  26376. 0xa37f60fd,
  26377. 0xb16477e0,
  26378. 0xbf6d7aeb,
  26379. 0x955259da,
  26380. 0x9b5b54d1,
  26381. 0x894043cc,
  26382. 0x87494ec7,
  26383. 0xdd3e05ae,
  26384. 0xd33708a5,
  26385. 0xc12c1fb8,
  26386. 0xcf2512b3,
  26387. 0xe51a3182,
  26388. 0xeb133c89,
  26389. 0xf9082b94,
  26390. 0xf701269f,
  26391. 0x4de6bd46,
  26392. 0x43efb04d,
  26393. 0x51f4a750,
  26394. 0x5ffdaa5b,
  26395. 0x75c2896a,
  26396. 0x7bcb8461,
  26397. 0x69d0937c,
  26398. 0x67d99e77,
  26399. 0x3daed51e,
  26400. 0x33a7d815,
  26401. 0x21bccf08,
  26402. 0x2fb5c203,
  26403. 0x058ae132,
  26404. 0x0b83ec39,
  26405. 0x1998fb24,
  26406. 0x1791f62f,
  26407. 0x764dd68d,
  26408. 0x7844db86,
  26409. 0x6a5fcc9b,
  26410. 0x6456c190,
  26411. 0x4e69e2a1,
  26412. 0x4060efaa,
  26413. 0x527bf8b7,
  26414. 0x5c72f5bc,
  26415. 0x0605bed5,
  26416. 0x080cb3de,
  26417. 0x1a17a4c3,
  26418. 0x141ea9c8,
  26419. 0x3e218af9,
  26420. 0x302887f2,
  26421. 0x223390ef,
  26422. 0x2c3a9de4,
  26423. 0x96dd063d,
  26424. 0x98d40b36,
  26425. 0x8acf1c2b,
  26426. 0x84c61120,
  26427. 0xaef93211,
  26428. 0xa0f03f1a,
  26429. 0xb2eb2807,
  26430. 0xbce2250c,
  26431. 0xe6956e65,
  26432. 0xe89c636e,
  26433. 0xfa877473,
  26434. 0xf48e7978,
  26435. 0xdeb15a49,
  26436. 0xd0b85742,
  26437. 0xc2a3405f,
  26438. 0xccaa4d54,
  26439. 0x41ecdaf7,
  26440. 0x4fe5d7fc,
  26441. 0x5dfec0e1,
  26442. 0x53f7cdea,
  26443. 0x79c8eedb,
  26444. 0x77c1e3d0,
  26445. 0x65daf4cd,
  26446. 0x6bd3f9c6,
  26447. 0x31a4b2af,
  26448. 0x3fadbfa4,
  26449. 0x2db6a8b9,
  26450. 0x23bfa5b2,
  26451. 0x09808683,
  26452. 0x07898b88,
  26453. 0x15929c95,
  26454. 0x1b9b919e,
  26455. 0xa17c0a47,
  26456. 0xaf75074c,
  26457. 0xbd6e1051,
  26458. 0xb3671d5a,
  26459. 0x99583e6b,
  26460. 0x97513360,
  26461. 0x854a247d,
  26462. 0x8b432976,
  26463. 0xd134621f,
  26464. 0xdf3d6f14,
  26465. 0xcd267809,
  26466. 0xc32f7502,
  26467. 0xe9105633,
  26468. 0xe7195b38,
  26469. 0xf5024c25,
  26470. 0xfb0b412e,
  26471. 0x9ad7618c,
  26472. 0x94de6c87,
  26473. 0x86c57b9a,
  26474. 0x88cc7691,
  26475. 0xa2f355a0,
  26476. 0xacfa58ab,
  26477. 0xbee14fb6,
  26478. 0xb0e842bd,
  26479. 0xea9f09d4,
  26480. 0xe49604df,
  26481. 0xf68d13c2,
  26482. 0xf8841ec9,
  26483. 0xd2bb3df8,
  26484. 0xdcb230f3,
  26485. 0xcea927ee,
  26486. 0xc0a02ae5,
  26487. 0x7a47b13c,
  26488. 0x744ebc37,
  26489. 0x6655ab2a,
  26490. 0x685ca621,
  26491. 0x42638510,
  26492. 0x4c6a881b,
  26493. 0x5e719f06,
  26494. 0x5078920d,
  26495. 0x0a0fd964,
  26496. 0x0406d46f,
  26497. 0x161dc372,
  26498. 0x1814ce79,
  26499. 0x322bed48,
  26500. 0x3c22e043,
  26501. 0x2e39f75e,
  26502. 0x2030fa55,
  26503. 0xec9ab701,
  26504. 0xe293ba0a,
  26505. 0xf088ad17,
  26506. 0xfe81a01c,
  26507. 0xd4be832d,
  26508. 0xdab78e26,
  26509. 0xc8ac993b,
  26510. 0xc6a59430,
  26511. 0x9cd2df59,
  26512. 0x92dbd252,
  26513. 0x80c0c54f,
  26514. 0x8ec9c844,
  26515. 0xa4f6eb75,
  26516. 0xaaffe67e,
  26517. 0xb8e4f163,
  26518. 0xb6edfc68,
  26519. 0x0c0a67b1,
  26520. 0x02036aba,
  26521. 0x10187da7,
  26522. 0x1e1170ac,
  26523. 0x342e539d,
  26524. 0x3a275e96,
  26525. 0x283c498b,
  26526. 0x26354480,
  26527. 0x7c420fe9,
  26528. 0x724b02e2,
  26529. 0x605015ff,
  26530. 0x6e5918f4,
  26531. 0x44663bc5,
  26532. 0x4a6f36ce,
  26533. 0x587421d3,
  26534. 0x567d2cd8,
  26535. 0x37a10c7a,
  26536. 0x39a80171,
  26537. 0x2bb3166c,
  26538. 0x25ba1b67,
  26539. 0x0f853856,
  26540. 0x018c355d,
  26541. 0x13972240,
  26542. 0x1d9e2f4b,
  26543. 0x47e96422,
  26544. 0x49e06929,
  26545. 0x5bfb7e34,
  26546. 0x55f2733f,
  26547. 0x7fcd500e,
  26548. 0x71c45d05,
  26549. 0x63df4a18,
  26550. 0x6dd64713,
  26551. 0xd731dcca,
  26552. 0xd938d1c1,
  26553. 0xcb23c6dc,
  26554. 0xc52acbd7,
  26555. 0xef15e8e6,
  26556. 0xe11ce5ed,
  26557. 0xf307f2f0,
  26558. 0xfd0efffb,
  26559. 0xa779b492,
  26560. 0xa970b999,
  26561. 0xbb6bae84,
  26562. 0xb562a38f,
  26563. 0x9f5d80be,
  26564. 0x91548db5,
  26565. 0x834f9aa8,
  26566. 0x8d4697a3
  26567. ]);
  26568. function expandKey128(cipherKey) {
  26569. var b = 176, result = new Uint8Array(b);
  26570. result.set(cipherKey);
  26571. for (var j = 16, i = 1; j < b; ++i) {
  26572. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  26573. t1 = s[t1];
  26574. t2 = s[t2];
  26575. t3 = s[t3];
  26576. t4 = s[t4];
  26577. t1 = t1 ^ rcon[i];
  26578. for (var n = 0; n < 4; ++n) {
  26579. result[j] = t1 ^= result[j - 16];
  26580. j++;
  26581. result[j] = t2 ^= result[j - 16];
  26582. j++;
  26583. result[j] = t3 ^= result[j - 16];
  26584. j++;
  26585. result[j] = t4 ^= result[j - 16];
  26586. j++;
  26587. }
  26588. }
  26589. return result;
  26590. }
  26591. function decrypt128(input, key) {
  26592. var state = new Uint8Array(16);
  26593. state.set(input);
  26594. var i, j, k;
  26595. var t, u, v;
  26596. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26597. state[j] ^= key[k];
  26598. }
  26599. for (i = 9; i >= 1; --i) {
  26600. t = state[13];
  26601. state[13] = state[9];
  26602. state[9] = state[5];
  26603. state[5] = state[1];
  26604. state[1] = t;
  26605. t = state[14];
  26606. u = state[10];
  26607. state[14] = state[6];
  26608. state[10] = state[2];
  26609. state[6] = t;
  26610. state[2] = u;
  26611. t = state[15];
  26612. u = state[11];
  26613. v = state[7];
  26614. state[15] = state[3];
  26615. state[11] = t;
  26616. state[7] = u;
  26617. state[3] = v;
  26618. for (j = 0; j < 16; ++j) {
  26619. state[j] = inv_s[state[j]];
  26620. }
  26621. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26622. state[j] ^= key[k];
  26623. }
  26624. for (j = 0; j < 16; j += 4) {
  26625. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  26626. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  26627. state[j] = t >>> 24 & 0xFF;
  26628. state[j + 1] = t >> 16 & 0xFF;
  26629. state[j + 2] = t >> 8 & 0xFF;
  26630. state[j + 3] = t & 0xFF;
  26631. }
  26632. }
  26633. t = state[13];
  26634. state[13] = state[9];
  26635. state[9] = state[5];
  26636. state[5] = state[1];
  26637. state[1] = t;
  26638. t = state[14];
  26639. u = state[10];
  26640. state[14] = state[6];
  26641. state[10] = state[2];
  26642. state[6] = t;
  26643. state[2] = u;
  26644. t = state[15];
  26645. u = state[11];
  26646. v = state[7];
  26647. state[15] = state[3];
  26648. state[11] = t;
  26649. state[7] = u;
  26650. state[3] = v;
  26651. for (j = 0; j < 16; ++j) {
  26652. state[j] = inv_s[state[j]];
  26653. state[j] ^= key[j];
  26654. }
  26655. return state;
  26656. }
  26657. function encrypt128(input, key) {
  26658. var t, u, v, k;
  26659. var state = new Uint8Array(16);
  26660. state.set(input);
  26661. for (j = 0; j < 16; ++j) {
  26662. state[j] ^= key[j];
  26663. }
  26664. for (i = 1; i < 10; i++) {
  26665. for (j = 0; j < 16; ++j) {
  26666. state[j] = s[state[j]];
  26667. }
  26668. v = state[1];
  26669. state[1] = state[5];
  26670. state[5] = state[9];
  26671. state[9] = state[13];
  26672. state[13] = v;
  26673. v = state[2];
  26674. u = state[6];
  26675. state[2] = state[10];
  26676. state[6] = state[14];
  26677. state[10] = v;
  26678. state[14] = u;
  26679. v = state[3];
  26680. u = state[7];
  26681. t = state[11];
  26682. state[3] = state[15];
  26683. state[7] = v;
  26684. state[11] = u;
  26685. state[15] = t;
  26686. for (var j = 0; j < 16; j += 4) {
  26687. var s0 = state[j + 0], s1 = state[j + 1];
  26688. var s2 = state[j + 2], s3 = state[j + 3];
  26689. t = s0 ^ s1 ^ s2 ^ s3;
  26690. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  26691. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  26692. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  26693. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  26694. }
  26695. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26696. state[j] ^= key[k];
  26697. }
  26698. }
  26699. for (j = 0; j < 16; ++j) {
  26700. state[j] = s[state[j]];
  26701. }
  26702. v = state[1];
  26703. state[1] = state[5];
  26704. state[5] = state[9];
  26705. state[9] = state[13];
  26706. state[13] = v;
  26707. v = state[2];
  26708. u = state[6];
  26709. state[2] = state[10];
  26710. state[6] = state[14];
  26711. state[10] = v;
  26712. state[14] = u;
  26713. v = state[3];
  26714. u = state[7];
  26715. t = state[11];
  26716. state[3] = state[15];
  26717. state[7] = v;
  26718. state[11] = u;
  26719. state[15] = t;
  26720. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26721. state[j] ^= key[k];
  26722. }
  26723. return state;
  26724. }
  26725. function AES128Cipher(key) {
  26726. this.key = expandKey128(key);
  26727. this.buffer = new Uint8Array(16);
  26728. this.bufferPosition = 0;
  26729. }
  26730. function decryptBlock2(data, finalize) {
  26731. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  26732. for (i = 0; i < sourceLength; ++i) {
  26733. buffer[bufferLength] = data[i];
  26734. ++bufferLength;
  26735. if (bufferLength < 16) {
  26736. continue;
  26737. }
  26738. var plain = decrypt128(buffer, this.key);
  26739. for (j = 0; j < 16; ++j) {
  26740. plain[j] ^= iv[j];
  26741. }
  26742. iv = buffer;
  26743. result.push(plain);
  26744. buffer = new Uint8Array(16);
  26745. bufferLength = 0;
  26746. }
  26747. this.buffer = buffer;
  26748. this.bufferLength = bufferLength;
  26749. this.iv = iv;
  26750. if (result.length === 0) {
  26751. return new Uint8Array([]);
  26752. }
  26753. var outputLength = 16 * result.length;
  26754. if (finalize) {
  26755. var lastBlock = result[result.length - 1];
  26756. var psLen = lastBlock[15];
  26757. if (psLen <= 16) {
  26758. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  26759. if (lastBlock[i] !== psLen) {
  26760. psLen = 0;
  26761. break;
  26762. }
  26763. }
  26764. outputLength -= psLen;
  26765. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  26766. }
  26767. }
  26768. var output = new Uint8Array(outputLength);
  26769. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26770. output.set(result[i], j);
  26771. }
  26772. return output;
  26773. }
  26774. AES128Cipher.prototype = {
  26775. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  26776. var i, sourceLength = data.length;
  26777. var buffer = this.buffer, bufferLength = this.bufferPosition;
  26778. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  26779. buffer[bufferLength] = data[i];
  26780. }
  26781. if (bufferLength < 16) {
  26782. this.bufferLength = bufferLength;
  26783. return new Uint8Array([]);
  26784. }
  26785. this.iv = buffer;
  26786. this.buffer = new Uint8Array(16);
  26787. this.bufferLength = 0;
  26788. this.decryptBlock = decryptBlock2;
  26789. return this.decryptBlock(data.subarray(16), finalize);
  26790. },
  26791. encrypt: function AES128Cipher_encrypt(data, iv) {
  26792. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  26793. if (!iv) {
  26794. iv = new Uint8Array(16);
  26795. }
  26796. for (i = 0; i < sourceLength; ++i) {
  26797. buffer[bufferLength] = data[i];
  26798. ++bufferLength;
  26799. if (bufferLength < 16) {
  26800. continue;
  26801. }
  26802. for (j = 0; j < 16; ++j) {
  26803. buffer[j] ^= iv[j];
  26804. }
  26805. var cipher = encrypt128(buffer, this.key);
  26806. iv = cipher;
  26807. result.push(cipher);
  26808. buffer = new Uint8Array(16);
  26809. bufferLength = 0;
  26810. }
  26811. this.buffer = buffer;
  26812. this.bufferLength = bufferLength;
  26813. this.iv = iv;
  26814. if (result.length === 0) {
  26815. return new Uint8Array([]);
  26816. }
  26817. var outputLength = 16 * result.length;
  26818. var output = new Uint8Array(outputLength);
  26819. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26820. output.set(result[i], j);
  26821. }
  26822. return output;
  26823. }
  26824. };
  26825. return AES128Cipher;
  26826. }();
  26827. var AES256Cipher = function AES256CipherClosure() {
  26828. var s = new Uint8Array([
  26829. 0x63,
  26830. 0x7c,
  26831. 0x77,
  26832. 0x7b,
  26833. 0xf2,
  26834. 0x6b,
  26835. 0x6f,
  26836. 0xc5,
  26837. 0x30,
  26838. 0x01,
  26839. 0x67,
  26840. 0x2b,
  26841. 0xfe,
  26842. 0xd7,
  26843. 0xab,
  26844. 0x76,
  26845. 0xca,
  26846. 0x82,
  26847. 0xc9,
  26848. 0x7d,
  26849. 0xfa,
  26850. 0x59,
  26851. 0x47,
  26852. 0xf0,
  26853. 0xad,
  26854. 0xd4,
  26855. 0xa2,
  26856. 0xaf,
  26857. 0x9c,
  26858. 0xa4,
  26859. 0x72,
  26860. 0xc0,
  26861. 0xb7,
  26862. 0xfd,
  26863. 0x93,
  26864. 0x26,
  26865. 0x36,
  26866. 0x3f,
  26867. 0xf7,
  26868. 0xcc,
  26869. 0x34,
  26870. 0xa5,
  26871. 0xe5,
  26872. 0xf1,
  26873. 0x71,
  26874. 0xd8,
  26875. 0x31,
  26876. 0x15,
  26877. 0x04,
  26878. 0xc7,
  26879. 0x23,
  26880. 0xc3,
  26881. 0x18,
  26882. 0x96,
  26883. 0x05,
  26884. 0x9a,
  26885. 0x07,
  26886. 0x12,
  26887. 0x80,
  26888. 0xe2,
  26889. 0xeb,
  26890. 0x27,
  26891. 0xb2,
  26892. 0x75,
  26893. 0x09,
  26894. 0x83,
  26895. 0x2c,
  26896. 0x1a,
  26897. 0x1b,
  26898. 0x6e,
  26899. 0x5a,
  26900. 0xa0,
  26901. 0x52,
  26902. 0x3b,
  26903. 0xd6,
  26904. 0xb3,
  26905. 0x29,
  26906. 0xe3,
  26907. 0x2f,
  26908. 0x84,
  26909. 0x53,
  26910. 0xd1,
  26911. 0x00,
  26912. 0xed,
  26913. 0x20,
  26914. 0xfc,
  26915. 0xb1,
  26916. 0x5b,
  26917. 0x6a,
  26918. 0xcb,
  26919. 0xbe,
  26920. 0x39,
  26921. 0x4a,
  26922. 0x4c,
  26923. 0x58,
  26924. 0xcf,
  26925. 0xd0,
  26926. 0xef,
  26927. 0xaa,
  26928. 0xfb,
  26929. 0x43,
  26930. 0x4d,
  26931. 0x33,
  26932. 0x85,
  26933. 0x45,
  26934. 0xf9,
  26935. 0x02,
  26936. 0x7f,
  26937. 0x50,
  26938. 0x3c,
  26939. 0x9f,
  26940. 0xa8,
  26941. 0x51,
  26942. 0xa3,
  26943. 0x40,
  26944. 0x8f,
  26945. 0x92,
  26946. 0x9d,
  26947. 0x38,
  26948. 0xf5,
  26949. 0xbc,
  26950. 0xb6,
  26951. 0xda,
  26952. 0x21,
  26953. 0x10,
  26954. 0xff,
  26955. 0xf3,
  26956. 0xd2,
  26957. 0xcd,
  26958. 0x0c,
  26959. 0x13,
  26960. 0xec,
  26961. 0x5f,
  26962. 0x97,
  26963. 0x44,
  26964. 0x17,
  26965. 0xc4,
  26966. 0xa7,
  26967. 0x7e,
  26968. 0x3d,
  26969. 0x64,
  26970. 0x5d,
  26971. 0x19,
  26972. 0x73,
  26973. 0x60,
  26974. 0x81,
  26975. 0x4f,
  26976. 0xdc,
  26977. 0x22,
  26978. 0x2a,
  26979. 0x90,
  26980. 0x88,
  26981. 0x46,
  26982. 0xee,
  26983. 0xb8,
  26984. 0x14,
  26985. 0xde,
  26986. 0x5e,
  26987. 0x0b,
  26988. 0xdb,
  26989. 0xe0,
  26990. 0x32,
  26991. 0x3a,
  26992. 0x0a,
  26993. 0x49,
  26994. 0x06,
  26995. 0x24,
  26996. 0x5c,
  26997. 0xc2,
  26998. 0xd3,
  26999. 0xac,
  27000. 0x62,
  27001. 0x91,
  27002. 0x95,
  27003. 0xe4,
  27004. 0x79,
  27005. 0xe7,
  27006. 0xc8,
  27007. 0x37,
  27008. 0x6d,
  27009. 0x8d,
  27010. 0xd5,
  27011. 0x4e,
  27012. 0xa9,
  27013. 0x6c,
  27014. 0x56,
  27015. 0xf4,
  27016. 0xea,
  27017. 0x65,
  27018. 0x7a,
  27019. 0xae,
  27020. 0x08,
  27021. 0xba,
  27022. 0x78,
  27023. 0x25,
  27024. 0x2e,
  27025. 0x1c,
  27026. 0xa6,
  27027. 0xb4,
  27028. 0xc6,
  27029. 0xe8,
  27030. 0xdd,
  27031. 0x74,
  27032. 0x1f,
  27033. 0x4b,
  27034. 0xbd,
  27035. 0x8b,
  27036. 0x8a,
  27037. 0x70,
  27038. 0x3e,
  27039. 0xb5,
  27040. 0x66,
  27041. 0x48,
  27042. 0x03,
  27043. 0xf6,
  27044. 0x0e,
  27045. 0x61,
  27046. 0x35,
  27047. 0x57,
  27048. 0xb9,
  27049. 0x86,
  27050. 0xc1,
  27051. 0x1d,
  27052. 0x9e,
  27053. 0xe1,
  27054. 0xf8,
  27055. 0x98,
  27056. 0x11,
  27057. 0x69,
  27058. 0xd9,
  27059. 0x8e,
  27060. 0x94,
  27061. 0x9b,
  27062. 0x1e,
  27063. 0x87,
  27064. 0xe9,
  27065. 0xce,
  27066. 0x55,
  27067. 0x28,
  27068. 0xdf,
  27069. 0x8c,
  27070. 0xa1,
  27071. 0x89,
  27072. 0x0d,
  27073. 0xbf,
  27074. 0xe6,
  27075. 0x42,
  27076. 0x68,
  27077. 0x41,
  27078. 0x99,
  27079. 0x2d,
  27080. 0x0f,
  27081. 0xb0,
  27082. 0x54,
  27083. 0xbb,
  27084. 0x16
  27085. ]);
  27086. var inv_s = new Uint8Array([
  27087. 0x52,
  27088. 0x09,
  27089. 0x6a,
  27090. 0xd5,
  27091. 0x30,
  27092. 0x36,
  27093. 0xa5,
  27094. 0x38,
  27095. 0xbf,
  27096. 0x40,
  27097. 0xa3,
  27098. 0x9e,
  27099. 0x81,
  27100. 0xf3,
  27101. 0xd7,
  27102. 0xfb,
  27103. 0x7c,
  27104. 0xe3,
  27105. 0x39,
  27106. 0x82,
  27107. 0x9b,
  27108. 0x2f,
  27109. 0xff,
  27110. 0x87,
  27111. 0x34,
  27112. 0x8e,
  27113. 0x43,
  27114. 0x44,
  27115. 0xc4,
  27116. 0xde,
  27117. 0xe9,
  27118. 0xcb,
  27119. 0x54,
  27120. 0x7b,
  27121. 0x94,
  27122. 0x32,
  27123. 0xa6,
  27124. 0xc2,
  27125. 0x23,
  27126. 0x3d,
  27127. 0xee,
  27128. 0x4c,
  27129. 0x95,
  27130. 0x0b,
  27131. 0x42,
  27132. 0xfa,
  27133. 0xc3,
  27134. 0x4e,
  27135. 0x08,
  27136. 0x2e,
  27137. 0xa1,
  27138. 0x66,
  27139. 0x28,
  27140. 0xd9,
  27141. 0x24,
  27142. 0xb2,
  27143. 0x76,
  27144. 0x5b,
  27145. 0xa2,
  27146. 0x49,
  27147. 0x6d,
  27148. 0x8b,
  27149. 0xd1,
  27150. 0x25,
  27151. 0x72,
  27152. 0xf8,
  27153. 0xf6,
  27154. 0x64,
  27155. 0x86,
  27156. 0x68,
  27157. 0x98,
  27158. 0x16,
  27159. 0xd4,
  27160. 0xa4,
  27161. 0x5c,
  27162. 0xcc,
  27163. 0x5d,
  27164. 0x65,
  27165. 0xb6,
  27166. 0x92,
  27167. 0x6c,
  27168. 0x70,
  27169. 0x48,
  27170. 0x50,
  27171. 0xfd,
  27172. 0xed,
  27173. 0xb9,
  27174. 0xda,
  27175. 0x5e,
  27176. 0x15,
  27177. 0x46,
  27178. 0x57,
  27179. 0xa7,
  27180. 0x8d,
  27181. 0x9d,
  27182. 0x84,
  27183. 0x90,
  27184. 0xd8,
  27185. 0xab,
  27186. 0x00,
  27187. 0x8c,
  27188. 0xbc,
  27189. 0xd3,
  27190. 0x0a,
  27191. 0xf7,
  27192. 0xe4,
  27193. 0x58,
  27194. 0x05,
  27195. 0xb8,
  27196. 0xb3,
  27197. 0x45,
  27198. 0x06,
  27199. 0xd0,
  27200. 0x2c,
  27201. 0x1e,
  27202. 0x8f,
  27203. 0xca,
  27204. 0x3f,
  27205. 0x0f,
  27206. 0x02,
  27207. 0xc1,
  27208. 0xaf,
  27209. 0xbd,
  27210. 0x03,
  27211. 0x01,
  27212. 0x13,
  27213. 0x8a,
  27214. 0x6b,
  27215. 0x3a,
  27216. 0x91,
  27217. 0x11,
  27218. 0x41,
  27219. 0x4f,
  27220. 0x67,
  27221. 0xdc,
  27222. 0xea,
  27223. 0x97,
  27224. 0xf2,
  27225. 0xcf,
  27226. 0xce,
  27227. 0xf0,
  27228. 0xb4,
  27229. 0xe6,
  27230. 0x73,
  27231. 0x96,
  27232. 0xac,
  27233. 0x74,
  27234. 0x22,
  27235. 0xe7,
  27236. 0xad,
  27237. 0x35,
  27238. 0x85,
  27239. 0xe2,
  27240. 0xf9,
  27241. 0x37,
  27242. 0xe8,
  27243. 0x1c,
  27244. 0x75,
  27245. 0xdf,
  27246. 0x6e,
  27247. 0x47,
  27248. 0xf1,
  27249. 0x1a,
  27250. 0x71,
  27251. 0x1d,
  27252. 0x29,
  27253. 0xc5,
  27254. 0x89,
  27255. 0x6f,
  27256. 0xb7,
  27257. 0x62,
  27258. 0x0e,
  27259. 0xaa,
  27260. 0x18,
  27261. 0xbe,
  27262. 0x1b,
  27263. 0xfc,
  27264. 0x56,
  27265. 0x3e,
  27266. 0x4b,
  27267. 0xc6,
  27268. 0xd2,
  27269. 0x79,
  27270. 0x20,
  27271. 0x9a,
  27272. 0xdb,
  27273. 0xc0,
  27274. 0xfe,
  27275. 0x78,
  27276. 0xcd,
  27277. 0x5a,
  27278. 0xf4,
  27279. 0x1f,
  27280. 0xdd,
  27281. 0xa8,
  27282. 0x33,
  27283. 0x88,
  27284. 0x07,
  27285. 0xc7,
  27286. 0x31,
  27287. 0xb1,
  27288. 0x12,
  27289. 0x10,
  27290. 0x59,
  27291. 0x27,
  27292. 0x80,
  27293. 0xec,
  27294. 0x5f,
  27295. 0x60,
  27296. 0x51,
  27297. 0x7f,
  27298. 0xa9,
  27299. 0x19,
  27300. 0xb5,
  27301. 0x4a,
  27302. 0x0d,
  27303. 0x2d,
  27304. 0xe5,
  27305. 0x7a,
  27306. 0x9f,
  27307. 0x93,
  27308. 0xc9,
  27309. 0x9c,
  27310. 0xef,
  27311. 0xa0,
  27312. 0xe0,
  27313. 0x3b,
  27314. 0x4d,
  27315. 0xae,
  27316. 0x2a,
  27317. 0xf5,
  27318. 0xb0,
  27319. 0xc8,
  27320. 0xeb,
  27321. 0xbb,
  27322. 0x3c,
  27323. 0x83,
  27324. 0x53,
  27325. 0x99,
  27326. 0x61,
  27327. 0x17,
  27328. 0x2b,
  27329. 0x04,
  27330. 0x7e,
  27331. 0xba,
  27332. 0x77,
  27333. 0xd6,
  27334. 0x26,
  27335. 0xe1,
  27336. 0x69,
  27337. 0x14,
  27338. 0x63,
  27339. 0x55,
  27340. 0x21,
  27341. 0x0c,
  27342. 0x7d
  27343. ]);
  27344. var mixCol = new Uint8Array(256);
  27345. for (var i = 0; i < 256; i++) {
  27346. if (i < 128) {
  27347. mixCol[i] = i << 1;
  27348. } else {
  27349. mixCol[i] = i << 1 ^ 0x1b;
  27350. }
  27351. }
  27352. var mix = new Uint32Array([
  27353. 0x00000000,
  27354. 0x0e090d0b,
  27355. 0x1c121a16,
  27356. 0x121b171d,
  27357. 0x3824342c,
  27358. 0x362d3927,
  27359. 0x24362e3a,
  27360. 0x2a3f2331,
  27361. 0x70486858,
  27362. 0x7e416553,
  27363. 0x6c5a724e,
  27364. 0x62537f45,
  27365. 0x486c5c74,
  27366. 0x4665517f,
  27367. 0x547e4662,
  27368. 0x5a774b69,
  27369. 0xe090d0b0,
  27370. 0xee99ddbb,
  27371. 0xfc82caa6,
  27372. 0xf28bc7ad,
  27373. 0xd8b4e49c,
  27374. 0xd6bde997,
  27375. 0xc4a6fe8a,
  27376. 0xcaaff381,
  27377. 0x90d8b8e8,
  27378. 0x9ed1b5e3,
  27379. 0x8ccaa2fe,
  27380. 0x82c3aff5,
  27381. 0xa8fc8cc4,
  27382. 0xa6f581cf,
  27383. 0xb4ee96d2,
  27384. 0xbae79bd9,
  27385. 0xdb3bbb7b,
  27386. 0xd532b670,
  27387. 0xc729a16d,
  27388. 0xc920ac66,
  27389. 0xe31f8f57,
  27390. 0xed16825c,
  27391. 0xff0d9541,
  27392. 0xf104984a,
  27393. 0xab73d323,
  27394. 0xa57ade28,
  27395. 0xb761c935,
  27396. 0xb968c43e,
  27397. 0x9357e70f,
  27398. 0x9d5eea04,
  27399. 0x8f45fd19,
  27400. 0x814cf012,
  27401. 0x3bab6bcb,
  27402. 0x35a266c0,
  27403. 0x27b971dd,
  27404. 0x29b07cd6,
  27405. 0x038f5fe7,
  27406. 0x0d8652ec,
  27407. 0x1f9d45f1,
  27408. 0x119448fa,
  27409. 0x4be30393,
  27410. 0x45ea0e98,
  27411. 0x57f11985,
  27412. 0x59f8148e,
  27413. 0x73c737bf,
  27414. 0x7dce3ab4,
  27415. 0x6fd52da9,
  27416. 0x61dc20a2,
  27417. 0xad766df6,
  27418. 0xa37f60fd,
  27419. 0xb16477e0,
  27420. 0xbf6d7aeb,
  27421. 0x955259da,
  27422. 0x9b5b54d1,
  27423. 0x894043cc,
  27424. 0x87494ec7,
  27425. 0xdd3e05ae,
  27426. 0xd33708a5,
  27427. 0xc12c1fb8,
  27428. 0xcf2512b3,
  27429. 0xe51a3182,
  27430. 0xeb133c89,
  27431. 0xf9082b94,
  27432. 0xf701269f,
  27433. 0x4de6bd46,
  27434. 0x43efb04d,
  27435. 0x51f4a750,
  27436. 0x5ffdaa5b,
  27437. 0x75c2896a,
  27438. 0x7bcb8461,
  27439. 0x69d0937c,
  27440. 0x67d99e77,
  27441. 0x3daed51e,
  27442. 0x33a7d815,
  27443. 0x21bccf08,
  27444. 0x2fb5c203,
  27445. 0x058ae132,
  27446. 0x0b83ec39,
  27447. 0x1998fb24,
  27448. 0x1791f62f,
  27449. 0x764dd68d,
  27450. 0x7844db86,
  27451. 0x6a5fcc9b,
  27452. 0x6456c190,
  27453. 0x4e69e2a1,
  27454. 0x4060efaa,
  27455. 0x527bf8b7,
  27456. 0x5c72f5bc,
  27457. 0x0605bed5,
  27458. 0x080cb3de,
  27459. 0x1a17a4c3,
  27460. 0x141ea9c8,
  27461. 0x3e218af9,
  27462. 0x302887f2,
  27463. 0x223390ef,
  27464. 0x2c3a9de4,
  27465. 0x96dd063d,
  27466. 0x98d40b36,
  27467. 0x8acf1c2b,
  27468. 0x84c61120,
  27469. 0xaef93211,
  27470. 0xa0f03f1a,
  27471. 0xb2eb2807,
  27472. 0xbce2250c,
  27473. 0xe6956e65,
  27474. 0xe89c636e,
  27475. 0xfa877473,
  27476. 0xf48e7978,
  27477. 0xdeb15a49,
  27478. 0xd0b85742,
  27479. 0xc2a3405f,
  27480. 0xccaa4d54,
  27481. 0x41ecdaf7,
  27482. 0x4fe5d7fc,
  27483. 0x5dfec0e1,
  27484. 0x53f7cdea,
  27485. 0x79c8eedb,
  27486. 0x77c1e3d0,
  27487. 0x65daf4cd,
  27488. 0x6bd3f9c6,
  27489. 0x31a4b2af,
  27490. 0x3fadbfa4,
  27491. 0x2db6a8b9,
  27492. 0x23bfa5b2,
  27493. 0x09808683,
  27494. 0x07898b88,
  27495. 0x15929c95,
  27496. 0x1b9b919e,
  27497. 0xa17c0a47,
  27498. 0xaf75074c,
  27499. 0xbd6e1051,
  27500. 0xb3671d5a,
  27501. 0x99583e6b,
  27502. 0x97513360,
  27503. 0x854a247d,
  27504. 0x8b432976,
  27505. 0xd134621f,
  27506. 0xdf3d6f14,
  27507. 0xcd267809,
  27508. 0xc32f7502,
  27509. 0xe9105633,
  27510. 0xe7195b38,
  27511. 0xf5024c25,
  27512. 0xfb0b412e,
  27513. 0x9ad7618c,
  27514. 0x94de6c87,
  27515. 0x86c57b9a,
  27516. 0x88cc7691,
  27517. 0xa2f355a0,
  27518. 0xacfa58ab,
  27519. 0xbee14fb6,
  27520. 0xb0e842bd,
  27521. 0xea9f09d4,
  27522. 0xe49604df,
  27523. 0xf68d13c2,
  27524. 0xf8841ec9,
  27525. 0xd2bb3df8,
  27526. 0xdcb230f3,
  27527. 0xcea927ee,
  27528. 0xc0a02ae5,
  27529. 0x7a47b13c,
  27530. 0x744ebc37,
  27531. 0x6655ab2a,
  27532. 0x685ca621,
  27533. 0x42638510,
  27534. 0x4c6a881b,
  27535. 0x5e719f06,
  27536. 0x5078920d,
  27537. 0x0a0fd964,
  27538. 0x0406d46f,
  27539. 0x161dc372,
  27540. 0x1814ce79,
  27541. 0x322bed48,
  27542. 0x3c22e043,
  27543. 0x2e39f75e,
  27544. 0x2030fa55,
  27545. 0xec9ab701,
  27546. 0xe293ba0a,
  27547. 0xf088ad17,
  27548. 0xfe81a01c,
  27549. 0xd4be832d,
  27550. 0xdab78e26,
  27551. 0xc8ac993b,
  27552. 0xc6a59430,
  27553. 0x9cd2df59,
  27554. 0x92dbd252,
  27555. 0x80c0c54f,
  27556. 0x8ec9c844,
  27557. 0xa4f6eb75,
  27558. 0xaaffe67e,
  27559. 0xb8e4f163,
  27560. 0xb6edfc68,
  27561. 0x0c0a67b1,
  27562. 0x02036aba,
  27563. 0x10187da7,
  27564. 0x1e1170ac,
  27565. 0x342e539d,
  27566. 0x3a275e96,
  27567. 0x283c498b,
  27568. 0x26354480,
  27569. 0x7c420fe9,
  27570. 0x724b02e2,
  27571. 0x605015ff,
  27572. 0x6e5918f4,
  27573. 0x44663bc5,
  27574. 0x4a6f36ce,
  27575. 0x587421d3,
  27576. 0x567d2cd8,
  27577. 0x37a10c7a,
  27578. 0x39a80171,
  27579. 0x2bb3166c,
  27580. 0x25ba1b67,
  27581. 0x0f853856,
  27582. 0x018c355d,
  27583. 0x13972240,
  27584. 0x1d9e2f4b,
  27585. 0x47e96422,
  27586. 0x49e06929,
  27587. 0x5bfb7e34,
  27588. 0x55f2733f,
  27589. 0x7fcd500e,
  27590. 0x71c45d05,
  27591. 0x63df4a18,
  27592. 0x6dd64713,
  27593. 0xd731dcca,
  27594. 0xd938d1c1,
  27595. 0xcb23c6dc,
  27596. 0xc52acbd7,
  27597. 0xef15e8e6,
  27598. 0xe11ce5ed,
  27599. 0xf307f2f0,
  27600. 0xfd0efffb,
  27601. 0xa779b492,
  27602. 0xa970b999,
  27603. 0xbb6bae84,
  27604. 0xb562a38f,
  27605. 0x9f5d80be,
  27606. 0x91548db5,
  27607. 0x834f9aa8,
  27608. 0x8d4697a3
  27609. ]);
  27610. function expandKey256(cipherKey) {
  27611. var b = 240, result = new Uint8Array(b);
  27612. var r = 1;
  27613. result.set(cipherKey);
  27614. for (var j = 32, i = 1; j < b; ++i) {
  27615. if (j % 32 === 16) {
  27616. t1 = s[t1];
  27617. t2 = s[t2];
  27618. t3 = s[t3];
  27619. t4 = s[t4];
  27620. } else if (j % 32 === 0) {
  27621. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27622. t1 = s[t1];
  27623. t2 = s[t2];
  27624. t3 = s[t3];
  27625. t4 = s[t4];
  27626. t1 = t1 ^ r;
  27627. if ((r <<= 1) >= 256) {
  27628. r = (r ^ 0x1b) & 0xFF;
  27629. }
  27630. }
  27631. for (var n = 0; n < 4; ++n) {
  27632. result[j] = t1 ^= result[j - 32];
  27633. j++;
  27634. result[j] = t2 ^= result[j - 32];
  27635. j++;
  27636. result[j] = t3 ^= result[j - 32];
  27637. j++;
  27638. result[j] = t4 ^= result[j - 32];
  27639. j++;
  27640. }
  27641. }
  27642. return result;
  27643. }
  27644. function decrypt256(input, key) {
  27645. var state = new Uint8Array(16);
  27646. state.set(input);
  27647. var i, j, k;
  27648. var t, u, v;
  27649. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27650. state[j] ^= key[k];
  27651. }
  27652. for (i = 13; i >= 1; --i) {
  27653. t = state[13];
  27654. state[13] = state[9];
  27655. state[9] = state[5];
  27656. state[5] = state[1];
  27657. state[1] = t;
  27658. t = state[14];
  27659. u = state[10];
  27660. state[14] = state[6];
  27661. state[10] = state[2];
  27662. state[6] = t;
  27663. state[2] = u;
  27664. t = state[15];
  27665. u = state[11];
  27666. v = state[7];
  27667. state[15] = state[3];
  27668. state[11] = t;
  27669. state[7] = u;
  27670. state[3] = v;
  27671. for (j = 0; j < 16; ++j) {
  27672. state[j] = inv_s[state[j]];
  27673. }
  27674. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27675. state[j] ^= key[k];
  27676. }
  27677. for (j = 0; j < 16; j += 4) {
  27678. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27679. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27680. state[j] = t >>> 24 & 0xFF;
  27681. state[j + 1] = t >> 16 & 0xFF;
  27682. state[j + 2] = t >> 8 & 0xFF;
  27683. state[j + 3] = t & 0xFF;
  27684. }
  27685. }
  27686. t = state[13];
  27687. state[13] = state[9];
  27688. state[9] = state[5];
  27689. state[5] = state[1];
  27690. state[1] = t;
  27691. t = state[14];
  27692. u = state[10];
  27693. state[14] = state[6];
  27694. state[10] = state[2];
  27695. state[6] = t;
  27696. state[2] = u;
  27697. t = state[15];
  27698. u = state[11];
  27699. v = state[7];
  27700. state[15] = state[3];
  27701. state[11] = t;
  27702. state[7] = u;
  27703. state[3] = v;
  27704. for (j = 0; j < 16; ++j) {
  27705. state[j] = inv_s[state[j]];
  27706. state[j] ^= key[j];
  27707. }
  27708. return state;
  27709. }
  27710. function encrypt256(input, key) {
  27711. var t, u, v, k;
  27712. var state = new Uint8Array(16);
  27713. state.set(input);
  27714. for (j = 0; j < 16; ++j) {
  27715. state[j] ^= key[j];
  27716. }
  27717. for (i = 1; i < 14; i++) {
  27718. for (j = 0; j < 16; ++j) {
  27719. state[j] = s[state[j]];
  27720. }
  27721. v = state[1];
  27722. state[1] = state[5];
  27723. state[5] = state[9];
  27724. state[9] = state[13];
  27725. state[13] = v;
  27726. v = state[2];
  27727. u = state[6];
  27728. state[2] = state[10];
  27729. state[6] = state[14];
  27730. state[10] = v;
  27731. state[14] = u;
  27732. v = state[3];
  27733. u = state[7];
  27734. t = state[11];
  27735. state[3] = state[15];
  27736. state[7] = v;
  27737. state[11] = u;
  27738. state[15] = t;
  27739. for (var j = 0; j < 16; j += 4) {
  27740. var s0 = state[j + 0], s1 = state[j + 1];
  27741. var s2 = state[j + 2], s3 = state[j + 3];
  27742. t = s0 ^ s1 ^ s2 ^ s3;
  27743. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27744. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27745. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27746. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27747. }
  27748. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27749. state[j] ^= key[k];
  27750. }
  27751. }
  27752. for (j = 0; j < 16; ++j) {
  27753. state[j] = s[state[j]];
  27754. }
  27755. v = state[1];
  27756. state[1] = state[5];
  27757. state[5] = state[9];
  27758. state[9] = state[13];
  27759. state[13] = v;
  27760. v = state[2];
  27761. u = state[6];
  27762. state[2] = state[10];
  27763. state[6] = state[14];
  27764. state[10] = v;
  27765. state[14] = u;
  27766. v = state[3];
  27767. u = state[7];
  27768. t = state[11];
  27769. state[3] = state[15];
  27770. state[7] = v;
  27771. state[11] = u;
  27772. state[15] = t;
  27773. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27774. state[j] ^= key[k];
  27775. }
  27776. return state;
  27777. }
  27778. function AES256Cipher(key) {
  27779. this.key = expandKey256(key);
  27780. this.buffer = new Uint8Array(16);
  27781. this.bufferPosition = 0;
  27782. }
  27783. function decryptBlock2(data, finalize) {
  27784. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27785. for (i = 0; i < sourceLength; ++i) {
  27786. buffer[bufferLength] = data[i];
  27787. ++bufferLength;
  27788. if (bufferLength < 16) {
  27789. continue;
  27790. }
  27791. var plain = decrypt256(buffer, this.key);
  27792. for (j = 0; j < 16; ++j) {
  27793. plain[j] ^= iv[j];
  27794. }
  27795. iv = buffer;
  27796. result.push(plain);
  27797. buffer = new Uint8Array(16);
  27798. bufferLength = 0;
  27799. }
  27800. this.buffer = buffer;
  27801. this.bufferLength = bufferLength;
  27802. this.iv = iv;
  27803. if (result.length === 0) {
  27804. return new Uint8Array([]);
  27805. }
  27806. var outputLength = 16 * result.length;
  27807. if (finalize) {
  27808. var lastBlock = result[result.length - 1];
  27809. var psLen = lastBlock[15];
  27810. if (psLen <= 16) {
  27811. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27812. if (lastBlock[i] !== psLen) {
  27813. psLen = 0;
  27814. break;
  27815. }
  27816. }
  27817. outputLength -= psLen;
  27818. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27819. }
  27820. }
  27821. var output = new Uint8Array(outputLength);
  27822. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27823. output.set(result[i], j);
  27824. }
  27825. return output;
  27826. }
  27827. AES256Cipher.prototype = {
  27828. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  27829. var i, sourceLength = data.length;
  27830. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27831. if (iv) {
  27832. this.iv = iv;
  27833. } else {
  27834. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27835. buffer[bufferLength] = data[i];
  27836. }
  27837. if (bufferLength < 16) {
  27838. this.bufferLength = bufferLength;
  27839. return new Uint8Array([]);
  27840. }
  27841. this.iv = buffer;
  27842. data = data.subarray(16);
  27843. }
  27844. this.buffer = new Uint8Array(16);
  27845. this.bufferLength = 0;
  27846. this.decryptBlock = decryptBlock2;
  27847. return this.decryptBlock(data, finalize);
  27848. },
  27849. encrypt: function AES256Cipher_encrypt(data, iv) {
  27850. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27851. if (!iv) {
  27852. iv = new Uint8Array(16);
  27853. }
  27854. for (i = 0; i < sourceLength; ++i) {
  27855. buffer[bufferLength] = data[i];
  27856. ++bufferLength;
  27857. if (bufferLength < 16) {
  27858. continue;
  27859. }
  27860. for (j = 0; j < 16; ++j) {
  27861. buffer[j] ^= iv[j];
  27862. }
  27863. var cipher = encrypt256(buffer, this.key);
  27864. this.iv = cipher;
  27865. result.push(cipher);
  27866. buffer = new Uint8Array(16);
  27867. bufferLength = 0;
  27868. }
  27869. this.buffer = buffer;
  27870. this.bufferLength = bufferLength;
  27871. this.iv = iv;
  27872. if (result.length === 0) {
  27873. return new Uint8Array([]);
  27874. }
  27875. var outputLength = 16 * result.length;
  27876. var output = new Uint8Array(outputLength);
  27877. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27878. output.set(result[i], j);
  27879. }
  27880. return output;
  27881. }
  27882. };
  27883. return AES256Cipher;
  27884. }();
  27885. var PDF17 = function PDF17Closure() {
  27886. function compareByteArrays(array1, array2) {
  27887. if (array1.length !== array2.length) {
  27888. return false;
  27889. }
  27890. for (var i = 0; i < array1.length; i++) {
  27891. if (array1[i] !== array2[i]) {
  27892. return false;
  27893. }
  27894. }
  27895. return true;
  27896. }
  27897. function PDF17() {
  27898. }
  27899. PDF17.prototype = {
  27900. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  27901. var hashData = new Uint8Array(password.length + 56);
  27902. hashData.set(password, 0);
  27903. hashData.set(ownerValidationSalt, password.length);
  27904. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  27905. var result = calculateSHA256(hashData, 0, hashData.length);
  27906. return compareByteArrays(result, ownerPassword);
  27907. },
  27908. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  27909. var hashData = new Uint8Array(password.length + 8);
  27910. hashData.set(password, 0);
  27911. hashData.set(userValidationSalt, password.length);
  27912. var result = calculateSHA256(hashData, 0, hashData.length);
  27913. return compareByteArrays(result, userPassword);
  27914. },
  27915. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  27916. var hashData = new Uint8Array(password.length + 56);
  27917. hashData.set(password, 0);
  27918. hashData.set(ownerKeySalt, password.length);
  27919. hashData.set(userBytes, password.length + ownerKeySalt.length);
  27920. var key = calculateSHA256(hashData, 0, hashData.length);
  27921. var cipher = new AES256Cipher(key);
  27922. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  27923. },
  27924. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  27925. var hashData = new Uint8Array(password.length + 8);
  27926. hashData.set(password, 0);
  27927. hashData.set(userKeySalt, password.length);
  27928. var key = calculateSHA256(hashData, 0, hashData.length);
  27929. var cipher = new AES256Cipher(key);
  27930. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  27931. }
  27932. };
  27933. return PDF17;
  27934. }();
  27935. var PDF20 = function PDF20Closure() {
  27936. function concatArrays(array1, array2) {
  27937. var t = new Uint8Array(array1.length + array2.length);
  27938. t.set(array1, 0);
  27939. t.set(array2, array1.length);
  27940. return t;
  27941. }
  27942. function calculatePDF20Hash(password, input, userBytes) {
  27943. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  27944. var e = [0];
  27945. var i = 0;
  27946. while (i < 64 || e[e.length - 1] > i - 32) {
  27947. var arrayLength = password.length + k.length + userBytes.length;
  27948. var k1 = new Uint8Array(arrayLength * 64);
  27949. var array = concatArrays(password, k);
  27950. array = concatArrays(array, userBytes);
  27951. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  27952. k1.set(array, pos);
  27953. }
  27954. var cipher = new AES128Cipher(k.subarray(0, 16));
  27955. e = cipher.encrypt(k1, k.subarray(16, 32));
  27956. var remainder = 0;
  27957. for (var z = 0; z < 16; z++) {
  27958. remainder *= 256 % 3;
  27959. remainder %= 3;
  27960. remainder += (e[z] >>> 0) % 3;
  27961. remainder %= 3;
  27962. }
  27963. if (remainder === 0) {
  27964. k = calculateSHA256(e, 0, e.length);
  27965. } else if (remainder === 1) {
  27966. k = calculateSHA384(e, 0, e.length);
  27967. } else if (remainder === 2) {
  27968. k = calculateSHA512(e, 0, e.length);
  27969. }
  27970. i++;
  27971. }
  27972. return k.subarray(0, 32);
  27973. }
  27974. function PDF20() {
  27975. }
  27976. function compareByteArrays(array1, array2) {
  27977. if (array1.length !== array2.length) {
  27978. return false;
  27979. }
  27980. for (var i = 0; i < array1.length; i++) {
  27981. if (array1[i] !== array2[i]) {
  27982. return false;
  27983. }
  27984. }
  27985. return true;
  27986. }
  27987. PDF20.prototype = {
  27988. hash: function PDF20_hash(password, concatBytes, userBytes) {
  27989. return calculatePDF20Hash(password, concatBytes, userBytes);
  27990. },
  27991. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  27992. var hashData = new Uint8Array(password.length + 56);
  27993. hashData.set(password, 0);
  27994. hashData.set(ownerValidationSalt, password.length);
  27995. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  27996. var result = calculatePDF20Hash(password, hashData, userBytes);
  27997. return compareByteArrays(result, ownerPassword);
  27998. },
  27999. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28000. var hashData = new Uint8Array(password.length + 8);
  28001. hashData.set(password, 0);
  28002. hashData.set(userValidationSalt, password.length);
  28003. var result = calculatePDF20Hash(password, hashData, []);
  28004. return compareByteArrays(result, userPassword);
  28005. },
  28006. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28007. var hashData = new Uint8Array(password.length + 56);
  28008. hashData.set(password, 0);
  28009. hashData.set(ownerKeySalt, password.length);
  28010. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28011. var key = calculatePDF20Hash(password, hashData, userBytes);
  28012. var cipher = new AES256Cipher(key);
  28013. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28014. },
  28015. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28016. var hashData = new Uint8Array(password.length + 8);
  28017. hashData.set(password, 0);
  28018. hashData.set(userKeySalt, password.length);
  28019. var key = calculatePDF20Hash(password, hashData, []);
  28020. var cipher = new AES256Cipher(key);
  28021. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28022. }
  28023. };
  28024. return PDF20;
  28025. }();
  28026. var CipherTransform = function CipherTransformClosure() {
  28027. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28028. this.StringCipherConstructor = stringCipherConstructor;
  28029. this.StreamCipherConstructor = streamCipherConstructor;
  28030. }
  28031. CipherTransform.prototype = {
  28032. createStream: function CipherTransform_createStream(stream, length) {
  28033. var cipher = new this.StreamCipherConstructor();
  28034. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28035. return cipher.decryptBlock(data, finalize);
  28036. });
  28037. },
  28038. decryptString: function CipherTransform_decryptString(s) {
  28039. var cipher = new this.StringCipherConstructor();
  28040. var data = stringToBytes(s);
  28041. data = cipher.decryptBlock(data, true);
  28042. return bytesToString(data);
  28043. }
  28044. };
  28045. return CipherTransform;
  28046. }();
  28047. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28048. var defaultPasswordBytes = new Uint8Array([
  28049. 0x28,
  28050. 0xBF,
  28051. 0x4E,
  28052. 0x5E,
  28053. 0x4E,
  28054. 0x75,
  28055. 0x8A,
  28056. 0x41,
  28057. 0x64,
  28058. 0x00,
  28059. 0x4E,
  28060. 0x56,
  28061. 0xFF,
  28062. 0xFA,
  28063. 0x01,
  28064. 0x08,
  28065. 0x2E,
  28066. 0x2E,
  28067. 0x00,
  28068. 0xB6,
  28069. 0xD0,
  28070. 0x68,
  28071. 0x3E,
  28072. 0x80,
  28073. 0x2F,
  28074. 0x0C,
  28075. 0xA9,
  28076. 0xFE,
  28077. 0x64,
  28078. 0x53,
  28079. 0x69,
  28080. 0x7A
  28081. ]);
  28082. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28083. if (password) {
  28084. var passwordLength = Math.min(127, password.length);
  28085. password = password.subarray(0, passwordLength);
  28086. } else {
  28087. password = [];
  28088. }
  28089. var pdfAlgorithm;
  28090. if (revision === 6) {
  28091. pdfAlgorithm = new PDF20();
  28092. } else {
  28093. pdfAlgorithm = new PDF17();
  28094. }
  28095. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28096. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28097. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28098. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28099. }
  28100. return null;
  28101. }
  28102. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28103. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28104. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28105. if (password) {
  28106. n = Math.min(32, password.length);
  28107. for (; i < n; ++i) {
  28108. hashData[i] = password[i];
  28109. }
  28110. }
  28111. j = 0;
  28112. while (i < 32) {
  28113. hashData[i++] = defaultPasswordBytes[j++];
  28114. }
  28115. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28116. hashData[i++] = ownerPassword[j];
  28117. }
  28118. hashData[i++] = flags & 0xFF;
  28119. hashData[i++] = flags >> 8 & 0xFF;
  28120. hashData[i++] = flags >> 16 & 0xFF;
  28121. hashData[i++] = flags >>> 24 & 0xFF;
  28122. for (j = 0, n = fileId.length; j < n; ++j) {
  28123. hashData[i++] = fileId[j];
  28124. }
  28125. if (revision >= 4 && !encryptMetadata) {
  28126. hashData[i++] = 0xFF;
  28127. hashData[i++] = 0xFF;
  28128. hashData[i++] = 0xFF;
  28129. hashData[i++] = 0xFF;
  28130. }
  28131. var hash = calculateMD5(hashData, 0, i);
  28132. var keyLengthInBytes = keyLength >> 3;
  28133. if (revision >= 3) {
  28134. for (j = 0; j < 50; ++j) {
  28135. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28136. }
  28137. }
  28138. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28139. var cipher, checkData;
  28140. if (revision >= 3) {
  28141. for (i = 0; i < 32; ++i) {
  28142. hashData[i] = defaultPasswordBytes[i];
  28143. }
  28144. for (j = 0, n = fileId.length; j < n; ++j) {
  28145. hashData[i++] = fileId[j];
  28146. }
  28147. cipher = new ARCFourCipher(encryptionKey);
  28148. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28149. n = encryptionKey.length;
  28150. var derivedKey = new Uint8Array(n), k;
  28151. for (j = 1; j <= 19; ++j) {
  28152. for (k = 0; k < n; ++k) {
  28153. derivedKey[k] = encryptionKey[k] ^ j;
  28154. }
  28155. cipher = new ARCFourCipher(derivedKey);
  28156. checkData = cipher.encryptBlock(checkData);
  28157. }
  28158. for (j = 0, n = checkData.length; j < n; ++j) {
  28159. if (userPassword[j] !== checkData[j]) {
  28160. return null;
  28161. }
  28162. }
  28163. } else {
  28164. cipher = new ARCFourCipher(encryptionKey);
  28165. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28166. for (j = 0, n = checkData.length; j < n; ++j) {
  28167. if (userPassword[j] !== checkData[j]) {
  28168. return null;
  28169. }
  28170. }
  28171. }
  28172. return encryptionKey;
  28173. }
  28174. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28175. var hashData = new Uint8Array(32), i = 0, j, n;
  28176. n = Math.min(32, password.length);
  28177. for (; i < n; ++i) {
  28178. hashData[i] = password[i];
  28179. }
  28180. j = 0;
  28181. while (i < 32) {
  28182. hashData[i++] = defaultPasswordBytes[j++];
  28183. }
  28184. var hash = calculateMD5(hashData, 0, i);
  28185. var keyLengthInBytes = keyLength >> 3;
  28186. if (revision >= 3) {
  28187. for (j = 0; j < 50; ++j) {
  28188. hash = calculateMD5(hash, 0, hash.length);
  28189. }
  28190. }
  28191. var cipher, userPassword;
  28192. if (revision >= 3) {
  28193. userPassword = ownerPassword;
  28194. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28195. for (j = 19; j >= 0; j--) {
  28196. for (k = 0; k < keyLengthInBytes; ++k) {
  28197. derivedKey[k] = hash[k] ^ j;
  28198. }
  28199. cipher = new ARCFourCipher(derivedKey);
  28200. userPassword = cipher.encryptBlock(userPassword);
  28201. }
  28202. } else {
  28203. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28204. userPassword = cipher.encryptBlock(ownerPassword);
  28205. }
  28206. return userPassword;
  28207. }
  28208. var identityName = Name.get('Identity');
  28209. function CipherTransformFactory(dict, fileId, password) {
  28210. var filter = dict.get('Filter');
  28211. if (!isName(filter, 'Standard')) {
  28212. error('unknown encryption method');
  28213. }
  28214. this.dict = dict;
  28215. var algorithm = dict.get('V');
  28216. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28217. error('unsupported encryption algorithm');
  28218. }
  28219. this.algorithm = algorithm;
  28220. var keyLength = dict.get('Length');
  28221. if (!keyLength) {
  28222. if (algorithm <= 3) {
  28223. keyLength = 40;
  28224. } else {
  28225. var cfDict = dict.get('CF');
  28226. var streamCryptoName = dict.get('StmF');
  28227. if (isDict(cfDict) && isName(streamCryptoName)) {
  28228. cfDict.suppressEncryption = true;
  28229. var handlerDict = cfDict.get(streamCryptoName.name);
  28230. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28231. if (keyLength < 40) {
  28232. keyLength <<= 3;
  28233. }
  28234. }
  28235. }
  28236. }
  28237. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28238. error('invalid key length');
  28239. }
  28240. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28241. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28242. var flags = dict.get('P');
  28243. var revision = dict.get('R');
  28244. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28245. this.encryptMetadata = encryptMetadata;
  28246. var fileIdBytes = stringToBytes(fileId);
  28247. var passwordBytes;
  28248. if (password) {
  28249. if (revision === 6) {
  28250. try {
  28251. password = utf8StringToString(password);
  28252. } catch (ex) {
  28253. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  28254. }
  28255. }
  28256. passwordBytes = stringToBytes(password);
  28257. }
  28258. var encryptionKey;
  28259. if (algorithm !== 5) {
  28260. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28261. } else {
  28262. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  28263. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  28264. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  28265. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  28266. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  28267. var ownerEncryption = stringToBytes(dict.get('OE'));
  28268. var userEncryption = stringToBytes(dict.get('UE'));
  28269. var perms = stringToBytes(dict.get('Perms'));
  28270. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  28271. }
  28272. if (!encryptionKey && !password) {
  28273. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  28274. } else if (!encryptionKey && password) {
  28275. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  28276. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28277. }
  28278. if (!encryptionKey) {
  28279. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  28280. }
  28281. this.encryptionKey = encryptionKey;
  28282. if (algorithm >= 4) {
  28283. var cf = dict.get('CF');
  28284. if (isDict(cf)) {
  28285. cf.suppressEncryption = true;
  28286. }
  28287. this.cf = cf;
  28288. this.stmf = dict.get('StmF') || identityName;
  28289. this.strf = dict.get('StrF') || identityName;
  28290. this.eff = dict.get('EFF') || this.stmf;
  28291. }
  28292. }
  28293. function buildObjectKey(num, gen, encryptionKey, isAes) {
  28294. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  28295. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  28296. key[i] = encryptionKey[i];
  28297. }
  28298. key[i++] = num & 0xFF;
  28299. key[i++] = num >> 8 & 0xFF;
  28300. key[i++] = num >> 16 & 0xFF;
  28301. key[i++] = gen & 0xFF;
  28302. key[i++] = gen >> 8 & 0xFF;
  28303. if (isAes) {
  28304. key[i++] = 0x73;
  28305. key[i++] = 0x41;
  28306. key[i++] = 0x6C;
  28307. key[i++] = 0x54;
  28308. }
  28309. var hash = calculateMD5(key, 0, i);
  28310. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  28311. }
  28312. function buildCipherConstructor(cf, name, num, gen, key) {
  28313. assert(isName(name), 'Invalid crypt filter name.');
  28314. var cryptFilter = cf.get(name.name);
  28315. var cfm;
  28316. if (cryptFilter !== null && cryptFilter !== undefined) {
  28317. cfm = cryptFilter.get('CFM');
  28318. }
  28319. if (!cfm || cfm.name === 'None') {
  28320. return function cipherTransformFactoryBuildCipherConstructorNone() {
  28321. return new NullCipher();
  28322. };
  28323. }
  28324. if (cfm.name === 'V2') {
  28325. return function cipherTransformFactoryBuildCipherConstructorV2() {
  28326. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  28327. };
  28328. }
  28329. if (cfm.name === 'AESV2') {
  28330. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  28331. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  28332. };
  28333. }
  28334. if (cfm.name === 'AESV3') {
  28335. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  28336. return new AES256Cipher(key);
  28337. };
  28338. }
  28339. error('Unknown crypto method');
  28340. }
  28341. CipherTransformFactory.prototype = {
  28342. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  28343. if (this.algorithm === 4 || this.algorithm === 5) {
  28344. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  28345. }
  28346. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  28347. var cipherConstructor = function buildCipherCipherConstructor() {
  28348. return new ARCFourCipher(key);
  28349. };
  28350. return new CipherTransform(cipherConstructor, cipherConstructor);
  28351. }
  28352. };
  28353. return CipherTransformFactory;
  28354. }();
  28355. exports.AES128Cipher = AES128Cipher;
  28356. exports.AES256Cipher = AES256Cipher;
  28357. exports.ARCFourCipher = ARCFourCipher;
  28358. exports.CipherTransformFactory = CipherTransformFactory;
  28359. exports.PDF17 = PDF17;
  28360. exports.PDF20 = PDF20;
  28361. exports.calculateMD5 = calculateMD5;
  28362. exports.calculateSHA256 = calculateSHA256;
  28363. exports.calculateSHA384 = calculateSHA384;
  28364. exports.calculateSHA512 = calculateSHA512;
  28365. /***/ }),
  28366. /* 18 */
  28367. /***/ (function(module, exports, __w_pdfjs_require__) {
  28368. "use strict";
  28369. var sharedUtil = __w_pdfjs_require__(0);
  28370. var corePrimitives = __w_pdfjs_require__(1);
  28371. var coreStream = __w_pdfjs_require__(2);
  28372. var coreParser = __w_pdfjs_require__(6);
  28373. var coreImage = __w_pdfjs_require__(34);
  28374. var coreColorSpace = __w_pdfjs_require__(4);
  28375. var coreMurmurHash3 = __w_pdfjs_require__(38);
  28376. var coreFonts = __w_pdfjs_require__(33);
  28377. var coreFunction = __w_pdfjs_require__(7);
  28378. var corePattern = __w_pdfjs_require__(40);
  28379. var coreCMap = __w_pdfjs_require__(30);
  28380. var coreMetrics = __w_pdfjs_require__(37);
  28381. var coreBidi = __w_pdfjs_require__(28);
  28382. var coreEncodings = __w_pdfjs_require__(5);
  28383. var coreStandardFonts = __w_pdfjs_require__(21);
  28384. var coreUnicode = __w_pdfjs_require__(22);
  28385. var coreGlyphList = __w_pdfjs_require__(8);
  28386. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  28387. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  28388. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  28389. var ImageKind = sharedUtil.ImageKind;
  28390. var OPS = sharedUtil.OPS;
  28391. var TextRenderingMode = sharedUtil.TextRenderingMode;
  28392. var CMapCompressionType = sharedUtil.CMapCompressionType;
  28393. var Util = sharedUtil.Util;
  28394. var assert = sharedUtil.assert;
  28395. var createPromiseCapability = sharedUtil.createPromiseCapability;
  28396. var error = sharedUtil.error;
  28397. var info = sharedUtil.info;
  28398. var isArray = sharedUtil.isArray;
  28399. var isNum = sharedUtil.isNum;
  28400. var isString = sharedUtil.isString;
  28401. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  28402. var warn = sharedUtil.warn;
  28403. var Dict = corePrimitives.Dict;
  28404. var Name = corePrimitives.Name;
  28405. var isEOF = corePrimitives.isEOF;
  28406. var isCmd = corePrimitives.isCmd;
  28407. var isDict = corePrimitives.isDict;
  28408. var isName = corePrimitives.isName;
  28409. var isRef = corePrimitives.isRef;
  28410. var isStream = corePrimitives.isStream;
  28411. var DecodeStream = coreStream.DecodeStream;
  28412. var JpegStream = coreStream.JpegStream;
  28413. var Stream = coreStream.Stream;
  28414. var Lexer = coreParser.Lexer;
  28415. var Parser = coreParser.Parser;
  28416. var PDFImage = coreImage.PDFImage;
  28417. var ColorSpace = coreColorSpace.ColorSpace;
  28418. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  28419. var ErrorFont = coreFonts.ErrorFont;
  28420. var FontFlags = coreFonts.FontFlags;
  28421. var Font = coreFonts.Font;
  28422. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  28423. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  28424. var getFontType = coreFonts.getFontType;
  28425. var isPDFFunction = coreFunction.isPDFFunction;
  28426. var PDFFunction = coreFunction.PDFFunction;
  28427. var Pattern = corePattern.Pattern;
  28428. var getTilingPatternIR = corePattern.getTilingPatternIR;
  28429. var CMapFactory = coreCMap.CMapFactory;
  28430. var IdentityCMap = coreCMap.IdentityCMap;
  28431. var getMetrics = coreMetrics.getMetrics;
  28432. var bidi = coreBidi.bidi;
  28433. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  28434. var StandardEncoding = coreEncodings.StandardEncoding;
  28435. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  28436. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  28437. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  28438. var getEncoding = coreEncodings.getEncoding;
  28439. var getStdFontMap = coreStandardFonts.getStdFontMap;
  28440. var getSerifFonts = coreStandardFonts.getSerifFonts;
  28441. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  28442. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  28443. var reverseIfRtl = coreUnicode.reverseIfRtl;
  28444. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  28445. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  28446. var PartialEvaluator = function PartialEvaluatorClosure() {
  28447. var DefaultPartialEvaluatorOptions = {
  28448. forceDataSchema: false,
  28449. maxImageSize: -1,
  28450. disableFontFace: false,
  28451. disableNativeImageDecoder: false
  28452. };
  28453. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  28454. this.xref = xref;
  28455. this.resources = resources;
  28456. this.handler = handler;
  28457. this.forceDataSchema = forceDataSchema;
  28458. }
  28459. NativeImageDecoder.prototype = {
  28460. canDecode: function (image) {
  28461. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  28462. },
  28463. decode: function (image) {
  28464. var dict = image.dict;
  28465. var colorSpace = dict.get('ColorSpace', 'CS');
  28466. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  28467. var numComps = colorSpace.numComps;
  28468. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  28469. image.getIR(this.forceDataSchema),
  28470. numComps
  28471. ]);
  28472. return decodePromise.then(function (message) {
  28473. var data = message.data;
  28474. return new Stream(data, 0, data.length, image.dict);
  28475. });
  28476. }
  28477. };
  28478. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  28479. var dict = image.dict;
  28480. if (dict.has('DecodeParms') || dict.has('DP')) {
  28481. return false;
  28482. }
  28483. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28484. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28485. };
  28486. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  28487. var dict = image.dict;
  28488. if (dict.has('DecodeParms') || dict.has('DP')) {
  28489. return false;
  28490. }
  28491. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28492. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28493. };
  28494. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  28495. this.pdfManager = pdfManager;
  28496. this.xref = xref;
  28497. this.handler = handler;
  28498. this.pageIndex = pageIndex;
  28499. this.idFactory = idFactory;
  28500. this.fontCache = fontCache;
  28501. this.builtInCMapCache = builtInCMapCache;
  28502. this.options = options || DefaultPartialEvaluatorOptions;
  28503. this.fetchBuiltInCMap = function (name) {
  28504. var cachedCMap = builtInCMapCache[name];
  28505. if (cachedCMap) {
  28506. return Promise.resolve(cachedCMap);
  28507. }
  28508. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  28509. if (data.compressionType !== CMapCompressionType.NONE) {
  28510. builtInCMapCache[name] = data;
  28511. }
  28512. return data;
  28513. });
  28514. };
  28515. }
  28516. var TIME_SLOT_DURATION_MS = 20;
  28517. var CHECK_TIME_EVERY = 100;
  28518. function TimeSlotManager() {
  28519. this.reset();
  28520. }
  28521. TimeSlotManager.prototype = {
  28522. check: function TimeSlotManager_check() {
  28523. if (++this.checked < CHECK_TIME_EVERY) {
  28524. return false;
  28525. }
  28526. this.checked = 0;
  28527. return this.endTime <= Date.now();
  28528. },
  28529. reset: function TimeSlotManager_reset() {
  28530. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  28531. this.checked = 0;
  28532. }
  28533. };
  28534. var deferred = Promise.resolve();
  28535. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  28536. PartialEvaluator.prototype = {
  28537. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  28538. if (!isDict(resources)) {
  28539. return false;
  28540. }
  28541. var processed = Object.create(null);
  28542. if (resources.objId) {
  28543. processed[resources.objId] = true;
  28544. }
  28545. var nodes = [resources], xref = this.xref;
  28546. while (nodes.length) {
  28547. var key, i, ii;
  28548. var node = nodes.shift();
  28549. var graphicStates = node.get('ExtGState');
  28550. if (isDict(graphicStates)) {
  28551. var graphicStatesKeys = graphicStates.getKeys();
  28552. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  28553. key = graphicStatesKeys[i];
  28554. var graphicState = graphicStates.get(key);
  28555. var bm = graphicState.get('BM');
  28556. if (isName(bm) && bm.name !== 'Normal') {
  28557. return true;
  28558. }
  28559. }
  28560. }
  28561. var xObjects = node.get('XObject');
  28562. if (!isDict(xObjects)) {
  28563. continue;
  28564. }
  28565. var xObjectsKeys = xObjects.getKeys();
  28566. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  28567. key = xObjectsKeys[i];
  28568. var xObject = xObjects.getRaw(key);
  28569. if (isRef(xObject)) {
  28570. if (processed[xObject.toString()]) {
  28571. continue;
  28572. }
  28573. xObject = xref.fetch(xObject);
  28574. }
  28575. if (!isStream(xObject)) {
  28576. continue;
  28577. }
  28578. if (xObject.dict.objId) {
  28579. if (processed[xObject.dict.objId]) {
  28580. continue;
  28581. }
  28582. processed[xObject.dict.objId] = true;
  28583. }
  28584. var xResources = xObject.dict.get('Resources');
  28585. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  28586. nodes.push(xResources);
  28587. if (xResources.objId) {
  28588. processed[xResources.objId] = true;
  28589. }
  28590. }
  28591. }
  28592. }
  28593. return false;
  28594. },
  28595. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  28596. var matrix = xobj.dict.getArray('Matrix');
  28597. var bbox = xobj.dict.getArray('BBox');
  28598. var group = xobj.dict.get('Group');
  28599. if (group) {
  28600. var groupOptions = {
  28601. matrix: matrix,
  28602. bbox: bbox,
  28603. smask: smask,
  28604. isolated: false,
  28605. knockout: false
  28606. };
  28607. var groupSubtype = group.get('S');
  28608. var colorSpace;
  28609. if (isName(groupSubtype, 'Transparency')) {
  28610. groupOptions.isolated = group.get('I') || false;
  28611. groupOptions.knockout = group.get('K') || false;
  28612. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  28613. }
  28614. if (smask && smask.backdrop) {
  28615. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  28616. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  28617. }
  28618. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  28619. }
  28620. operatorList.addOp(OPS.paintFormXObjectBegin, [
  28621. matrix,
  28622. bbox
  28623. ]);
  28624. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  28625. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  28626. if (group) {
  28627. operatorList.addOp(OPS.endGroup, [groupOptions]);
  28628. }
  28629. });
  28630. },
  28631. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  28632. var self = this;
  28633. var dict = image.dict;
  28634. var w = dict.get('Width', 'W');
  28635. var h = dict.get('Height', 'H');
  28636. if (!(w && isNum(w)) || !(h && isNum(h))) {
  28637. warn('Image dimensions are missing, or not numbers.');
  28638. return;
  28639. }
  28640. var maxImageSize = this.options.maxImageSize;
  28641. if (maxImageSize !== -1 && w * h > maxImageSize) {
  28642. warn('Image exceeded maximum allowed size and was removed.');
  28643. return;
  28644. }
  28645. var imageMask = dict.get('ImageMask', 'IM') || false;
  28646. var imgData, args;
  28647. if (imageMask) {
  28648. var width = dict.get('Width', 'W');
  28649. var height = dict.get('Height', 'H');
  28650. var bitStrideLength = width + 7 >> 3;
  28651. var imgArray = image.getBytes(bitStrideLength * height);
  28652. var decode = dict.getArray('Decode', 'D');
  28653. var inverseDecode = !!decode && decode[0] > 0;
  28654. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  28655. imgData.cached = true;
  28656. args = [imgData];
  28657. operatorList.addOp(OPS.paintImageMaskXObject, args);
  28658. if (cacheKey) {
  28659. imageCache[cacheKey] = {
  28660. fn: OPS.paintImageMaskXObject,
  28661. args: args
  28662. };
  28663. }
  28664. return;
  28665. }
  28666. var softMask = dict.get('SMask', 'SM') || false;
  28667. var mask = dict.get('Mask') || false;
  28668. var SMALL_IMAGE_DIMENSIONS = 200;
  28669. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  28670. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  28671. imgData = imageObj.createImageData(true);
  28672. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  28673. return;
  28674. }
  28675. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  28676. var objId = 'img_' + this.idFactory.createObjId();
  28677. operatorList.addDependency(objId);
  28678. args = [
  28679. objId,
  28680. w,
  28681. h
  28682. ];
  28683. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  28684. operatorList.addOp(OPS.paintJpegXObject, args);
  28685. this.handler.send('obj', [
  28686. objId,
  28687. this.pageIndex,
  28688. 'JpegStream',
  28689. image.getIR(this.options.forceDataSchema)
  28690. ]);
  28691. return;
  28692. }
  28693. var nativeImageDecoder = null;
  28694. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  28695. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  28696. }
  28697. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  28698. var imgData = imageObj.createImageData(false);
  28699. self.handler.send('obj', [
  28700. objId,
  28701. self.pageIndex,
  28702. 'Image',
  28703. imgData
  28704. ], [imgData.data.buffer]);
  28705. }).then(undefined, function (reason) {
  28706. warn('Unable to decode image: ' + reason);
  28707. self.handler.send('obj', [
  28708. objId,
  28709. self.pageIndex,
  28710. 'Image',
  28711. null
  28712. ]);
  28713. });
  28714. operatorList.addOp(OPS.paintImageXObject, args);
  28715. if (cacheKey) {
  28716. imageCache[cacheKey] = {
  28717. fn: OPS.paintImageXObject,
  28718. args: args
  28719. };
  28720. }
  28721. },
  28722. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  28723. var smaskContent = smask.get('G');
  28724. var smaskOptions = {
  28725. subtype: smask.get('S').name,
  28726. backdrop: smask.get('BC')
  28727. };
  28728. var transferObj = smask.get('TR');
  28729. if (isPDFFunction(transferObj)) {
  28730. var transferFn = PDFFunction.parse(this.xref, transferObj);
  28731. var transferMap = new Uint8Array(256);
  28732. var tmp = new Float32Array(1);
  28733. for (var i = 0; i < 256; i++) {
  28734. tmp[0] = i / 255;
  28735. transferFn(tmp, 0, tmp, 0);
  28736. transferMap[i] = tmp[0] * 255 | 0;
  28737. }
  28738. smaskOptions.transferMap = transferMap;
  28739. }
  28740. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  28741. },
  28742. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  28743. var tilingOpList = new OperatorList();
  28744. var resourcesArray = [
  28745. patternDict.get('Resources'),
  28746. resources
  28747. ];
  28748. var patternResources = Dict.merge(this.xref, resourcesArray);
  28749. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  28750. operatorList.addDependencies(tilingOpList.dependencies);
  28751. operatorList.addOp(fn, getTilingPatternIR({
  28752. fnArray: tilingOpList.fnArray,
  28753. argsArray: tilingOpList.argsArray
  28754. }, patternDict, args));
  28755. });
  28756. },
  28757. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  28758. var fontName;
  28759. if (fontArgs) {
  28760. fontArgs = fontArgs.slice();
  28761. fontName = fontArgs[0].name;
  28762. }
  28763. var self = this;
  28764. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  28765. if (!translated.font.isType3Font) {
  28766. return translated;
  28767. }
  28768. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  28769. return translated;
  28770. }, function (reason) {
  28771. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28772. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  28773. });
  28774. }).then(function (translated) {
  28775. state.font = translated.font;
  28776. translated.send(self.handler);
  28777. return translated.loadedName;
  28778. });
  28779. },
  28780. handleText: function PartialEvaluator_handleText(chars, state) {
  28781. var font = state.font;
  28782. var glyphs = font.charsToGlyphs(chars);
  28783. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  28784. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  28785. var buildPath = function (fontChar) {
  28786. if (!font.renderer.hasBuiltPath(fontChar)) {
  28787. var path = font.renderer.getPathJs(fontChar);
  28788. this.handler.send('commonobj', [
  28789. font.loadedName + '_path_' + fontChar,
  28790. 'FontPath',
  28791. path
  28792. ]);
  28793. }
  28794. }.bind(this);
  28795. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  28796. var glyph = glyphs[i];
  28797. buildPath(glyph.fontChar);
  28798. var accent = glyph.accent;
  28799. if (accent && accent.fontChar) {
  28800. buildPath(accent.fontChar);
  28801. }
  28802. }
  28803. }
  28804. return glyphs;
  28805. },
  28806. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  28807. var gStateObj = [];
  28808. var gStateKeys = gState.getKeys();
  28809. var self = this;
  28810. var promise = Promise.resolve();
  28811. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  28812. var key = gStateKeys[i];
  28813. var value = gState.get(key);
  28814. switch (key) {
  28815. case 'Type':
  28816. break;
  28817. case 'LW':
  28818. case 'LC':
  28819. case 'LJ':
  28820. case 'ML':
  28821. case 'D':
  28822. case 'RI':
  28823. case 'FL':
  28824. case 'CA':
  28825. case 'ca':
  28826. gStateObj.push([
  28827. key,
  28828. value
  28829. ]);
  28830. break;
  28831. case 'Font':
  28832. promise = promise.then(function () {
  28833. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  28834. operatorList.addDependency(loadedName);
  28835. gStateObj.push([
  28836. key,
  28837. [
  28838. loadedName,
  28839. value[1]
  28840. ]
  28841. ]);
  28842. });
  28843. });
  28844. break;
  28845. case 'BM':
  28846. gStateObj.push([
  28847. key,
  28848. value
  28849. ]);
  28850. break;
  28851. case 'SMask':
  28852. if (isName(value, 'None')) {
  28853. gStateObj.push([
  28854. key,
  28855. false
  28856. ]);
  28857. break;
  28858. }
  28859. if (isDict(value)) {
  28860. promise = promise.then(function (dict) {
  28861. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  28862. }.bind(this, value));
  28863. gStateObj.push([
  28864. key,
  28865. true
  28866. ]);
  28867. } else {
  28868. warn('Unsupported SMask type');
  28869. }
  28870. break;
  28871. case 'OP':
  28872. case 'op':
  28873. case 'OPM':
  28874. case 'BG':
  28875. case 'BG2':
  28876. case 'UCR':
  28877. case 'UCR2':
  28878. case 'TR':
  28879. case 'TR2':
  28880. case 'HT':
  28881. case 'SM':
  28882. case 'SA':
  28883. case 'AIS':
  28884. case 'TK':
  28885. info('graphic state operator ' + key);
  28886. break;
  28887. default:
  28888. info('Unknown graphic state operator ' + key);
  28889. break;
  28890. }
  28891. }
  28892. return promise.then(function () {
  28893. if (gStateObj.length > 0) {
  28894. operatorList.addOp(OPS.setGState, [gStateObj]);
  28895. }
  28896. });
  28897. },
  28898. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  28899. function errorFont() {
  28900. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  28901. }
  28902. var fontRef;
  28903. if (font) {
  28904. assert(isRef(font));
  28905. fontRef = font;
  28906. } else {
  28907. var fontRes = resources.get('Font');
  28908. if (fontRes) {
  28909. fontRef = fontRes.getRaw(fontName);
  28910. } else {
  28911. warn('fontRes not available');
  28912. return errorFont();
  28913. }
  28914. }
  28915. if (!fontRef) {
  28916. warn('fontRef not available');
  28917. return errorFont();
  28918. }
  28919. if (this.fontCache.has(fontRef)) {
  28920. return this.fontCache.get(fontRef);
  28921. }
  28922. font = xref.fetchIfRef(fontRef);
  28923. if (!isDict(font)) {
  28924. return errorFont();
  28925. }
  28926. if (font.translated) {
  28927. return font.translated;
  28928. }
  28929. var fontCapability = createPromiseCapability();
  28930. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  28931. var descriptor = preEvaluatedFont.descriptor;
  28932. var fontRefIsRef = isRef(fontRef), fontID;
  28933. if (fontRefIsRef) {
  28934. fontID = fontRef.toString();
  28935. }
  28936. if (isDict(descriptor)) {
  28937. if (!descriptor.fontAliases) {
  28938. descriptor.fontAliases = Object.create(null);
  28939. }
  28940. var fontAliases = descriptor.fontAliases;
  28941. var hash = preEvaluatedFont.hash;
  28942. if (fontAliases[hash]) {
  28943. var aliasFontRef = fontAliases[hash].aliasRef;
  28944. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  28945. this.fontCache.putAlias(fontRef, aliasFontRef);
  28946. return this.fontCache.get(fontRef);
  28947. }
  28948. } else {
  28949. fontAliases[hash] = { fontID: Font.getFontID() };
  28950. }
  28951. if (fontRefIsRef) {
  28952. fontAliases[hash].aliasRef = fontRef;
  28953. }
  28954. fontID = fontAliases[hash].fontID;
  28955. }
  28956. if (fontRefIsRef) {
  28957. this.fontCache.put(fontRef, fontCapability.promise);
  28958. } else {
  28959. if (!fontID) {
  28960. fontID = this.idFactory.createObjId();
  28961. }
  28962. this.fontCache.put('id_' + fontID, fontCapability.promise);
  28963. }
  28964. assert(fontID, 'The "fontID" must be defined.');
  28965. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  28966. font.translated = fontCapability.promise;
  28967. var translatedPromise;
  28968. try {
  28969. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  28970. } catch (e) {
  28971. translatedPromise = Promise.reject(e);
  28972. }
  28973. var self = this;
  28974. translatedPromise.then(function (translatedFont) {
  28975. if (translatedFont.fontType !== undefined) {
  28976. var xrefFontStats = xref.stats.fontTypes;
  28977. xrefFontStats[translatedFont.fontType] = true;
  28978. }
  28979. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  28980. }, function (reason) {
  28981. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28982. try {
  28983. var descriptor = preEvaluatedFont.descriptor;
  28984. var fontFile3 = descriptor && descriptor.get('FontFile3');
  28985. var subtype = fontFile3 && fontFile3.get('Subtype');
  28986. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  28987. var xrefFontStats = xref.stats.fontTypes;
  28988. xrefFontStats[fontType] = true;
  28989. } catch (ex) {
  28990. }
  28991. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  28992. });
  28993. return fontCapability.promise;
  28994. },
  28995. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  28996. var lastIndex = operatorList.length - 1;
  28997. if (!args) {
  28998. args = [];
  28999. }
  29000. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29001. operatorList.addOp(OPS.constructPath, [
  29002. [fn],
  29003. args
  29004. ]);
  29005. } else {
  29006. var opArgs = operatorList.argsArray[lastIndex];
  29007. opArgs[0].push(fn);
  29008. Array.prototype.push.apply(opArgs[1], args);
  29009. }
  29010. },
  29011. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29012. var patternName = args[args.length - 1];
  29013. var pattern;
  29014. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29015. var dict = isStream(pattern) ? pattern.dict : pattern;
  29016. var typeNum = dict.get('PatternType');
  29017. if (typeNum === TILING_PATTERN) {
  29018. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29019. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29020. } else if (typeNum === SHADING_PATTERN) {
  29021. var shading = dict.get('Shading');
  29022. var matrix = dict.getArray('Matrix');
  29023. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29024. operatorList.addOp(fn, pattern.getIR());
  29025. return Promise.resolve();
  29026. }
  29027. return Promise.reject('Unknown PatternType: ' + typeNum);
  29028. }
  29029. operatorList.addOp(fn, args);
  29030. return Promise.resolve();
  29031. },
  29032. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29033. var self = this;
  29034. var xref = this.xref;
  29035. var imageCache = Object.create(null);
  29036. assert(operatorList);
  29037. resources = resources || Dict.empty;
  29038. var xobjs = resources.get('XObject') || Dict.empty;
  29039. var patterns = resources.get('Pattern') || Dict.empty;
  29040. var stateManager = new StateManager(initialState || new EvalState());
  29041. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29042. var timeSlotManager = new TimeSlotManager();
  29043. return new Promise(function promiseBody(resolve, reject) {
  29044. var next = function (promise) {
  29045. promise.then(function () {
  29046. try {
  29047. promiseBody(resolve, reject);
  29048. } catch (ex) {
  29049. reject(ex);
  29050. }
  29051. }, reject);
  29052. };
  29053. task.ensureNotTerminated();
  29054. timeSlotManager.reset();
  29055. var stop, operation = {}, i, ii, cs;
  29056. while (!(stop = timeSlotManager.check())) {
  29057. operation.args = null;
  29058. if (!preprocessor.read(operation)) {
  29059. break;
  29060. }
  29061. var args = operation.args;
  29062. var fn = operation.fn;
  29063. switch (fn | 0) {
  29064. case OPS.paintXObject:
  29065. if (args[0].code) {
  29066. break;
  29067. }
  29068. var name = args[0].name;
  29069. if (!name) {
  29070. warn('XObject must be referred to by name.');
  29071. continue;
  29072. }
  29073. if (imageCache[name] !== undefined) {
  29074. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29075. args = null;
  29076. continue;
  29077. }
  29078. var xobj = xobjs.get(name);
  29079. if (xobj) {
  29080. assert(isStream(xobj), 'XObject should be a stream');
  29081. var type = xobj.dict.get('Subtype');
  29082. assert(isName(type), 'XObject should have a Name subtype');
  29083. if (type.name === 'Form') {
  29084. stateManager.save();
  29085. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29086. stateManager.restore();
  29087. }));
  29088. return;
  29089. } else if (type.name === 'Image') {
  29090. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29091. args = null;
  29092. continue;
  29093. } else if (type.name === 'PS') {
  29094. info('Ignored XObject subtype PS');
  29095. continue;
  29096. } else {
  29097. error('Unhandled XObject subtype ' + type.name);
  29098. }
  29099. }
  29100. break;
  29101. case OPS.setFont:
  29102. var fontSize = args[1];
  29103. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29104. operatorList.addDependency(loadedName);
  29105. operatorList.addOp(OPS.setFont, [
  29106. loadedName,
  29107. fontSize
  29108. ]);
  29109. }));
  29110. return;
  29111. case OPS.endInlineImage:
  29112. var cacheKey = args[0].cacheKey;
  29113. if (cacheKey) {
  29114. var cacheEntry = imageCache[cacheKey];
  29115. if (cacheEntry !== undefined) {
  29116. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29117. args = null;
  29118. continue;
  29119. }
  29120. }
  29121. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29122. args = null;
  29123. continue;
  29124. case OPS.showText:
  29125. args[0] = self.handleText(args[0], stateManager.state);
  29126. break;
  29127. case OPS.showSpacedText:
  29128. var arr = args[0];
  29129. var combinedGlyphs = [];
  29130. var arrLength = arr.length;
  29131. var state = stateManager.state;
  29132. for (i = 0; i < arrLength; ++i) {
  29133. var arrItem = arr[i];
  29134. if (isString(arrItem)) {
  29135. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29136. } else if (isNum(arrItem)) {
  29137. combinedGlyphs.push(arrItem);
  29138. }
  29139. }
  29140. args[0] = combinedGlyphs;
  29141. fn = OPS.showText;
  29142. break;
  29143. case OPS.nextLineShowText:
  29144. operatorList.addOp(OPS.nextLine);
  29145. args[0] = self.handleText(args[0], stateManager.state);
  29146. fn = OPS.showText;
  29147. break;
  29148. case OPS.nextLineSetSpacingShowText:
  29149. operatorList.addOp(OPS.nextLine);
  29150. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29151. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29152. args[0] = self.handleText(args[0], stateManager.state);
  29153. fn = OPS.showText;
  29154. break;
  29155. case OPS.setTextRenderingMode:
  29156. stateManager.state.textRenderingMode = args[0];
  29157. break;
  29158. case OPS.setFillColorSpace:
  29159. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29160. continue;
  29161. case OPS.setStrokeColorSpace:
  29162. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29163. continue;
  29164. case OPS.setFillColor:
  29165. cs = stateManager.state.fillColorSpace;
  29166. args = cs.getRgb(args, 0);
  29167. fn = OPS.setFillRGBColor;
  29168. break;
  29169. case OPS.setStrokeColor:
  29170. cs = stateManager.state.strokeColorSpace;
  29171. args = cs.getRgb(args, 0);
  29172. fn = OPS.setStrokeRGBColor;
  29173. break;
  29174. case OPS.setFillGray:
  29175. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29176. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29177. fn = OPS.setFillRGBColor;
  29178. break;
  29179. case OPS.setStrokeGray:
  29180. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29181. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29182. fn = OPS.setStrokeRGBColor;
  29183. break;
  29184. case OPS.setFillCMYKColor:
  29185. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29186. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29187. fn = OPS.setFillRGBColor;
  29188. break;
  29189. case OPS.setStrokeCMYKColor:
  29190. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29191. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29192. fn = OPS.setStrokeRGBColor;
  29193. break;
  29194. case OPS.setFillRGBColor:
  29195. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29196. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29197. break;
  29198. case OPS.setStrokeRGBColor:
  29199. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29200. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29201. break;
  29202. case OPS.setFillColorN:
  29203. cs = stateManager.state.fillColorSpace;
  29204. if (cs.name === 'Pattern') {
  29205. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29206. return;
  29207. }
  29208. args = cs.getRgb(args, 0);
  29209. fn = OPS.setFillRGBColor;
  29210. break;
  29211. case OPS.setStrokeColorN:
  29212. cs = stateManager.state.strokeColorSpace;
  29213. if (cs.name === 'Pattern') {
  29214. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29215. return;
  29216. }
  29217. args = cs.getRgb(args, 0);
  29218. fn = OPS.setStrokeRGBColor;
  29219. break;
  29220. case OPS.shadingFill:
  29221. var shadingRes = resources.get('Shading');
  29222. if (!shadingRes) {
  29223. error('No shading resource found');
  29224. }
  29225. var shading = shadingRes.get(args[0].name);
  29226. if (!shading) {
  29227. error('No shading object found');
  29228. }
  29229. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29230. var patternIR = shadingFill.getIR();
  29231. args = [patternIR];
  29232. fn = OPS.shadingFill;
  29233. break;
  29234. case OPS.setGState:
  29235. var dictName = args[0];
  29236. var extGState = resources.get('ExtGState');
  29237. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29238. break;
  29239. }
  29240. var gState = extGState.get(dictName.name);
  29241. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29242. return;
  29243. case OPS.moveTo:
  29244. case OPS.lineTo:
  29245. case OPS.curveTo:
  29246. case OPS.curveTo2:
  29247. case OPS.curveTo3:
  29248. case OPS.closePath:
  29249. self.buildPath(operatorList, fn, args);
  29250. continue;
  29251. case OPS.rectangle:
  29252. self.buildPath(operatorList, fn, args);
  29253. continue;
  29254. case OPS.markPoint:
  29255. case OPS.markPointProps:
  29256. case OPS.beginMarkedContent:
  29257. case OPS.beginMarkedContentProps:
  29258. case OPS.endMarkedContent:
  29259. case OPS.beginCompat:
  29260. case OPS.endCompat:
  29261. continue;
  29262. default:
  29263. if (args !== null) {
  29264. for (i = 0, ii = args.length; i < ii; i++) {
  29265. if (args[i] instanceof Dict) {
  29266. break;
  29267. }
  29268. }
  29269. if (i < ii) {
  29270. warn('getOperatorList - ignoring operator: ' + fn);
  29271. continue;
  29272. }
  29273. }
  29274. }
  29275. operatorList.addOp(fn, args);
  29276. }
  29277. if (stop) {
  29278. next(deferred);
  29279. return;
  29280. }
  29281. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  29282. operatorList.addOp(OPS.restore, []);
  29283. }
  29284. resolve();
  29285. });
  29286. },
  29287. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  29288. stateManager = stateManager || new StateManager(new TextState());
  29289. var WhitespaceRegexp = /\s/g;
  29290. var textContent = {
  29291. items: [],
  29292. styles: Object.create(null)
  29293. };
  29294. var textContentItem = {
  29295. initialized: false,
  29296. str: [],
  29297. width: 0,
  29298. height: 0,
  29299. vertical: false,
  29300. lastAdvanceWidth: 0,
  29301. lastAdvanceHeight: 0,
  29302. textAdvanceScale: 0,
  29303. spaceWidth: 0,
  29304. fakeSpaceMin: Infinity,
  29305. fakeMultiSpaceMin: Infinity,
  29306. fakeMultiSpaceMax: -0,
  29307. textRunBreakAllowed: false,
  29308. transform: null,
  29309. fontName: null
  29310. };
  29311. var SPACE_FACTOR = 0.3;
  29312. var MULTI_SPACE_FACTOR = 1.5;
  29313. var MULTI_SPACE_FACTOR_MAX = 4;
  29314. var self = this;
  29315. var xref = this.xref;
  29316. resources = xref.fetchIfRef(resources) || Dict.empty;
  29317. var xobjs = null;
  29318. var xobjsCache = Object.create(null);
  29319. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29320. var textState;
  29321. function ensureTextContentItem() {
  29322. if (textContentItem.initialized) {
  29323. return textContentItem;
  29324. }
  29325. var font = textState.font;
  29326. if (!(font.loadedName in textContent.styles)) {
  29327. textContent.styles[font.loadedName] = {
  29328. fontFamily: font.fallbackName,
  29329. ascent: font.ascent,
  29330. descent: font.descent,
  29331. vertical: font.vertical
  29332. };
  29333. }
  29334. textContentItem.fontName = font.loadedName;
  29335. var tsm = [
  29336. textState.fontSize * textState.textHScale,
  29337. 0,
  29338. 0,
  29339. textState.fontSize,
  29340. 0,
  29341. textState.textRise
  29342. ];
  29343. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  29344. var glyphHeight = font.bbox[3] - font.bbox[1];
  29345. if (glyphHeight > 0) {
  29346. glyphHeight = glyphHeight * textState.fontMatrix[3];
  29347. tsm[3] *= glyphHeight;
  29348. }
  29349. }
  29350. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  29351. textContentItem.transform = trm;
  29352. if (!font.vertical) {
  29353. textContentItem.width = 0;
  29354. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  29355. textContentItem.vertical = false;
  29356. } else {
  29357. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  29358. textContentItem.height = 0;
  29359. textContentItem.vertical = true;
  29360. }
  29361. var a = textState.textLineMatrix[0];
  29362. var b = textState.textLineMatrix[1];
  29363. var scaleLineX = Math.sqrt(a * a + b * b);
  29364. a = textState.ctm[0];
  29365. b = textState.ctm[1];
  29366. var scaleCtmX = Math.sqrt(a * a + b * b);
  29367. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  29368. textContentItem.lastAdvanceWidth = 0;
  29369. textContentItem.lastAdvanceHeight = 0;
  29370. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  29371. if (spaceWidth) {
  29372. textContentItem.spaceWidth = spaceWidth;
  29373. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  29374. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  29375. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  29376. textContentItem.textRunBreakAllowed = !font.isMonospace;
  29377. } else {
  29378. textContentItem.spaceWidth = 0;
  29379. textContentItem.fakeSpaceMin = Infinity;
  29380. textContentItem.fakeMultiSpaceMin = Infinity;
  29381. textContentItem.fakeMultiSpaceMax = 0;
  29382. textContentItem.textRunBreakAllowed = false;
  29383. }
  29384. textContentItem.initialized = true;
  29385. return textContentItem;
  29386. }
  29387. function replaceWhitespace(str) {
  29388. var i = 0, ii = str.length, code;
  29389. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  29390. i++;
  29391. }
  29392. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  29393. }
  29394. function runBidiTransform(textChunk) {
  29395. var str = textChunk.str.join('');
  29396. var bidiResult = bidi(str, -1, textChunk.vertical);
  29397. return {
  29398. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  29399. dir: bidiResult.dir,
  29400. width: textChunk.width,
  29401. height: textChunk.height,
  29402. transform: textChunk.transform,
  29403. fontName: textChunk.fontName
  29404. };
  29405. }
  29406. function handleSetFont(fontName, fontRef) {
  29407. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  29408. textState.font = translated.font;
  29409. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  29410. });
  29411. }
  29412. function buildTextContentItem(chars) {
  29413. var font = textState.font;
  29414. var textChunk = ensureTextContentItem();
  29415. var width = 0;
  29416. var height = 0;
  29417. var glyphs = font.charsToGlyphs(chars);
  29418. for (var i = 0; i < glyphs.length; i++) {
  29419. var glyph = glyphs[i];
  29420. var glyphWidth = null;
  29421. if (font.vertical && glyph.vmetric) {
  29422. glyphWidth = glyph.vmetric[0];
  29423. } else {
  29424. glyphWidth = glyph.width;
  29425. }
  29426. var glyphUnicode = glyph.unicode;
  29427. var NormalizedUnicodes = getNormalizedUnicodes();
  29428. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  29429. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  29430. }
  29431. glyphUnicode = reverseIfRtl(glyphUnicode);
  29432. var charSpacing = textState.charSpacing;
  29433. if (glyph.isSpace) {
  29434. var wordSpacing = textState.wordSpacing;
  29435. charSpacing += wordSpacing;
  29436. if (wordSpacing > 0) {
  29437. addFakeSpaces(wordSpacing, textChunk.str);
  29438. }
  29439. }
  29440. var tx = 0;
  29441. var ty = 0;
  29442. if (!font.vertical) {
  29443. var w0 = glyphWidth * textState.fontMatrix[0];
  29444. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  29445. width += tx;
  29446. } else {
  29447. var w1 = glyphWidth * textState.fontMatrix[0];
  29448. ty = w1 * textState.fontSize + charSpacing;
  29449. height += ty;
  29450. }
  29451. textState.translateTextMatrix(tx, ty);
  29452. textChunk.str.push(glyphUnicode);
  29453. }
  29454. if (!font.vertical) {
  29455. textChunk.lastAdvanceWidth = width;
  29456. textChunk.width += width;
  29457. } else {
  29458. textChunk.lastAdvanceHeight = height;
  29459. textChunk.height += Math.abs(height);
  29460. }
  29461. return textChunk;
  29462. }
  29463. function addFakeSpaces(width, strBuf) {
  29464. if (width < textContentItem.fakeSpaceMin) {
  29465. return;
  29466. }
  29467. if (width < textContentItem.fakeMultiSpaceMin) {
  29468. strBuf.push(' ');
  29469. return;
  29470. }
  29471. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  29472. while (fakeSpaces-- > 0) {
  29473. strBuf.push(' ');
  29474. }
  29475. }
  29476. function flushTextContentItem() {
  29477. if (!textContentItem.initialized) {
  29478. return;
  29479. }
  29480. textContentItem.width *= textContentItem.textAdvanceScale;
  29481. textContentItem.height *= textContentItem.textAdvanceScale;
  29482. textContent.items.push(runBidiTransform(textContentItem));
  29483. textContentItem.initialized = false;
  29484. textContentItem.str.length = 0;
  29485. }
  29486. var timeSlotManager = new TimeSlotManager();
  29487. return new Promise(function promiseBody(resolve, reject) {
  29488. var next = function (promise) {
  29489. promise.then(function () {
  29490. try {
  29491. promiseBody(resolve, reject);
  29492. } catch (ex) {
  29493. reject(ex);
  29494. }
  29495. }, reject);
  29496. };
  29497. task.ensureNotTerminated();
  29498. timeSlotManager.reset();
  29499. var stop, operation = {}, args = [];
  29500. while (!(stop = timeSlotManager.check())) {
  29501. args.length = 0;
  29502. operation.args = args;
  29503. if (!preprocessor.read(operation)) {
  29504. break;
  29505. }
  29506. textState = stateManager.state;
  29507. var fn = operation.fn;
  29508. args = operation.args;
  29509. var advance, diff;
  29510. switch (fn | 0) {
  29511. case OPS.setFont:
  29512. var fontNameArg = args[0].name, fontSizeArg = args[1];
  29513. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  29514. break;
  29515. }
  29516. flushTextContentItem();
  29517. textState.fontName = fontNameArg;
  29518. textState.fontSize = fontSizeArg;
  29519. next(handleSetFont(fontNameArg, null));
  29520. return;
  29521. case OPS.setTextRise:
  29522. flushTextContentItem();
  29523. textState.textRise = args[0];
  29524. break;
  29525. case OPS.setHScale:
  29526. flushTextContentItem();
  29527. textState.textHScale = args[0] / 100;
  29528. break;
  29529. case OPS.setLeading:
  29530. flushTextContentItem();
  29531. textState.leading = args[0];
  29532. break;
  29533. case OPS.moveText:
  29534. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  29535. advance = args[0] - args[1];
  29536. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  29537. textState.translateTextLineMatrix(args[0], args[1]);
  29538. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  29539. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  29540. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  29541. addFakeSpaces(diff, textContentItem.str);
  29542. break;
  29543. }
  29544. flushTextContentItem();
  29545. textState.translateTextLineMatrix(args[0], args[1]);
  29546. textState.textMatrix = textState.textLineMatrix.slice();
  29547. break;
  29548. case OPS.setLeadingMoveText:
  29549. flushTextContentItem();
  29550. textState.leading = -args[1];
  29551. textState.translateTextLineMatrix(args[0], args[1]);
  29552. textState.textMatrix = textState.textLineMatrix.slice();
  29553. break;
  29554. case OPS.nextLine:
  29555. flushTextContentItem();
  29556. textState.carriageReturn();
  29557. break;
  29558. case OPS.setTextMatrix:
  29559. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  29560. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  29561. textState.translateTextLineMatrix(advance.width, advance.height);
  29562. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  29563. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  29564. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  29565. addFakeSpaces(diff, textContentItem.str);
  29566. break;
  29567. }
  29568. flushTextContentItem();
  29569. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29570. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29571. break;
  29572. case OPS.setCharSpacing:
  29573. textState.charSpacing = args[0];
  29574. break;
  29575. case OPS.setWordSpacing:
  29576. textState.wordSpacing = args[0];
  29577. break;
  29578. case OPS.beginText:
  29579. flushTextContentItem();
  29580. textState.textMatrix = IDENTITY_MATRIX.slice();
  29581. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  29582. break;
  29583. case OPS.showSpacedText:
  29584. var items = args[0];
  29585. var offset;
  29586. for (var j = 0, jj = items.length; j < jj; j++) {
  29587. if (typeof items[j] === 'string') {
  29588. buildTextContentItem(items[j]);
  29589. } else if (isNum(items[j])) {
  29590. ensureTextContentItem();
  29591. advance = items[j] * textState.fontSize / 1000;
  29592. var breakTextRun = false;
  29593. if (textState.font.vertical) {
  29594. offset = advance;
  29595. textState.translateTextMatrix(0, offset);
  29596. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29597. if (!breakTextRun) {
  29598. textContentItem.height += offset;
  29599. }
  29600. } else {
  29601. advance = -advance;
  29602. offset = advance * textState.textHScale;
  29603. textState.translateTextMatrix(offset, 0);
  29604. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29605. if (!breakTextRun) {
  29606. textContentItem.width += offset;
  29607. }
  29608. }
  29609. if (breakTextRun) {
  29610. flushTextContentItem();
  29611. } else if (advance > 0) {
  29612. addFakeSpaces(advance, textContentItem.str);
  29613. }
  29614. }
  29615. }
  29616. break;
  29617. case OPS.showText:
  29618. buildTextContentItem(args[0]);
  29619. break;
  29620. case OPS.nextLineShowText:
  29621. flushTextContentItem();
  29622. textState.carriageReturn();
  29623. buildTextContentItem(args[0]);
  29624. break;
  29625. case OPS.nextLineSetSpacingShowText:
  29626. flushTextContentItem();
  29627. textState.wordSpacing = args[0];
  29628. textState.charSpacing = args[1];
  29629. textState.carriageReturn();
  29630. buildTextContentItem(args[2]);
  29631. break;
  29632. case OPS.paintXObject:
  29633. flushTextContentItem();
  29634. if (args[0].code) {
  29635. break;
  29636. }
  29637. if (!xobjs) {
  29638. xobjs = resources.get('XObject') || Dict.empty;
  29639. }
  29640. var name = args[0].name;
  29641. if (xobjsCache.key === name) {
  29642. if (xobjsCache.texts) {
  29643. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  29644. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  29645. }
  29646. break;
  29647. }
  29648. var xobj = xobjs.get(name);
  29649. if (!xobj) {
  29650. break;
  29651. }
  29652. assert(isStream(xobj), 'XObject should be a stream');
  29653. var type = xobj.dict.get('Subtype');
  29654. assert(isName(type), 'XObject should have a Name subtype');
  29655. if ('Form' !== type.name) {
  29656. xobjsCache.key = name;
  29657. xobjsCache.texts = null;
  29658. break;
  29659. }
  29660. stateManager.save();
  29661. var matrix = xobj.dict.getArray('Matrix');
  29662. if (isArray(matrix) && matrix.length === 6) {
  29663. stateManager.transform(matrix);
  29664. }
  29665. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  29666. Util.appendToArray(textContent.items, formTextContent.items);
  29667. Util.extendObj(textContent.styles, formTextContent.styles);
  29668. stateManager.restore();
  29669. xobjsCache.key = name;
  29670. xobjsCache.texts = formTextContent;
  29671. }));
  29672. return;
  29673. case OPS.setGState:
  29674. flushTextContentItem();
  29675. var dictName = args[0];
  29676. var extGState = resources.get('ExtGState');
  29677. if (!isDict(extGState) || !isName(dictName)) {
  29678. break;
  29679. }
  29680. var gState = extGState.get(dictName.name);
  29681. if (!isDict(gState)) {
  29682. break;
  29683. }
  29684. var gStateFont = gState.get('Font');
  29685. if (gStateFont) {
  29686. textState.fontName = null;
  29687. textState.fontSize = gStateFont[1];
  29688. next(handleSetFont(null, gStateFont[0]));
  29689. return;
  29690. }
  29691. break;
  29692. }
  29693. }
  29694. if (stop) {
  29695. next(deferred);
  29696. return;
  29697. }
  29698. flushTextContentItem();
  29699. resolve(textContent);
  29700. });
  29701. },
  29702. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  29703. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  29704. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  29705. if (properties.composite) {
  29706. var cidSystemInfo = dict.get('CIDSystemInfo');
  29707. if (isDict(cidSystemInfo)) {
  29708. properties.cidSystemInfo = {
  29709. registry: cidSystemInfo.get('Registry'),
  29710. ordering: cidSystemInfo.get('Ordering'),
  29711. supplement: cidSystemInfo.get('Supplement')
  29712. };
  29713. }
  29714. var cidToGidMap = dict.get('CIDToGIDMap');
  29715. if (isStream(cidToGidMap)) {
  29716. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  29717. }
  29718. }
  29719. var differences = [];
  29720. var baseEncodingName = null;
  29721. var encoding;
  29722. if (dict.has('Encoding')) {
  29723. encoding = dict.get('Encoding');
  29724. if (isDict(encoding)) {
  29725. baseEncodingName = encoding.get('BaseEncoding');
  29726. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  29727. if (encoding.has('Differences')) {
  29728. var diffEncoding = encoding.get('Differences');
  29729. var index = 0;
  29730. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  29731. var data = xref.fetchIfRef(diffEncoding[j]);
  29732. if (isNum(data)) {
  29733. index = data;
  29734. } else if (isName(data)) {
  29735. differences[index++] = data.name;
  29736. } else {
  29737. error('Invalid entry in \'Differences\' array: ' + data);
  29738. }
  29739. }
  29740. }
  29741. } else if (isName(encoding)) {
  29742. baseEncodingName = encoding.name;
  29743. } else {
  29744. error('Encoding is not a Name nor a Dict');
  29745. }
  29746. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  29747. baseEncodingName = null;
  29748. }
  29749. }
  29750. if (baseEncodingName) {
  29751. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  29752. } else {
  29753. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  29754. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  29755. encoding = StandardEncoding;
  29756. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  29757. encoding = WinAnsiEncoding;
  29758. }
  29759. if (isSymbolicFont) {
  29760. encoding = MacRomanEncoding;
  29761. if (!properties.file) {
  29762. if (/Symbol/i.test(properties.name)) {
  29763. encoding = SymbolSetEncoding;
  29764. } else if (/Dingbats/i.test(properties.name)) {
  29765. encoding = ZapfDingbatsEncoding;
  29766. }
  29767. }
  29768. }
  29769. properties.defaultEncoding = encoding;
  29770. }
  29771. properties.differences = differences;
  29772. properties.baseEncodingName = baseEncodingName;
  29773. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  29774. properties.dict = dict;
  29775. return toUnicodePromise.then(function (toUnicode) {
  29776. properties.toUnicode = toUnicode;
  29777. return this.buildToUnicode(properties);
  29778. }.bind(this)).then(function (toUnicode) {
  29779. properties.toUnicode = toUnicode;
  29780. return properties;
  29781. });
  29782. },
  29783. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  29784. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  29785. if (properties.hasIncludedToUnicodeMap) {
  29786. return Promise.resolve(properties.toUnicode);
  29787. }
  29788. var toUnicode, charcode, glyphName;
  29789. if (!properties.composite) {
  29790. toUnicode = [];
  29791. var encoding = properties.defaultEncoding.slice();
  29792. var baseEncodingName = properties.baseEncodingName;
  29793. var differences = properties.differences;
  29794. for (charcode in differences) {
  29795. glyphName = differences[charcode];
  29796. if (glyphName === '.notdef') {
  29797. continue;
  29798. }
  29799. encoding[charcode] = glyphName;
  29800. }
  29801. var glyphsUnicodeMap = getGlyphsUnicode();
  29802. for (charcode in encoding) {
  29803. glyphName = encoding[charcode];
  29804. if (glyphName === '') {
  29805. continue;
  29806. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  29807. var code = 0;
  29808. switch (glyphName[0]) {
  29809. case 'G':
  29810. if (glyphName.length === 3) {
  29811. code = parseInt(glyphName.substr(1), 16);
  29812. }
  29813. break;
  29814. case 'g':
  29815. if (glyphName.length === 5) {
  29816. code = parseInt(glyphName.substr(1), 16);
  29817. }
  29818. break;
  29819. case 'C':
  29820. case 'c':
  29821. if (glyphName.length >= 3) {
  29822. code = +glyphName.substr(1);
  29823. }
  29824. break;
  29825. default:
  29826. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  29827. if (unicode !== -1) {
  29828. code = unicode;
  29829. }
  29830. }
  29831. if (code) {
  29832. if (baseEncodingName && code === +charcode) {
  29833. var baseEncoding = getEncoding(baseEncodingName);
  29834. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  29835. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29836. continue;
  29837. }
  29838. }
  29839. toUnicode[charcode] = String.fromCharCode(code);
  29840. }
  29841. continue;
  29842. }
  29843. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29844. }
  29845. return Promise.resolve(new ToUnicodeMap(toUnicode));
  29846. }
  29847. 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'))) {
  29848. var registry = properties.cidSystemInfo.registry;
  29849. var ordering = properties.cidSystemInfo.ordering;
  29850. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  29851. return CMapFactory.create({
  29852. encoding: ucs2CMapName,
  29853. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29854. useCMap: null
  29855. }).then(function (ucs2CMap) {
  29856. var cMap = properties.cMap;
  29857. toUnicode = [];
  29858. cMap.forEach(function (charcode, cid) {
  29859. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  29860. var ucs2 = ucs2CMap.lookup(cid);
  29861. if (ucs2) {
  29862. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  29863. }
  29864. });
  29865. return new ToUnicodeMap(toUnicode);
  29866. });
  29867. }
  29868. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  29869. },
  29870. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  29871. var cmapObj = toUnicode;
  29872. if (isName(cmapObj)) {
  29873. return CMapFactory.create({
  29874. encoding: cmapObj,
  29875. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29876. useCMap: null
  29877. }).then(function (cmap) {
  29878. if (cmap instanceof IdentityCMap) {
  29879. return new IdentityToUnicodeMap(0, 0xFFFF);
  29880. }
  29881. return new ToUnicodeMap(cmap.getMap());
  29882. });
  29883. } else if (isStream(cmapObj)) {
  29884. return CMapFactory.create({
  29885. encoding: cmapObj,
  29886. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29887. useCMap: null
  29888. }).then(function (cmap) {
  29889. if (cmap instanceof IdentityCMap) {
  29890. return new IdentityToUnicodeMap(0, 0xFFFF);
  29891. }
  29892. var map = new Array(cmap.length);
  29893. cmap.forEach(function (charCode, token) {
  29894. var str = [];
  29895. for (var k = 0; k < token.length; k += 2) {
  29896. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29897. if ((w1 & 0xF800) !== 0xD800) {
  29898. str.push(w1);
  29899. continue;
  29900. }
  29901. k += 2;
  29902. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29903. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  29904. }
  29905. map[charCode] = String.fromCharCode.apply(String, str);
  29906. });
  29907. return new ToUnicodeMap(map);
  29908. });
  29909. }
  29910. return Promise.resolve(null);
  29911. },
  29912. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  29913. var glyphsData = cidToGidStream.getBytes();
  29914. var result = [];
  29915. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  29916. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  29917. if (glyphID === 0) {
  29918. continue;
  29919. }
  29920. var code = j >> 1;
  29921. result[code] = glyphID;
  29922. }
  29923. return result;
  29924. },
  29925. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  29926. var glyphsWidths = [];
  29927. var defaultWidth = 0;
  29928. var glyphsVMetrics = [];
  29929. var defaultVMetrics;
  29930. var i, ii, j, jj, start, code, widths;
  29931. if (properties.composite) {
  29932. defaultWidth = dict.get('DW') || 1000;
  29933. widths = dict.get('W');
  29934. if (widths) {
  29935. for (i = 0, ii = widths.length; i < ii; i++) {
  29936. start = xref.fetchIfRef(widths[i++]);
  29937. code = xref.fetchIfRef(widths[i]);
  29938. if (isArray(code)) {
  29939. for (j = 0, jj = code.length; j < jj; j++) {
  29940. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  29941. }
  29942. } else {
  29943. var width = xref.fetchIfRef(widths[++i]);
  29944. for (j = start; j <= code; j++) {
  29945. glyphsWidths[j] = width;
  29946. }
  29947. }
  29948. }
  29949. }
  29950. if (properties.vertical) {
  29951. var vmetrics = dict.getArray('DW2') || [
  29952. 880,
  29953. -1000
  29954. ];
  29955. defaultVMetrics = [
  29956. vmetrics[1],
  29957. defaultWidth * 0.5,
  29958. vmetrics[0]
  29959. ];
  29960. vmetrics = dict.get('W2');
  29961. if (vmetrics) {
  29962. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  29963. start = xref.fetchIfRef(vmetrics[i++]);
  29964. code = xref.fetchIfRef(vmetrics[i]);
  29965. if (isArray(code)) {
  29966. for (j = 0, jj = code.length; j < jj; j++) {
  29967. glyphsVMetrics[start++] = [
  29968. xref.fetchIfRef(code[j++]),
  29969. xref.fetchIfRef(code[j++]),
  29970. xref.fetchIfRef(code[j])
  29971. ];
  29972. }
  29973. } else {
  29974. var vmetric = [
  29975. xref.fetchIfRef(vmetrics[++i]),
  29976. xref.fetchIfRef(vmetrics[++i]),
  29977. xref.fetchIfRef(vmetrics[++i])
  29978. ];
  29979. for (j = start; j <= code; j++) {
  29980. glyphsVMetrics[j] = vmetric;
  29981. }
  29982. }
  29983. }
  29984. }
  29985. }
  29986. } else {
  29987. var firstChar = properties.firstChar;
  29988. widths = dict.get('Widths');
  29989. if (widths) {
  29990. j = firstChar;
  29991. for (i = 0, ii = widths.length; i < ii; i++) {
  29992. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  29993. }
  29994. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  29995. } else {
  29996. var baseFontName = dict.get('BaseFont');
  29997. if (isName(baseFontName)) {
  29998. var metrics = this.getBaseFontMetrics(baseFontName.name);
  29999. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30000. defaultWidth = metrics.defaultWidth;
  30001. }
  30002. }
  30003. }
  30004. var isMonospace = true;
  30005. var firstWidth = defaultWidth;
  30006. for (var glyph in glyphsWidths) {
  30007. var glyphWidth = glyphsWidths[glyph];
  30008. if (!glyphWidth) {
  30009. continue;
  30010. }
  30011. if (!firstWidth) {
  30012. firstWidth = glyphWidth;
  30013. continue;
  30014. }
  30015. if (firstWidth !== glyphWidth) {
  30016. isMonospace = false;
  30017. break;
  30018. }
  30019. }
  30020. if (isMonospace) {
  30021. properties.flags |= FontFlags.FixedPitch;
  30022. }
  30023. properties.defaultWidth = defaultWidth;
  30024. properties.widths = glyphsWidths;
  30025. properties.defaultVMetrics = defaultVMetrics;
  30026. properties.vmetrics = glyphsVMetrics;
  30027. },
  30028. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30029. var fontNameWoStyle = baseFontName.split('-')[0];
  30030. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30031. },
  30032. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30033. var defaultWidth = 0;
  30034. var widths = [];
  30035. var monospace = false;
  30036. var stdFontMap = getStdFontMap();
  30037. var lookupName = stdFontMap[name] || name;
  30038. var Metrics = getMetrics();
  30039. if (!(lookupName in Metrics)) {
  30040. if (this.isSerifFont(name)) {
  30041. lookupName = 'Times-Roman';
  30042. } else {
  30043. lookupName = 'Helvetica';
  30044. }
  30045. }
  30046. var glyphWidths = Metrics[lookupName];
  30047. if (isNum(glyphWidths)) {
  30048. defaultWidth = glyphWidths;
  30049. monospace = true;
  30050. } else {
  30051. widths = glyphWidths();
  30052. }
  30053. return {
  30054. defaultWidth: defaultWidth,
  30055. monospace: monospace,
  30056. widths: widths
  30057. };
  30058. },
  30059. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30060. var widths = Object.create(null);
  30061. var differences = properties.differences;
  30062. var encoding = properties.defaultEncoding;
  30063. for (var charCode = 0; charCode < 256; charCode++) {
  30064. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30065. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30066. continue;
  30067. }
  30068. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30069. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30070. continue;
  30071. }
  30072. }
  30073. return widths;
  30074. },
  30075. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30076. var baseDict = dict;
  30077. var type = dict.get('Subtype');
  30078. assert(isName(type), 'invalid font Subtype');
  30079. var composite = false;
  30080. var uint8array;
  30081. if (type.name === 'Type0') {
  30082. var df = dict.get('DescendantFonts');
  30083. if (!df) {
  30084. error('Descendant fonts are not specified');
  30085. }
  30086. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30087. type = dict.get('Subtype');
  30088. assert(isName(type), 'invalid font Subtype');
  30089. composite = true;
  30090. }
  30091. var descriptor = dict.get('FontDescriptor');
  30092. if (descriptor) {
  30093. var hash = new MurmurHash3_64();
  30094. var encoding = baseDict.getRaw('Encoding');
  30095. if (isName(encoding)) {
  30096. hash.update(encoding.name);
  30097. } else if (isRef(encoding)) {
  30098. hash.update(encoding.toString());
  30099. } else if (isDict(encoding)) {
  30100. var keys = encoding.getKeys();
  30101. for (var i = 0, ii = keys.length; i < ii; i++) {
  30102. var entry = encoding.getRaw(keys[i]);
  30103. if (isName(entry)) {
  30104. hash.update(entry.name);
  30105. } else if (isRef(entry)) {
  30106. hash.update(entry.toString());
  30107. } else if (isArray(entry)) {
  30108. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30109. for (var j = 0; j < diffLength; j++) {
  30110. var diffEntry = entry[j];
  30111. if (isName(diffEntry)) {
  30112. diffBuf[j] = diffEntry.name;
  30113. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30114. diffBuf[j] = diffEntry.toString();
  30115. }
  30116. }
  30117. hash.update(diffBuf.join());
  30118. }
  30119. }
  30120. }
  30121. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30122. if (isStream(toUnicode)) {
  30123. var stream = toUnicode.str || toUnicode;
  30124. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30125. hash.update(uint8array);
  30126. } else if (isName(toUnicode)) {
  30127. hash.update(toUnicode.name);
  30128. }
  30129. var widths = dict.get('Widths') || baseDict.get('Widths');
  30130. if (widths) {
  30131. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30132. hash.update(uint8array);
  30133. }
  30134. }
  30135. return {
  30136. descriptor: descriptor,
  30137. dict: dict,
  30138. baseDict: baseDict,
  30139. composite: composite,
  30140. type: type.name,
  30141. hash: hash ? hash.hexdigest() : ''
  30142. };
  30143. },
  30144. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30145. var baseDict = preEvaluatedFont.baseDict;
  30146. var dict = preEvaluatedFont.dict;
  30147. var composite = preEvaluatedFont.composite;
  30148. var descriptor = preEvaluatedFont.descriptor;
  30149. var type = preEvaluatedFont.type;
  30150. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30151. var properties;
  30152. if (!descriptor) {
  30153. if (type === 'Type3') {
  30154. descriptor = new Dict(null);
  30155. descriptor.set('FontName', Name.get(type));
  30156. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30157. } else {
  30158. var baseFontName = dict.get('BaseFont');
  30159. if (!isName(baseFontName)) {
  30160. error('Base font is not specified');
  30161. }
  30162. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30163. var metrics = this.getBaseFontMetrics(baseFontName);
  30164. var fontNameWoStyle = baseFontName.split('-')[0];
  30165. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30166. properties = {
  30167. type: type,
  30168. name: baseFontName,
  30169. widths: metrics.widths,
  30170. defaultWidth: metrics.defaultWidth,
  30171. flags: flags,
  30172. firstChar: 0,
  30173. lastChar: maxCharIndex
  30174. };
  30175. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30176. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30177. return new Font(baseFontName, null, properties);
  30178. }.bind(this));
  30179. }
  30180. }
  30181. var firstChar = dict.get('FirstChar') || 0;
  30182. var lastChar = dict.get('LastChar') || maxCharIndex;
  30183. var fontName = descriptor.get('FontName');
  30184. var baseFont = dict.get('BaseFont');
  30185. if (isString(fontName)) {
  30186. fontName = Name.get(fontName);
  30187. }
  30188. if (isString(baseFont)) {
  30189. baseFont = Name.get(baseFont);
  30190. }
  30191. if (type !== 'Type3') {
  30192. var fontNameStr = fontName && fontName.name;
  30193. var baseFontStr = baseFont && baseFont.name;
  30194. if (fontNameStr !== baseFontStr) {
  30195. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30196. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30197. fontName = baseFont;
  30198. }
  30199. }
  30200. }
  30201. fontName = fontName || baseFont;
  30202. assert(isName(fontName), 'invalid font name');
  30203. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30204. if (fontFile) {
  30205. if (fontFile.dict) {
  30206. var subtype = fontFile.dict.get('Subtype');
  30207. if (subtype) {
  30208. subtype = subtype.name;
  30209. }
  30210. var length1 = fontFile.dict.get('Length1');
  30211. var length2 = fontFile.dict.get('Length2');
  30212. var length3 = fontFile.dict.get('Length3');
  30213. }
  30214. }
  30215. properties = {
  30216. type: type,
  30217. name: fontName.name,
  30218. subtype: subtype,
  30219. file: fontFile,
  30220. length1: length1,
  30221. length2: length2,
  30222. length3: length3,
  30223. loadedName: baseDict.loadedName,
  30224. composite: composite,
  30225. wideChars: composite,
  30226. fixedPitch: false,
  30227. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30228. firstChar: firstChar || 0,
  30229. lastChar: lastChar || maxCharIndex,
  30230. bbox: descriptor.getArray('FontBBox'),
  30231. ascent: descriptor.get('Ascent'),
  30232. descent: descriptor.get('Descent'),
  30233. xHeight: descriptor.get('XHeight'),
  30234. capHeight: descriptor.get('CapHeight'),
  30235. flags: descriptor.get('Flags'),
  30236. italicAngle: descriptor.get('ItalicAngle'),
  30237. coded: false
  30238. };
  30239. var cMapPromise;
  30240. if (composite) {
  30241. var cidEncoding = baseDict.get('Encoding');
  30242. if (isName(cidEncoding)) {
  30243. properties.cidEncoding = cidEncoding.name;
  30244. }
  30245. cMapPromise = CMapFactory.create({
  30246. encoding: cidEncoding,
  30247. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30248. useCMap: null
  30249. }).then(function (cMap) {
  30250. properties.cMap = cMap;
  30251. properties.vertical = properties.cMap.vertical;
  30252. });
  30253. } else {
  30254. cMapPromise = Promise.resolve(undefined);
  30255. }
  30256. return cMapPromise.then(function () {
  30257. return this.extractDataStructures(dict, baseDict, xref, properties);
  30258. }.bind(this)).then(function (properties) {
  30259. this.extractWidths(dict, xref, descriptor, properties);
  30260. if (type === 'Type3') {
  30261. properties.isType3Font = true;
  30262. }
  30263. return new Font(fontName.name, fontFile, properties);
  30264. }.bind(this));
  30265. }
  30266. };
  30267. return PartialEvaluator;
  30268. }();
  30269. var TranslatedFont = function TranslatedFontClosure() {
  30270. function TranslatedFont(loadedName, font, dict) {
  30271. this.loadedName = loadedName;
  30272. this.font = font;
  30273. this.dict = dict;
  30274. this.type3Loaded = null;
  30275. this.sent = false;
  30276. }
  30277. TranslatedFont.prototype = {
  30278. send: function (handler) {
  30279. if (this.sent) {
  30280. return;
  30281. }
  30282. var fontData = this.font.exportData();
  30283. handler.send('commonobj', [
  30284. this.loadedName,
  30285. 'Font',
  30286. fontData
  30287. ]);
  30288. this.sent = true;
  30289. },
  30290. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  30291. assert(this.font.isType3Font);
  30292. if (this.type3Loaded) {
  30293. return this.type3Loaded;
  30294. }
  30295. var translatedFont = this.font;
  30296. var loadCharProcsPromise = Promise.resolve();
  30297. var charProcs = this.dict.get('CharProcs');
  30298. var fontResources = this.dict.get('Resources') || resources;
  30299. var charProcKeys = charProcs.getKeys();
  30300. var charProcOperatorList = Object.create(null);
  30301. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  30302. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  30303. var glyphStream = charProcs.get(key);
  30304. var operatorList = new OperatorList();
  30305. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  30306. charProcOperatorList[key] = operatorList.getIR();
  30307. parentOperatorList.addDependencies(operatorList.dependencies);
  30308. }, function (reason) {
  30309. warn('Type3 font resource \"' + key + '\" is not available');
  30310. var operatorList = new OperatorList();
  30311. charProcOperatorList[key] = operatorList.getIR();
  30312. });
  30313. }.bind(this, charProcKeys[i]));
  30314. }
  30315. this.type3Loaded = loadCharProcsPromise.then(function () {
  30316. translatedFont.charProcOperatorList = charProcOperatorList;
  30317. });
  30318. return this.type3Loaded;
  30319. }
  30320. };
  30321. return TranslatedFont;
  30322. }();
  30323. var OperatorList = function OperatorListClosure() {
  30324. var CHUNK_SIZE = 1000;
  30325. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  30326. function getTransfers(queue) {
  30327. var transfers = [];
  30328. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  30329. for (var i = 0, ii = queue.length; i < ii; i++) {
  30330. switch (fnArray[i]) {
  30331. case OPS.paintInlineImageXObject:
  30332. case OPS.paintInlineImageXObjectGroup:
  30333. case OPS.paintImageMaskXObject:
  30334. var arg = argsArray[i][0];
  30335. if (!arg.cached) {
  30336. transfers.push(arg.data.buffer);
  30337. }
  30338. break;
  30339. }
  30340. }
  30341. return transfers;
  30342. }
  30343. function OperatorList(intent, messageHandler, pageIndex) {
  30344. this.messageHandler = messageHandler;
  30345. this.fnArray = [];
  30346. this.argsArray = [];
  30347. this.dependencies = Object.create(null);
  30348. this._totalLength = 0;
  30349. this.pageIndex = pageIndex;
  30350. this.intent = intent;
  30351. }
  30352. OperatorList.prototype = {
  30353. get length() {
  30354. return this.argsArray.length;
  30355. },
  30356. get totalLength() {
  30357. return this._totalLength + this.length;
  30358. },
  30359. addOp: function (fn, args) {
  30360. this.fnArray.push(fn);
  30361. this.argsArray.push(args);
  30362. if (this.messageHandler) {
  30363. if (this.fnArray.length >= CHUNK_SIZE) {
  30364. this.flush();
  30365. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  30366. this.flush();
  30367. }
  30368. }
  30369. },
  30370. addDependency: function (dependency) {
  30371. if (dependency in this.dependencies) {
  30372. return;
  30373. }
  30374. this.dependencies[dependency] = true;
  30375. this.addOp(OPS.dependency, [dependency]);
  30376. },
  30377. addDependencies: function (dependencies) {
  30378. for (var key in dependencies) {
  30379. this.addDependency(key);
  30380. }
  30381. },
  30382. addOpList: function (opList) {
  30383. Util.extendObj(this.dependencies, opList.dependencies);
  30384. for (var i = 0, ii = opList.length; i < ii; i++) {
  30385. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  30386. }
  30387. },
  30388. getIR: function () {
  30389. return {
  30390. fnArray: this.fnArray,
  30391. argsArray: this.argsArray,
  30392. length: this.length
  30393. };
  30394. },
  30395. flush: function (lastChunk) {
  30396. if (this.intent !== 'oplist') {
  30397. new QueueOptimizer().optimize(this);
  30398. }
  30399. var transfers = getTransfers(this);
  30400. var length = this.length;
  30401. this._totalLength += length;
  30402. this.messageHandler.send('RenderPageChunk', {
  30403. operatorList: {
  30404. fnArray: this.fnArray,
  30405. argsArray: this.argsArray,
  30406. lastChunk: lastChunk,
  30407. length: length
  30408. },
  30409. pageIndex: this.pageIndex,
  30410. intent: this.intent
  30411. }, transfers);
  30412. this.dependencies = Object.create(null);
  30413. this.fnArray.length = 0;
  30414. this.argsArray.length = 0;
  30415. }
  30416. };
  30417. return OperatorList;
  30418. }();
  30419. var StateManager = function StateManagerClosure() {
  30420. function StateManager(initialState) {
  30421. this.state = initialState;
  30422. this.stateStack = [];
  30423. }
  30424. StateManager.prototype = {
  30425. save: function () {
  30426. var old = this.state;
  30427. this.stateStack.push(this.state);
  30428. this.state = old.clone();
  30429. },
  30430. restore: function () {
  30431. var prev = this.stateStack.pop();
  30432. if (prev) {
  30433. this.state = prev;
  30434. }
  30435. },
  30436. transform: function (args) {
  30437. this.state.ctm = Util.transform(this.state.ctm, args);
  30438. }
  30439. };
  30440. return StateManager;
  30441. }();
  30442. var TextState = function TextStateClosure() {
  30443. function TextState() {
  30444. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30445. this.fontName = null;
  30446. this.fontSize = 0;
  30447. this.font = null;
  30448. this.fontMatrix = FONT_IDENTITY_MATRIX;
  30449. this.textMatrix = IDENTITY_MATRIX.slice();
  30450. this.textLineMatrix = IDENTITY_MATRIX.slice();
  30451. this.charSpacing = 0;
  30452. this.wordSpacing = 0;
  30453. this.leading = 0;
  30454. this.textHScale = 1;
  30455. this.textRise = 0;
  30456. }
  30457. TextState.prototype = {
  30458. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30459. var m = this.textMatrix;
  30460. m[0] = a;
  30461. m[1] = b;
  30462. m[2] = c;
  30463. m[3] = d;
  30464. m[4] = e;
  30465. m[5] = f;
  30466. },
  30467. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30468. var m = this.textLineMatrix;
  30469. m[0] = a;
  30470. m[1] = b;
  30471. m[2] = c;
  30472. m[3] = d;
  30473. m[4] = e;
  30474. m[5] = f;
  30475. },
  30476. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  30477. var m = this.textMatrix;
  30478. m[4] = m[0] * x + m[2] * y + m[4];
  30479. m[5] = m[1] * x + m[3] * y + m[5];
  30480. },
  30481. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  30482. var m = this.textLineMatrix;
  30483. m[4] = m[0] * x + m[2] * y + m[4];
  30484. m[5] = m[1] * x + m[3] * y + m[5];
  30485. },
  30486. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  30487. var font = this.font;
  30488. if (!font) {
  30489. return null;
  30490. }
  30491. var m = this.textLineMatrix;
  30492. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  30493. return null;
  30494. }
  30495. var txDiff = e - m[4], tyDiff = f - m[5];
  30496. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  30497. return null;
  30498. }
  30499. var tx, ty, denominator = a * d - b * c;
  30500. if (font.vertical) {
  30501. tx = -tyDiff * c / denominator;
  30502. ty = tyDiff * a / denominator;
  30503. } else {
  30504. tx = txDiff * d / denominator;
  30505. ty = -txDiff * b / denominator;
  30506. }
  30507. return {
  30508. width: tx,
  30509. height: ty,
  30510. value: font.vertical ? ty : tx
  30511. };
  30512. },
  30513. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  30514. var tsm = [
  30515. this.fontSize * this.textHScale,
  30516. 0,
  30517. 0,
  30518. this.fontSize,
  30519. 0,
  30520. this.textRise
  30521. ];
  30522. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  30523. },
  30524. carriageReturn: function TextState_carriageReturn() {
  30525. this.translateTextLineMatrix(0, -this.leading);
  30526. this.textMatrix = this.textLineMatrix.slice();
  30527. },
  30528. clone: function TextState_clone() {
  30529. var clone = Object.create(this);
  30530. clone.textMatrix = this.textMatrix.slice();
  30531. clone.textLineMatrix = this.textLineMatrix.slice();
  30532. clone.fontMatrix = this.fontMatrix.slice();
  30533. return clone;
  30534. }
  30535. };
  30536. return TextState;
  30537. }();
  30538. var EvalState = function EvalStateClosure() {
  30539. function EvalState() {
  30540. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30541. this.font = null;
  30542. this.textRenderingMode = TextRenderingMode.FILL;
  30543. this.fillColorSpace = ColorSpace.singletons.gray;
  30544. this.strokeColorSpace = ColorSpace.singletons.gray;
  30545. }
  30546. EvalState.prototype = {
  30547. clone: function CanvasExtraState_clone() {
  30548. return Object.create(this);
  30549. }
  30550. };
  30551. return EvalState;
  30552. }();
  30553. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  30554. var getOPMap = getLookupTableFactory(function (t) {
  30555. t['w'] = {
  30556. id: OPS.setLineWidth,
  30557. numArgs: 1,
  30558. variableArgs: false
  30559. };
  30560. t['J'] = {
  30561. id: OPS.setLineCap,
  30562. numArgs: 1,
  30563. variableArgs: false
  30564. };
  30565. t['j'] = {
  30566. id: OPS.setLineJoin,
  30567. numArgs: 1,
  30568. variableArgs: false
  30569. };
  30570. t['M'] = {
  30571. id: OPS.setMiterLimit,
  30572. numArgs: 1,
  30573. variableArgs: false
  30574. };
  30575. t['d'] = {
  30576. id: OPS.setDash,
  30577. numArgs: 2,
  30578. variableArgs: false
  30579. };
  30580. t['ri'] = {
  30581. id: OPS.setRenderingIntent,
  30582. numArgs: 1,
  30583. variableArgs: false
  30584. };
  30585. t['i'] = {
  30586. id: OPS.setFlatness,
  30587. numArgs: 1,
  30588. variableArgs: false
  30589. };
  30590. t['gs'] = {
  30591. id: OPS.setGState,
  30592. numArgs: 1,
  30593. variableArgs: false
  30594. };
  30595. t['q'] = {
  30596. id: OPS.save,
  30597. numArgs: 0,
  30598. variableArgs: false
  30599. };
  30600. t['Q'] = {
  30601. id: OPS.restore,
  30602. numArgs: 0,
  30603. variableArgs: false
  30604. };
  30605. t['cm'] = {
  30606. id: OPS.transform,
  30607. numArgs: 6,
  30608. variableArgs: false
  30609. };
  30610. t['m'] = {
  30611. id: OPS.moveTo,
  30612. numArgs: 2,
  30613. variableArgs: false
  30614. };
  30615. t['l'] = {
  30616. id: OPS.lineTo,
  30617. numArgs: 2,
  30618. variableArgs: false
  30619. };
  30620. t['c'] = {
  30621. id: OPS.curveTo,
  30622. numArgs: 6,
  30623. variableArgs: false
  30624. };
  30625. t['v'] = {
  30626. id: OPS.curveTo2,
  30627. numArgs: 4,
  30628. variableArgs: false
  30629. };
  30630. t['y'] = {
  30631. id: OPS.curveTo3,
  30632. numArgs: 4,
  30633. variableArgs: false
  30634. };
  30635. t['h'] = {
  30636. id: OPS.closePath,
  30637. numArgs: 0,
  30638. variableArgs: false
  30639. };
  30640. t['re'] = {
  30641. id: OPS.rectangle,
  30642. numArgs: 4,
  30643. variableArgs: false
  30644. };
  30645. t['S'] = {
  30646. id: OPS.stroke,
  30647. numArgs: 0,
  30648. variableArgs: false
  30649. };
  30650. t['s'] = {
  30651. id: OPS.closeStroke,
  30652. numArgs: 0,
  30653. variableArgs: false
  30654. };
  30655. t['f'] = {
  30656. id: OPS.fill,
  30657. numArgs: 0,
  30658. variableArgs: false
  30659. };
  30660. t['F'] = {
  30661. id: OPS.fill,
  30662. numArgs: 0,
  30663. variableArgs: false
  30664. };
  30665. t['f*'] = {
  30666. id: OPS.eoFill,
  30667. numArgs: 0,
  30668. variableArgs: false
  30669. };
  30670. t['B'] = {
  30671. id: OPS.fillStroke,
  30672. numArgs: 0,
  30673. variableArgs: false
  30674. };
  30675. t['B*'] = {
  30676. id: OPS.eoFillStroke,
  30677. numArgs: 0,
  30678. variableArgs: false
  30679. };
  30680. t['b'] = {
  30681. id: OPS.closeFillStroke,
  30682. numArgs: 0,
  30683. variableArgs: false
  30684. };
  30685. t['b*'] = {
  30686. id: OPS.closeEOFillStroke,
  30687. numArgs: 0,
  30688. variableArgs: false
  30689. };
  30690. t['n'] = {
  30691. id: OPS.endPath,
  30692. numArgs: 0,
  30693. variableArgs: false
  30694. };
  30695. t['W'] = {
  30696. id: OPS.clip,
  30697. numArgs: 0,
  30698. variableArgs: false
  30699. };
  30700. t['W*'] = {
  30701. id: OPS.eoClip,
  30702. numArgs: 0,
  30703. variableArgs: false
  30704. };
  30705. t['BT'] = {
  30706. id: OPS.beginText,
  30707. numArgs: 0,
  30708. variableArgs: false
  30709. };
  30710. t['ET'] = {
  30711. id: OPS.endText,
  30712. numArgs: 0,
  30713. variableArgs: false
  30714. };
  30715. t['Tc'] = {
  30716. id: OPS.setCharSpacing,
  30717. numArgs: 1,
  30718. variableArgs: false
  30719. };
  30720. t['Tw'] = {
  30721. id: OPS.setWordSpacing,
  30722. numArgs: 1,
  30723. variableArgs: false
  30724. };
  30725. t['Tz'] = {
  30726. id: OPS.setHScale,
  30727. numArgs: 1,
  30728. variableArgs: false
  30729. };
  30730. t['TL'] = {
  30731. id: OPS.setLeading,
  30732. numArgs: 1,
  30733. variableArgs: false
  30734. };
  30735. t['Tf'] = {
  30736. id: OPS.setFont,
  30737. numArgs: 2,
  30738. variableArgs: false
  30739. };
  30740. t['Tr'] = {
  30741. id: OPS.setTextRenderingMode,
  30742. numArgs: 1,
  30743. variableArgs: false
  30744. };
  30745. t['Ts'] = {
  30746. id: OPS.setTextRise,
  30747. numArgs: 1,
  30748. variableArgs: false
  30749. };
  30750. t['Td'] = {
  30751. id: OPS.moveText,
  30752. numArgs: 2,
  30753. variableArgs: false
  30754. };
  30755. t['TD'] = {
  30756. id: OPS.setLeadingMoveText,
  30757. numArgs: 2,
  30758. variableArgs: false
  30759. };
  30760. t['Tm'] = {
  30761. id: OPS.setTextMatrix,
  30762. numArgs: 6,
  30763. variableArgs: false
  30764. };
  30765. t['T*'] = {
  30766. id: OPS.nextLine,
  30767. numArgs: 0,
  30768. variableArgs: false
  30769. };
  30770. t['Tj'] = {
  30771. id: OPS.showText,
  30772. numArgs: 1,
  30773. variableArgs: false
  30774. };
  30775. t['TJ'] = {
  30776. id: OPS.showSpacedText,
  30777. numArgs: 1,
  30778. variableArgs: false
  30779. };
  30780. t['\''] = {
  30781. id: OPS.nextLineShowText,
  30782. numArgs: 1,
  30783. variableArgs: false
  30784. };
  30785. t['"'] = {
  30786. id: OPS.nextLineSetSpacingShowText,
  30787. numArgs: 3,
  30788. variableArgs: false
  30789. };
  30790. t['d0'] = {
  30791. id: OPS.setCharWidth,
  30792. numArgs: 2,
  30793. variableArgs: false
  30794. };
  30795. t['d1'] = {
  30796. id: OPS.setCharWidthAndBounds,
  30797. numArgs: 6,
  30798. variableArgs: false
  30799. };
  30800. t['CS'] = {
  30801. id: OPS.setStrokeColorSpace,
  30802. numArgs: 1,
  30803. variableArgs: false
  30804. };
  30805. t['cs'] = {
  30806. id: OPS.setFillColorSpace,
  30807. numArgs: 1,
  30808. variableArgs: false
  30809. };
  30810. t['SC'] = {
  30811. id: OPS.setStrokeColor,
  30812. numArgs: 4,
  30813. variableArgs: true
  30814. };
  30815. t['SCN'] = {
  30816. id: OPS.setStrokeColorN,
  30817. numArgs: 33,
  30818. variableArgs: true
  30819. };
  30820. t['sc'] = {
  30821. id: OPS.setFillColor,
  30822. numArgs: 4,
  30823. variableArgs: true
  30824. };
  30825. t['scn'] = {
  30826. id: OPS.setFillColorN,
  30827. numArgs: 33,
  30828. variableArgs: true
  30829. };
  30830. t['G'] = {
  30831. id: OPS.setStrokeGray,
  30832. numArgs: 1,
  30833. variableArgs: false
  30834. };
  30835. t['g'] = {
  30836. id: OPS.setFillGray,
  30837. numArgs: 1,
  30838. variableArgs: false
  30839. };
  30840. t['RG'] = {
  30841. id: OPS.setStrokeRGBColor,
  30842. numArgs: 3,
  30843. variableArgs: false
  30844. };
  30845. t['rg'] = {
  30846. id: OPS.setFillRGBColor,
  30847. numArgs: 3,
  30848. variableArgs: false
  30849. };
  30850. t['K'] = {
  30851. id: OPS.setStrokeCMYKColor,
  30852. numArgs: 4,
  30853. variableArgs: false
  30854. };
  30855. t['k'] = {
  30856. id: OPS.setFillCMYKColor,
  30857. numArgs: 4,
  30858. variableArgs: false
  30859. };
  30860. t['sh'] = {
  30861. id: OPS.shadingFill,
  30862. numArgs: 1,
  30863. variableArgs: false
  30864. };
  30865. t['BI'] = {
  30866. id: OPS.beginInlineImage,
  30867. numArgs: 0,
  30868. variableArgs: false
  30869. };
  30870. t['ID'] = {
  30871. id: OPS.beginImageData,
  30872. numArgs: 0,
  30873. variableArgs: false
  30874. };
  30875. t['EI'] = {
  30876. id: OPS.endInlineImage,
  30877. numArgs: 1,
  30878. variableArgs: false
  30879. };
  30880. t['Do'] = {
  30881. id: OPS.paintXObject,
  30882. numArgs: 1,
  30883. variableArgs: false
  30884. };
  30885. t['MP'] = {
  30886. id: OPS.markPoint,
  30887. numArgs: 1,
  30888. variableArgs: false
  30889. };
  30890. t['DP'] = {
  30891. id: OPS.markPointProps,
  30892. numArgs: 2,
  30893. variableArgs: false
  30894. };
  30895. t['BMC'] = {
  30896. id: OPS.beginMarkedContent,
  30897. numArgs: 1,
  30898. variableArgs: false
  30899. };
  30900. t['BDC'] = {
  30901. id: OPS.beginMarkedContentProps,
  30902. numArgs: 2,
  30903. variableArgs: false
  30904. };
  30905. t['EMC'] = {
  30906. id: OPS.endMarkedContent,
  30907. numArgs: 0,
  30908. variableArgs: false
  30909. };
  30910. t['BX'] = {
  30911. id: OPS.beginCompat,
  30912. numArgs: 0,
  30913. variableArgs: false
  30914. };
  30915. t['EX'] = {
  30916. id: OPS.endCompat,
  30917. numArgs: 0,
  30918. variableArgs: false
  30919. };
  30920. t['BM'] = null;
  30921. t['BD'] = null;
  30922. t['true'] = null;
  30923. t['fa'] = null;
  30924. t['fal'] = null;
  30925. t['fals'] = null;
  30926. t['false'] = null;
  30927. t['nu'] = null;
  30928. t['nul'] = null;
  30929. t['null'] = null;
  30930. });
  30931. function EvaluatorPreprocessor(stream, xref, stateManager) {
  30932. this.opMap = getOPMap();
  30933. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  30934. this.stateManager = stateManager;
  30935. this.nonProcessedArgs = [];
  30936. }
  30937. EvaluatorPreprocessor.prototype = {
  30938. get savedStatesDepth() {
  30939. return this.stateManager.stateStack.length;
  30940. },
  30941. read: function EvaluatorPreprocessor_read(operation) {
  30942. var args = operation.args;
  30943. while (true) {
  30944. var obj = this.parser.getObj();
  30945. if (isCmd(obj)) {
  30946. var cmd = obj.cmd;
  30947. var opSpec = this.opMap[cmd];
  30948. if (!opSpec) {
  30949. warn('Unknown command "' + cmd + '"');
  30950. continue;
  30951. }
  30952. var fn = opSpec.id;
  30953. var numArgs = opSpec.numArgs;
  30954. var argsLength = args !== null ? args.length : 0;
  30955. if (!opSpec.variableArgs) {
  30956. if (argsLength !== numArgs) {
  30957. var nonProcessedArgs = this.nonProcessedArgs;
  30958. while (argsLength > numArgs) {
  30959. nonProcessedArgs.push(args.shift());
  30960. argsLength--;
  30961. }
  30962. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  30963. if (args === null) {
  30964. args = [];
  30965. }
  30966. args.unshift(nonProcessedArgs.pop());
  30967. argsLength++;
  30968. }
  30969. }
  30970. if (argsLength < numArgs) {
  30971. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  30972. if (args !== null) {
  30973. args.length = 0;
  30974. }
  30975. continue;
  30976. }
  30977. } else if (argsLength > numArgs) {
  30978. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  30979. }
  30980. this.preprocessCommand(fn, args);
  30981. operation.fn = fn;
  30982. operation.args = args;
  30983. return true;
  30984. }
  30985. if (isEOF(obj)) {
  30986. return false;
  30987. }
  30988. if (obj !== null) {
  30989. if (args === null) {
  30990. args = [];
  30991. }
  30992. args.push(obj);
  30993. assert(args.length <= 33, 'Too many arguments');
  30994. }
  30995. }
  30996. },
  30997. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  30998. switch (fn | 0) {
  30999. case OPS.save:
  31000. this.stateManager.save();
  31001. break;
  31002. case OPS.restore:
  31003. this.stateManager.restore();
  31004. break;
  31005. case OPS.transform:
  31006. this.stateManager.transform(args);
  31007. break;
  31008. }
  31009. }
  31010. };
  31011. return EvaluatorPreprocessor;
  31012. }();
  31013. var QueueOptimizer = function QueueOptimizerClosure() {
  31014. function addState(parentState, pattern, fn) {
  31015. var state = parentState;
  31016. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31017. var item = pattern[i];
  31018. state = state[item] || (state[item] = []);
  31019. }
  31020. state[pattern[pattern.length - 1]] = fn;
  31021. }
  31022. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31023. var iFirstPIMXO = iFirstSave + 2;
  31024. for (var i = 0; i < count; i++) {
  31025. var arg = argsArray[iFirstPIMXO + 4 * i];
  31026. var imageMask = arg.length === 1 && arg[0];
  31027. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31028. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31029. continue;
  31030. }
  31031. break;
  31032. }
  31033. return count - i;
  31034. }
  31035. var InitialState = [];
  31036. addState(InitialState, [
  31037. OPS.save,
  31038. OPS.transform,
  31039. OPS.paintInlineImageXObject,
  31040. OPS.restore
  31041. ], function foundInlineImageGroup(context) {
  31042. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31043. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31044. var MAX_WIDTH = 1000;
  31045. var IMAGE_PADDING = 1;
  31046. var fnArray = context.fnArray, argsArray = context.argsArray;
  31047. var curr = context.iCurr;
  31048. var iFirstSave = curr - 3;
  31049. var iFirstTransform = curr - 2;
  31050. var iFirstPIIXO = curr - 1;
  31051. var i = iFirstSave + 4;
  31052. var ii = fnArray.length;
  31053. while (i + 3 < ii) {
  31054. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31055. break;
  31056. }
  31057. i += 4;
  31058. }
  31059. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31060. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31061. return i;
  31062. }
  31063. var maxX = 0;
  31064. var map = [], maxLineHeight = 0;
  31065. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31066. var q;
  31067. for (q = 0; q < count; q++) {
  31068. var transform = argsArray[iFirstTransform + (q << 2)];
  31069. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31070. if (currentX + img.width > MAX_WIDTH) {
  31071. maxX = Math.max(maxX, currentX);
  31072. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31073. currentX = 0;
  31074. maxLineHeight = 0;
  31075. }
  31076. map.push({
  31077. transform: transform,
  31078. x: currentX,
  31079. y: currentY,
  31080. w: img.width,
  31081. h: img.height
  31082. });
  31083. currentX += img.width + 2 * IMAGE_PADDING;
  31084. maxLineHeight = Math.max(maxLineHeight, img.height);
  31085. }
  31086. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31087. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31088. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31089. var imgRowSize = imgWidth << 2;
  31090. for (q = 0; q < count; q++) {
  31091. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31092. var rowSize = map[q].w << 2;
  31093. var dataOffset = 0;
  31094. var offset = map[q].x + map[q].y * imgWidth << 2;
  31095. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31096. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31097. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31098. dataOffset += rowSize;
  31099. offset += imgRowSize;
  31100. }
  31101. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31102. while (offset >= 0) {
  31103. data[offset - 4] = data[offset];
  31104. data[offset - 3] = data[offset + 1];
  31105. data[offset - 2] = data[offset + 2];
  31106. data[offset - 1] = data[offset + 3];
  31107. data[offset + rowSize] = data[offset + rowSize - 4];
  31108. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31109. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31110. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31111. offset -= imgRowSize;
  31112. }
  31113. }
  31114. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31115. argsArray.splice(iFirstSave, count * 4, [
  31116. {
  31117. width: imgWidth,
  31118. height: imgHeight,
  31119. kind: ImageKind.RGBA_32BPP,
  31120. data: imgData
  31121. },
  31122. map
  31123. ]);
  31124. return iFirstSave + 1;
  31125. });
  31126. addState(InitialState, [
  31127. OPS.save,
  31128. OPS.transform,
  31129. OPS.paintImageMaskXObject,
  31130. OPS.restore
  31131. ], function foundImageMaskGroup(context) {
  31132. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31133. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31134. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31135. var fnArray = context.fnArray, argsArray = context.argsArray;
  31136. var curr = context.iCurr;
  31137. var iFirstSave = curr - 3;
  31138. var iFirstTransform = curr - 2;
  31139. var iFirstPIMXO = curr - 1;
  31140. var i = iFirstSave + 4;
  31141. var ii = fnArray.length;
  31142. while (i + 3 < ii) {
  31143. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31144. break;
  31145. }
  31146. i += 4;
  31147. }
  31148. var count = (i - iFirstSave) / 4;
  31149. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31150. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31151. return i;
  31152. }
  31153. var q;
  31154. var isSameImage = false;
  31155. var iTransform, transformArgs;
  31156. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31157. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31158. isSameImage = true;
  31159. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31160. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31161. iTransform = iFirstTransform + 4;
  31162. var iPIMXO = iFirstPIMXO + 4;
  31163. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31164. transformArgs = argsArray[iTransform];
  31165. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31166. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31167. isSameImage = false;
  31168. } else {
  31169. count = q;
  31170. }
  31171. break;
  31172. }
  31173. }
  31174. }
  31175. if (isSameImage) {
  31176. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31177. var positions = new Float32Array(count * 2);
  31178. iTransform = iFirstTransform;
  31179. for (q = 0; q < count; q++, iTransform += 4) {
  31180. transformArgs = argsArray[iTransform];
  31181. positions[q << 1] = transformArgs[4];
  31182. positions[(q << 1) + 1] = transformArgs[5];
  31183. }
  31184. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31185. argsArray.splice(iFirstSave, count * 4, [
  31186. firstPIMXOArg0,
  31187. firstTransformArg0,
  31188. firstTransformArg3,
  31189. positions
  31190. ]);
  31191. } else {
  31192. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31193. var images = [];
  31194. for (q = 0; q < count; q++) {
  31195. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31196. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31197. images.push({
  31198. data: maskParams.data,
  31199. width: maskParams.width,
  31200. height: maskParams.height,
  31201. transform: transformArgs
  31202. });
  31203. }
  31204. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31205. argsArray.splice(iFirstSave, count * 4, [images]);
  31206. }
  31207. return iFirstSave + 1;
  31208. });
  31209. addState(InitialState, [
  31210. OPS.save,
  31211. OPS.transform,
  31212. OPS.paintImageXObject,
  31213. OPS.restore
  31214. ], function (context) {
  31215. var MIN_IMAGES_IN_BLOCK = 3;
  31216. var MAX_IMAGES_IN_BLOCK = 1000;
  31217. var fnArray = context.fnArray, argsArray = context.argsArray;
  31218. var curr = context.iCurr;
  31219. var iFirstSave = curr - 3;
  31220. var iFirstTransform = curr - 2;
  31221. var iFirstPIXO = curr - 1;
  31222. var iFirstRestore = curr;
  31223. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31224. return iFirstRestore + 1;
  31225. }
  31226. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31227. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31228. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31229. var i = iFirstSave + 4;
  31230. var ii = fnArray.length;
  31231. while (i + 3 < ii) {
  31232. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31233. break;
  31234. }
  31235. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31236. break;
  31237. }
  31238. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31239. break;
  31240. }
  31241. i += 4;
  31242. }
  31243. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31244. if (count < MIN_IMAGES_IN_BLOCK) {
  31245. return i;
  31246. }
  31247. var positions = new Float32Array(count * 2);
  31248. var iTransform = iFirstTransform;
  31249. for (var q = 0; q < count; q++, iTransform += 4) {
  31250. var transformArgs = argsArray[iTransform];
  31251. positions[q << 1] = transformArgs[4];
  31252. positions[(q << 1) + 1] = transformArgs[5];
  31253. }
  31254. var args = [
  31255. firstPIXOArg0,
  31256. firstTransformArg0,
  31257. firstTransformArg3,
  31258. positions
  31259. ];
  31260. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31261. argsArray.splice(iFirstSave, count * 4, args);
  31262. return iFirstSave + 1;
  31263. });
  31264. addState(InitialState, [
  31265. OPS.beginText,
  31266. OPS.setFont,
  31267. OPS.setTextMatrix,
  31268. OPS.showText,
  31269. OPS.endText
  31270. ], function (context) {
  31271. var MIN_CHARS_IN_BLOCK = 3;
  31272. var MAX_CHARS_IN_BLOCK = 1000;
  31273. var fnArray = context.fnArray, argsArray = context.argsArray;
  31274. var curr = context.iCurr;
  31275. var iFirstBeginText = curr - 4;
  31276. var iFirstSetFont = curr - 3;
  31277. var iFirstSetTextMatrix = curr - 2;
  31278. var iFirstShowText = curr - 1;
  31279. var iFirstEndText = curr;
  31280. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  31281. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  31282. var i = iFirstBeginText + 5;
  31283. var ii = fnArray.length;
  31284. while (i + 4 < ii) {
  31285. 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) {
  31286. break;
  31287. }
  31288. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  31289. break;
  31290. }
  31291. i += 5;
  31292. }
  31293. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  31294. if (count < MIN_CHARS_IN_BLOCK) {
  31295. return i;
  31296. }
  31297. var iFirst = iFirstBeginText;
  31298. 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) {
  31299. count++;
  31300. iFirst -= 5;
  31301. }
  31302. var iEndText = iFirst + 4;
  31303. for (var q = 1; q < count; q++) {
  31304. fnArray.splice(iEndText, 3);
  31305. argsArray.splice(iEndText, 3);
  31306. iEndText += 2;
  31307. }
  31308. return iEndText + 1;
  31309. });
  31310. function QueueOptimizer() {
  31311. }
  31312. QueueOptimizer.prototype = {
  31313. optimize: function QueueOptimizer_optimize(queue) {
  31314. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31315. var context = {
  31316. iCurr: 0,
  31317. fnArray: fnArray,
  31318. argsArray: argsArray
  31319. };
  31320. var state;
  31321. var i = 0, ii = fnArray.length;
  31322. while (i < ii) {
  31323. state = (state || InitialState)[fnArray[i]];
  31324. if (typeof state === 'function') {
  31325. context.iCurr = i;
  31326. i = state(context);
  31327. state = undefined;
  31328. ii = context.fnArray.length;
  31329. } else {
  31330. i++;
  31331. }
  31332. }
  31333. }
  31334. };
  31335. return QueueOptimizer;
  31336. }();
  31337. exports.OperatorList = OperatorList;
  31338. exports.PartialEvaluator = PartialEvaluator;
  31339. /***/ }),
  31340. /* 19 */
  31341. /***/ (function(module, exports, __w_pdfjs_require__) {
  31342. "use strict";
  31343. var sharedUtil = __w_pdfjs_require__(0);
  31344. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  31345. var info = sharedUtil.info;
  31346. var warn = sharedUtil.warn;
  31347. var error = sharedUtil.error;
  31348. var log2 = sharedUtil.log2;
  31349. var readUint16 = sharedUtil.readUint16;
  31350. var readUint32 = sharedUtil.readUint32;
  31351. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  31352. var JpxImage = function JpxImageClosure() {
  31353. var SubbandsGainLog2 = {
  31354. 'LL': 0,
  31355. 'LH': 1,
  31356. 'HL': 1,
  31357. 'HH': 2
  31358. };
  31359. function JpxImage() {
  31360. this.failOnCorruptedImage = false;
  31361. }
  31362. JpxImage.prototype = {
  31363. parse: function JpxImage_parse(data) {
  31364. var head = readUint16(data, 0);
  31365. if (head === 0xFF4F) {
  31366. this.parseCodestream(data, 0, data.length);
  31367. return;
  31368. }
  31369. var position = 0, length = data.length;
  31370. while (position < length) {
  31371. var headerSize = 8;
  31372. var lbox = readUint32(data, position);
  31373. var tbox = readUint32(data, position + 4);
  31374. position += headerSize;
  31375. if (lbox === 1) {
  31376. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  31377. position += 8;
  31378. headerSize += 8;
  31379. }
  31380. if (lbox === 0) {
  31381. lbox = length - position + headerSize;
  31382. }
  31383. if (lbox < headerSize) {
  31384. error('JPX Error: Invalid box field size');
  31385. }
  31386. var dataLength = lbox - headerSize;
  31387. var jumpDataLength = true;
  31388. switch (tbox) {
  31389. case 0x6A703268:
  31390. jumpDataLength = false;
  31391. break;
  31392. case 0x636F6C72:
  31393. var method = data[position];
  31394. if (method === 1) {
  31395. var colorspace = readUint32(data, position + 3);
  31396. switch (colorspace) {
  31397. case 16:
  31398. case 17:
  31399. case 18:
  31400. break;
  31401. default:
  31402. warn('Unknown colorspace ' + colorspace);
  31403. break;
  31404. }
  31405. } else if (method === 2) {
  31406. info('ICC profile not supported');
  31407. }
  31408. break;
  31409. case 0x6A703263:
  31410. this.parseCodestream(data, position, position + dataLength);
  31411. break;
  31412. case 0x6A502020:
  31413. if (0x0d0a870a !== readUint32(data, position)) {
  31414. warn('Invalid JP2 signature');
  31415. }
  31416. break;
  31417. case 0x6A501A1A:
  31418. case 0x66747970:
  31419. case 0x72726571:
  31420. case 0x72657320:
  31421. case 0x69686472:
  31422. break;
  31423. default:
  31424. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  31425. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  31426. break;
  31427. }
  31428. if (jumpDataLength) {
  31429. position += dataLength;
  31430. }
  31431. }
  31432. },
  31433. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  31434. var newByte = stream.getByte();
  31435. while (newByte >= 0) {
  31436. var oldByte = newByte;
  31437. newByte = stream.getByte();
  31438. var code = oldByte << 8 | newByte;
  31439. if (code === 0xFF51) {
  31440. stream.skip(4);
  31441. var Xsiz = stream.getInt32() >>> 0;
  31442. var Ysiz = stream.getInt32() >>> 0;
  31443. var XOsiz = stream.getInt32() >>> 0;
  31444. var YOsiz = stream.getInt32() >>> 0;
  31445. stream.skip(16);
  31446. var Csiz = stream.getUint16();
  31447. this.width = Xsiz - XOsiz;
  31448. this.height = Ysiz - YOsiz;
  31449. this.componentsCount = Csiz;
  31450. this.bitsPerComponent = 8;
  31451. return;
  31452. }
  31453. }
  31454. error('JPX Error: No size marker found in JPX stream');
  31455. },
  31456. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  31457. var context = {};
  31458. var doNotRecover = false;
  31459. try {
  31460. var position = start;
  31461. while (position + 1 < end) {
  31462. var code = readUint16(data, position);
  31463. position += 2;
  31464. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  31465. switch (code) {
  31466. case 0xFF4F:
  31467. context.mainHeader = true;
  31468. break;
  31469. case 0xFFD9:
  31470. break;
  31471. case 0xFF51:
  31472. length = readUint16(data, position);
  31473. var siz = {};
  31474. siz.Xsiz = readUint32(data, position + 4);
  31475. siz.Ysiz = readUint32(data, position + 8);
  31476. siz.XOsiz = readUint32(data, position + 12);
  31477. siz.YOsiz = readUint32(data, position + 16);
  31478. siz.XTsiz = readUint32(data, position + 20);
  31479. siz.YTsiz = readUint32(data, position + 24);
  31480. siz.XTOsiz = readUint32(data, position + 28);
  31481. siz.YTOsiz = readUint32(data, position + 32);
  31482. var componentsCount = readUint16(data, position + 36);
  31483. siz.Csiz = componentsCount;
  31484. var components = [];
  31485. j = position + 38;
  31486. for (var i = 0; i < componentsCount; i++) {
  31487. var component = {
  31488. precision: (data[j] & 0x7F) + 1,
  31489. isSigned: !!(data[j] & 0x80),
  31490. XRsiz: data[j + 1],
  31491. YRsiz: data[j + 1]
  31492. };
  31493. calculateComponentDimensions(component, siz);
  31494. components.push(component);
  31495. }
  31496. context.SIZ = siz;
  31497. context.components = components;
  31498. calculateTileGrids(context, components);
  31499. context.QCC = [];
  31500. context.COC = [];
  31501. break;
  31502. case 0xFF5C:
  31503. length = readUint16(data, position);
  31504. var qcd = {};
  31505. j = position + 2;
  31506. sqcd = data[j++];
  31507. switch (sqcd & 0x1F) {
  31508. case 0:
  31509. spqcdSize = 8;
  31510. scalarExpounded = true;
  31511. break;
  31512. case 1:
  31513. spqcdSize = 16;
  31514. scalarExpounded = false;
  31515. break;
  31516. case 2:
  31517. spqcdSize = 16;
  31518. scalarExpounded = true;
  31519. break;
  31520. default:
  31521. throw new Error('Invalid SQcd value ' + sqcd);
  31522. }
  31523. qcd.noQuantization = spqcdSize === 8;
  31524. qcd.scalarExpounded = scalarExpounded;
  31525. qcd.guardBits = sqcd >> 5;
  31526. spqcds = [];
  31527. while (j < length + position) {
  31528. var spqcd = {};
  31529. if (spqcdSize === 8) {
  31530. spqcd.epsilon = data[j++] >> 3;
  31531. spqcd.mu = 0;
  31532. } else {
  31533. spqcd.epsilon = data[j] >> 3;
  31534. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31535. j += 2;
  31536. }
  31537. spqcds.push(spqcd);
  31538. }
  31539. qcd.SPqcds = spqcds;
  31540. if (context.mainHeader) {
  31541. context.QCD = qcd;
  31542. } else {
  31543. context.currentTile.QCD = qcd;
  31544. context.currentTile.QCC = [];
  31545. }
  31546. break;
  31547. case 0xFF5D:
  31548. length = readUint16(data, position);
  31549. var qcc = {};
  31550. j = position + 2;
  31551. var cqcc;
  31552. if (context.SIZ.Csiz < 257) {
  31553. cqcc = data[j++];
  31554. } else {
  31555. cqcc = readUint16(data, j);
  31556. j += 2;
  31557. }
  31558. sqcd = data[j++];
  31559. switch (sqcd & 0x1F) {
  31560. case 0:
  31561. spqcdSize = 8;
  31562. scalarExpounded = true;
  31563. break;
  31564. case 1:
  31565. spqcdSize = 16;
  31566. scalarExpounded = false;
  31567. break;
  31568. case 2:
  31569. spqcdSize = 16;
  31570. scalarExpounded = true;
  31571. break;
  31572. default:
  31573. throw new Error('Invalid SQcd value ' + sqcd);
  31574. }
  31575. qcc.noQuantization = spqcdSize === 8;
  31576. qcc.scalarExpounded = scalarExpounded;
  31577. qcc.guardBits = sqcd >> 5;
  31578. spqcds = [];
  31579. while (j < length + position) {
  31580. spqcd = {};
  31581. if (spqcdSize === 8) {
  31582. spqcd.epsilon = data[j++] >> 3;
  31583. spqcd.mu = 0;
  31584. } else {
  31585. spqcd.epsilon = data[j] >> 3;
  31586. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31587. j += 2;
  31588. }
  31589. spqcds.push(spqcd);
  31590. }
  31591. qcc.SPqcds = spqcds;
  31592. if (context.mainHeader) {
  31593. context.QCC[cqcc] = qcc;
  31594. } else {
  31595. context.currentTile.QCC[cqcc] = qcc;
  31596. }
  31597. break;
  31598. case 0xFF52:
  31599. length = readUint16(data, position);
  31600. var cod = {};
  31601. j = position + 2;
  31602. var scod = data[j++];
  31603. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  31604. cod.sopMarkerUsed = !!(scod & 2);
  31605. cod.ephMarkerUsed = !!(scod & 4);
  31606. cod.progressionOrder = data[j++];
  31607. cod.layersCount = readUint16(data, j);
  31608. j += 2;
  31609. cod.multipleComponentTransform = data[j++];
  31610. cod.decompositionLevelsCount = data[j++];
  31611. cod.xcb = (data[j++] & 0xF) + 2;
  31612. cod.ycb = (data[j++] & 0xF) + 2;
  31613. var blockStyle = data[j++];
  31614. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  31615. cod.resetContextProbabilities = !!(blockStyle & 2);
  31616. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  31617. cod.verticalyStripe = !!(blockStyle & 8);
  31618. cod.predictableTermination = !!(blockStyle & 16);
  31619. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  31620. cod.reversibleTransformation = data[j++];
  31621. if (cod.entropyCoderWithCustomPrecincts) {
  31622. var precinctsSizes = [];
  31623. while (j < length + position) {
  31624. var precinctsSize = data[j++];
  31625. precinctsSizes.push({
  31626. PPx: precinctsSize & 0xF,
  31627. PPy: precinctsSize >> 4
  31628. });
  31629. }
  31630. cod.precinctsSizes = precinctsSizes;
  31631. }
  31632. var unsupported = [];
  31633. if (cod.selectiveArithmeticCodingBypass) {
  31634. unsupported.push('selectiveArithmeticCodingBypass');
  31635. }
  31636. if (cod.resetContextProbabilities) {
  31637. unsupported.push('resetContextProbabilities');
  31638. }
  31639. if (cod.terminationOnEachCodingPass) {
  31640. unsupported.push('terminationOnEachCodingPass');
  31641. }
  31642. if (cod.verticalyStripe) {
  31643. unsupported.push('verticalyStripe');
  31644. }
  31645. if (cod.predictableTermination) {
  31646. unsupported.push('predictableTermination');
  31647. }
  31648. if (unsupported.length > 0) {
  31649. doNotRecover = true;
  31650. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  31651. }
  31652. if (context.mainHeader) {
  31653. context.COD = cod;
  31654. } else {
  31655. context.currentTile.COD = cod;
  31656. context.currentTile.COC = [];
  31657. }
  31658. break;
  31659. case 0xFF90:
  31660. length = readUint16(data, position);
  31661. tile = {};
  31662. tile.index = readUint16(data, position + 2);
  31663. tile.length = readUint32(data, position + 4);
  31664. tile.dataEnd = tile.length + position - 2;
  31665. tile.partIndex = data[position + 8];
  31666. tile.partsCount = data[position + 9];
  31667. context.mainHeader = false;
  31668. if (tile.partIndex === 0) {
  31669. tile.COD = context.COD;
  31670. tile.COC = context.COC.slice(0);
  31671. tile.QCD = context.QCD;
  31672. tile.QCC = context.QCC.slice(0);
  31673. }
  31674. context.currentTile = tile;
  31675. break;
  31676. case 0xFF93:
  31677. tile = context.currentTile;
  31678. if (tile.partIndex === 0) {
  31679. initializeTile(context, tile.index);
  31680. buildPackets(context);
  31681. }
  31682. length = tile.dataEnd - position;
  31683. parseTilePackets(context, data, position, length);
  31684. break;
  31685. case 0xFF55:
  31686. case 0xFF57:
  31687. case 0xFF58:
  31688. case 0xFF64:
  31689. length = readUint16(data, position);
  31690. break;
  31691. case 0xFF53:
  31692. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  31693. default:
  31694. throw new Error('Unknown codestream code: ' + code.toString(16));
  31695. }
  31696. position += length;
  31697. }
  31698. } catch (e) {
  31699. if (doNotRecover || this.failOnCorruptedImage) {
  31700. error('JPX Error: ' + e.message);
  31701. } else {
  31702. warn('JPX: Trying to recover from: ' + e.message);
  31703. }
  31704. }
  31705. this.tiles = transformComponents(context);
  31706. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  31707. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  31708. this.componentsCount = context.SIZ.Csiz;
  31709. }
  31710. };
  31711. function calculateComponentDimensions(component, siz) {
  31712. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  31713. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  31714. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  31715. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  31716. component.width = component.x1 - component.x0;
  31717. component.height = component.y1 - component.y0;
  31718. }
  31719. function calculateTileGrids(context, components) {
  31720. var siz = context.SIZ;
  31721. var tile, tiles = [];
  31722. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  31723. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  31724. for (var q = 0; q < numYtiles; q++) {
  31725. for (var p = 0; p < numXtiles; p++) {
  31726. tile = {};
  31727. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  31728. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  31729. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  31730. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  31731. tile.width = tile.tx1 - tile.tx0;
  31732. tile.height = tile.ty1 - tile.ty0;
  31733. tile.components = [];
  31734. tiles.push(tile);
  31735. }
  31736. }
  31737. context.tiles = tiles;
  31738. var componentsCount = siz.Csiz;
  31739. for (var i = 0, ii = componentsCount; i < ii; i++) {
  31740. var component = components[i];
  31741. for (var j = 0, jj = tiles.length; j < jj; j++) {
  31742. var tileComponent = {};
  31743. tile = tiles[j];
  31744. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  31745. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  31746. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  31747. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  31748. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  31749. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  31750. tile.components[i] = tileComponent;
  31751. }
  31752. }
  31753. }
  31754. function getBlocksDimensions(context, component, r) {
  31755. var codOrCoc = component.codingStyleParameters;
  31756. var result = {};
  31757. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  31758. result.PPx = 15;
  31759. result.PPy = 15;
  31760. } else {
  31761. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  31762. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  31763. }
  31764. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  31765. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  31766. return result;
  31767. }
  31768. function buildPrecincts(context, resolution, dimensions) {
  31769. var precinctWidth = 1 << dimensions.PPx;
  31770. var precinctHeight = 1 << dimensions.PPy;
  31771. var isZeroRes = resolution.resLevel === 0;
  31772. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  31773. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  31774. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  31775. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  31776. var numprecincts = numprecinctswide * numprecinctshigh;
  31777. resolution.precinctParameters = {
  31778. precinctWidth: precinctWidth,
  31779. precinctHeight: precinctHeight,
  31780. numprecinctswide: numprecinctswide,
  31781. numprecinctshigh: numprecinctshigh,
  31782. numprecincts: numprecincts,
  31783. precinctWidthInSubband: precinctWidthInSubband,
  31784. precinctHeightInSubband: precinctHeightInSubband
  31785. };
  31786. }
  31787. function buildCodeblocks(context, subband, dimensions) {
  31788. var xcb_ = dimensions.xcb_;
  31789. var ycb_ = dimensions.ycb_;
  31790. var codeblockWidth = 1 << xcb_;
  31791. var codeblockHeight = 1 << ycb_;
  31792. var cbx0 = subband.tbx0 >> xcb_;
  31793. var cby0 = subband.tby0 >> ycb_;
  31794. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  31795. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  31796. var precinctParameters = subband.resolution.precinctParameters;
  31797. var codeblocks = [];
  31798. var precincts = [];
  31799. var i, j, codeblock, precinctNumber;
  31800. for (j = cby0; j < cby1; j++) {
  31801. for (i = cbx0; i < cbx1; i++) {
  31802. codeblock = {
  31803. cbx: i,
  31804. cby: j,
  31805. tbx0: codeblockWidth * i,
  31806. tby0: codeblockHeight * j,
  31807. tbx1: codeblockWidth * (i + 1),
  31808. tby1: codeblockHeight * (j + 1)
  31809. };
  31810. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  31811. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  31812. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  31813. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  31814. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  31815. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  31816. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  31817. codeblock.precinctNumber = precinctNumber;
  31818. codeblock.subbandType = subband.type;
  31819. codeblock.Lblock = 3;
  31820. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  31821. continue;
  31822. }
  31823. codeblocks.push(codeblock);
  31824. var precinct = precincts[precinctNumber];
  31825. if (precinct !== undefined) {
  31826. if (i < precinct.cbxMin) {
  31827. precinct.cbxMin = i;
  31828. } else if (i > precinct.cbxMax) {
  31829. precinct.cbxMax = i;
  31830. }
  31831. if (j < precinct.cbyMin) {
  31832. precinct.cbxMin = j;
  31833. } else if (j > precinct.cbyMax) {
  31834. precinct.cbyMax = j;
  31835. }
  31836. } else {
  31837. precincts[precinctNumber] = precinct = {
  31838. cbxMin: i,
  31839. cbyMin: j,
  31840. cbxMax: i,
  31841. cbyMax: j
  31842. };
  31843. }
  31844. codeblock.precinct = precinct;
  31845. }
  31846. }
  31847. subband.codeblockParameters = {
  31848. codeblockWidth: xcb_,
  31849. codeblockHeight: ycb_,
  31850. numcodeblockwide: cbx1 - cbx0 + 1,
  31851. numcodeblockhigh: cby1 - cby0 + 1
  31852. };
  31853. subband.codeblocks = codeblocks;
  31854. subband.precincts = precincts;
  31855. }
  31856. function createPacket(resolution, precinctNumber, layerNumber) {
  31857. var precinctCodeblocks = [];
  31858. var subbands = resolution.subbands;
  31859. for (var i = 0, ii = subbands.length; i < ii; i++) {
  31860. var subband = subbands[i];
  31861. var codeblocks = subband.codeblocks;
  31862. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  31863. var codeblock = codeblocks[j];
  31864. if (codeblock.precinctNumber !== precinctNumber) {
  31865. continue;
  31866. }
  31867. precinctCodeblocks.push(codeblock);
  31868. }
  31869. }
  31870. return {
  31871. layerNumber: layerNumber,
  31872. codeblocks: precinctCodeblocks
  31873. };
  31874. }
  31875. function LayerResolutionComponentPositionIterator(context) {
  31876. var siz = context.SIZ;
  31877. var tileIndex = context.currentTile.index;
  31878. var tile = context.tiles[tileIndex];
  31879. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31880. var componentsCount = siz.Csiz;
  31881. var maxDecompositionLevelsCount = 0;
  31882. for (var q = 0; q < componentsCount; q++) {
  31883. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31884. }
  31885. var l = 0, r = 0, i = 0, k = 0;
  31886. this.nextPacket = function JpxImage_nextPacket() {
  31887. for (; l < layersCount; l++) {
  31888. for (; r <= maxDecompositionLevelsCount; r++) {
  31889. for (; i < componentsCount; i++) {
  31890. var component = tile.components[i];
  31891. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31892. continue;
  31893. }
  31894. var resolution = component.resolutions[r];
  31895. var numprecincts = resolution.precinctParameters.numprecincts;
  31896. for (; k < numprecincts;) {
  31897. var packet = createPacket(resolution, k, l);
  31898. k++;
  31899. return packet;
  31900. }
  31901. k = 0;
  31902. }
  31903. i = 0;
  31904. }
  31905. r = 0;
  31906. }
  31907. error('JPX Error: Out of packets');
  31908. };
  31909. }
  31910. function ResolutionLayerComponentPositionIterator(context) {
  31911. var siz = context.SIZ;
  31912. var tileIndex = context.currentTile.index;
  31913. var tile = context.tiles[tileIndex];
  31914. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31915. var componentsCount = siz.Csiz;
  31916. var maxDecompositionLevelsCount = 0;
  31917. for (var q = 0; q < componentsCount; q++) {
  31918. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31919. }
  31920. var r = 0, l = 0, i = 0, k = 0;
  31921. this.nextPacket = function JpxImage_nextPacket() {
  31922. for (; r <= maxDecompositionLevelsCount; r++) {
  31923. for (; l < layersCount; l++) {
  31924. for (; i < componentsCount; i++) {
  31925. var component = tile.components[i];
  31926. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31927. continue;
  31928. }
  31929. var resolution = component.resolutions[r];
  31930. var numprecincts = resolution.precinctParameters.numprecincts;
  31931. for (; k < numprecincts;) {
  31932. var packet = createPacket(resolution, k, l);
  31933. k++;
  31934. return packet;
  31935. }
  31936. k = 0;
  31937. }
  31938. i = 0;
  31939. }
  31940. l = 0;
  31941. }
  31942. error('JPX Error: Out of packets');
  31943. };
  31944. }
  31945. function ResolutionPositionComponentLayerIterator(context) {
  31946. var siz = context.SIZ;
  31947. var tileIndex = context.currentTile.index;
  31948. var tile = context.tiles[tileIndex];
  31949. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31950. var componentsCount = siz.Csiz;
  31951. var l, r, c, p;
  31952. var maxDecompositionLevelsCount = 0;
  31953. for (c = 0; c < componentsCount; c++) {
  31954. var component = tile.components[c];
  31955. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  31956. }
  31957. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  31958. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  31959. var maxNumPrecincts = 0;
  31960. for (c = 0; c < componentsCount; ++c) {
  31961. var resolutions = tile.components[c].resolutions;
  31962. if (r < resolutions.length) {
  31963. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  31964. }
  31965. }
  31966. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  31967. }
  31968. l = 0;
  31969. r = 0;
  31970. c = 0;
  31971. p = 0;
  31972. this.nextPacket = function JpxImage_nextPacket() {
  31973. for (; r <= maxDecompositionLevelsCount; r++) {
  31974. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  31975. for (; c < componentsCount; c++) {
  31976. var component = tile.components[c];
  31977. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31978. continue;
  31979. }
  31980. var resolution = component.resolutions[r];
  31981. var numprecincts = resolution.precinctParameters.numprecincts;
  31982. if (p >= numprecincts) {
  31983. continue;
  31984. }
  31985. for (; l < layersCount;) {
  31986. var packet = createPacket(resolution, p, l);
  31987. l++;
  31988. return packet;
  31989. }
  31990. l = 0;
  31991. }
  31992. c = 0;
  31993. }
  31994. p = 0;
  31995. }
  31996. error('JPX Error: Out of packets');
  31997. };
  31998. }
  31999. function PositionComponentResolutionLayerIterator(context) {
  32000. var siz = context.SIZ;
  32001. var tileIndex = context.currentTile.index;
  32002. var tile = context.tiles[tileIndex];
  32003. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32004. var componentsCount = siz.Csiz;
  32005. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32006. var precinctsIterationSizes = precinctsSizes;
  32007. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32008. this.nextPacket = function JpxImage_nextPacket() {
  32009. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32010. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32011. for (; c < componentsCount; c++) {
  32012. var component = tile.components[c];
  32013. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32014. for (; r <= decompositionLevelsCount; r++) {
  32015. var resolution = component.resolutions[r];
  32016. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32017. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32018. if (k === null) {
  32019. continue;
  32020. }
  32021. for (; l < layersCount;) {
  32022. var packet = createPacket(resolution, k, l);
  32023. l++;
  32024. return packet;
  32025. }
  32026. l = 0;
  32027. }
  32028. r = 0;
  32029. }
  32030. c = 0;
  32031. }
  32032. px = 0;
  32033. }
  32034. error('JPX Error: Out of packets');
  32035. };
  32036. }
  32037. function ComponentPositionResolutionLayerIterator(context) {
  32038. var siz = context.SIZ;
  32039. var tileIndex = context.currentTile.index;
  32040. var tile = context.tiles[tileIndex];
  32041. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32042. var componentsCount = siz.Csiz;
  32043. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32044. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32045. this.nextPacket = function JpxImage_nextPacket() {
  32046. for (; c < componentsCount; ++c) {
  32047. var component = tile.components[c];
  32048. var precinctsIterationSizes = precinctsSizes.components[c];
  32049. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32050. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32051. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32052. for (; r <= decompositionLevelsCount; r++) {
  32053. var resolution = component.resolutions[r];
  32054. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32055. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32056. if (k === null) {
  32057. continue;
  32058. }
  32059. for (; l < layersCount;) {
  32060. var packet = createPacket(resolution, k, l);
  32061. l++;
  32062. return packet;
  32063. }
  32064. l = 0;
  32065. }
  32066. r = 0;
  32067. }
  32068. px = 0;
  32069. }
  32070. py = 0;
  32071. }
  32072. error('JPX Error: Out of packets');
  32073. };
  32074. }
  32075. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32076. var posX = pxIndex * precinctIterationSizes.minWidth;
  32077. var posY = pyIndex * precinctIterationSizes.minHeight;
  32078. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32079. return null;
  32080. }
  32081. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32082. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32083. }
  32084. function getPrecinctSizesInImageScale(tile) {
  32085. var componentsCount = tile.components.length;
  32086. var minWidth = Number.MAX_VALUE;
  32087. var minHeight = Number.MAX_VALUE;
  32088. var maxNumWide = 0;
  32089. var maxNumHigh = 0;
  32090. var sizePerComponent = new Array(componentsCount);
  32091. for (var c = 0; c < componentsCount; c++) {
  32092. var component = tile.components[c];
  32093. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32094. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32095. var minWidthCurrentComponent = Number.MAX_VALUE;
  32096. var minHeightCurrentComponent = Number.MAX_VALUE;
  32097. var maxNumWideCurrentComponent = 0;
  32098. var maxNumHighCurrentComponent = 0;
  32099. var scale = 1;
  32100. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32101. var resolution = component.resolutions[r];
  32102. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32103. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32104. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32105. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32106. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32107. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32108. sizePerResolution[r] = {
  32109. width: widthCurrentResolution,
  32110. height: heightCurrentResolution
  32111. };
  32112. scale <<= 1;
  32113. }
  32114. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32115. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32116. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32117. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32118. sizePerComponent[c] = {
  32119. resolutions: sizePerResolution,
  32120. minWidth: minWidthCurrentComponent,
  32121. minHeight: minHeightCurrentComponent,
  32122. maxNumWide: maxNumWideCurrentComponent,
  32123. maxNumHigh: maxNumHighCurrentComponent
  32124. };
  32125. }
  32126. return {
  32127. components: sizePerComponent,
  32128. minWidth: minWidth,
  32129. minHeight: minHeight,
  32130. maxNumWide: maxNumWide,
  32131. maxNumHigh: maxNumHigh
  32132. };
  32133. }
  32134. function buildPackets(context) {
  32135. var siz = context.SIZ;
  32136. var tileIndex = context.currentTile.index;
  32137. var tile = context.tiles[tileIndex];
  32138. var componentsCount = siz.Csiz;
  32139. for (var c = 0; c < componentsCount; c++) {
  32140. var component = tile.components[c];
  32141. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32142. var resolutions = [];
  32143. var subbands = [];
  32144. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32145. var blocksDimensions = getBlocksDimensions(context, component, r);
  32146. var resolution = {};
  32147. var scale = 1 << decompositionLevelsCount - r;
  32148. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32149. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32150. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32151. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32152. resolution.resLevel = r;
  32153. buildPrecincts(context, resolution, blocksDimensions);
  32154. resolutions.push(resolution);
  32155. var subband;
  32156. if (r === 0) {
  32157. subband = {};
  32158. subband.type = 'LL';
  32159. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32160. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32161. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32162. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32163. subband.resolution = resolution;
  32164. buildCodeblocks(context, subband, blocksDimensions);
  32165. subbands.push(subband);
  32166. resolution.subbands = [subband];
  32167. } else {
  32168. var bscale = 1 << decompositionLevelsCount - r + 1;
  32169. var resolutionSubbands = [];
  32170. subband = {};
  32171. subband.type = 'HL';
  32172. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32173. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32174. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32175. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32176. subband.resolution = resolution;
  32177. buildCodeblocks(context, subband, blocksDimensions);
  32178. subbands.push(subband);
  32179. resolutionSubbands.push(subband);
  32180. subband = {};
  32181. subband.type = 'LH';
  32182. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32183. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32184. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32185. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32186. subband.resolution = resolution;
  32187. buildCodeblocks(context, subband, blocksDimensions);
  32188. subbands.push(subband);
  32189. resolutionSubbands.push(subband);
  32190. subband = {};
  32191. subband.type = 'HH';
  32192. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32193. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32194. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32195. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32196. subband.resolution = resolution;
  32197. buildCodeblocks(context, subband, blocksDimensions);
  32198. subbands.push(subband);
  32199. resolutionSubbands.push(subband);
  32200. resolution.subbands = resolutionSubbands;
  32201. }
  32202. }
  32203. component.resolutions = resolutions;
  32204. component.subbands = subbands;
  32205. }
  32206. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32207. switch (progressionOrder) {
  32208. case 0:
  32209. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32210. break;
  32211. case 1:
  32212. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32213. break;
  32214. case 2:
  32215. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32216. break;
  32217. case 3:
  32218. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32219. break;
  32220. case 4:
  32221. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32222. break;
  32223. default:
  32224. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32225. }
  32226. }
  32227. function parseTilePackets(context, data, offset, dataLength) {
  32228. var position = 0;
  32229. var buffer, bufferSize = 0, skipNextBit = false;
  32230. function readBits(count) {
  32231. while (bufferSize < count) {
  32232. var b = data[offset + position];
  32233. position++;
  32234. if (skipNextBit) {
  32235. buffer = buffer << 7 | b;
  32236. bufferSize += 7;
  32237. skipNextBit = false;
  32238. } else {
  32239. buffer = buffer << 8 | b;
  32240. bufferSize += 8;
  32241. }
  32242. if (b === 0xFF) {
  32243. skipNextBit = true;
  32244. }
  32245. }
  32246. bufferSize -= count;
  32247. return buffer >>> bufferSize & (1 << count) - 1;
  32248. }
  32249. function skipMarkerIfEqual(value) {
  32250. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32251. skipBytes(1);
  32252. return true;
  32253. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32254. skipBytes(2);
  32255. return true;
  32256. }
  32257. return false;
  32258. }
  32259. function skipBytes(count) {
  32260. position += count;
  32261. }
  32262. function alignToByte() {
  32263. bufferSize = 0;
  32264. if (skipNextBit) {
  32265. position++;
  32266. skipNextBit = false;
  32267. }
  32268. }
  32269. function readCodingpasses() {
  32270. if (readBits(1) === 0) {
  32271. return 1;
  32272. }
  32273. if (readBits(1) === 0) {
  32274. return 2;
  32275. }
  32276. var value = readBits(2);
  32277. if (value < 3) {
  32278. return value + 3;
  32279. }
  32280. value = readBits(5);
  32281. if (value < 31) {
  32282. return value + 6;
  32283. }
  32284. value = readBits(7);
  32285. return value + 37;
  32286. }
  32287. var tileIndex = context.currentTile.index;
  32288. var tile = context.tiles[tileIndex];
  32289. var sopMarkerUsed = context.COD.sopMarkerUsed;
  32290. var ephMarkerUsed = context.COD.ephMarkerUsed;
  32291. var packetsIterator = tile.packetsIterator;
  32292. while (position < dataLength) {
  32293. alignToByte();
  32294. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  32295. skipBytes(4);
  32296. }
  32297. var packet = packetsIterator.nextPacket();
  32298. if (!readBits(1)) {
  32299. continue;
  32300. }
  32301. var layerNumber = packet.layerNumber;
  32302. var queue = [], codeblock;
  32303. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  32304. codeblock = packet.codeblocks[i];
  32305. var precinct = codeblock.precinct;
  32306. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  32307. var codeblockRow = codeblock.cby - precinct.cbyMin;
  32308. var codeblockIncluded = false;
  32309. var firstTimeInclusion = false;
  32310. var valueReady;
  32311. if (codeblock['included'] !== undefined) {
  32312. codeblockIncluded = !!readBits(1);
  32313. } else {
  32314. precinct = codeblock.precinct;
  32315. var inclusionTree, zeroBitPlanesTree;
  32316. if (precinct['inclusionTree'] !== undefined) {
  32317. inclusionTree = precinct.inclusionTree;
  32318. } else {
  32319. var width = precinct.cbxMax - precinct.cbxMin + 1;
  32320. var height = precinct.cbyMax - precinct.cbyMin + 1;
  32321. inclusionTree = new InclusionTree(width, height, layerNumber);
  32322. zeroBitPlanesTree = new TagTree(width, height);
  32323. precinct.inclusionTree = inclusionTree;
  32324. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  32325. }
  32326. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  32327. while (true) {
  32328. if (readBits(1)) {
  32329. valueReady = !inclusionTree.nextLevel();
  32330. if (valueReady) {
  32331. codeblock.included = true;
  32332. codeblockIncluded = firstTimeInclusion = true;
  32333. break;
  32334. }
  32335. } else {
  32336. inclusionTree.incrementValue(layerNumber);
  32337. break;
  32338. }
  32339. }
  32340. }
  32341. }
  32342. if (!codeblockIncluded) {
  32343. continue;
  32344. }
  32345. if (firstTimeInclusion) {
  32346. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  32347. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  32348. while (true) {
  32349. if (readBits(1)) {
  32350. valueReady = !zeroBitPlanesTree.nextLevel();
  32351. if (valueReady) {
  32352. break;
  32353. }
  32354. } else {
  32355. zeroBitPlanesTree.incrementValue();
  32356. }
  32357. }
  32358. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  32359. }
  32360. var codingpasses = readCodingpasses();
  32361. while (readBits(1)) {
  32362. codeblock.Lblock++;
  32363. }
  32364. var codingpassesLog2 = log2(codingpasses);
  32365. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  32366. var codedDataLength = readBits(bits);
  32367. queue.push({
  32368. codeblock: codeblock,
  32369. codingpasses: codingpasses,
  32370. dataLength: codedDataLength
  32371. });
  32372. }
  32373. alignToByte();
  32374. if (ephMarkerUsed) {
  32375. skipMarkerIfEqual(0x92);
  32376. }
  32377. while (queue.length > 0) {
  32378. var packetItem = queue.shift();
  32379. codeblock = packetItem.codeblock;
  32380. if (codeblock['data'] === undefined) {
  32381. codeblock.data = [];
  32382. }
  32383. codeblock.data.push({
  32384. data: data,
  32385. start: offset + position,
  32386. end: offset + position + packetItem.dataLength,
  32387. codingpasses: packetItem.codingpasses
  32388. });
  32389. position += packetItem.dataLength;
  32390. }
  32391. }
  32392. return position;
  32393. }
  32394. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  32395. var x0 = subband.tbx0;
  32396. var y0 = subband.tby0;
  32397. var width = subband.tbx1 - subband.tbx0;
  32398. var codeblocks = subband.codeblocks;
  32399. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  32400. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  32401. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  32402. var codeblock = codeblocks[i];
  32403. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  32404. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  32405. if (blockWidth === 0 || blockHeight === 0) {
  32406. continue;
  32407. }
  32408. if (codeblock['data'] === undefined) {
  32409. continue;
  32410. }
  32411. var bitModel, currentCodingpassType;
  32412. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  32413. currentCodingpassType = 2;
  32414. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  32415. var j, jj, dataItem;
  32416. for (j = 0, jj = data.length; j < jj; j++) {
  32417. dataItem = data[j];
  32418. totalLength += dataItem.end - dataItem.start;
  32419. codingpasses += dataItem.codingpasses;
  32420. }
  32421. var encodedData = new Uint8Array(totalLength);
  32422. var position = 0;
  32423. for (j = 0, jj = data.length; j < jj; j++) {
  32424. dataItem = data[j];
  32425. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  32426. encodedData.set(chunk, position);
  32427. position += chunk.length;
  32428. }
  32429. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  32430. bitModel.setDecoder(decoder);
  32431. for (j = 0; j < codingpasses; j++) {
  32432. switch (currentCodingpassType) {
  32433. case 0:
  32434. bitModel.runSignificancePropagationPass();
  32435. break;
  32436. case 1:
  32437. bitModel.runMagnitudeRefinementPass();
  32438. break;
  32439. case 2:
  32440. bitModel.runCleanupPass();
  32441. if (segmentationSymbolUsed) {
  32442. bitModel.checkSegmentationSymbol();
  32443. }
  32444. break;
  32445. }
  32446. currentCodingpassType = (currentCodingpassType + 1) % 3;
  32447. }
  32448. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  32449. var sign = bitModel.coefficentsSign;
  32450. var magnitude = bitModel.coefficentsMagnitude;
  32451. var bitsDecoded = bitModel.bitsDecoded;
  32452. var magnitudeCorrection = reversible ? 0 : 0.5;
  32453. var k, n, nb;
  32454. position = 0;
  32455. var interleave = subband.type !== 'LL';
  32456. for (j = 0; j < blockHeight; j++) {
  32457. var row = offset / width | 0;
  32458. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  32459. for (k = 0; k < blockWidth; k++) {
  32460. n = magnitude[position];
  32461. if (n !== 0) {
  32462. n = (n + magnitudeCorrection) * delta;
  32463. if (sign[position] !== 0) {
  32464. n = -n;
  32465. }
  32466. nb = bitsDecoded[position];
  32467. var pos = interleave ? levelOffset + (offset << 1) : offset;
  32468. if (reversible && nb >= mb) {
  32469. coefficients[pos] = n;
  32470. } else {
  32471. coefficients[pos] = n * (1 << mb - nb);
  32472. }
  32473. }
  32474. offset++;
  32475. position++;
  32476. }
  32477. offset += width - blockWidth;
  32478. }
  32479. }
  32480. }
  32481. function transformTile(context, tile, c) {
  32482. var component = tile.components[c];
  32483. var codingStyleParameters = component.codingStyleParameters;
  32484. var quantizationParameters = component.quantizationParameters;
  32485. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  32486. var spqcds = quantizationParameters.SPqcds;
  32487. var scalarExpounded = quantizationParameters.scalarExpounded;
  32488. var guardBits = quantizationParameters.guardBits;
  32489. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  32490. var precision = context.components[c].precision;
  32491. var reversible = codingStyleParameters.reversibleTransformation;
  32492. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  32493. var subbandCoefficients = [];
  32494. var b = 0;
  32495. for (var i = 0; i <= decompositionLevelsCount; i++) {
  32496. var resolution = component.resolutions[i];
  32497. var width = resolution.trx1 - resolution.trx0;
  32498. var height = resolution.try1 - resolution.try0;
  32499. var coefficients = new Float32Array(width * height);
  32500. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  32501. var mu, epsilon;
  32502. if (!scalarExpounded) {
  32503. mu = spqcds[0].mu;
  32504. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  32505. } else {
  32506. mu = spqcds[b].mu;
  32507. epsilon = spqcds[b].epsilon;
  32508. b++;
  32509. }
  32510. var subband = resolution.subbands[j];
  32511. var gainLog2 = SubbandsGainLog2[subband.type];
  32512. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  32513. var mb = guardBits + epsilon - 1;
  32514. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  32515. }
  32516. subbandCoefficients.push({
  32517. width: width,
  32518. height: height,
  32519. items: coefficients
  32520. });
  32521. }
  32522. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  32523. return {
  32524. left: component.tcx0,
  32525. top: component.tcy0,
  32526. width: result.width,
  32527. height: result.height,
  32528. items: result.items
  32529. };
  32530. }
  32531. function transformComponents(context) {
  32532. var siz = context.SIZ;
  32533. var components = context.components;
  32534. var componentsCount = siz.Csiz;
  32535. var resultImages = [];
  32536. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  32537. var tile = context.tiles[i];
  32538. var transformedTiles = [];
  32539. var c;
  32540. for (c = 0; c < componentsCount; c++) {
  32541. transformedTiles[c] = transformTile(context, tile, c);
  32542. }
  32543. var tile0 = transformedTiles[0];
  32544. var out = new Uint8Array(tile0.items.length * componentsCount);
  32545. var result = {
  32546. left: tile0.left,
  32547. top: tile0.top,
  32548. width: tile0.width,
  32549. height: tile0.height,
  32550. items: out
  32551. };
  32552. var shift, offset, max, min, maxK;
  32553. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  32554. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  32555. var fourComponents = componentsCount === 4;
  32556. var y0items = transformedTiles[0].items;
  32557. var y1items = transformedTiles[1].items;
  32558. var y2items = transformedTiles[2].items;
  32559. var y3items = fourComponents ? transformedTiles[3].items : null;
  32560. shift = components[0].precision - 8;
  32561. offset = (128 << shift) + 0.5;
  32562. max = 255 * (1 << shift);
  32563. maxK = max * 0.5;
  32564. min = -maxK;
  32565. var component0 = tile.components[0];
  32566. var alpha01 = componentsCount - 3;
  32567. jj = y0items.length;
  32568. if (!component0.codingStyleParameters.reversibleTransformation) {
  32569. for (j = 0; j < jj; j++, pos += alpha01) {
  32570. y0 = y0items[j] + offset;
  32571. y1 = y1items[j];
  32572. y2 = y2items[j];
  32573. r = y0 + 1.402 * y2;
  32574. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  32575. b = y0 + 1.772 * y1;
  32576. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32577. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32578. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32579. }
  32580. } else {
  32581. for (j = 0; j < jj; j++, pos += alpha01) {
  32582. y0 = y0items[j] + offset;
  32583. y1 = y1items[j];
  32584. y2 = y2items[j];
  32585. g = y0 - (y2 + y1 >> 2);
  32586. r = g + y2;
  32587. b = g + y1;
  32588. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32589. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32590. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32591. }
  32592. }
  32593. if (fourComponents) {
  32594. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  32595. k = y3items[j];
  32596. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  32597. }
  32598. }
  32599. } else {
  32600. for (c = 0; c < componentsCount; c++) {
  32601. var items = transformedTiles[c].items;
  32602. shift = components[c].precision - 8;
  32603. offset = (128 << shift) + 0.5;
  32604. max = 127.5 * (1 << shift);
  32605. min = -max;
  32606. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  32607. val = items[j];
  32608. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  32609. pos += componentsCount;
  32610. }
  32611. }
  32612. }
  32613. resultImages.push(result);
  32614. }
  32615. return resultImages;
  32616. }
  32617. function initializeTile(context, tileIndex) {
  32618. var siz = context.SIZ;
  32619. var componentsCount = siz.Csiz;
  32620. var tile = context.tiles[tileIndex];
  32621. for (var c = 0; c < componentsCount; c++) {
  32622. var component = tile.components[c];
  32623. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  32624. component.quantizationParameters = qcdOrQcc;
  32625. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  32626. component.codingStyleParameters = codOrCoc;
  32627. }
  32628. tile.codingStyleDefaultParameters = context.currentTile.COD;
  32629. }
  32630. var TagTree = function TagTreeClosure() {
  32631. function TagTree(width, height) {
  32632. var levelsLength = log2(Math.max(width, height)) + 1;
  32633. this.levels = [];
  32634. for (var i = 0; i < levelsLength; i++) {
  32635. var level = {
  32636. width: width,
  32637. height: height,
  32638. items: []
  32639. };
  32640. this.levels.push(level);
  32641. width = Math.ceil(width / 2);
  32642. height = Math.ceil(height / 2);
  32643. }
  32644. }
  32645. TagTree.prototype = {
  32646. reset: function TagTree_reset(i, j) {
  32647. var currentLevel = 0, value = 0, level;
  32648. while (currentLevel < this.levels.length) {
  32649. level = this.levels[currentLevel];
  32650. var index = i + j * level.width;
  32651. if (level.items[index] !== undefined) {
  32652. value = level.items[index];
  32653. break;
  32654. }
  32655. level.index = index;
  32656. i >>= 1;
  32657. j >>= 1;
  32658. currentLevel++;
  32659. }
  32660. currentLevel--;
  32661. level = this.levels[currentLevel];
  32662. level.items[level.index] = value;
  32663. this.currentLevel = currentLevel;
  32664. delete this.value;
  32665. },
  32666. incrementValue: function TagTree_incrementValue() {
  32667. var level = this.levels[this.currentLevel];
  32668. level.items[level.index]++;
  32669. },
  32670. nextLevel: function TagTree_nextLevel() {
  32671. var currentLevel = this.currentLevel;
  32672. var level = this.levels[currentLevel];
  32673. var value = level.items[level.index];
  32674. currentLevel--;
  32675. if (currentLevel < 0) {
  32676. this.value = value;
  32677. return false;
  32678. }
  32679. this.currentLevel = currentLevel;
  32680. level = this.levels[currentLevel];
  32681. level.items[level.index] = value;
  32682. return true;
  32683. }
  32684. };
  32685. return TagTree;
  32686. }();
  32687. var InclusionTree = function InclusionTreeClosure() {
  32688. function InclusionTree(width, height, defaultValue) {
  32689. var levelsLength = log2(Math.max(width, height)) + 1;
  32690. this.levels = [];
  32691. for (var i = 0; i < levelsLength; i++) {
  32692. var items = new Uint8Array(width * height);
  32693. for (var j = 0, jj = items.length; j < jj; j++) {
  32694. items[j] = defaultValue;
  32695. }
  32696. var level = {
  32697. width: width,
  32698. height: height,
  32699. items: items
  32700. };
  32701. this.levels.push(level);
  32702. width = Math.ceil(width / 2);
  32703. height = Math.ceil(height / 2);
  32704. }
  32705. }
  32706. InclusionTree.prototype = {
  32707. reset: function InclusionTree_reset(i, j, stopValue) {
  32708. var currentLevel = 0;
  32709. while (currentLevel < this.levels.length) {
  32710. var level = this.levels[currentLevel];
  32711. var index = i + j * level.width;
  32712. level.index = index;
  32713. var value = level.items[index];
  32714. if (value === 0xFF) {
  32715. break;
  32716. }
  32717. if (value > stopValue) {
  32718. this.currentLevel = currentLevel;
  32719. this.propagateValues();
  32720. return false;
  32721. }
  32722. i >>= 1;
  32723. j >>= 1;
  32724. currentLevel++;
  32725. }
  32726. this.currentLevel = currentLevel - 1;
  32727. return true;
  32728. },
  32729. incrementValue: function InclusionTree_incrementValue(stopValue) {
  32730. var level = this.levels[this.currentLevel];
  32731. level.items[level.index] = stopValue + 1;
  32732. this.propagateValues();
  32733. },
  32734. propagateValues: function InclusionTree_propagateValues() {
  32735. var levelIndex = this.currentLevel;
  32736. var level = this.levels[levelIndex];
  32737. var currentValue = level.items[level.index];
  32738. while (--levelIndex >= 0) {
  32739. level = this.levels[levelIndex];
  32740. level.items[level.index] = currentValue;
  32741. }
  32742. },
  32743. nextLevel: function InclusionTree_nextLevel() {
  32744. var currentLevel = this.currentLevel;
  32745. var level = this.levels[currentLevel];
  32746. var value = level.items[level.index];
  32747. level.items[level.index] = 0xFF;
  32748. currentLevel--;
  32749. if (currentLevel < 0) {
  32750. return false;
  32751. }
  32752. this.currentLevel = currentLevel;
  32753. level = this.levels[currentLevel];
  32754. level.items[level.index] = value;
  32755. return true;
  32756. }
  32757. };
  32758. return InclusionTree;
  32759. }();
  32760. var BitModel = function BitModelClosure() {
  32761. var UNIFORM_CONTEXT = 17;
  32762. var RUNLENGTH_CONTEXT = 18;
  32763. var LLAndLHContextsLabel = new Uint8Array([
  32764. 0,
  32765. 5,
  32766. 8,
  32767. 0,
  32768. 3,
  32769. 7,
  32770. 8,
  32771. 0,
  32772. 4,
  32773. 7,
  32774. 8,
  32775. 0,
  32776. 0,
  32777. 0,
  32778. 0,
  32779. 0,
  32780. 1,
  32781. 6,
  32782. 8,
  32783. 0,
  32784. 3,
  32785. 7,
  32786. 8,
  32787. 0,
  32788. 4,
  32789. 7,
  32790. 8,
  32791. 0,
  32792. 0,
  32793. 0,
  32794. 0,
  32795. 0,
  32796. 2,
  32797. 6,
  32798. 8,
  32799. 0,
  32800. 3,
  32801. 7,
  32802. 8,
  32803. 0,
  32804. 4,
  32805. 7,
  32806. 8,
  32807. 0,
  32808. 0,
  32809. 0,
  32810. 0,
  32811. 0,
  32812. 2,
  32813. 6,
  32814. 8,
  32815. 0,
  32816. 3,
  32817. 7,
  32818. 8,
  32819. 0,
  32820. 4,
  32821. 7,
  32822. 8,
  32823. 0,
  32824. 0,
  32825. 0,
  32826. 0,
  32827. 0,
  32828. 2,
  32829. 6,
  32830. 8,
  32831. 0,
  32832. 3,
  32833. 7,
  32834. 8,
  32835. 0,
  32836. 4,
  32837. 7,
  32838. 8
  32839. ]);
  32840. var HLContextLabel = new Uint8Array([
  32841. 0,
  32842. 3,
  32843. 4,
  32844. 0,
  32845. 5,
  32846. 7,
  32847. 7,
  32848. 0,
  32849. 8,
  32850. 8,
  32851. 8,
  32852. 0,
  32853. 0,
  32854. 0,
  32855. 0,
  32856. 0,
  32857. 1,
  32858. 3,
  32859. 4,
  32860. 0,
  32861. 6,
  32862. 7,
  32863. 7,
  32864. 0,
  32865. 8,
  32866. 8,
  32867. 8,
  32868. 0,
  32869. 0,
  32870. 0,
  32871. 0,
  32872. 0,
  32873. 2,
  32874. 3,
  32875. 4,
  32876. 0,
  32877. 6,
  32878. 7,
  32879. 7,
  32880. 0,
  32881. 8,
  32882. 8,
  32883. 8,
  32884. 0,
  32885. 0,
  32886. 0,
  32887. 0,
  32888. 0,
  32889. 2,
  32890. 3,
  32891. 4,
  32892. 0,
  32893. 6,
  32894. 7,
  32895. 7,
  32896. 0,
  32897. 8,
  32898. 8,
  32899. 8,
  32900. 0,
  32901. 0,
  32902. 0,
  32903. 0,
  32904. 0,
  32905. 2,
  32906. 3,
  32907. 4,
  32908. 0,
  32909. 6,
  32910. 7,
  32911. 7,
  32912. 0,
  32913. 8,
  32914. 8,
  32915. 8
  32916. ]);
  32917. var HHContextLabel = new Uint8Array([
  32918. 0,
  32919. 1,
  32920. 2,
  32921. 0,
  32922. 1,
  32923. 2,
  32924. 2,
  32925. 0,
  32926. 2,
  32927. 2,
  32928. 2,
  32929. 0,
  32930. 0,
  32931. 0,
  32932. 0,
  32933. 0,
  32934. 3,
  32935. 4,
  32936. 5,
  32937. 0,
  32938. 4,
  32939. 5,
  32940. 5,
  32941. 0,
  32942. 5,
  32943. 5,
  32944. 5,
  32945. 0,
  32946. 0,
  32947. 0,
  32948. 0,
  32949. 0,
  32950. 6,
  32951. 7,
  32952. 7,
  32953. 0,
  32954. 7,
  32955. 7,
  32956. 7,
  32957. 0,
  32958. 7,
  32959. 7,
  32960. 7,
  32961. 0,
  32962. 0,
  32963. 0,
  32964. 0,
  32965. 0,
  32966. 8,
  32967. 8,
  32968. 8,
  32969. 0,
  32970. 8,
  32971. 8,
  32972. 8,
  32973. 0,
  32974. 8,
  32975. 8,
  32976. 8,
  32977. 0,
  32978. 0,
  32979. 0,
  32980. 0,
  32981. 0,
  32982. 8,
  32983. 8,
  32984. 8,
  32985. 0,
  32986. 8,
  32987. 8,
  32988. 8,
  32989. 0,
  32990. 8,
  32991. 8,
  32992. 8
  32993. ]);
  32994. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  32995. this.width = width;
  32996. this.height = height;
  32997. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  32998. var coefficientCount = width * height;
  32999. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33000. this.coefficentsSign = new Uint8Array(coefficientCount);
  33001. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33002. this.processingFlags = new Uint8Array(coefficientCount);
  33003. var bitsDecoded = new Uint8Array(coefficientCount);
  33004. if (zeroBitPlanes !== 0) {
  33005. for (var i = 0; i < coefficientCount; i++) {
  33006. bitsDecoded[i] = zeroBitPlanes;
  33007. }
  33008. }
  33009. this.bitsDecoded = bitsDecoded;
  33010. this.reset();
  33011. }
  33012. BitModel.prototype = {
  33013. setDecoder: function BitModel_setDecoder(decoder) {
  33014. this.decoder = decoder;
  33015. },
  33016. reset: function BitModel_reset() {
  33017. this.contexts = new Int8Array(19);
  33018. this.contexts[0] = 4 << 1 | 0;
  33019. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33020. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33021. },
  33022. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33023. var neighborsSignificance = this.neighborsSignificance;
  33024. var width = this.width, height = this.height;
  33025. var left = column > 0;
  33026. var right = column + 1 < width;
  33027. var i;
  33028. if (row > 0) {
  33029. i = index - width;
  33030. if (left) {
  33031. neighborsSignificance[i - 1] += 0x10;
  33032. }
  33033. if (right) {
  33034. neighborsSignificance[i + 1] += 0x10;
  33035. }
  33036. neighborsSignificance[i] += 0x04;
  33037. }
  33038. if (row + 1 < height) {
  33039. i = index + width;
  33040. if (left) {
  33041. neighborsSignificance[i - 1] += 0x10;
  33042. }
  33043. if (right) {
  33044. neighborsSignificance[i + 1] += 0x10;
  33045. }
  33046. neighborsSignificance[i] += 0x04;
  33047. }
  33048. if (left) {
  33049. neighborsSignificance[index - 1] += 0x01;
  33050. }
  33051. if (right) {
  33052. neighborsSignificance[index + 1] += 0x01;
  33053. }
  33054. neighborsSignificance[index] |= 0x80;
  33055. },
  33056. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33057. var decoder = this.decoder;
  33058. var width = this.width, height = this.height;
  33059. var coefficentsMagnitude = this.coefficentsMagnitude;
  33060. var coefficentsSign = this.coefficentsSign;
  33061. var neighborsSignificance = this.neighborsSignificance;
  33062. var processingFlags = this.processingFlags;
  33063. var contexts = this.contexts;
  33064. var labels = this.contextLabelTable;
  33065. var bitsDecoded = this.bitsDecoded;
  33066. var processedInverseMask = ~1;
  33067. var processedMask = 1;
  33068. var firstMagnitudeBitMask = 2;
  33069. for (var i0 = 0; i0 < height; i0 += 4) {
  33070. for (var j = 0; j < width; j++) {
  33071. var index = i0 * width + j;
  33072. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33073. var i = i0 + i1;
  33074. if (i >= height) {
  33075. break;
  33076. }
  33077. processingFlags[index] &= processedInverseMask;
  33078. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33079. continue;
  33080. }
  33081. var contextLabel = labels[neighborsSignificance[index]];
  33082. var decision = decoder.readBit(contexts, contextLabel);
  33083. if (decision) {
  33084. var sign = this.decodeSignBit(i, j, index);
  33085. coefficentsSign[index] = sign;
  33086. coefficentsMagnitude[index] = 1;
  33087. this.setNeighborsSignificance(i, j, index);
  33088. processingFlags[index] |= firstMagnitudeBitMask;
  33089. }
  33090. bitsDecoded[index]++;
  33091. processingFlags[index] |= processedMask;
  33092. }
  33093. }
  33094. }
  33095. },
  33096. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33097. var width = this.width, height = this.height;
  33098. var coefficentsMagnitude = this.coefficentsMagnitude;
  33099. var coefficentsSign = this.coefficentsSign;
  33100. var contribution, sign0, sign1, significance1;
  33101. var contextLabel, decoded;
  33102. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33103. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33104. sign1 = coefficentsSign[index + 1];
  33105. if (significance1) {
  33106. sign0 = coefficentsSign[index - 1];
  33107. contribution = 1 - sign1 - sign0;
  33108. } else {
  33109. contribution = 1 - sign1 - sign1;
  33110. }
  33111. } else if (significance1) {
  33112. sign0 = coefficentsSign[index - 1];
  33113. contribution = 1 - sign0 - sign0;
  33114. } else {
  33115. contribution = 0;
  33116. }
  33117. var horizontalContribution = 3 * contribution;
  33118. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33119. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33120. sign1 = coefficentsSign[index + width];
  33121. if (significance1) {
  33122. sign0 = coefficentsSign[index - width];
  33123. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33124. } else {
  33125. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33126. }
  33127. } else if (significance1) {
  33128. sign0 = coefficentsSign[index - width];
  33129. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33130. } else {
  33131. contribution = horizontalContribution;
  33132. }
  33133. if (contribution >= 0) {
  33134. contextLabel = 9 + contribution;
  33135. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33136. } else {
  33137. contextLabel = 9 - contribution;
  33138. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33139. }
  33140. return decoded;
  33141. },
  33142. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33143. var decoder = this.decoder;
  33144. var width = this.width, height = this.height;
  33145. var coefficentsMagnitude = this.coefficentsMagnitude;
  33146. var neighborsSignificance = this.neighborsSignificance;
  33147. var contexts = this.contexts;
  33148. var bitsDecoded = this.bitsDecoded;
  33149. var processingFlags = this.processingFlags;
  33150. var processedMask = 1;
  33151. var firstMagnitudeBitMask = 2;
  33152. var length = width * height;
  33153. var width4 = width * 4;
  33154. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33155. indexNext = Math.min(length, index0 + width4);
  33156. for (var j = 0; j < width; j++) {
  33157. for (var index = index0 + j; index < indexNext; index += width) {
  33158. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33159. continue;
  33160. }
  33161. var contextLabel = 16;
  33162. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33163. processingFlags[index] ^= firstMagnitudeBitMask;
  33164. var significance = neighborsSignificance[index] & 127;
  33165. contextLabel = significance === 0 ? 15 : 14;
  33166. }
  33167. var bit = decoder.readBit(contexts, contextLabel);
  33168. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33169. bitsDecoded[index]++;
  33170. processingFlags[index] |= processedMask;
  33171. }
  33172. }
  33173. }
  33174. },
  33175. runCleanupPass: function BitModel_runCleanupPass() {
  33176. var decoder = this.decoder;
  33177. var width = this.width, height = this.height;
  33178. var neighborsSignificance = this.neighborsSignificance;
  33179. var coefficentsMagnitude = this.coefficentsMagnitude;
  33180. var coefficentsSign = this.coefficentsSign;
  33181. var contexts = this.contexts;
  33182. var labels = this.contextLabelTable;
  33183. var bitsDecoded = this.bitsDecoded;
  33184. var processingFlags = this.processingFlags;
  33185. var processedMask = 1;
  33186. var firstMagnitudeBitMask = 2;
  33187. var oneRowDown = width;
  33188. var twoRowsDown = width * 2;
  33189. var threeRowsDown = width * 3;
  33190. var iNext;
  33191. for (var i0 = 0; i0 < height; i0 = iNext) {
  33192. iNext = Math.min(i0 + 4, height);
  33193. var indexBase = i0 * width;
  33194. var checkAllEmpty = i0 + 3 < height;
  33195. for (var j = 0; j < width; j++) {
  33196. var index0 = indexBase + j;
  33197. 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;
  33198. var i1 = 0, index = index0;
  33199. var i = i0, sign;
  33200. if (allEmpty) {
  33201. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33202. if (!hasSignificantCoefficent) {
  33203. bitsDecoded[index0]++;
  33204. bitsDecoded[index0 + oneRowDown]++;
  33205. bitsDecoded[index0 + twoRowsDown]++;
  33206. bitsDecoded[index0 + threeRowsDown]++;
  33207. continue;
  33208. }
  33209. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33210. if (i1 !== 0) {
  33211. i = i0 + i1;
  33212. index += i1 * width;
  33213. }
  33214. sign = this.decodeSignBit(i, j, index);
  33215. coefficentsSign[index] = sign;
  33216. coefficentsMagnitude[index] = 1;
  33217. this.setNeighborsSignificance(i, j, index);
  33218. processingFlags[index] |= firstMagnitudeBitMask;
  33219. index = index0;
  33220. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33221. bitsDecoded[index]++;
  33222. }
  33223. i1++;
  33224. }
  33225. for (i = i0 + i1; i < iNext; i++, index += width) {
  33226. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33227. continue;
  33228. }
  33229. var contextLabel = labels[neighborsSignificance[index]];
  33230. var decision = decoder.readBit(contexts, contextLabel);
  33231. if (decision === 1) {
  33232. sign = this.decodeSignBit(i, j, index);
  33233. coefficentsSign[index] = sign;
  33234. coefficentsMagnitude[index] = 1;
  33235. this.setNeighborsSignificance(i, j, index);
  33236. processingFlags[index] |= firstMagnitudeBitMask;
  33237. }
  33238. bitsDecoded[index]++;
  33239. }
  33240. }
  33241. }
  33242. },
  33243. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33244. var decoder = this.decoder;
  33245. var contexts = this.contexts;
  33246. 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);
  33247. if (symbol !== 0xA) {
  33248. error('JPX Error: Invalid segmentation symbol');
  33249. }
  33250. }
  33251. };
  33252. return BitModel;
  33253. }();
  33254. var Transform = function TransformClosure() {
  33255. function Transform() {
  33256. }
  33257. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33258. var ll = subbands[0];
  33259. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33260. ll = this.iterate(ll, subbands[i], u0, v0);
  33261. }
  33262. return ll;
  33263. };
  33264. Transform.prototype.extend = function extend(buffer, offset, size) {
  33265. var i1 = offset - 1, j1 = offset + 1;
  33266. var i2 = offset + size - 2, j2 = offset + size;
  33267. buffer[i1--] = buffer[j1++];
  33268. buffer[j2++] = buffer[i2--];
  33269. buffer[i1--] = buffer[j1++];
  33270. buffer[j2++] = buffer[i2--];
  33271. buffer[i1--] = buffer[j1++];
  33272. buffer[j2++] = buffer[i2--];
  33273. buffer[i1] = buffer[j1];
  33274. buffer[j2] = buffer[i2];
  33275. };
  33276. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  33277. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  33278. var width = hl_lh_hh.width;
  33279. var height = hl_lh_hh.height;
  33280. var items = hl_lh_hh.items;
  33281. var i, j, k, l, u, v;
  33282. for (k = 0, i = 0; i < llHeight; i++) {
  33283. l = i * 2 * width;
  33284. for (j = 0; j < llWidth; j++, k++, l += 2) {
  33285. items[l] = llItems[k];
  33286. }
  33287. }
  33288. llItems = ll.items = null;
  33289. var bufferPadding = 4;
  33290. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  33291. if (width === 1) {
  33292. if ((u0 & 1) !== 0) {
  33293. for (v = 0, k = 0; v < height; v++, k += width) {
  33294. items[k] *= 0.5;
  33295. }
  33296. }
  33297. } else {
  33298. for (v = 0, k = 0; v < height; v++, k += width) {
  33299. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  33300. this.extend(rowBuffer, bufferPadding, width);
  33301. this.filter(rowBuffer, bufferPadding, width);
  33302. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  33303. }
  33304. }
  33305. var numBuffers = 16;
  33306. var colBuffers = [];
  33307. for (i = 0; i < numBuffers; i++) {
  33308. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  33309. }
  33310. var b, currentBuffer = 0;
  33311. ll = bufferPadding + height;
  33312. if (height === 1) {
  33313. if ((v0 & 1) !== 0) {
  33314. for (u = 0; u < width; u++) {
  33315. items[u] *= 0.5;
  33316. }
  33317. }
  33318. } else {
  33319. for (u = 0; u < width; u++) {
  33320. if (currentBuffer === 0) {
  33321. numBuffers = Math.min(width - u, numBuffers);
  33322. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  33323. for (b = 0; b < numBuffers; b++) {
  33324. colBuffers[b][l] = items[k + b];
  33325. }
  33326. }
  33327. currentBuffer = numBuffers;
  33328. }
  33329. currentBuffer--;
  33330. var buffer = colBuffers[currentBuffer];
  33331. this.extend(buffer, bufferPadding, height);
  33332. this.filter(buffer, bufferPadding, height);
  33333. if (currentBuffer === 0) {
  33334. k = u - numBuffers + 1;
  33335. for (l = bufferPadding; l < ll; k += width, l++) {
  33336. for (b = 0; b < numBuffers; b++) {
  33337. items[k + b] = colBuffers[b][l];
  33338. }
  33339. }
  33340. }
  33341. }
  33342. }
  33343. return {
  33344. width: width,
  33345. height: height,
  33346. items: items
  33347. };
  33348. };
  33349. return Transform;
  33350. }();
  33351. var IrreversibleTransform = function IrreversibleTransformClosure() {
  33352. function IrreversibleTransform() {
  33353. Transform.call(this);
  33354. }
  33355. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  33356. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  33357. var len = length >> 1;
  33358. offset = offset | 0;
  33359. var j, n, current, next;
  33360. var alpha = -1.586134342059924;
  33361. var beta = -0.052980118572961;
  33362. var gamma = 0.882911075530934;
  33363. var delta = 0.443506852043971;
  33364. var K = 1.230174104914001;
  33365. var K_ = 1 / K;
  33366. j = offset - 3;
  33367. for (n = len + 4; n--; j += 2) {
  33368. x[j] *= K_;
  33369. }
  33370. j = offset - 2;
  33371. current = delta * x[j - 1];
  33372. for (n = len + 3; n--; j += 2) {
  33373. next = delta * x[j + 1];
  33374. x[j] = K * x[j] - current - next;
  33375. if (n--) {
  33376. j += 2;
  33377. current = delta * x[j + 1];
  33378. x[j] = K * x[j] - current - next;
  33379. } else {
  33380. break;
  33381. }
  33382. }
  33383. j = offset - 1;
  33384. current = gamma * x[j - 1];
  33385. for (n = len + 2; n--; j += 2) {
  33386. next = gamma * x[j + 1];
  33387. x[j] -= current + next;
  33388. if (n--) {
  33389. j += 2;
  33390. current = gamma * x[j + 1];
  33391. x[j] -= current + next;
  33392. } else {
  33393. break;
  33394. }
  33395. }
  33396. j = offset;
  33397. current = beta * x[j - 1];
  33398. for (n = len + 1; n--; j += 2) {
  33399. next = beta * x[j + 1];
  33400. x[j] -= current + next;
  33401. if (n--) {
  33402. j += 2;
  33403. current = beta * x[j + 1];
  33404. x[j] -= current + next;
  33405. } else {
  33406. break;
  33407. }
  33408. }
  33409. if (len !== 0) {
  33410. j = offset + 1;
  33411. current = alpha * x[j - 1];
  33412. for (n = len; n--; j += 2) {
  33413. next = alpha * x[j + 1];
  33414. x[j] -= current + next;
  33415. if (n--) {
  33416. j += 2;
  33417. current = alpha * x[j + 1];
  33418. x[j] -= current + next;
  33419. } else {
  33420. break;
  33421. }
  33422. }
  33423. }
  33424. };
  33425. return IrreversibleTransform;
  33426. }();
  33427. var ReversibleTransform = function ReversibleTransformClosure() {
  33428. function ReversibleTransform() {
  33429. Transform.call(this);
  33430. }
  33431. ReversibleTransform.prototype = Object.create(Transform.prototype);
  33432. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  33433. var len = length >> 1;
  33434. offset = offset | 0;
  33435. var j, n;
  33436. for (j = offset, n = len + 1; n--; j += 2) {
  33437. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  33438. }
  33439. for (j = offset + 1, n = len; n--; j += 2) {
  33440. x[j] += x[j - 1] + x[j + 1] >> 1;
  33441. }
  33442. };
  33443. return ReversibleTransform;
  33444. }();
  33445. return JpxImage;
  33446. }();
  33447. exports.JpxImage = JpxImage;
  33448. /***/ }),
  33449. /* 20 */
  33450. /***/ (function(module, exports, __w_pdfjs_require__) {
  33451. "use strict";
  33452. var sharedUtil = __w_pdfjs_require__(0);
  33453. var corePrimitives = __w_pdfjs_require__(1);
  33454. var coreCrypto = __w_pdfjs_require__(17);
  33455. var coreParser = __w_pdfjs_require__(6);
  33456. var coreChunkedStream = __w_pdfjs_require__(16);
  33457. var coreColorSpace = __w_pdfjs_require__(4);
  33458. var InvalidPDFException = sharedUtil.InvalidPDFException;
  33459. var MissingDataException = sharedUtil.MissingDataException;
  33460. var XRefParseException = sharedUtil.XRefParseException;
  33461. var assert = sharedUtil.assert;
  33462. var bytesToString = sharedUtil.bytesToString;
  33463. var createPromiseCapability = sharedUtil.createPromiseCapability;
  33464. var error = sharedUtil.error;
  33465. var info = sharedUtil.info;
  33466. var isArray = sharedUtil.isArray;
  33467. var isBool = sharedUtil.isBool;
  33468. var isInt = sharedUtil.isInt;
  33469. var isString = sharedUtil.isString;
  33470. var shadow = sharedUtil.shadow;
  33471. var stringToPDFString = sharedUtil.stringToPDFString;
  33472. var stringToUTF8String = sharedUtil.stringToUTF8String;
  33473. var warn = sharedUtil.warn;
  33474. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  33475. var Util = sharedUtil.Util;
  33476. var Ref = corePrimitives.Ref;
  33477. var RefSet = corePrimitives.RefSet;
  33478. var RefSetCache = corePrimitives.RefSetCache;
  33479. var isName = corePrimitives.isName;
  33480. var isCmd = corePrimitives.isCmd;
  33481. var isDict = corePrimitives.isDict;
  33482. var isRef = corePrimitives.isRef;
  33483. var isRefsEqual = corePrimitives.isRefsEqual;
  33484. var isStream = corePrimitives.isStream;
  33485. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  33486. var Lexer = coreParser.Lexer;
  33487. var Parser = coreParser.Parser;
  33488. var ChunkedStream = coreChunkedStream.ChunkedStream;
  33489. var ColorSpace = coreColorSpace.ColorSpace;
  33490. var Catalog = function CatalogClosure() {
  33491. function Catalog(pdfManager, xref, pageFactory) {
  33492. this.pdfManager = pdfManager;
  33493. this.xref = xref;
  33494. this.catDict = xref.getCatalogObj();
  33495. this.fontCache = new RefSetCache();
  33496. this.builtInCMapCache = Object.create(null);
  33497. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  33498. this.pageFactory = pageFactory;
  33499. this.pagePromises = [];
  33500. }
  33501. Catalog.prototype = {
  33502. get metadata() {
  33503. var streamRef = this.catDict.getRaw('Metadata');
  33504. if (!isRef(streamRef)) {
  33505. return shadow(this, 'metadata', null);
  33506. }
  33507. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  33508. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  33509. var metadata;
  33510. if (stream && isDict(stream.dict)) {
  33511. var type = stream.dict.get('Type');
  33512. var subtype = stream.dict.get('Subtype');
  33513. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  33514. try {
  33515. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  33516. } catch (e) {
  33517. info('Skipping invalid metadata.');
  33518. }
  33519. }
  33520. }
  33521. return shadow(this, 'metadata', metadata);
  33522. },
  33523. get toplevelPagesDict() {
  33524. var pagesObj = this.catDict.get('Pages');
  33525. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  33526. return shadow(this, 'toplevelPagesDict', pagesObj);
  33527. },
  33528. get documentOutline() {
  33529. var obj = null;
  33530. try {
  33531. obj = this.readDocumentOutline();
  33532. } catch (ex) {
  33533. if (ex instanceof MissingDataException) {
  33534. throw ex;
  33535. }
  33536. warn('Unable to read document outline');
  33537. }
  33538. return shadow(this, 'documentOutline', obj);
  33539. },
  33540. readDocumentOutline: function Catalog_readDocumentOutline() {
  33541. var obj = this.catDict.get('Outlines');
  33542. if (!isDict(obj)) {
  33543. return null;
  33544. }
  33545. obj = obj.getRaw('First');
  33546. if (!isRef(obj)) {
  33547. return null;
  33548. }
  33549. var root = { items: [] };
  33550. var queue = [{
  33551. obj: obj,
  33552. parent: root
  33553. }];
  33554. var processed = new RefSet();
  33555. processed.put(obj);
  33556. var xref = this.xref, blackColor = new Uint8Array(3);
  33557. while (queue.length > 0) {
  33558. var i = queue.shift();
  33559. var outlineDict = xref.fetchIfRef(i.obj);
  33560. if (outlineDict === null) {
  33561. continue;
  33562. }
  33563. assert(outlineDict.has('Title'), 'Invalid outline item');
  33564. var data = {
  33565. url: null,
  33566. dest: null
  33567. };
  33568. Catalog.parseDestDictionary({
  33569. destDict: outlineDict,
  33570. resultObj: data,
  33571. docBaseUrl: this.pdfManager.docBaseUrl
  33572. });
  33573. var title = outlineDict.get('Title');
  33574. var flags = outlineDict.get('F') || 0;
  33575. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  33576. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  33577. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  33578. }
  33579. var outlineItem = {
  33580. dest: data.dest,
  33581. url: data.url,
  33582. unsafeUrl: data.unsafeUrl,
  33583. newWindow: data.newWindow,
  33584. title: stringToPDFString(title),
  33585. color: rgbColor,
  33586. count: outlineDict.get('Count'),
  33587. bold: !!(flags & 2),
  33588. italic: !!(flags & 1),
  33589. items: []
  33590. };
  33591. i.parent.items.push(outlineItem);
  33592. obj = outlineDict.getRaw('First');
  33593. if (isRef(obj) && !processed.has(obj)) {
  33594. queue.push({
  33595. obj: obj,
  33596. parent: outlineItem
  33597. });
  33598. processed.put(obj);
  33599. }
  33600. obj = outlineDict.getRaw('Next');
  33601. if (isRef(obj) && !processed.has(obj)) {
  33602. queue.push({
  33603. obj: obj,
  33604. parent: i.parent
  33605. });
  33606. processed.put(obj);
  33607. }
  33608. }
  33609. return root.items.length > 0 ? root.items : null;
  33610. },
  33611. get numPages() {
  33612. var obj = this.toplevelPagesDict.get('Count');
  33613. assert(isInt(obj), 'page count in top level pages object is not an integer');
  33614. return shadow(this, 'num', obj);
  33615. },
  33616. get destinations() {
  33617. function fetchDestination(dest) {
  33618. return isDict(dest) ? dest.get('D') : dest;
  33619. }
  33620. var xref = this.xref;
  33621. var dests = {}, nameTreeRef, nameDictionaryRef;
  33622. var obj = this.catDict.get('Names');
  33623. if (obj && obj.has('Dests')) {
  33624. nameTreeRef = obj.getRaw('Dests');
  33625. } else if (this.catDict.has('Dests')) {
  33626. nameDictionaryRef = this.catDict.get('Dests');
  33627. }
  33628. if (nameDictionaryRef) {
  33629. obj = nameDictionaryRef;
  33630. obj.forEach(function catalogForEach(key, value) {
  33631. if (!value) {
  33632. return;
  33633. }
  33634. dests[key] = fetchDestination(value);
  33635. });
  33636. }
  33637. if (nameTreeRef) {
  33638. var nameTree = new NameTree(nameTreeRef, xref);
  33639. var names = nameTree.getAll();
  33640. for (var name in names) {
  33641. dests[name] = fetchDestination(names[name]);
  33642. }
  33643. }
  33644. return shadow(this, 'destinations', dests);
  33645. },
  33646. getDestination: function Catalog_getDestination(destinationId) {
  33647. function fetchDestination(dest) {
  33648. return isDict(dest) ? dest.get('D') : dest;
  33649. }
  33650. var xref = this.xref;
  33651. var dest = null, nameTreeRef, nameDictionaryRef;
  33652. var obj = this.catDict.get('Names');
  33653. if (obj && obj.has('Dests')) {
  33654. nameTreeRef = obj.getRaw('Dests');
  33655. } else if (this.catDict.has('Dests')) {
  33656. nameDictionaryRef = this.catDict.get('Dests');
  33657. }
  33658. if (nameDictionaryRef) {
  33659. var value = nameDictionaryRef.get(destinationId);
  33660. if (value) {
  33661. dest = fetchDestination(value);
  33662. }
  33663. }
  33664. if (nameTreeRef) {
  33665. var nameTree = new NameTree(nameTreeRef, xref);
  33666. dest = fetchDestination(nameTree.get(destinationId));
  33667. }
  33668. return dest;
  33669. },
  33670. get pageLabels() {
  33671. var obj = null;
  33672. try {
  33673. obj = this.readPageLabels();
  33674. } catch (ex) {
  33675. if (ex instanceof MissingDataException) {
  33676. throw ex;
  33677. }
  33678. warn('Unable to read page labels.');
  33679. }
  33680. return shadow(this, 'pageLabels', obj);
  33681. },
  33682. readPageLabels: function Catalog_readPageLabels() {
  33683. var obj = this.catDict.getRaw('PageLabels');
  33684. if (!obj) {
  33685. return null;
  33686. }
  33687. var pageLabels = new Array(this.numPages);
  33688. var style = null;
  33689. var prefix = '';
  33690. var numberTree = new NumberTree(obj, this.xref);
  33691. var nums = numberTree.getAll();
  33692. var currentLabel = '', currentIndex = 1;
  33693. for (var i = 0, ii = this.numPages; i < ii; i++) {
  33694. if (i in nums) {
  33695. var labelDict = nums[i];
  33696. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  33697. var type = labelDict.get('Type');
  33698. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  33699. var s = labelDict.get('S');
  33700. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  33701. style = s ? s.name : null;
  33702. var p = labelDict.get('P');
  33703. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  33704. prefix = p ? stringToPDFString(p) : '';
  33705. var st = labelDict.get('St');
  33706. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  33707. currentIndex = st || 1;
  33708. }
  33709. switch (style) {
  33710. case 'D':
  33711. currentLabel = currentIndex;
  33712. break;
  33713. case 'R':
  33714. case 'r':
  33715. currentLabel = Util.toRoman(currentIndex, style === 'r');
  33716. break;
  33717. case 'A':
  33718. case 'a':
  33719. var LIMIT = 26;
  33720. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  33721. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  33722. var letterIndex = currentIndex - 1;
  33723. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  33724. var charBuf = [];
  33725. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  33726. charBuf.push(character);
  33727. }
  33728. currentLabel = charBuf.join('');
  33729. break;
  33730. default:
  33731. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  33732. }
  33733. pageLabels[i] = prefix + currentLabel;
  33734. currentLabel = '';
  33735. currentIndex++;
  33736. }
  33737. return pageLabels;
  33738. },
  33739. get attachments() {
  33740. var xref = this.xref;
  33741. var attachments = null, nameTreeRef;
  33742. var obj = this.catDict.get('Names');
  33743. if (obj) {
  33744. nameTreeRef = obj.getRaw('EmbeddedFiles');
  33745. }
  33746. if (nameTreeRef) {
  33747. var nameTree = new NameTree(nameTreeRef, xref);
  33748. var names = nameTree.getAll();
  33749. for (var name in names) {
  33750. var fs = new FileSpec(names[name], xref);
  33751. if (!attachments) {
  33752. attachments = Object.create(null);
  33753. }
  33754. attachments[stringToPDFString(name)] = fs.serializable;
  33755. }
  33756. }
  33757. return shadow(this, 'attachments', attachments);
  33758. },
  33759. get javaScript() {
  33760. var xref = this.xref;
  33761. var obj = this.catDict.get('Names');
  33762. var javaScript = [];
  33763. function appendIfJavaScriptDict(jsDict) {
  33764. var type = jsDict.get('S');
  33765. if (!isName(type, 'JavaScript')) {
  33766. return;
  33767. }
  33768. var js = jsDict.get('JS');
  33769. if (isStream(js)) {
  33770. js = bytesToString(js.getBytes());
  33771. } else if (!isString(js)) {
  33772. return;
  33773. }
  33774. javaScript.push(stringToPDFString(js));
  33775. }
  33776. if (obj && obj.has('JavaScript')) {
  33777. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  33778. var names = nameTree.getAll();
  33779. for (var name in names) {
  33780. var jsDict = names[name];
  33781. if (isDict(jsDict)) {
  33782. appendIfJavaScriptDict(jsDict);
  33783. }
  33784. }
  33785. }
  33786. var openactionDict = this.catDict.get('OpenAction');
  33787. if (isDict(openactionDict, 'Action')) {
  33788. var actionType = openactionDict.get('S');
  33789. if (isName(actionType, 'Named')) {
  33790. var action = openactionDict.get('N');
  33791. if (isName(action, 'Print')) {
  33792. javaScript.push('print({});');
  33793. }
  33794. } else {
  33795. appendIfJavaScriptDict(openactionDict);
  33796. }
  33797. }
  33798. return shadow(this, 'javaScript', javaScript);
  33799. },
  33800. cleanup: function Catalog_cleanup() {
  33801. var promises = [];
  33802. this.fontCache.forEach(function (promise) {
  33803. promises.push(promise);
  33804. });
  33805. return Promise.all(promises).then(function (translatedFonts) {
  33806. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  33807. var font = translatedFonts[i].dict;
  33808. delete font.translated;
  33809. }
  33810. this.fontCache.clear();
  33811. this.builtInCMapCache = Object.create(null);
  33812. }.bind(this));
  33813. },
  33814. getPage: function Catalog_getPage(pageIndex) {
  33815. if (!(pageIndex in this.pagePromises)) {
  33816. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  33817. var dict = a[0];
  33818. var ref = a[1];
  33819. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  33820. }.bind(this));
  33821. }
  33822. return this.pagePromises[pageIndex];
  33823. },
  33824. getPageDict: function Catalog_getPageDict(pageIndex) {
  33825. var capability = createPromiseCapability();
  33826. var nodesToVisit = [this.catDict.getRaw('Pages')];
  33827. var currentPageIndex = 0;
  33828. var xref = this.xref;
  33829. function next() {
  33830. while (nodesToVisit.length) {
  33831. var currentNode = nodesToVisit.pop();
  33832. if (isRef(currentNode)) {
  33833. xref.fetchAsync(currentNode).then(function (obj) {
  33834. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  33835. if (pageIndex === currentPageIndex) {
  33836. capability.resolve([
  33837. obj,
  33838. currentNode
  33839. ]);
  33840. } else {
  33841. currentPageIndex++;
  33842. next();
  33843. }
  33844. return;
  33845. }
  33846. nodesToVisit.push(obj);
  33847. next();
  33848. }, capability.reject);
  33849. return;
  33850. }
  33851. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  33852. var count = currentNode.get('Count');
  33853. if (currentPageIndex + count <= pageIndex) {
  33854. currentPageIndex += count;
  33855. continue;
  33856. }
  33857. var kids = currentNode.get('Kids');
  33858. assert(isArray(kids), 'page dictionary kids object is not an array');
  33859. for (var last = kids.length - 1; last >= 0; last--) {
  33860. nodesToVisit.push(kids[last]);
  33861. }
  33862. }
  33863. capability.reject('Page index ' + pageIndex + ' not found.');
  33864. }
  33865. next();
  33866. return capability.promise;
  33867. },
  33868. getPageIndex: function Catalog_getPageIndex(pageRef) {
  33869. var xref = this.xref;
  33870. function pagesBeforeRef(kidRef) {
  33871. var total = 0;
  33872. var parentRef;
  33873. return xref.fetchAsync(kidRef).then(function (node) {
  33874. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  33875. throw new Error('The reference does not point to a /Page Dict.');
  33876. }
  33877. if (!node) {
  33878. return null;
  33879. }
  33880. assert(isDict(node), 'node must be a Dict.');
  33881. parentRef = node.getRaw('Parent');
  33882. return node.getAsync('Parent');
  33883. }).then(function (parent) {
  33884. if (!parent) {
  33885. return null;
  33886. }
  33887. assert(isDict(parent), 'parent must be a Dict.');
  33888. return parent.getAsync('Kids');
  33889. }).then(function (kids) {
  33890. if (!kids) {
  33891. return null;
  33892. }
  33893. var kidPromises = [];
  33894. var found = false;
  33895. for (var i = 0; i < kids.length; i++) {
  33896. var kid = kids[i];
  33897. assert(isRef(kid), 'kid must be a Ref.');
  33898. if (kid.num === kidRef.num) {
  33899. found = true;
  33900. break;
  33901. }
  33902. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  33903. if (kid.has('Count')) {
  33904. var count = kid.get('Count');
  33905. total += count;
  33906. } else {
  33907. total++;
  33908. }
  33909. }));
  33910. }
  33911. if (!found) {
  33912. error('kid ref not found in parents kids');
  33913. }
  33914. return Promise.all(kidPromises).then(function () {
  33915. return [
  33916. total,
  33917. parentRef
  33918. ];
  33919. });
  33920. });
  33921. }
  33922. var total = 0;
  33923. function next(ref) {
  33924. return pagesBeforeRef(ref).then(function (args) {
  33925. if (!args) {
  33926. return total;
  33927. }
  33928. var count = args[0];
  33929. var parentRef = args[1];
  33930. total += count;
  33931. return next(parentRef);
  33932. });
  33933. }
  33934. return next(pageRef);
  33935. }
  33936. };
  33937. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  33938. function addDefaultProtocolToUrl(url) {
  33939. if (url.indexOf('www.') === 0) {
  33940. return 'http://' + url;
  33941. }
  33942. return url;
  33943. }
  33944. function tryConvertUrlEncoding(url) {
  33945. try {
  33946. return stringToUTF8String(url);
  33947. } catch (e) {
  33948. return url;
  33949. }
  33950. }
  33951. var destDict = params.destDict;
  33952. if (!isDict(destDict)) {
  33953. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  33954. return;
  33955. }
  33956. var resultObj = params.resultObj;
  33957. if (typeof resultObj !== 'object') {
  33958. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  33959. return;
  33960. }
  33961. var docBaseUrl = params.docBaseUrl || null;
  33962. var action = destDict.get('A'), url, dest;
  33963. if (isDict(action)) {
  33964. var linkType = action.get('S').name;
  33965. switch (linkType) {
  33966. case 'URI':
  33967. url = action.get('URI');
  33968. if (isName(url)) {
  33969. url = '/' + url.name;
  33970. } else if (isString(url)) {
  33971. url = addDefaultProtocolToUrl(url);
  33972. }
  33973. break;
  33974. case 'GoTo':
  33975. dest = action.get('D');
  33976. break;
  33977. case 'Launch':
  33978. case 'GoToR':
  33979. var urlDict = action.get('F');
  33980. if (isDict(urlDict)) {
  33981. url = urlDict.get('F') || null;
  33982. } else if (isString(urlDict)) {
  33983. url = urlDict;
  33984. }
  33985. var remoteDest = action.get('D');
  33986. if (remoteDest) {
  33987. if (isName(remoteDest)) {
  33988. remoteDest = remoteDest.name;
  33989. }
  33990. if (isString(url)) {
  33991. var baseUrl = url.split('#')[0];
  33992. if (isString(remoteDest)) {
  33993. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  33994. } else if (isArray(remoteDest)) {
  33995. url = baseUrl + '#' + JSON.stringify(remoteDest);
  33996. }
  33997. }
  33998. }
  33999. var newWindow = action.get('NewWindow');
  34000. if (isBool(newWindow)) {
  34001. resultObj.newWindow = newWindow;
  34002. }
  34003. break;
  34004. case 'Named':
  34005. var namedAction = action.get('N');
  34006. if (isName(namedAction)) {
  34007. resultObj.action = namedAction.name;
  34008. }
  34009. break;
  34010. case 'JavaScript':
  34011. var jsAction = action.get('JS'), js;
  34012. if (isStream(jsAction)) {
  34013. js = bytesToString(jsAction.getBytes());
  34014. } else if (isString(jsAction)) {
  34015. js = jsAction;
  34016. }
  34017. if (js) {
  34018. var URL_OPEN_METHODS = [
  34019. 'app.launchURL',
  34020. 'window.open'
  34021. ];
  34022. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34023. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34024. if (jsUrl && jsUrl[1]) {
  34025. url = jsUrl[1];
  34026. break;
  34027. }
  34028. }
  34029. default:
  34030. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34031. break;
  34032. }
  34033. } else if (destDict.has('Dest')) {
  34034. dest = destDict.get('Dest');
  34035. }
  34036. if (isString(url)) {
  34037. url = tryConvertUrlEncoding(url);
  34038. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34039. if (absoluteUrl) {
  34040. resultObj.url = absoluteUrl.href;
  34041. }
  34042. resultObj.unsafeUrl = url;
  34043. }
  34044. if (dest) {
  34045. if (isName(dest)) {
  34046. dest = dest.name;
  34047. }
  34048. if (isString(dest) || isArray(dest)) {
  34049. resultObj.dest = dest;
  34050. }
  34051. }
  34052. };
  34053. return Catalog;
  34054. }();
  34055. var XRef = function XRefClosure() {
  34056. function XRef(stream, pdfManager) {
  34057. this.stream = stream;
  34058. this.pdfManager = pdfManager;
  34059. this.entries = [];
  34060. this.xrefstms = Object.create(null);
  34061. this.cache = [];
  34062. this.stats = {
  34063. streamTypes: [],
  34064. fontTypes: []
  34065. };
  34066. }
  34067. XRef.prototype = {
  34068. setStartXRef: function XRef_setStartXRef(startXRef) {
  34069. this.startXRefQueue = [startXRef];
  34070. },
  34071. parse: function XRef_parse(recoveryMode) {
  34072. var trailerDict;
  34073. if (!recoveryMode) {
  34074. trailerDict = this.readXRef();
  34075. } else {
  34076. warn('Indexing all PDF objects');
  34077. trailerDict = this.indexObjects();
  34078. }
  34079. trailerDict.assignXref(this);
  34080. this.trailer = trailerDict;
  34081. var encrypt = trailerDict.get('Encrypt');
  34082. if (isDict(encrypt)) {
  34083. var ids = trailerDict.get('ID');
  34084. var fileId = ids && ids.length ? ids[0] : '';
  34085. encrypt.suppressEncryption = true;
  34086. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34087. }
  34088. if (!(this.root = trailerDict.get('Root'))) {
  34089. error('Invalid root reference');
  34090. }
  34091. },
  34092. processXRefTable: function XRef_processXRefTable(parser) {
  34093. if (!('tableState' in this)) {
  34094. this.tableState = {
  34095. entryNum: 0,
  34096. streamPos: parser.lexer.stream.pos,
  34097. parserBuf1: parser.buf1,
  34098. parserBuf2: parser.buf2
  34099. };
  34100. }
  34101. var obj = this.readXRefTable(parser);
  34102. if (!isCmd(obj, 'trailer')) {
  34103. error('Invalid XRef table: could not find trailer dictionary');
  34104. }
  34105. var dict = parser.getObj();
  34106. if (!isDict(dict) && dict.dict) {
  34107. dict = dict.dict;
  34108. }
  34109. if (!isDict(dict)) {
  34110. error('Invalid XRef table: could not parse trailer dictionary');
  34111. }
  34112. delete this.tableState;
  34113. return dict;
  34114. },
  34115. readXRefTable: function XRef_readXRefTable(parser) {
  34116. var stream = parser.lexer.stream;
  34117. var tableState = this.tableState;
  34118. stream.pos = tableState.streamPos;
  34119. parser.buf1 = tableState.parserBuf1;
  34120. parser.buf2 = tableState.parserBuf2;
  34121. var obj;
  34122. while (true) {
  34123. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34124. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34125. break;
  34126. }
  34127. tableState.firstEntryNum = obj;
  34128. tableState.entryCount = parser.getObj();
  34129. }
  34130. var first = tableState.firstEntryNum;
  34131. var count = tableState.entryCount;
  34132. if (!isInt(first) || !isInt(count)) {
  34133. error('Invalid XRef table: wrong types in subsection header');
  34134. }
  34135. for (var i = tableState.entryNum; i < count; i++) {
  34136. tableState.streamPos = stream.pos;
  34137. tableState.entryNum = i;
  34138. tableState.parserBuf1 = parser.buf1;
  34139. tableState.parserBuf2 = parser.buf2;
  34140. var entry = {};
  34141. entry.offset = parser.getObj();
  34142. entry.gen = parser.getObj();
  34143. var type = parser.getObj();
  34144. if (isCmd(type, 'f')) {
  34145. entry.free = true;
  34146. } else if (isCmd(type, 'n')) {
  34147. entry.uncompressed = true;
  34148. }
  34149. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34150. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34151. }
  34152. if (i === 0 && entry.free && first === 1) {
  34153. first = 0;
  34154. }
  34155. if (!this.entries[i + first]) {
  34156. this.entries[i + first] = entry;
  34157. }
  34158. }
  34159. tableState.entryNum = 0;
  34160. tableState.streamPos = stream.pos;
  34161. tableState.parserBuf1 = parser.buf1;
  34162. tableState.parserBuf2 = parser.buf2;
  34163. delete tableState.firstEntryNum;
  34164. delete tableState.entryCount;
  34165. }
  34166. if (this.entries[0] && !this.entries[0].free) {
  34167. error('Invalid XRef table: unexpected first object');
  34168. }
  34169. return obj;
  34170. },
  34171. processXRefStream: function XRef_processXRefStream(stream) {
  34172. if (!('streamState' in this)) {
  34173. var streamParameters = stream.dict;
  34174. var byteWidths = streamParameters.get('W');
  34175. var range = streamParameters.get('Index');
  34176. if (!range) {
  34177. range = [
  34178. 0,
  34179. streamParameters.get('Size')
  34180. ];
  34181. }
  34182. this.streamState = {
  34183. entryRanges: range,
  34184. byteWidths: byteWidths,
  34185. entryNum: 0,
  34186. streamPos: stream.pos
  34187. };
  34188. }
  34189. this.readXRefStream(stream);
  34190. delete this.streamState;
  34191. return stream.dict;
  34192. },
  34193. readXRefStream: function XRef_readXRefStream(stream) {
  34194. var i, j;
  34195. var streamState = this.streamState;
  34196. stream.pos = streamState.streamPos;
  34197. var byteWidths = streamState.byteWidths;
  34198. var typeFieldWidth = byteWidths[0];
  34199. var offsetFieldWidth = byteWidths[1];
  34200. var generationFieldWidth = byteWidths[2];
  34201. var entryRanges = streamState.entryRanges;
  34202. while (entryRanges.length > 0) {
  34203. var first = entryRanges[0];
  34204. var n = entryRanges[1];
  34205. if (!isInt(first) || !isInt(n)) {
  34206. error('Invalid XRef range fields: ' + first + ', ' + n);
  34207. }
  34208. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34209. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34210. }
  34211. for (i = streamState.entryNum; i < n; ++i) {
  34212. streamState.entryNum = i;
  34213. streamState.streamPos = stream.pos;
  34214. var type = 0, offset = 0, generation = 0;
  34215. for (j = 0; j < typeFieldWidth; ++j) {
  34216. type = type << 8 | stream.getByte();
  34217. }
  34218. if (typeFieldWidth === 0) {
  34219. type = 1;
  34220. }
  34221. for (j = 0; j < offsetFieldWidth; ++j) {
  34222. offset = offset << 8 | stream.getByte();
  34223. }
  34224. for (j = 0; j < generationFieldWidth; ++j) {
  34225. generation = generation << 8 | stream.getByte();
  34226. }
  34227. var entry = {};
  34228. entry.offset = offset;
  34229. entry.gen = generation;
  34230. switch (type) {
  34231. case 0:
  34232. entry.free = true;
  34233. break;
  34234. case 1:
  34235. entry.uncompressed = true;
  34236. break;
  34237. case 2:
  34238. break;
  34239. default:
  34240. error('Invalid XRef entry type: ' + type);
  34241. }
  34242. if (!this.entries[first + i]) {
  34243. this.entries[first + i] = entry;
  34244. }
  34245. }
  34246. streamState.entryNum = 0;
  34247. streamState.streamPos = stream.pos;
  34248. entryRanges.splice(0, 2);
  34249. }
  34250. },
  34251. indexObjects: function XRef_indexObjects() {
  34252. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34253. var PERCENT = 0x25, LT = 0x3C;
  34254. function readToken(data, offset) {
  34255. var token = '', ch = data[offset];
  34256. while (ch !== LF && ch !== CR && ch !== LT) {
  34257. if (++offset >= data.length) {
  34258. break;
  34259. }
  34260. token += String.fromCharCode(ch);
  34261. ch = data[offset];
  34262. }
  34263. return token;
  34264. }
  34265. function skipUntil(data, offset, what) {
  34266. var length = what.length, dataLength = data.length;
  34267. var skipped = 0;
  34268. while (offset < dataLength) {
  34269. var i = 0;
  34270. while (i < length && data[offset + i] === what[i]) {
  34271. ++i;
  34272. }
  34273. if (i >= length) {
  34274. break;
  34275. }
  34276. offset++;
  34277. skipped++;
  34278. }
  34279. return skipped;
  34280. }
  34281. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  34282. var trailerBytes = new Uint8Array([
  34283. 116,
  34284. 114,
  34285. 97,
  34286. 105,
  34287. 108,
  34288. 101,
  34289. 114
  34290. ]);
  34291. var startxrefBytes = new Uint8Array([
  34292. 115,
  34293. 116,
  34294. 97,
  34295. 114,
  34296. 116,
  34297. 120,
  34298. 114,
  34299. 101,
  34300. 102
  34301. ]);
  34302. var endobjBytes = new Uint8Array([
  34303. 101,
  34304. 110,
  34305. 100,
  34306. 111,
  34307. 98,
  34308. 106
  34309. ]);
  34310. var xrefBytes = new Uint8Array([
  34311. 47,
  34312. 88,
  34313. 82,
  34314. 101,
  34315. 102
  34316. ]);
  34317. this.entries.length = 0;
  34318. var stream = this.stream;
  34319. stream.pos = 0;
  34320. var buffer = stream.getBytes();
  34321. var position = stream.start, length = buffer.length;
  34322. var trailers = [], xrefStms = [];
  34323. while (position < length) {
  34324. var ch = buffer[position];
  34325. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  34326. ++position;
  34327. continue;
  34328. }
  34329. if (ch === PERCENT) {
  34330. do {
  34331. ++position;
  34332. if (position >= length) {
  34333. break;
  34334. }
  34335. ch = buffer[position];
  34336. } while (ch !== LF && ch !== CR);
  34337. continue;
  34338. }
  34339. var token = readToken(buffer, position);
  34340. var m;
  34341. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  34342. position += skipUntil(buffer, position, trailerBytes);
  34343. trailers.push(position);
  34344. position += skipUntil(buffer, position, startxrefBytes);
  34345. } else if (m = objRegExp.exec(token)) {
  34346. if (typeof this.entries[m[1]] === 'undefined') {
  34347. this.entries[m[1]] = {
  34348. offset: position - stream.start,
  34349. gen: m[2] | 0,
  34350. uncompressed: true
  34351. };
  34352. }
  34353. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  34354. var content = buffer.subarray(position, position + contentLength);
  34355. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  34356. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  34357. xrefStms.push(position - stream.start);
  34358. this.xrefstms[position - stream.start] = 1;
  34359. }
  34360. position += contentLength;
  34361. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  34362. trailers.push(position);
  34363. position += skipUntil(buffer, position, startxrefBytes);
  34364. } else {
  34365. position += token.length + 1;
  34366. }
  34367. }
  34368. var i, ii;
  34369. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  34370. this.startXRefQueue.push(xrefStms[i]);
  34371. this.readXRef(true);
  34372. }
  34373. var dict;
  34374. for (i = 0, ii = trailers.length; i < ii; ++i) {
  34375. stream.pos = trailers[i];
  34376. var parser = new Parser(new Lexer(stream), true, this, true);
  34377. var obj = parser.getObj();
  34378. if (!isCmd(obj, 'trailer')) {
  34379. continue;
  34380. }
  34381. dict = parser.getObj();
  34382. if (!isDict(dict)) {
  34383. continue;
  34384. }
  34385. if (dict.has('ID')) {
  34386. return dict;
  34387. }
  34388. }
  34389. if (dict) {
  34390. return dict;
  34391. }
  34392. throw new InvalidPDFException('Invalid PDF structure');
  34393. },
  34394. readXRef: function XRef_readXRef(recoveryMode) {
  34395. var stream = this.stream;
  34396. try {
  34397. while (this.startXRefQueue.length) {
  34398. var startXRef = this.startXRefQueue[0];
  34399. stream.pos = startXRef + stream.start;
  34400. var parser = new Parser(new Lexer(stream), true, this);
  34401. var obj = parser.getObj();
  34402. var dict;
  34403. if (isCmd(obj, 'xref')) {
  34404. dict = this.processXRefTable(parser);
  34405. if (!this.topDict) {
  34406. this.topDict = dict;
  34407. }
  34408. obj = dict.get('XRefStm');
  34409. if (isInt(obj)) {
  34410. var pos = obj;
  34411. if (!(pos in this.xrefstms)) {
  34412. this.xrefstms[pos] = 1;
  34413. this.startXRefQueue.push(pos);
  34414. }
  34415. }
  34416. } else if (isInt(obj)) {
  34417. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  34418. error('Invalid XRef stream');
  34419. }
  34420. dict = this.processXRefStream(obj);
  34421. if (!this.topDict) {
  34422. this.topDict = dict;
  34423. }
  34424. if (!dict) {
  34425. error('Failed to read XRef stream');
  34426. }
  34427. } else {
  34428. error('Invalid XRef stream header');
  34429. }
  34430. obj = dict.get('Prev');
  34431. if (isInt(obj)) {
  34432. this.startXRefQueue.push(obj);
  34433. } else if (isRef(obj)) {
  34434. this.startXRefQueue.push(obj.num);
  34435. }
  34436. this.startXRefQueue.shift();
  34437. }
  34438. return this.topDict;
  34439. } catch (e) {
  34440. if (e instanceof MissingDataException) {
  34441. throw e;
  34442. }
  34443. info('(while reading XRef): ' + e);
  34444. }
  34445. if (recoveryMode) {
  34446. return;
  34447. }
  34448. throw new XRefParseException();
  34449. },
  34450. getEntry: function XRef_getEntry(i) {
  34451. var xrefEntry = this.entries[i];
  34452. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  34453. return xrefEntry;
  34454. }
  34455. return null;
  34456. },
  34457. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  34458. if (!isRef(obj)) {
  34459. return obj;
  34460. }
  34461. return this.fetch(obj, suppressEncryption);
  34462. },
  34463. fetch: function XRef_fetch(ref, suppressEncryption) {
  34464. assert(isRef(ref), 'ref object is not a reference');
  34465. var num = ref.num;
  34466. if (num in this.cache) {
  34467. var cacheEntry = this.cache[num];
  34468. return cacheEntry;
  34469. }
  34470. var xrefEntry = this.getEntry(num);
  34471. if (xrefEntry === null) {
  34472. return this.cache[num] = null;
  34473. }
  34474. if (xrefEntry.uncompressed) {
  34475. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  34476. } else {
  34477. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  34478. }
  34479. if (isDict(xrefEntry)) {
  34480. xrefEntry.objId = ref.toString();
  34481. } else if (isStream(xrefEntry)) {
  34482. xrefEntry.dict.objId = ref.toString();
  34483. }
  34484. return xrefEntry;
  34485. },
  34486. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  34487. var gen = ref.gen;
  34488. var num = ref.num;
  34489. if (xrefEntry.gen !== gen) {
  34490. error('inconsistent generation in XRef');
  34491. }
  34492. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  34493. var parser = new Parser(new Lexer(stream), true, this);
  34494. var obj1 = parser.getObj();
  34495. var obj2 = parser.getObj();
  34496. var obj3 = parser.getObj();
  34497. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  34498. error('bad XRef entry');
  34499. }
  34500. if (!isCmd(obj3, 'obj')) {
  34501. if (obj3.cmd.indexOf('obj') === 0) {
  34502. num = parseInt(obj3.cmd.substring(3), 10);
  34503. if (!isNaN(num)) {
  34504. return num;
  34505. }
  34506. }
  34507. error('bad XRef entry');
  34508. }
  34509. if (this.encrypt && !suppressEncryption) {
  34510. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  34511. } else {
  34512. xrefEntry = parser.getObj();
  34513. }
  34514. if (!isStream(xrefEntry)) {
  34515. this.cache[num] = xrefEntry;
  34516. }
  34517. return xrefEntry;
  34518. },
  34519. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  34520. var tableOffset = xrefEntry.offset;
  34521. var stream = this.fetch(new Ref(tableOffset, 0));
  34522. if (!isStream(stream)) {
  34523. error('bad ObjStm stream');
  34524. }
  34525. var first = stream.dict.get('First');
  34526. var n = stream.dict.get('N');
  34527. if (!isInt(first) || !isInt(n)) {
  34528. error('invalid first and n parameters for ObjStm stream');
  34529. }
  34530. var parser = new Parser(new Lexer(stream), false, this);
  34531. parser.allowStreams = true;
  34532. var i, entries = [], num, nums = [];
  34533. for (i = 0; i < n; ++i) {
  34534. num = parser.getObj();
  34535. if (!isInt(num)) {
  34536. error('invalid object number in the ObjStm stream: ' + num);
  34537. }
  34538. nums.push(num);
  34539. var offset = parser.getObj();
  34540. if (!isInt(offset)) {
  34541. error('invalid object offset in the ObjStm stream: ' + offset);
  34542. }
  34543. }
  34544. for (i = 0; i < n; ++i) {
  34545. entries.push(parser.getObj());
  34546. if (isCmd(parser.buf1, 'endobj')) {
  34547. parser.shift();
  34548. }
  34549. num = nums[i];
  34550. var entry = this.entries[num];
  34551. if (entry && entry.offset === tableOffset && entry.gen === i) {
  34552. this.cache[num] = entries[i];
  34553. }
  34554. }
  34555. xrefEntry = entries[xrefEntry.gen];
  34556. if (xrefEntry === undefined) {
  34557. error('bad XRef entry for compressed object');
  34558. }
  34559. return xrefEntry;
  34560. },
  34561. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  34562. if (!isRef(obj)) {
  34563. return Promise.resolve(obj);
  34564. }
  34565. return this.fetchAsync(obj, suppressEncryption);
  34566. },
  34567. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  34568. var streamManager = this.stream.manager;
  34569. var xref = this;
  34570. return new Promise(function tryFetch(resolve, reject) {
  34571. try {
  34572. resolve(xref.fetch(ref, suppressEncryption));
  34573. } catch (e) {
  34574. if (e instanceof MissingDataException) {
  34575. streamManager.requestRange(e.begin, e.end).then(function () {
  34576. tryFetch(resolve, reject);
  34577. }, reject);
  34578. return;
  34579. }
  34580. reject(e);
  34581. }
  34582. });
  34583. },
  34584. getCatalogObj: function XRef_getCatalogObj() {
  34585. return this.root;
  34586. }
  34587. };
  34588. return XRef;
  34589. }();
  34590. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  34591. function NameOrNumberTree(root, xref) {
  34592. throw new Error('Cannot initialize NameOrNumberTree.');
  34593. }
  34594. NameOrNumberTree.prototype = {
  34595. getAll: function NameOrNumberTree_getAll() {
  34596. var dict = Object.create(null);
  34597. if (!this.root) {
  34598. return dict;
  34599. }
  34600. var xref = this.xref;
  34601. var processed = new RefSet();
  34602. processed.put(this.root);
  34603. var queue = [this.root];
  34604. while (queue.length > 0) {
  34605. var i, n;
  34606. var obj = xref.fetchIfRef(queue.shift());
  34607. if (!isDict(obj)) {
  34608. continue;
  34609. }
  34610. if (obj.has('Kids')) {
  34611. var kids = obj.get('Kids');
  34612. for (i = 0, n = kids.length; i < n; i++) {
  34613. var kid = kids[i];
  34614. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  34615. queue.push(kid);
  34616. processed.put(kid);
  34617. }
  34618. continue;
  34619. }
  34620. var entries = obj.get(this._type);
  34621. if (isArray(entries)) {
  34622. for (i = 0, n = entries.length; i < n; i += 2) {
  34623. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  34624. }
  34625. }
  34626. }
  34627. return dict;
  34628. },
  34629. get: function NameOrNumberTree_get(key) {
  34630. if (!this.root) {
  34631. return null;
  34632. }
  34633. var xref = this.xref;
  34634. var kidsOrEntries = xref.fetchIfRef(this.root);
  34635. var loopCount = 0;
  34636. var MAX_LEVELS = 10;
  34637. var l, r, m;
  34638. while (kidsOrEntries.has('Kids')) {
  34639. if (++loopCount > MAX_LEVELS) {
  34640. warn('Search depth limit reached for "' + this._type + '" tree.');
  34641. return null;
  34642. }
  34643. var kids = kidsOrEntries.get('Kids');
  34644. if (!isArray(kids)) {
  34645. return null;
  34646. }
  34647. l = 0;
  34648. r = kids.length - 1;
  34649. while (l <= r) {
  34650. m = l + r >> 1;
  34651. var kid = xref.fetchIfRef(kids[m]);
  34652. var limits = kid.get('Limits');
  34653. if (key < xref.fetchIfRef(limits[0])) {
  34654. r = m - 1;
  34655. } else if (key > xref.fetchIfRef(limits[1])) {
  34656. l = m + 1;
  34657. } else {
  34658. kidsOrEntries = xref.fetchIfRef(kids[m]);
  34659. break;
  34660. }
  34661. }
  34662. if (l > r) {
  34663. return null;
  34664. }
  34665. }
  34666. var entries = kidsOrEntries.get(this._type);
  34667. if (isArray(entries)) {
  34668. l = 0;
  34669. r = entries.length - 2;
  34670. while (l <= r) {
  34671. m = l + r & ~1;
  34672. var currentKey = xref.fetchIfRef(entries[m]);
  34673. if (key < currentKey) {
  34674. r = m - 2;
  34675. } else if (key > currentKey) {
  34676. l = m + 2;
  34677. } else {
  34678. return xref.fetchIfRef(entries[m + 1]);
  34679. }
  34680. }
  34681. }
  34682. return null;
  34683. }
  34684. };
  34685. return NameOrNumberTree;
  34686. }();
  34687. var NameTree = function NameTreeClosure() {
  34688. function NameTree(root, xref) {
  34689. this.root = root;
  34690. this.xref = xref;
  34691. this._type = 'Names';
  34692. }
  34693. Util.inherit(NameTree, NameOrNumberTree, {});
  34694. return NameTree;
  34695. }();
  34696. var NumberTree = function NumberTreeClosure() {
  34697. function NumberTree(root, xref) {
  34698. this.root = root;
  34699. this.xref = xref;
  34700. this._type = 'Nums';
  34701. }
  34702. Util.inherit(NumberTree, NameOrNumberTree, {});
  34703. return NumberTree;
  34704. }();
  34705. var FileSpec = function FileSpecClosure() {
  34706. function FileSpec(root, xref) {
  34707. if (!root || !isDict(root)) {
  34708. return;
  34709. }
  34710. this.xref = xref;
  34711. this.root = root;
  34712. if (root.has('FS')) {
  34713. this.fs = root.get('FS');
  34714. }
  34715. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  34716. if (root.has('RF')) {
  34717. warn('Related file specifications are not supported');
  34718. }
  34719. this.contentAvailable = true;
  34720. if (!root.has('EF')) {
  34721. this.contentAvailable = false;
  34722. warn('Non-embedded file specifications are not supported');
  34723. }
  34724. }
  34725. function pickPlatformItem(dict) {
  34726. if (dict.has('UF')) {
  34727. return dict.get('UF');
  34728. } else if (dict.has('F')) {
  34729. return dict.get('F');
  34730. } else if (dict.has('Unix')) {
  34731. return dict.get('Unix');
  34732. } else if (dict.has('Mac')) {
  34733. return dict.get('Mac');
  34734. } else if (dict.has('DOS')) {
  34735. return dict.get('DOS');
  34736. }
  34737. return null;
  34738. }
  34739. FileSpec.prototype = {
  34740. get filename() {
  34741. if (!this._filename && this.root) {
  34742. var filename = pickPlatformItem(this.root) || 'unnamed';
  34743. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  34744. }
  34745. return this._filename;
  34746. },
  34747. get content() {
  34748. if (!this.contentAvailable) {
  34749. return null;
  34750. }
  34751. if (!this.contentRef && this.root) {
  34752. this.contentRef = pickPlatformItem(this.root.get('EF'));
  34753. }
  34754. var content = null;
  34755. if (this.contentRef) {
  34756. var xref = this.xref;
  34757. var fileObj = xref.fetchIfRef(this.contentRef);
  34758. if (fileObj && isStream(fileObj)) {
  34759. content = fileObj.getBytes();
  34760. } else {
  34761. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  34762. }
  34763. } else {
  34764. warn('Embedded file specification does not have a content');
  34765. }
  34766. return content;
  34767. },
  34768. get serializable() {
  34769. return {
  34770. filename: this.filename,
  34771. content: this.content
  34772. };
  34773. }
  34774. };
  34775. return FileSpec;
  34776. }();
  34777. var ObjectLoader = function () {
  34778. function mayHaveChildren(value) {
  34779. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  34780. }
  34781. function addChildren(node, nodesToVisit) {
  34782. var value;
  34783. if (isDict(node) || isStream(node)) {
  34784. var map;
  34785. if (isDict(node)) {
  34786. map = node.map;
  34787. } else {
  34788. map = node.dict.map;
  34789. }
  34790. for (var key in map) {
  34791. value = map[key];
  34792. if (mayHaveChildren(value)) {
  34793. nodesToVisit.push(value);
  34794. }
  34795. }
  34796. } else if (isArray(node)) {
  34797. for (var i = 0, ii = node.length; i < ii; i++) {
  34798. value = node[i];
  34799. if (mayHaveChildren(value)) {
  34800. nodesToVisit.push(value);
  34801. }
  34802. }
  34803. }
  34804. }
  34805. function ObjectLoader(obj, keys, xref) {
  34806. this.obj = obj;
  34807. this.keys = keys;
  34808. this.xref = xref;
  34809. this.refSet = null;
  34810. this.capability = null;
  34811. }
  34812. ObjectLoader.prototype = {
  34813. load: function ObjectLoader_load() {
  34814. var keys = this.keys;
  34815. this.capability = createPromiseCapability();
  34816. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  34817. this.capability.resolve();
  34818. return this.capability.promise;
  34819. }
  34820. this.refSet = new RefSet();
  34821. var nodesToVisit = [];
  34822. for (var i = 0; i < keys.length; i++) {
  34823. nodesToVisit.push(this.obj[keys[i]]);
  34824. }
  34825. this._walk(nodesToVisit);
  34826. return this.capability.promise;
  34827. },
  34828. _walk: function ObjectLoader_walk(nodesToVisit) {
  34829. var nodesToRevisit = [];
  34830. var pendingRequests = [];
  34831. while (nodesToVisit.length) {
  34832. var currentNode = nodesToVisit.pop();
  34833. if (isRef(currentNode)) {
  34834. if (this.refSet.has(currentNode)) {
  34835. continue;
  34836. }
  34837. try {
  34838. var ref = currentNode;
  34839. this.refSet.put(ref);
  34840. currentNode = this.xref.fetch(currentNode);
  34841. } catch (e) {
  34842. if (!(e instanceof MissingDataException)) {
  34843. throw e;
  34844. }
  34845. nodesToRevisit.push(currentNode);
  34846. pendingRequests.push({
  34847. begin: e.begin,
  34848. end: e.end
  34849. });
  34850. }
  34851. }
  34852. if (currentNode && currentNode.getBaseStreams) {
  34853. var baseStreams = currentNode.getBaseStreams();
  34854. var foundMissingData = false;
  34855. for (var i = 0; i < baseStreams.length; i++) {
  34856. var stream = baseStreams[i];
  34857. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  34858. foundMissingData = true;
  34859. pendingRequests.push({
  34860. begin: stream.start,
  34861. end: stream.end
  34862. });
  34863. }
  34864. }
  34865. if (foundMissingData) {
  34866. nodesToRevisit.push(currentNode);
  34867. }
  34868. }
  34869. addChildren(currentNode, nodesToVisit);
  34870. }
  34871. if (pendingRequests.length) {
  34872. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  34873. nodesToVisit = nodesToRevisit;
  34874. for (var i = 0; i < nodesToRevisit.length; i++) {
  34875. var node = nodesToRevisit[i];
  34876. if (isRef(node)) {
  34877. this.refSet.remove(node);
  34878. }
  34879. }
  34880. this._walk(nodesToVisit);
  34881. }.bind(this), this.capability.reject);
  34882. return;
  34883. }
  34884. this.refSet = null;
  34885. this.capability.resolve();
  34886. }
  34887. };
  34888. return ObjectLoader;
  34889. }();
  34890. exports.Catalog = Catalog;
  34891. exports.ObjectLoader = ObjectLoader;
  34892. exports.XRef = XRef;
  34893. exports.FileSpec = FileSpec;
  34894. /***/ }),
  34895. /* 21 */
  34896. /***/ (function(module, exports, __w_pdfjs_require__) {
  34897. "use strict";
  34898. var sharedUtil = __w_pdfjs_require__(0);
  34899. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  34900. var getStdFontMap = getLookupTableFactory(function (t) {
  34901. t['ArialNarrow'] = 'Helvetica';
  34902. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  34903. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  34904. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  34905. t['ArialBlack'] = 'Helvetica';
  34906. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  34907. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  34908. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  34909. t['Arial-Black'] = 'Helvetica';
  34910. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  34911. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  34912. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  34913. t['Arial'] = 'Helvetica';
  34914. t['Arial-Bold'] = 'Helvetica-Bold';
  34915. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  34916. t['Arial-Italic'] = 'Helvetica-Oblique';
  34917. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  34918. t['Arial-BoldMT'] = 'Helvetica-Bold';
  34919. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  34920. t['ArialMT'] = 'Helvetica';
  34921. t['Courier-Bold'] = 'Courier-Bold';
  34922. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  34923. t['Courier-Italic'] = 'Courier-Oblique';
  34924. t['CourierNew'] = 'Courier';
  34925. t['CourierNew-Bold'] = 'Courier-Bold';
  34926. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  34927. t['CourierNew-Italic'] = 'Courier-Oblique';
  34928. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  34929. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  34930. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  34931. t['CourierNewPSMT'] = 'Courier';
  34932. t['Helvetica'] = 'Helvetica';
  34933. t['Helvetica-Bold'] = 'Helvetica-Bold';
  34934. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  34935. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  34936. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  34937. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  34938. t['Symbol-Bold'] = 'Symbol';
  34939. t['Symbol-BoldItalic'] = 'Symbol';
  34940. t['Symbol-Italic'] = 'Symbol';
  34941. t['TimesNewRoman'] = 'Times-Roman';
  34942. t['TimesNewRoman-Bold'] = 'Times-Bold';
  34943. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  34944. t['TimesNewRoman-Italic'] = 'Times-Italic';
  34945. t['TimesNewRomanPS'] = 'Times-Roman';
  34946. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  34947. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  34948. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  34949. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  34950. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  34951. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  34952. t['TimesNewRomanPSMT'] = 'Times-Roman';
  34953. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  34954. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  34955. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  34956. });
  34957. var getNonStdFontMap = getLookupTableFactory(function (t) {
  34958. t['CenturyGothic'] = 'Helvetica';
  34959. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  34960. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  34961. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  34962. t['ComicSansMS'] = 'Comic Sans MS';
  34963. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  34964. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  34965. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  34966. t['LucidaConsole'] = 'Courier';
  34967. t['LucidaConsole-Bold'] = 'Courier-Bold';
  34968. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  34969. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  34970. t['MS-Gothic'] = 'MS Gothic';
  34971. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  34972. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  34973. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  34974. t['MS-Mincho'] = 'MS Mincho';
  34975. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  34976. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  34977. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  34978. t['MS-PGothic'] = 'MS PGothic';
  34979. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  34980. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  34981. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  34982. t['MS-PMincho'] = 'MS PMincho';
  34983. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  34984. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  34985. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  34986. t['NuptialScript'] = 'Times-Italic';
  34987. t['Wingdings'] = 'ZapfDingbats';
  34988. });
  34989. var getSerifFonts = getLookupTableFactory(function (t) {
  34990. t['Adobe Jenson'] = true;
  34991. t['Adobe Text'] = true;
  34992. t['Albertus'] = true;
  34993. t['Aldus'] = true;
  34994. t['Alexandria'] = true;
  34995. t['Algerian'] = true;
  34996. t['American Typewriter'] = true;
  34997. t['Antiqua'] = true;
  34998. t['Apex'] = true;
  34999. t['Arno'] = true;
  35000. t['Aster'] = true;
  35001. t['Aurora'] = true;
  35002. t['Baskerville'] = true;
  35003. t['Bell'] = true;
  35004. t['Bembo'] = true;
  35005. t['Bembo Schoolbook'] = true;
  35006. t['Benguiat'] = true;
  35007. t['Berkeley Old Style'] = true;
  35008. t['Bernhard Modern'] = true;
  35009. t['Berthold City'] = true;
  35010. t['Bodoni'] = true;
  35011. t['Bauer Bodoni'] = true;
  35012. t['Book Antiqua'] = true;
  35013. t['Bookman'] = true;
  35014. t['Bordeaux Roman'] = true;
  35015. t['Californian FB'] = true;
  35016. t['Calisto'] = true;
  35017. t['Calvert'] = true;
  35018. t['Capitals'] = true;
  35019. t['Cambria'] = true;
  35020. t['Cartier'] = true;
  35021. t['Caslon'] = true;
  35022. t['Catull'] = true;
  35023. t['Centaur'] = true;
  35024. t['Century Old Style'] = true;
  35025. t['Century Schoolbook'] = true;
  35026. t['Chaparral'] = true;
  35027. t['Charis SIL'] = true;
  35028. t['Cheltenham'] = true;
  35029. t['Cholla Slab'] = true;
  35030. t['Clarendon'] = true;
  35031. t['Clearface'] = true;
  35032. t['Cochin'] = true;
  35033. t['Colonna'] = true;
  35034. t['Computer Modern'] = true;
  35035. t['Concrete Roman'] = true;
  35036. t['Constantia'] = true;
  35037. t['Cooper Black'] = true;
  35038. t['Corona'] = true;
  35039. t['Ecotype'] = true;
  35040. t['Egyptienne'] = true;
  35041. t['Elephant'] = true;
  35042. t['Excelsior'] = true;
  35043. t['Fairfield'] = true;
  35044. t['FF Scala'] = true;
  35045. t['Folkard'] = true;
  35046. t['Footlight'] = true;
  35047. t['FreeSerif'] = true;
  35048. t['Friz Quadrata'] = true;
  35049. t['Garamond'] = true;
  35050. t['Gentium'] = true;
  35051. t['Georgia'] = true;
  35052. t['Gloucester'] = true;
  35053. t['Goudy Old Style'] = true;
  35054. t['Goudy Schoolbook'] = true;
  35055. t['Goudy Pro Font'] = true;
  35056. t['Granjon'] = true;
  35057. t['Guardian Egyptian'] = true;
  35058. t['Heather'] = true;
  35059. t['Hercules'] = true;
  35060. t['High Tower Text'] = true;
  35061. t['Hiroshige'] = true;
  35062. t['Hoefler Text'] = true;
  35063. t['Humana Serif'] = true;
  35064. t['Imprint'] = true;
  35065. t['Ionic No. 5'] = true;
  35066. t['Janson'] = true;
  35067. t['Joanna'] = true;
  35068. t['Korinna'] = true;
  35069. t['Lexicon'] = true;
  35070. t['Liberation Serif'] = true;
  35071. t['Linux Libertine'] = true;
  35072. t['Literaturnaya'] = true;
  35073. t['Lucida'] = true;
  35074. t['Lucida Bright'] = true;
  35075. t['Melior'] = true;
  35076. t['Memphis'] = true;
  35077. t['Miller'] = true;
  35078. t['Minion'] = true;
  35079. t['Modern'] = true;
  35080. t['Mona Lisa'] = true;
  35081. t['Mrs Eaves'] = true;
  35082. t['MS Serif'] = true;
  35083. t['Museo Slab'] = true;
  35084. t['New York'] = true;
  35085. t['Nimbus Roman'] = true;
  35086. t['NPS Rawlinson Roadway'] = true;
  35087. t['NuptialScript'] = true;
  35088. t['Palatino'] = true;
  35089. t['Perpetua'] = true;
  35090. t['Plantin'] = true;
  35091. t['Plantin Schoolbook'] = true;
  35092. t['Playbill'] = true;
  35093. t['Poor Richard'] = true;
  35094. t['Rawlinson Roadway'] = true;
  35095. t['Renault'] = true;
  35096. t['Requiem'] = true;
  35097. t['Rockwell'] = true;
  35098. t['Roman'] = true;
  35099. t['Rotis Serif'] = true;
  35100. t['Sabon'] = true;
  35101. t['Scala'] = true;
  35102. t['Seagull'] = true;
  35103. t['Sistina'] = true;
  35104. t['Souvenir'] = true;
  35105. t['STIX'] = true;
  35106. t['Stone Informal'] = true;
  35107. t['Stone Serif'] = true;
  35108. t['Sylfaen'] = true;
  35109. t['Times'] = true;
  35110. t['Trajan'] = true;
  35111. t['Trinité'] = true;
  35112. t['Trump Mediaeval'] = true;
  35113. t['Utopia'] = true;
  35114. t['Vale Type'] = true;
  35115. t['Bitstream Vera'] = true;
  35116. t['Vera Serif'] = true;
  35117. t['Versailles'] = true;
  35118. t['Wanted'] = true;
  35119. t['Weiss'] = true;
  35120. t['Wide Latin'] = true;
  35121. t['Windsor'] = true;
  35122. t['XITS'] = true;
  35123. });
  35124. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35125. t['Dingbats'] = true;
  35126. t['Symbol'] = true;
  35127. t['ZapfDingbats'] = true;
  35128. });
  35129. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35130. t[2] = 10;
  35131. t[3] = 32;
  35132. t[4] = 33;
  35133. t[5] = 34;
  35134. t[6] = 35;
  35135. t[7] = 36;
  35136. t[8] = 37;
  35137. t[9] = 38;
  35138. t[10] = 39;
  35139. t[11] = 40;
  35140. t[12] = 41;
  35141. t[13] = 42;
  35142. t[14] = 43;
  35143. t[15] = 44;
  35144. t[16] = 45;
  35145. t[17] = 46;
  35146. t[18] = 47;
  35147. t[19] = 48;
  35148. t[20] = 49;
  35149. t[21] = 50;
  35150. t[22] = 51;
  35151. t[23] = 52;
  35152. t[24] = 53;
  35153. t[25] = 54;
  35154. t[26] = 55;
  35155. t[27] = 56;
  35156. t[28] = 57;
  35157. t[29] = 58;
  35158. t[30] = 894;
  35159. t[31] = 60;
  35160. t[32] = 61;
  35161. t[33] = 62;
  35162. t[34] = 63;
  35163. t[35] = 64;
  35164. t[36] = 65;
  35165. t[37] = 66;
  35166. t[38] = 67;
  35167. t[39] = 68;
  35168. t[40] = 69;
  35169. t[41] = 70;
  35170. t[42] = 71;
  35171. t[43] = 72;
  35172. t[44] = 73;
  35173. t[45] = 74;
  35174. t[46] = 75;
  35175. t[47] = 76;
  35176. t[48] = 77;
  35177. t[49] = 78;
  35178. t[50] = 79;
  35179. t[51] = 80;
  35180. t[52] = 81;
  35181. t[53] = 82;
  35182. t[54] = 83;
  35183. t[55] = 84;
  35184. t[56] = 85;
  35185. t[57] = 86;
  35186. t[58] = 87;
  35187. t[59] = 88;
  35188. t[60] = 89;
  35189. t[61] = 90;
  35190. t[62] = 91;
  35191. t[63] = 92;
  35192. t[64] = 93;
  35193. t[65] = 94;
  35194. t[66] = 95;
  35195. t[67] = 96;
  35196. t[68] = 97;
  35197. t[69] = 98;
  35198. t[70] = 99;
  35199. t[71] = 100;
  35200. t[72] = 101;
  35201. t[73] = 102;
  35202. t[74] = 103;
  35203. t[75] = 104;
  35204. t[76] = 105;
  35205. t[77] = 106;
  35206. t[78] = 107;
  35207. t[79] = 108;
  35208. t[80] = 109;
  35209. t[81] = 110;
  35210. t[82] = 111;
  35211. t[83] = 112;
  35212. t[84] = 113;
  35213. t[85] = 114;
  35214. t[86] = 115;
  35215. t[87] = 116;
  35216. t[88] = 117;
  35217. t[89] = 118;
  35218. t[90] = 119;
  35219. t[91] = 120;
  35220. t[92] = 121;
  35221. t[93] = 122;
  35222. t[94] = 123;
  35223. t[95] = 124;
  35224. t[96] = 125;
  35225. t[97] = 126;
  35226. t[98] = 196;
  35227. t[99] = 197;
  35228. t[100] = 199;
  35229. t[101] = 201;
  35230. t[102] = 209;
  35231. t[103] = 214;
  35232. t[104] = 220;
  35233. t[105] = 225;
  35234. t[106] = 224;
  35235. t[107] = 226;
  35236. t[108] = 228;
  35237. t[109] = 227;
  35238. t[110] = 229;
  35239. t[111] = 231;
  35240. t[112] = 233;
  35241. t[113] = 232;
  35242. t[114] = 234;
  35243. t[115] = 235;
  35244. t[116] = 237;
  35245. t[117] = 236;
  35246. t[118] = 238;
  35247. t[119] = 239;
  35248. t[120] = 241;
  35249. t[121] = 243;
  35250. t[122] = 242;
  35251. t[123] = 244;
  35252. t[124] = 246;
  35253. t[125] = 245;
  35254. t[126] = 250;
  35255. t[127] = 249;
  35256. t[128] = 251;
  35257. t[129] = 252;
  35258. t[130] = 8224;
  35259. t[131] = 176;
  35260. t[132] = 162;
  35261. t[133] = 163;
  35262. t[134] = 167;
  35263. t[135] = 8226;
  35264. t[136] = 182;
  35265. t[137] = 223;
  35266. t[138] = 174;
  35267. t[139] = 169;
  35268. t[140] = 8482;
  35269. t[141] = 180;
  35270. t[142] = 168;
  35271. t[143] = 8800;
  35272. t[144] = 198;
  35273. t[145] = 216;
  35274. t[146] = 8734;
  35275. t[147] = 177;
  35276. t[148] = 8804;
  35277. t[149] = 8805;
  35278. t[150] = 165;
  35279. t[151] = 181;
  35280. t[152] = 8706;
  35281. t[153] = 8721;
  35282. t[154] = 8719;
  35283. t[156] = 8747;
  35284. t[157] = 170;
  35285. t[158] = 186;
  35286. t[159] = 8486;
  35287. t[160] = 230;
  35288. t[161] = 248;
  35289. t[162] = 191;
  35290. t[163] = 161;
  35291. t[164] = 172;
  35292. t[165] = 8730;
  35293. t[166] = 402;
  35294. t[167] = 8776;
  35295. t[168] = 8710;
  35296. t[169] = 171;
  35297. t[170] = 187;
  35298. t[171] = 8230;
  35299. t[210] = 218;
  35300. t[223] = 711;
  35301. t[224] = 321;
  35302. t[225] = 322;
  35303. t[227] = 353;
  35304. t[229] = 382;
  35305. t[234] = 253;
  35306. t[252] = 263;
  35307. t[253] = 268;
  35308. t[254] = 269;
  35309. t[258] = 258;
  35310. t[260] = 260;
  35311. t[261] = 261;
  35312. t[265] = 280;
  35313. t[266] = 281;
  35314. t[268] = 283;
  35315. t[269] = 313;
  35316. t[275] = 323;
  35317. t[276] = 324;
  35318. t[278] = 328;
  35319. t[284] = 345;
  35320. t[285] = 346;
  35321. t[286] = 347;
  35322. t[292] = 367;
  35323. t[295] = 377;
  35324. t[296] = 378;
  35325. t[298] = 380;
  35326. t[305] = 963;
  35327. t[306] = 964;
  35328. t[307] = 966;
  35329. t[308] = 8215;
  35330. t[309] = 8252;
  35331. t[310] = 8319;
  35332. t[311] = 8359;
  35333. t[312] = 8592;
  35334. t[313] = 8593;
  35335. t[337] = 9552;
  35336. t[493] = 1039;
  35337. t[494] = 1040;
  35338. t[705] = 1524;
  35339. t[706] = 8362;
  35340. t[710] = 64288;
  35341. t[711] = 64298;
  35342. t[759] = 1617;
  35343. t[761] = 1776;
  35344. t[763] = 1778;
  35345. t[775] = 1652;
  35346. t[777] = 1764;
  35347. t[778] = 1780;
  35348. t[779] = 1781;
  35349. t[780] = 1782;
  35350. t[782] = 771;
  35351. t[783] = 64726;
  35352. t[786] = 8363;
  35353. t[788] = 8532;
  35354. t[790] = 768;
  35355. t[791] = 769;
  35356. t[792] = 768;
  35357. t[795] = 803;
  35358. t[797] = 64336;
  35359. t[798] = 64337;
  35360. t[799] = 64342;
  35361. t[800] = 64343;
  35362. t[801] = 64344;
  35363. t[802] = 64345;
  35364. t[803] = 64362;
  35365. t[804] = 64363;
  35366. t[805] = 64364;
  35367. t[2424] = 7821;
  35368. t[2425] = 7822;
  35369. t[2426] = 7823;
  35370. t[2427] = 7824;
  35371. t[2428] = 7825;
  35372. t[2429] = 7826;
  35373. t[2430] = 7827;
  35374. t[2433] = 7682;
  35375. t[2678] = 8045;
  35376. t[2679] = 8046;
  35377. t[2830] = 1552;
  35378. t[2838] = 686;
  35379. t[2840] = 751;
  35380. t[2842] = 753;
  35381. t[2843] = 754;
  35382. t[2844] = 755;
  35383. t[2846] = 757;
  35384. t[2856] = 767;
  35385. t[2857] = 848;
  35386. t[2858] = 849;
  35387. t[2862] = 853;
  35388. t[2863] = 854;
  35389. t[2864] = 855;
  35390. t[2865] = 861;
  35391. t[2866] = 862;
  35392. t[2906] = 7460;
  35393. t[2908] = 7462;
  35394. t[2909] = 7463;
  35395. t[2910] = 7464;
  35396. t[2912] = 7466;
  35397. t[2913] = 7467;
  35398. t[2914] = 7468;
  35399. t[2916] = 7470;
  35400. t[2917] = 7471;
  35401. t[2918] = 7472;
  35402. t[2920] = 7474;
  35403. t[2921] = 7475;
  35404. t[2922] = 7476;
  35405. t[2924] = 7478;
  35406. t[2925] = 7479;
  35407. t[2926] = 7480;
  35408. t[2928] = 7482;
  35409. t[2929] = 7483;
  35410. t[2930] = 7484;
  35411. t[2932] = 7486;
  35412. t[2933] = 7487;
  35413. t[2934] = 7488;
  35414. t[2936] = 7490;
  35415. t[2937] = 7491;
  35416. t[2938] = 7492;
  35417. t[2940] = 7494;
  35418. t[2941] = 7495;
  35419. t[2942] = 7496;
  35420. t[2944] = 7498;
  35421. t[2946] = 7500;
  35422. t[2948] = 7502;
  35423. t[2950] = 7504;
  35424. t[2951] = 7505;
  35425. t[2952] = 7506;
  35426. t[2954] = 7508;
  35427. t[2955] = 7509;
  35428. t[2956] = 7510;
  35429. t[2958] = 7512;
  35430. t[2959] = 7513;
  35431. t[2960] = 7514;
  35432. t[2962] = 7516;
  35433. t[2963] = 7517;
  35434. t[2964] = 7518;
  35435. t[2966] = 7520;
  35436. t[2967] = 7521;
  35437. t[2968] = 7522;
  35438. t[2970] = 7524;
  35439. t[2971] = 7525;
  35440. t[2972] = 7526;
  35441. t[2974] = 7528;
  35442. t[2975] = 7529;
  35443. t[2976] = 7530;
  35444. t[2978] = 1537;
  35445. t[2979] = 1538;
  35446. t[2980] = 1539;
  35447. t[2982] = 1549;
  35448. t[2983] = 1551;
  35449. t[2984] = 1552;
  35450. t[2986] = 1554;
  35451. t[2987] = 1555;
  35452. t[2988] = 1556;
  35453. t[2990] = 1623;
  35454. t[2991] = 1624;
  35455. t[2995] = 1775;
  35456. t[2999] = 1791;
  35457. t[3002] = 64290;
  35458. t[3003] = 64291;
  35459. t[3004] = 64292;
  35460. t[3006] = 64294;
  35461. t[3007] = 64295;
  35462. t[3008] = 64296;
  35463. t[3011] = 1900;
  35464. t[3014] = 8223;
  35465. t[3015] = 8244;
  35466. t[3017] = 7532;
  35467. t[3018] = 7533;
  35468. t[3019] = 7534;
  35469. t[3075] = 7590;
  35470. t[3076] = 7591;
  35471. t[3079] = 7594;
  35472. t[3080] = 7595;
  35473. t[3083] = 7598;
  35474. t[3084] = 7599;
  35475. t[3087] = 7602;
  35476. t[3088] = 7603;
  35477. t[3091] = 7606;
  35478. t[3092] = 7607;
  35479. t[3095] = 7610;
  35480. t[3096] = 7611;
  35481. t[3099] = 7614;
  35482. t[3100] = 7615;
  35483. t[3103] = 7618;
  35484. t[3104] = 7619;
  35485. t[3107] = 8337;
  35486. t[3108] = 8338;
  35487. t[3116] = 1884;
  35488. t[3119] = 1885;
  35489. t[3120] = 1885;
  35490. t[3123] = 1886;
  35491. t[3124] = 1886;
  35492. t[3127] = 1887;
  35493. t[3128] = 1887;
  35494. t[3131] = 1888;
  35495. t[3132] = 1888;
  35496. t[3135] = 1889;
  35497. t[3136] = 1889;
  35498. t[3139] = 1890;
  35499. t[3140] = 1890;
  35500. t[3143] = 1891;
  35501. t[3144] = 1891;
  35502. t[3147] = 1892;
  35503. t[3148] = 1892;
  35504. t[3153] = 580;
  35505. t[3154] = 581;
  35506. t[3157] = 584;
  35507. t[3158] = 585;
  35508. t[3161] = 588;
  35509. t[3162] = 589;
  35510. t[3165] = 891;
  35511. t[3166] = 892;
  35512. t[3169] = 1274;
  35513. t[3170] = 1275;
  35514. t[3173] = 1278;
  35515. t[3174] = 1279;
  35516. t[3181] = 7622;
  35517. t[3182] = 7623;
  35518. t[3282] = 11799;
  35519. t[3316] = 578;
  35520. t[3379] = 42785;
  35521. t[3393] = 1159;
  35522. t[3416] = 8377;
  35523. });
  35524. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  35525. t[227] = 322;
  35526. t[264] = 261;
  35527. t[291] = 346;
  35528. });
  35529. exports.getStdFontMap = getStdFontMap;
  35530. exports.getNonStdFontMap = getNonStdFontMap;
  35531. exports.getSerifFonts = getSerifFonts;
  35532. exports.getSymbolsFonts = getSymbolsFonts;
  35533. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  35534. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  35535. /***/ }),
  35536. /* 22 */
  35537. /***/ (function(module, exports, __w_pdfjs_require__) {
  35538. "use strict";
  35539. var sharedUtil = __w_pdfjs_require__(0);
  35540. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35541. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  35542. t[63721] = 0x00A9;
  35543. t[63193] = 0x00A9;
  35544. t[63720] = 0x00AE;
  35545. t[63194] = 0x00AE;
  35546. t[63722] = 0x2122;
  35547. t[63195] = 0x2122;
  35548. t[63729] = 0x23A7;
  35549. t[63730] = 0x23A8;
  35550. t[63731] = 0x23A9;
  35551. t[63740] = 0x23AB;
  35552. t[63741] = 0x23AC;
  35553. t[63742] = 0x23AD;
  35554. t[63726] = 0x23A1;
  35555. t[63727] = 0x23A2;
  35556. t[63728] = 0x23A3;
  35557. t[63737] = 0x23A4;
  35558. t[63738] = 0x23A5;
  35559. t[63739] = 0x23A6;
  35560. t[63723] = 0x239B;
  35561. t[63724] = 0x239C;
  35562. t[63725] = 0x239D;
  35563. t[63734] = 0x239E;
  35564. t[63735] = 0x239F;
  35565. t[63736] = 0x23A0;
  35566. });
  35567. function mapSpecialUnicodeValues(code) {
  35568. if (code >= 0xFFF0 && code <= 0xFFFF) {
  35569. return 0;
  35570. } else if (code >= 0xF600 && code <= 0xF8FF) {
  35571. return getSpecialPUASymbols()[code] || code;
  35572. }
  35573. return code;
  35574. }
  35575. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  35576. var unicode = glyphsUnicodeMap[name];
  35577. if (unicode !== undefined) {
  35578. return unicode;
  35579. }
  35580. if (!name) {
  35581. return -1;
  35582. }
  35583. if (name[0] === 'u') {
  35584. var nameLen = name.length, hexStr;
  35585. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  35586. hexStr = name.substr(3);
  35587. } else if (nameLen >= 5 && nameLen <= 7) {
  35588. hexStr = name.substr(1);
  35589. } else {
  35590. return -1;
  35591. }
  35592. if (hexStr === hexStr.toUpperCase()) {
  35593. unicode = parseInt(hexStr, 16);
  35594. if (unicode >= 0) {
  35595. return unicode;
  35596. }
  35597. }
  35598. }
  35599. return -1;
  35600. }
  35601. var UnicodeRanges = [
  35602. {
  35603. 'begin': 0x0000,
  35604. 'end': 0x007F
  35605. },
  35606. {
  35607. 'begin': 0x0080,
  35608. 'end': 0x00FF
  35609. },
  35610. {
  35611. 'begin': 0x0100,
  35612. 'end': 0x017F
  35613. },
  35614. {
  35615. 'begin': 0x0180,
  35616. 'end': 0x024F
  35617. },
  35618. {
  35619. 'begin': 0x0250,
  35620. 'end': 0x02AF
  35621. },
  35622. {
  35623. 'begin': 0x02B0,
  35624. 'end': 0x02FF
  35625. },
  35626. {
  35627. 'begin': 0x0300,
  35628. 'end': 0x036F
  35629. },
  35630. {
  35631. 'begin': 0x0370,
  35632. 'end': 0x03FF
  35633. },
  35634. {
  35635. 'begin': 0x2C80,
  35636. 'end': 0x2CFF
  35637. },
  35638. {
  35639. 'begin': 0x0400,
  35640. 'end': 0x04FF
  35641. },
  35642. {
  35643. 'begin': 0x0530,
  35644. 'end': 0x058F
  35645. },
  35646. {
  35647. 'begin': 0x0590,
  35648. 'end': 0x05FF
  35649. },
  35650. {
  35651. 'begin': 0xA500,
  35652. 'end': 0xA63F
  35653. },
  35654. {
  35655. 'begin': 0x0600,
  35656. 'end': 0x06FF
  35657. },
  35658. {
  35659. 'begin': 0x07C0,
  35660. 'end': 0x07FF
  35661. },
  35662. {
  35663. 'begin': 0x0900,
  35664. 'end': 0x097F
  35665. },
  35666. {
  35667. 'begin': 0x0980,
  35668. 'end': 0x09FF
  35669. },
  35670. {
  35671. 'begin': 0x0A00,
  35672. 'end': 0x0A7F
  35673. },
  35674. {
  35675. 'begin': 0x0A80,
  35676. 'end': 0x0AFF
  35677. },
  35678. {
  35679. 'begin': 0x0B00,
  35680. 'end': 0x0B7F
  35681. },
  35682. {
  35683. 'begin': 0x0B80,
  35684. 'end': 0x0BFF
  35685. },
  35686. {
  35687. 'begin': 0x0C00,
  35688. 'end': 0x0C7F
  35689. },
  35690. {
  35691. 'begin': 0x0C80,
  35692. 'end': 0x0CFF
  35693. },
  35694. {
  35695. 'begin': 0x0D00,
  35696. 'end': 0x0D7F
  35697. },
  35698. {
  35699. 'begin': 0x0E00,
  35700. 'end': 0x0E7F
  35701. },
  35702. {
  35703. 'begin': 0x0E80,
  35704. 'end': 0x0EFF
  35705. },
  35706. {
  35707. 'begin': 0x10A0,
  35708. 'end': 0x10FF
  35709. },
  35710. {
  35711. 'begin': 0x1B00,
  35712. 'end': 0x1B7F
  35713. },
  35714. {
  35715. 'begin': 0x1100,
  35716. 'end': 0x11FF
  35717. },
  35718. {
  35719. 'begin': 0x1E00,
  35720. 'end': 0x1EFF
  35721. },
  35722. {
  35723. 'begin': 0x1F00,
  35724. 'end': 0x1FFF
  35725. },
  35726. {
  35727. 'begin': 0x2000,
  35728. 'end': 0x206F
  35729. },
  35730. {
  35731. 'begin': 0x2070,
  35732. 'end': 0x209F
  35733. },
  35734. {
  35735. 'begin': 0x20A0,
  35736. 'end': 0x20CF
  35737. },
  35738. {
  35739. 'begin': 0x20D0,
  35740. 'end': 0x20FF
  35741. },
  35742. {
  35743. 'begin': 0x2100,
  35744. 'end': 0x214F
  35745. },
  35746. {
  35747. 'begin': 0x2150,
  35748. 'end': 0x218F
  35749. },
  35750. {
  35751. 'begin': 0x2190,
  35752. 'end': 0x21FF
  35753. },
  35754. {
  35755. 'begin': 0x2200,
  35756. 'end': 0x22FF
  35757. },
  35758. {
  35759. 'begin': 0x2300,
  35760. 'end': 0x23FF
  35761. },
  35762. {
  35763. 'begin': 0x2400,
  35764. 'end': 0x243F
  35765. },
  35766. {
  35767. 'begin': 0x2440,
  35768. 'end': 0x245F
  35769. },
  35770. {
  35771. 'begin': 0x2460,
  35772. 'end': 0x24FF
  35773. },
  35774. {
  35775. 'begin': 0x2500,
  35776. 'end': 0x257F
  35777. },
  35778. {
  35779. 'begin': 0x2580,
  35780. 'end': 0x259F
  35781. },
  35782. {
  35783. 'begin': 0x25A0,
  35784. 'end': 0x25FF
  35785. },
  35786. {
  35787. 'begin': 0x2600,
  35788. 'end': 0x26FF
  35789. },
  35790. {
  35791. 'begin': 0x2700,
  35792. 'end': 0x27BF
  35793. },
  35794. {
  35795. 'begin': 0x3000,
  35796. 'end': 0x303F
  35797. },
  35798. {
  35799. 'begin': 0x3040,
  35800. 'end': 0x309F
  35801. },
  35802. {
  35803. 'begin': 0x30A0,
  35804. 'end': 0x30FF
  35805. },
  35806. {
  35807. 'begin': 0x3100,
  35808. 'end': 0x312F
  35809. },
  35810. {
  35811. 'begin': 0x3130,
  35812. 'end': 0x318F
  35813. },
  35814. {
  35815. 'begin': 0xA840,
  35816. 'end': 0xA87F
  35817. },
  35818. {
  35819. 'begin': 0x3200,
  35820. 'end': 0x32FF
  35821. },
  35822. {
  35823. 'begin': 0x3300,
  35824. 'end': 0x33FF
  35825. },
  35826. {
  35827. 'begin': 0xAC00,
  35828. 'end': 0xD7AF
  35829. },
  35830. {
  35831. 'begin': 0xD800,
  35832. 'end': 0xDFFF
  35833. },
  35834. {
  35835. 'begin': 0x10900,
  35836. 'end': 0x1091F
  35837. },
  35838. {
  35839. 'begin': 0x4E00,
  35840. 'end': 0x9FFF
  35841. },
  35842. {
  35843. 'begin': 0xE000,
  35844. 'end': 0xF8FF
  35845. },
  35846. {
  35847. 'begin': 0x31C0,
  35848. 'end': 0x31EF
  35849. },
  35850. {
  35851. 'begin': 0xFB00,
  35852. 'end': 0xFB4F
  35853. },
  35854. {
  35855. 'begin': 0xFB50,
  35856. 'end': 0xFDFF
  35857. },
  35858. {
  35859. 'begin': 0xFE20,
  35860. 'end': 0xFE2F
  35861. },
  35862. {
  35863. 'begin': 0xFE10,
  35864. 'end': 0xFE1F
  35865. },
  35866. {
  35867. 'begin': 0xFE50,
  35868. 'end': 0xFE6F
  35869. },
  35870. {
  35871. 'begin': 0xFE70,
  35872. 'end': 0xFEFF
  35873. },
  35874. {
  35875. 'begin': 0xFF00,
  35876. 'end': 0xFFEF
  35877. },
  35878. {
  35879. 'begin': 0xFFF0,
  35880. 'end': 0xFFFF
  35881. },
  35882. {
  35883. 'begin': 0x0F00,
  35884. 'end': 0x0FFF
  35885. },
  35886. {
  35887. 'begin': 0x0700,
  35888. 'end': 0x074F
  35889. },
  35890. {
  35891. 'begin': 0x0780,
  35892. 'end': 0x07BF
  35893. },
  35894. {
  35895. 'begin': 0x0D80,
  35896. 'end': 0x0DFF
  35897. },
  35898. {
  35899. 'begin': 0x1000,
  35900. 'end': 0x109F
  35901. },
  35902. {
  35903. 'begin': 0x1200,
  35904. 'end': 0x137F
  35905. },
  35906. {
  35907. 'begin': 0x13A0,
  35908. 'end': 0x13FF
  35909. },
  35910. {
  35911. 'begin': 0x1400,
  35912. 'end': 0x167F
  35913. },
  35914. {
  35915. 'begin': 0x1680,
  35916. 'end': 0x169F
  35917. },
  35918. {
  35919. 'begin': 0x16A0,
  35920. 'end': 0x16FF
  35921. },
  35922. {
  35923. 'begin': 0x1780,
  35924. 'end': 0x17FF
  35925. },
  35926. {
  35927. 'begin': 0x1800,
  35928. 'end': 0x18AF
  35929. },
  35930. {
  35931. 'begin': 0x2800,
  35932. 'end': 0x28FF
  35933. },
  35934. {
  35935. 'begin': 0xA000,
  35936. 'end': 0xA48F
  35937. },
  35938. {
  35939. 'begin': 0x1700,
  35940. 'end': 0x171F
  35941. },
  35942. {
  35943. 'begin': 0x10300,
  35944. 'end': 0x1032F
  35945. },
  35946. {
  35947. 'begin': 0x10330,
  35948. 'end': 0x1034F
  35949. },
  35950. {
  35951. 'begin': 0x10400,
  35952. 'end': 0x1044F
  35953. },
  35954. {
  35955. 'begin': 0x1D000,
  35956. 'end': 0x1D0FF
  35957. },
  35958. {
  35959. 'begin': 0x1D400,
  35960. 'end': 0x1D7FF
  35961. },
  35962. {
  35963. 'begin': 0xFF000,
  35964. 'end': 0xFFFFD
  35965. },
  35966. {
  35967. 'begin': 0xFE00,
  35968. 'end': 0xFE0F
  35969. },
  35970. {
  35971. 'begin': 0xE0000,
  35972. 'end': 0xE007F
  35973. },
  35974. {
  35975. 'begin': 0x1900,
  35976. 'end': 0x194F
  35977. },
  35978. {
  35979. 'begin': 0x1950,
  35980. 'end': 0x197F
  35981. },
  35982. {
  35983. 'begin': 0x1980,
  35984. 'end': 0x19DF
  35985. },
  35986. {
  35987. 'begin': 0x1A00,
  35988. 'end': 0x1A1F
  35989. },
  35990. {
  35991. 'begin': 0x2C00,
  35992. 'end': 0x2C5F
  35993. },
  35994. {
  35995. 'begin': 0x2D30,
  35996. 'end': 0x2D7F
  35997. },
  35998. {
  35999. 'begin': 0x4DC0,
  36000. 'end': 0x4DFF
  36001. },
  36002. {
  36003. 'begin': 0xA800,
  36004. 'end': 0xA82F
  36005. },
  36006. {
  36007. 'begin': 0x10000,
  36008. 'end': 0x1007F
  36009. },
  36010. {
  36011. 'begin': 0x10140,
  36012. 'end': 0x1018F
  36013. },
  36014. {
  36015. 'begin': 0x10380,
  36016. 'end': 0x1039F
  36017. },
  36018. {
  36019. 'begin': 0x103A0,
  36020. 'end': 0x103DF
  36021. },
  36022. {
  36023. 'begin': 0x10450,
  36024. 'end': 0x1047F
  36025. },
  36026. {
  36027. 'begin': 0x10480,
  36028. 'end': 0x104AF
  36029. },
  36030. {
  36031. 'begin': 0x10800,
  36032. 'end': 0x1083F
  36033. },
  36034. {
  36035. 'begin': 0x10A00,
  36036. 'end': 0x10A5F
  36037. },
  36038. {
  36039. 'begin': 0x1D300,
  36040. 'end': 0x1D35F
  36041. },
  36042. {
  36043. 'begin': 0x12000,
  36044. 'end': 0x123FF
  36045. },
  36046. {
  36047. 'begin': 0x1D360,
  36048. 'end': 0x1D37F
  36049. },
  36050. {
  36051. 'begin': 0x1B80,
  36052. 'end': 0x1BBF
  36053. },
  36054. {
  36055. 'begin': 0x1C00,
  36056. 'end': 0x1C4F
  36057. },
  36058. {
  36059. 'begin': 0x1C50,
  36060. 'end': 0x1C7F
  36061. },
  36062. {
  36063. 'begin': 0xA880,
  36064. 'end': 0xA8DF
  36065. },
  36066. {
  36067. 'begin': 0xA900,
  36068. 'end': 0xA92F
  36069. },
  36070. {
  36071. 'begin': 0xA930,
  36072. 'end': 0xA95F
  36073. },
  36074. {
  36075. 'begin': 0xAA00,
  36076. 'end': 0xAA5F
  36077. },
  36078. {
  36079. 'begin': 0x10190,
  36080. 'end': 0x101CF
  36081. },
  36082. {
  36083. 'begin': 0x101D0,
  36084. 'end': 0x101FF
  36085. },
  36086. {
  36087. 'begin': 0x102A0,
  36088. 'end': 0x102DF
  36089. },
  36090. {
  36091. 'begin': 0x1F030,
  36092. 'end': 0x1F09F
  36093. }
  36094. ];
  36095. function getUnicodeRangeFor(value) {
  36096. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36097. var range = UnicodeRanges[i];
  36098. if (value >= range.begin && value < range.end) {
  36099. return i;
  36100. }
  36101. }
  36102. return -1;
  36103. }
  36104. function isRTLRangeFor(value) {
  36105. var range = UnicodeRanges[13];
  36106. if (value >= range.begin && value < range.end) {
  36107. return true;
  36108. }
  36109. range = UnicodeRanges[11];
  36110. if (value >= range.begin && value < range.end) {
  36111. return true;
  36112. }
  36113. return false;
  36114. }
  36115. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36116. t['\u00A8'] = '\u0020\u0308';
  36117. t['\u00AF'] = '\u0020\u0304';
  36118. t['\u00B4'] = '\u0020\u0301';
  36119. t['\u00B5'] = '\u03BC';
  36120. t['\u00B8'] = '\u0020\u0327';
  36121. t['\u0132'] = '\u0049\u004A';
  36122. t['\u0133'] = '\u0069\u006A';
  36123. t['\u013F'] = '\u004C\u00B7';
  36124. t['\u0140'] = '\u006C\u00B7';
  36125. t['\u0149'] = '\u02BC\u006E';
  36126. t['\u017F'] = '\u0073';
  36127. t['\u01C4'] = '\u0044\u017D';
  36128. t['\u01C5'] = '\u0044\u017E';
  36129. t['\u01C6'] = '\u0064\u017E';
  36130. t['\u01C7'] = '\u004C\u004A';
  36131. t['\u01C8'] = '\u004C\u006A';
  36132. t['\u01C9'] = '\u006C\u006A';
  36133. t['\u01CA'] = '\u004E\u004A';
  36134. t['\u01CB'] = '\u004E\u006A';
  36135. t['\u01CC'] = '\u006E\u006A';
  36136. t['\u01F1'] = '\u0044\u005A';
  36137. t['\u01F2'] = '\u0044\u007A';
  36138. t['\u01F3'] = '\u0064\u007A';
  36139. t['\u02D8'] = '\u0020\u0306';
  36140. t['\u02D9'] = '\u0020\u0307';
  36141. t['\u02DA'] = '\u0020\u030A';
  36142. t['\u02DB'] = '\u0020\u0328';
  36143. t['\u02DC'] = '\u0020\u0303';
  36144. t['\u02DD'] = '\u0020\u030B';
  36145. t['\u037A'] = '\u0020\u0345';
  36146. t['\u0384'] = '\u0020\u0301';
  36147. t['\u03D0'] = '\u03B2';
  36148. t['\u03D1'] = '\u03B8';
  36149. t['\u03D2'] = '\u03A5';
  36150. t['\u03D5'] = '\u03C6';
  36151. t['\u03D6'] = '\u03C0';
  36152. t['\u03F0'] = '\u03BA';
  36153. t['\u03F1'] = '\u03C1';
  36154. t['\u03F2'] = '\u03C2';
  36155. t['\u03F4'] = '\u0398';
  36156. t['\u03F5'] = '\u03B5';
  36157. t['\u03F9'] = '\u03A3';
  36158. t['\u0587'] = '\u0565\u0582';
  36159. t['\u0675'] = '\u0627\u0674';
  36160. t['\u0676'] = '\u0648\u0674';
  36161. t['\u0677'] = '\u06C7\u0674';
  36162. t['\u0678'] = '\u064A\u0674';
  36163. t['\u0E33'] = '\u0E4D\u0E32';
  36164. t['\u0EB3'] = '\u0ECD\u0EB2';
  36165. t['\u0EDC'] = '\u0EAB\u0E99';
  36166. t['\u0EDD'] = '\u0EAB\u0EA1';
  36167. t['\u0F77'] = '\u0FB2\u0F81';
  36168. t['\u0F79'] = '\u0FB3\u0F81';
  36169. t['\u1E9A'] = '\u0061\u02BE';
  36170. t['\u1FBD'] = '\u0020\u0313';
  36171. t['\u1FBF'] = '\u0020\u0313';
  36172. t['\u1FC0'] = '\u0020\u0342';
  36173. t['\u1FFE'] = '\u0020\u0314';
  36174. t['\u2002'] = '\u0020';
  36175. t['\u2003'] = '\u0020';
  36176. t['\u2004'] = '\u0020';
  36177. t['\u2005'] = '\u0020';
  36178. t['\u2006'] = '\u0020';
  36179. t['\u2008'] = '\u0020';
  36180. t['\u2009'] = '\u0020';
  36181. t['\u200A'] = '\u0020';
  36182. t['\u2017'] = '\u0020\u0333';
  36183. t['\u2024'] = '\u002E';
  36184. t['\u2025'] = '\u002E\u002E';
  36185. t['\u2026'] = '\u002E\u002E\u002E';
  36186. t['\u2033'] = '\u2032\u2032';
  36187. t['\u2034'] = '\u2032\u2032\u2032';
  36188. t['\u2036'] = '\u2035\u2035';
  36189. t['\u2037'] = '\u2035\u2035\u2035';
  36190. t['\u203C'] = '\u0021\u0021';
  36191. t['\u203E'] = '\u0020\u0305';
  36192. t['\u2047'] = '\u003F\u003F';
  36193. t['\u2048'] = '\u003F\u0021';
  36194. t['\u2049'] = '\u0021\u003F';
  36195. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36196. t['\u205F'] = '\u0020';
  36197. t['\u20A8'] = '\u0052\u0073';
  36198. t['\u2100'] = '\u0061\u002F\u0063';
  36199. t['\u2101'] = '\u0061\u002F\u0073';
  36200. t['\u2103'] = '\u00B0\u0043';
  36201. t['\u2105'] = '\u0063\u002F\u006F';
  36202. t['\u2106'] = '\u0063\u002F\u0075';
  36203. t['\u2107'] = '\u0190';
  36204. t['\u2109'] = '\u00B0\u0046';
  36205. t['\u2116'] = '\u004E\u006F';
  36206. t['\u2121'] = '\u0054\u0045\u004C';
  36207. t['\u2135'] = '\u05D0';
  36208. t['\u2136'] = '\u05D1';
  36209. t['\u2137'] = '\u05D2';
  36210. t['\u2138'] = '\u05D3';
  36211. t['\u213B'] = '\u0046\u0041\u0058';
  36212. t['\u2160'] = '\u0049';
  36213. t['\u2161'] = '\u0049\u0049';
  36214. t['\u2162'] = '\u0049\u0049\u0049';
  36215. t['\u2163'] = '\u0049\u0056';
  36216. t['\u2164'] = '\u0056';
  36217. t['\u2165'] = '\u0056\u0049';
  36218. t['\u2166'] = '\u0056\u0049\u0049';
  36219. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36220. t['\u2168'] = '\u0049\u0058';
  36221. t['\u2169'] = '\u0058';
  36222. t['\u216A'] = '\u0058\u0049';
  36223. t['\u216B'] = '\u0058\u0049\u0049';
  36224. t['\u216C'] = '\u004C';
  36225. t['\u216D'] = '\u0043';
  36226. t['\u216E'] = '\u0044';
  36227. t['\u216F'] = '\u004D';
  36228. t['\u2170'] = '\u0069';
  36229. t['\u2171'] = '\u0069\u0069';
  36230. t['\u2172'] = '\u0069\u0069\u0069';
  36231. t['\u2173'] = '\u0069\u0076';
  36232. t['\u2174'] = '\u0076';
  36233. t['\u2175'] = '\u0076\u0069';
  36234. t['\u2176'] = '\u0076\u0069\u0069';
  36235. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36236. t['\u2178'] = '\u0069\u0078';
  36237. t['\u2179'] = '\u0078';
  36238. t['\u217A'] = '\u0078\u0069';
  36239. t['\u217B'] = '\u0078\u0069\u0069';
  36240. t['\u217C'] = '\u006C';
  36241. t['\u217D'] = '\u0063';
  36242. t['\u217E'] = '\u0064';
  36243. t['\u217F'] = '\u006D';
  36244. t['\u222C'] = '\u222B\u222B';
  36245. t['\u222D'] = '\u222B\u222B\u222B';
  36246. t['\u222F'] = '\u222E\u222E';
  36247. t['\u2230'] = '\u222E\u222E\u222E';
  36248. t['\u2474'] = '\u0028\u0031\u0029';
  36249. t['\u2475'] = '\u0028\u0032\u0029';
  36250. t['\u2476'] = '\u0028\u0033\u0029';
  36251. t['\u2477'] = '\u0028\u0034\u0029';
  36252. t['\u2478'] = '\u0028\u0035\u0029';
  36253. t['\u2479'] = '\u0028\u0036\u0029';
  36254. t['\u247A'] = '\u0028\u0037\u0029';
  36255. t['\u247B'] = '\u0028\u0038\u0029';
  36256. t['\u247C'] = '\u0028\u0039\u0029';
  36257. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36258. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36259. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36260. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36261. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36262. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36263. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36264. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36265. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36266. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36267. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  36268. t['\u2488'] = '\u0031\u002E';
  36269. t['\u2489'] = '\u0032\u002E';
  36270. t['\u248A'] = '\u0033\u002E';
  36271. t['\u248B'] = '\u0034\u002E';
  36272. t['\u248C'] = '\u0035\u002E';
  36273. t['\u248D'] = '\u0036\u002E';
  36274. t['\u248E'] = '\u0037\u002E';
  36275. t['\u248F'] = '\u0038\u002E';
  36276. t['\u2490'] = '\u0039\u002E';
  36277. t['\u2491'] = '\u0031\u0030\u002E';
  36278. t['\u2492'] = '\u0031\u0031\u002E';
  36279. t['\u2493'] = '\u0031\u0032\u002E';
  36280. t['\u2494'] = '\u0031\u0033\u002E';
  36281. t['\u2495'] = '\u0031\u0034\u002E';
  36282. t['\u2496'] = '\u0031\u0035\u002E';
  36283. t['\u2497'] = '\u0031\u0036\u002E';
  36284. t['\u2498'] = '\u0031\u0037\u002E';
  36285. t['\u2499'] = '\u0031\u0038\u002E';
  36286. t['\u249A'] = '\u0031\u0039\u002E';
  36287. t['\u249B'] = '\u0032\u0030\u002E';
  36288. t['\u249C'] = '\u0028\u0061\u0029';
  36289. t['\u249D'] = '\u0028\u0062\u0029';
  36290. t['\u249E'] = '\u0028\u0063\u0029';
  36291. t['\u249F'] = '\u0028\u0064\u0029';
  36292. t['\u24A0'] = '\u0028\u0065\u0029';
  36293. t['\u24A1'] = '\u0028\u0066\u0029';
  36294. t['\u24A2'] = '\u0028\u0067\u0029';
  36295. t['\u24A3'] = '\u0028\u0068\u0029';
  36296. t['\u24A4'] = '\u0028\u0069\u0029';
  36297. t['\u24A5'] = '\u0028\u006A\u0029';
  36298. t['\u24A6'] = '\u0028\u006B\u0029';
  36299. t['\u24A7'] = '\u0028\u006C\u0029';
  36300. t['\u24A8'] = '\u0028\u006D\u0029';
  36301. t['\u24A9'] = '\u0028\u006E\u0029';
  36302. t['\u24AA'] = '\u0028\u006F\u0029';
  36303. t['\u24AB'] = '\u0028\u0070\u0029';
  36304. t['\u24AC'] = '\u0028\u0071\u0029';
  36305. t['\u24AD'] = '\u0028\u0072\u0029';
  36306. t['\u24AE'] = '\u0028\u0073\u0029';
  36307. t['\u24AF'] = '\u0028\u0074\u0029';
  36308. t['\u24B0'] = '\u0028\u0075\u0029';
  36309. t['\u24B1'] = '\u0028\u0076\u0029';
  36310. t['\u24B2'] = '\u0028\u0077\u0029';
  36311. t['\u24B3'] = '\u0028\u0078\u0029';
  36312. t['\u24B4'] = '\u0028\u0079\u0029';
  36313. t['\u24B5'] = '\u0028\u007A\u0029';
  36314. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  36315. t['\u2A74'] = '\u003A\u003A\u003D';
  36316. t['\u2A75'] = '\u003D\u003D';
  36317. t['\u2A76'] = '\u003D\u003D\u003D';
  36318. t['\u2E9F'] = '\u6BCD';
  36319. t['\u2EF3'] = '\u9F9F';
  36320. t['\u2F00'] = '\u4E00';
  36321. t['\u2F01'] = '\u4E28';
  36322. t['\u2F02'] = '\u4E36';
  36323. t['\u2F03'] = '\u4E3F';
  36324. t['\u2F04'] = '\u4E59';
  36325. t['\u2F05'] = '\u4E85';
  36326. t['\u2F06'] = '\u4E8C';
  36327. t['\u2F07'] = '\u4EA0';
  36328. t['\u2F08'] = '\u4EBA';
  36329. t['\u2F09'] = '\u513F';
  36330. t['\u2F0A'] = '\u5165';
  36331. t['\u2F0B'] = '\u516B';
  36332. t['\u2F0C'] = '\u5182';
  36333. t['\u2F0D'] = '\u5196';
  36334. t['\u2F0E'] = '\u51AB';
  36335. t['\u2F0F'] = '\u51E0';
  36336. t['\u2F10'] = '\u51F5';
  36337. t['\u2F11'] = '\u5200';
  36338. t['\u2F12'] = '\u529B';
  36339. t['\u2F13'] = '\u52F9';
  36340. t['\u2F14'] = '\u5315';
  36341. t['\u2F15'] = '\u531A';
  36342. t['\u2F16'] = '\u5338';
  36343. t['\u2F17'] = '\u5341';
  36344. t['\u2F18'] = '\u535C';
  36345. t['\u2F19'] = '\u5369';
  36346. t['\u2F1A'] = '\u5382';
  36347. t['\u2F1B'] = '\u53B6';
  36348. t['\u2F1C'] = '\u53C8';
  36349. t['\u2F1D'] = '\u53E3';
  36350. t['\u2F1E'] = '\u56D7';
  36351. t['\u2F1F'] = '\u571F';
  36352. t['\u2F20'] = '\u58EB';
  36353. t['\u2F21'] = '\u5902';
  36354. t['\u2F22'] = '\u590A';
  36355. t['\u2F23'] = '\u5915';
  36356. t['\u2F24'] = '\u5927';
  36357. t['\u2F25'] = '\u5973';
  36358. t['\u2F26'] = '\u5B50';
  36359. t['\u2F27'] = '\u5B80';
  36360. t['\u2F28'] = '\u5BF8';
  36361. t['\u2F29'] = '\u5C0F';
  36362. t['\u2F2A'] = '\u5C22';
  36363. t['\u2F2B'] = '\u5C38';
  36364. t['\u2F2C'] = '\u5C6E';
  36365. t['\u2F2D'] = '\u5C71';
  36366. t['\u2F2E'] = '\u5DDB';
  36367. t['\u2F2F'] = '\u5DE5';
  36368. t['\u2F30'] = '\u5DF1';
  36369. t['\u2F31'] = '\u5DFE';
  36370. t['\u2F32'] = '\u5E72';
  36371. t['\u2F33'] = '\u5E7A';
  36372. t['\u2F34'] = '\u5E7F';
  36373. t['\u2F35'] = '\u5EF4';
  36374. t['\u2F36'] = '\u5EFE';
  36375. t['\u2F37'] = '\u5F0B';
  36376. t['\u2F38'] = '\u5F13';
  36377. t['\u2F39'] = '\u5F50';
  36378. t['\u2F3A'] = '\u5F61';
  36379. t['\u2F3B'] = '\u5F73';
  36380. t['\u2F3C'] = '\u5FC3';
  36381. t['\u2F3D'] = '\u6208';
  36382. t['\u2F3E'] = '\u6236';
  36383. t['\u2F3F'] = '\u624B';
  36384. t['\u2F40'] = '\u652F';
  36385. t['\u2F41'] = '\u6534';
  36386. t['\u2F42'] = '\u6587';
  36387. t['\u2F43'] = '\u6597';
  36388. t['\u2F44'] = '\u65A4';
  36389. t['\u2F45'] = '\u65B9';
  36390. t['\u2F46'] = '\u65E0';
  36391. t['\u2F47'] = '\u65E5';
  36392. t['\u2F48'] = '\u66F0';
  36393. t['\u2F49'] = '\u6708';
  36394. t['\u2F4A'] = '\u6728';
  36395. t['\u2F4B'] = '\u6B20';
  36396. t['\u2F4C'] = '\u6B62';
  36397. t['\u2F4D'] = '\u6B79';
  36398. t['\u2F4E'] = '\u6BB3';
  36399. t['\u2F4F'] = '\u6BCB';
  36400. t['\u2F50'] = '\u6BD4';
  36401. t['\u2F51'] = '\u6BDB';
  36402. t['\u2F52'] = '\u6C0F';
  36403. t['\u2F53'] = '\u6C14';
  36404. t['\u2F54'] = '\u6C34';
  36405. t['\u2F55'] = '\u706B';
  36406. t['\u2F56'] = '\u722A';
  36407. t['\u2F57'] = '\u7236';
  36408. t['\u2F58'] = '\u723B';
  36409. t['\u2F59'] = '\u723F';
  36410. t['\u2F5A'] = '\u7247';
  36411. t['\u2F5B'] = '\u7259';
  36412. t['\u2F5C'] = '\u725B';
  36413. t['\u2F5D'] = '\u72AC';
  36414. t['\u2F5E'] = '\u7384';
  36415. t['\u2F5F'] = '\u7389';
  36416. t['\u2F60'] = '\u74DC';
  36417. t['\u2F61'] = '\u74E6';
  36418. t['\u2F62'] = '\u7518';
  36419. t['\u2F63'] = '\u751F';
  36420. t['\u2F64'] = '\u7528';
  36421. t['\u2F65'] = '\u7530';
  36422. t['\u2F66'] = '\u758B';
  36423. t['\u2F67'] = '\u7592';
  36424. t['\u2F68'] = '\u7676';
  36425. t['\u2F69'] = '\u767D';
  36426. t['\u2F6A'] = '\u76AE';
  36427. t['\u2F6B'] = '\u76BF';
  36428. t['\u2F6C'] = '\u76EE';
  36429. t['\u2F6D'] = '\u77DB';
  36430. t['\u2F6E'] = '\u77E2';
  36431. t['\u2F6F'] = '\u77F3';
  36432. t['\u2F70'] = '\u793A';
  36433. t['\u2F71'] = '\u79B8';
  36434. t['\u2F72'] = '\u79BE';
  36435. t['\u2F73'] = '\u7A74';
  36436. t['\u2F74'] = '\u7ACB';
  36437. t['\u2F75'] = '\u7AF9';
  36438. t['\u2F76'] = '\u7C73';
  36439. t['\u2F77'] = '\u7CF8';
  36440. t['\u2F78'] = '\u7F36';
  36441. t['\u2F79'] = '\u7F51';
  36442. t['\u2F7A'] = '\u7F8A';
  36443. t['\u2F7B'] = '\u7FBD';
  36444. t['\u2F7C'] = '\u8001';
  36445. t['\u2F7D'] = '\u800C';
  36446. t['\u2F7E'] = '\u8012';
  36447. t['\u2F7F'] = '\u8033';
  36448. t['\u2F80'] = '\u807F';
  36449. t['\u2F81'] = '\u8089';
  36450. t['\u2F82'] = '\u81E3';
  36451. t['\u2F83'] = '\u81EA';
  36452. t['\u2F84'] = '\u81F3';
  36453. t['\u2F85'] = '\u81FC';
  36454. t['\u2F86'] = '\u820C';
  36455. t['\u2F87'] = '\u821B';
  36456. t['\u2F88'] = '\u821F';
  36457. t['\u2F89'] = '\u826E';
  36458. t['\u2F8A'] = '\u8272';
  36459. t['\u2F8B'] = '\u8278';
  36460. t['\u2F8C'] = '\u864D';
  36461. t['\u2F8D'] = '\u866B';
  36462. t['\u2F8E'] = '\u8840';
  36463. t['\u2F8F'] = '\u884C';
  36464. t['\u2F90'] = '\u8863';
  36465. t['\u2F91'] = '\u897E';
  36466. t['\u2F92'] = '\u898B';
  36467. t['\u2F93'] = '\u89D2';
  36468. t['\u2F94'] = '\u8A00';
  36469. t['\u2F95'] = '\u8C37';
  36470. t['\u2F96'] = '\u8C46';
  36471. t['\u2F97'] = '\u8C55';
  36472. t['\u2F98'] = '\u8C78';
  36473. t['\u2F99'] = '\u8C9D';
  36474. t['\u2F9A'] = '\u8D64';
  36475. t['\u2F9B'] = '\u8D70';
  36476. t['\u2F9C'] = '\u8DB3';
  36477. t['\u2F9D'] = '\u8EAB';
  36478. t['\u2F9E'] = '\u8ECA';
  36479. t['\u2F9F'] = '\u8F9B';
  36480. t['\u2FA0'] = '\u8FB0';
  36481. t['\u2FA1'] = '\u8FB5';
  36482. t['\u2FA2'] = '\u9091';
  36483. t['\u2FA3'] = '\u9149';
  36484. t['\u2FA4'] = '\u91C6';
  36485. t['\u2FA5'] = '\u91CC';
  36486. t['\u2FA6'] = '\u91D1';
  36487. t['\u2FA7'] = '\u9577';
  36488. t['\u2FA8'] = '\u9580';
  36489. t['\u2FA9'] = '\u961C';
  36490. t['\u2FAA'] = '\u96B6';
  36491. t['\u2FAB'] = '\u96B9';
  36492. t['\u2FAC'] = '\u96E8';
  36493. t['\u2FAD'] = '\u9751';
  36494. t['\u2FAE'] = '\u975E';
  36495. t['\u2FAF'] = '\u9762';
  36496. t['\u2FB0'] = '\u9769';
  36497. t['\u2FB1'] = '\u97CB';
  36498. t['\u2FB2'] = '\u97ED';
  36499. t['\u2FB3'] = '\u97F3';
  36500. t['\u2FB4'] = '\u9801';
  36501. t['\u2FB5'] = '\u98A8';
  36502. t['\u2FB6'] = '\u98DB';
  36503. t['\u2FB7'] = '\u98DF';
  36504. t['\u2FB8'] = '\u9996';
  36505. t['\u2FB9'] = '\u9999';
  36506. t['\u2FBA'] = '\u99AC';
  36507. t['\u2FBB'] = '\u9AA8';
  36508. t['\u2FBC'] = '\u9AD8';
  36509. t['\u2FBD'] = '\u9ADF';
  36510. t['\u2FBE'] = '\u9B25';
  36511. t['\u2FBF'] = '\u9B2F';
  36512. t['\u2FC0'] = '\u9B32';
  36513. t['\u2FC1'] = '\u9B3C';
  36514. t['\u2FC2'] = '\u9B5A';
  36515. t['\u2FC3'] = '\u9CE5';
  36516. t['\u2FC4'] = '\u9E75';
  36517. t['\u2FC5'] = '\u9E7F';
  36518. t['\u2FC6'] = '\u9EA5';
  36519. t['\u2FC7'] = '\u9EBB';
  36520. t['\u2FC8'] = '\u9EC3';
  36521. t['\u2FC9'] = '\u9ECD';
  36522. t['\u2FCA'] = '\u9ED1';
  36523. t['\u2FCB'] = '\u9EF9';
  36524. t['\u2FCC'] = '\u9EFD';
  36525. t['\u2FCD'] = '\u9F0E';
  36526. t['\u2FCE'] = '\u9F13';
  36527. t['\u2FCF'] = '\u9F20';
  36528. t['\u2FD0'] = '\u9F3B';
  36529. t['\u2FD1'] = '\u9F4A';
  36530. t['\u2FD2'] = '\u9F52';
  36531. t['\u2FD3'] = '\u9F8D';
  36532. t['\u2FD4'] = '\u9F9C';
  36533. t['\u2FD5'] = '\u9FA0';
  36534. t['\u3036'] = '\u3012';
  36535. t['\u3038'] = '\u5341';
  36536. t['\u3039'] = '\u5344';
  36537. t['\u303A'] = '\u5345';
  36538. t['\u309B'] = '\u0020\u3099';
  36539. t['\u309C'] = '\u0020\u309A';
  36540. t['\u3131'] = '\u1100';
  36541. t['\u3132'] = '\u1101';
  36542. t['\u3133'] = '\u11AA';
  36543. t['\u3134'] = '\u1102';
  36544. t['\u3135'] = '\u11AC';
  36545. t['\u3136'] = '\u11AD';
  36546. t['\u3137'] = '\u1103';
  36547. t['\u3138'] = '\u1104';
  36548. t['\u3139'] = '\u1105';
  36549. t['\u313A'] = '\u11B0';
  36550. t['\u313B'] = '\u11B1';
  36551. t['\u313C'] = '\u11B2';
  36552. t['\u313D'] = '\u11B3';
  36553. t['\u313E'] = '\u11B4';
  36554. t['\u313F'] = '\u11B5';
  36555. t['\u3140'] = '\u111A';
  36556. t['\u3141'] = '\u1106';
  36557. t['\u3142'] = '\u1107';
  36558. t['\u3143'] = '\u1108';
  36559. t['\u3144'] = '\u1121';
  36560. t['\u3145'] = '\u1109';
  36561. t['\u3146'] = '\u110A';
  36562. t['\u3147'] = '\u110B';
  36563. t['\u3148'] = '\u110C';
  36564. t['\u3149'] = '\u110D';
  36565. t['\u314A'] = '\u110E';
  36566. t['\u314B'] = '\u110F';
  36567. t['\u314C'] = '\u1110';
  36568. t['\u314D'] = '\u1111';
  36569. t['\u314E'] = '\u1112';
  36570. t['\u314F'] = '\u1161';
  36571. t['\u3150'] = '\u1162';
  36572. t['\u3151'] = '\u1163';
  36573. t['\u3152'] = '\u1164';
  36574. t['\u3153'] = '\u1165';
  36575. t['\u3154'] = '\u1166';
  36576. t['\u3155'] = '\u1167';
  36577. t['\u3156'] = '\u1168';
  36578. t['\u3157'] = '\u1169';
  36579. t['\u3158'] = '\u116A';
  36580. t['\u3159'] = '\u116B';
  36581. t['\u315A'] = '\u116C';
  36582. t['\u315B'] = '\u116D';
  36583. t['\u315C'] = '\u116E';
  36584. t['\u315D'] = '\u116F';
  36585. t['\u315E'] = '\u1170';
  36586. t['\u315F'] = '\u1171';
  36587. t['\u3160'] = '\u1172';
  36588. t['\u3161'] = '\u1173';
  36589. t['\u3162'] = '\u1174';
  36590. t['\u3163'] = '\u1175';
  36591. t['\u3164'] = '\u1160';
  36592. t['\u3165'] = '\u1114';
  36593. t['\u3166'] = '\u1115';
  36594. t['\u3167'] = '\u11C7';
  36595. t['\u3168'] = '\u11C8';
  36596. t['\u3169'] = '\u11CC';
  36597. t['\u316A'] = '\u11CE';
  36598. t['\u316B'] = '\u11D3';
  36599. t['\u316C'] = '\u11D7';
  36600. t['\u316D'] = '\u11D9';
  36601. t['\u316E'] = '\u111C';
  36602. t['\u316F'] = '\u11DD';
  36603. t['\u3170'] = '\u11DF';
  36604. t['\u3171'] = '\u111D';
  36605. t['\u3172'] = '\u111E';
  36606. t['\u3173'] = '\u1120';
  36607. t['\u3174'] = '\u1122';
  36608. t['\u3175'] = '\u1123';
  36609. t['\u3176'] = '\u1127';
  36610. t['\u3177'] = '\u1129';
  36611. t['\u3178'] = '\u112B';
  36612. t['\u3179'] = '\u112C';
  36613. t['\u317A'] = '\u112D';
  36614. t['\u317B'] = '\u112E';
  36615. t['\u317C'] = '\u112F';
  36616. t['\u317D'] = '\u1132';
  36617. t['\u317E'] = '\u1136';
  36618. t['\u317F'] = '\u1140';
  36619. t['\u3180'] = '\u1147';
  36620. t['\u3181'] = '\u114C';
  36621. t['\u3182'] = '\u11F1';
  36622. t['\u3183'] = '\u11F2';
  36623. t['\u3184'] = '\u1157';
  36624. t['\u3185'] = '\u1158';
  36625. t['\u3186'] = '\u1159';
  36626. t['\u3187'] = '\u1184';
  36627. t['\u3188'] = '\u1185';
  36628. t['\u3189'] = '\u1188';
  36629. t['\u318A'] = '\u1191';
  36630. t['\u318B'] = '\u1192';
  36631. t['\u318C'] = '\u1194';
  36632. t['\u318D'] = '\u119E';
  36633. t['\u318E'] = '\u11A1';
  36634. t['\u3200'] = '\u0028\u1100\u0029';
  36635. t['\u3201'] = '\u0028\u1102\u0029';
  36636. t['\u3202'] = '\u0028\u1103\u0029';
  36637. t['\u3203'] = '\u0028\u1105\u0029';
  36638. t['\u3204'] = '\u0028\u1106\u0029';
  36639. t['\u3205'] = '\u0028\u1107\u0029';
  36640. t['\u3206'] = '\u0028\u1109\u0029';
  36641. t['\u3207'] = '\u0028\u110B\u0029';
  36642. t['\u3208'] = '\u0028\u110C\u0029';
  36643. t['\u3209'] = '\u0028\u110E\u0029';
  36644. t['\u320A'] = '\u0028\u110F\u0029';
  36645. t['\u320B'] = '\u0028\u1110\u0029';
  36646. t['\u320C'] = '\u0028\u1111\u0029';
  36647. t['\u320D'] = '\u0028\u1112\u0029';
  36648. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  36649. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  36650. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  36651. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  36652. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  36653. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  36654. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  36655. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  36656. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  36657. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  36658. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  36659. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  36660. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  36661. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  36662. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  36663. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  36664. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  36665. t['\u3220'] = '\u0028\u4E00\u0029';
  36666. t['\u3221'] = '\u0028\u4E8C\u0029';
  36667. t['\u3222'] = '\u0028\u4E09\u0029';
  36668. t['\u3223'] = '\u0028\u56DB\u0029';
  36669. t['\u3224'] = '\u0028\u4E94\u0029';
  36670. t['\u3225'] = '\u0028\u516D\u0029';
  36671. t['\u3226'] = '\u0028\u4E03\u0029';
  36672. t['\u3227'] = '\u0028\u516B\u0029';
  36673. t['\u3228'] = '\u0028\u4E5D\u0029';
  36674. t['\u3229'] = '\u0028\u5341\u0029';
  36675. t['\u322A'] = '\u0028\u6708\u0029';
  36676. t['\u322B'] = '\u0028\u706B\u0029';
  36677. t['\u322C'] = '\u0028\u6C34\u0029';
  36678. t['\u322D'] = '\u0028\u6728\u0029';
  36679. t['\u322E'] = '\u0028\u91D1\u0029';
  36680. t['\u322F'] = '\u0028\u571F\u0029';
  36681. t['\u3230'] = '\u0028\u65E5\u0029';
  36682. t['\u3231'] = '\u0028\u682A\u0029';
  36683. t['\u3232'] = '\u0028\u6709\u0029';
  36684. t['\u3233'] = '\u0028\u793E\u0029';
  36685. t['\u3234'] = '\u0028\u540D\u0029';
  36686. t['\u3235'] = '\u0028\u7279\u0029';
  36687. t['\u3236'] = '\u0028\u8CA1\u0029';
  36688. t['\u3237'] = '\u0028\u795D\u0029';
  36689. t['\u3238'] = '\u0028\u52B4\u0029';
  36690. t['\u3239'] = '\u0028\u4EE3\u0029';
  36691. t['\u323A'] = '\u0028\u547C\u0029';
  36692. t['\u323B'] = '\u0028\u5B66\u0029';
  36693. t['\u323C'] = '\u0028\u76E3\u0029';
  36694. t['\u323D'] = '\u0028\u4F01\u0029';
  36695. t['\u323E'] = '\u0028\u8CC7\u0029';
  36696. t['\u323F'] = '\u0028\u5354\u0029';
  36697. t['\u3240'] = '\u0028\u796D\u0029';
  36698. t['\u3241'] = '\u0028\u4F11\u0029';
  36699. t['\u3242'] = '\u0028\u81EA\u0029';
  36700. t['\u3243'] = '\u0028\u81F3\u0029';
  36701. t['\u32C0'] = '\u0031\u6708';
  36702. t['\u32C1'] = '\u0032\u6708';
  36703. t['\u32C2'] = '\u0033\u6708';
  36704. t['\u32C3'] = '\u0034\u6708';
  36705. t['\u32C4'] = '\u0035\u6708';
  36706. t['\u32C5'] = '\u0036\u6708';
  36707. t['\u32C6'] = '\u0037\u6708';
  36708. t['\u32C7'] = '\u0038\u6708';
  36709. t['\u32C8'] = '\u0039\u6708';
  36710. t['\u32C9'] = '\u0031\u0030\u6708';
  36711. t['\u32CA'] = '\u0031\u0031\u6708';
  36712. t['\u32CB'] = '\u0031\u0032\u6708';
  36713. t['\u3358'] = '\u0030\u70B9';
  36714. t['\u3359'] = '\u0031\u70B9';
  36715. t['\u335A'] = '\u0032\u70B9';
  36716. t['\u335B'] = '\u0033\u70B9';
  36717. t['\u335C'] = '\u0034\u70B9';
  36718. t['\u335D'] = '\u0035\u70B9';
  36719. t['\u335E'] = '\u0036\u70B9';
  36720. t['\u335F'] = '\u0037\u70B9';
  36721. t['\u3360'] = '\u0038\u70B9';
  36722. t['\u3361'] = '\u0039\u70B9';
  36723. t['\u3362'] = '\u0031\u0030\u70B9';
  36724. t['\u3363'] = '\u0031\u0031\u70B9';
  36725. t['\u3364'] = '\u0031\u0032\u70B9';
  36726. t['\u3365'] = '\u0031\u0033\u70B9';
  36727. t['\u3366'] = '\u0031\u0034\u70B9';
  36728. t['\u3367'] = '\u0031\u0035\u70B9';
  36729. t['\u3368'] = '\u0031\u0036\u70B9';
  36730. t['\u3369'] = '\u0031\u0037\u70B9';
  36731. t['\u336A'] = '\u0031\u0038\u70B9';
  36732. t['\u336B'] = '\u0031\u0039\u70B9';
  36733. t['\u336C'] = '\u0032\u0030\u70B9';
  36734. t['\u336D'] = '\u0032\u0031\u70B9';
  36735. t['\u336E'] = '\u0032\u0032\u70B9';
  36736. t['\u336F'] = '\u0032\u0033\u70B9';
  36737. t['\u3370'] = '\u0032\u0034\u70B9';
  36738. t['\u33E0'] = '\u0031\u65E5';
  36739. t['\u33E1'] = '\u0032\u65E5';
  36740. t['\u33E2'] = '\u0033\u65E5';
  36741. t['\u33E3'] = '\u0034\u65E5';
  36742. t['\u33E4'] = '\u0035\u65E5';
  36743. t['\u33E5'] = '\u0036\u65E5';
  36744. t['\u33E6'] = '\u0037\u65E5';
  36745. t['\u33E7'] = '\u0038\u65E5';
  36746. t['\u33E8'] = '\u0039\u65E5';
  36747. t['\u33E9'] = '\u0031\u0030\u65E5';
  36748. t['\u33EA'] = '\u0031\u0031\u65E5';
  36749. t['\u33EB'] = '\u0031\u0032\u65E5';
  36750. t['\u33EC'] = '\u0031\u0033\u65E5';
  36751. t['\u33ED'] = '\u0031\u0034\u65E5';
  36752. t['\u33EE'] = '\u0031\u0035\u65E5';
  36753. t['\u33EF'] = '\u0031\u0036\u65E5';
  36754. t['\u33F0'] = '\u0031\u0037\u65E5';
  36755. t['\u33F1'] = '\u0031\u0038\u65E5';
  36756. t['\u33F2'] = '\u0031\u0039\u65E5';
  36757. t['\u33F3'] = '\u0032\u0030\u65E5';
  36758. t['\u33F4'] = '\u0032\u0031\u65E5';
  36759. t['\u33F5'] = '\u0032\u0032\u65E5';
  36760. t['\u33F6'] = '\u0032\u0033\u65E5';
  36761. t['\u33F7'] = '\u0032\u0034\u65E5';
  36762. t['\u33F8'] = '\u0032\u0035\u65E5';
  36763. t['\u33F9'] = '\u0032\u0036\u65E5';
  36764. t['\u33FA'] = '\u0032\u0037\u65E5';
  36765. t['\u33FB'] = '\u0032\u0038\u65E5';
  36766. t['\u33FC'] = '\u0032\u0039\u65E5';
  36767. t['\u33FD'] = '\u0033\u0030\u65E5';
  36768. t['\u33FE'] = '\u0033\u0031\u65E5';
  36769. t['\uFB00'] = '\u0066\u0066';
  36770. t['\uFB01'] = '\u0066\u0069';
  36771. t['\uFB02'] = '\u0066\u006C';
  36772. t['\uFB03'] = '\u0066\u0066\u0069';
  36773. t['\uFB04'] = '\u0066\u0066\u006C';
  36774. t['\uFB05'] = '\u017F\u0074';
  36775. t['\uFB06'] = '\u0073\u0074';
  36776. t['\uFB13'] = '\u0574\u0576';
  36777. t['\uFB14'] = '\u0574\u0565';
  36778. t['\uFB15'] = '\u0574\u056B';
  36779. t['\uFB16'] = '\u057E\u0576';
  36780. t['\uFB17'] = '\u0574\u056D';
  36781. t['\uFB4F'] = '\u05D0\u05DC';
  36782. t['\uFB50'] = '\u0671';
  36783. t['\uFB51'] = '\u0671';
  36784. t['\uFB52'] = '\u067B';
  36785. t['\uFB53'] = '\u067B';
  36786. t['\uFB54'] = '\u067B';
  36787. t['\uFB55'] = '\u067B';
  36788. t['\uFB56'] = '\u067E';
  36789. t['\uFB57'] = '\u067E';
  36790. t['\uFB58'] = '\u067E';
  36791. t['\uFB59'] = '\u067E';
  36792. t['\uFB5A'] = '\u0680';
  36793. t['\uFB5B'] = '\u0680';
  36794. t['\uFB5C'] = '\u0680';
  36795. t['\uFB5D'] = '\u0680';
  36796. t['\uFB5E'] = '\u067A';
  36797. t['\uFB5F'] = '\u067A';
  36798. t['\uFB60'] = '\u067A';
  36799. t['\uFB61'] = '\u067A';
  36800. t['\uFB62'] = '\u067F';
  36801. t['\uFB63'] = '\u067F';
  36802. t['\uFB64'] = '\u067F';
  36803. t['\uFB65'] = '\u067F';
  36804. t['\uFB66'] = '\u0679';
  36805. t['\uFB67'] = '\u0679';
  36806. t['\uFB68'] = '\u0679';
  36807. t['\uFB69'] = '\u0679';
  36808. t['\uFB6A'] = '\u06A4';
  36809. t['\uFB6B'] = '\u06A4';
  36810. t['\uFB6C'] = '\u06A4';
  36811. t['\uFB6D'] = '\u06A4';
  36812. t['\uFB6E'] = '\u06A6';
  36813. t['\uFB6F'] = '\u06A6';
  36814. t['\uFB70'] = '\u06A6';
  36815. t['\uFB71'] = '\u06A6';
  36816. t['\uFB72'] = '\u0684';
  36817. t['\uFB73'] = '\u0684';
  36818. t['\uFB74'] = '\u0684';
  36819. t['\uFB75'] = '\u0684';
  36820. t['\uFB76'] = '\u0683';
  36821. t['\uFB77'] = '\u0683';
  36822. t['\uFB78'] = '\u0683';
  36823. t['\uFB79'] = '\u0683';
  36824. t['\uFB7A'] = '\u0686';
  36825. t['\uFB7B'] = '\u0686';
  36826. t['\uFB7C'] = '\u0686';
  36827. t['\uFB7D'] = '\u0686';
  36828. t['\uFB7E'] = '\u0687';
  36829. t['\uFB7F'] = '\u0687';
  36830. t['\uFB80'] = '\u0687';
  36831. t['\uFB81'] = '\u0687';
  36832. t['\uFB82'] = '\u068D';
  36833. t['\uFB83'] = '\u068D';
  36834. t['\uFB84'] = '\u068C';
  36835. t['\uFB85'] = '\u068C';
  36836. t['\uFB86'] = '\u068E';
  36837. t['\uFB87'] = '\u068E';
  36838. t['\uFB88'] = '\u0688';
  36839. t['\uFB89'] = '\u0688';
  36840. t['\uFB8A'] = '\u0698';
  36841. t['\uFB8B'] = '\u0698';
  36842. t['\uFB8C'] = '\u0691';
  36843. t['\uFB8D'] = '\u0691';
  36844. t['\uFB8E'] = '\u06A9';
  36845. t['\uFB8F'] = '\u06A9';
  36846. t['\uFB90'] = '\u06A9';
  36847. t['\uFB91'] = '\u06A9';
  36848. t['\uFB92'] = '\u06AF';
  36849. t['\uFB93'] = '\u06AF';
  36850. t['\uFB94'] = '\u06AF';
  36851. t['\uFB95'] = '\u06AF';
  36852. t['\uFB96'] = '\u06B3';
  36853. t['\uFB97'] = '\u06B3';
  36854. t['\uFB98'] = '\u06B3';
  36855. t['\uFB99'] = '\u06B3';
  36856. t['\uFB9A'] = '\u06B1';
  36857. t['\uFB9B'] = '\u06B1';
  36858. t['\uFB9C'] = '\u06B1';
  36859. t['\uFB9D'] = '\u06B1';
  36860. t['\uFB9E'] = '\u06BA';
  36861. t['\uFB9F'] = '\u06BA';
  36862. t['\uFBA0'] = '\u06BB';
  36863. t['\uFBA1'] = '\u06BB';
  36864. t['\uFBA2'] = '\u06BB';
  36865. t['\uFBA3'] = '\u06BB';
  36866. t['\uFBA4'] = '\u06C0';
  36867. t['\uFBA5'] = '\u06C0';
  36868. t['\uFBA6'] = '\u06C1';
  36869. t['\uFBA7'] = '\u06C1';
  36870. t['\uFBA8'] = '\u06C1';
  36871. t['\uFBA9'] = '\u06C1';
  36872. t['\uFBAA'] = '\u06BE';
  36873. t['\uFBAB'] = '\u06BE';
  36874. t['\uFBAC'] = '\u06BE';
  36875. t['\uFBAD'] = '\u06BE';
  36876. t['\uFBAE'] = '\u06D2';
  36877. t['\uFBAF'] = '\u06D2';
  36878. t['\uFBB0'] = '\u06D3';
  36879. t['\uFBB1'] = '\u06D3';
  36880. t['\uFBD3'] = '\u06AD';
  36881. t['\uFBD4'] = '\u06AD';
  36882. t['\uFBD5'] = '\u06AD';
  36883. t['\uFBD6'] = '\u06AD';
  36884. t['\uFBD7'] = '\u06C7';
  36885. t['\uFBD8'] = '\u06C7';
  36886. t['\uFBD9'] = '\u06C6';
  36887. t['\uFBDA'] = '\u06C6';
  36888. t['\uFBDB'] = '\u06C8';
  36889. t['\uFBDC'] = '\u06C8';
  36890. t['\uFBDD'] = '\u0677';
  36891. t['\uFBDE'] = '\u06CB';
  36892. t['\uFBDF'] = '\u06CB';
  36893. t['\uFBE0'] = '\u06C5';
  36894. t['\uFBE1'] = '\u06C5';
  36895. t['\uFBE2'] = '\u06C9';
  36896. t['\uFBE3'] = '\u06C9';
  36897. t['\uFBE4'] = '\u06D0';
  36898. t['\uFBE5'] = '\u06D0';
  36899. t['\uFBE6'] = '\u06D0';
  36900. t['\uFBE7'] = '\u06D0';
  36901. t['\uFBE8'] = '\u0649';
  36902. t['\uFBE9'] = '\u0649';
  36903. t['\uFBEA'] = '\u0626\u0627';
  36904. t['\uFBEB'] = '\u0626\u0627';
  36905. t['\uFBEC'] = '\u0626\u06D5';
  36906. t['\uFBED'] = '\u0626\u06D5';
  36907. t['\uFBEE'] = '\u0626\u0648';
  36908. t['\uFBEF'] = '\u0626\u0648';
  36909. t['\uFBF0'] = '\u0626\u06C7';
  36910. t['\uFBF1'] = '\u0626\u06C7';
  36911. t['\uFBF2'] = '\u0626\u06C6';
  36912. t['\uFBF3'] = '\u0626\u06C6';
  36913. t['\uFBF4'] = '\u0626\u06C8';
  36914. t['\uFBF5'] = '\u0626\u06C8';
  36915. t['\uFBF6'] = '\u0626\u06D0';
  36916. t['\uFBF7'] = '\u0626\u06D0';
  36917. t['\uFBF8'] = '\u0626\u06D0';
  36918. t['\uFBF9'] = '\u0626\u0649';
  36919. t['\uFBFA'] = '\u0626\u0649';
  36920. t['\uFBFB'] = '\u0626\u0649';
  36921. t['\uFBFC'] = '\u06CC';
  36922. t['\uFBFD'] = '\u06CC';
  36923. t['\uFBFE'] = '\u06CC';
  36924. t['\uFBFF'] = '\u06CC';
  36925. t['\uFC00'] = '\u0626\u062C';
  36926. t['\uFC01'] = '\u0626\u062D';
  36927. t['\uFC02'] = '\u0626\u0645';
  36928. t['\uFC03'] = '\u0626\u0649';
  36929. t['\uFC04'] = '\u0626\u064A';
  36930. t['\uFC05'] = '\u0628\u062C';
  36931. t['\uFC06'] = '\u0628\u062D';
  36932. t['\uFC07'] = '\u0628\u062E';
  36933. t['\uFC08'] = '\u0628\u0645';
  36934. t['\uFC09'] = '\u0628\u0649';
  36935. t['\uFC0A'] = '\u0628\u064A';
  36936. t['\uFC0B'] = '\u062A\u062C';
  36937. t['\uFC0C'] = '\u062A\u062D';
  36938. t['\uFC0D'] = '\u062A\u062E';
  36939. t['\uFC0E'] = '\u062A\u0645';
  36940. t['\uFC0F'] = '\u062A\u0649';
  36941. t['\uFC10'] = '\u062A\u064A';
  36942. t['\uFC11'] = '\u062B\u062C';
  36943. t['\uFC12'] = '\u062B\u0645';
  36944. t['\uFC13'] = '\u062B\u0649';
  36945. t['\uFC14'] = '\u062B\u064A';
  36946. t['\uFC15'] = '\u062C\u062D';
  36947. t['\uFC16'] = '\u062C\u0645';
  36948. t['\uFC17'] = '\u062D\u062C';
  36949. t['\uFC18'] = '\u062D\u0645';
  36950. t['\uFC19'] = '\u062E\u062C';
  36951. t['\uFC1A'] = '\u062E\u062D';
  36952. t['\uFC1B'] = '\u062E\u0645';
  36953. t['\uFC1C'] = '\u0633\u062C';
  36954. t['\uFC1D'] = '\u0633\u062D';
  36955. t['\uFC1E'] = '\u0633\u062E';
  36956. t['\uFC1F'] = '\u0633\u0645';
  36957. t['\uFC20'] = '\u0635\u062D';
  36958. t['\uFC21'] = '\u0635\u0645';
  36959. t['\uFC22'] = '\u0636\u062C';
  36960. t['\uFC23'] = '\u0636\u062D';
  36961. t['\uFC24'] = '\u0636\u062E';
  36962. t['\uFC25'] = '\u0636\u0645';
  36963. t['\uFC26'] = '\u0637\u062D';
  36964. t['\uFC27'] = '\u0637\u0645';
  36965. t['\uFC28'] = '\u0638\u0645';
  36966. t['\uFC29'] = '\u0639\u062C';
  36967. t['\uFC2A'] = '\u0639\u0645';
  36968. t['\uFC2B'] = '\u063A\u062C';
  36969. t['\uFC2C'] = '\u063A\u0645';
  36970. t['\uFC2D'] = '\u0641\u062C';
  36971. t['\uFC2E'] = '\u0641\u062D';
  36972. t['\uFC2F'] = '\u0641\u062E';
  36973. t['\uFC30'] = '\u0641\u0645';
  36974. t['\uFC31'] = '\u0641\u0649';
  36975. t['\uFC32'] = '\u0641\u064A';
  36976. t['\uFC33'] = '\u0642\u062D';
  36977. t['\uFC34'] = '\u0642\u0645';
  36978. t['\uFC35'] = '\u0642\u0649';
  36979. t['\uFC36'] = '\u0642\u064A';
  36980. t['\uFC37'] = '\u0643\u0627';
  36981. t['\uFC38'] = '\u0643\u062C';
  36982. t['\uFC39'] = '\u0643\u062D';
  36983. t['\uFC3A'] = '\u0643\u062E';
  36984. t['\uFC3B'] = '\u0643\u0644';
  36985. t['\uFC3C'] = '\u0643\u0645';
  36986. t['\uFC3D'] = '\u0643\u0649';
  36987. t['\uFC3E'] = '\u0643\u064A';
  36988. t['\uFC3F'] = '\u0644\u062C';
  36989. t['\uFC40'] = '\u0644\u062D';
  36990. t['\uFC41'] = '\u0644\u062E';
  36991. t['\uFC42'] = '\u0644\u0645';
  36992. t['\uFC43'] = '\u0644\u0649';
  36993. t['\uFC44'] = '\u0644\u064A';
  36994. t['\uFC45'] = '\u0645\u062C';
  36995. t['\uFC46'] = '\u0645\u062D';
  36996. t['\uFC47'] = '\u0645\u062E';
  36997. t['\uFC48'] = '\u0645\u0645';
  36998. t['\uFC49'] = '\u0645\u0649';
  36999. t['\uFC4A'] = '\u0645\u064A';
  37000. t['\uFC4B'] = '\u0646\u062C';
  37001. t['\uFC4C'] = '\u0646\u062D';
  37002. t['\uFC4D'] = '\u0646\u062E';
  37003. t['\uFC4E'] = '\u0646\u0645';
  37004. t['\uFC4F'] = '\u0646\u0649';
  37005. t['\uFC50'] = '\u0646\u064A';
  37006. t['\uFC51'] = '\u0647\u062C';
  37007. t['\uFC52'] = '\u0647\u0645';
  37008. t['\uFC53'] = '\u0647\u0649';
  37009. t['\uFC54'] = '\u0647\u064A';
  37010. t['\uFC55'] = '\u064A\u062C';
  37011. t['\uFC56'] = '\u064A\u062D';
  37012. t['\uFC57'] = '\u064A\u062E';
  37013. t['\uFC58'] = '\u064A\u0645';
  37014. t['\uFC59'] = '\u064A\u0649';
  37015. t['\uFC5A'] = '\u064A\u064A';
  37016. t['\uFC5B'] = '\u0630\u0670';
  37017. t['\uFC5C'] = '\u0631\u0670';
  37018. t['\uFC5D'] = '\u0649\u0670';
  37019. t['\uFC5E'] = '\u0020\u064C\u0651';
  37020. t['\uFC5F'] = '\u0020\u064D\u0651';
  37021. t['\uFC60'] = '\u0020\u064E\u0651';
  37022. t['\uFC61'] = '\u0020\u064F\u0651';
  37023. t['\uFC62'] = '\u0020\u0650\u0651';
  37024. t['\uFC63'] = '\u0020\u0651\u0670';
  37025. t['\uFC64'] = '\u0626\u0631';
  37026. t['\uFC65'] = '\u0626\u0632';
  37027. t['\uFC66'] = '\u0626\u0645';
  37028. t['\uFC67'] = '\u0626\u0646';
  37029. t['\uFC68'] = '\u0626\u0649';
  37030. t['\uFC69'] = '\u0626\u064A';
  37031. t['\uFC6A'] = '\u0628\u0631';
  37032. t['\uFC6B'] = '\u0628\u0632';
  37033. t['\uFC6C'] = '\u0628\u0645';
  37034. t['\uFC6D'] = '\u0628\u0646';
  37035. t['\uFC6E'] = '\u0628\u0649';
  37036. t['\uFC6F'] = '\u0628\u064A';
  37037. t['\uFC70'] = '\u062A\u0631';
  37038. t['\uFC71'] = '\u062A\u0632';
  37039. t['\uFC72'] = '\u062A\u0645';
  37040. t['\uFC73'] = '\u062A\u0646';
  37041. t['\uFC74'] = '\u062A\u0649';
  37042. t['\uFC75'] = '\u062A\u064A';
  37043. t['\uFC76'] = '\u062B\u0631';
  37044. t['\uFC77'] = '\u062B\u0632';
  37045. t['\uFC78'] = '\u062B\u0645';
  37046. t['\uFC79'] = '\u062B\u0646';
  37047. t['\uFC7A'] = '\u062B\u0649';
  37048. t['\uFC7B'] = '\u062B\u064A';
  37049. t['\uFC7C'] = '\u0641\u0649';
  37050. t['\uFC7D'] = '\u0641\u064A';
  37051. t['\uFC7E'] = '\u0642\u0649';
  37052. t['\uFC7F'] = '\u0642\u064A';
  37053. t['\uFC80'] = '\u0643\u0627';
  37054. t['\uFC81'] = '\u0643\u0644';
  37055. t['\uFC82'] = '\u0643\u0645';
  37056. t['\uFC83'] = '\u0643\u0649';
  37057. t['\uFC84'] = '\u0643\u064A';
  37058. t['\uFC85'] = '\u0644\u0645';
  37059. t['\uFC86'] = '\u0644\u0649';
  37060. t['\uFC87'] = '\u0644\u064A';
  37061. t['\uFC88'] = '\u0645\u0627';
  37062. t['\uFC89'] = '\u0645\u0645';
  37063. t['\uFC8A'] = '\u0646\u0631';
  37064. t['\uFC8B'] = '\u0646\u0632';
  37065. t['\uFC8C'] = '\u0646\u0645';
  37066. t['\uFC8D'] = '\u0646\u0646';
  37067. t['\uFC8E'] = '\u0646\u0649';
  37068. t['\uFC8F'] = '\u0646\u064A';
  37069. t['\uFC90'] = '\u0649\u0670';
  37070. t['\uFC91'] = '\u064A\u0631';
  37071. t['\uFC92'] = '\u064A\u0632';
  37072. t['\uFC93'] = '\u064A\u0645';
  37073. t['\uFC94'] = '\u064A\u0646';
  37074. t['\uFC95'] = '\u064A\u0649';
  37075. t['\uFC96'] = '\u064A\u064A';
  37076. t['\uFC97'] = '\u0626\u062C';
  37077. t['\uFC98'] = '\u0626\u062D';
  37078. t['\uFC99'] = '\u0626\u062E';
  37079. t['\uFC9A'] = '\u0626\u0645';
  37080. t['\uFC9B'] = '\u0626\u0647';
  37081. t['\uFC9C'] = '\u0628\u062C';
  37082. t['\uFC9D'] = '\u0628\u062D';
  37083. t['\uFC9E'] = '\u0628\u062E';
  37084. t['\uFC9F'] = '\u0628\u0645';
  37085. t['\uFCA0'] = '\u0628\u0647';
  37086. t['\uFCA1'] = '\u062A\u062C';
  37087. t['\uFCA2'] = '\u062A\u062D';
  37088. t['\uFCA3'] = '\u062A\u062E';
  37089. t['\uFCA4'] = '\u062A\u0645';
  37090. t['\uFCA5'] = '\u062A\u0647';
  37091. t['\uFCA6'] = '\u062B\u0645';
  37092. t['\uFCA7'] = '\u062C\u062D';
  37093. t['\uFCA8'] = '\u062C\u0645';
  37094. t['\uFCA9'] = '\u062D\u062C';
  37095. t['\uFCAA'] = '\u062D\u0645';
  37096. t['\uFCAB'] = '\u062E\u062C';
  37097. t['\uFCAC'] = '\u062E\u0645';
  37098. t['\uFCAD'] = '\u0633\u062C';
  37099. t['\uFCAE'] = '\u0633\u062D';
  37100. t['\uFCAF'] = '\u0633\u062E';
  37101. t['\uFCB0'] = '\u0633\u0645';
  37102. t['\uFCB1'] = '\u0635\u062D';
  37103. t['\uFCB2'] = '\u0635\u062E';
  37104. t['\uFCB3'] = '\u0635\u0645';
  37105. t['\uFCB4'] = '\u0636\u062C';
  37106. t['\uFCB5'] = '\u0636\u062D';
  37107. t['\uFCB6'] = '\u0636\u062E';
  37108. t['\uFCB7'] = '\u0636\u0645';
  37109. t['\uFCB8'] = '\u0637\u062D';
  37110. t['\uFCB9'] = '\u0638\u0645';
  37111. t['\uFCBA'] = '\u0639\u062C';
  37112. t['\uFCBB'] = '\u0639\u0645';
  37113. t['\uFCBC'] = '\u063A\u062C';
  37114. t['\uFCBD'] = '\u063A\u0645';
  37115. t['\uFCBE'] = '\u0641\u062C';
  37116. t['\uFCBF'] = '\u0641\u062D';
  37117. t['\uFCC0'] = '\u0641\u062E';
  37118. t['\uFCC1'] = '\u0641\u0645';
  37119. t['\uFCC2'] = '\u0642\u062D';
  37120. t['\uFCC3'] = '\u0642\u0645';
  37121. t['\uFCC4'] = '\u0643\u062C';
  37122. t['\uFCC5'] = '\u0643\u062D';
  37123. t['\uFCC6'] = '\u0643\u062E';
  37124. t['\uFCC7'] = '\u0643\u0644';
  37125. t['\uFCC8'] = '\u0643\u0645';
  37126. t['\uFCC9'] = '\u0644\u062C';
  37127. t['\uFCCA'] = '\u0644\u062D';
  37128. t['\uFCCB'] = '\u0644\u062E';
  37129. t['\uFCCC'] = '\u0644\u0645';
  37130. t['\uFCCD'] = '\u0644\u0647';
  37131. t['\uFCCE'] = '\u0645\u062C';
  37132. t['\uFCCF'] = '\u0645\u062D';
  37133. t['\uFCD0'] = '\u0645\u062E';
  37134. t['\uFCD1'] = '\u0645\u0645';
  37135. t['\uFCD2'] = '\u0646\u062C';
  37136. t['\uFCD3'] = '\u0646\u062D';
  37137. t['\uFCD4'] = '\u0646\u062E';
  37138. t['\uFCD5'] = '\u0646\u0645';
  37139. t['\uFCD6'] = '\u0646\u0647';
  37140. t['\uFCD7'] = '\u0647\u062C';
  37141. t['\uFCD8'] = '\u0647\u0645';
  37142. t['\uFCD9'] = '\u0647\u0670';
  37143. t['\uFCDA'] = '\u064A\u062C';
  37144. t['\uFCDB'] = '\u064A\u062D';
  37145. t['\uFCDC'] = '\u064A\u062E';
  37146. t['\uFCDD'] = '\u064A\u0645';
  37147. t['\uFCDE'] = '\u064A\u0647';
  37148. t['\uFCDF'] = '\u0626\u0645';
  37149. t['\uFCE0'] = '\u0626\u0647';
  37150. t['\uFCE1'] = '\u0628\u0645';
  37151. t['\uFCE2'] = '\u0628\u0647';
  37152. t['\uFCE3'] = '\u062A\u0645';
  37153. t['\uFCE4'] = '\u062A\u0647';
  37154. t['\uFCE5'] = '\u062B\u0645';
  37155. t['\uFCE6'] = '\u062B\u0647';
  37156. t['\uFCE7'] = '\u0633\u0645';
  37157. t['\uFCE8'] = '\u0633\u0647';
  37158. t['\uFCE9'] = '\u0634\u0645';
  37159. t['\uFCEA'] = '\u0634\u0647';
  37160. t['\uFCEB'] = '\u0643\u0644';
  37161. t['\uFCEC'] = '\u0643\u0645';
  37162. t['\uFCED'] = '\u0644\u0645';
  37163. t['\uFCEE'] = '\u0646\u0645';
  37164. t['\uFCEF'] = '\u0646\u0647';
  37165. t['\uFCF0'] = '\u064A\u0645';
  37166. t['\uFCF1'] = '\u064A\u0647';
  37167. t['\uFCF2'] = '\u0640\u064E\u0651';
  37168. t['\uFCF3'] = '\u0640\u064F\u0651';
  37169. t['\uFCF4'] = '\u0640\u0650\u0651';
  37170. t['\uFCF5'] = '\u0637\u0649';
  37171. t['\uFCF6'] = '\u0637\u064A';
  37172. t['\uFCF7'] = '\u0639\u0649';
  37173. t['\uFCF8'] = '\u0639\u064A';
  37174. t['\uFCF9'] = '\u063A\u0649';
  37175. t['\uFCFA'] = '\u063A\u064A';
  37176. t['\uFCFB'] = '\u0633\u0649';
  37177. t['\uFCFC'] = '\u0633\u064A';
  37178. t['\uFCFD'] = '\u0634\u0649';
  37179. t['\uFCFE'] = '\u0634\u064A';
  37180. t['\uFCFF'] = '\u062D\u0649';
  37181. t['\uFD00'] = '\u062D\u064A';
  37182. t['\uFD01'] = '\u062C\u0649';
  37183. t['\uFD02'] = '\u062C\u064A';
  37184. t['\uFD03'] = '\u062E\u0649';
  37185. t['\uFD04'] = '\u062E\u064A';
  37186. t['\uFD05'] = '\u0635\u0649';
  37187. t['\uFD06'] = '\u0635\u064A';
  37188. t['\uFD07'] = '\u0636\u0649';
  37189. t['\uFD08'] = '\u0636\u064A';
  37190. t['\uFD09'] = '\u0634\u062C';
  37191. t['\uFD0A'] = '\u0634\u062D';
  37192. t['\uFD0B'] = '\u0634\u062E';
  37193. t['\uFD0C'] = '\u0634\u0645';
  37194. t['\uFD0D'] = '\u0634\u0631';
  37195. t['\uFD0E'] = '\u0633\u0631';
  37196. t['\uFD0F'] = '\u0635\u0631';
  37197. t['\uFD10'] = '\u0636\u0631';
  37198. t['\uFD11'] = '\u0637\u0649';
  37199. t['\uFD12'] = '\u0637\u064A';
  37200. t['\uFD13'] = '\u0639\u0649';
  37201. t['\uFD14'] = '\u0639\u064A';
  37202. t['\uFD15'] = '\u063A\u0649';
  37203. t['\uFD16'] = '\u063A\u064A';
  37204. t['\uFD17'] = '\u0633\u0649';
  37205. t['\uFD18'] = '\u0633\u064A';
  37206. t['\uFD19'] = '\u0634\u0649';
  37207. t['\uFD1A'] = '\u0634\u064A';
  37208. t['\uFD1B'] = '\u062D\u0649';
  37209. t['\uFD1C'] = '\u062D\u064A';
  37210. t['\uFD1D'] = '\u062C\u0649';
  37211. t['\uFD1E'] = '\u062C\u064A';
  37212. t['\uFD1F'] = '\u062E\u0649';
  37213. t['\uFD20'] = '\u062E\u064A';
  37214. t['\uFD21'] = '\u0635\u0649';
  37215. t['\uFD22'] = '\u0635\u064A';
  37216. t['\uFD23'] = '\u0636\u0649';
  37217. t['\uFD24'] = '\u0636\u064A';
  37218. t['\uFD25'] = '\u0634\u062C';
  37219. t['\uFD26'] = '\u0634\u062D';
  37220. t['\uFD27'] = '\u0634\u062E';
  37221. t['\uFD28'] = '\u0634\u0645';
  37222. t['\uFD29'] = '\u0634\u0631';
  37223. t['\uFD2A'] = '\u0633\u0631';
  37224. t['\uFD2B'] = '\u0635\u0631';
  37225. t['\uFD2C'] = '\u0636\u0631';
  37226. t['\uFD2D'] = '\u0634\u062C';
  37227. t['\uFD2E'] = '\u0634\u062D';
  37228. t['\uFD2F'] = '\u0634\u062E';
  37229. t['\uFD30'] = '\u0634\u0645';
  37230. t['\uFD31'] = '\u0633\u0647';
  37231. t['\uFD32'] = '\u0634\u0647';
  37232. t['\uFD33'] = '\u0637\u0645';
  37233. t['\uFD34'] = '\u0633\u062C';
  37234. t['\uFD35'] = '\u0633\u062D';
  37235. t['\uFD36'] = '\u0633\u062E';
  37236. t['\uFD37'] = '\u0634\u062C';
  37237. t['\uFD38'] = '\u0634\u062D';
  37238. t['\uFD39'] = '\u0634\u062E';
  37239. t['\uFD3A'] = '\u0637\u0645';
  37240. t['\uFD3B'] = '\u0638\u0645';
  37241. t['\uFD3C'] = '\u0627\u064B';
  37242. t['\uFD3D'] = '\u0627\u064B';
  37243. t['\uFD50'] = '\u062A\u062C\u0645';
  37244. t['\uFD51'] = '\u062A\u062D\u062C';
  37245. t['\uFD52'] = '\u062A\u062D\u062C';
  37246. t['\uFD53'] = '\u062A\u062D\u0645';
  37247. t['\uFD54'] = '\u062A\u062E\u0645';
  37248. t['\uFD55'] = '\u062A\u0645\u062C';
  37249. t['\uFD56'] = '\u062A\u0645\u062D';
  37250. t['\uFD57'] = '\u062A\u0645\u062E';
  37251. t['\uFD58'] = '\u062C\u0645\u062D';
  37252. t['\uFD59'] = '\u062C\u0645\u062D';
  37253. t['\uFD5A'] = '\u062D\u0645\u064A';
  37254. t['\uFD5B'] = '\u062D\u0645\u0649';
  37255. t['\uFD5C'] = '\u0633\u062D\u062C';
  37256. t['\uFD5D'] = '\u0633\u062C\u062D';
  37257. t['\uFD5E'] = '\u0633\u062C\u0649';
  37258. t['\uFD5F'] = '\u0633\u0645\u062D';
  37259. t['\uFD60'] = '\u0633\u0645\u062D';
  37260. t['\uFD61'] = '\u0633\u0645\u062C';
  37261. t['\uFD62'] = '\u0633\u0645\u0645';
  37262. t['\uFD63'] = '\u0633\u0645\u0645';
  37263. t['\uFD64'] = '\u0635\u062D\u062D';
  37264. t['\uFD65'] = '\u0635\u062D\u062D';
  37265. t['\uFD66'] = '\u0635\u0645\u0645';
  37266. t['\uFD67'] = '\u0634\u062D\u0645';
  37267. t['\uFD68'] = '\u0634\u062D\u0645';
  37268. t['\uFD69'] = '\u0634\u062C\u064A';
  37269. t['\uFD6A'] = '\u0634\u0645\u062E';
  37270. t['\uFD6B'] = '\u0634\u0645\u062E';
  37271. t['\uFD6C'] = '\u0634\u0645\u0645';
  37272. t['\uFD6D'] = '\u0634\u0645\u0645';
  37273. t['\uFD6E'] = '\u0636\u062D\u0649';
  37274. t['\uFD6F'] = '\u0636\u062E\u0645';
  37275. t['\uFD70'] = '\u0636\u062E\u0645';
  37276. t['\uFD71'] = '\u0637\u0645\u062D';
  37277. t['\uFD72'] = '\u0637\u0645\u062D';
  37278. t['\uFD73'] = '\u0637\u0645\u0645';
  37279. t['\uFD74'] = '\u0637\u0645\u064A';
  37280. t['\uFD75'] = '\u0639\u062C\u0645';
  37281. t['\uFD76'] = '\u0639\u0645\u0645';
  37282. t['\uFD77'] = '\u0639\u0645\u0645';
  37283. t['\uFD78'] = '\u0639\u0645\u0649';
  37284. t['\uFD79'] = '\u063A\u0645\u0645';
  37285. t['\uFD7A'] = '\u063A\u0645\u064A';
  37286. t['\uFD7B'] = '\u063A\u0645\u0649';
  37287. t['\uFD7C'] = '\u0641\u062E\u0645';
  37288. t['\uFD7D'] = '\u0641\u062E\u0645';
  37289. t['\uFD7E'] = '\u0642\u0645\u062D';
  37290. t['\uFD7F'] = '\u0642\u0645\u0645';
  37291. t['\uFD80'] = '\u0644\u062D\u0645';
  37292. t['\uFD81'] = '\u0644\u062D\u064A';
  37293. t['\uFD82'] = '\u0644\u062D\u0649';
  37294. t['\uFD83'] = '\u0644\u062C\u062C';
  37295. t['\uFD84'] = '\u0644\u062C\u062C';
  37296. t['\uFD85'] = '\u0644\u062E\u0645';
  37297. t['\uFD86'] = '\u0644\u062E\u0645';
  37298. t['\uFD87'] = '\u0644\u0645\u062D';
  37299. t['\uFD88'] = '\u0644\u0645\u062D';
  37300. t['\uFD89'] = '\u0645\u062D\u062C';
  37301. t['\uFD8A'] = '\u0645\u062D\u0645';
  37302. t['\uFD8B'] = '\u0645\u062D\u064A';
  37303. t['\uFD8C'] = '\u0645\u062C\u062D';
  37304. t['\uFD8D'] = '\u0645\u062C\u0645';
  37305. t['\uFD8E'] = '\u0645\u062E\u062C';
  37306. t['\uFD8F'] = '\u0645\u062E\u0645';
  37307. t['\uFD92'] = '\u0645\u062C\u062E';
  37308. t['\uFD93'] = '\u0647\u0645\u062C';
  37309. t['\uFD94'] = '\u0647\u0645\u0645';
  37310. t['\uFD95'] = '\u0646\u062D\u0645';
  37311. t['\uFD96'] = '\u0646\u062D\u0649';
  37312. t['\uFD97'] = '\u0646\u062C\u0645';
  37313. t['\uFD98'] = '\u0646\u062C\u0645';
  37314. t['\uFD99'] = '\u0646\u062C\u0649';
  37315. t['\uFD9A'] = '\u0646\u0645\u064A';
  37316. t['\uFD9B'] = '\u0646\u0645\u0649';
  37317. t['\uFD9C'] = '\u064A\u0645\u0645';
  37318. t['\uFD9D'] = '\u064A\u0645\u0645';
  37319. t['\uFD9E'] = '\u0628\u062E\u064A';
  37320. t['\uFD9F'] = '\u062A\u062C\u064A';
  37321. t['\uFDA0'] = '\u062A\u062C\u0649';
  37322. t['\uFDA1'] = '\u062A\u062E\u064A';
  37323. t['\uFDA2'] = '\u062A\u062E\u0649';
  37324. t['\uFDA3'] = '\u062A\u0645\u064A';
  37325. t['\uFDA4'] = '\u062A\u0645\u0649';
  37326. t['\uFDA5'] = '\u062C\u0645\u064A';
  37327. t['\uFDA6'] = '\u062C\u062D\u0649';
  37328. t['\uFDA7'] = '\u062C\u0645\u0649';
  37329. t['\uFDA8'] = '\u0633\u062E\u0649';
  37330. t['\uFDA9'] = '\u0635\u062D\u064A';
  37331. t['\uFDAA'] = '\u0634\u062D\u064A';
  37332. t['\uFDAB'] = '\u0636\u062D\u064A';
  37333. t['\uFDAC'] = '\u0644\u062C\u064A';
  37334. t['\uFDAD'] = '\u0644\u0645\u064A';
  37335. t['\uFDAE'] = '\u064A\u062D\u064A';
  37336. t['\uFDAF'] = '\u064A\u062C\u064A';
  37337. t['\uFDB0'] = '\u064A\u0645\u064A';
  37338. t['\uFDB1'] = '\u0645\u0645\u064A';
  37339. t['\uFDB2'] = '\u0642\u0645\u064A';
  37340. t['\uFDB3'] = '\u0646\u062D\u064A';
  37341. t['\uFDB4'] = '\u0642\u0645\u062D';
  37342. t['\uFDB5'] = '\u0644\u062D\u0645';
  37343. t['\uFDB6'] = '\u0639\u0645\u064A';
  37344. t['\uFDB7'] = '\u0643\u0645\u064A';
  37345. t['\uFDB8'] = '\u0646\u062C\u062D';
  37346. t['\uFDB9'] = '\u0645\u062E\u064A';
  37347. t['\uFDBA'] = '\u0644\u062C\u0645';
  37348. t['\uFDBB'] = '\u0643\u0645\u0645';
  37349. t['\uFDBC'] = '\u0644\u062C\u0645';
  37350. t['\uFDBD'] = '\u0646\u062C\u062D';
  37351. t['\uFDBE'] = '\u062C\u062D\u064A';
  37352. t['\uFDBF'] = '\u062D\u062C\u064A';
  37353. t['\uFDC0'] = '\u0645\u062C\u064A';
  37354. t['\uFDC1'] = '\u0641\u0645\u064A';
  37355. t['\uFDC2'] = '\u0628\u062D\u064A';
  37356. t['\uFDC3'] = '\u0643\u0645\u0645';
  37357. t['\uFDC4'] = '\u0639\u062C\u0645';
  37358. t['\uFDC5'] = '\u0635\u0645\u0645';
  37359. t['\uFDC6'] = '\u0633\u062E\u064A';
  37360. t['\uFDC7'] = '\u0646\u062C\u064A';
  37361. t['\uFE49'] = '\u203E';
  37362. t['\uFE4A'] = '\u203E';
  37363. t['\uFE4B'] = '\u203E';
  37364. t['\uFE4C'] = '\u203E';
  37365. t['\uFE4D'] = '\u005F';
  37366. t['\uFE4E'] = '\u005F';
  37367. t['\uFE4F'] = '\u005F';
  37368. t['\uFE80'] = '\u0621';
  37369. t['\uFE81'] = '\u0622';
  37370. t['\uFE82'] = '\u0622';
  37371. t['\uFE83'] = '\u0623';
  37372. t['\uFE84'] = '\u0623';
  37373. t['\uFE85'] = '\u0624';
  37374. t['\uFE86'] = '\u0624';
  37375. t['\uFE87'] = '\u0625';
  37376. t['\uFE88'] = '\u0625';
  37377. t['\uFE89'] = '\u0626';
  37378. t['\uFE8A'] = '\u0626';
  37379. t['\uFE8B'] = '\u0626';
  37380. t['\uFE8C'] = '\u0626';
  37381. t['\uFE8D'] = '\u0627';
  37382. t['\uFE8E'] = '\u0627';
  37383. t['\uFE8F'] = '\u0628';
  37384. t['\uFE90'] = '\u0628';
  37385. t['\uFE91'] = '\u0628';
  37386. t['\uFE92'] = '\u0628';
  37387. t['\uFE93'] = '\u0629';
  37388. t['\uFE94'] = '\u0629';
  37389. t['\uFE95'] = '\u062A';
  37390. t['\uFE96'] = '\u062A';
  37391. t['\uFE97'] = '\u062A';
  37392. t['\uFE98'] = '\u062A';
  37393. t['\uFE99'] = '\u062B';
  37394. t['\uFE9A'] = '\u062B';
  37395. t['\uFE9B'] = '\u062B';
  37396. t['\uFE9C'] = '\u062B';
  37397. t['\uFE9D'] = '\u062C';
  37398. t['\uFE9E'] = '\u062C';
  37399. t['\uFE9F'] = '\u062C';
  37400. t['\uFEA0'] = '\u062C';
  37401. t['\uFEA1'] = '\u062D';
  37402. t['\uFEA2'] = '\u062D';
  37403. t['\uFEA3'] = '\u062D';
  37404. t['\uFEA4'] = '\u062D';
  37405. t['\uFEA5'] = '\u062E';
  37406. t['\uFEA6'] = '\u062E';
  37407. t['\uFEA7'] = '\u062E';
  37408. t['\uFEA8'] = '\u062E';
  37409. t['\uFEA9'] = '\u062F';
  37410. t['\uFEAA'] = '\u062F';
  37411. t['\uFEAB'] = '\u0630';
  37412. t['\uFEAC'] = '\u0630';
  37413. t['\uFEAD'] = '\u0631';
  37414. t['\uFEAE'] = '\u0631';
  37415. t['\uFEAF'] = '\u0632';
  37416. t['\uFEB0'] = '\u0632';
  37417. t['\uFEB1'] = '\u0633';
  37418. t['\uFEB2'] = '\u0633';
  37419. t['\uFEB3'] = '\u0633';
  37420. t['\uFEB4'] = '\u0633';
  37421. t['\uFEB5'] = '\u0634';
  37422. t['\uFEB6'] = '\u0634';
  37423. t['\uFEB7'] = '\u0634';
  37424. t['\uFEB8'] = '\u0634';
  37425. t['\uFEB9'] = '\u0635';
  37426. t['\uFEBA'] = '\u0635';
  37427. t['\uFEBB'] = '\u0635';
  37428. t['\uFEBC'] = '\u0635';
  37429. t['\uFEBD'] = '\u0636';
  37430. t['\uFEBE'] = '\u0636';
  37431. t['\uFEBF'] = '\u0636';
  37432. t['\uFEC0'] = '\u0636';
  37433. t['\uFEC1'] = '\u0637';
  37434. t['\uFEC2'] = '\u0637';
  37435. t['\uFEC3'] = '\u0637';
  37436. t['\uFEC4'] = '\u0637';
  37437. t['\uFEC5'] = '\u0638';
  37438. t['\uFEC6'] = '\u0638';
  37439. t['\uFEC7'] = '\u0638';
  37440. t['\uFEC8'] = '\u0638';
  37441. t['\uFEC9'] = '\u0639';
  37442. t['\uFECA'] = '\u0639';
  37443. t['\uFECB'] = '\u0639';
  37444. t['\uFECC'] = '\u0639';
  37445. t['\uFECD'] = '\u063A';
  37446. t['\uFECE'] = '\u063A';
  37447. t['\uFECF'] = '\u063A';
  37448. t['\uFED0'] = '\u063A';
  37449. t['\uFED1'] = '\u0641';
  37450. t['\uFED2'] = '\u0641';
  37451. t['\uFED3'] = '\u0641';
  37452. t['\uFED4'] = '\u0641';
  37453. t['\uFED5'] = '\u0642';
  37454. t['\uFED6'] = '\u0642';
  37455. t['\uFED7'] = '\u0642';
  37456. t['\uFED8'] = '\u0642';
  37457. t['\uFED9'] = '\u0643';
  37458. t['\uFEDA'] = '\u0643';
  37459. t['\uFEDB'] = '\u0643';
  37460. t['\uFEDC'] = '\u0643';
  37461. t['\uFEDD'] = '\u0644';
  37462. t['\uFEDE'] = '\u0644';
  37463. t['\uFEDF'] = '\u0644';
  37464. t['\uFEE0'] = '\u0644';
  37465. t['\uFEE1'] = '\u0645';
  37466. t['\uFEE2'] = '\u0645';
  37467. t['\uFEE3'] = '\u0645';
  37468. t['\uFEE4'] = '\u0645';
  37469. t['\uFEE5'] = '\u0646';
  37470. t['\uFEE6'] = '\u0646';
  37471. t['\uFEE7'] = '\u0646';
  37472. t['\uFEE8'] = '\u0646';
  37473. t['\uFEE9'] = '\u0647';
  37474. t['\uFEEA'] = '\u0647';
  37475. t['\uFEEB'] = '\u0647';
  37476. t['\uFEEC'] = '\u0647';
  37477. t['\uFEED'] = '\u0648';
  37478. t['\uFEEE'] = '\u0648';
  37479. t['\uFEEF'] = '\u0649';
  37480. t['\uFEF0'] = '\u0649';
  37481. t['\uFEF1'] = '\u064A';
  37482. t['\uFEF2'] = '\u064A';
  37483. t['\uFEF3'] = '\u064A';
  37484. t['\uFEF4'] = '\u064A';
  37485. t['\uFEF5'] = '\u0644\u0622';
  37486. t['\uFEF6'] = '\u0644\u0622';
  37487. t['\uFEF7'] = '\u0644\u0623';
  37488. t['\uFEF8'] = '\u0644\u0623';
  37489. t['\uFEF9'] = '\u0644\u0625';
  37490. t['\uFEFA'] = '\u0644\u0625';
  37491. t['\uFEFB'] = '\u0644\u0627';
  37492. t['\uFEFC'] = '\u0644\u0627';
  37493. });
  37494. function reverseIfRtl(chars) {
  37495. var charsLength = chars.length;
  37496. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  37497. return chars;
  37498. }
  37499. var s = '';
  37500. for (var ii = charsLength - 1; ii >= 0; ii--) {
  37501. s += chars[ii];
  37502. }
  37503. return s;
  37504. }
  37505. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  37506. exports.reverseIfRtl = reverseIfRtl;
  37507. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  37508. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  37509. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  37510. /***/ }),
  37511. /* 23 */
  37512. /***/ (function(module, exports, __w_pdfjs_require__) {
  37513. "use strict";
  37514. var sharedUtil = __w_pdfjs_require__(0);
  37515. var corePrimitives = __w_pdfjs_require__(1);
  37516. var corePdfManager = __w_pdfjs_require__(41);
  37517. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  37518. var InvalidPDFException = sharedUtil.InvalidPDFException;
  37519. var MessageHandler = sharedUtil.MessageHandler;
  37520. var MissingPDFException = sharedUtil.MissingPDFException;
  37521. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  37522. var PasswordException = sharedUtil.PasswordException;
  37523. var UnknownErrorException = sharedUtil.UnknownErrorException;
  37524. var XRefParseException = sharedUtil.XRefParseException;
  37525. var arrayByteLength = sharedUtil.arrayByteLength;
  37526. var arraysToBytes = sharedUtil.arraysToBytes;
  37527. var assert = sharedUtil.assert;
  37528. var createPromiseCapability = sharedUtil.createPromiseCapability;
  37529. var info = sharedUtil.info;
  37530. var warn = sharedUtil.warn;
  37531. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  37532. var isNodeJS = sharedUtil.isNodeJS;
  37533. var Ref = corePrimitives.Ref;
  37534. var LocalPdfManager = corePdfManager.LocalPdfManager;
  37535. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  37536. var WorkerTask = function WorkerTaskClosure() {
  37537. function WorkerTask(name) {
  37538. this.name = name;
  37539. this.terminated = false;
  37540. this._capability = createPromiseCapability();
  37541. }
  37542. WorkerTask.prototype = {
  37543. get finished() {
  37544. return this._capability.promise;
  37545. },
  37546. finish: function () {
  37547. this._capability.resolve();
  37548. },
  37549. terminate: function () {
  37550. this.terminated = true;
  37551. },
  37552. ensureNotTerminated: function () {
  37553. if (this.terminated) {
  37554. throw new Error('Worker task was terminated');
  37555. }
  37556. }
  37557. };
  37558. return WorkerTask;
  37559. }();
  37560. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  37561. function PDFWorkerStream(params, msgHandler) {
  37562. this._queuedChunks = [];
  37563. var initialData = params.initialData;
  37564. if (initialData && initialData.length > 0) {
  37565. this._queuedChunks.push(initialData);
  37566. }
  37567. this._msgHandler = msgHandler;
  37568. this._isRangeSupported = !params.disableRange;
  37569. this._isStreamingSupported = !params.disableStream;
  37570. this._contentLength = params.length;
  37571. this._fullRequestReader = null;
  37572. this._rangeReaders = [];
  37573. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  37574. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  37575. }
  37576. PDFWorkerStream.prototype = {
  37577. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  37578. if (args.begin === undefined) {
  37579. if (this._fullRequestReader) {
  37580. this._fullRequestReader._enqueue(args.chunk);
  37581. } else {
  37582. this._queuedChunks.push(args.chunk);
  37583. }
  37584. } else {
  37585. var found = this._rangeReaders.some(function (rangeReader) {
  37586. if (rangeReader._begin !== args.begin) {
  37587. return false;
  37588. }
  37589. rangeReader._enqueue(args.chunk);
  37590. return true;
  37591. });
  37592. assert(found);
  37593. }
  37594. },
  37595. _onProgress: function PDFWorkerStream_onProgress(evt) {
  37596. if (this._rangeReaders.length > 0) {
  37597. var firstReader = this._rangeReaders[0];
  37598. if (firstReader.onProgress) {
  37599. firstReader.onProgress({ loaded: evt.loaded });
  37600. }
  37601. }
  37602. },
  37603. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  37604. var i = this._rangeReaders.indexOf(reader);
  37605. if (i >= 0) {
  37606. this._rangeReaders.splice(i, 1);
  37607. }
  37608. },
  37609. getFullReader: function PDFWorkerStream_getFullReader() {
  37610. assert(!this._fullRequestReader);
  37611. var queuedChunks = this._queuedChunks;
  37612. this._queuedChunks = null;
  37613. return new PDFWorkerStreamReader(this, queuedChunks);
  37614. },
  37615. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  37616. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  37617. this._msgHandler.send('RequestDataRange', {
  37618. begin: begin,
  37619. end: end
  37620. });
  37621. this._rangeReaders.push(reader);
  37622. return reader;
  37623. },
  37624. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  37625. if (this._fullRequestReader) {
  37626. this._fullRequestReader.cancel(reason);
  37627. }
  37628. var readers = this._rangeReaders.slice(0);
  37629. readers.forEach(function (rangeReader) {
  37630. rangeReader.cancel(reason);
  37631. });
  37632. }
  37633. };
  37634. function PDFWorkerStreamReader(stream, queuedChunks) {
  37635. this._stream = stream;
  37636. this._done = false;
  37637. this._queuedChunks = queuedChunks || [];
  37638. this._requests = [];
  37639. this._headersReady = Promise.resolve();
  37640. stream._fullRequestReader = this;
  37641. this.onProgress = null;
  37642. }
  37643. PDFWorkerStreamReader.prototype = {
  37644. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  37645. if (this._done) {
  37646. return;
  37647. }
  37648. if (this._requests.length > 0) {
  37649. var requestCapability = this._requests.shift();
  37650. requestCapability.resolve({
  37651. value: chunk,
  37652. done: false
  37653. });
  37654. return;
  37655. }
  37656. this._queuedChunks.push(chunk);
  37657. },
  37658. get headersReady() {
  37659. return this._headersReady;
  37660. },
  37661. get isRangeSupported() {
  37662. return this._stream._isRangeSupported;
  37663. },
  37664. get isStreamingSupported() {
  37665. return this._stream._isStreamingSupported;
  37666. },
  37667. get contentLength() {
  37668. return this._stream._contentLength;
  37669. },
  37670. read: function PDFWorkerStreamReader_read() {
  37671. if (this._queuedChunks.length > 0) {
  37672. var chunk = this._queuedChunks.shift();
  37673. return Promise.resolve({
  37674. value: chunk,
  37675. done: false
  37676. });
  37677. }
  37678. if (this._done) {
  37679. return Promise.resolve({
  37680. value: undefined,
  37681. done: true
  37682. });
  37683. }
  37684. var requestCapability = createPromiseCapability();
  37685. this._requests.push(requestCapability);
  37686. return requestCapability.promise;
  37687. },
  37688. cancel: function PDFWorkerStreamReader_cancel(reason) {
  37689. this._done = true;
  37690. this._requests.forEach(function (requestCapability) {
  37691. requestCapability.resolve({
  37692. value: undefined,
  37693. done: true
  37694. });
  37695. });
  37696. this._requests = [];
  37697. }
  37698. };
  37699. function PDFWorkerStreamRangeReader(stream, begin, end) {
  37700. this._stream = stream;
  37701. this._begin = begin;
  37702. this._end = end;
  37703. this._queuedChunk = null;
  37704. this._requests = [];
  37705. this._done = false;
  37706. this.onProgress = null;
  37707. }
  37708. PDFWorkerStreamRangeReader.prototype = {
  37709. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  37710. if (this._done) {
  37711. return;
  37712. }
  37713. if (this._requests.length === 0) {
  37714. this._queuedChunk = chunk;
  37715. } else {
  37716. var requestsCapability = this._requests.shift();
  37717. requestsCapability.resolve({
  37718. value: chunk,
  37719. done: false
  37720. });
  37721. this._requests.forEach(function (requestCapability) {
  37722. requestCapability.resolve({
  37723. value: undefined,
  37724. done: true
  37725. });
  37726. });
  37727. this._requests = [];
  37728. }
  37729. this._done = true;
  37730. this._stream._removeRangeReader(this);
  37731. },
  37732. get isStreamingSupported() {
  37733. return false;
  37734. },
  37735. read: function PDFWorkerStreamRangeReader_read() {
  37736. if (this._queuedChunk) {
  37737. return Promise.resolve({
  37738. value: this._queuedChunk,
  37739. done: false
  37740. });
  37741. }
  37742. if (this._done) {
  37743. return Promise.resolve({
  37744. value: undefined,
  37745. done: true
  37746. });
  37747. }
  37748. var requestCapability = createPromiseCapability();
  37749. this._requests.push(requestCapability);
  37750. return requestCapability.promise;
  37751. },
  37752. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  37753. this._done = true;
  37754. this._requests.forEach(function (requestCapability) {
  37755. requestCapability.resolve({
  37756. value: undefined,
  37757. done: true
  37758. });
  37759. });
  37760. this._requests = [];
  37761. this._stream._removeRangeReader(this);
  37762. }
  37763. };
  37764. return PDFWorkerStream;
  37765. }();
  37766. var PDFNetworkStream;
  37767. function setPDFNetworkStreamClass(cls) {
  37768. PDFNetworkStream = cls;
  37769. }
  37770. var WorkerMessageHandler = {
  37771. setup: function wphSetup(handler, port) {
  37772. var testMessageProcessed = false;
  37773. handler.on('test', function wphSetupTest(data) {
  37774. if (testMessageProcessed) {
  37775. return;
  37776. }
  37777. testMessageProcessed = true;
  37778. if (!(data instanceof Uint8Array)) {
  37779. handler.send('test', 'main', false);
  37780. return;
  37781. }
  37782. var supportTransfers = data[0] === 255;
  37783. handler.postMessageTransfers = supportTransfers;
  37784. var xhr = new XMLHttpRequest();
  37785. var responseExists = 'response' in xhr;
  37786. try {
  37787. xhr.responseType;
  37788. } catch (e) {
  37789. responseExists = false;
  37790. }
  37791. if (!responseExists) {
  37792. handler.send('test', false);
  37793. return;
  37794. }
  37795. handler.send('test', {
  37796. supportTypedArray: true,
  37797. supportTransfers: supportTransfers
  37798. });
  37799. });
  37800. handler.on('configure', function wphConfigure(data) {
  37801. setVerbosityLevel(data.verbosity);
  37802. });
  37803. handler.on('GetDocRequest', function wphSetupDoc(data) {
  37804. return WorkerMessageHandler.createDocumentHandler(data, port);
  37805. });
  37806. },
  37807. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  37808. var pdfManager;
  37809. var terminated = false;
  37810. var cancelXHRs = null;
  37811. var WorkerTasks = [];
  37812. var docId = docParams.docId;
  37813. var docBaseUrl = docParams.docBaseUrl;
  37814. var workerHandlerName = docParams.docId + '_worker';
  37815. var handler = new MessageHandler(workerHandlerName, docId, port);
  37816. handler.postMessageTransfers = docParams.postMessageTransfers;
  37817. function ensureNotTerminated() {
  37818. if (terminated) {
  37819. throw new Error('Worker was terminated');
  37820. }
  37821. }
  37822. function startWorkerTask(task) {
  37823. WorkerTasks.push(task);
  37824. }
  37825. function finishWorkerTask(task) {
  37826. task.finish();
  37827. var i = WorkerTasks.indexOf(task);
  37828. WorkerTasks.splice(i, 1);
  37829. }
  37830. function loadDocument(recoveryMode) {
  37831. var loadDocumentCapability = createPromiseCapability();
  37832. var parseSuccess = function parseSuccess() {
  37833. var numPagesPromise = pdfManager.ensureDoc('numPages');
  37834. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  37835. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  37836. Promise.all([
  37837. numPagesPromise,
  37838. fingerprintPromise,
  37839. encryptedPromise
  37840. ]).then(function onDocReady(results) {
  37841. var doc = {
  37842. numPages: results[0],
  37843. fingerprint: results[1],
  37844. encrypted: !!results[2]
  37845. };
  37846. loadDocumentCapability.resolve(doc);
  37847. }, parseFailure);
  37848. };
  37849. var parseFailure = function parseFailure(e) {
  37850. loadDocumentCapability.reject(e);
  37851. };
  37852. pdfManager.ensureDoc('checkHeader', []).then(function () {
  37853. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  37854. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  37855. }, parseFailure);
  37856. }, parseFailure);
  37857. return loadDocumentCapability.promise;
  37858. }
  37859. function getPdfManager(data, evaluatorOptions) {
  37860. var pdfManagerCapability = createPromiseCapability();
  37861. var pdfManager;
  37862. var source = data.source;
  37863. if (source.data) {
  37864. try {
  37865. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  37866. pdfManagerCapability.resolve(pdfManager);
  37867. } catch (ex) {
  37868. pdfManagerCapability.reject(ex);
  37869. }
  37870. return pdfManagerCapability.promise;
  37871. }
  37872. var pdfStream;
  37873. try {
  37874. if (source.chunkedViewerLoading) {
  37875. pdfStream = new PDFWorkerStream(source, handler);
  37876. } else {
  37877. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  37878. pdfStream = new PDFNetworkStream(data);
  37879. }
  37880. } catch (ex) {
  37881. pdfManagerCapability.reject(ex);
  37882. return pdfManagerCapability.promise;
  37883. }
  37884. var fullRequest = pdfStream.getFullReader();
  37885. fullRequest.headersReady.then(function () {
  37886. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  37887. fullRequest.onProgress = function (evt) {
  37888. handler.send('DocProgress', {
  37889. loaded: evt.loaded,
  37890. total: evt.total
  37891. });
  37892. };
  37893. }
  37894. if (!fullRequest.isRangeSupported) {
  37895. return;
  37896. }
  37897. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  37898. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  37899. msgHandler: handler,
  37900. url: source.url,
  37901. password: source.password,
  37902. length: fullRequest.contentLength,
  37903. disableAutoFetch: disableAutoFetch,
  37904. rangeChunkSize: source.rangeChunkSize
  37905. }, evaluatorOptions, docBaseUrl);
  37906. pdfManagerCapability.resolve(pdfManager);
  37907. cancelXHRs = null;
  37908. }).catch(function (reason) {
  37909. pdfManagerCapability.reject(reason);
  37910. cancelXHRs = null;
  37911. });
  37912. var cachedChunks = [], loaded = 0;
  37913. var flushChunks = function () {
  37914. var pdfFile = arraysToBytes(cachedChunks);
  37915. if (source.length && pdfFile.length !== source.length) {
  37916. warn('reported HTTP length is different from actual');
  37917. }
  37918. try {
  37919. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  37920. pdfManagerCapability.resolve(pdfManager);
  37921. } catch (ex) {
  37922. pdfManagerCapability.reject(ex);
  37923. }
  37924. cachedChunks = [];
  37925. };
  37926. var readPromise = new Promise(function (resolve, reject) {
  37927. var readChunk = function (chunk) {
  37928. try {
  37929. ensureNotTerminated();
  37930. if (chunk.done) {
  37931. if (!pdfManager) {
  37932. flushChunks();
  37933. }
  37934. cancelXHRs = null;
  37935. return;
  37936. }
  37937. var data = chunk.value;
  37938. loaded += arrayByteLength(data);
  37939. if (!fullRequest.isStreamingSupported) {
  37940. handler.send('DocProgress', {
  37941. loaded: loaded,
  37942. total: Math.max(loaded, fullRequest.contentLength || 0)
  37943. });
  37944. }
  37945. if (pdfManager) {
  37946. pdfManager.sendProgressiveData(data);
  37947. } else {
  37948. cachedChunks.push(data);
  37949. }
  37950. fullRequest.read().then(readChunk, reject);
  37951. } catch (e) {
  37952. reject(e);
  37953. }
  37954. };
  37955. fullRequest.read().then(readChunk, reject);
  37956. });
  37957. readPromise.catch(function (e) {
  37958. pdfManagerCapability.reject(e);
  37959. cancelXHRs = null;
  37960. });
  37961. cancelXHRs = function () {
  37962. pdfStream.cancelAllRequests('abort');
  37963. };
  37964. return pdfManagerCapability.promise;
  37965. }
  37966. function setupDoc(data) {
  37967. function onSuccess(doc) {
  37968. ensureNotTerminated();
  37969. handler.send('GetDoc', { pdfInfo: doc });
  37970. }
  37971. function onFailure(e) {
  37972. if (e instanceof PasswordException) {
  37973. var task = new WorkerTask('PasswordException: response ' + e.code);
  37974. startWorkerTask(task);
  37975. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  37976. finishWorkerTask(task);
  37977. pdfManager.updatePassword(data.password);
  37978. pdfManagerReady();
  37979. }).catch(function (ex) {
  37980. finishWorkerTask(task);
  37981. handler.send('PasswordException', ex);
  37982. }.bind(null, e));
  37983. } else if (e instanceof InvalidPDFException) {
  37984. handler.send('InvalidPDF', e);
  37985. } else if (e instanceof MissingPDFException) {
  37986. handler.send('MissingPDF', e);
  37987. } else if (e instanceof UnexpectedResponseException) {
  37988. handler.send('UnexpectedResponse', e);
  37989. } else {
  37990. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  37991. }
  37992. }
  37993. function pdfManagerReady() {
  37994. ensureNotTerminated();
  37995. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  37996. ensureNotTerminated();
  37997. if (!(ex instanceof XRefParseException)) {
  37998. onFailure(ex);
  37999. return;
  38000. }
  38001. pdfManager.requestLoadedStream();
  38002. pdfManager.onLoadedStream().then(function () {
  38003. ensureNotTerminated();
  38004. loadDocument(true).then(onSuccess, onFailure);
  38005. });
  38006. }, onFailure);
  38007. }
  38008. ensureNotTerminated();
  38009. var evaluatorOptions = {
  38010. forceDataSchema: data.disableCreateObjectURL,
  38011. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38012. disableFontFace: data.disableFontFace,
  38013. disableNativeImageDecoder: data.disableNativeImageDecoder
  38014. };
  38015. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38016. if (terminated) {
  38017. newPdfManager.terminate();
  38018. throw new Error('Worker was terminated');
  38019. }
  38020. pdfManager = newPdfManager;
  38021. handler.send('PDFManagerReady', null);
  38022. pdfManager.onLoadedStream().then(function (stream) {
  38023. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38024. });
  38025. }).then(pdfManagerReady, onFailure);
  38026. }
  38027. handler.on('GetPage', function wphSetupGetPage(data) {
  38028. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38029. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38030. var refPromise = pdfManager.ensure(page, 'ref');
  38031. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38032. var viewPromise = pdfManager.ensure(page, 'view');
  38033. return Promise.all([
  38034. rotatePromise,
  38035. refPromise,
  38036. userUnitPromise,
  38037. viewPromise
  38038. ]).then(function (results) {
  38039. return {
  38040. rotate: results[0],
  38041. ref: results[1],
  38042. userUnit: results[2],
  38043. view: results[3]
  38044. };
  38045. });
  38046. });
  38047. });
  38048. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38049. var ref = new Ref(data.ref.num, data.ref.gen);
  38050. var catalog = pdfManager.pdfDocument.catalog;
  38051. return catalog.getPageIndex(ref);
  38052. });
  38053. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38054. return pdfManager.ensureCatalog('destinations');
  38055. });
  38056. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38057. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38058. });
  38059. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38060. return pdfManager.ensureCatalog('pageLabels');
  38061. });
  38062. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38063. return pdfManager.ensureCatalog('attachments');
  38064. });
  38065. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38066. return pdfManager.ensureCatalog('javaScript');
  38067. });
  38068. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38069. return pdfManager.ensureCatalog('documentOutline');
  38070. });
  38071. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38072. return Promise.all([
  38073. pdfManager.ensureDoc('documentInfo'),
  38074. pdfManager.ensureCatalog('metadata')
  38075. ]);
  38076. });
  38077. handler.on('GetData', function wphSetupGetData(data) {
  38078. pdfManager.requestLoadedStream();
  38079. return pdfManager.onLoadedStream().then(function (stream) {
  38080. return stream.bytes;
  38081. });
  38082. });
  38083. handler.on('GetStats', function wphSetupGetStats(data) {
  38084. return pdfManager.pdfDocument.xref.stats;
  38085. });
  38086. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38087. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38088. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38089. });
  38090. });
  38091. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38092. var pageIndex = data.pageIndex;
  38093. pdfManager.getPage(pageIndex).then(function (page) {
  38094. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38095. startWorkerTask(task);
  38096. var pageNum = pageIndex + 1;
  38097. var start = Date.now();
  38098. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38099. finishWorkerTask(task);
  38100. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38101. }, function (e) {
  38102. finishWorkerTask(task);
  38103. if (task.terminated) {
  38104. return;
  38105. }
  38106. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38107. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38108. var wrappedException;
  38109. if (typeof e === 'string') {
  38110. wrappedException = {
  38111. message: e,
  38112. stack: minimumStackMessage
  38113. };
  38114. } else if (typeof e === 'object') {
  38115. wrappedException = {
  38116. message: e.message || e.toString(),
  38117. stack: e.stack || minimumStackMessage
  38118. };
  38119. } else {
  38120. wrappedException = {
  38121. message: 'Unknown exception type: ' + typeof e,
  38122. stack: minimumStackMessage
  38123. };
  38124. }
  38125. handler.send('PageError', {
  38126. pageNum: pageNum,
  38127. error: wrappedException,
  38128. intent: data.intent
  38129. });
  38130. });
  38131. });
  38132. }, this);
  38133. handler.on('GetTextContent', function wphExtractText(data) {
  38134. var pageIndex = data.pageIndex;
  38135. var normalizeWhitespace = data.normalizeWhitespace;
  38136. var combineTextItems = data.combineTextItems;
  38137. return pdfManager.getPage(pageIndex).then(function (page) {
  38138. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38139. startWorkerTask(task);
  38140. var pageNum = pageIndex + 1;
  38141. var start = Date.now();
  38142. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38143. finishWorkerTask(task);
  38144. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38145. return textContent;
  38146. }, function (reason) {
  38147. finishWorkerTask(task);
  38148. if (task.terminated) {
  38149. return;
  38150. }
  38151. throw reason;
  38152. });
  38153. });
  38154. });
  38155. handler.on('Cleanup', function wphCleanup(data) {
  38156. return pdfManager.cleanup();
  38157. });
  38158. handler.on('Terminate', function wphTerminate(data) {
  38159. terminated = true;
  38160. if (pdfManager) {
  38161. pdfManager.terminate();
  38162. pdfManager = null;
  38163. }
  38164. if (cancelXHRs) {
  38165. cancelXHRs();
  38166. }
  38167. var waitOn = [];
  38168. WorkerTasks.forEach(function (task) {
  38169. waitOn.push(task.finished);
  38170. task.terminate();
  38171. });
  38172. return Promise.all(waitOn).then(function () {
  38173. handler.destroy();
  38174. handler = null;
  38175. });
  38176. });
  38177. handler.on('Ready', function wphReady(data) {
  38178. setupDoc(docParams);
  38179. docParams = null;
  38180. });
  38181. return workerHandlerName;
  38182. }
  38183. };
  38184. function initializeWorker() {
  38185. var handler = new MessageHandler('worker', 'main', self);
  38186. WorkerMessageHandler.setup(handler, self);
  38187. handler.send('ready', null);
  38188. }
  38189. if (typeof window === 'undefined' && !isNodeJS()) {
  38190. initializeWorker();
  38191. }
  38192. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38193. exports.WorkerTask = WorkerTask;
  38194. exports.WorkerMessageHandler = WorkerMessageHandler;
  38195. /***/ }),
  38196. /* 24 */
  38197. /***/ (function(module, exports, __w_pdfjs_require__) {
  38198. "use strict";
  38199. var sharedUtil = __w_pdfjs_require__(0);
  38200. var error = sharedUtil.error;
  38201. function fixMetadata(meta) {
  38202. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38203. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38204. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38205. });
  38206. var chars = '';
  38207. for (var i = 0; i < bytes.length; i += 2) {
  38208. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38209. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38210. }
  38211. return '>' + chars;
  38212. });
  38213. }
  38214. function Metadata(meta) {
  38215. if (typeof meta === 'string') {
  38216. meta = fixMetadata(meta);
  38217. var parser = new DOMParser();
  38218. meta = parser.parseFromString(meta, 'application/xml');
  38219. } else if (!(meta instanceof Document)) {
  38220. error('Metadata: Invalid metadata object');
  38221. }
  38222. this.metaDocument = meta;
  38223. this.metadata = Object.create(null);
  38224. this.parse();
  38225. }
  38226. Metadata.prototype = {
  38227. parse: function Metadata_parse() {
  38228. var doc = this.metaDocument;
  38229. var rdf = doc.documentElement;
  38230. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38231. rdf = rdf.firstChild;
  38232. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38233. rdf = rdf.nextSibling;
  38234. }
  38235. }
  38236. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  38237. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  38238. return;
  38239. }
  38240. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  38241. for (i = 0, length = children.length; i < length; i++) {
  38242. desc = children[i];
  38243. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  38244. continue;
  38245. }
  38246. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  38247. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  38248. entry = desc.childNodes[ii];
  38249. name = entry.nodeName.toLowerCase();
  38250. this.metadata[name] = entry.textContent.trim();
  38251. }
  38252. }
  38253. }
  38254. },
  38255. get: function Metadata_get(name) {
  38256. return this.metadata[name] || null;
  38257. },
  38258. has: function Metadata_has(name) {
  38259. return typeof this.metadata[name] !== 'undefined';
  38260. }
  38261. };
  38262. exports.Metadata = Metadata;
  38263. /***/ }),
  38264. /* 25 */
  38265. /***/ (function(module, exports, __w_pdfjs_require__) {
  38266. "use strict";
  38267. var sharedUtil = __w_pdfjs_require__(0);
  38268. var displayDOMUtils = __w_pdfjs_require__(3);
  38269. var shadow = sharedUtil.shadow;
  38270. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  38271. var WebGLUtils = function WebGLUtilsClosure() {
  38272. function loadShader(gl, code, shaderType) {
  38273. var shader = gl.createShader(shaderType);
  38274. gl.shaderSource(shader, code);
  38275. gl.compileShader(shader);
  38276. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  38277. if (!compiled) {
  38278. var errorMsg = gl.getShaderInfoLog(shader);
  38279. throw new Error('Error during shader compilation: ' + errorMsg);
  38280. }
  38281. return shader;
  38282. }
  38283. function createVertexShader(gl, code) {
  38284. return loadShader(gl, code, gl.VERTEX_SHADER);
  38285. }
  38286. function createFragmentShader(gl, code) {
  38287. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  38288. }
  38289. function createProgram(gl, shaders) {
  38290. var program = gl.createProgram();
  38291. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  38292. gl.attachShader(program, shaders[i]);
  38293. }
  38294. gl.linkProgram(program);
  38295. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  38296. if (!linked) {
  38297. var errorMsg = gl.getProgramInfoLog(program);
  38298. throw new Error('Error during program linking: ' + errorMsg);
  38299. }
  38300. return program;
  38301. }
  38302. function createTexture(gl, image, textureId) {
  38303. gl.activeTexture(textureId);
  38304. var texture = gl.createTexture();
  38305. gl.bindTexture(gl.TEXTURE_2D, texture);
  38306. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  38307. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  38308. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  38309. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  38310. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  38311. return texture;
  38312. }
  38313. var currentGL, currentCanvas;
  38314. function generateGL() {
  38315. if (currentGL) {
  38316. return;
  38317. }
  38318. currentCanvas = document.createElement('canvas');
  38319. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  38320. }
  38321. var smaskVertexShaderCode = '\
  38322. attribute vec2 a_position; \
  38323. attribute vec2 a_texCoord; \
  38324. \
  38325. uniform vec2 u_resolution; \
  38326. \
  38327. varying vec2 v_texCoord; \
  38328. \
  38329. void main() { \
  38330. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  38331. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38332. \
  38333. v_texCoord = a_texCoord; \
  38334. } ';
  38335. var smaskFragmentShaderCode = '\
  38336. precision mediump float; \
  38337. \
  38338. uniform vec4 u_backdrop; \
  38339. uniform int u_subtype; \
  38340. uniform sampler2D u_image; \
  38341. uniform sampler2D u_mask; \
  38342. \
  38343. varying vec2 v_texCoord; \
  38344. \
  38345. void main() { \
  38346. vec4 imageColor = texture2D(u_image, v_texCoord); \
  38347. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  38348. if (u_backdrop.a > 0.0) { \
  38349. maskColor.rgb = maskColor.rgb * maskColor.a + \
  38350. u_backdrop.rgb * (1.0 - maskColor.a); \
  38351. } \
  38352. float lum; \
  38353. if (u_subtype == 0) { \
  38354. lum = maskColor.a; \
  38355. } else { \
  38356. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  38357. maskColor.b * 0.11; \
  38358. } \
  38359. imageColor.a *= lum; \
  38360. imageColor.rgb *= imageColor.a; \
  38361. gl_FragColor = imageColor; \
  38362. } ';
  38363. var smaskCache = null;
  38364. function initSmaskGL() {
  38365. var canvas, gl;
  38366. generateGL();
  38367. canvas = currentCanvas;
  38368. currentCanvas = null;
  38369. gl = currentGL;
  38370. currentGL = null;
  38371. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  38372. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  38373. var program = createProgram(gl, [
  38374. vertexShader,
  38375. fragmentShader
  38376. ]);
  38377. gl.useProgram(program);
  38378. var cache = {};
  38379. cache.gl = gl;
  38380. cache.canvas = canvas;
  38381. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38382. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38383. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  38384. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  38385. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  38386. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  38387. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  38388. var texCoordBuffer = gl.createBuffer();
  38389. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  38390. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38391. 0.0,
  38392. 0.0,
  38393. 1.0,
  38394. 0.0,
  38395. 0.0,
  38396. 1.0,
  38397. 0.0,
  38398. 1.0,
  38399. 1.0,
  38400. 0.0,
  38401. 1.0,
  38402. 1.0
  38403. ]), gl.STATIC_DRAW);
  38404. gl.enableVertexAttribArray(texCoordLocation);
  38405. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  38406. gl.uniform1i(texLayerLocation, 0);
  38407. gl.uniform1i(texMaskLocation, 1);
  38408. smaskCache = cache;
  38409. }
  38410. function composeSMask(layer, mask, properties) {
  38411. var width = layer.width, height = layer.height;
  38412. if (!smaskCache) {
  38413. initSmaskGL();
  38414. }
  38415. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  38416. canvas.width = width;
  38417. canvas.height = height;
  38418. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38419. gl.uniform2f(cache.resolutionLocation, width, height);
  38420. if (properties.backdrop) {
  38421. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  38422. } else {
  38423. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  38424. }
  38425. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  38426. var texture = createTexture(gl, layer, gl.TEXTURE0);
  38427. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  38428. var buffer = gl.createBuffer();
  38429. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  38430. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38431. 0,
  38432. 0,
  38433. width,
  38434. 0,
  38435. 0,
  38436. height,
  38437. 0,
  38438. height,
  38439. width,
  38440. 0,
  38441. width,
  38442. height
  38443. ]), gl.STATIC_DRAW);
  38444. gl.enableVertexAttribArray(cache.positionLocation);
  38445. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38446. gl.clearColor(0, 0, 0, 0);
  38447. gl.enable(gl.BLEND);
  38448. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  38449. gl.clear(gl.COLOR_BUFFER_BIT);
  38450. gl.drawArrays(gl.TRIANGLES, 0, 6);
  38451. gl.flush();
  38452. gl.deleteTexture(texture);
  38453. gl.deleteTexture(maskTexture);
  38454. gl.deleteBuffer(buffer);
  38455. return canvas;
  38456. }
  38457. var figuresVertexShaderCode = '\
  38458. attribute vec2 a_position; \
  38459. attribute vec3 a_color; \
  38460. \
  38461. uniform vec2 u_resolution; \
  38462. uniform vec2 u_scale; \
  38463. uniform vec2 u_offset; \
  38464. \
  38465. varying vec4 v_color; \
  38466. \
  38467. void main() { \
  38468. vec2 position = (a_position + u_offset) * u_scale; \
  38469. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  38470. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38471. \
  38472. v_color = vec4(a_color / 255.0, 1.0); \
  38473. } ';
  38474. var figuresFragmentShaderCode = '\
  38475. precision mediump float; \
  38476. \
  38477. varying vec4 v_color; \
  38478. \
  38479. void main() { \
  38480. gl_FragColor = v_color; \
  38481. } ';
  38482. var figuresCache = null;
  38483. function initFiguresGL() {
  38484. var canvas, gl;
  38485. generateGL();
  38486. canvas = currentCanvas;
  38487. currentCanvas = null;
  38488. gl = currentGL;
  38489. currentGL = null;
  38490. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  38491. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  38492. var program = createProgram(gl, [
  38493. vertexShader,
  38494. fragmentShader
  38495. ]);
  38496. gl.useProgram(program);
  38497. var cache = {};
  38498. cache.gl = gl;
  38499. cache.canvas = canvas;
  38500. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38501. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  38502. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  38503. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38504. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  38505. figuresCache = cache;
  38506. }
  38507. function drawFigures(width, height, backgroundColor, figures, context) {
  38508. if (!figuresCache) {
  38509. initFiguresGL();
  38510. }
  38511. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  38512. canvas.width = width;
  38513. canvas.height = height;
  38514. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38515. gl.uniform2f(cache.resolutionLocation, width, height);
  38516. var count = 0;
  38517. var i, ii, rows;
  38518. for (i = 0, ii = figures.length; i < ii; i++) {
  38519. switch (figures[i].type) {
  38520. case 'lattice':
  38521. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  38522. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  38523. break;
  38524. case 'triangles':
  38525. count += figures[i].coords.length;
  38526. break;
  38527. }
  38528. }
  38529. var coords = new Float32Array(count * 2);
  38530. var colors = new Uint8Array(count * 3);
  38531. var coordsMap = context.coords, colorsMap = context.colors;
  38532. var pIndex = 0, cIndex = 0;
  38533. for (i = 0, ii = figures.length; i < ii; i++) {
  38534. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  38535. switch (figure.type) {
  38536. case 'lattice':
  38537. var cols = figure.verticesPerRow;
  38538. rows = ps.length / cols | 0;
  38539. for (var row = 1; row < rows; row++) {
  38540. var offset = row * cols + 1;
  38541. for (var col = 1; col < cols; col++, offset++) {
  38542. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  38543. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  38544. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  38545. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  38546. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  38547. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  38548. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  38549. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  38550. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  38551. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  38552. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  38553. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  38554. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  38555. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  38556. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  38557. coords[pIndex + 6] = coords[pIndex + 2];
  38558. coords[pIndex + 7] = coords[pIndex + 3];
  38559. coords[pIndex + 8] = coords[pIndex + 4];
  38560. coords[pIndex + 9] = coords[pIndex + 5];
  38561. coords[pIndex + 10] = coordsMap[ps[offset]];
  38562. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  38563. colors[cIndex + 9] = colors[cIndex + 3];
  38564. colors[cIndex + 10] = colors[cIndex + 4];
  38565. colors[cIndex + 11] = colors[cIndex + 5];
  38566. colors[cIndex + 12] = colors[cIndex + 6];
  38567. colors[cIndex + 13] = colors[cIndex + 7];
  38568. colors[cIndex + 14] = colors[cIndex + 8];
  38569. colors[cIndex + 15] = colorsMap[cs[offset]];
  38570. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  38571. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  38572. pIndex += 12;
  38573. cIndex += 18;
  38574. }
  38575. }
  38576. break;
  38577. case 'triangles':
  38578. for (var j = 0, jj = ps.length; j < jj; j++) {
  38579. coords[pIndex] = coordsMap[ps[j]];
  38580. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  38581. colors[cIndex] = colorsMap[cs[j]];
  38582. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  38583. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  38584. pIndex += 2;
  38585. cIndex += 3;
  38586. }
  38587. break;
  38588. }
  38589. }
  38590. if (backgroundColor) {
  38591. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  38592. } else {
  38593. gl.clearColor(0, 0, 0, 0);
  38594. }
  38595. gl.clear(gl.COLOR_BUFFER_BIT);
  38596. var coordsBuffer = gl.createBuffer();
  38597. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  38598. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  38599. gl.enableVertexAttribArray(cache.positionLocation);
  38600. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38601. var colorsBuffer = gl.createBuffer();
  38602. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  38603. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  38604. gl.enableVertexAttribArray(cache.colorLocation);
  38605. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  38606. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  38607. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  38608. gl.drawArrays(gl.TRIANGLES, 0, count);
  38609. gl.flush();
  38610. gl.deleteBuffer(coordsBuffer);
  38611. gl.deleteBuffer(colorsBuffer);
  38612. return canvas;
  38613. }
  38614. function cleanup() {
  38615. if (smaskCache && smaskCache.canvas) {
  38616. smaskCache.canvas.width = 0;
  38617. smaskCache.canvas.height = 0;
  38618. }
  38619. if (figuresCache && figuresCache.canvas) {
  38620. figuresCache.canvas.width = 0;
  38621. figuresCache.canvas.height = 0;
  38622. }
  38623. smaskCache = null;
  38624. figuresCache = null;
  38625. }
  38626. return {
  38627. get isEnabled() {
  38628. if (getDefaultSetting('disableWebGL')) {
  38629. return false;
  38630. }
  38631. var enabled = false;
  38632. try {
  38633. generateGL();
  38634. enabled = !!currentGL;
  38635. } catch (e) {
  38636. }
  38637. return shadow(this, 'isEnabled', enabled);
  38638. },
  38639. composeSMask: composeSMask,
  38640. drawFigures: drawFigures,
  38641. clear: cleanup
  38642. };
  38643. }();
  38644. exports.WebGLUtils = WebGLUtils;
  38645. /***/ }),
  38646. /* 26 */
  38647. /***/ (function(module, exports, __w_pdfjs_require__) {
  38648. "use strict";
  38649. var sharedUtil = __w_pdfjs_require__(0);
  38650. var displayDOMUtils = __w_pdfjs_require__(3);
  38651. var displayAPI = __w_pdfjs_require__(10);
  38652. var displayAnnotationLayer = __w_pdfjs_require__(9);
  38653. var displayTextLayer = __w_pdfjs_require__(12);
  38654. var displayMetadata = __w_pdfjs_require__(24);
  38655. var displaySVG = __w_pdfjs_require__(11);
  38656. var globalScope = sharedUtil.globalScope;
  38657. var deprecated = sharedUtil.deprecated;
  38658. var warn = sharedUtil.warn;
  38659. var LinkTarget = displayDOMUtils.LinkTarget;
  38660. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  38661. var isWorker = typeof window === 'undefined';
  38662. if (!globalScope.PDFJS) {
  38663. globalScope.PDFJS = {};
  38664. }
  38665. var PDFJS = globalScope.PDFJS;
  38666. PDFJS.version = '1.7.316';
  38667. PDFJS.build = '59392fd5';
  38668. PDFJS.pdfBug = false;
  38669. if (PDFJS.verbosity !== undefined) {
  38670. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  38671. }
  38672. delete PDFJS.verbosity;
  38673. Object.defineProperty(PDFJS, 'verbosity', {
  38674. get: function () {
  38675. return sharedUtil.getVerbosityLevel();
  38676. },
  38677. set: function (level) {
  38678. sharedUtil.setVerbosityLevel(level);
  38679. },
  38680. enumerable: true,
  38681. configurable: true
  38682. });
  38683. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  38684. PDFJS.OPS = sharedUtil.OPS;
  38685. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38686. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  38687. PDFJS.shadow = sharedUtil.shadow;
  38688. PDFJS.createBlob = sharedUtil.createBlob;
  38689. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  38690. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  38691. };
  38692. Object.defineProperty(PDFJS, 'isLittleEndian', {
  38693. configurable: true,
  38694. get: function PDFJS_isLittleEndian() {
  38695. var value = sharedUtil.isLittleEndian();
  38696. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  38697. }
  38698. });
  38699. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  38700. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  38701. PDFJS.PasswordException = sharedUtil.PasswordException;
  38702. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  38703. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  38704. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  38705. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38706. PDFJS.Util = sharedUtil.Util;
  38707. PDFJS.PageViewport = sharedUtil.PageViewport;
  38708. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  38709. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  38710. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  38711. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  38712. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  38713. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  38714. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  38715. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  38716. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  38717. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  38718. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  38719. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  38720. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  38721. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  38722. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  38723. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  38724. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  38725. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  38726. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  38727. delete PDFJS.openExternalLinksInNewWindow;
  38728. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  38729. get: function () {
  38730. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  38731. },
  38732. set: function (value) {
  38733. if (value) {
  38734. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  38735. }
  38736. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  38737. warn('PDFJS.externalLinkTarget is already initialized');
  38738. return;
  38739. }
  38740. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  38741. },
  38742. enumerable: true,
  38743. configurable: true
  38744. });
  38745. if (savedOpenExternalLinksInNewWindow) {
  38746. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  38747. }
  38748. PDFJS.getDocument = displayAPI.getDocument;
  38749. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  38750. PDFJS.PDFWorker = displayAPI.PDFWorker;
  38751. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  38752. configurable: true,
  38753. get: function PDFJS_hasCanvasTypedArrays() {
  38754. var value = displayDOMUtils.hasCanvasTypedArrays();
  38755. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  38756. }
  38757. });
  38758. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  38759. PDFJS.LinkTarget = LinkTarget;
  38760. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  38761. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  38762. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  38763. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  38764. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  38765. PDFJS.Metadata = displayMetadata.Metadata;
  38766. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  38767. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  38768. exports.globalScope = globalScope;
  38769. exports.isWorker = isWorker;
  38770. exports.PDFJS = globalScope.PDFJS;
  38771. /***/ }),
  38772. /* 27 */
  38773. /***/ (function(module, exports, __w_pdfjs_require__) {
  38774. "use strict";
  38775. var sharedUtil = __w_pdfjs_require__(0);
  38776. var corePrimitives = __w_pdfjs_require__(1);
  38777. var coreStream = __w_pdfjs_require__(2);
  38778. var coreColorSpace = __w_pdfjs_require__(4);
  38779. var coreObj = __w_pdfjs_require__(20);
  38780. var coreEvaluator = __w_pdfjs_require__(18);
  38781. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  38782. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  38783. var AnnotationFlag = sharedUtil.AnnotationFlag;
  38784. var AnnotationType = sharedUtil.AnnotationType;
  38785. var OPS = sharedUtil.OPS;
  38786. var Util = sharedUtil.Util;
  38787. var isArray = sharedUtil.isArray;
  38788. var isInt = sharedUtil.isInt;
  38789. var stringToBytes = sharedUtil.stringToBytes;
  38790. var stringToPDFString = sharedUtil.stringToPDFString;
  38791. var warn = sharedUtil.warn;
  38792. var Dict = corePrimitives.Dict;
  38793. var isDict = corePrimitives.isDict;
  38794. var isName = corePrimitives.isName;
  38795. var isRef = corePrimitives.isRef;
  38796. var isStream = corePrimitives.isStream;
  38797. var Stream = coreStream.Stream;
  38798. var ColorSpace = coreColorSpace.ColorSpace;
  38799. var Catalog = coreObj.Catalog;
  38800. var ObjectLoader = coreObj.ObjectLoader;
  38801. var FileSpec = coreObj.FileSpec;
  38802. var OperatorList = coreEvaluator.OperatorList;
  38803. function AnnotationFactory() {
  38804. }
  38805. AnnotationFactory.prototype = {
  38806. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  38807. var dict = xref.fetchIfRef(ref);
  38808. if (!isDict(dict)) {
  38809. return;
  38810. }
  38811. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  38812. var subtype = dict.get('Subtype');
  38813. subtype = isName(subtype) ? subtype.name : null;
  38814. var parameters = {
  38815. xref: xref,
  38816. dict: dict,
  38817. ref: isRef(ref) ? ref : null,
  38818. subtype: subtype,
  38819. id: id,
  38820. pdfManager: pdfManager
  38821. };
  38822. switch (subtype) {
  38823. case 'Link':
  38824. return new LinkAnnotation(parameters);
  38825. case 'Text':
  38826. return new TextAnnotation(parameters);
  38827. case 'Widget':
  38828. var fieldType = Util.getInheritableProperty(dict, 'FT');
  38829. fieldType = isName(fieldType) ? fieldType.name : null;
  38830. switch (fieldType) {
  38831. case 'Tx':
  38832. return new TextWidgetAnnotation(parameters);
  38833. case 'Btn':
  38834. return new ButtonWidgetAnnotation(parameters);
  38835. case 'Ch':
  38836. return new ChoiceWidgetAnnotation(parameters);
  38837. }
  38838. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  38839. return new WidgetAnnotation(parameters);
  38840. case 'Popup':
  38841. return new PopupAnnotation(parameters);
  38842. case 'Highlight':
  38843. return new HighlightAnnotation(parameters);
  38844. case 'Underline':
  38845. return new UnderlineAnnotation(parameters);
  38846. case 'Squiggly':
  38847. return new SquigglyAnnotation(parameters);
  38848. case 'StrikeOut':
  38849. return new StrikeOutAnnotation(parameters);
  38850. case 'FileAttachment':
  38851. return new FileAttachmentAnnotation(parameters);
  38852. default:
  38853. if (!subtype) {
  38854. warn('Annotation is missing the required /Subtype.');
  38855. } else {
  38856. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  38857. }
  38858. return new Annotation(parameters);
  38859. }
  38860. }
  38861. };
  38862. var Annotation = function AnnotationClosure() {
  38863. function getTransformMatrix(rect, bbox, matrix) {
  38864. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  38865. var minX = bounds[0];
  38866. var minY = bounds[1];
  38867. var maxX = bounds[2];
  38868. var maxY = bounds[3];
  38869. if (minX === maxX || minY === maxY) {
  38870. return [
  38871. 1,
  38872. 0,
  38873. 0,
  38874. 1,
  38875. rect[0],
  38876. rect[1]
  38877. ];
  38878. }
  38879. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  38880. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  38881. return [
  38882. xRatio,
  38883. 0,
  38884. 0,
  38885. yRatio,
  38886. rect[0] - minX * xRatio,
  38887. rect[1] - minY * yRatio
  38888. ];
  38889. }
  38890. function Annotation(params) {
  38891. var dict = params.dict;
  38892. this.setFlags(dict.get('F'));
  38893. this.setRectangle(dict.getArray('Rect'));
  38894. this.setColor(dict.getArray('C'));
  38895. this.setBorderStyle(dict);
  38896. this.setAppearance(dict);
  38897. this.data = {};
  38898. this.data.id = params.id;
  38899. this.data.subtype = params.subtype;
  38900. this.data.annotationFlags = this.flags;
  38901. this.data.rect = this.rectangle;
  38902. this.data.color = this.color;
  38903. this.data.borderStyle = this.borderStyle;
  38904. this.data.hasAppearance = !!this.appearance;
  38905. }
  38906. Annotation.prototype = {
  38907. _hasFlag: function Annotation_hasFlag(flags, flag) {
  38908. return !!(flags & flag);
  38909. },
  38910. _isViewable: function Annotation_isViewable(flags) {
  38911. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  38912. },
  38913. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  38914. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  38915. },
  38916. get viewable() {
  38917. if (this.flags === 0) {
  38918. return true;
  38919. }
  38920. return this._isViewable(this.flags);
  38921. },
  38922. get printable() {
  38923. if (this.flags === 0) {
  38924. return false;
  38925. }
  38926. return this._isPrintable(this.flags);
  38927. },
  38928. setFlags: function Annotation_setFlags(flags) {
  38929. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  38930. },
  38931. hasFlag: function Annotation_hasFlag(flag) {
  38932. return this._hasFlag(this.flags, flag);
  38933. },
  38934. setRectangle: function Annotation_setRectangle(rectangle) {
  38935. if (isArray(rectangle) && rectangle.length === 4) {
  38936. this.rectangle = Util.normalizeRect(rectangle);
  38937. } else {
  38938. this.rectangle = [
  38939. 0,
  38940. 0,
  38941. 0,
  38942. 0
  38943. ];
  38944. }
  38945. },
  38946. setColor: function Annotation_setColor(color) {
  38947. var rgbColor = new Uint8Array(3);
  38948. if (!isArray(color)) {
  38949. this.color = rgbColor;
  38950. return;
  38951. }
  38952. switch (color.length) {
  38953. case 0:
  38954. this.color = null;
  38955. break;
  38956. case 1:
  38957. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  38958. this.color = rgbColor;
  38959. break;
  38960. case 3:
  38961. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  38962. this.color = rgbColor;
  38963. break;
  38964. case 4:
  38965. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  38966. this.color = rgbColor;
  38967. break;
  38968. default:
  38969. this.color = rgbColor;
  38970. break;
  38971. }
  38972. },
  38973. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  38974. this.borderStyle = new AnnotationBorderStyle();
  38975. if (!isDict(borderStyle)) {
  38976. return;
  38977. }
  38978. if (borderStyle.has('BS')) {
  38979. var dict = borderStyle.get('BS');
  38980. var dictType = dict.get('Type');
  38981. if (!dictType || isName(dictType, 'Border')) {
  38982. this.borderStyle.setWidth(dict.get('W'));
  38983. this.borderStyle.setStyle(dict.get('S'));
  38984. this.borderStyle.setDashArray(dict.getArray('D'));
  38985. }
  38986. } else if (borderStyle.has('Border')) {
  38987. var array = borderStyle.getArray('Border');
  38988. if (isArray(array) && array.length >= 3) {
  38989. this.borderStyle.setHorizontalCornerRadius(array[0]);
  38990. this.borderStyle.setVerticalCornerRadius(array[1]);
  38991. this.borderStyle.setWidth(array[2]);
  38992. if (array.length === 4) {
  38993. this.borderStyle.setDashArray(array[3]);
  38994. }
  38995. }
  38996. } else {
  38997. this.borderStyle.setWidth(0);
  38998. }
  38999. },
  39000. setAppearance: function Annotation_setAppearance(dict) {
  39001. this.appearance = null;
  39002. var appearanceStates = dict.get('AP');
  39003. if (!isDict(appearanceStates)) {
  39004. return;
  39005. }
  39006. var normalAppearanceState = appearanceStates.get('N');
  39007. if (isStream(normalAppearanceState)) {
  39008. this.appearance = normalAppearanceState;
  39009. return;
  39010. }
  39011. if (!isDict(normalAppearanceState)) {
  39012. return;
  39013. }
  39014. var as = dict.get('AS');
  39015. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39016. return;
  39017. }
  39018. this.appearance = normalAppearanceState.get(as.name);
  39019. },
  39020. _preparePopup: function Annotation_preparePopup(dict) {
  39021. if (!dict.has('C')) {
  39022. this.data.color = null;
  39023. }
  39024. this.data.hasPopup = dict.has('Popup');
  39025. this.data.title = stringToPDFString(dict.get('T') || '');
  39026. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39027. },
  39028. loadResources: function Annotation_loadResources(keys) {
  39029. return new Promise(function (resolve, reject) {
  39030. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39031. if (!resources) {
  39032. resolve();
  39033. return;
  39034. }
  39035. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39036. objectLoader.load().then(function () {
  39037. resolve(resources);
  39038. }, reject);
  39039. }, reject);
  39040. }.bind(this));
  39041. },
  39042. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39043. if (!this.appearance) {
  39044. return Promise.resolve(new OperatorList());
  39045. }
  39046. var data = this.data;
  39047. var appearanceDict = this.appearance.dict;
  39048. var resourcesPromise = this.loadResources([
  39049. 'ExtGState',
  39050. 'ColorSpace',
  39051. 'Pattern',
  39052. 'Shading',
  39053. 'XObject',
  39054. 'Font'
  39055. ]);
  39056. var bbox = appearanceDict.getArray('BBox') || [
  39057. 0,
  39058. 0,
  39059. 1,
  39060. 1
  39061. ];
  39062. var matrix = appearanceDict.getArray('Matrix') || [
  39063. 1,
  39064. 0,
  39065. 0,
  39066. 1,
  39067. 0,
  39068. 0
  39069. ];
  39070. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39071. var self = this;
  39072. return resourcesPromise.then(function (resources) {
  39073. var opList = new OperatorList();
  39074. opList.addOp(OPS.beginAnnotation, [
  39075. data.rect,
  39076. transform,
  39077. matrix
  39078. ]);
  39079. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39080. opList.addOp(OPS.endAnnotation, []);
  39081. self.appearance.reset();
  39082. return opList;
  39083. });
  39084. });
  39085. }
  39086. };
  39087. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39088. var annotationPromises = [];
  39089. for (var i = 0, n = annotations.length; i < n; ++i) {
  39090. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39091. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39092. }
  39093. }
  39094. return Promise.all(annotationPromises).then(function (operatorLists) {
  39095. opList.addOp(OPS.beginAnnotations, []);
  39096. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39097. opList.addOpList(operatorLists[i]);
  39098. }
  39099. opList.addOp(OPS.endAnnotations, []);
  39100. });
  39101. };
  39102. return Annotation;
  39103. }();
  39104. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39105. function AnnotationBorderStyle() {
  39106. this.width = 1;
  39107. this.style = AnnotationBorderStyleType.SOLID;
  39108. this.dashArray = [3];
  39109. this.horizontalCornerRadius = 0;
  39110. this.verticalCornerRadius = 0;
  39111. }
  39112. AnnotationBorderStyle.prototype = {
  39113. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39114. if (width === (width | 0)) {
  39115. this.width = width;
  39116. }
  39117. },
  39118. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39119. if (!style) {
  39120. return;
  39121. }
  39122. switch (style.name) {
  39123. case 'S':
  39124. this.style = AnnotationBorderStyleType.SOLID;
  39125. break;
  39126. case 'D':
  39127. this.style = AnnotationBorderStyleType.DASHED;
  39128. break;
  39129. case 'B':
  39130. this.style = AnnotationBorderStyleType.BEVELED;
  39131. break;
  39132. case 'I':
  39133. this.style = AnnotationBorderStyleType.INSET;
  39134. break;
  39135. case 'U':
  39136. this.style = AnnotationBorderStyleType.UNDERLINE;
  39137. break;
  39138. default:
  39139. break;
  39140. }
  39141. },
  39142. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39143. if (isArray(dashArray) && dashArray.length > 0) {
  39144. var isValid = true;
  39145. var allZeros = true;
  39146. for (var i = 0, len = dashArray.length; i < len; i++) {
  39147. var element = dashArray[i];
  39148. var validNumber = +element >= 0;
  39149. if (!validNumber) {
  39150. isValid = false;
  39151. break;
  39152. } else if (element > 0) {
  39153. allZeros = false;
  39154. }
  39155. }
  39156. if (isValid && !allZeros) {
  39157. this.dashArray = dashArray;
  39158. } else {
  39159. this.width = 0;
  39160. }
  39161. } else if (dashArray) {
  39162. this.width = 0;
  39163. }
  39164. },
  39165. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39166. if (radius === (radius | 0)) {
  39167. this.horizontalCornerRadius = radius;
  39168. }
  39169. },
  39170. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39171. if (radius === (radius | 0)) {
  39172. this.verticalCornerRadius = radius;
  39173. }
  39174. }
  39175. };
  39176. return AnnotationBorderStyle;
  39177. }();
  39178. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39179. function WidgetAnnotation(params) {
  39180. Annotation.call(this, params);
  39181. var dict = params.dict;
  39182. var data = this.data;
  39183. data.annotationType = AnnotationType.WIDGET;
  39184. data.fieldName = this._constructFieldName(dict);
  39185. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39186. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39187. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39188. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39189. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39190. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39191. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39192. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39193. data.fieldFlags = 0;
  39194. }
  39195. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39196. if (data.fieldType === 'Sig') {
  39197. this.setFlags(AnnotationFlag.HIDDEN);
  39198. }
  39199. }
  39200. Util.inherit(WidgetAnnotation, Annotation, {
  39201. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39202. if (!dict.has('T') && !dict.has('Parent')) {
  39203. warn('Unknown field name, falling back to empty field name.');
  39204. return '';
  39205. }
  39206. if (!dict.has('Parent')) {
  39207. return stringToPDFString(dict.get('T'));
  39208. }
  39209. var fieldName = [];
  39210. if (dict.has('T')) {
  39211. fieldName.unshift(stringToPDFString(dict.get('T')));
  39212. }
  39213. var loopDict = dict;
  39214. while (loopDict.has('Parent')) {
  39215. loopDict = loopDict.get('Parent');
  39216. if (loopDict.has('T')) {
  39217. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  39218. }
  39219. }
  39220. return fieldName.join('.');
  39221. },
  39222. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  39223. return !!(this.data.fieldFlags & flag);
  39224. }
  39225. });
  39226. return WidgetAnnotation;
  39227. }();
  39228. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  39229. function TextWidgetAnnotation(params) {
  39230. WidgetAnnotation.call(this, params);
  39231. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  39232. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  39233. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  39234. alignment = null;
  39235. }
  39236. this.data.textAlignment = alignment;
  39237. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  39238. if (!isInt(maximumLength) || maximumLength < 0) {
  39239. maximumLength = null;
  39240. }
  39241. this.data.maxLen = maximumLength;
  39242. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  39243. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  39244. }
  39245. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  39246. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39247. var operatorList = new OperatorList();
  39248. if (renderForms) {
  39249. return Promise.resolve(operatorList);
  39250. }
  39251. if (this.appearance) {
  39252. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39253. }
  39254. if (!this.data.defaultAppearance) {
  39255. return Promise.resolve(operatorList);
  39256. }
  39257. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  39258. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  39259. return operatorList;
  39260. });
  39261. }
  39262. });
  39263. return TextWidgetAnnotation;
  39264. }();
  39265. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  39266. function ButtonWidgetAnnotation(params) {
  39267. WidgetAnnotation.call(this, params);
  39268. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39269. if (this.data.checkBox) {
  39270. if (!isName(this.data.fieldValue)) {
  39271. return;
  39272. }
  39273. this.data.fieldValue = this.data.fieldValue.name;
  39274. }
  39275. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39276. if (this.data.radioButton) {
  39277. this.data.fieldValue = this.data.buttonValue = null;
  39278. var fieldParent = params.dict.get('Parent');
  39279. if (isDict(fieldParent) && fieldParent.has('V')) {
  39280. var fieldParentValue = fieldParent.get('V');
  39281. if (isName(fieldParentValue)) {
  39282. this.data.fieldValue = fieldParentValue.name;
  39283. }
  39284. }
  39285. var appearanceStates = params.dict.get('AP');
  39286. if (!isDict(appearanceStates)) {
  39287. return;
  39288. }
  39289. var normalAppearanceState = appearanceStates.get('N');
  39290. if (!isDict(normalAppearanceState)) {
  39291. return;
  39292. }
  39293. var keys = normalAppearanceState.getKeys();
  39294. for (var i = 0, ii = keys.length; i < ii; i++) {
  39295. if (keys[i] !== 'Off') {
  39296. this.data.buttonValue = keys[i];
  39297. break;
  39298. }
  39299. }
  39300. }
  39301. }
  39302. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  39303. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39304. var operatorList = new OperatorList();
  39305. if (renderForms) {
  39306. return Promise.resolve(operatorList);
  39307. }
  39308. if (this.appearance) {
  39309. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39310. }
  39311. return Promise.resolve(operatorList);
  39312. }
  39313. });
  39314. return ButtonWidgetAnnotation;
  39315. }();
  39316. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  39317. function ChoiceWidgetAnnotation(params) {
  39318. WidgetAnnotation.call(this, params);
  39319. this.data.options = [];
  39320. var options = params.dict.get('Opt');
  39321. if (isArray(options)) {
  39322. var xref = params.xref;
  39323. for (var i = 0, ii = options.length; i < ii; i++) {
  39324. var option = xref.fetchIfRef(options[i]);
  39325. var isOptionArray = isArray(option);
  39326. this.data.options[i] = {
  39327. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  39328. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  39329. };
  39330. }
  39331. }
  39332. if (!isArray(this.data.fieldValue)) {
  39333. this.data.fieldValue = [this.data.fieldValue];
  39334. }
  39335. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  39336. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  39337. }
  39338. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  39339. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39340. var operatorList = new OperatorList();
  39341. if (renderForms) {
  39342. return Promise.resolve(operatorList);
  39343. }
  39344. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39345. }
  39346. });
  39347. return ChoiceWidgetAnnotation;
  39348. }();
  39349. var TextAnnotation = function TextAnnotationClosure() {
  39350. var DEFAULT_ICON_SIZE = 22;
  39351. function TextAnnotation(parameters) {
  39352. Annotation.call(this, parameters);
  39353. this.data.annotationType = AnnotationType.TEXT;
  39354. if (this.data.hasAppearance) {
  39355. this.data.name = 'NoIcon';
  39356. } else {
  39357. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  39358. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  39359. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  39360. }
  39361. this._preparePopup(parameters.dict);
  39362. }
  39363. Util.inherit(TextAnnotation, Annotation, {});
  39364. return TextAnnotation;
  39365. }();
  39366. var LinkAnnotation = function LinkAnnotationClosure() {
  39367. function LinkAnnotation(params) {
  39368. Annotation.call(this, params);
  39369. var data = this.data;
  39370. data.annotationType = AnnotationType.LINK;
  39371. Catalog.parseDestDictionary({
  39372. destDict: params.dict,
  39373. resultObj: data,
  39374. docBaseUrl: params.pdfManager.docBaseUrl
  39375. });
  39376. }
  39377. Util.inherit(LinkAnnotation, Annotation, {});
  39378. return LinkAnnotation;
  39379. }();
  39380. var PopupAnnotation = function PopupAnnotationClosure() {
  39381. function PopupAnnotation(parameters) {
  39382. Annotation.call(this, parameters);
  39383. this.data.annotationType = AnnotationType.POPUP;
  39384. var dict = parameters.dict;
  39385. var parentItem = dict.get('Parent');
  39386. if (!parentItem) {
  39387. warn('Popup annotation has a missing or invalid parent annotation.');
  39388. return;
  39389. }
  39390. this.data.parentId = dict.getRaw('Parent').toString();
  39391. this.data.title = stringToPDFString(parentItem.get('T') || '');
  39392. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  39393. if (!parentItem.has('C')) {
  39394. this.data.color = null;
  39395. } else {
  39396. this.setColor(parentItem.getArray('C'));
  39397. this.data.color = this.color;
  39398. }
  39399. if (!this.viewable) {
  39400. var parentFlags = parentItem.get('F');
  39401. if (this._isViewable(parentFlags)) {
  39402. this.setFlags(parentFlags);
  39403. }
  39404. }
  39405. }
  39406. Util.inherit(PopupAnnotation, Annotation, {});
  39407. return PopupAnnotation;
  39408. }();
  39409. var HighlightAnnotation = function HighlightAnnotationClosure() {
  39410. function HighlightAnnotation(parameters) {
  39411. Annotation.call(this, parameters);
  39412. this.data.annotationType = AnnotationType.HIGHLIGHT;
  39413. this._preparePopup(parameters.dict);
  39414. this.data.borderStyle.setWidth(0);
  39415. }
  39416. Util.inherit(HighlightAnnotation, Annotation, {});
  39417. return HighlightAnnotation;
  39418. }();
  39419. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  39420. function UnderlineAnnotation(parameters) {
  39421. Annotation.call(this, parameters);
  39422. this.data.annotationType = AnnotationType.UNDERLINE;
  39423. this._preparePopup(parameters.dict);
  39424. this.data.borderStyle.setWidth(0);
  39425. }
  39426. Util.inherit(UnderlineAnnotation, Annotation, {});
  39427. return UnderlineAnnotation;
  39428. }();
  39429. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  39430. function SquigglyAnnotation(parameters) {
  39431. Annotation.call(this, parameters);
  39432. this.data.annotationType = AnnotationType.SQUIGGLY;
  39433. this._preparePopup(parameters.dict);
  39434. this.data.borderStyle.setWidth(0);
  39435. }
  39436. Util.inherit(SquigglyAnnotation, Annotation, {});
  39437. return SquigglyAnnotation;
  39438. }();
  39439. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  39440. function StrikeOutAnnotation(parameters) {
  39441. Annotation.call(this, parameters);
  39442. this.data.annotationType = AnnotationType.STRIKEOUT;
  39443. this._preparePopup(parameters.dict);
  39444. this.data.borderStyle.setWidth(0);
  39445. }
  39446. Util.inherit(StrikeOutAnnotation, Annotation, {});
  39447. return StrikeOutAnnotation;
  39448. }();
  39449. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  39450. function FileAttachmentAnnotation(parameters) {
  39451. Annotation.call(this, parameters);
  39452. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  39453. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  39454. this.data.file = file.serializable;
  39455. this._preparePopup(parameters.dict);
  39456. }
  39457. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  39458. return FileAttachmentAnnotation;
  39459. }();
  39460. exports.Annotation = Annotation;
  39461. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  39462. exports.AnnotationFactory = AnnotationFactory;
  39463. /***/ }),
  39464. /* 28 */
  39465. /***/ (function(module, exports, __w_pdfjs_require__) {
  39466. "use strict";
  39467. var sharedUtil = __w_pdfjs_require__(0);
  39468. var warn = sharedUtil.warn;
  39469. var baseTypes = [
  39470. 'BN',
  39471. 'BN',
  39472. 'BN',
  39473. 'BN',
  39474. 'BN',
  39475. 'BN',
  39476. 'BN',
  39477. 'BN',
  39478. 'BN',
  39479. 'S',
  39480. 'B',
  39481. 'S',
  39482. 'WS',
  39483. 'B',
  39484. 'BN',
  39485. 'BN',
  39486. 'BN',
  39487. 'BN',
  39488. 'BN',
  39489. 'BN',
  39490. 'BN',
  39491. 'BN',
  39492. 'BN',
  39493. 'BN',
  39494. 'BN',
  39495. 'BN',
  39496. 'BN',
  39497. 'BN',
  39498. 'B',
  39499. 'B',
  39500. 'B',
  39501. 'S',
  39502. 'WS',
  39503. 'ON',
  39504. 'ON',
  39505. 'ET',
  39506. 'ET',
  39507. 'ET',
  39508. 'ON',
  39509. 'ON',
  39510. 'ON',
  39511. 'ON',
  39512. 'ON',
  39513. 'ES',
  39514. 'CS',
  39515. 'ES',
  39516. 'CS',
  39517. 'CS',
  39518. 'EN',
  39519. 'EN',
  39520. 'EN',
  39521. 'EN',
  39522. 'EN',
  39523. 'EN',
  39524. 'EN',
  39525. 'EN',
  39526. 'EN',
  39527. 'EN',
  39528. 'CS',
  39529. 'ON',
  39530. 'ON',
  39531. 'ON',
  39532. 'ON',
  39533. 'ON',
  39534. 'ON',
  39535. 'L',
  39536. 'L',
  39537. 'L',
  39538. 'L',
  39539. 'L',
  39540. 'L',
  39541. 'L',
  39542. 'L',
  39543. 'L',
  39544. 'L',
  39545. 'L',
  39546. 'L',
  39547. 'L',
  39548. 'L',
  39549. 'L',
  39550. 'L',
  39551. 'L',
  39552. 'L',
  39553. 'L',
  39554. 'L',
  39555. 'L',
  39556. 'L',
  39557. 'L',
  39558. 'L',
  39559. 'L',
  39560. 'L',
  39561. 'ON',
  39562. 'ON',
  39563. 'ON',
  39564. 'ON',
  39565. 'ON',
  39566. 'ON',
  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. 'L',
  39586. 'L',
  39587. 'L',
  39588. 'L',
  39589. 'L',
  39590. 'L',
  39591. 'L',
  39592. 'L',
  39593. 'ON',
  39594. 'ON',
  39595. 'ON',
  39596. 'ON',
  39597. 'BN',
  39598. 'BN',
  39599. 'BN',
  39600. 'BN',
  39601. 'BN',
  39602. 'BN',
  39603. 'B',
  39604. 'BN',
  39605. 'BN',
  39606. 'BN',
  39607. 'BN',
  39608. 'BN',
  39609. 'BN',
  39610. 'BN',
  39611. 'BN',
  39612. 'BN',
  39613. 'BN',
  39614. 'BN',
  39615. 'BN',
  39616. 'BN',
  39617. 'BN',
  39618. 'BN',
  39619. 'BN',
  39620. 'BN',
  39621. 'BN',
  39622. 'BN',
  39623. 'BN',
  39624. 'BN',
  39625. 'BN',
  39626. 'BN',
  39627. 'BN',
  39628. 'BN',
  39629. 'BN',
  39630. 'CS',
  39631. 'ON',
  39632. 'ET',
  39633. 'ET',
  39634. 'ET',
  39635. 'ET',
  39636. 'ON',
  39637. 'ON',
  39638. 'ON',
  39639. 'ON',
  39640. 'L',
  39641. 'ON',
  39642. 'ON',
  39643. 'BN',
  39644. 'ON',
  39645. 'ON',
  39646. 'ET',
  39647. 'ET',
  39648. 'EN',
  39649. 'EN',
  39650. 'ON',
  39651. 'L',
  39652. 'ON',
  39653. 'ON',
  39654. 'ON',
  39655. 'EN',
  39656. 'L',
  39657. 'ON',
  39658. 'ON',
  39659. 'ON',
  39660. 'ON',
  39661. 'ON',
  39662. 'L',
  39663. 'L',
  39664. 'L',
  39665. 'L',
  39666. 'L',
  39667. 'L',
  39668. 'L',
  39669. 'L',
  39670. 'L',
  39671. 'L',
  39672. 'L',
  39673. 'L',
  39674. 'L',
  39675. 'L',
  39676. 'L',
  39677. 'L',
  39678. 'L',
  39679. 'L',
  39680. 'L',
  39681. 'L',
  39682. 'L',
  39683. 'L',
  39684. 'L',
  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. 'L',
  39710. 'L',
  39711. 'L',
  39712. 'L',
  39713. 'L',
  39714. 'L',
  39715. 'L',
  39716. 'L',
  39717. 'ON',
  39718. 'L',
  39719. 'L',
  39720. 'L',
  39721. 'L',
  39722. 'L',
  39723. 'L',
  39724. 'L',
  39725. 'L'
  39726. ];
  39727. var arabicTypes = [
  39728. 'AN',
  39729. 'AN',
  39730. 'AN',
  39731. 'AN',
  39732. 'AN',
  39733. 'AN',
  39734. 'ON',
  39735. 'ON',
  39736. 'AL',
  39737. 'ET',
  39738. 'ET',
  39739. 'AL',
  39740. 'CS',
  39741. 'AL',
  39742. 'ON',
  39743. 'ON',
  39744. 'NSM',
  39745. 'NSM',
  39746. 'NSM',
  39747. 'NSM',
  39748. 'NSM',
  39749. 'NSM',
  39750. 'NSM',
  39751. 'NSM',
  39752. 'NSM',
  39753. 'NSM',
  39754. 'NSM',
  39755. 'AL',
  39756. 'AL',
  39757. '',
  39758. 'AL',
  39759. 'AL',
  39760. 'AL',
  39761. 'AL',
  39762. 'AL',
  39763. 'AL',
  39764. 'AL',
  39765. 'AL',
  39766. 'AL',
  39767. 'AL',
  39768. 'AL',
  39769. 'AL',
  39770. 'AL',
  39771. 'AL',
  39772. 'AL',
  39773. 'AL',
  39774. 'AL',
  39775. 'AL',
  39776. 'AL',
  39777. 'AL',
  39778. 'AL',
  39779. 'AL',
  39780. 'AL',
  39781. 'AL',
  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. 'NSM',
  39804. 'NSM',
  39805. 'NSM',
  39806. 'NSM',
  39807. 'NSM',
  39808. 'NSM',
  39809. 'NSM',
  39810. 'NSM',
  39811. 'NSM',
  39812. 'NSM',
  39813. 'NSM',
  39814. 'NSM',
  39815. 'NSM',
  39816. 'NSM',
  39817. 'NSM',
  39818. 'NSM',
  39819. 'NSM',
  39820. 'NSM',
  39821. 'NSM',
  39822. 'NSM',
  39823. 'NSM',
  39824. 'AN',
  39825. 'AN',
  39826. 'AN',
  39827. 'AN',
  39828. 'AN',
  39829. 'AN',
  39830. 'AN',
  39831. 'AN',
  39832. 'AN',
  39833. 'AN',
  39834. 'ET',
  39835. 'AN',
  39836. 'AN',
  39837. 'AL',
  39838. 'AL',
  39839. 'AL',
  39840. 'NSM',
  39841. 'AL',
  39842. 'AL',
  39843. 'AL',
  39844. 'AL',
  39845. 'AL',
  39846. 'AL',
  39847. 'AL',
  39848. 'AL',
  39849. 'AL',
  39850. 'AL',
  39851. 'AL',
  39852. 'AL',
  39853. 'AL',
  39854. 'AL',
  39855. 'AL',
  39856. 'AL',
  39857. 'AL',
  39858. 'AL',
  39859. 'AL',
  39860. 'AL',
  39861. 'AL',
  39862. 'AL',
  39863. 'AL',
  39864. 'AL',
  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. 'NSM',
  39943. 'NSM',
  39944. 'NSM',
  39945. 'NSM',
  39946. 'NSM',
  39947. 'NSM',
  39948. 'NSM',
  39949. 'AN',
  39950. 'ON',
  39951. 'NSM',
  39952. 'NSM',
  39953. 'NSM',
  39954. 'NSM',
  39955. 'NSM',
  39956. 'NSM',
  39957. 'AL',
  39958. 'AL',
  39959. 'NSM',
  39960. 'NSM',
  39961. 'ON',
  39962. 'NSM',
  39963. 'NSM',
  39964. 'NSM',
  39965. 'NSM',
  39966. 'AL',
  39967. 'AL',
  39968. 'EN',
  39969. 'EN',
  39970. 'EN',
  39971. 'EN',
  39972. 'EN',
  39973. 'EN',
  39974. 'EN',
  39975. 'EN',
  39976. 'EN',
  39977. 'EN',
  39978. 'AL',
  39979. 'AL',
  39980. 'AL',
  39981. 'AL',
  39982. 'AL',
  39983. 'AL'
  39984. ];
  39985. function isOdd(i) {
  39986. return (i & 1) !== 0;
  39987. }
  39988. function isEven(i) {
  39989. return (i & 1) === 0;
  39990. }
  39991. function findUnequal(arr, start, value) {
  39992. for (var j = start, jj = arr.length; j < jj; ++j) {
  39993. if (arr[j] !== value) {
  39994. return j;
  39995. }
  39996. }
  39997. return j;
  39998. }
  39999. function setValues(arr, start, end, value) {
  40000. for (var j = start; j < end; ++j) {
  40001. arr[j] = value;
  40002. }
  40003. }
  40004. function reverseValues(arr, start, end) {
  40005. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40006. var temp = arr[i];
  40007. arr[i] = arr[j];
  40008. arr[j] = temp;
  40009. }
  40010. }
  40011. function createBidiText(str, isLTR, vertical) {
  40012. return {
  40013. str: str,
  40014. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40015. };
  40016. }
  40017. var chars = [];
  40018. var types = [];
  40019. function bidi(str, startLevel, vertical) {
  40020. var isLTR = true;
  40021. var strLength = str.length;
  40022. if (strLength === 0 || vertical) {
  40023. return createBidiText(str, isLTR, vertical);
  40024. }
  40025. chars.length = strLength;
  40026. types.length = strLength;
  40027. var numBidi = 0;
  40028. var i, ii;
  40029. for (i = 0; i < strLength; ++i) {
  40030. chars[i] = str.charAt(i);
  40031. var charCode = str.charCodeAt(i);
  40032. var charType = 'L';
  40033. if (charCode <= 0x00ff) {
  40034. charType = baseTypes[charCode];
  40035. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40036. charType = 'R';
  40037. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40038. charType = arabicTypes[charCode & 0xff];
  40039. if (!charType) {
  40040. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40041. }
  40042. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40043. charType = 'AL';
  40044. }
  40045. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40046. numBidi++;
  40047. }
  40048. types[i] = charType;
  40049. }
  40050. if (numBidi === 0) {
  40051. isLTR = true;
  40052. return createBidiText(str, isLTR);
  40053. }
  40054. if (startLevel === -1) {
  40055. if (numBidi / strLength < 0.3) {
  40056. isLTR = true;
  40057. startLevel = 0;
  40058. } else {
  40059. isLTR = false;
  40060. startLevel = 1;
  40061. }
  40062. }
  40063. var levels = [];
  40064. for (i = 0; i < strLength; ++i) {
  40065. levels[i] = startLevel;
  40066. }
  40067. var e = isOdd(startLevel) ? 'R' : 'L';
  40068. var sor = e;
  40069. var eor = sor;
  40070. var lastType = sor;
  40071. for (i = 0; i < strLength; ++i) {
  40072. if (types[i] === 'NSM') {
  40073. types[i] = lastType;
  40074. } else {
  40075. lastType = types[i];
  40076. }
  40077. }
  40078. lastType = sor;
  40079. var t;
  40080. for (i = 0; i < strLength; ++i) {
  40081. t = types[i];
  40082. if (t === 'EN') {
  40083. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40084. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40085. lastType = t;
  40086. }
  40087. }
  40088. for (i = 0; i < strLength; ++i) {
  40089. t = types[i];
  40090. if (t === 'AL') {
  40091. types[i] = 'R';
  40092. }
  40093. }
  40094. for (i = 1; i < strLength - 1; ++i) {
  40095. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40096. types[i] = 'EN';
  40097. }
  40098. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40099. types[i] = types[i - 1];
  40100. }
  40101. }
  40102. for (i = 0; i < strLength; ++i) {
  40103. if (types[i] === 'EN') {
  40104. var j;
  40105. for (j = i - 1; j >= 0; --j) {
  40106. if (types[j] !== 'ET') {
  40107. break;
  40108. }
  40109. types[j] = 'EN';
  40110. }
  40111. for (j = i + 1; j < strLength; ++j) {
  40112. if (types[j] !== 'ET') {
  40113. break;
  40114. }
  40115. types[j] = 'EN';
  40116. }
  40117. }
  40118. }
  40119. for (i = 0; i < strLength; ++i) {
  40120. t = types[i];
  40121. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40122. types[i] = 'ON';
  40123. }
  40124. }
  40125. lastType = sor;
  40126. for (i = 0; i < strLength; ++i) {
  40127. t = types[i];
  40128. if (t === 'EN') {
  40129. types[i] = lastType === 'L' ? 'L' : 'EN';
  40130. } else if (t === 'R' || t === 'L') {
  40131. lastType = t;
  40132. }
  40133. }
  40134. for (i = 0; i < strLength; ++i) {
  40135. if (types[i] === 'ON') {
  40136. var end = findUnequal(types, i + 1, 'ON');
  40137. var before = sor;
  40138. if (i > 0) {
  40139. before = types[i - 1];
  40140. }
  40141. var after = eor;
  40142. if (end + 1 < strLength) {
  40143. after = types[end + 1];
  40144. }
  40145. if (before !== 'L') {
  40146. before = 'R';
  40147. }
  40148. if (after !== 'L') {
  40149. after = 'R';
  40150. }
  40151. if (before === after) {
  40152. setValues(types, i, end, before);
  40153. }
  40154. i = end - 1;
  40155. }
  40156. }
  40157. for (i = 0; i < strLength; ++i) {
  40158. if (types[i] === 'ON') {
  40159. types[i] = e;
  40160. }
  40161. }
  40162. for (i = 0; i < strLength; ++i) {
  40163. t = types[i];
  40164. if (isEven(levels[i])) {
  40165. if (t === 'R') {
  40166. levels[i] += 1;
  40167. } else if (t === 'AN' || t === 'EN') {
  40168. levels[i] += 2;
  40169. }
  40170. } else {
  40171. if (t === 'L' || t === 'AN' || t === 'EN') {
  40172. levels[i] += 1;
  40173. }
  40174. }
  40175. }
  40176. var highestLevel = -1;
  40177. var lowestOddLevel = 99;
  40178. var level;
  40179. for (i = 0, ii = levels.length; i < ii; ++i) {
  40180. level = levels[i];
  40181. if (highestLevel < level) {
  40182. highestLevel = level;
  40183. }
  40184. if (lowestOddLevel > level && isOdd(level)) {
  40185. lowestOddLevel = level;
  40186. }
  40187. }
  40188. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40189. var start = -1;
  40190. for (i = 0, ii = levels.length; i < ii; ++i) {
  40191. if (levels[i] < level) {
  40192. if (start >= 0) {
  40193. reverseValues(chars, start, i);
  40194. start = -1;
  40195. }
  40196. } else if (start < 0) {
  40197. start = i;
  40198. }
  40199. }
  40200. if (start >= 0) {
  40201. reverseValues(chars, start, levels.length);
  40202. }
  40203. }
  40204. for (i = 0, ii = chars.length; i < ii; ++i) {
  40205. var ch = chars[i];
  40206. if (ch === '<' || ch === '>') {
  40207. chars[i] = '';
  40208. }
  40209. }
  40210. return createBidiText(chars.join(''), isLTR);
  40211. }
  40212. exports.bidi = bidi;
  40213. /***/ }),
  40214. /* 29 */
  40215. /***/ (function(module, exports, __w_pdfjs_require__) {
  40216. "use strict";
  40217. var ISOAdobeCharset = [
  40218. '.notdef',
  40219. 'space',
  40220. 'exclam',
  40221. 'quotedbl',
  40222. 'numbersign',
  40223. 'dollar',
  40224. 'percent',
  40225. 'ampersand',
  40226. 'quoteright',
  40227. 'parenleft',
  40228. 'parenright',
  40229. 'asterisk',
  40230. 'plus',
  40231. 'comma',
  40232. 'hyphen',
  40233. 'period',
  40234. 'slash',
  40235. 'zero',
  40236. 'one',
  40237. 'two',
  40238. 'three',
  40239. 'four',
  40240. 'five',
  40241. 'six',
  40242. 'seven',
  40243. 'eight',
  40244. 'nine',
  40245. 'colon',
  40246. 'semicolon',
  40247. 'less',
  40248. 'equal',
  40249. 'greater',
  40250. 'question',
  40251. 'at',
  40252. 'A',
  40253. 'B',
  40254. 'C',
  40255. 'D',
  40256. 'E',
  40257. 'F',
  40258. 'G',
  40259. 'H',
  40260. 'I',
  40261. 'J',
  40262. 'K',
  40263. 'L',
  40264. 'M',
  40265. 'N',
  40266. 'O',
  40267. 'P',
  40268. 'Q',
  40269. 'R',
  40270. 'S',
  40271. 'T',
  40272. 'U',
  40273. 'V',
  40274. 'W',
  40275. 'X',
  40276. 'Y',
  40277. 'Z',
  40278. 'bracketleft',
  40279. 'backslash',
  40280. 'bracketright',
  40281. 'asciicircum',
  40282. 'underscore',
  40283. 'quoteleft',
  40284. 'a',
  40285. 'b',
  40286. 'c',
  40287. 'd',
  40288. 'e',
  40289. 'f',
  40290. 'g',
  40291. 'h',
  40292. 'i',
  40293. 'j',
  40294. 'k',
  40295. 'l',
  40296. 'm',
  40297. 'n',
  40298. 'o',
  40299. 'p',
  40300. 'q',
  40301. 'r',
  40302. 's',
  40303. 't',
  40304. 'u',
  40305. 'v',
  40306. 'w',
  40307. 'x',
  40308. 'y',
  40309. 'z',
  40310. 'braceleft',
  40311. 'bar',
  40312. 'braceright',
  40313. 'asciitilde',
  40314. 'exclamdown',
  40315. 'cent',
  40316. 'sterling',
  40317. 'fraction',
  40318. 'yen',
  40319. 'florin',
  40320. 'section',
  40321. 'currency',
  40322. 'quotesingle',
  40323. 'quotedblleft',
  40324. 'guillemotleft',
  40325. 'guilsinglleft',
  40326. 'guilsinglright',
  40327. 'fi',
  40328. 'fl',
  40329. 'endash',
  40330. 'dagger',
  40331. 'daggerdbl',
  40332. 'periodcentered',
  40333. 'paragraph',
  40334. 'bullet',
  40335. 'quotesinglbase',
  40336. 'quotedblbase',
  40337. 'quotedblright',
  40338. 'guillemotright',
  40339. 'ellipsis',
  40340. 'perthousand',
  40341. 'questiondown',
  40342. 'grave',
  40343. 'acute',
  40344. 'circumflex',
  40345. 'tilde',
  40346. 'macron',
  40347. 'breve',
  40348. 'dotaccent',
  40349. 'dieresis',
  40350. 'ring',
  40351. 'cedilla',
  40352. 'hungarumlaut',
  40353. 'ogonek',
  40354. 'caron',
  40355. 'emdash',
  40356. 'AE',
  40357. 'ordfeminine',
  40358. 'Lslash',
  40359. 'Oslash',
  40360. 'OE',
  40361. 'ordmasculine',
  40362. 'ae',
  40363. 'dotlessi',
  40364. 'lslash',
  40365. 'oslash',
  40366. 'oe',
  40367. 'germandbls',
  40368. 'onesuperior',
  40369. 'logicalnot',
  40370. 'mu',
  40371. 'trademark',
  40372. 'Eth',
  40373. 'onehalf',
  40374. 'plusminus',
  40375. 'Thorn',
  40376. 'onequarter',
  40377. 'divide',
  40378. 'brokenbar',
  40379. 'degree',
  40380. 'thorn',
  40381. 'threequarters',
  40382. 'twosuperior',
  40383. 'registered',
  40384. 'minus',
  40385. 'eth',
  40386. 'multiply',
  40387. 'threesuperior',
  40388. 'copyright',
  40389. 'Aacute',
  40390. 'Acircumflex',
  40391. 'Adieresis',
  40392. 'Agrave',
  40393. 'Aring',
  40394. 'Atilde',
  40395. 'Ccedilla',
  40396. 'Eacute',
  40397. 'Ecircumflex',
  40398. 'Edieresis',
  40399. 'Egrave',
  40400. 'Iacute',
  40401. 'Icircumflex',
  40402. 'Idieresis',
  40403. 'Igrave',
  40404. 'Ntilde',
  40405. 'Oacute',
  40406. 'Ocircumflex',
  40407. 'Odieresis',
  40408. 'Ograve',
  40409. 'Otilde',
  40410. 'Scaron',
  40411. 'Uacute',
  40412. 'Ucircumflex',
  40413. 'Udieresis',
  40414. 'Ugrave',
  40415. 'Yacute',
  40416. 'Ydieresis',
  40417. 'Zcaron',
  40418. 'aacute',
  40419. 'acircumflex',
  40420. 'adieresis',
  40421. 'agrave',
  40422. 'aring',
  40423. 'atilde',
  40424. 'ccedilla',
  40425. 'eacute',
  40426. 'ecircumflex',
  40427. 'edieresis',
  40428. 'egrave',
  40429. 'iacute',
  40430. 'icircumflex',
  40431. 'idieresis',
  40432. 'igrave',
  40433. 'ntilde',
  40434. 'oacute',
  40435. 'ocircumflex',
  40436. 'odieresis',
  40437. 'ograve',
  40438. 'otilde',
  40439. 'scaron',
  40440. 'uacute',
  40441. 'ucircumflex',
  40442. 'udieresis',
  40443. 'ugrave',
  40444. 'yacute',
  40445. 'ydieresis',
  40446. 'zcaron'
  40447. ];
  40448. var ExpertCharset = [
  40449. '.notdef',
  40450. 'space',
  40451. 'exclamsmall',
  40452. 'Hungarumlautsmall',
  40453. 'dollaroldstyle',
  40454. 'dollarsuperior',
  40455. 'ampersandsmall',
  40456. 'Acutesmall',
  40457. 'parenleftsuperior',
  40458. 'parenrightsuperior',
  40459. 'twodotenleader',
  40460. 'onedotenleader',
  40461. 'comma',
  40462. 'hyphen',
  40463. 'period',
  40464. 'fraction',
  40465. 'zerooldstyle',
  40466. 'oneoldstyle',
  40467. 'twooldstyle',
  40468. 'threeoldstyle',
  40469. 'fouroldstyle',
  40470. 'fiveoldstyle',
  40471. 'sixoldstyle',
  40472. 'sevenoldstyle',
  40473. 'eightoldstyle',
  40474. 'nineoldstyle',
  40475. 'colon',
  40476. 'semicolon',
  40477. 'commasuperior',
  40478. 'threequartersemdash',
  40479. 'periodsuperior',
  40480. 'questionsmall',
  40481. 'asuperior',
  40482. 'bsuperior',
  40483. 'centsuperior',
  40484. 'dsuperior',
  40485. 'esuperior',
  40486. 'isuperior',
  40487. 'lsuperior',
  40488. 'msuperior',
  40489. 'nsuperior',
  40490. 'osuperior',
  40491. 'rsuperior',
  40492. 'ssuperior',
  40493. 'tsuperior',
  40494. 'ff',
  40495. 'fi',
  40496. 'fl',
  40497. 'ffi',
  40498. 'ffl',
  40499. 'parenleftinferior',
  40500. 'parenrightinferior',
  40501. 'Circumflexsmall',
  40502. 'hyphensuperior',
  40503. 'Gravesmall',
  40504. 'Asmall',
  40505. 'Bsmall',
  40506. 'Csmall',
  40507. 'Dsmall',
  40508. 'Esmall',
  40509. 'Fsmall',
  40510. 'Gsmall',
  40511. 'Hsmall',
  40512. 'Ismall',
  40513. 'Jsmall',
  40514. 'Ksmall',
  40515. 'Lsmall',
  40516. 'Msmall',
  40517. 'Nsmall',
  40518. 'Osmall',
  40519. 'Psmall',
  40520. 'Qsmall',
  40521. 'Rsmall',
  40522. 'Ssmall',
  40523. 'Tsmall',
  40524. 'Usmall',
  40525. 'Vsmall',
  40526. 'Wsmall',
  40527. 'Xsmall',
  40528. 'Ysmall',
  40529. 'Zsmall',
  40530. 'colonmonetary',
  40531. 'onefitted',
  40532. 'rupiah',
  40533. 'Tildesmall',
  40534. 'exclamdownsmall',
  40535. 'centoldstyle',
  40536. 'Lslashsmall',
  40537. 'Scaronsmall',
  40538. 'Zcaronsmall',
  40539. 'Dieresissmall',
  40540. 'Brevesmall',
  40541. 'Caronsmall',
  40542. 'Dotaccentsmall',
  40543. 'Macronsmall',
  40544. 'figuredash',
  40545. 'hypheninferior',
  40546. 'Ogoneksmall',
  40547. 'Ringsmall',
  40548. 'Cedillasmall',
  40549. 'onequarter',
  40550. 'onehalf',
  40551. 'threequarters',
  40552. 'questiondownsmall',
  40553. 'oneeighth',
  40554. 'threeeighths',
  40555. 'fiveeighths',
  40556. 'seveneighths',
  40557. 'onethird',
  40558. 'twothirds',
  40559. 'zerosuperior',
  40560. 'onesuperior',
  40561. 'twosuperior',
  40562. 'threesuperior',
  40563. 'foursuperior',
  40564. 'fivesuperior',
  40565. 'sixsuperior',
  40566. 'sevensuperior',
  40567. 'eightsuperior',
  40568. 'ninesuperior',
  40569. 'zeroinferior',
  40570. 'oneinferior',
  40571. 'twoinferior',
  40572. 'threeinferior',
  40573. 'fourinferior',
  40574. 'fiveinferior',
  40575. 'sixinferior',
  40576. 'seveninferior',
  40577. 'eightinferior',
  40578. 'nineinferior',
  40579. 'centinferior',
  40580. 'dollarinferior',
  40581. 'periodinferior',
  40582. 'commainferior',
  40583. 'Agravesmall',
  40584. 'Aacutesmall',
  40585. 'Acircumflexsmall',
  40586. 'Atildesmall',
  40587. 'Adieresissmall',
  40588. 'Aringsmall',
  40589. 'AEsmall',
  40590. 'Ccedillasmall',
  40591. 'Egravesmall',
  40592. 'Eacutesmall',
  40593. 'Ecircumflexsmall',
  40594. 'Edieresissmall',
  40595. 'Igravesmall',
  40596. 'Iacutesmall',
  40597. 'Icircumflexsmall',
  40598. 'Idieresissmall',
  40599. 'Ethsmall',
  40600. 'Ntildesmall',
  40601. 'Ogravesmall',
  40602. 'Oacutesmall',
  40603. 'Ocircumflexsmall',
  40604. 'Otildesmall',
  40605. 'Odieresissmall',
  40606. 'OEsmall',
  40607. 'Oslashsmall',
  40608. 'Ugravesmall',
  40609. 'Uacutesmall',
  40610. 'Ucircumflexsmall',
  40611. 'Udieresissmall',
  40612. 'Yacutesmall',
  40613. 'Thornsmall',
  40614. 'Ydieresissmall'
  40615. ];
  40616. var ExpertSubsetCharset = [
  40617. '.notdef',
  40618. 'space',
  40619. 'dollaroldstyle',
  40620. 'dollarsuperior',
  40621. 'parenleftsuperior',
  40622. 'parenrightsuperior',
  40623. 'twodotenleader',
  40624. 'onedotenleader',
  40625. 'comma',
  40626. 'hyphen',
  40627. 'period',
  40628. 'fraction',
  40629. 'zerooldstyle',
  40630. 'oneoldstyle',
  40631. 'twooldstyle',
  40632. 'threeoldstyle',
  40633. 'fouroldstyle',
  40634. 'fiveoldstyle',
  40635. 'sixoldstyle',
  40636. 'sevenoldstyle',
  40637. 'eightoldstyle',
  40638. 'nineoldstyle',
  40639. 'colon',
  40640. 'semicolon',
  40641. 'commasuperior',
  40642. 'threequartersemdash',
  40643. 'periodsuperior',
  40644. 'asuperior',
  40645. 'bsuperior',
  40646. 'centsuperior',
  40647. 'dsuperior',
  40648. 'esuperior',
  40649. 'isuperior',
  40650. 'lsuperior',
  40651. 'msuperior',
  40652. 'nsuperior',
  40653. 'osuperior',
  40654. 'rsuperior',
  40655. 'ssuperior',
  40656. 'tsuperior',
  40657. 'ff',
  40658. 'fi',
  40659. 'fl',
  40660. 'ffi',
  40661. 'ffl',
  40662. 'parenleftinferior',
  40663. 'parenrightinferior',
  40664. 'hyphensuperior',
  40665. 'colonmonetary',
  40666. 'onefitted',
  40667. 'rupiah',
  40668. 'centoldstyle',
  40669. 'figuredash',
  40670. 'hypheninferior',
  40671. 'onequarter',
  40672. 'onehalf',
  40673. 'threequarters',
  40674. 'oneeighth',
  40675. 'threeeighths',
  40676. 'fiveeighths',
  40677. 'seveneighths',
  40678. 'onethird',
  40679. 'twothirds',
  40680. 'zerosuperior',
  40681. 'onesuperior',
  40682. 'twosuperior',
  40683. 'threesuperior',
  40684. 'foursuperior',
  40685. 'fivesuperior',
  40686. 'sixsuperior',
  40687. 'sevensuperior',
  40688. 'eightsuperior',
  40689. 'ninesuperior',
  40690. 'zeroinferior',
  40691. 'oneinferior',
  40692. 'twoinferior',
  40693. 'threeinferior',
  40694. 'fourinferior',
  40695. 'fiveinferior',
  40696. 'sixinferior',
  40697. 'seveninferior',
  40698. 'eightinferior',
  40699. 'nineinferior',
  40700. 'centinferior',
  40701. 'dollarinferior',
  40702. 'periodinferior',
  40703. 'commainferior'
  40704. ];
  40705. exports.ISOAdobeCharset = ISOAdobeCharset;
  40706. exports.ExpertCharset = ExpertCharset;
  40707. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  40708. /***/ }),
  40709. /* 30 */
  40710. /***/ (function(module, exports, __w_pdfjs_require__) {
  40711. "use strict";
  40712. var sharedUtil = __w_pdfjs_require__(0);
  40713. var corePrimitives = __w_pdfjs_require__(1);
  40714. var coreStream = __w_pdfjs_require__(2);
  40715. var coreParser = __w_pdfjs_require__(6);
  40716. var Util = sharedUtil.Util;
  40717. var assert = sharedUtil.assert;
  40718. var warn = sharedUtil.warn;
  40719. var error = sharedUtil.error;
  40720. var isInt = sharedUtil.isInt;
  40721. var isString = sharedUtil.isString;
  40722. var MissingDataException = sharedUtil.MissingDataException;
  40723. var CMapCompressionType = sharedUtil.CMapCompressionType;
  40724. var isEOF = corePrimitives.isEOF;
  40725. var isName = corePrimitives.isName;
  40726. var isCmd = corePrimitives.isCmd;
  40727. var isStream = corePrimitives.isStream;
  40728. var Stream = coreStream.Stream;
  40729. var Lexer = coreParser.Lexer;
  40730. var BUILT_IN_CMAPS = [
  40731. 'Adobe-GB1-UCS2',
  40732. 'Adobe-CNS1-UCS2',
  40733. 'Adobe-Japan1-UCS2',
  40734. 'Adobe-Korea1-UCS2',
  40735. '78-EUC-H',
  40736. '78-EUC-V',
  40737. '78-H',
  40738. '78-RKSJ-H',
  40739. '78-RKSJ-V',
  40740. '78-V',
  40741. '78ms-RKSJ-H',
  40742. '78ms-RKSJ-V',
  40743. '83pv-RKSJ-H',
  40744. '90ms-RKSJ-H',
  40745. '90ms-RKSJ-V',
  40746. '90msp-RKSJ-H',
  40747. '90msp-RKSJ-V',
  40748. '90pv-RKSJ-H',
  40749. '90pv-RKSJ-V',
  40750. 'Add-H',
  40751. 'Add-RKSJ-H',
  40752. 'Add-RKSJ-V',
  40753. 'Add-V',
  40754. 'Adobe-CNS1-0',
  40755. 'Adobe-CNS1-1',
  40756. 'Adobe-CNS1-2',
  40757. 'Adobe-CNS1-3',
  40758. 'Adobe-CNS1-4',
  40759. 'Adobe-CNS1-5',
  40760. 'Adobe-CNS1-6',
  40761. 'Adobe-GB1-0',
  40762. 'Adobe-GB1-1',
  40763. 'Adobe-GB1-2',
  40764. 'Adobe-GB1-3',
  40765. 'Adobe-GB1-4',
  40766. 'Adobe-GB1-5',
  40767. 'Adobe-Japan1-0',
  40768. 'Adobe-Japan1-1',
  40769. 'Adobe-Japan1-2',
  40770. 'Adobe-Japan1-3',
  40771. 'Adobe-Japan1-4',
  40772. 'Adobe-Japan1-5',
  40773. 'Adobe-Japan1-6',
  40774. 'Adobe-Korea1-0',
  40775. 'Adobe-Korea1-1',
  40776. 'Adobe-Korea1-2',
  40777. 'B5-H',
  40778. 'B5-V',
  40779. 'B5pc-H',
  40780. 'B5pc-V',
  40781. 'CNS-EUC-H',
  40782. 'CNS-EUC-V',
  40783. 'CNS1-H',
  40784. 'CNS1-V',
  40785. 'CNS2-H',
  40786. 'CNS2-V',
  40787. 'ETHK-B5-H',
  40788. 'ETHK-B5-V',
  40789. 'ETen-B5-H',
  40790. 'ETen-B5-V',
  40791. 'ETenms-B5-H',
  40792. 'ETenms-B5-V',
  40793. 'EUC-H',
  40794. 'EUC-V',
  40795. 'Ext-H',
  40796. 'Ext-RKSJ-H',
  40797. 'Ext-RKSJ-V',
  40798. 'Ext-V',
  40799. 'GB-EUC-H',
  40800. 'GB-EUC-V',
  40801. 'GB-H',
  40802. 'GB-V',
  40803. 'GBK-EUC-H',
  40804. 'GBK-EUC-V',
  40805. 'GBK2K-H',
  40806. 'GBK2K-V',
  40807. 'GBKp-EUC-H',
  40808. 'GBKp-EUC-V',
  40809. 'GBT-EUC-H',
  40810. 'GBT-EUC-V',
  40811. 'GBT-H',
  40812. 'GBT-V',
  40813. 'GBTpc-EUC-H',
  40814. 'GBTpc-EUC-V',
  40815. 'GBpc-EUC-H',
  40816. 'GBpc-EUC-V',
  40817. 'H',
  40818. 'HKdla-B5-H',
  40819. 'HKdla-B5-V',
  40820. 'HKdlb-B5-H',
  40821. 'HKdlb-B5-V',
  40822. 'HKgccs-B5-H',
  40823. 'HKgccs-B5-V',
  40824. 'HKm314-B5-H',
  40825. 'HKm314-B5-V',
  40826. 'HKm471-B5-H',
  40827. 'HKm471-B5-V',
  40828. 'HKscs-B5-H',
  40829. 'HKscs-B5-V',
  40830. 'Hankaku',
  40831. 'Hiragana',
  40832. 'KSC-EUC-H',
  40833. 'KSC-EUC-V',
  40834. 'KSC-H',
  40835. 'KSC-Johab-H',
  40836. 'KSC-Johab-V',
  40837. 'KSC-V',
  40838. 'KSCms-UHC-H',
  40839. 'KSCms-UHC-HW-H',
  40840. 'KSCms-UHC-HW-V',
  40841. 'KSCms-UHC-V',
  40842. 'KSCpc-EUC-H',
  40843. 'KSCpc-EUC-V',
  40844. 'Katakana',
  40845. 'NWP-H',
  40846. 'NWP-V',
  40847. 'RKSJ-H',
  40848. 'RKSJ-V',
  40849. 'Roman',
  40850. 'UniCNS-UCS2-H',
  40851. 'UniCNS-UCS2-V',
  40852. 'UniCNS-UTF16-H',
  40853. 'UniCNS-UTF16-V',
  40854. 'UniCNS-UTF32-H',
  40855. 'UniCNS-UTF32-V',
  40856. 'UniCNS-UTF8-H',
  40857. 'UniCNS-UTF8-V',
  40858. 'UniGB-UCS2-H',
  40859. 'UniGB-UCS2-V',
  40860. 'UniGB-UTF16-H',
  40861. 'UniGB-UTF16-V',
  40862. 'UniGB-UTF32-H',
  40863. 'UniGB-UTF32-V',
  40864. 'UniGB-UTF8-H',
  40865. 'UniGB-UTF8-V',
  40866. 'UniJIS-UCS2-H',
  40867. 'UniJIS-UCS2-HW-H',
  40868. 'UniJIS-UCS2-HW-V',
  40869. 'UniJIS-UCS2-V',
  40870. 'UniJIS-UTF16-H',
  40871. 'UniJIS-UTF16-V',
  40872. 'UniJIS-UTF32-H',
  40873. 'UniJIS-UTF32-V',
  40874. 'UniJIS-UTF8-H',
  40875. 'UniJIS-UTF8-V',
  40876. 'UniJIS2004-UTF16-H',
  40877. 'UniJIS2004-UTF16-V',
  40878. 'UniJIS2004-UTF32-H',
  40879. 'UniJIS2004-UTF32-V',
  40880. 'UniJIS2004-UTF8-H',
  40881. 'UniJIS2004-UTF8-V',
  40882. 'UniJISPro-UCS2-HW-V',
  40883. 'UniJISPro-UCS2-V',
  40884. 'UniJISPro-UTF8-V',
  40885. 'UniJISX0213-UTF32-H',
  40886. 'UniJISX0213-UTF32-V',
  40887. 'UniJISX02132004-UTF32-H',
  40888. 'UniJISX02132004-UTF32-V',
  40889. 'UniKS-UCS2-H',
  40890. 'UniKS-UCS2-V',
  40891. 'UniKS-UTF16-H',
  40892. 'UniKS-UTF16-V',
  40893. 'UniKS-UTF32-H',
  40894. 'UniKS-UTF32-V',
  40895. 'UniKS-UTF8-H',
  40896. 'UniKS-UTF8-V',
  40897. 'V',
  40898. 'WP-Symbol'
  40899. ];
  40900. var CMap = function CMapClosure() {
  40901. function CMap(builtInCMap) {
  40902. this.codespaceRanges = [
  40903. [],
  40904. [],
  40905. [],
  40906. []
  40907. ];
  40908. this.numCodespaceRanges = 0;
  40909. this._map = [];
  40910. this.name = '';
  40911. this.vertical = false;
  40912. this.useCMap = null;
  40913. this.builtInCMap = builtInCMap;
  40914. }
  40915. CMap.prototype = {
  40916. addCodespaceRange: function (n, low, high) {
  40917. this.codespaceRanges[n - 1].push(low, high);
  40918. this.numCodespaceRanges++;
  40919. },
  40920. mapCidRange: function (low, high, dstLow) {
  40921. while (low <= high) {
  40922. this._map[low++] = dstLow++;
  40923. }
  40924. },
  40925. mapBfRange: function (low, high, dstLow) {
  40926. var lastByte = dstLow.length - 1;
  40927. while (low <= high) {
  40928. this._map[low++] = dstLow;
  40929. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40930. }
  40931. },
  40932. mapBfRangeToArray: function (low, high, array) {
  40933. var i = 0, ii = array.length;
  40934. while (low <= high && i < ii) {
  40935. this._map[low] = array[i++];
  40936. ++low;
  40937. }
  40938. },
  40939. mapOne: function (src, dst) {
  40940. this._map[src] = dst;
  40941. },
  40942. lookup: function (code) {
  40943. return this._map[code];
  40944. },
  40945. contains: function (code) {
  40946. return this._map[code] !== undefined;
  40947. },
  40948. forEach: function (callback) {
  40949. var map = this._map;
  40950. var length = map.length;
  40951. var i;
  40952. if (length <= 0x10000) {
  40953. for (i = 0; i < length; i++) {
  40954. if (map[i] !== undefined) {
  40955. callback(i, map[i]);
  40956. }
  40957. }
  40958. } else {
  40959. for (i in this._map) {
  40960. callback(i, map[i]);
  40961. }
  40962. }
  40963. },
  40964. charCodeOf: function (value) {
  40965. return this._map.indexOf(value);
  40966. },
  40967. getMap: function () {
  40968. return this._map;
  40969. },
  40970. readCharCode: function (str, offset, out) {
  40971. var c = 0;
  40972. var codespaceRanges = this.codespaceRanges;
  40973. var codespaceRangesLen = this.codespaceRanges.length;
  40974. for (var n = 0; n < codespaceRangesLen; n++) {
  40975. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  40976. var codespaceRange = codespaceRanges[n];
  40977. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  40978. var low = codespaceRange[k++];
  40979. var high = codespaceRange[k++];
  40980. if (c >= low && c <= high) {
  40981. out.charcode = c;
  40982. out.length = n + 1;
  40983. return;
  40984. }
  40985. }
  40986. }
  40987. out.charcode = 0;
  40988. out.length = 1;
  40989. },
  40990. get length() {
  40991. return this._map.length;
  40992. },
  40993. get isIdentityCMap() {
  40994. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  40995. return false;
  40996. }
  40997. if (this._map.length !== 0x10000) {
  40998. return false;
  40999. }
  41000. for (var i = 0; i < 0x10000; i++) {
  41001. if (this._map[i] !== i) {
  41002. return false;
  41003. }
  41004. }
  41005. return true;
  41006. }
  41007. };
  41008. return CMap;
  41009. }();
  41010. var IdentityCMap = function IdentityCMapClosure() {
  41011. function IdentityCMap(vertical, n) {
  41012. CMap.call(this);
  41013. this.vertical = vertical;
  41014. this.addCodespaceRange(n, 0, 0xffff);
  41015. }
  41016. Util.inherit(IdentityCMap, CMap, {});
  41017. IdentityCMap.prototype = {
  41018. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41019. mapCidRange: function (low, high, dstLow) {
  41020. error('should not call mapCidRange');
  41021. },
  41022. mapBfRange: function (low, high, dstLow) {
  41023. error('should not call mapBfRange');
  41024. },
  41025. mapBfRangeToArray: function (low, high, array) {
  41026. error('should not call mapBfRangeToArray');
  41027. },
  41028. mapOne: function (src, dst) {
  41029. error('should not call mapCidOne');
  41030. },
  41031. lookup: function (code) {
  41032. return isInt(code) && code <= 0xffff ? code : undefined;
  41033. },
  41034. contains: function (code) {
  41035. return isInt(code) && code <= 0xffff;
  41036. },
  41037. forEach: function (callback) {
  41038. for (var i = 0; i <= 0xffff; i++) {
  41039. callback(i, i);
  41040. }
  41041. },
  41042. charCodeOf: function (value) {
  41043. return isInt(value) && value <= 0xffff ? value : -1;
  41044. },
  41045. getMap: function () {
  41046. var map = new Array(0x10000);
  41047. for (var i = 0; i <= 0xffff; i++) {
  41048. map[i] = i;
  41049. }
  41050. return map;
  41051. },
  41052. readCharCode: CMap.prototype.readCharCode,
  41053. get length() {
  41054. return 0x10000;
  41055. },
  41056. get isIdentityCMap() {
  41057. error('should not access .isIdentityCMap');
  41058. }
  41059. };
  41060. return IdentityCMap;
  41061. }();
  41062. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41063. function hexToInt(a, size) {
  41064. var n = 0;
  41065. for (var i = 0; i <= size; i++) {
  41066. n = n << 8 | a[i];
  41067. }
  41068. return n >>> 0;
  41069. }
  41070. function hexToStr(a, size) {
  41071. if (size === 1) {
  41072. return String.fromCharCode(a[0], a[1]);
  41073. }
  41074. if (size === 3) {
  41075. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41076. }
  41077. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41078. }
  41079. function addHex(a, b, size) {
  41080. var c = 0;
  41081. for (var i = size; i >= 0; i--) {
  41082. c += a[i] + b[i];
  41083. a[i] = c & 255;
  41084. c >>= 8;
  41085. }
  41086. }
  41087. function incHex(a, size) {
  41088. var c = 1;
  41089. for (var i = size; i >= 0 && c > 0; i--) {
  41090. c += a[i];
  41091. a[i] = c & 255;
  41092. c >>= 8;
  41093. }
  41094. }
  41095. var MAX_NUM_SIZE = 16;
  41096. var MAX_ENCODED_NUM_SIZE = 19;
  41097. function BinaryCMapStream(data) {
  41098. this.buffer = data;
  41099. this.pos = 0;
  41100. this.end = data.length;
  41101. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41102. }
  41103. BinaryCMapStream.prototype = {
  41104. readByte: function () {
  41105. if (this.pos >= this.end) {
  41106. return -1;
  41107. }
  41108. return this.buffer[this.pos++];
  41109. },
  41110. readNumber: function () {
  41111. var n = 0;
  41112. var last;
  41113. do {
  41114. var b = this.readByte();
  41115. if (b < 0) {
  41116. error('unexpected EOF in bcmap');
  41117. }
  41118. last = !(b & 0x80);
  41119. n = n << 7 | b & 0x7F;
  41120. } while (!last);
  41121. return n;
  41122. },
  41123. readSigned: function () {
  41124. var n = this.readNumber();
  41125. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41126. },
  41127. readHex: function (num, size) {
  41128. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41129. this.pos += size + 1;
  41130. },
  41131. readHexNumber: function (num, size) {
  41132. var last;
  41133. var stack = this.tmpBuf, sp = 0;
  41134. do {
  41135. var b = this.readByte();
  41136. if (b < 0) {
  41137. error('unexpected EOF in bcmap');
  41138. }
  41139. last = !(b & 0x80);
  41140. stack[sp++] = b & 0x7F;
  41141. } while (!last);
  41142. var i = size, buffer = 0, bufferSize = 0;
  41143. while (i >= 0) {
  41144. while (bufferSize < 8 && stack.length > 0) {
  41145. buffer = stack[--sp] << bufferSize | buffer;
  41146. bufferSize += 7;
  41147. }
  41148. num[i] = buffer & 255;
  41149. i--;
  41150. buffer >>= 8;
  41151. bufferSize -= 8;
  41152. }
  41153. },
  41154. readHexSigned: function (num, size) {
  41155. this.readHexNumber(num, size);
  41156. var sign = num[size] & 1 ? 255 : 0;
  41157. var c = 0;
  41158. for (var i = 0; i <= size; i++) {
  41159. c = (c & 1) << 8 | num[i];
  41160. num[i] = c >> 1 ^ sign;
  41161. }
  41162. },
  41163. readString: function () {
  41164. var len = this.readNumber();
  41165. var s = '';
  41166. for (var i = 0; i < len; i++) {
  41167. s += String.fromCharCode(this.readNumber());
  41168. }
  41169. return s;
  41170. }
  41171. };
  41172. function processBinaryCMap(data, cMap, extend) {
  41173. return new Promise(function (resolve, reject) {
  41174. var stream = new BinaryCMapStream(data);
  41175. var header = stream.readByte();
  41176. cMap.vertical = !!(header & 1);
  41177. var useCMap = null;
  41178. var start = new Uint8Array(MAX_NUM_SIZE);
  41179. var end = new Uint8Array(MAX_NUM_SIZE);
  41180. var char = new Uint8Array(MAX_NUM_SIZE);
  41181. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41182. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41183. var code;
  41184. var b;
  41185. while ((b = stream.readByte()) >= 0) {
  41186. var type = b >> 5;
  41187. if (type === 7) {
  41188. switch (b & 0x1F) {
  41189. case 0:
  41190. stream.readString();
  41191. break;
  41192. case 1:
  41193. useCMap = stream.readString();
  41194. break;
  41195. }
  41196. continue;
  41197. }
  41198. var sequence = !!(b & 0x10);
  41199. var dataSize = b & 15;
  41200. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41201. var ucs2DataSize = 1;
  41202. var subitemsCount = stream.readNumber();
  41203. var i;
  41204. switch (type) {
  41205. case 0:
  41206. stream.readHex(start, dataSize);
  41207. stream.readHexNumber(end, dataSize);
  41208. addHex(end, start, dataSize);
  41209. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41210. for (i = 1; i < subitemsCount; i++) {
  41211. incHex(end, dataSize);
  41212. stream.readHexNumber(start, dataSize);
  41213. addHex(start, end, dataSize);
  41214. stream.readHexNumber(end, dataSize);
  41215. addHex(end, start, dataSize);
  41216. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41217. }
  41218. break;
  41219. case 1:
  41220. stream.readHex(start, dataSize);
  41221. stream.readHexNumber(end, dataSize);
  41222. addHex(end, start, dataSize);
  41223. code = stream.readNumber();
  41224. for (i = 1; i < subitemsCount; i++) {
  41225. incHex(end, dataSize);
  41226. stream.readHexNumber(start, dataSize);
  41227. addHex(start, end, dataSize);
  41228. stream.readHexNumber(end, dataSize);
  41229. addHex(end, start, dataSize);
  41230. code = stream.readNumber();
  41231. }
  41232. break;
  41233. case 2:
  41234. stream.readHex(char, dataSize);
  41235. code = stream.readNumber();
  41236. cMap.mapOne(hexToInt(char, dataSize), code);
  41237. for (i = 1; i < subitemsCount; i++) {
  41238. incHex(char, dataSize);
  41239. if (!sequence) {
  41240. stream.readHexNumber(tmp, dataSize);
  41241. addHex(char, tmp, dataSize);
  41242. }
  41243. code = stream.readSigned() + (code + 1);
  41244. cMap.mapOne(hexToInt(char, dataSize), code);
  41245. }
  41246. break;
  41247. case 3:
  41248. stream.readHex(start, dataSize);
  41249. stream.readHexNumber(end, dataSize);
  41250. addHex(end, start, dataSize);
  41251. code = stream.readNumber();
  41252. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41253. for (i = 1; i < subitemsCount; i++) {
  41254. incHex(end, dataSize);
  41255. if (!sequence) {
  41256. stream.readHexNumber(start, dataSize);
  41257. addHex(start, end, dataSize);
  41258. } else {
  41259. start.set(end);
  41260. }
  41261. stream.readHexNumber(end, dataSize);
  41262. addHex(end, start, dataSize);
  41263. code = stream.readNumber();
  41264. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41265. }
  41266. break;
  41267. case 4:
  41268. stream.readHex(char, ucs2DataSize);
  41269. stream.readHex(charCode, dataSize);
  41270. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41271. for (i = 1; i < subitemsCount; i++) {
  41272. incHex(char, ucs2DataSize);
  41273. if (!sequence) {
  41274. stream.readHexNumber(tmp, ucs2DataSize);
  41275. addHex(char, tmp, ucs2DataSize);
  41276. }
  41277. incHex(charCode, dataSize);
  41278. stream.readHexSigned(tmp, dataSize);
  41279. addHex(charCode, tmp, dataSize);
  41280. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41281. }
  41282. break;
  41283. case 5:
  41284. stream.readHex(start, ucs2DataSize);
  41285. stream.readHexNumber(end, ucs2DataSize);
  41286. addHex(end, start, ucs2DataSize);
  41287. stream.readHex(charCode, dataSize);
  41288. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41289. for (i = 1; i < subitemsCount; i++) {
  41290. incHex(end, ucs2DataSize);
  41291. if (!sequence) {
  41292. stream.readHexNumber(start, ucs2DataSize);
  41293. addHex(start, end, ucs2DataSize);
  41294. } else {
  41295. start.set(end);
  41296. }
  41297. stream.readHexNumber(end, ucs2DataSize);
  41298. addHex(end, start, ucs2DataSize);
  41299. stream.readHex(charCode, dataSize);
  41300. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41301. }
  41302. break;
  41303. default:
  41304. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  41305. return;
  41306. }
  41307. }
  41308. if (useCMap) {
  41309. resolve(extend(useCMap));
  41310. return;
  41311. }
  41312. resolve(cMap);
  41313. });
  41314. }
  41315. function BinaryCMapReader() {
  41316. }
  41317. BinaryCMapReader.prototype = { process: processBinaryCMap };
  41318. return BinaryCMapReader;
  41319. }();
  41320. var CMapFactory = function CMapFactoryClosure() {
  41321. function strToInt(str) {
  41322. var a = 0;
  41323. for (var i = 0; i < str.length; i++) {
  41324. a = a << 8 | str.charCodeAt(i);
  41325. }
  41326. return a >>> 0;
  41327. }
  41328. function expectString(obj) {
  41329. if (!isString(obj)) {
  41330. error('Malformed CMap: expected string.');
  41331. }
  41332. }
  41333. function expectInt(obj) {
  41334. if (!isInt(obj)) {
  41335. error('Malformed CMap: expected int.');
  41336. }
  41337. }
  41338. function parseBfChar(cMap, lexer) {
  41339. while (true) {
  41340. var obj = lexer.getObj();
  41341. if (isEOF(obj)) {
  41342. break;
  41343. }
  41344. if (isCmd(obj, 'endbfchar')) {
  41345. return;
  41346. }
  41347. expectString(obj);
  41348. var src = strToInt(obj);
  41349. obj = lexer.getObj();
  41350. expectString(obj);
  41351. var dst = obj;
  41352. cMap.mapOne(src, dst);
  41353. }
  41354. }
  41355. function parseBfRange(cMap, lexer) {
  41356. while (true) {
  41357. var obj = lexer.getObj();
  41358. if (isEOF(obj)) {
  41359. break;
  41360. }
  41361. if (isCmd(obj, 'endbfrange')) {
  41362. return;
  41363. }
  41364. expectString(obj);
  41365. var low = strToInt(obj);
  41366. obj = lexer.getObj();
  41367. expectString(obj);
  41368. var high = strToInt(obj);
  41369. obj = lexer.getObj();
  41370. if (isInt(obj) || isString(obj)) {
  41371. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41372. cMap.mapBfRange(low, high, dstLow);
  41373. } else if (isCmd(obj, '[')) {
  41374. obj = lexer.getObj();
  41375. var array = [];
  41376. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41377. array.push(obj);
  41378. obj = lexer.getObj();
  41379. }
  41380. cMap.mapBfRangeToArray(low, high, array);
  41381. } else {
  41382. break;
  41383. }
  41384. }
  41385. error('Invalid bf range.');
  41386. }
  41387. function parseCidChar(cMap, lexer) {
  41388. while (true) {
  41389. var obj = lexer.getObj();
  41390. if (isEOF(obj)) {
  41391. break;
  41392. }
  41393. if (isCmd(obj, 'endcidchar')) {
  41394. return;
  41395. }
  41396. expectString(obj);
  41397. var src = strToInt(obj);
  41398. obj = lexer.getObj();
  41399. expectInt(obj);
  41400. var dst = obj;
  41401. cMap.mapOne(src, dst);
  41402. }
  41403. }
  41404. function parseCidRange(cMap, lexer) {
  41405. while (true) {
  41406. var obj = lexer.getObj();
  41407. if (isEOF(obj)) {
  41408. break;
  41409. }
  41410. if (isCmd(obj, 'endcidrange')) {
  41411. return;
  41412. }
  41413. expectString(obj);
  41414. var low = strToInt(obj);
  41415. obj = lexer.getObj();
  41416. expectString(obj);
  41417. var high = strToInt(obj);
  41418. obj = lexer.getObj();
  41419. expectInt(obj);
  41420. var dstLow = obj;
  41421. cMap.mapCidRange(low, high, dstLow);
  41422. }
  41423. }
  41424. function parseCodespaceRange(cMap, lexer) {
  41425. while (true) {
  41426. var obj = lexer.getObj();
  41427. if (isEOF(obj)) {
  41428. break;
  41429. }
  41430. if (isCmd(obj, 'endcodespacerange')) {
  41431. return;
  41432. }
  41433. if (!isString(obj)) {
  41434. break;
  41435. }
  41436. var low = strToInt(obj);
  41437. obj = lexer.getObj();
  41438. if (!isString(obj)) {
  41439. break;
  41440. }
  41441. var high = strToInt(obj);
  41442. cMap.addCodespaceRange(obj.length, low, high);
  41443. }
  41444. error('Invalid codespace range.');
  41445. }
  41446. function parseWMode(cMap, lexer) {
  41447. var obj = lexer.getObj();
  41448. if (isInt(obj)) {
  41449. cMap.vertical = !!obj;
  41450. }
  41451. }
  41452. function parseCMapName(cMap, lexer) {
  41453. var obj = lexer.getObj();
  41454. if (isName(obj) && isString(obj.name)) {
  41455. cMap.name = obj.name;
  41456. }
  41457. }
  41458. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  41459. var previous;
  41460. var embededUseCMap;
  41461. objLoop:
  41462. while (true) {
  41463. try {
  41464. var obj = lexer.getObj();
  41465. if (isEOF(obj)) {
  41466. break;
  41467. } else if (isName(obj)) {
  41468. if (obj.name === 'WMode') {
  41469. parseWMode(cMap, lexer);
  41470. } else if (obj.name === 'CMapName') {
  41471. parseCMapName(cMap, lexer);
  41472. }
  41473. previous = obj;
  41474. } else if (isCmd(obj)) {
  41475. switch (obj.cmd) {
  41476. case 'endcmap':
  41477. break objLoop;
  41478. case 'usecmap':
  41479. if (isName(previous)) {
  41480. embededUseCMap = previous.name;
  41481. }
  41482. break;
  41483. case 'begincodespacerange':
  41484. parseCodespaceRange(cMap, lexer);
  41485. break;
  41486. case 'beginbfchar':
  41487. parseBfChar(cMap, lexer);
  41488. break;
  41489. case 'begincidchar':
  41490. parseCidChar(cMap, lexer);
  41491. break;
  41492. case 'beginbfrange':
  41493. parseBfRange(cMap, lexer);
  41494. break;
  41495. case 'begincidrange':
  41496. parseCidRange(cMap, lexer);
  41497. break;
  41498. }
  41499. }
  41500. } catch (ex) {
  41501. if (ex instanceof MissingDataException) {
  41502. throw ex;
  41503. }
  41504. warn('Invalid cMap data: ' + ex);
  41505. continue;
  41506. }
  41507. }
  41508. if (!useCMap && embededUseCMap) {
  41509. useCMap = embededUseCMap;
  41510. }
  41511. if (useCMap) {
  41512. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41513. }
  41514. return Promise.resolve(cMap);
  41515. }
  41516. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  41517. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  41518. cMap.useCMap = newCMap;
  41519. if (cMap.numCodespaceRanges === 0) {
  41520. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41521. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41522. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41523. }
  41524. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41525. }
  41526. cMap.useCMap.forEach(function (key, value) {
  41527. if (!cMap.contains(key)) {
  41528. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41529. }
  41530. });
  41531. return cMap;
  41532. });
  41533. }
  41534. function createBuiltInCMap(name, fetchBuiltInCMap) {
  41535. if (name === 'Identity-H') {
  41536. return Promise.resolve(new IdentityCMap(false, 2));
  41537. } else if (name === 'Identity-V') {
  41538. return Promise.resolve(new IdentityCMap(true, 2));
  41539. }
  41540. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41541. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41542. }
  41543. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  41544. return fetchBuiltInCMap(name).then(function (data) {
  41545. var cMapData = data.cMapData, compressionType = data.compressionType;
  41546. var cMap = new CMap(true);
  41547. if (compressionType === CMapCompressionType.BINARY) {
  41548. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  41549. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41550. });
  41551. }
  41552. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  41553. var lexer = new Lexer(new Stream(cMapData));
  41554. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  41555. });
  41556. }
  41557. return {
  41558. create: function (params) {
  41559. var encoding = params.encoding;
  41560. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  41561. var useCMap = params.useCMap;
  41562. if (isName(encoding)) {
  41563. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  41564. } else if (isStream(encoding)) {
  41565. var cMap = new CMap();
  41566. var lexer = new Lexer(encoding);
  41567. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  41568. if (parsedCMap.isIdentityCMap) {
  41569. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  41570. }
  41571. return parsedCMap;
  41572. });
  41573. }
  41574. return Promise.reject(new Error('Encoding required.'));
  41575. }
  41576. };
  41577. }();
  41578. exports.CMap = CMap;
  41579. exports.CMapFactory = CMapFactory;
  41580. exports.IdentityCMap = IdentityCMap;
  41581. /***/ }),
  41582. /* 31 */
  41583. /***/ (function(module, exports, __w_pdfjs_require__) {
  41584. "use strict";
  41585. var sharedUtil = __w_pdfjs_require__(0);
  41586. var corePrimitives = __w_pdfjs_require__(1);
  41587. var coreStream = __w_pdfjs_require__(2);
  41588. var coreObj = __w_pdfjs_require__(20);
  41589. var coreParser = __w_pdfjs_require__(6);
  41590. var coreCrypto = __w_pdfjs_require__(17);
  41591. var coreEvaluator = __w_pdfjs_require__(18);
  41592. var coreAnnotation = __w_pdfjs_require__(27);
  41593. var MissingDataException = sharedUtil.MissingDataException;
  41594. var Util = sharedUtil.Util;
  41595. var assert = sharedUtil.assert;
  41596. var error = sharedUtil.error;
  41597. var info = sharedUtil.info;
  41598. var isArray = sharedUtil.isArray;
  41599. var isArrayBuffer = sharedUtil.isArrayBuffer;
  41600. var isNum = sharedUtil.isNum;
  41601. var isString = sharedUtil.isString;
  41602. var shadow = sharedUtil.shadow;
  41603. var stringToBytes = sharedUtil.stringToBytes;
  41604. var stringToPDFString = sharedUtil.stringToPDFString;
  41605. var warn = sharedUtil.warn;
  41606. var isSpace = sharedUtil.isSpace;
  41607. var Dict = corePrimitives.Dict;
  41608. var isDict = corePrimitives.isDict;
  41609. var isName = corePrimitives.isName;
  41610. var isStream = corePrimitives.isStream;
  41611. var NullStream = coreStream.NullStream;
  41612. var Stream = coreStream.Stream;
  41613. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  41614. var Catalog = coreObj.Catalog;
  41615. var ObjectLoader = coreObj.ObjectLoader;
  41616. var XRef = coreObj.XRef;
  41617. var Linearization = coreParser.Linearization;
  41618. var calculateMD5 = coreCrypto.calculateMD5;
  41619. var OperatorList = coreEvaluator.OperatorList;
  41620. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  41621. var Annotation = coreAnnotation.Annotation;
  41622. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  41623. var Page = function PageClosure() {
  41624. var DEFAULT_USER_UNIT = 1.0;
  41625. var LETTER_SIZE_MEDIABOX = [
  41626. 0,
  41627. 0,
  41628. 612,
  41629. 792
  41630. ];
  41631. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  41632. this.pdfManager = pdfManager;
  41633. this.pageIndex = pageIndex;
  41634. this.pageDict = pageDict;
  41635. this.xref = xref;
  41636. this.ref = ref;
  41637. this.fontCache = fontCache;
  41638. this.builtInCMapCache = builtInCMapCache;
  41639. this.evaluatorOptions = pdfManager.evaluatorOptions;
  41640. this.resourcesPromise = null;
  41641. var uniquePrefix = 'p' + this.pageIndex + '_';
  41642. var idCounters = { obj: 0 };
  41643. this.idFactory = {
  41644. createObjId: function () {
  41645. return uniquePrefix + ++idCounters.obj;
  41646. }
  41647. };
  41648. }
  41649. Page.prototype = {
  41650. getPageProp: function Page_getPageProp(key) {
  41651. return this.pageDict.get(key);
  41652. },
  41653. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  41654. var dict = this.pageDict, valueArray = null, loopCount = 0;
  41655. var MAX_LOOP_COUNT = 100;
  41656. getArray = getArray || false;
  41657. while (dict) {
  41658. var value = getArray ? dict.getArray(key) : dict.get(key);
  41659. if (value) {
  41660. if (!valueArray) {
  41661. valueArray = [];
  41662. }
  41663. valueArray.push(value);
  41664. }
  41665. if (++loopCount > MAX_LOOP_COUNT) {
  41666. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  41667. break;
  41668. }
  41669. dict = dict.get('Parent');
  41670. }
  41671. if (!valueArray) {
  41672. return Dict.empty;
  41673. }
  41674. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  41675. return valueArray[0];
  41676. }
  41677. return Dict.merge(this.xref, valueArray);
  41678. },
  41679. get content() {
  41680. return this.getPageProp('Contents');
  41681. },
  41682. get resources() {
  41683. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  41684. },
  41685. get mediaBox() {
  41686. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  41687. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  41688. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  41689. }
  41690. return shadow(this, 'mediaBox', mediaBox);
  41691. },
  41692. get cropBox() {
  41693. var cropBox = this.getInheritedPageProp('CropBox', true);
  41694. if (!isArray(cropBox) || cropBox.length !== 4) {
  41695. return shadow(this, 'cropBox', this.mediaBox);
  41696. }
  41697. return shadow(this, 'cropBox', cropBox);
  41698. },
  41699. get userUnit() {
  41700. var obj = this.getPageProp('UserUnit');
  41701. if (!isNum(obj) || obj <= 0) {
  41702. obj = DEFAULT_USER_UNIT;
  41703. }
  41704. return shadow(this, 'userUnit', obj);
  41705. },
  41706. get view() {
  41707. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  41708. if (mediaBox === cropBox) {
  41709. return shadow(this, 'view', mediaBox);
  41710. }
  41711. var intersection = Util.intersect(cropBox, mediaBox);
  41712. return shadow(this, 'view', intersection || mediaBox);
  41713. },
  41714. get rotate() {
  41715. var rotate = this.getInheritedPageProp('Rotate') || 0;
  41716. if (rotate % 90 !== 0) {
  41717. rotate = 0;
  41718. } else if (rotate >= 360) {
  41719. rotate = rotate % 360;
  41720. } else if (rotate < 0) {
  41721. rotate = (rotate % 360 + 360) % 360;
  41722. }
  41723. return shadow(this, 'rotate', rotate);
  41724. },
  41725. getContentStream: function Page_getContentStream() {
  41726. var content = this.content;
  41727. var stream;
  41728. if (isArray(content)) {
  41729. var xref = this.xref;
  41730. var i, n = content.length;
  41731. var streams = [];
  41732. for (i = 0; i < n; ++i) {
  41733. streams.push(xref.fetchIfRef(content[i]));
  41734. }
  41735. stream = new StreamsSequenceStream(streams);
  41736. } else if (isStream(content)) {
  41737. stream = content;
  41738. } else {
  41739. stream = new NullStream();
  41740. }
  41741. return stream;
  41742. },
  41743. loadResources: function Page_loadResources(keys) {
  41744. if (!this.resourcesPromise) {
  41745. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  41746. }
  41747. return this.resourcesPromise.then(function resourceSuccess() {
  41748. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  41749. return objectLoader.load();
  41750. }.bind(this));
  41751. },
  41752. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  41753. var self = this;
  41754. var pdfManager = this.pdfManager;
  41755. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41756. var resourcesPromise = this.loadResources([
  41757. 'ExtGState',
  41758. 'ColorSpace',
  41759. 'Pattern',
  41760. 'Shading',
  41761. 'XObject',
  41762. 'Font'
  41763. ]);
  41764. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  41765. var dataPromises = Promise.all([
  41766. contentStreamPromise,
  41767. resourcesPromise
  41768. ]);
  41769. var pageListPromise = dataPromises.then(function (data) {
  41770. var contentStream = data[0];
  41771. var opList = new OperatorList(intent, handler, self.pageIndex);
  41772. handler.send('StartRenderPage', {
  41773. transparency: partialEvaluator.hasBlendModes(self.resources),
  41774. pageIndex: self.pageIndex,
  41775. intent: intent
  41776. });
  41777. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  41778. return opList;
  41779. });
  41780. });
  41781. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  41782. return Promise.all([
  41783. pageListPromise,
  41784. annotationsPromise
  41785. ]).then(function (datas) {
  41786. var pageOpList = datas[0];
  41787. var annotations = datas[1];
  41788. if (annotations.length === 0) {
  41789. pageOpList.flush(true);
  41790. return pageOpList;
  41791. }
  41792. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  41793. return annotationsReadyPromise.then(function () {
  41794. pageOpList.flush(true);
  41795. return pageOpList;
  41796. });
  41797. });
  41798. },
  41799. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  41800. var handler = {
  41801. on: function nullHandlerOn() {
  41802. },
  41803. send: function nullHandlerSend() {
  41804. }
  41805. };
  41806. var self = this;
  41807. var pdfManager = this.pdfManager;
  41808. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41809. var resourcesPromise = this.loadResources([
  41810. 'ExtGState',
  41811. 'XObject',
  41812. 'Font'
  41813. ]);
  41814. var dataPromises = Promise.all([
  41815. contentStreamPromise,
  41816. resourcesPromise
  41817. ]);
  41818. return dataPromises.then(function (data) {
  41819. var contentStream = data[0];
  41820. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  41821. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  41822. });
  41823. },
  41824. getAnnotationsData: function Page_getAnnotationsData(intent) {
  41825. var annotations = this.annotations;
  41826. var annotationsData = [];
  41827. for (var i = 0, n = annotations.length; i < n; ++i) {
  41828. if (intent) {
  41829. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  41830. continue;
  41831. }
  41832. }
  41833. annotationsData.push(annotations[i].data);
  41834. }
  41835. return annotationsData;
  41836. },
  41837. get annotations() {
  41838. var annotations = [];
  41839. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  41840. var annotationFactory = new AnnotationFactory();
  41841. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  41842. var annotationRef = annotationRefs[i];
  41843. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  41844. if (annotation) {
  41845. annotations.push(annotation);
  41846. }
  41847. }
  41848. return shadow(this, 'annotations', annotations);
  41849. }
  41850. };
  41851. return Page;
  41852. }();
  41853. var PDFDocument = function PDFDocumentClosure() {
  41854. var FINGERPRINT_FIRST_BYTES = 1024;
  41855. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  41856. function PDFDocument(pdfManager, arg) {
  41857. var stream;
  41858. if (isStream(arg)) {
  41859. stream = arg;
  41860. } else if (isArrayBuffer(arg)) {
  41861. stream = new Stream(arg);
  41862. } else {
  41863. error('PDFDocument: Unknown argument type');
  41864. }
  41865. assert(stream.length > 0, 'stream must have data');
  41866. this.pdfManager = pdfManager;
  41867. this.stream = stream;
  41868. this.xref = new XRef(stream, pdfManager);
  41869. }
  41870. function find(stream, needle, limit, backwards) {
  41871. var pos = stream.pos;
  41872. var end = stream.end;
  41873. var strBuf = [];
  41874. if (pos + limit > end) {
  41875. limit = end - pos;
  41876. }
  41877. for (var n = 0; n < limit; ++n) {
  41878. strBuf.push(String.fromCharCode(stream.getByte()));
  41879. }
  41880. var str = strBuf.join('');
  41881. stream.pos = pos;
  41882. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  41883. if (index === -1) {
  41884. return false;
  41885. }
  41886. stream.pos += index;
  41887. return true;
  41888. }
  41889. var DocumentInfoValidators = {
  41890. get entries() {
  41891. return shadow(this, 'entries', {
  41892. Title: isString,
  41893. Author: isString,
  41894. Subject: isString,
  41895. Keywords: isString,
  41896. Creator: isString,
  41897. Producer: isString,
  41898. CreationDate: isString,
  41899. ModDate: isString,
  41900. Trapped: isName
  41901. });
  41902. }
  41903. };
  41904. PDFDocument.prototype = {
  41905. parse: function PDFDocument_parse(recoveryMode) {
  41906. this.setup(recoveryMode);
  41907. var version = this.catalog.catDict.get('Version');
  41908. if (isName(version)) {
  41909. this.pdfFormatVersion = version.name;
  41910. }
  41911. try {
  41912. this.acroForm = this.catalog.catDict.get('AcroForm');
  41913. if (this.acroForm) {
  41914. this.xfa = this.acroForm.get('XFA');
  41915. var fields = this.acroForm.get('Fields');
  41916. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  41917. this.acroForm = null;
  41918. }
  41919. }
  41920. } catch (ex) {
  41921. info('Something wrong with AcroForm entry');
  41922. this.acroForm = null;
  41923. }
  41924. },
  41925. get linearization() {
  41926. var linearization = null;
  41927. if (this.stream.length) {
  41928. try {
  41929. linearization = Linearization.create(this.stream);
  41930. } catch (err) {
  41931. if (err instanceof MissingDataException) {
  41932. throw err;
  41933. }
  41934. info(err);
  41935. }
  41936. }
  41937. return shadow(this, 'linearization', linearization);
  41938. },
  41939. get startXRef() {
  41940. var stream = this.stream;
  41941. var startXRef = 0;
  41942. var linearization = this.linearization;
  41943. if (linearization) {
  41944. stream.reset();
  41945. if (find(stream, 'endobj', 1024)) {
  41946. startXRef = stream.pos + 6;
  41947. }
  41948. } else {
  41949. var step = 1024;
  41950. var found = false, pos = stream.end;
  41951. while (!found && pos > 0) {
  41952. pos -= step - 'startxref'.length;
  41953. if (pos < 0) {
  41954. pos = 0;
  41955. }
  41956. stream.pos = pos;
  41957. found = find(stream, 'startxref', step, true);
  41958. }
  41959. if (found) {
  41960. stream.skip(9);
  41961. var ch;
  41962. do {
  41963. ch = stream.getByte();
  41964. } while (isSpace(ch));
  41965. var str = '';
  41966. while (ch >= 0x20 && ch <= 0x39) {
  41967. str += String.fromCharCode(ch);
  41968. ch = stream.getByte();
  41969. }
  41970. startXRef = parseInt(str, 10);
  41971. if (isNaN(startXRef)) {
  41972. startXRef = 0;
  41973. }
  41974. }
  41975. }
  41976. return shadow(this, 'startXRef', startXRef);
  41977. },
  41978. get mainXRefEntriesOffset() {
  41979. var mainXRefEntriesOffset = 0;
  41980. var linearization = this.linearization;
  41981. if (linearization) {
  41982. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  41983. }
  41984. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  41985. },
  41986. checkHeader: function PDFDocument_checkHeader() {
  41987. var stream = this.stream;
  41988. stream.reset();
  41989. if (find(stream, '%PDF-', 1024)) {
  41990. stream.moveStart();
  41991. var MAX_VERSION_LENGTH = 12;
  41992. var version = '', ch;
  41993. while ((ch = stream.getByte()) > 0x20) {
  41994. if (version.length >= MAX_VERSION_LENGTH) {
  41995. break;
  41996. }
  41997. version += String.fromCharCode(ch);
  41998. }
  41999. if (!this.pdfFormatVersion) {
  42000. this.pdfFormatVersion = version.substring(5);
  42001. }
  42002. return;
  42003. }
  42004. },
  42005. parseStartXRef: function PDFDocument_parseStartXRef() {
  42006. var startXRef = this.startXRef;
  42007. this.xref.setStartXRef(startXRef);
  42008. },
  42009. setup: function PDFDocument_setup(recoveryMode) {
  42010. this.xref.parse(recoveryMode);
  42011. var self = this;
  42012. var pageFactory = {
  42013. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42014. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42015. }
  42016. };
  42017. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42018. },
  42019. get numPages() {
  42020. var linearization = this.linearization;
  42021. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42022. return shadow(this, 'numPages', num);
  42023. },
  42024. get documentInfo() {
  42025. var docInfo = {
  42026. PDFFormatVersion: this.pdfFormatVersion,
  42027. IsAcroFormPresent: !!this.acroForm,
  42028. IsXFAPresent: !!this.xfa
  42029. };
  42030. var infoDict;
  42031. try {
  42032. infoDict = this.xref.trailer.get('Info');
  42033. } catch (err) {
  42034. info('The document information dictionary is invalid.');
  42035. }
  42036. if (infoDict) {
  42037. var validEntries = DocumentInfoValidators.entries;
  42038. for (var key in validEntries) {
  42039. if (infoDict.has(key)) {
  42040. var value = infoDict.get(key);
  42041. if (validEntries[key](value)) {
  42042. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42043. } else {
  42044. info('Bad value in document info for "' + key + '"');
  42045. }
  42046. }
  42047. }
  42048. }
  42049. return shadow(this, 'documentInfo', docInfo);
  42050. },
  42051. get fingerprint() {
  42052. var xref = this.xref, hash, fileID = '';
  42053. var idArray = xref.trailer.get('ID');
  42054. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42055. hash = stringToBytes(idArray[0]);
  42056. } else {
  42057. if (this.stream.ensureRange) {
  42058. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42059. }
  42060. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42061. }
  42062. for (var i = 0, n = hash.length; i < n; i++) {
  42063. var hex = hash[i].toString(16);
  42064. fileID += hex.length === 1 ? '0' + hex : hex;
  42065. }
  42066. return shadow(this, 'fingerprint', fileID);
  42067. },
  42068. getPage: function PDFDocument_getPage(pageIndex) {
  42069. return this.catalog.getPage(pageIndex);
  42070. },
  42071. cleanup: function PDFDocument_cleanup() {
  42072. return this.catalog.cleanup();
  42073. }
  42074. };
  42075. return PDFDocument;
  42076. }();
  42077. exports.Page = Page;
  42078. exports.PDFDocument = PDFDocument;
  42079. /***/ }),
  42080. /* 32 */
  42081. /***/ (function(module, exports, __w_pdfjs_require__) {
  42082. "use strict";
  42083. var sharedUtil = __w_pdfjs_require__(0);
  42084. var coreStream = __w_pdfjs_require__(2);
  42085. var coreGlyphList = __w_pdfjs_require__(8);
  42086. var coreEncodings = __w_pdfjs_require__(5);
  42087. var coreCFFParser = __w_pdfjs_require__(15);
  42088. var Util = sharedUtil.Util;
  42089. var bytesToString = sharedUtil.bytesToString;
  42090. var error = sharedUtil.error;
  42091. var Stream = coreStream.Stream;
  42092. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42093. var StandardEncoding = coreEncodings.StandardEncoding;
  42094. var CFFParser = coreCFFParser.CFFParser;
  42095. var FontRendererFactory = function FontRendererFactoryClosure() {
  42096. function getLong(data, offset) {
  42097. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42098. }
  42099. function getUshort(data, offset) {
  42100. return data[offset] << 8 | data[offset + 1];
  42101. }
  42102. function parseCmap(data, start, end) {
  42103. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42104. var format = getUshort(data, start + offset);
  42105. var ranges, p, i;
  42106. if (format === 4) {
  42107. getUshort(data, start + offset + 2);
  42108. var segCount = getUshort(data, start + offset + 6) >> 1;
  42109. p = start + offset + 14;
  42110. ranges = [];
  42111. for (i = 0; i < segCount; i++, p += 2) {
  42112. ranges[i] = { end: getUshort(data, p) };
  42113. }
  42114. p += 2;
  42115. for (i = 0; i < segCount; i++, p += 2) {
  42116. ranges[i].start = getUshort(data, p);
  42117. }
  42118. for (i = 0; i < segCount; i++, p += 2) {
  42119. ranges[i].idDelta = getUshort(data, p);
  42120. }
  42121. for (i = 0; i < segCount; i++, p += 2) {
  42122. var idOffset = getUshort(data, p);
  42123. if (idOffset === 0) {
  42124. continue;
  42125. }
  42126. ranges[i].ids = [];
  42127. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42128. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42129. idOffset += 2;
  42130. }
  42131. }
  42132. return ranges;
  42133. } else if (format === 12) {
  42134. getLong(data, start + offset + 4);
  42135. var groups = getLong(data, start + offset + 12);
  42136. p = start + offset + 16;
  42137. ranges = [];
  42138. for (i = 0; i < groups; i++) {
  42139. ranges.push({
  42140. start: getLong(data, p),
  42141. end: getLong(data, p + 4),
  42142. idDelta: getLong(data, p + 8) - getLong(data, p)
  42143. });
  42144. p += 12;
  42145. }
  42146. return ranges;
  42147. }
  42148. error('not supported cmap: ' + format);
  42149. }
  42150. function parseCff(data, start, end, seacAnalysisEnabled) {
  42151. var properties = {};
  42152. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42153. var cff = parser.parse();
  42154. return {
  42155. glyphs: cff.charStrings.objects,
  42156. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42157. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42158. };
  42159. }
  42160. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42161. var itemSize, itemDecode;
  42162. if (isGlyphLocationsLong) {
  42163. itemSize = 4;
  42164. itemDecode = function fontItemDecodeLong(data, offset) {
  42165. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42166. };
  42167. } else {
  42168. itemSize = 2;
  42169. itemDecode = function fontItemDecode(data, offset) {
  42170. return data[offset] << 9 | data[offset + 1] << 1;
  42171. };
  42172. }
  42173. var glyphs = [];
  42174. var startOffset = itemDecode(loca, 0);
  42175. for (var j = itemSize; j < loca.length; j += itemSize) {
  42176. var endOffset = itemDecode(loca, j);
  42177. glyphs.push(glyf.subarray(startOffset, endOffset));
  42178. startOffset = endOffset;
  42179. }
  42180. return glyphs;
  42181. }
  42182. function lookupCmap(ranges, unicode) {
  42183. var code = unicode.charCodeAt(0), gid = 0;
  42184. var l = 0, r = ranges.length - 1;
  42185. while (l < r) {
  42186. var c = l + r + 1 >> 1;
  42187. if (code < ranges[c].start) {
  42188. r = c - 1;
  42189. } else {
  42190. l = c;
  42191. }
  42192. }
  42193. if (ranges[l].start <= code && code <= ranges[l].end) {
  42194. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  42195. }
  42196. return {
  42197. charCode: code,
  42198. glyphId: gid
  42199. };
  42200. }
  42201. function compileGlyf(code, cmds, font) {
  42202. function moveTo(x, y) {
  42203. cmds.push({
  42204. cmd: 'moveTo',
  42205. args: [
  42206. x,
  42207. y
  42208. ]
  42209. });
  42210. }
  42211. function lineTo(x, y) {
  42212. cmds.push({
  42213. cmd: 'lineTo',
  42214. args: [
  42215. x,
  42216. y
  42217. ]
  42218. });
  42219. }
  42220. function quadraticCurveTo(xa, ya, x, y) {
  42221. cmds.push({
  42222. cmd: 'quadraticCurveTo',
  42223. args: [
  42224. xa,
  42225. ya,
  42226. x,
  42227. y
  42228. ]
  42229. });
  42230. }
  42231. var i = 0;
  42232. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42233. var flags;
  42234. var x = 0, y = 0;
  42235. i += 10;
  42236. if (numberOfContours < 0) {
  42237. do {
  42238. flags = code[i] << 8 | code[i + 1];
  42239. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  42240. i += 4;
  42241. var arg1, arg2;
  42242. if (flags & 0x01) {
  42243. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42244. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  42245. i += 4;
  42246. } else {
  42247. arg1 = code[i++];
  42248. arg2 = code[i++];
  42249. }
  42250. if (flags & 0x02) {
  42251. x = arg1;
  42252. y = arg2;
  42253. } else {
  42254. x = 0;
  42255. y = 0;
  42256. }
  42257. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  42258. if (flags & 0x08) {
  42259. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42260. i += 2;
  42261. } else if (flags & 0x40) {
  42262. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42263. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42264. i += 4;
  42265. } else if (flags & 0x80) {
  42266. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42267. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42268. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  42269. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  42270. i += 8;
  42271. }
  42272. var subglyph = font.glyphs[glyphIndex];
  42273. if (subglyph) {
  42274. cmds.push({ cmd: 'save' });
  42275. cmds.push({
  42276. cmd: 'transform',
  42277. args: [
  42278. scaleX,
  42279. scale01,
  42280. scale10,
  42281. scaleY,
  42282. x,
  42283. y
  42284. ]
  42285. });
  42286. compileGlyf(subglyph, cmds, font);
  42287. cmds.push({ cmd: 'restore' });
  42288. }
  42289. } while (flags & 0x20);
  42290. } else {
  42291. var endPtsOfContours = [];
  42292. var j, jj;
  42293. for (j = 0; j < numberOfContours; j++) {
  42294. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  42295. i += 2;
  42296. }
  42297. var instructionLength = code[i] << 8 | code[i + 1];
  42298. i += 2 + instructionLength;
  42299. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  42300. var points = [];
  42301. while (points.length < numberOfPoints) {
  42302. flags = code[i++];
  42303. var repeat = 1;
  42304. if (flags & 0x08) {
  42305. repeat += code[i++];
  42306. }
  42307. while (repeat-- > 0) {
  42308. points.push({ flags: flags });
  42309. }
  42310. }
  42311. for (j = 0; j < numberOfPoints; j++) {
  42312. switch (points[j].flags & 0x12) {
  42313. case 0x00:
  42314. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42315. i += 2;
  42316. break;
  42317. case 0x02:
  42318. x -= code[i++];
  42319. break;
  42320. case 0x12:
  42321. x += code[i++];
  42322. break;
  42323. }
  42324. points[j].x = x;
  42325. }
  42326. for (j = 0; j < numberOfPoints; j++) {
  42327. switch (points[j].flags & 0x24) {
  42328. case 0x00:
  42329. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42330. i += 2;
  42331. break;
  42332. case 0x04:
  42333. y -= code[i++];
  42334. break;
  42335. case 0x24:
  42336. y += code[i++];
  42337. break;
  42338. }
  42339. points[j].y = y;
  42340. }
  42341. var startPoint = 0;
  42342. for (i = 0; i < numberOfContours; i++) {
  42343. var endPoint = endPtsOfContours[i];
  42344. var contour = points.slice(startPoint, endPoint + 1);
  42345. if (contour[0].flags & 1) {
  42346. contour.push(contour[0]);
  42347. } else if (contour[contour.length - 1].flags & 1) {
  42348. contour.unshift(contour[contour.length - 1]);
  42349. } else {
  42350. var p = {
  42351. flags: 1,
  42352. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  42353. y: (contour[0].y + contour[contour.length - 1].y) / 2
  42354. };
  42355. contour.unshift(p);
  42356. contour.push(p);
  42357. }
  42358. moveTo(contour[0].x, contour[0].y);
  42359. for (j = 1, jj = contour.length; j < jj; j++) {
  42360. if (contour[j].flags & 1) {
  42361. lineTo(contour[j].x, contour[j].y);
  42362. } else if (contour[j + 1].flags & 1) {
  42363. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  42364. j++;
  42365. } else {
  42366. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  42367. }
  42368. }
  42369. startPoint = endPoint + 1;
  42370. }
  42371. }
  42372. }
  42373. function compileCharString(code, cmds, font) {
  42374. var stack = [];
  42375. var x = 0, y = 0;
  42376. var stems = 0;
  42377. function moveTo(x, y) {
  42378. cmds.push({
  42379. cmd: 'moveTo',
  42380. args: [
  42381. x,
  42382. y
  42383. ]
  42384. });
  42385. }
  42386. function lineTo(x, y) {
  42387. cmds.push({
  42388. cmd: 'lineTo',
  42389. args: [
  42390. x,
  42391. y
  42392. ]
  42393. });
  42394. }
  42395. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  42396. cmds.push({
  42397. cmd: 'bezierCurveTo',
  42398. args: [
  42399. x1,
  42400. y1,
  42401. x2,
  42402. y2,
  42403. x,
  42404. y
  42405. ]
  42406. });
  42407. }
  42408. function parse(code) {
  42409. var i = 0;
  42410. while (i < code.length) {
  42411. var stackClean = false;
  42412. var v = code[i++];
  42413. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  42414. switch (v) {
  42415. case 1:
  42416. stems += stack.length >> 1;
  42417. stackClean = true;
  42418. break;
  42419. case 3:
  42420. stems += stack.length >> 1;
  42421. stackClean = true;
  42422. break;
  42423. case 4:
  42424. y += stack.pop();
  42425. moveTo(x, y);
  42426. stackClean = true;
  42427. break;
  42428. case 5:
  42429. while (stack.length > 0) {
  42430. x += stack.shift();
  42431. y += stack.shift();
  42432. lineTo(x, y);
  42433. }
  42434. break;
  42435. case 6:
  42436. while (stack.length > 0) {
  42437. x += stack.shift();
  42438. lineTo(x, y);
  42439. if (stack.length === 0) {
  42440. break;
  42441. }
  42442. y += stack.shift();
  42443. lineTo(x, y);
  42444. }
  42445. break;
  42446. case 7:
  42447. while (stack.length > 0) {
  42448. y += stack.shift();
  42449. lineTo(x, y);
  42450. if (stack.length === 0) {
  42451. break;
  42452. }
  42453. x += stack.shift();
  42454. lineTo(x, y);
  42455. }
  42456. break;
  42457. case 8:
  42458. while (stack.length > 0) {
  42459. xa = x + stack.shift();
  42460. ya = y + stack.shift();
  42461. xb = xa + stack.shift();
  42462. yb = ya + stack.shift();
  42463. x = xb + stack.shift();
  42464. y = yb + stack.shift();
  42465. bezierCurveTo(xa, ya, xb, yb, x, y);
  42466. }
  42467. break;
  42468. case 10:
  42469. n = stack.pop() + font.subrsBias;
  42470. subrCode = font.subrs[n];
  42471. if (subrCode) {
  42472. parse(subrCode);
  42473. }
  42474. break;
  42475. case 11:
  42476. return;
  42477. case 12:
  42478. v = code[i++];
  42479. switch (v) {
  42480. case 34:
  42481. xa = x + stack.shift();
  42482. xb = xa + stack.shift();
  42483. y1 = y + stack.shift();
  42484. x = xb + stack.shift();
  42485. bezierCurveTo(xa, y, xb, y1, x, y1);
  42486. xa = x + stack.shift();
  42487. xb = xa + stack.shift();
  42488. x = xb + stack.shift();
  42489. bezierCurveTo(xa, y1, xb, y, x, y);
  42490. break;
  42491. case 35:
  42492. xa = x + stack.shift();
  42493. ya = y + stack.shift();
  42494. xb = xa + stack.shift();
  42495. yb = ya + stack.shift();
  42496. x = xb + stack.shift();
  42497. y = yb + stack.shift();
  42498. bezierCurveTo(xa, ya, xb, yb, x, y);
  42499. xa = x + stack.shift();
  42500. ya = y + stack.shift();
  42501. xb = xa + stack.shift();
  42502. yb = ya + stack.shift();
  42503. x = xb + stack.shift();
  42504. y = yb + stack.shift();
  42505. bezierCurveTo(xa, ya, xb, yb, x, y);
  42506. stack.pop();
  42507. break;
  42508. case 36:
  42509. xa = x + stack.shift();
  42510. y1 = y + stack.shift();
  42511. xb = xa + stack.shift();
  42512. y2 = y1 + stack.shift();
  42513. x = xb + stack.shift();
  42514. bezierCurveTo(xa, y1, xb, y2, x, y2);
  42515. xa = x + stack.shift();
  42516. xb = xa + stack.shift();
  42517. y3 = y2 + stack.shift();
  42518. x = xb + stack.shift();
  42519. bezierCurveTo(xa, y2, xb, y3, x, y);
  42520. break;
  42521. case 37:
  42522. var x0 = x, y0 = y;
  42523. xa = x + stack.shift();
  42524. ya = y + stack.shift();
  42525. xb = xa + stack.shift();
  42526. yb = ya + stack.shift();
  42527. x = xb + stack.shift();
  42528. y = yb + stack.shift();
  42529. bezierCurveTo(xa, ya, xb, yb, x, y);
  42530. xa = x + stack.shift();
  42531. ya = y + stack.shift();
  42532. xb = xa + stack.shift();
  42533. yb = ya + stack.shift();
  42534. x = xb;
  42535. y = yb;
  42536. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  42537. x += stack.shift();
  42538. } else {
  42539. y += stack.shift();
  42540. }
  42541. bezierCurveTo(xa, ya, xb, yb, x, y);
  42542. break;
  42543. default:
  42544. error('unknown operator: 12 ' + v);
  42545. }
  42546. break;
  42547. case 14:
  42548. if (stack.length >= 4) {
  42549. var achar = stack.pop();
  42550. var bchar = stack.pop();
  42551. y = stack.pop();
  42552. x = stack.pop();
  42553. cmds.push({ cmd: 'save' });
  42554. cmds.push({
  42555. cmd: 'translate',
  42556. args: [
  42557. x,
  42558. y
  42559. ]
  42560. });
  42561. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  42562. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42563. cmds.push({ cmd: 'restore' });
  42564. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  42565. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42566. }
  42567. return;
  42568. case 18:
  42569. stems += stack.length >> 1;
  42570. stackClean = true;
  42571. break;
  42572. case 19:
  42573. stems += stack.length >> 1;
  42574. i += stems + 7 >> 3;
  42575. stackClean = true;
  42576. break;
  42577. case 20:
  42578. stems += stack.length >> 1;
  42579. i += stems + 7 >> 3;
  42580. stackClean = true;
  42581. break;
  42582. case 21:
  42583. y += stack.pop();
  42584. x += stack.pop();
  42585. moveTo(x, y);
  42586. stackClean = true;
  42587. break;
  42588. case 22:
  42589. x += stack.pop();
  42590. moveTo(x, y);
  42591. stackClean = true;
  42592. break;
  42593. case 23:
  42594. stems += stack.length >> 1;
  42595. stackClean = true;
  42596. break;
  42597. case 24:
  42598. while (stack.length > 2) {
  42599. xa = x + stack.shift();
  42600. ya = y + stack.shift();
  42601. xb = xa + stack.shift();
  42602. yb = ya + stack.shift();
  42603. x = xb + stack.shift();
  42604. y = yb + stack.shift();
  42605. bezierCurveTo(xa, ya, xb, yb, x, y);
  42606. }
  42607. x += stack.shift();
  42608. y += stack.shift();
  42609. lineTo(x, y);
  42610. break;
  42611. case 25:
  42612. while (stack.length > 6) {
  42613. x += stack.shift();
  42614. y += stack.shift();
  42615. lineTo(x, y);
  42616. }
  42617. xa = x + stack.shift();
  42618. ya = y + stack.shift();
  42619. xb = xa + stack.shift();
  42620. yb = ya + stack.shift();
  42621. x = xb + stack.shift();
  42622. y = yb + stack.shift();
  42623. bezierCurveTo(xa, ya, xb, yb, x, y);
  42624. break;
  42625. case 26:
  42626. if (stack.length % 2) {
  42627. x += stack.shift();
  42628. }
  42629. while (stack.length > 0) {
  42630. xa = x;
  42631. ya = y + stack.shift();
  42632. xb = xa + stack.shift();
  42633. yb = ya + stack.shift();
  42634. x = xb;
  42635. y = yb + stack.shift();
  42636. bezierCurveTo(xa, ya, xb, yb, x, y);
  42637. }
  42638. break;
  42639. case 27:
  42640. if (stack.length % 2) {
  42641. y += stack.shift();
  42642. }
  42643. while (stack.length > 0) {
  42644. xa = x + stack.shift();
  42645. ya = y;
  42646. xb = xa + stack.shift();
  42647. yb = ya + stack.shift();
  42648. x = xb + stack.shift();
  42649. y = yb;
  42650. bezierCurveTo(xa, ya, xb, yb, x, y);
  42651. }
  42652. break;
  42653. case 28:
  42654. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  42655. i += 2;
  42656. break;
  42657. case 29:
  42658. n = stack.pop() + font.gsubrsBias;
  42659. subrCode = font.gsubrs[n];
  42660. if (subrCode) {
  42661. parse(subrCode);
  42662. }
  42663. break;
  42664. case 30:
  42665. while (stack.length > 0) {
  42666. xa = x;
  42667. ya = y + stack.shift();
  42668. xb = xa + stack.shift();
  42669. yb = ya + stack.shift();
  42670. x = xb + stack.shift();
  42671. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42672. bezierCurveTo(xa, ya, xb, yb, x, y);
  42673. if (stack.length === 0) {
  42674. break;
  42675. }
  42676. xa = x + stack.shift();
  42677. ya = y;
  42678. xb = xa + stack.shift();
  42679. yb = ya + stack.shift();
  42680. y = yb + stack.shift();
  42681. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42682. bezierCurveTo(xa, ya, xb, yb, x, y);
  42683. }
  42684. break;
  42685. case 31:
  42686. while (stack.length > 0) {
  42687. xa = x + stack.shift();
  42688. ya = y;
  42689. xb = xa + stack.shift();
  42690. yb = ya + stack.shift();
  42691. y = yb + stack.shift();
  42692. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42693. bezierCurveTo(xa, ya, xb, yb, x, y);
  42694. if (stack.length === 0) {
  42695. break;
  42696. }
  42697. xa = x;
  42698. ya = y + stack.shift();
  42699. xb = xa + stack.shift();
  42700. yb = ya + stack.shift();
  42701. x = xb + stack.shift();
  42702. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42703. bezierCurveTo(xa, ya, xb, yb, x, y);
  42704. }
  42705. break;
  42706. default:
  42707. if (v < 32) {
  42708. error('unknown operator: ' + v);
  42709. }
  42710. if (v < 247) {
  42711. stack.push(v - 139);
  42712. } else if (v < 251) {
  42713. stack.push((v - 247) * 256 + code[i++] + 108);
  42714. } else if (v < 255) {
  42715. stack.push(-(v - 251) * 256 - code[i++] - 108);
  42716. } else {
  42717. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  42718. i += 4;
  42719. }
  42720. break;
  42721. }
  42722. if (stackClean) {
  42723. stack.length = 0;
  42724. }
  42725. }
  42726. }
  42727. parse(code);
  42728. }
  42729. var noop = '';
  42730. function CompiledFont(fontMatrix) {
  42731. this.compiledGlyphs = Object.create(null);
  42732. this.compiledCharCodeToGlyphId = Object.create(null);
  42733. this.fontMatrix = fontMatrix;
  42734. }
  42735. CompiledFont.prototype = {
  42736. getPathJs: function (unicode) {
  42737. var cmap = lookupCmap(this.cmap, unicode);
  42738. var fn = this.compiledGlyphs[cmap.glyphId];
  42739. if (!fn) {
  42740. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  42741. this.compiledGlyphs[cmap.glyphId] = fn;
  42742. }
  42743. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  42744. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  42745. }
  42746. return fn;
  42747. },
  42748. compileGlyph: function (code) {
  42749. if (!code || code.length === 0 || code[0] === 14) {
  42750. return noop;
  42751. }
  42752. var cmds = [];
  42753. cmds.push({ cmd: 'save' });
  42754. cmds.push({
  42755. cmd: 'transform',
  42756. args: this.fontMatrix.slice()
  42757. });
  42758. cmds.push({
  42759. cmd: 'scale',
  42760. args: [
  42761. 'size',
  42762. '-size'
  42763. ]
  42764. });
  42765. this.compileGlyphImpl(code, cmds);
  42766. cmds.push({ cmd: 'restore' });
  42767. return cmds;
  42768. },
  42769. compileGlyphImpl: function () {
  42770. error('Children classes should implement this.');
  42771. },
  42772. hasBuiltPath: function (unicode) {
  42773. var cmap = lookupCmap(this.cmap, unicode);
  42774. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  42775. }
  42776. };
  42777. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  42778. fontMatrix = fontMatrix || [
  42779. 0.000488,
  42780. 0,
  42781. 0,
  42782. 0.000488,
  42783. 0,
  42784. 0
  42785. ];
  42786. CompiledFont.call(this, fontMatrix);
  42787. this.glyphs = glyphs;
  42788. this.cmap = cmap;
  42789. }
  42790. Util.inherit(TrueTypeCompiled, CompiledFont, {
  42791. compileGlyphImpl: function (code, cmds) {
  42792. compileGlyf(code, cmds, this);
  42793. }
  42794. });
  42795. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  42796. fontMatrix = fontMatrix || [
  42797. 0.001,
  42798. 0,
  42799. 0,
  42800. 0.001,
  42801. 0,
  42802. 0
  42803. ];
  42804. CompiledFont.call(this, fontMatrix);
  42805. this.glyphs = cffInfo.glyphs;
  42806. this.gsubrs = cffInfo.gsubrs || [];
  42807. this.subrs = cffInfo.subrs || [];
  42808. this.cmap = cmap;
  42809. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  42810. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  42811. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  42812. }
  42813. Util.inherit(Type2Compiled, CompiledFont, {
  42814. compileGlyphImpl: function (code, cmds) {
  42815. compileCharString(code, cmds, this);
  42816. }
  42817. });
  42818. return {
  42819. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  42820. var data = new Uint8Array(font.data);
  42821. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  42822. var numTables = getUshort(data, 4);
  42823. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  42824. var tag = bytesToString(data.subarray(p, p + 4));
  42825. var offset = getLong(data, p + 8);
  42826. var length = getLong(data, p + 12);
  42827. switch (tag) {
  42828. case 'cmap':
  42829. cmap = parseCmap(data, offset, offset + length);
  42830. break;
  42831. case 'glyf':
  42832. glyf = data.subarray(offset, offset + length);
  42833. break;
  42834. case 'loca':
  42835. loca = data.subarray(offset, offset + length);
  42836. break;
  42837. case 'head':
  42838. unitsPerEm = getUshort(data, offset + 18);
  42839. indexToLocFormat = getUshort(data, offset + 50);
  42840. break;
  42841. case 'CFF ':
  42842. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  42843. break;
  42844. }
  42845. }
  42846. if (glyf) {
  42847. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  42848. 1 / unitsPerEm,
  42849. 0,
  42850. 0,
  42851. 1 / unitsPerEm,
  42852. 0,
  42853. 0
  42854. ];
  42855. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  42856. }
  42857. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  42858. }
  42859. };
  42860. }();
  42861. exports.FontRendererFactory = FontRendererFactory;
  42862. /***/ }),
  42863. /* 33 */
  42864. /***/ (function(module, exports, __w_pdfjs_require__) {
  42865. "use strict";
  42866. var sharedUtil = __w_pdfjs_require__(0);
  42867. var corePrimitives = __w_pdfjs_require__(1);
  42868. var coreStream = __w_pdfjs_require__(2);
  42869. var coreGlyphList = __w_pdfjs_require__(8);
  42870. var coreFontRenderer = __w_pdfjs_require__(32);
  42871. var coreEncodings = __w_pdfjs_require__(5);
  42872. var coreStandardFonts = __w_pdfjs_require__(21);
  42873. var coreUnicode = __w_pdfjs_require__(22);
  42874. var coreType1Parser = __w_pdfjs_require__(43);
  42875. var coreCFFParser = __w_pdfjs_require__(15);
  42876. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42877. var FontType = sharedUtil.FontType;
  42878. var assert = sharedUtil.assert;
  42879. var bytesToString = sharedUtil.bytesToString;
  42880. var error = sharedUtil.error;
  42881. var info = sharedUtil.info;
  42882. var isArray = sharedUtil.isArray;
  42883. var isInt = sharedUtil.isInt;
  42884. var isNum = sharedUtil.isNum;
  42885. var readUint32 = sharedUtil.readUint32;
  42886. var shadow = sharedUtil.shadow;
  42887. var string32 = sharedUtil.string32;
  42888. var warn = sharedUtil.warn;
  42889. var MissingDataException = sharedUtil.MissingDataException;
  42890. var isSpace = sharedUtil.isSpace;
  42891. var Stream = coreStream.Stream;
  42892. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42893. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42894. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42895. var StandardEncoding = coreEncodings.StandardEncoding;
  42896. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42897. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42898. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42899. var getEncoding = coreEncodings.getEncoding;
  42900. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42901. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42902. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42903. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42904. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42905. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42906. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42907. var Type1Parser = coreType1Parser.Type1Parser;
  42908. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42909. var CFFParser = coreCFFParser.CFFParser;
  42910. var CFFCompiler = coreCFFParser.CFFCompiler;
  42911. var CFF = coreCFFParser.CFF;
  42912. var CFFHeader = coreCFFParser.CFFHeader;
  42913. var CFFTopDict = coreCFFParser.CFFTopDict;
  42914. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42915. var CFFStrings = coreCFFParser.CFFStrings;
  42916. var CFFIndex = coreCFFParser.CFFIndex;
  42917. var CFFCharset = coreCFFParser.CFFCharset;
  42918. var PRIVATE_USE_OFFSET_START = 0xE000;
  42919. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42920. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42921. var PDF_GLYPH_SPACE_UNITS = 1000;
  42922. var SEAC_ANALYSIS_ENABLED = false;
  42923. var FontFlags = {
  42924. FixedPitch: 1,
  42925. Serif: 2,
  42926. Symbolic: 4,
  42927. Script: 8,
  42928. Nonsymbolic: 32,
  42929. Italic: 64,
  42930. AllCap: 65536,
  42931. SmallCap: 131072,
  42932. ForceBold: 262144
  42933. };
  42934. var MacStandardGlyphOrdering = [
  42935. '.notdef',
  42936. '.null',
  42937. 'nonmarkingreturn',
  42938. 'space',
  42939. 'exclam',
  42940. 'quotedbl',
  42941. 'numbersign',
  42942. 'dollar',
  42943. 'percent',
  42944. 'ampersand',
  42945. 'quotesingle',
  42946. 'parenleft',
  42947. 'parenright',
  42948. 'asterisk',
  42949. 'plus',
  42950. 'comma',
  42951. 'hyphen',
  42952. 'period',
  42953. 'slash',
  42954. 'zero',
  42955. 'one',
  42956. 'two',
  42957. 'three',
  42958. 'four',
  42959. 'five',
  42960. 'six',
  42961. 'seven',
  42962. 'eight',
  42963. 'nine',
  42964. 'colon',
  42965. 'semicolon',
  42966. 'less',
  42967. 'equal',
  42968. 'greater',
  42969. 'question',
  42970. 'at',
  42971. 'A',
  42972. 'B',
  42973. 'C',
  42974. 'D',
  42975. 'E',
  42976. 'F',
  42977. 'G',
  42978. 'H',
  42979. 'I',
  42980. 'J',
  42981. 'K',
  42982. 'L',
  42983. 'M',
  42984. 'N',
  42985. 'O',
  42986. 'P',
  42987. 'Q',
  42988. 'R',
  42989. 'S',
  42990. 'T',
  42991. 'U',
  42992. 'V',
  42993. 'W',
  42994. 'X',
  42995. 'Y',
  42996. 'Z',
  42997. 'bracketleft',
  42998. 'backslash',
  42999. 'bracketright',
  43000. 'asciicircum',
  43001. 'underscore',
  43002. 'grave',
  43003. 'a',
  43004. 'b',
  43005. 'c',
  43006. 'd',
  43007. 'e',
  43008. 'f',
  43009. 'g',
  43010. 'h',
  43011. 'i',
  43012. 'j',
  43013. 'k',
  43014. 'l',
  43015. 'm',
  43016. 'n',
  43017. 'o',
  43018. 'p',
  43019. 'q',
  43020. 'r',
  43021. 's',
  43022. 't',
  43023. 'u',
  43024. 'v',
  43025. 'w',
  43026. 'x',
  43027. 'y',
  43028. 'z',
  43029. 'braceleft',
  43030. 'bar',
  43031. 'braceright',
  43032. 'asciitilde',
  43033. 'Adieresis',
  43034. 'Aring',
  43035. 'Ccedilla',
  43036. 'Eacute',
  43037. 'Ntilde',
  43038. 'Odieresis',
  43039. 'Udieresis',
  43040. 'aacute',
  43041. 'agrave',
  43042. 'acircumflex',
  43043. 'adieresis',
  43044. 'atilde',
  43045. 'aring',
  43046. 'ccedilla',
  43047. 'eacute',
  43048. 'egrave',
  43049. 'ecircumflex',
  43050. 'edieresis',
  43051. 'iacute',
  43052. 'igrave',
  43053. 'icircumflex',
  43054. 'idieresis',
  43055. 'ntilde',
  43056. 'oacute',
  43057. 'ograve',
  43058. 'ocircumflex',
  43059. 'odieresis',
  43060. 'otilde',
  43061. 'uacute',
  43062. 'ugrave',
  43063. 'ucircumflex',
  43064. 'udieresis',
  43065. 'dagger',
  43066. 'degree',
  43067. 'cent',
  43068. 'sterling',
  43069. 'section',
  43070. 'bullet',
  43071. 'paragraph',
  43072. 'germandbls',
  43073. 'registered',
  43074. 'copyright',
  43075. 'trademark',
  43076. 'acute',
  43077. 'dieresis',
  43078. 'notequal',
  43079. 'AE',
  43080. 'Oslash',
  43081. 'infinity',
  43082. 'plusminus',
  43083. 'lessequal',
  43084. 'greaterequal',
  43085. 'yen',
  43086. 'mu',
  43087. 'partialdiff',
  43088. 'summation',
  43089. 'product',
  43090. 'pi',
  43091. 'integral',
  43092. 'ordfeminine',
  43093. 'ordmasculine',
  43094. 'Omega',
  43095. 'ae',
  43096. 'oslash',
  43097. 'questiondown',
  43098. 'exclamdown',
  43099. 'logicalnot',
  43100. 'radical',
  43101. 'florin',
  43102. 'approxequal',
  43103. 'Delta',
  43104. 'guillemotleft',
  43105. 'guillemotright',
  43106. 'ellipsis',
  43107. 'nonbreakingspace',
  43108. 'Agrave',
  43109. 'Atilde',
  43110. 'Otilde',
  43111. 'OE',
  43112. 'oe',
  43113. 'endash',
  43114. 'emdash',
  43115. 'quotedblleft',
  43116. 'quotedblright',
  43117. 'quoteleft',
  43118. 'quoteright',
  43119. 'divide',
  43120. 'lozenge',
  43121. 'ydieresis',
  43122. 'Ydieresis',
  43123. 'fraction',
  43124. 'currency',
  43125. 'guilsinglleft',
  43126. 'guilsinglright',
  43127. 'fi',
  43128. 'fl',
  43129. 'daggerdbl',
  43130. 'periodcentered',
  43131. 'quotesinglbase',
  43132. 'quotedblbase',
  43133. 'perthousand',
  43134. 'Acircumflex',
  43135. 'Ecircumflex',
  43136. 'Aacute',
  43137. 'Edieresis',
  43138. 'Egrave',
  43139. 'Iacute',
  43140. 'Icircumflex',
  43141. 'Idieresis',
  43142. 'Igrave',
  43143. 'Oacute',
  43144. 'Ocircumflex',
  43145. 'apple',
  43146. 'Ograve',
  43147. 'Uacute',
  43148. 'Ucircumflex',
  43149. 'Ugrave',
  43150. 'dotlessi',
  43151. 'circumflex',
  43152. 'tilde',
  43153. 'macron',
  43154. 'breve',
  43155. 'dotaccent',
  43156. 'ring',
  43157. 'cedilla',
  43158. 'hungarumlaut',
  43159. 'ogonek',
  43160. 'caron',
  43161. 'Lslash',
  43162. 'lslash',
  43163. 'Scaron',
  43164. 'scaron',
  43165. 'Zcaron',
  43166. 'zcaron',
  43167. 'brokenbar',
  43168. 'Eth',
  43169. 'eth',
  43170. 'Yacute',
  43171. 'yacute',
  43172. 'Thorn',
  43173. 'thorn',
  43174. 'minus',
  43175. 'multiply',
  43176. 'onesuperior',
  43177. 'twosuperior',
  43178. 'threesuperior',
  43179. 'onehalf',
  43180. 'onequarter',
  43181. 'threequarters',
  43182. 'franc',
  43183. 'Gbreve',
  43184. 'gbreve',
  43185. 'Idotaccent',
  43186. 'Scedilla',
  43187. 'scedilla',
  43188. 'Cacute',
  43189. 'cacute',
  43190. 'Ccaron',
  43191. 'ccaron',
  43192. 'dcroat'
  43193. ];
  43194. function adjustWidths(properties) {
  43195. if (!properties.fontMatrix) {
  43196. return;
  43197. }
  43198. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  43199. return;
  43200. }
  43201. var scale = 0.001 / properties.fontMatrix[0];
  43202. var glyphsWidths = properties.widths;
  43203. for (var glyph in glyphsWidths) {
  43204. glyphsWidths[glyph] *= scale;
  43205. }
  43206. properties.defaultWidth *= scale;
  43207. }
  43208. function adjustToUnicode(properties, builtInEncoding) {
  43209. if (properties.hasIncludedToUnicodeMap) {
  43210. return;
  43211. }
  43212. if (properties.hasEncoding) {
  43213. return;
  43214. }
  43215. if (builtInEncoding === properties.defaultEncoding) {
  43216. return;
  43217. }
  43218. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  43219. return;
  43220. }
  43221. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  43222. for (var charCode in builtInEncoding) {
  43223. var glyphName = builtInEncoding[charCode];
  43224. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43225. if (unicode !== -1) {
  43226. toUnicode[charCode] = String.fromCharCode(unicode);
  43227. }
  43228. }
  43229. properties.toUnicode.amend(toUnicode);
  43230. }
  43231. function getFontType(type, subtype) {
  43232. switch (type) {
  43233. case 'Type1':
  43234. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  43235. case 'CIDFontType0':
  43236. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  43237. case 'OpenType':
  43238. return FontType.OPENTYPE;
  43239. case 'TrueType':
  43240. return FontType.TRUETYPE;
  43241. case 'CIDFontType2':
  43242. return FontType.CIDFONTTYPE2;
  43243. case 'MMType1':
  43244. return FontType.MMTYPE1;
  43245. case 'Type0':
  43246. return FontType.TYPE0;
  43247. default:
  43248. return FontType.UNKNOWN;
  43249. }
  43250. }
  43251. function recoverGlyphName(name, glyphsUnicodeMap) {
  43252. if (glyphsUnicodeMap[name] !== undefined) {
  43253. return name;
  43254. }
  43255. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  43256. if (unicode !== -1) {
  43257. for (var key in glyphsUnicodeMap) {
  43258. if (glyphsUnicodeMap[key] === unicode) {
  43259. return key;
  43260. }
  43261. }
  43262. }
  43263. info('Unable to recover a standard glyph name for: ' + name);
  43264. return name;
  43265. }
  43266. var Glyph = function GlyphClosure() {
  43267. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43268. this.fontChar = fontChar;
  43269. this.unicode = unicode;
  43270. this.accent = accent;
  43271. this.width = width;
  43272. this.vmetric = vmetric;
  43273. this.operatorListId = operatorListId;
  43274. this.isSpace = isSpace;
  43275. this.isInFont = isInFont;
  43276. }
  43277. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43278. 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;
  43279. };
  43280. return Glyph;
  43281. }();
  43282. var ToUnicodeMap = function ToUnicodeMapClosure() {
  43283. function ToUnicodeMap(cmap) {
  43284. this._map = cmap;
  43285. }
  43286. ToUnicodeMap.prototype = {
  43287. get length() {
  43288. return this._map.length;
  43289. },
  43290. forEach: function (callback) {
  43291. for (var charCode in this._map) {
  43292. callback(charCode, this._map[charCode].charCodeAt(0));
  43293. }
  43294. },
  43295. has: function (i) {
  43296. return this._map[i] !== undefined;
  43297. },
  43298. get: function (i) {
  43299. return this._map[i];
  43300. },
  43301. charCodeOf: function (v) {
  43302. return this._map.indexOf(v);
  43303. },
  43304. amend: function (map) {
  43305. for (var charCode in map) {
  43306. this._map[charCode] = map[charCode];
  43307. }
  43308. }
  43309. };
  43310. return ToUnicodeMap;
  43311. }();
  43312. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  43313. function IdentityToUnicodeMap(firstChar, lastChar) {
  43314. this.firstChar = firstChar;
  43315. this.lastChar = lastChar;
  43316. }
  43317. IdentityToUnicodeMap.prototype = {
  43318. get length() {
  43319. return this.lastChar + 1 - this.firstChar;
  43320. },
  43321. forEach: function (callback) {
  43322. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  43323. callback(i, i);
  43324. }
  43325. },
  43326. has: function (i) {
  43327. return this.firstChar <= i && i <= this.lastChar;
  43328. },
  43329. get: function (i) {
  43330. if (this.firstChar <= i && i <= this.lastChar) {
  43331. return String.fromCharCode(i);
  43332. }
  43333. return undefined;
  43334. },
  43335. charCodeOf: function (v) {
  43336. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  43337. },
  43338. amend: function (map) {
  43339. error('Should not call amend()');
  43340. }
  43341. };
  43342. return IdentityToUnicodeMap;
  43343. }();
  43344. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  43345. function writeInt16(dest, offset, num) {
  43346. dest[offset] = num >> 8 & 0xFF;
  43347. dest[offset + 1] = num & 0xFF;
  43348. }
  43349. function writeInt32(dest, offset, num) {
  43350. dest[offset] = num >> 24 & 0xFF;
  43351. dest[offset + 1] = num >> 16 & 0xFF;
  43352. dest[offset + 2] = num >> 8 & 0xFF;
  43353. dest[offset + 3] = num & 0xFF;
  43354. }
  43355. function writeData(dest, offset, data) {
  43356. var i, ii;
  43357. if (data instanceof Uint8Array) {
  43358. dest.set(data, offset);
  43359. } else if (typeof data === 'string') {
  43360. for (i = 0, ii = data.length; i < ii; i++) {
  43361. dest[offset++] = data.charCodeAt(i) & 0xFF;
  43362. }
  43363. } else {
  43364. for (i = 0, ii = data.length; i < ii; i++) {
  43365. dest[offset++] = data[i] & 0xFF;
  43366. }
  43367. }
  43368. }
  43369. function OpenTypeFileBuilder(sfnt) {
  43370. this.sfnt = sfnt;
  43371. this.tables = Object.create(null);
  43372. }
  43373. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  43374. var maxPower2 = 1, log2 = 0;
  43375. while ((maxPower2 ^ entriesCount) > maxPower2) {
  43376. maxPower2 <<= 1;
  43377. log2++;
  43378. }
  43379. var searchRange = maxPower2 * entrySize;
  43380. return {
  43381. range: searchRange,
  43382. entry: log2,
  43383. rangeShift: entrySize * entriesCount - searchRange
  43384. };
  43385. };
  43386. var OTF_HEADER_SIZE = 12;
  43387. var OTF_TABLE_ENTRY_SIZE = 16;
  43388. OpenTypeFileBuilder.prototype = {
  43389. toArray: function OpenTypeFileBuilder_toArray() {
  43390. var sfnt = this.sfnt;
  43391. var tables = this.tables;
  43392. var tablesNames = Object.keys(tables);
  43393. tablesNames.sort();
  43394. var numTables = tablesNames.length;
  43395. var i, j, jj, table, tableName;
  43396. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  43397. var tableOffsets = [offset];
  43398. for (i = 0; i < numTables; i++) {
  43399. table = tables[tablesNames[i]];
  43400. var paddedLength = (table.length + 3 & ~3) >>> 0;
  43401. offset += paddedLength;
  43402. tableOffsets.push(offset);
  43403. }
  43404. var file = new Uint8Array(offset);
  43405. for (i = 0; i < numTables; i++) {
  43406. table = tables[tablesNames[i]];
  43407. writeData(file, tableOffsets[i], table);
  43408. }
  43409. if (sfnt === 'true') {
  43410. sfnt = string32(0x00010000);
  43411. }
  43412. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43413. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43414. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43415. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43416. writeInt16(file, 4, numTables);
  43417. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43418. writeInt16(file, 6, searchParams.range);
  43419. writeInt16(file, 8, searchParams.entry);
  43420. writeInt16(file, 10, searchParams.rangeShift);
  43421. offset = OTF_HEADER_SIZE;
  43422. for (i = 0; i < numTables; i++) {
  43423. tableName = tablesNames[i];
  43424. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43425. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43426. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43427. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43428. var checksum = 0;
  43429. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43430. var quad = readUint32(file, j);
  43431. checksum = checksum + quad >>> 0;
  43432. }
  43433. writeInt32(file, offset + 4, checksum);
  43434. writeInt32(file, offset + 8, tableOffsets[i]);
  43435. writeInt32(file, offset + 12, tables[tableName].length);
  43436. offset += OTF_TABLE_ENTRY_SIZE;
  43437. }
  43438. return file;
  43439. },
  43440. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43441. if (tag in this.tables) {
  43442. throw new Error('Table ' + tag + ' already exists');
  43443. }
  43444. this.tables[tag] = data;
  43445. }
  43446. };
  43447. return OpenTypeFileBuilder;
  43448. }();
  43449. var ProblematicCharRanges = new Int32Array([
  43450. 0x0000,
  43451. 0x0020,
  43452. 0x007F,
  43453. 0x00A1,
  43454. 0x00AD,
  43455. 0x00AE,
  43456. 0x0600,
  43457. 0x0780,
  43458. 0x08A0,
  43459. 0x10A0,
  43460. 0x1780,
  43461. 0x1800,
  43462. 0x1C00,
  43463. 0x1C50,
  43464. 0x2000,
  43465. 0x2010,
  43466. 0x2011,
  43467. 0x2012,
  43468. 0x2028,
  43469. 0x2030,
  43470. 0x205F,
  43471. 0x2070,
  43472. 0x25CC,
  43473. 0x25CD,
  43474. 0x3000,
  43475. 0x3001,
  43476. 0xAA60,
  43477. 0xAA80,
  43478. 0xFFF0,
  43479. 0x10000
  43480. ]);
  43481. var Font = function FontClosure() {
  43482. function Font(name, file, properties) {
  43483. var charCode, glyphName, unicode;
  43484. this.name = name;
  43485. this.loadedName = properties.loadedName;
  43486. this.isType3Font = properties.isType3Font;
  43487. this.sizes = [];
  43488. this.missingFile = false;
  43489. this.glyphCache = Object.create(null);
  43490. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43491. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43492. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43493. var type = properties.type;
  43494. var subtype = properties.subtype;
  43495. this.type = type;
  43496. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43497. this.differences = properties.differences;
  43498. this.widths = properties.widths;
  43499. this.defaultWidth = properties.defaultWidth;
  43500. this.composite = properties.composite;
  43501. this.wideChars = properties.wideChars;
  43502. this.cMap = properties.cMap;
  43503. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43504. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43505. this.fontMatrix = properties.fontMatrix;
  43506. this.bbox = properties.bbox;
  43507. this.toUnicode = properties.toUnicode;
  43508. this.toFontChar = [];
  43509. if (properties.type === 'Type3') {
  43510. for (charCode = 0; charCode < 256; charCode++) {
  43511. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43512. }
  43513. this.fontType = FontType.TYPE3;
  43514. return;
  43515. }
  43516. this.cidEncoding = properties.cidEncoding;
  43517. this.vertical = properties.vertical;
  43518. if (this.vertical) {
  43519. this.vmetrics = properties.vmetrics;
  43520. this.defaultVMetrics = properties.defaultVMetrics;
  43521. }
  43522. var glyphsUnicodeMap;
  43523. if (!file || file.isEmpty) {
  43524. if (file) {
  43525. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43526. }
  43527. this.missingFile = true;
  43528. var fontName = name.replace(/[,_]/g, '-');
  43529. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43530. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43531. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43532. this.bold = fontName.search(/bold/gi) !== -1;
  43533. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43534. this.black = name.search(/Black/g) !== -1;
  43535. this.remeasure = Object.keys(this.widths).length > 0;
  43536. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43537. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43538. var map = [];
  43539. for (charCode in GlyphMapForStandardFonts) {
  43540. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43541. }
  43542. if (/Arial-?Black/i.test(name)) {
  43543. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43544. for (charCode in SupplementalGlyphMapForArialBlack) {
  43545. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43546. }
  43547. }
  43548. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43549. if (!isIdentityUnicode) {
  43550. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43551. map[+charCode] = unicodeCharCode;
  43552. });
  43553. }
  43554. this.toFontChar = map;
  43555. this.toUnicode = new ToUnicodeMap(map);
  43556. } else if (/Symbol/i.test(fontName)) {
  43557. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43558. } else if (/Dingbats/i.test(fontName)) {
  43559. if (/Wingdings/i.test(name)) {
  43560. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43561. }
  43562. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43563. } else if (isStandardFont) {
  43564. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43565. } else {
  43566. glyphsUnicodeMap = getGlyphsUnicode();
  43567. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43568. if (!this.composite) {
  43569. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43570. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43571. if (unicode !== -1) {
  43572. unicodeCharCode = unicode;
  43573. }
  43574. }
  43575. this.toFontChar[charCode] = unicodeCharCode;
  43576. }.bind(this));
  43577. }
  43578. this.loadedName = fontName.split('-')[0];
  43579. this.loading = false;
  43580. this.fontType = getFontType(type, subtype);
  43581. return;
  43582. }
  43583. if (subtype === 'Type1C') {
  43584. if (type !== 'Type1' && type !== 'MMType1') {
  43585. if (isTrueTypeFile(file)) {
  43586. subtype = 'TrueType';
  43587. } else {
  43588. type = 'Type1';
  43589. }
  43590. } else if (isOpenTypeFile(file)) {
  43591. type = subtype = 'OpenType';
  43592. }
  43593. }
  43594. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43595. type = 'CIDFontType0';
  43596. }
  43597. if (subtype === 'OpenType') {
  43598. type = 'OpenType';
  43599. }
  43600. if (type === 'CIDFontType0') {
  43601. if (isType1File(file)) {
  43602. subtype = 'CIDFontType0';
  43603. } else if (isOpenTypeFile(file)) {
  43604. type = subtype = 'OpenType';
  43605. } else {
  43606. subtype = 'CIDFontType0C';
  43607. }
  43608. }
  43609. var data;
  43610. switch (type) {
  43611. case 'MMType1':
  43612. info('MMType1 font (' + name + '), falling back to Type1.');
  43613. case 'Type1':
  43614. case 'CIDFontType0':
  43615. this.mimetype = 'font/opentype';
  43616. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43617. adjustWidths(properties);
  43618. data = this.convert(name, cff, properties);
  43619. break;
  43620. case 'OpenType':
  43621. case 'TrueType':
  43622. case 'CIDFontType2':
  43623. this.mimetype = 'font/opentype';
  43624. data = this.checkAndRepair(name, file, properties);
  43625. if (this.isOpenType) {
  43626. adjustWidths(properties);
  43627. type = 'OpenType';
  43628. }
  43629. break;
  43630. default:
  43631. error('Font ' + type + ' is not supported');
  43632. break;
  43633. }
  43634. this.data = data;
  43635. this.fontType = getFontType(type, subtype);
  43636. this.fontMatrix = properties.fontMatrix;
  43637. this.widths = properties.widths;
  43638. this.defaultWidth = properties.defaultWidth;
  43639. this.toUnicode = properties.toUnicode;
  43640. this.encoding = properties.baseEncoding;
  43641. this.seacMap = properties.seacMap;
  43642. this.loading = true;
  43643. }
  43644. Font.getFontID = function () {
  43645. var ID = 1;
  43646. return function Font_getFontID() {
  43647. return String(ID++);
  43648. };
  43649. }();
  43650. function int16(b0, b1) {
  43651. return (b0 << 8) + b1;
  43652. }
  43653. function signedInt16(b0, b1) {
  43654. var value = (b0 << 8) + b1;
  43655. return value & 1 << 15 ? value - 0x10000 : value;
  43656. }
  43657. function int32(b0, b1, b2, b3) {
  43658. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43659. }
  43660. function string16(value) {
  43661. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43662. }
  43663. function safeString16(value) {
  43664. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43665. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43666. }
  43667. function isTrueTypeFile(file) {
  43668. var header = file.peekBytes(4);
  43669. return readUint32(header, 0) === 0x00010000;
  43670. }
  43671. function isOpenTypeFile(file) {
  43672. var header = file.peekBytes(4);
  43673. return bytesToString(header) === 'OTTO';
  43674. }
  43675. function isType1File(file) {
  43676. var header = file.peekBytes(2);
  43677. if (header[0] === 0x25 && header[1] === 0x21) {
  43678. return true;
  43679. }
  43680. if (header[0] === 0x80 && header[1] === 0x01) {
  43681. return true;
  43682. }
  43683. return false;
  43684. }
  43685. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43686. var toFontChar = [], unicode;
  43687. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43688. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43689. if (unicode !== -1) {
  43690. toFontChar[i] = unicode;
  43691. }
  43692. }
  43693. for (var charCode in differences) {
  43694. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43695. if (unicode !== -1) {
  43696. toFontChar[+charCode] = unicode;
  43697. }
  43698. }
  43699. return toFontChar;
  43700. }
  43701. function isProblematicUnicodeLocation(code) {
  43702. var i = 0, j = ProblematicCharRanges.length - 1;
  43703. while (i < j) {
  43704. var c = i + j + 1 >> 1;
  43705. if (code < ProblematicCharRanges[c]) {
  43706. j = c - 1;
  43707. } else {
  43708. i = c;
  43709. }
  43710. }
  43711. return !(i & 1);
  43712. }
  43713. function adjustMapping(charCodeToGlyphId, properties) {
  43714. var toUnicode = properties.toUnicode;
  43715. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43716. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43717. var newMap = Object.create(null);
  43718. var toFontChar = [];
  43719. var usedFontCharCodes = [];
  43720. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43721. for (var originalCharCode in charCodeToGlyphId) {
  43722. originalCharCode |= 0;
  43723. var glyphId = charCodeToGlyphId[originalCharCode];
  43724. var fontCharCode = originalCharCode;
  43725. var hasUnicodeValue = false;
  43726. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43727. hasUnicodeValue = true;
  43728. var unicode = toUnicode.get(fontCharCode);
  43729. if (unicode.length === 1) {
  43730. fontCharCode = unicode.charCodeAt(0);
  43731. }
  43732. }
  43733. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43734. do {
  43735. fontCharCode = nextAvailableFontCharCode++;
  43736. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43737. fontCharCode = 0xF020;
  43738. nextAvailableFontCharCode = fontCharCode + 1;
  43739. }
  43740. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43741. }
  43742. newMap[fontCharCode] = glyphId;
  43743. toFontChar[originalCharCode] = fontCharCode;
  43744. usedFontCharCodes[fontCharCode] = true;
  43745. }
  43746. return {
  43747. toFontChar: toFontChar,
  43748. charCodeToGlyphId: newMap,
  43749. nextAvailableFontCharCode: nextAvailableFontCharCode
  43750. };
  43751. }
  43752. function getRanges(glyphs, numGlyphs) {
  43753. var codes = [];
  43754. for (var charCode in glyphs) {
  43755. if (glyphs[charCode] >= numGlyphs) {
  43756. continue;
  43757. }
  43758. codes.push({
  43759. fontCharCode: charCode | 0,
  43760. glyphId: glyphs[charCode]
  43761. });
  43762. }
  43763. codes.sort(function fontGetRangesSort(a, b) {
  43764. return a.fontCharCode - b.fontCharCode;
  43765. });
  43766. var ranges = [];
  43767. var length = codes.length;
  43768. for (var n = 0; n < length;) {
  43769. var start = codes[n].fontCharCode;
  43770. var codeIndices = [codes[n].glyphId];
  43771. ++n;
  43772. var end = start;
  43773. while (n < length && end + 1 === codes[n].fontCharCode) {
  43774. codeIndices.push(codes[n].glyphId);
  43775. ++end;
  43776. ++n;
  43777. if (end === 0xFFFF) {
  43778. break;
  43779. }
  43780. }
  43781. ranges.push([
  43782. start,
  43783. end,
  43784. codeIndices
  43785. ]);
  43786. }
  43787. return ranges;
  43788. }
  43789. function createCmapTable(glyphs, numGlyphs) {
  43790. var ranges = getRanges(glyphs, numGlyphs);
  43791. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43792. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43793. var i, ii, j, jj;
  43794. for (i = ranges.length - 1; i >= 0; --i) {
  43795. if (ranges[i][0] <= 0xFFFF) {
  43796. break;
  43797. }
  43798. }
  43799. var bmpLength = i + 1;
  43800. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43801. ranges[i][1] = 0xFFFE;
  43802. }
  43803. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43804. var segCount = bmpLength + trailingRangesCount;
  43805. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43806. var startCount = '';
  43807. var endCount = '';
  43808. var idDeltas = '';
  43809. var idRangeOffsets = '';
  43810. var glyphsIds = '';
  43811. var bias = 0;
  43812. var range, start, end, codes;
  43813. for (i = 0, ii = bmpLength; i < ii; i++) {
  43814. range = ranges[i];
  43815. start = range[0];
  43816. end = range[1];
  43817. startCount += string16(start);
  43818. endCount += string16(end);
  43819. codes = range[2];
  43820. var contiguous = true;
  43821. for (j = 1, jj = codes.length; j < jj; ++j) {
  43822. if (codes[j] !== codes[j - 1] + 1) {
  43823. contiguous = false;
  43824. break;
  43825. }
  43826. }
  43827. if (!contiguous) {
  43828. var offset = (segCount - i) * 2 + bias * 2;
  43829. bias += end - start + 1;
  43830. idDeltas += string16(0);
  43831. idRangeOffsets += string16(offset);
  43832. for (j = 0, jj = codes.length; j < jj; ++j) {
  43833. glyphsIds += string16(codes[j]);
  43834. }
  43835. } else {
  43836. var startCode = codes[0];
  43837. idDeltas += string16(startCode - start & 0xFFFF);
  43838. idRangeOffsets += string16(0);
  43839. }
  43840. }
  43841. if (trailingRangesCount > 0) {
  43842. endCount += '\xFF\xFF';
  43843. startCount += '\xFF\xFF';
  43844. idDeltas += '\x00\x01';
  43845. idRangeOffsets += '\x00\x00';
  43846. }
  43847. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43848. var format31012 = '';
  43849. var header31012 = '';
  43850. if (numTables > 1) {
  43851. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43852. format31012 = '';
  43853. for (i = 0, ii = ranges.length; i < ii; i++) {
  43854. range = ranges[i];
  43855. start = range[0];
  43856. codes = range[2];
  43857. var code = codes[0];
  43858. for (j = 1, jj = codes.length; j < jj; ++j) {
  43859. if (codes[j] !== codes[j - 1] + 1) {
  43860. end = range[0] + j - 1;
  43861. format31012 += string32(start) + string32(end) + string32(code);
  43862. start = end + 1;
  43863. code = codes[j];
  43864. }
  43865. }
  43866. format31012 += string32(start) + string32(range[1]) + string32(code);
  43867. }
  43868. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43869. }
  43870. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43871. }
  43872. function validateOS2Table(os2) {
  43873. var stream = new Stream(os2.data);
  43874. var version = stream.getUint16();
  43875. stream.getBytes(60);
  43876. var selection = stream.getUint16();
  43877. if (version < 4 && selection & 0x0300) {
  43878. return false;
  43879. }
  43880. var firstChar = stream.getUint16();
  43881. var lastChar = stream.getUint16();
  43882. if (firstChar > lastChar) {
  43883. return false;
  43884. }
  43885. stream.getBytes(6);
  43886. var usWinAscent = stream.getUint16();
  43887. if (usWinAscent === 0) {
  43888. return false;
  43889. }
  43890. os2.data[8] = os2.data[9] = 0;
  43891. return true;
  43892. }
  43893. function createOS2Table(properties, charstrings, override) {
  43894. override = override || {
  43895. unitsPerEm: 0,
  43896. yMax: 0,
  43897. yMin: 0,
  43898. ascent: 0,
  43899. descent: 0
  43900. };
  43901. var ulUnicodeRange1 = 0;
  43902. var ulUnicodeRange2 = 0;
  43903. var ulUnicodeRange3 = 0;
  43904. var ulUnicodeRange4 = 0;
  43905. var firstCharIndex = null;
  43906. var lastCharIndex = 0;
  43907. if (charstrings) {
  43908. for (var code in charstrings) {
  43909. code |= 0;
  43910. if (firstCharIndex > code || !firstCharIndex) {
  43911. firstCharIndex = code;
  43912. }
  43913. if (lastCharIndex < code) {
  43914. lastCharIndex = code;
  43915. }
  43916. var position = getUnicodeRangeFor(code);
  43917. if (position < 32) {
  43918. ulUnicodeRange1 |= 1 << position;
  43919. } else if (position < 64) {
  43920. ulUnicodeRange2 |= 1 << position - 32;
  43921. } else if (position < 96) {
  43922. ulUnicodeRange3 |= 1 << position - 64;
  43923. } else if (position < 123) {
  43924. ulUnicodeRange4 |= 1 << position - 96;
  43925. } else {
  43926. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43927. }
  43928. }
  43929. } else {
  43930. firstCharIndex = 0;
  43931. lastCharIndex = 255;
  43932. }
  43933. var bbox = properties.bbox || [
  43934. 0,
  43935. 0,
  43936. 0,
  43937. 0
  43938. ];
  43939. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43940. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43941. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43942. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43943. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43944. typoDescent = -typoDescent;
  43945. }
  43946. var winAscent = override.yMax || typoAscent;
  43947. var winDescent = -override.yMin || -typoDescent;
  43948. 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';
  43949. }
  43950. function createPostTable(properties) {
  43951. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43952. 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';
  43953. }
  43954. function createNameTable(name, proto) {
  43955. if (!proto) {
  43956. proto = [
  43957. [],
  43958. []
  43959. ];
  43960. }
  43961. var strings = [
  43962. proto[0][0] || 'Original licence',
  43963. proto[0][1] || name,
  43964. proto[0][2] || 'Unknown',
  43965. proto[0][3] || 'uniqueID',
  43966. proto[0][4] || name,
  43967. proto[0][5] || 'Version 0.11',
  43968. proto[0][6] || '',
  43969. proto[0][7] || 'Unknown',
  43970. proto[0][8] || 'Unknown',
  43971. proto[0][9] || 'Unknown'
  43972. ];
  43973. var stringsUnicode = [];
  43974. var i, ii, j, jj, str;
  43975. for (i = 0, ii = strings.length; i < ii; i++) {
  43976. str = proto[1][i] || strings[i];
  43977. var strBufUnicode = [];
  43978. for (j = 0, jj = str.length; j < jj; j++) {
  43979. strBufUnicode.push(string16(str.charCodeAt(j)));
  43980. }
  43981. stringsUnicode.push(strBufUnicode.join(''));
  43982. }
  43983. var names = [
  43984. strings,
  43985. stringsUnicode
  43986. ];
  43987. var platforms = [
  43988. '\x00\x01',
  43989. '\x00\x03'
  43990. ];
  43991. var encodings = [
  43992. '\x00\x00',
  43993. '\x00\x01'
  43994. ];
  43995. var languages = [
  43996. '\x00\x00',
  43997. '\x04\x09'
  43998. ];
  43999. var namesRecordCount = strings.length * platforms.length;
  44000. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44001. var strOffset = 0;
  44002. for (i = 0, ii = platforms.length; i < ii; i++) {
  44003. var strs = names[i];
  44004. for (j = 0, jj = strs.length; j < jj; j++) {
  44005. str = strs[j];
  44006. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44007. nameTable += nameRecord;
  44008. strOffset += str.length;
  44009. }
  44010. }
  44011. nameTable += strings.join('') + stringsUnicode.join('');
  44012. return nameTable;
  44013. }
  44014. Font.prototype = {
  44015. name: null,
  44016. font: null,
  44017. mimetype: null,
  44018. encoding: null,
  44019. get renderer() {
  44020. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44021. return shadow(this, 'renderer', renderer);
  44022. },
  44023. exportData: function Font_exportData() {
  44024. var data = {};
  44025. for (var i in this) {
  44026. if (this.hasOwnProperty(i)) {
  44027. data[i] = this[i];
  44028. }
  44029. }
  44030. return data;
  44031. },
  44032. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44033. function readTableEntry(file) {
  44034. var tag = bytesToString(file.getBytes(4));
  44035. var checksum = file.getInt32() >>> 0;
  44036. var offset = file.getInt32() >>> 0;
  44037. var length = file.getInt32() >>> 0;
  44038. var previousPosition = file.pos;
  44039. file.pos = file.start ? file.start : 0;
  44040. file.skip(offset);
  44041. var data = file.getBytes(length);
  44042. file.pos = previousPosition;
  44043. if (tag === 'head') {
  44044. data[8] = data[9] = data[10] = data[11] = 0;
  44045. data[17] |= 0x20;
  44046. }
  44047. return {
  44048. tag: tag,
  44049. checksum: checksum,
  44050. length: length,
  44051. offset: offset,
  44052. data: data
  44053. };
  44054. }
  44055. function readOpenTypeHeader(ttf) {
  44056. return {
  44057. version: bytesToString(ttf.getBytes(4)),
  44058. numTables: ttf.getUint16(),
  44059. searchRange: ttf.getUint16(),
  44060. entrySelector: ttf.getUint16(),
  44061. rangeShift: ttf.getUint16()
  44062. };
  44063. }
  44064. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44065. if (!cmap) {
  44066. warn('No cmap table available.');
  44067. return {
  44068. platformId: -1,
  44069. encodingId: -1,
  44070. mappings: [],
  44071. hasShortCmap: false
  44072. };
  44073. }
  44074. var segment;
  44075. var start = (font.start ? font.start : 0) + cmap.offset;
  44076. font.pos = start;
  44077. font.getUint16();
  44078. var numTables = font.getUint16();
  44079. var potentialTable;
  44080. var canBreak = false;
  44081. for (var i = 0; i < numTables; i++) {
  44082. var platformId = font.getUint16();
  44083. var encodingId = font.getUint16();
  44084. var offset = font.getInt32() >>> 0;
  44085. var useTable = false;
  44086. if (platformId === 0 && encodingId === 0) {
  44087. useTable = true;
  44088. } else if (platformId === 1 && encodingId === 0) {
  44089. useTable = true;
  44090. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44091. useTable = true;
  44092. if (!isSymbolicFont) {
  44093. canBreak = true;
  44094. }
  44095. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44096. useTable = true;
  44097. canBreak = true;
  44098. }
  44099. if (useTable) {
  44100. potentialTable = {
  44101. platformId: platformId,
  44102. encodingId: encodingId,
  44103. offset: offset
  44104. };
  44105. }
  44106. if (canBreak) {
  44107. break;
  44108. }
  44109. }
  44110. if (potentialTable) {
  44111. font.pos = start + potentialTable.offset;
  44112. }
  44113. if (!potentialTable || font.peekByte() === -1) {
  44114. warn('Could not find a preferred cmap table.');
  44115. return {
  44116. platformId: -1,
  44117. encodingId: -1,
  44118. mappings: [],
  44119. hasShortCmap: false
  44120. };
  44121. }
  44122. var format = font.getUint16();
  44123. font.getUint16();
  44124. font.getUint16();
  44125. var hasShortCmap = false;
  44126. var mappings = [];
  44127. var j, glyphId;
  44128. if (format === 0) {
  44129. for (j = 0; j < 256; j++) {
  44130. var index = font.getByte();
  44131. if (!index) {
  44132. continue;
  44133. }
  44134. mappings.push({
  44135. charCode: j,
  44136. glyphId: index
  44137. });
  44138. }
  44139. hasShortCmap = true;
  44140. } else if (format === 4) {
  44141. var segCount = font.getUint16() >> 1;
  44142. font.getBytes(6);
  44143. var segIndex, segments = [];
  44144. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44145. segments.push({ end: font.getUint16() });
  44146. }
  44147. font.getUint16();
  44148. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44149. segments[segIndex].start = font.getUint16();
  44150. }
  44151. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44152. segments[segIndex].delta = font.getUint16();
  44153. }
  44154. var offsetsCount = 0;
  44155. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44156. segment = segments[segIndex];
  44157. var rangeOffset = font.getUint16();
  44158. if (!rangeOffset) {
  44159. segment.offsetIndex = -1;
  44160. continue;
  44161. }
  44162. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44163. segment.offsetIndex = offsetIndex;
  44164. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44165. }
  44166. var offsets = [];
  44167. for (j = 0; j < offsetsCount; j++) {
  44168. offsets.push(font.getUint16());
  44169. }
  44170. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44171. segment = segments[segIndex];
  44172. start = segment.start;
  44173. var end = segment.end;
  44174. var delta = segment.delta;
  44175. offsetIndex = segment.offsetIndex;
  44176. for (j = start; j <= end; j++) {
  44177. if (j === 0xFFFF) {
  44178. continue;
  44179. }
  44180. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  44181. glyphId = glyphId + delta & 0xFFFF;
  44182. if (glyphId === 0) {
  44183. continue;
  44184. }
  44185. mappings.push({
  44186. charCode: j,
  44187. glyphId: glyphId
  44188. });
  44189. }
  44190. }
  44191. } else if (format === 6) {
  44192. var firstCode = font.getUint16();
  44193. var entryCount = font.getUint16();
  44194. for (j = 0; j < entryCount; j++) {
  44195. glyphId = font.getUint16();
  44196. var charCode = firstCode + j;
  44197. mappings.push({
  44198. charCode: charCode,
  44199. glyphId: glyphId
  44200. });
  44201. }
  44202. } else {
  44203. warn('cmap table has unsupported format: ' + format);
  44204. return {
  44205. platformId: -1,
  44206. encodingId: -1,
  44207. mappings: [],
  44208. hasShortCmap: false
  44209. };
  44210. }
  44211. mappings.sort(function (a, b) {
  44212. return a.charCode - b.charCode;
  44213. });
  44214. for (i = 1; i < mappings.length; i++) {
  44215. if (mappings[i - 1].charCode === mappings[i].charCode) {
  44216. mappings.splice(i, 1);
  44217. i--;
  44218. }
  44219. }
  44220. return {
  44221. platformId: potentialTable.platformId,
  44222. encodingId: potentialTable.encodingId,
  44223. mappings: mappings,
  44224. hasShortCmap: hasShortCmap
  44225. };
  44226. }
  44227. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  44228. if (!header) {
  44229. if (metrics) {
  44230. metrics.data = null;
  44231. }
  44232. return;
  44233. }
  44234. font.pos = (font.start ? font.start : 0) + header.offset;
  44235. font.pos += header.length - 2;
  44236. var numOfMetrics = font.getUint16();
  44237. if (numOfMetrics > numGlyphs) {
  44238. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  44239. numOfMetrics = numGlyphs;
  44240. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  44241. header.data[35] = numOfMetrics & 0x00ff;
  44242. }
  44243. var numOfSidebearings = numGlyphs - numOfMetrics;
  44244. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  44245. if (numMissing > 0) {
  44246. var entries = new Uint8Array(metrics.length + numMissing * 2);
  44247. entries.set(metrics.data);
  44248. metrics.data = entries;
  44249. }
  44250. }
  44251. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  44252. if (sourceEnd - sourceStart <= 12) {
  44253. return 0;
  44254. }
  44255. var glyf = source.subarray(sourceStart, sourceEnd);
  44256. var contoursCount = glyf[0] << 8 | glyf[1];
  44257. if (contoursCount & 0x8000) {
  44258. dest.set(glyf, destStart);
  44259. return glyf.length;
  44260. }
  44261. var i, j = 10, flagsCount = 0;
  44262. for (i = 0; i < contoursCount; i++) {
  44263. var endPoint = glyf[j] << 8 | glyf[j + 1];
  44264. flagsCount = endPoint + 1;
  44265. j += 2;
  44266. }
  44267. var instructionsStart = j;
  44268. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  44269. j += 2 + instructionsLength;
  44270. var instructionsEnd = j;
  44271. var coordinatesLength = 0;
  44272. for (i = 0; i < flagsCount; i++) {
  44273. var flag = glyf[j++];
  44274. if (flag & 0xC0) {
  44275. glyf[j - 1] = flag & 0x3F;
  44276. }
  44277. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  44278. coordinatesLength += xyLength;
  44279. if (flag & 8) {
  44280. var repeat = glyf[j++];
  44281. i += repeat;
  44282. coordinatesLength += repeat * xyLength;
  44283. }
  44284. }
  44285. if (coordinatesLength === 0) {
  44286. return 0;
  44287. }
  44288. var glyphDataLength = j + coordinatesLength;
  44289. if (glyphDataLength > glyf.length) {
  44290. return 0;
  44291. }
  44292. if (!hintsValid && instructionsLength > 0) {
  44293. dest.set(glyf.subarray(0, instructionsStart), destStart);
  44294. dest.set([
  44295. 0,
  44296. 0
  44297. ], destStart + instructionsStart);
  44298. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  44299. glyphDataLength -= instructionsLength;
  44300. if (glyf.length - glyphDataLength > 3) {
  44301. glyphDataLength = glyphDataLength + 3 & ~3;
  44302. }
  44303. return glyphDataLength;
  44304. }
  44305. if (glyf.length - glyphDataLength > 3) {
  44306. glyphDataLength = glyphDataLength + 3 & ~3;
  44307. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  44308. return glyphDataLength;
  44309. }
  44310. dest.set(glyf, destStart);
  44311. return glyf.length;
  44312. }
  44313. function sanitizeHead(head, numGlyphs, locaLength) {
  44314. var data = head.data;
  44315. var version = int32(data[0], data[1], data[2], data[3]);
  44316. if (version >> 16 !== 1) {
  44317. info('Attempting to fix invalid version in head table: ' + version);
  44318. data[0] = 0;
  44319. data[1] = 1;
  44320. data[2] = 0;
  44321. data[3] = 0;
  44322. }
  44323. var indexToLocFormat = int16(data[50], data[51]);
  44324. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  44325. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  44326. var numGlyphsPlusOne = numGlyphs + 1;
  44327. if (locaLength === numGlyphsPlusOne << 1) {
  44328. data[50] = 0;
  44329. data[51] = 0;
  44330. } else if (locaLength === numGlyphsPlusOne << 2) {
  44331. data[50] = 0;
  44332. data[51] = 1;
  44333. } else {
  44334. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  44335. }
  44336. }
  44337. }
  44338. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  44339. var itemSize, itemDecode, itemEncode;
  44340. if (isGlyphLocationsLong) {
  44341. itemSize = 4;
  44342. itemDecode = function fontItemDecodeLong(data, offset) {
  44343. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  44344. };
  44345. itemEncode = function fontItemEncodeLong(data, offset, value) {
  44346. data[offset] = value >>> 24 & 0xFF;
  44347. data[offset + 1] = value >> 16 & 0xFF;
  44348. data[offset + 2] = value >> 8 & 0xFF;
  44349. data[offset + 3] = value & 0xFF;
  44350. };
  44351. } else {
  44352. itemSize = 2;
  44353. itemDecode = function fontItemDecode(data, offset) {
  44354. return data[offset] << 9 | data[offset + 1] << 1;
  44355. };
  44356. itemEncode = function fontItemEncode(data, offset, value) {
  44357. data[offset] = value >> 9 & 0xFF;
  44358. data[offset + 1] = value >> 1 & 0xFF;
  44359. };
  44360. }
  44361. var locaData = loca.data;
  44362. var locaDataSize = itemSize * (1 + numGlyphs);
  44363. if (locaData.length !== locaDataSize) {
  44364. locaData = new Uint8Array(locaDataSize);
  44365. locaData.set(loca.data.subarray(0, locaDataSize));
  44366. loca.data = locaData;
  44367. }
  44368. var oldGlyfData = glyf.data;
  44369. var oldGlyfDataLength = oldGlyfData.length;
  44370. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  44371. var startOffset = itemDecode(locaData, 0);
  44372. var writeOffset = 0;
  44373. var missingGlyphData = Object.create(null);
  44374. itemEncode(locaData, 0, writeOffset);
  44375. var i, j;
  44376. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44377. var endOffset = itemDecode(locaData, j);
  44378. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  44379. endOffset = oldGlyfDataLength;
  44380. }
  44381. if (endOffset > oldGlyfDataLength) {
  44382. itemEncode(locaData, j, writeOffset);
  44383. startOffset = endOffset;
  44384. continue;
  44385. }
  44386. if (startOffset === endOffset) {
  44387. missingGlyphData[i] = true;
  44388. }
  44389. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  44390. writeOffset += newLength;
  44391. itemEncode(locaData, j, writeOffset);
  44392. startOffset = endOffset;
  44393. }
  44394. if (writeOffset === 0) {
  44395. var simpleGlyph = new Uint8Array([
  44396. 0,
  44397. 1,
  44398. 0,
  44399. 0,
  44400. 0,
  44401. 0,
  44402. 0,
  44403. 0,
  44404. 0,
  44405. 0,
  44406. 0,
  44407. 0,
  44408. 0,
  44409. 0,
  44410. 49,
  44411. 0
  44412. ]);
  44413. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44414. itemEncode(locaData, j, simpleGlyph.length);
  44415. }
  44416. glyf.data = simpleGlyph;
  44417. return missingGlyphData;
  44418. }
  44419. if (dupFirstEntry) {
  44420. var firstEntryLength = itemDecode(locaData, itemSize);
  44421. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44422. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44423. } else {
  44424. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44425. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44426. }
  44427. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44428. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44429. } else {
  44430. glyf.data = newGlyfData.subarray(0, writeOffset);
  44431. }
  44432. return missingGlyphData;
  44433. }
  44434. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44435. var start = (font.start ? font.start : 0) + post.offset;
  44436. font.pos = start;
  44437. var length = post.length, end = start + length;
  44438. var version = font.getInt32();
  44439. font.getBytes(28);
  44440. var glyphNames;
  44441. var valid = true;
  44442. var i;
  44443. switch (version) {
  44444. case 0x00010000:
  44445. glyphNames = MacStandardGlyphOrdering;
  44446. break;
  44447. case 0x00020000:
  44448. var numGlyphs = font.getUint16();
  44449. if (numGlyphs !== maxpNumGlyphs) {
  44450. valid = false;
  44451. break;
  44452. }
  44453. var glyphNameIndexes = [];
  44454. for (i = 0; i < numGlyphs; ++i) {
  44455. var index = font.getUint16();
  44456. if (index >= 32768) {
  44457. valid = false;
  44458. break;
  44459. }
  44460. glyphNameIndexes.push(index);
  44461. }
  44462. if (!valid) {
  44463. break;
  44464. }
  44465. var customNames = [];
  44466. var strBuf = [];
  44467. while (font.pos < end) {
  44468. var stringLength = font.getByte();
  44469. strBuf.length = stringLength;
  44470. for (i = 0; i < stringLength; ++i) {
  44471. strBuf[i] = String.fromCharCode(font.getByte());
  44472. }
  44473. customNames.push(strBuf.join(''));
  44474. }
  44475. glyphNames = [];
  44476. for (i = 0; i < numGlyphs; ++i) {
  44477. var j = glyphNameIndexes[i];
  44478. if (j < 258) {
  44479. glyphNames.push(MacStandardGlyphOrdering[j]);
  44480. continue;
  44481. }
  44482. glyphNames.push(customNames[j - 258]);
  44483. }
  44484. break;
  44485. case 0x00030000:
  44486. break;
  44487. default:
  44488. warn('Unknown/unsupported post table version ' + version);
  44489. valid = false;
  44490. if (properties.defaultEncoding) {
  44491. glyphNames = properties.defaultEncoding;
  44492. }
  44493. break;
  44494. }
  44495. properties.glyphNames = glyphNames;
  44496. return valid;
  44497. }
  44498. function readNameTable(nameTable) {
  44499. var start = (font.start ? font.start : 0) + nameTable.offset;
  44500. font.pos = start;
  44501. var names = [
  44502. [],
  44503. []
  44504. ];
  44505. var length = nameTable.length, end = start + length;
  44506. var format = font.getUint16();
  44507. var FORMAT_0_HEADER_LENGTH = 6;
  44508. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44509. return names;
  44510. }
  44511. var numRecords = font.getUint16();
  44512. var stringsStart = font.getUint16();
  44513. var records = [];
  44514. var NAME_RECORD_LENGTH = 12;
  44515. var i, ii;
  44516. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44517. var r = {
  44518. platform: font.getUint16(),
  44519. encoding: font.getUint16(),
  44520. language: font.getUint16(),
  44521. name: font.getUint16(),
  44522. length: font.getUint16(),
  44523. offset: font.getUint16()
  44524. };
  44525. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44526. records.push(r);
  44527. }
  44528. }
  44529. for (i = 0, ii = records.length; i < ii; i++) {
  44530. var record = records[i];
  44531. if (record.length <= 0) {
  44532. continue;
  44533. }
  44534. var pos = start + stringsStart + record.offset;
  44535. if (pos + record.length > end) {
  44536. continue;
  44537. }
  44538. font.pos = pos;
  44539. var nameIndex = record.name;
  44540. if (record.encoding) {
  44541. var str = '';
  44542. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44543. str += String.fromCharCode(font.getUint16());
  44544. }
  44545. names[1][nameIndex] = str;
  44546. } else {
  44547. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44548. }
  44549. }
  44550. return names;
  44551. }
  44552. var TTOpsStackDeltas = [
  44553. 0,
  44554. 0,
  44555. 0,
  44556. 0,
  44557. 0,
  44558. 0,
  44559. 0,
  44560. 0,
  44561. -2,
  44562. -2,
  44563. -2,
  44564. -2,
  44565. 0,
  44566. 0,
  44567. -2,
  44568. -5,
  44569. -1,
  44570. -1,
  44571. -1,
  44572. -1,
  44573. -1,
  44574. -1,
  44575. -1,
  44576. -1,
  44577. 0,
  44578. 0,
  44579. -1,
  44580. 0,
  44581. -1,
  44582. -1,
  44583. -1,
  44584. -1,
  44585. 1,
  44586. -1,
  44587. -999,
  44588. 0,
  44589. 1,
  44590. 0,
  44591. -1,
  44592. -2,
  44593. 0,
  44594. -1,
  44595. -2,
  44596. -1,
  44597. -1,
  44598. 0,
  44599. -1,
  44600. -1,
  44601. 0,
  44602. 0,
  44603. -999,
  44604. -999,
  44605. -1,
  44606. -1,
  44607. -1,
  44608. -1,
  44609. -2,
  44610. -999,
  44611. -2,
  44612. -2,
  44613. -999,
  44614. 0,
  44615. -2,
  44616. -2,
  44617. 0,
  44618. 0,
  44619. -2,
  44620. 0,
  44621. -2,
  44622. 0,
  44623. 0,
  44624. 0,
  44625. -2,
  44626. -1,
  44627. -1,
  44628. 1,
  44629. 1,
  44630. 0,
  44631. 0,
  44632. -1,
  44633. -1,
  44634. -1,
  44635. -1,
  44636. -1,
  44637. -1,
  44638. -1,
  44639. 0,
  44640. 0,
  44641. -1,
  44642. 0,
  44643. -1,
  44644. -1,
  44645. 0,
  44646. -999,
  44647. -1,
  44648. -1,
  44649. -1,
  44650. -1,
  44651. -1,
  44652. -1,
  44653. 0,
  44654. 0,
  44655. 0,
  44656. 0,
  44657. 0,
  44658. 0,
  44659. 0,
  44660. 0,
  44661. 0,
  44662. 0,
  44663. 0,
  44664. 0,
  44665. -2,
  44666. -999,
  44667. -999,
  44668. -999,
  44669. -999,
  44670. -999,
  44671. -1,
  44672. -1,
  44673. -2,
  44674. -2,
  44675. 0,
  44676. 0,
  44677. 0,
  44678. 0,
  44679. -1,
  44680. -1,
  44681. -999,
  44682. -2,
  44683. -2,
  44684. 0,
  44685. 0,
  44686. -1,
  44687. -2,
  44688. -2,
  44689. 0,
  44690. 0,
  44691. 0,
  44692. -1,
  44693. -1,
  44694. -1,
  44695. -2
  44696. ];
  44697. function sanitizeTTProgram(table, ttContext) {
  44698. var data = table.data;
  44699. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44700. var stack = [];
  44701. var callstack = [];
  44702. var functionsCalled = [];
  44703. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44704. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44705. for (var ii = data.length; i < ii;) {
  44706. var op = data[i++];
  44707. if (op === 0x40) {
  44708. n = data[i++];
  44709. if (inFDEF || inELSE) {
  44710. i += n;
  44711. } else {
  44712. for (j = 0; j < n; j++) {
  44713. stack.push(data[i++]);
  44714. }
  44715. }
  44716. } else if (op === 0x41) {
  44717. n = data[i++];
  44718. if (inFDEF || inELSE) {
  44719. i += n * 2;
  44720. } else {
  44721. for (j = 0; j < n; j++) {
  44722. b = data[i++];
  44723. stack.push(b << 8 | data[i++]);
  44724. }
  44725. }
  44726. } else if ((op & 0xF8) === 0xB0) {
  44727. n = op - 0xB0 + 1;
  44728. if (inFDEF || inELSE) {
  44729. i += n;
  44730. } else {
  44731. for (j = 0; j < n; j++) {
  44732. stack.push(data[i++]);
  44733. }
  44734. }
  44735. } else if ((op & 0xF8) === 0xB8) {
  44736. n = op - 0xB8 + 1;
  44737. if (inFDEF || inELSE) {
  44738. i += n * 2;
  44739. } else {
  44740. for (j = 0; j < n; j++) {
  44741. b = data[i++];
  44742. stack.push(b << 8 | data[i++]);
  44743. }
  44744. }
  44745. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44746. if (!inFDEF && !inELSE) {
  44747. funcId = stack[stack.length - 1];
  44748. ttContext.functionsUsed[funcId] = true;
  44749. if (funcId in ttContext.functionsStackDeltas) {
  44750. stack.length += ttContext.functionsStackDeltas[funcId];
  44751. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44752. callstack.push({
  44753. data: data,
  44754. i: i,
  44755. stackTop: stack.length - 1
  44756. });
  44757. functionsCalled.push(funcId);
  44758. pc = ttContext.functionsDefined[funcId];
  44759. if (!pc) {
  44760. warn('TT: CALL non-existent function');
  44761. ttContext.hintsValid = false;
  44762. return;
  44763. }
  44764. data = pc.data;
  44765. i = pc.i;
  44766. }
  44767. }
  44768. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44769. if (inFDEF || inELSE) {
  44770. warn('TT: nested FDEFs not allowed');
  44771. tooComplexToFollowFunctions = true;
  44772. }
  44773. inFDEF = true;
  44774. lastDeff = i;
  44775. funcId = stack.pop();
  44776. ttContext.functionsDefined[funcId] = {
  44777. data: data,
  44778. i: i
  44779. };
  44780. } else if (op === 0x2D) {
  44781. if (inFDEF) {
  44782. inFDEF = false;
  44783. lastEndf = i;
  44784. } else {
  44785. pc = callstack.pop();
  44786. if (!pc) {
  44787. warn('TT: ENDF bad stack');
  44788. ttContext.hintsValid = false;
  44789. return;
  44790. }
  44791. funcId = functionsCalled.pop();
  44792. data = pc.data;
  44793. i = pc.i;
  44794. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44795. }
  44796. } else if (op === 0x89) {
  44797. if (inFDEF || inELSE) {
  44798. warn('TT: nested IDEFs not allowed');
  44799. tooComplexToFollowFunctions = true;
  44800. }
  44801. inFDEF = true;
  44802. lastDeff = i;
  44803. } else if (op === 0x58) {
  44804. ++ifLevel;
  44805. } else if (op === 0x1B) {
  44806. inELSE = ifLevel;
  44807. } else if (op === 0x59) {
  44808. if (inELSE === ifLevel) {
  44809. inELSE = 0;
  44810. }
  44811. --ifLevel;
  44812. } else if (op === 0x1C) {
  44813. if (!inFDEF && !inELSE) {
  44814. var offset = stack[stack.length - 1];
  44815. if (offset > 0) {
  44816. i += offset - 1;
  44817. }
  44818. }
  44819. }
  44820. if (!inFDEF && !inELSE) {
  44821. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44822. if (op >= 0x71 && op <= 0x75) {
  44823. n = stack.pop();
  44824. if (!isNaN(n)) {
  44825. stackDelta = -n * 2;
  44826. }
  44827. }
  44828. while (stackDelta < 0 && stack.length > 0) {
  44829. stack.pop();
  44830. stackDelta++;
  44831. }
  44832. while (stackDelta > 0) {
  44833. stack.push(NaN);
  44834. stackDelta--;
  44835. }
  44836. }
  44837. }
  44838. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44839. var content = [data];
  44840. if (i > data.length) {
  44841. content.push(new Uint8Array(i - data.length));
  44842. }
  44843. if (lastDeff > lastEndf) {
  44844. warn('TT: complementing a missing function tail');
  44845. content.push(new Uint8Array([
  44846. 0x22,
  44847. 0x2D
  44848. ]));
  44849. }
  44850. foldTTTable(table, content);
  44851. }
  44852. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44853. if (ttContext.tooComplexToFollowFunctions) {
  44854. return;
  44855. }
  44856. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44857. warn('TT: more functions defined than expected');
  44858. ttContext.hintsValid = false;
  44859. return;
  44860. }
  44861. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44862. if (j > maxFunctionDefs) {
  44863. warn('TT: invalid function id: ' + j);
  44864. ttContext.hintsValid = false;
  44865. return;
  44866. }
  44867. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44868. warn('TT: undefined function: ' + j);
  44869. ttContext.hintsValid = false;
  44870. return;
  44871. }
  44872. }
  44873. }
  44874. function foldTTTable(table, content) {
  44875. if (content.length > 1) {
  44876. var newLength = 0;
  44877. var j, jj;
  44878. for (j = 0, jj = content.length; j < jj; j++) {
  44879. newLength += content[j].length;
  44880. }
  44881. newLength = newLength + 3 & ~3;
  44882. var result = new Uint8Array(newLength);
  44883. var pos = 0;
  44884. for (j = 0, jj = content.length; j < jj; j++) {
  44885. result.set(content[j], pos);
  44886. pos += content[j].length;
  44887. }
  44888. table.data = result;
  44889. table.length = newLength;
  44890. }
  44891. }
  44892. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44893. var ttContext = {
  44894. functionsDefined: [],
  44895. functionsUsed: [],
  44896. functionsStackDeltas: [],
  44897. tooComplexToFollowFunctions: false,
  44898. hintsValid: true
  44899. };
  44900. if (fpgm) {
  44901. sanitizeTTProgram(fpgm, ttContext);
  44902. }
  44903. if (prep) {
  44904. sanitizeTTProgram(prep, ttContext);
  44905. }
  44906. if (fpgm) {
  44907. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44908. }
  44909. if (cvt && cvt.length & 1) {
  44910. var cvtData = new Uint8Array(cvt.length + 1);
  44911. cvtData.set(cvt.data);
  44912. cvt.data = cvtData;
  44913. }
  44914. return ttContext.hintsValid;
  44915. }
  44916. font = new Stream(new Uint8Array(font.getBytes()));
  44917. var VALID_TABLES = [
  44918. 'OS/2',
  44919. 'cmap',
  44920. 'head',
  44921. 'hhea',
  44922. 'hmtx',
  44923. 'maxp',
  44924. 'name',
  44925. 'post',
  44926. 'loca',
  44927. 'glyf',
  44928. 'fpgm',
  44929. 'prep',
  44930. 'cvt ',
  44931. 'CFF '
  44932. ];
  44933. var header = readOpenTypeHeader(font);
  44934. var numTables = header.numTables;
  44935. var cff, cffFile;
  44936. var tables = Object.create(null);
  44937. tables['OS/2'] = null;
  44938. tables['cmap'] = null;
  44939. tables['head'] = null;
  44940. tables['hhea'] = null;
  44941. tables['hmtx'] = null;
  44942. tables['maxp'] = null;
  44943. tables['name'] = null;
  44944. tables['post'] = null;
  44945. var table;
  44946. for (var i = 0; i < numTables; i++) {
  44947. table = readTableEntry(font);
  44948. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44949. continue;
  44950. }
  44951. if (table.length === 0) {
  44952. continue;
  44953. }
  44954. tables[table.tag] = table;
  44955. }
  44956. var isTrueType = !tables['CFF '];
  44957. if (!isTrueType) {
  44958. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44959. cffFile = new Stream(tables['CFF '].data);
  44960. cff = new CFFFont(cffFile, properties);
  44961. adjustWidths(properties);
  44962. return this.convert(name, cff, properties);
  44963. }
  44964. delete tables['glyf'];
  44965. delete tables['loca'];
  44966. delete tables['fpgm'];
  44967. delete tables['prep'];
  44968. delete tables['cvt '];
  44969. this.isOpenType = true;
  44970. } else {
  44971. if (!tables['loca']) {
  44972. error('Required "loca" table is not found');
  44973. }
  44974. if (!tables['glyf']) {
  44975. warn('Required "glyf" table is not found -- trying to recover.');
  44976. tables['glyf'] = {
  44977. tag: 'glyf',
  44978. data: new Uint8Array(0)
  44979. };
  44980. }
  44981. this.isOpenType = false;
  44982. }
  44983. if (!tables['maxp']) {
  44984. error('Required "maxp" table is not found');
  44985. }
  44986. font.pos = (font.start || 0) + tables['maxp'].offset;
  44987. var version = font.getInt32();
  44988. var numGlyphs = font.getUint16();
  44989. var maxFunctionDefs = 0;
  44990. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  44991. font.pos += 8;
  44992. var maxZones = font.getUint16();
  44993. if (maxZones > 2) {
  44994. tables['maxp'].data[14] = 0;
  44995. tables['maxp'].data[15] = 2;
  44996. }
  44997. font.pos += 4;
  44998. maxFunctionDefs = font.getUint16();
  44999. }
  45000. var dupFirstEntry = false;
  45001. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45002. dupFirstEntry = true;
  45003. numGlyphs++;
  45004. tables['maxp'].data[4] = numGlyphs >> 8;
  45005. tables['maxp'].data[5] = numGlyphs & 255;
  45006. }
  45007. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45008. if (!hintsValid) {
  45009. delete tables['fpgm'];
  45010. delete tables['prep'];
  45011. delete tables['cvt '];
  45012. }
  45013. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45014. if (!tables['head']) {
  45015. error('Required "head" table is not found');
  45016. }
  45017. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45018. var missingGlyphs = Object.create(null);
  45019. if (isTrueType) {
  45020. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45021. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45022. }
  45023. if (!tables['hhea']) {
  45024. error('Required "hhea" table is not found');
  45025. }
  45026. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45027. tables['hhea'].data[10] = 0xFF;
  45028. tables['hhea'].data[11] = 0xFF;
  45029. }
  45030. var metricsOverride = {
  45031. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45032. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45033. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45034. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45035. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45036. };
  45037. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45038. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45039. if (tables['post']) {
  45040. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45041. if (!valid) {
  45042. tables['post'] = null;
  45043. }
  45044. }
  45045. var charCodeToGlyphId = [], charCode;
  45046. var toUnicode = properties.toUnicode, widths = properties.widths;
  45047. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45048. function hasGlyph(glyphId, charCode, widthCode) {
  45049. if (!missingGlyphs[glyphId]) {
  45050. return true;
  45051. }
  45052. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45053. return true;
  45054. }
  45055. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45056. return true;
  45057. }
  45058. return false;
  45059. }
  45060. if (properties.composite) {
  45061. var cidToGidMap = properties.cidToGidMap || [];
  45062. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45063. properties.cMap.forEach(function (charCode, cid) {
  45064. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45065. var glyphId = -1;
  45066. if (isCidToGidMapEmpty) {
  45067. glyphId = cid;
  45068. } else if (cidToGidMap[cid] !== undefined) {
  45069. glyphId = cidToGidMap[cid];
  45070. }
  45071. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45072. charCodeToGlyphId[charCode] = glyphId;
  45073. }
  45074. });
  45075. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45076. charCodeToGlyphId[0] = numGlyphs - 1;
  45077. }
  45078. } else {
  45079. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45080. var cmapPlatformId = cmapTable.platformId;
  45081. var cmapEncodingId = cmapTable.encodingId;
  45082. var cmapMappings = cmapTable.mappings;
  45083. var cmapMappingsLength = cmapMappings.length;
  45084. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45085. var baseEncoding = [];
  45086. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45087. baseEncoding = getEncoding(properties.baseEncodingName);
  45088. }
  45089. var glyphsUnicodeMap = getGlyphsUnicode();
  45090. for (charCode = 0; charCode < 256; charCode++) {
  45091. var glyphName, standardGlyphName;
  45092. if (this.differences && charCode in this.differences) {
  45093. glyphName = this.differences[charCode];
  45094. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45095. glyphName = baseEncoding[charCode];
  45096. } else {
  45097. glyphName = StandardEncoding[charCode];
  45098. }
  45099. if (!glyphName) {
  45100. continue;
  45101. }
  45102. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45103. var unicodeOrCharCode, isUnicode = false;
  45104. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45105. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45106. isUnicode = true;
  45107. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45108. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45109. }
  45110. var found = false;
  45111. for (i = 0; i < cmapMappingsLength; ++i) {
  45112. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45113. continue;
  45114. }
  45115. var code = isUnicode ? charCode : unicodeOrCharCode;
  45116. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45117. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45118. found = true;
  45119. break;
  45120. }
  45121. }
  45122. if (!found && properties.glyphNames) {
  45123. var glyphId = properties.glyphNames.indexOf(glyphName);
  45124. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45125. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45126. }
  45127. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45128. charCodeToGlyphId[charCode] = glyphId;
  45129. found = true;
  45130. }
  45131. }
  45132. if (!found) {
  45133. charCodeToGlyphId[charCode] = 0;
  45134. }
  45135. }
  45136. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45137. for (i = 0; i < cmapMappingsLength; ++i) {
  45138. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45139. }
  45140. } else {
  45141. for (i = 0; i < cmapMappingsLength; ++i) {
  45142. charCode = cmapMappings[i].charCode & 0xFF;
  45143. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45144. }
  45145. }
  45146. }
  45147. if (charCodeToGlyphId.length === 0) {
  45148. charCodeToGlyphId[0] = 0;
  45149. }
  45150. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45151. this.toFontChar = newMapping.toFontChar;
  45152. tables['cmap'] = {
  45153. tag: 'cmap',
  45154. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45155. };
  45156. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45157. tables['OS/2'] = {
  45158. tag: 'OS/2',
  45159. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45160. };
  45161. }
  45162. if (!tables['post']) {
  45163. tables['post'] = {
  45164. tag: 'post',
  45165. data: createPostTable(properties)
  45166. };
  45167. }
  45168. if (!isTrueType) {
  45169. try {
  45170. cffFile = new Stream(tables['CFF '].data);
  45171. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45172. cff = parser.parse();
  45173. var compiler = new CFFCompiler(cff);
  45174. tables['CFF '].data = compiler.compile();
  45175. } catch (e) {
  45176. warn('Failed to compile font ' + properties.loadedName);
  45177. }
  45178. }
  45179. if (!tables['name']) {
  45180. tables['name'] = {
  45181. tag: 'name',
  45182. data: createNameTable(this.name)
  45183. };
  45184. } else {
  45185. var namePrototype = readNameTable(tables['name']);
  45186. tables['name'].data = createNameTable(name, namePrototype);
  45187. }
  45188. var builder = new OpenTypeFileBuilder(header.version);
  45189. for (var tableTag in tables) {
  45190. builder.addTable(tableTag, tables[tableTag].data);
  45191. }
  45192. return builder.toArray();
  45193. },
  45194. convert: function Font_convert(fontName, font, properties) {
  45195. properties.fixedPitch = false;
  45196. if (properties.builtInEncoding) {
  45197. adjustToUnicode(properties, properties.builtInEncoding);
  45198. }
  45199. var mapping = font.getGlyphMapping(properties);
  45200. var newMapping = adjustMapping(mapping, properties);
  45201. this.toFontChar = newMapping.toFontChar;
  45202. var numGlyphs = font.numGlyphs;
  45203. function getCharCodes(charCodeToGlyphId, glyphId) {
  45204. var charCodes = null;
  45205. for (var charCode in charCodeToGlyphId) {
  45206. if (glyphId === charCodeToGlyphId[charCode]) {
  45207. if (!charCodes) {
  45208. charCodes = [];
  45209. }
  45210. charCodes.push(charCode | 0);
  45211. }
  45212. }
  45213. return charCodes;
  45214. }
  45215. function createCharCode(charCodeToGlyphId, glyphId) {
  45216. for (var charCode in charCodeToGlyphId) {
  45217. if (glyphId === charCodeToGlyphId[charCode]) {
  45218. return charCode | 0;
  45219. }
  45220. }
  45221. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  45222. return newMapping.nextAvailableFontCharCode++;
  45223. }
  45224. var seacs = font.seacs;
  45225. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  45226. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  45227. var charset = font.getCharset();
  45228. var seacMap = Object.create(null);
  45229. for (var glyphId in seacs) {
  45230. glyphId |= 0;
  45231. var seac = seacs[glyphId];
  45232. var baseGlyphName = StandardEncoding[seac[2]];
  45233. var accentGlyphName = StandardEncoding[seac[3]];
  45234. var baseGlyphId = charset.indexOf(baseGlyphName);
  45235. var accentGlyphId = charset.indexOf(accentGlyphName);
  45236. if (baseGlyphId < 0 || accentGlyphId < 0) {
  45237. continue;
  45238. }
  45239. var accentOffset = {
  45240. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  45241. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  45242. };
  45243. var charCodes = getCharCodes(mapping, glyphId);
  45244. if (!charCodes) {
  45245. continue;
  45246. }
  45247. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  45248. var charCode = charCodes[i];
  45249. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  45250. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  45251. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  45252. seacMap[charCode] = {
  45253. baseFontCharCode: baseFontCharCode,
  45254. accentFontCharCode: accentFontCharCode,
  45255. accentOffset: accentOffset
  45256. };
  45257. }
  45258. }
  45259. properties.seacMap = seacMap;
  45260. }
  45261. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45262. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  45263. builder.addTable('CFF ', font.data);
  45264. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  45265. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  45266. 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');
  45267. 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));
  45268. builder.addTable('hmtx', function fontFieldsHmtx() {
  45269. var charstrings = font.charstrings;
  45270. var cffWidths = font.cff ? font.cff.widths : null;
  45271. var hmtx = '\x00\x00\x00\x00';
  45272. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  45273. var width = 0;
  45274. if (charstrings) {
  45275. var charstring = charstrings[i - 1];
  45276. width = 'width' in charstring ? charstring.width : 0;
  45277. } else if (cffWidths) {
  45278. width = Math.ceil(cffWidths[i] || 0);
  45279. }
  45280. hmtx += string16(width) + string16(0);
  45281. }
  45282. return hmtx;
  45283. }());
  45284. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  45285. builder.addTable('name', createNameTable(fontName));
  45286. builder.addTable('post', createPostTable(properties));
  45287. return builder.toArray();
  45288. },
  45289. get spaceWidth() {
  45290. if ('_shadowWidth' in this) {
  45291. return this._shadowWidth;
  45292. }
  45293. var possibleSpaceReplacements = [
  45294. 'space',
  45295. 'minus',
  45296. 'one',
  45297. 'i',
  45298. 'I'
  45299. ];
  45300. var width;
  45301. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  45302. var glyphName = possibleSpaceReplacements[i];
  45303. if (glyphName in this.widths) {
  45304. width = this.widths[glyphName];
  45305. break;
  45306. }
  45307. var glyphsUnicodeMap = getGlyphsUnicode();
  45308. var glyphUnicode = glyphsUnicodeMap[glyphName];
  45309. var charcode = 0;
  45310. if (this.composite) {
  45311. if (this.cMap.contains(glyphUnicode)) {
  45312. charcode = this.cMap.lookup(glyphUnicode);
  45313. }
  45314. }
  45315. if (!charcode && this.toUnicode) {
  45316. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  45317. }
  45318. if (charcode <= 0) {
  45319. charcode = glyphUnicode;
  45320. }
  45321. width = this.widths[charcode];
  45322. if (width) {
  45323. break;
  45324. }
  45325. }
  45326. width = width || this.defaultWidth;
  45327. this._shadowWidth = width;
  45328. return width;
  45329. },
  45330. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  45331. var fontCharCode, width, operatorListId;
  45332. var widthCode = charcode;
  45333. if (this.cMap && this.cMap.contains(charcode)) {
  45334. widthCode = this.cMap.lookup(charcode);
  45335. }
  45336. width = this.widths[widthCode];
  45337. width = isNum(width) ? width : this.defaultWidth;
  45338. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  45339. var unicode = this.toUnicode.get(charcode) || charcode;
  45340. if (typeof unicode === 'number') {
  45341. unicode = String.fromCharCode(unicode);
  45342. }
  45343. var isInFont = charcode in this.toFontChar;
  45344. fontCharCode = this.toFontChar[charcode] || charcode;
  45345. if (this.missingFile) {
  45346. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  45347. }
  45348. if (this.isType3Font) {
  45349. operatorListId = fontCharCode;
  45350. }
  45351. var accent = null;
  45352. if (this.seacMap && this.seacMap[charcode]) {
  45353. isInFont = true;
  45354. var seac = this.seacMap[charcode];
  45355. fontCharCode = seac.baseFontCharCode;
  45356. accent = {
  45357. fontChar: String.fromCharCode(seac.accentFontCharCode),
  45358. offset: seac.accentOffset
  45359. };
  45360. }
  45361. var fontChar = String.fromCharCode(fontCharCode);
  45362. var glyph = this.glyphCache[charcode];
  45363. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  45364. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  45365. this.glyphCache[charcode] = glyph;
  45366. }
  45367. return glyph;
  45368. },
  45369. charsToGlyphs: function Font_charsToGlyphs(chars) {
  45370. var charsCache = this.charsCache;
  45371. var glyphs, glyph, charcode;
  45372. if (charsCache) {
  45373. glyphs = charsCache[chars];
  45374. if (glyphs) {
  45375. return glyphs;
  45376. }
  45377. }
  45378. if (!charsCache) {
  45379. charsCache = this.charsCache = Object.create(null);
  45380. }
  45381. glyphs = [];
  45382. var charsCacheKey = chars;
  45383. var i = 0, ii;
  45384. if (this.cMap) {
  45385. var c = Object.create(null);
  45386. while (i < chars.length) {
  45387. this.cMap.readCharCode(chars, i, c);
  45388. charcode = c.charcode;
  45389. var length = c.length;
  45390. i += length;
  45391. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  45392. glyph = this.charToGlyph(charcode, isSpace);
  45393. glyphs.push(glyph);
  45394. }
  45395. } else {
  45396. for (i = 0, ii = chars.length; i < ii; ++i) {
  45397. charcode = chars.charCodeAt(i);
  45398. glyph = this.charToGlyph(charcode, charcode === 0x20);
  45399. glyphs.push(glyph);
  45400. }
  45401. }
  45402. return charsCache[charsCacheKey] = glyphs;
  45403. }
  45404. };
  45405. return Font;
  45406. }();
  45407. var ErrorFont = function ErrorFontClosure() {
  45408. function ErrorFont(error) {
  45409. this.error = error;
  45410. this.loadedName = 'g_font_error';
  45411. this.loading = false;
  45412. }
  45413. ErrorFont.prototype = {
  45414. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45415. return [];
  45416. },
  45417. exportData: function ErrorFont_exportData() {
  45418. return { error: this.error };
  45419. }
  45420. };
  45421. return ErrorFont;
  45422. }();
  45423. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45424. var charCodeToGlyphId = Object.create(null);
  45425. var glyphId, charCode, baseEncoding;
  45426. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45427. if (properties.baseEncodingName) {
  45428. baseEncoding = getEncoding(properties.baseEncodingName);
  45429. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45430. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45431. if (glyphId >= 0) {
  45432. charCodeToGlyphId[charCode] = glyphId;
  45433. } else {
  45434. charCodeToGlyphId[charCode] = 0;
  45435. }
  45436. }
  45437. } else if (isSymbolicFont) {
  45438. for (charCode in builtInEncoding) {
  45439. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45440. }
  45441. } else {
  45442. baseEncoding = StandardEncoding;
  45443. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45444. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45445. if (glyphId >= 0) {
  45446. charCodeToGlyphId[charCode] = glyphId;
  45447. } else {
  45448. charCodeToGlyphId[charCode] = 0;
  45449. }
  45450. }
  45451. }
  45452. var differences = properties.differences, glyphsUnicodeMap;
  45453. if (differences) {
  45454. for (charCode in differences) {
  45455. var glyphName = differences[charCode];
  45456. glyphId = glyphNames.indexOf(glyphName);
  45457. if (glyphId === -1) {
  45458. if (!glyphsUnicodeMap) {
  45459. glyphsUnicodeMap = getGlyphsUnicode();
  45460. }
  45461. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45462. if (standardGlyphName !== glyphName) {
  45463. glyphId = glyphNames.indexOf(standardGlyphName);
  45464. }
  45465. }
  45466. if (glyphId >= 0) {
  45467. charCodeToGlyphId[charCode] = glyphId;
  45468. } else {
  45469. charCodeToGlyphId[charCode] = 0;
  45470. }
  45471. }
  45472. }
  45473. return charCodeToGlyphId;
  45474. }
  45475. var Type1Font = function Type1FontClosure() {
  45476. function findBlock(streamBytes, signature, startIndex) {
  45477. var streamBytesLength = streamBytes.length;
  45478. var signatureLength = signature.length;
  45479. var scanLength = streamBytesLength - signatureLength;
  45480. var i = startIndex, j, found = false;
  45481. while (i < scanLength) {
  45482. j = 0;
  45483. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45484. j++;
  45485. }
  45486. if (j >= signatureLength) {
  45487. i += j;
  45488. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45489. i++;
  45490. }
  45491. found = true;
  45492. break;
  45493. }
  45494. i++;
  45495. }
  45496. return {
  45497. found: found,
  45498. length: i
  45499. };
  45500. }
  45501. function getHeaderBlock(stream, suggestedLength) {
  45502. var EEXEC_SIGNATURE = [
  45503. 0x65,
  45504. 0x65,
  45505. 0x78,
  45506. 0x65,
  45507. 0x63
  45508. ];
  45509. var streamStartPos = stream.pos;
  45510. var headerBytes, headerBytesLength, block;
  45511. try {
  45512. headerBytes = stream.getBytes(suggestedLength);
  45513. headerBytesLength = headerBytes.length;
  45514. } catch (ex) {
  45515. if (ex instanceof MissingDataException) {
  45516. throw ex;
  45517. }
  45518. }
  45519. if (headerBytesLength === suggestedLength) {
  45520. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45521. if (block.found && block.length === suggestedLength) {
  45522. return {
  45523. stream: new Stream(headerBytes),
  45524. length: suggestedLength
  45525. };
  45526. }
  45527. }
  45528. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45529. stream.pos = streamStartPos;
  45530. var SCAN_BLOCK_LENGTH = 2048;
  45531. var actualLength;
  45532. while (true) {
  45533. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45534. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45535. if (block.length === 0) {
  45536. break;
  45537. }
  45538. stream.pos += block.length;
  45539. if (block.found) {
  45540. actualLength = stream.pos - streamStartPos;
  45541. break;
  45542. }
  45543. }
  45544. stream.pos = streamStartPos;
  45545. if (actualLength) {
  45546. return {
  45547. stream: new Stream(stream.getBytes(actualLength)),
  45548. length: actualLength
  45549. };
  45550. }
  45551. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45552. return {
  45553. stream: new Stream(stream.getBytes(suggestedLength)),
  45554. length: suggestedLength
  45555. };
  45556. }
  45557. function getEexecBlock(stream, suggestedLength) {
  45558. var eexecBytes = stream.getBytes();
  45559. return {
  45560. stream: new Stream(eexecBytes),
  45561. length: eexecBytes.length
  45562. };
  45563. }
  45564. function Type1Font(name, file, properties) {
  45565. var PFB_HEADER_SIZE = 6;
  45566. var headerBlockLength = properties.length1;
  45567. var eexecBlockLength = properties.length2;
  45568. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45569. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45570. if (pfbHeaderPresent) {
  45571. file.skip(PFB_HEADER_SIZE);
  45572. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45573. }
  45574. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45575. headerBlockLength = headerBlock.length;
  45576. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45577. headerBlockParser.extractFontHeader(properties);
  45578. if (pfbHeaderPresent) {
  45579. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45580. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45581. }
  45582. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45583. eexecBlockLength = eexecBlock.length;
  45584. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45585. var data = eexecBlockParser.extractFontProgram();
  45586. for (var info in data.properties) {
  45587. properties[info] = data.properties[info];
  45588. }
  45589. var charstrings = data.charstrings;
  45590. var type2Charstrings = this.getType2Charstrings(charstrings);
  45591. var subrs = this.getType2Subrs(data.subrs);
  45592. this.charstrings = charstrings;
  45593. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45594. this.seacs = this.getSeacs(data.charstrings);
  45595. }
  45596. Type1Font.prototype = {
  45597. get numGlyphs() {
  45598. return this.charstrings.length + 1;
  45599. },
  45600. getCharset: function Type1Font_getCharset() {
  45601. var charset = ['.notdef'];
  45602. var charstrings = this.charstrings;
  45603. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45604. charset.push(charstrings[glyphId].glyphName);
  45605. }
  45606. return charset;
  45607. },
  45608. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45609. var charstrings = this.charstrings;
  45610. var glyphNames = ['.notdef'], glyphId;
  45611. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45612. glyphNames.push(charstrings[glyphId].glyphName);
  45613. }
  45614. var encoding = properties.builtInEncoding;
  45615. if (encoding) {
  45616. var builtInEncoding = Object.create(null);
  45617. for (var charCode in encoding) {
  45618. glyphId = glyphNames.indexOf(encoding[charCode]);
  45619. if (glyphId >= 0) {
  45620. builtInEncoding[charCode] = glyphId;
  45621. }
  45622. }
  45623. }
  45624. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45625. },
  45626. getSeacs: function Type1Font_getSeacs(charstrings) {
  45627. var i, ii;
  45628. var seacMap = [];
  45629. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45630. var charstring = charstrings[i];
  45631. if (charstring.seac) {
  45632. seacMap[i + 1] = charstring.seac;
  45633. }
  45634. }
  45635. return seacMap;
  45636. },
  45637. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45638. var type2Charstrings = [];
  45639. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45640. type2Charstrings.push(type1Charstrings[i].charstring);
  45641. }
  45642. return type2Charstrings;
  45643. },
  45644. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45645. var bias = 0;
  45646. var count = type1Subrs.length;
  45647. if (count < 1133) {
  45648. bias = 107;
  45649. } else if (count < 33769) {
  45650. bias = 1131;
  45651. } else {
  45652. bias = 32768;
  45653. }
  45654. var type2Subrs = [];
  45655. var i;
  45656. for (i = 0; i < bias; i++) {
  45657. type2Subrs.push([0x0B]);
  45658. }
  45659. for (i = 0; i < count; i++) {
  45660. type2Subrs.push(type1Subrs[i]);
  45661. }
  45662. return type2Subrs;
  45663. },
  45664. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45665. var cff = new CFF();
  45666. cff.header = new CFFHeader(1, 0, 4, 4);
  45667. cff.names = [name];
  45668. var topDict = new CFFTopDict();
  45669. topDict.setByName('version', 391);
  45670. topDict.setByName('Notice', 392);
  45671. topDict.setByName('FullName', 393);
  45672. topDict.setByName('FamilyName', 394);
  45673. topDict.setByName('Weight', 395);
  45674. topDict.setByName('Encoding', null);
  45675. topDict.setByName('FontMatrix', properties.fontMatrix);
  45676. topDict.setByName('FontBBox', properties.bbox);
  45677. topDict.setByName('charset', null);
  45678. topDict.setByName('CharStrings', null);
  45679. topDict.setByName('Private', null);
  45680. cff.topDict = topDict;
  45681. var strings = new CFFStrings();
  45682. strings.add('Version 0.11');
  45683. strings.add('See original notice');
  45684. strings.add(name);
  45685. strings.add(name);
  45686. strings.add('Medium');
  45687. cff.strings = strings;
  45688. cff.globalSubrIndex = new CFFIndex();
  45689. var count = glyphs.length;
  45690. var charsetArray = [0];
  45691. var i, ii;
  45692. for (i = 0; i < count; i++) {
  45693. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45694. if (index === -1) {
  45695. index = 0;
  45696. }
  45697. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45698. }
  45699. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45700. var charStringsIndex = new CFFIndex();
  45701. charStringsIndex.add([
  45702. 0x8B,
  45703. 0x0E
  45704. ]);
  45705. for (i = 0; i < count; i++) {
  45706. var glyph = glyphs[i];
  45707. if (glyph.length === 0) {
  45708. charStringsIndex.add([
  45709. 0x8B,
  45710. 0x0E
  45711. ]);
  45712. continue;
  45713. }
  45714. charStringsIndex.add(glyph);
  45715. }
  45716. cff.charStrings = charStringsIndex;
  45717. var privateDict = new CFFPrivateDict();
  45718. privateDict.setByName('Subrs', null);
  45719. var fields = [
  45720. 'BlueValues',
  45721. 'OtherBlues',
  45722. 'FamilyBlues',
  45723. 'FamilyOtherBlues',
  45724. 'StemSnapH',
  45725. 'StemSnapV',
  45726. 'BlueShift',
  45727. 'BlueFuzz',
  45728. 'BlueScale',
  45729. 'LanguageGroup',
  45730. 'ExpansionFactor',
  45731. 'ForceBold',
  45732. 'StdHW',
  45733. 'StdVW'
  45734. ];
  45735. for (i = 0, ii = fields.length; i < ii; i++) {
  45736. var field = fields[i];
  45737. if (!(field in properties.privateData)) {
  45738. continue;
  45739. }
  45740. var value = properties.privateData[field];
  45741. if (isArray(value)) {
  45742. for (var j = value.length - 1; j > 0; j--) {
  45743. value[j] -= value[j - 1];
  45744. }
  45745. }
  45746. privateDict.setByName(field, value);
  45747. }
  45748. cff.topDict.privateDict = privateDict;
  45749. var subrIndex = new CFFIndex();
  45750. for (i = 0, ii = subrs.length; i < ii; i++) {
  45751. subrIndex.add(subrs[i]);
  45752. }
  45753. privateDict.subrsIndex = subrIndex;
  45754. var compiler = new CFFCompiler(cff);
  45755. return compiler.compile();
  45756. }
  45757. };
  45758. return Type1Font;
  45759. }();
  45760. var CFFFont = function CFFFontClosure() {
  45761. function CFFFont(file, properties) {
  45762. this.properties = properties;
  45763. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45764. this.cff = parser.parse();
  45765. var compiler = new CFFCompiler(this.cff);
  45766. this.seacs = this.cff.seacs;
  45767. try {
  45768. this.data = compiler.compile();
  45769. } catch (e) {
  45770. warn('Failed to compile font ' + properties.loadedName);
  45771. this.data = file;
  45772. }
  45773. }
  45774. CFFFont.prototype = {
  45775. get numGlyphs() {
  45776. return this.cff.charStrings.count;
  45777. },
  45778. getCharset: function CFFFont_getCharset() {
  45779. return this.cff.charset.charset;
  45780. },
  45781. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45782. var cff = this.cff;
  45783. var properties = this.properties;
  45784. var charsets = cff.charset.charset;
  45785. var charCodeToGlyphId;
  45786. var glyphId;
  45787. if (properties.composite) {
  45788. charCodeToGlyphId = Object.create(null);
  45789. if (cff.isCIDFont) {
  45790. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45791. var cid = charsets[glyphId];
  45792. var charCode = properties.cMap.charCodeOf(cid);
  45793. charCodeToGlyphId[charCode] = glyphId;
  45794. }
  45795. } else {
  45796. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45797. charCodeToGlyphId[glyphId] = glyphId;
  45798. }
  45799. }
  45800. return charCodeToGlyphId;
  45801. }
  45802. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45803. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45804. return charCodeToGlyphId;
  45805. }
  45806. };
  45807. return CFFFont;
  45808. }();
  45809. (function checkSeacSupport() {
  45810. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45811. SEAC_ANALYSIS_ENABLED = true;
  45812. }
  45813. }());
  45814. (function checkChromeWindows() {
  45815. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45816. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45817. }
  45818. }());
  45819. exports.ErrorFont = ErrorFont;
  45820. exports.Font = Font;
  45821. exports.FontFlags = FontFlags;
  45822. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45823. exports.ToUnicodeMap = ToUnicodeMap;
  45824. exports.getFontType = getFontType;
  45825. /***/ }),
  45826. /* 34 */
  45827. /***/ (function(module, exports, __w_pdfjs_require__) {
  45828. "use strict";
  45829. var sharedUtil = __w_pdfjs_require__(0);
  45830. var corePrimitives = __w_pdfjs_require__(1);
  45831. var coreColorSpace = __w_pdfjs_require__(4);
  45832. var coreStream = __w_pdfjs_require__(2);
  45833. var coreJpx = __w_pdfjs_require__(19);
  45834. var ImageKind = sharedUtil.ImageKind;
  45835. var assert = sharedUtil.assert;
  45836. var error = sharedUtil.error;
  45837. var info = sharedUtil.info;
  45838. var isArray = sharedUtil.isArray;
  45839. var warn = sharedUtil.warn;
  45840. var Name = corePrimitives.Name;
  45841. var isStream = corePrimitives.isStream;
  45842. var ColorSpace = coreColorSpace.ColorSpace;
  45843. var DecodeStream = coreStream.DecodeStream;
  45844. var JpegStream = coreStream.JpegStream;
  45845. var JpxImage = coreJpx.JpxImage;
  45846. var PDFImage = function PDFImageClosure() {
  45847. function handleImageData(image, nativeDecoder) {
  45848. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  45849. return nativeDecoder.decode(image);
  45850. }
  45851. return Promise.resolve(image);
  45852. }
  45853. function decodeAndClamp(value, addend, coefficient, max) {
  45854. value = addend + value * coefficient;
  45855. return value < 0 ? 0 : value > max ? max : value;
  45856. }
  45857. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  45858. var length = w2 * h2;
  45859. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  45860. var xRatio = w1 / w2;
  45861. var yRatio = h1 / h2;
  45862. var i, j, py, newIndex = 0, oldIndex;
  45863. var xScaled = new Uint16Array(w2);
  45864. var w1Scanline = w1;
  45865. for (i = 0; i < w2; i++) {
  45866. xScaled[i] = Math.floor(i * xRatio);
  45867. }
  45868. for (i = 0; i < h2; i++) {
  45869. py = Math.floor(i * yRatio) * w1Scanline;
  45870. for (j = 0; j < w2; j++) {
  45871. oldIndex = py + xScaled[j];
  45872. dest[newIndex++] = src[oldIndex];
  45873. }
  45874. }
  45875. return dest;
  45876. }
  45877. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  45878. this.image = image;
  45879. var dict = image.dict;
  45880. if (dict.has('Filter')) {
  45881. var filter = dict.get('Filter').name;
  45882. if (filter === 'JPXDecode') {
  45883. var jpxImage = new JpxImage();
  45884. jpxImage.parseImageProperties(image.stream);
  45885. image.stream.reset();
  45886. image.bitsPerComponent = jpxImage.bitsPerComponent;
  45887. image.numComps = jpxImage.componentsCount;
  45888. } else if (filter === 'JBIG2Decode') {
  45889. image.bitsPerComponent = 1;
  45890. image.numComps = 1;
  45891. }
  45892. }
  45893. this.width = dict.get('Width', 'W');
  45894. this.height = dict.get('Height', 'H');
  45895. if (this.width < 1 || this.height < 1) {
  45896. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  45897. }
  45898. this.interpolate = dict.get('Interpolate', 'I') || false;
  45899. this.imageMask = dict.get('ImageMask', 'IM') || false;
  45900. this.matte = dict.get('Matte') || false;
  45901. var bitsPerComponent = image.bitsPerComponent;
  45902. if (!bitsPerComponent) {
  45903. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  45904. if (!bitsPerComponent) {
  45905. if (this.imageMask) {
  45906. bitsPerComponent = 1;
  45907. } else {
  45908. error('Bits per component missing in image: ' + this.imageMask);
  45909. }
  45910. }
  45911. }
  45912. this.bpc = bitsPerComponent;
  45913. if (!this.imageMask) {
  45914. var colorSpace = dict.get('ColorSpace', 'CS');
  45915. if (!colorSpace) {
  45916. info('JPX images (which do not require color spaces)');
  45917. switch (image.numComps) {
  45918. case 1:
  45919. colorSpace = Name.get('DeviceGray');
  45920. break;
  45921. case 3:
  45922. colorSpace = Name.get('DeviceRGB');
  45923. break;
  45924. case 4:
  45925. colorSpace = Name.get('DeviceCMYK');
  45926. break;
  45927. default:
  45928. error('JPX images with ' + this.numComps + ' color components not supported.');
  45929. }
  45930. }
  45931. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  45932. this.numComps = this.colorSpace.numComps;
  45933. }
  45934. this.decode = dict.getArray('Decode', 'D');
  45935. this.needsDecode = false;
  45936. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  45937. this.needsDecode = true;
  45938. var max = (1 << bitsPerComponent) - 1;
  45939. this.decodeCoefficients = [];
  45940. this.decodeAddends = [];
  45941. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  45942. var dmin = this.decode[i];
  45943. var dmax = this.decode[i + 1];
  45944. this.decodeCoefficients[j] = dmax - dmin;
  45945. this.decodeAddends[j] = max * dmin;
  45946. }
  45947. }
  45948. if (smask) {
  45949. this.smask = new PDFImage(xref, res, smask, false);
  45950. } else if (mask) {
  45951. if (isStream(mask)) {
  45952. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  45953. if (!imageMask) {
  45954. warn('Ignoring /Mask in image without /ImageMask.');
  45955. } else {
  45956. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  45957. }
  45958. } else {
  45959. this.mask = mask;
  45960. }
  45961. }
  45962. }
  45963. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  45964. var imagePromise = handleImageData(image, nativeDecoder);
  45965. var smaskPromise;
  45966. var maskPromise;
  45967. var smask = image.dict.get('SMask');
  45968. var mask = image.dict.get('Mask');
  45969. if (smask) {
  45970. smaskPromise = handleImageData(smask, nativeDecoder);
  45971. maskPromise = Promise.resolve(null);
  45972. } else {
  45973. smaskPromise = Promise.resolve(null);
  45974. if (mask) {
  45975. if (isStream(mask)) {
  45976. maskPromise = handleImageData(mask, nativeDecoder);
  45977. } else if (isArray(mask)) {
  45978. maskPromise = Promise.resolve(mask);
  45979. } else {
  45980. warn('Unsupported mask format.');
  45981. maskPromise = Promise.resolve(null);
  45982. }
  45983. } else {
  45984. maskPromise = Promise.resolve(null);
  45985. }
  45986. }
  45987. return Promise.all([
  45988. imagePromise,
  45989. smaskPromise,
  45990. maskPromise
  45991. ]).then(function (results) {
  45992. var imageData = results[0];
  45993. var smaskData = results[1];
  45994. var maskData = results[2];
  45995. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  45996. });
  45997. };
  45998. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  45999. var computedLength = (width + 7 >> 3) * height;
  46000. var actualLength = imgArray.byteLength;
  46001. var haveFullData = computedLength === actualLength;
  46002. var data, i;
  46003. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46004. data = imgArray;
  46005. } else if (!inverseDecode) {
  46006. data = new Uint8Array(actualLength);
  46007. data.set(imgArray);
  46008. } else {
  46009. data = new Uint8Array(computedLength);
  46010. data.set(imgArray);
  46011. for (i = actualLength; i < computedLength; i++) {
  46012. data[i] = 0xff;
  46013. }
  46014. }
  46015. if (inverseDecode) {
  46016. for (i = 0; i < actualLength; i++) {
  46017. data[i] = ~data[i];
  46018. }
  46019. }
  46020. return {
  46021. data: data,
  46022. width: width,
  46023. height: height
  46024. };
  46025. };
  46026. PDFImage.prototype = {
  46027. get drawWidth() {
  46028. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46029. },
  46030. get drawHeight() {
  46031. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46032. },
  46033. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46034. var bpc = this.bpc;
  46035. var numComps = this.numComps;
  46036. var decodeAddends = this.decodeAddends;
  46037. var decodeCoefficients = this.decodeCoefficients;
  46038. var max = (1 << bpc) - 1;
  46039. var i, ii;
  46040. if (bpc === 1) {
  46041. for (i = 0, ii = buffer.length; i < ii; i++) {
  46042. buffer[i] = +!buffer[i];
  46043. }
  46044. return;
  46045. }
  46046. var index = 0;
  46047. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46048. for (var j = 0; j < numComps; j++) {
  46049. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46050. index++;
  46051. }
  46052. }
  46053. },
  46054. getComponents: function PDFImage_getComponents(buffer) {
  46055. var bpc = this.bpc;
  46056. if (bpc === 8) {
  46057. return buffer;
  46058. }
  46059. var width = this.width;
  46060. var height = this.height;
  46061. var numComps = this.numComps;
  46062. var length = width * height * numComps;
  46063. var bufferPos = 0;
  46064. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46065. var rowComps = width * numComps;
  46066. var max = (1 << bpc) - 1;
  46067. var i = 0, ii, buf;
  46068. if (bpc === 1) {
  46069. var mask, loop1End, loop2End;
  46070. for (var j = 0; j < height; j++) {
  46071. loop1End = i + (rowComps & ~7);
  46072. loop2End = i + rowComps;
  46073. while (i < loop1End) {
  46074. buf = buffer[bufferPos++];
  46075. output[i] = buf >> 7 & 1;
  46076. output[i + 1] = buf >> 6 & 1;
  46077. output[i + 2] = buf >> 5 & 1;
  46078. output[i + 3] = buf >> 4 & 1;
  46079. output[i + 4] = buf >> 3 & 1;
  46080. output[i + 5] = buf >> 2 & 1;
  46081. output[i + 6] = buf >> 1 & 1;
  46082. output[i + 7] = buf & 1;
  46083. i += 8;
  46084. }
  46085. if (i < loop2End) {
  46086. buf = buffer[bufferPos++];
  46087. mask = 128;
  46088. while (i < loop2End) {
  46089. output[i++] = +!!(buf & mask);
  46090. mask >>= 1;
  46091. }
  46092. }
  46093. }
  46094. } else {
  46095. var bits = 0;
  46096. buf = 0;
  46097. for (i = 0, ii = length; i < ii; ++i) {
  46098. if (i % rowComps === 0) {
  46099. buf = 0;
  46100. bits = 0;
  46101. }
  46102. while (bits < bpc) {
  46103. buf = buf << 8 | buffer[bufferPos++];
  46104. bits += 8;
  46105. }
  46106. var remainingBits = bits - bpc;
  46107. var value = buf >> remainingBits;
  46108. output[i] = value < 0 ? 0 : value > max ? max : value;
  46109. buf = buf & (1 << remainingBits) - 1;
  46110. bits = remainingBits;
  46111. }
  46112. }
  46113. return output;
  46114. },
  46115. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46116. var smask = this.smask;
  46117. var mask = this.mask;
  46118. var alphaBuf, sw, sh, i, ii, j;
  46119. if (smask) {
  46120. sw = smask.width;
  46121. sh = smask.height;
  46122. alphaBuf = new Uint8Array(sw * sh);
  46123. smask.fillGrayBuffer(alphaBuf);
  46124. if (sw !== width || sh !== height) {
  46125. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46126. }
  46127. } else if (mask) {
  46128. if (mask instanceof PDFImage) {
  46129. sw = mask.width;
  46130. sh = mask.height;
  46131. alphaBuf = new Uint8Array(sw * sh);
  46132. mask.numComps = 1;
  46133. mask.fillGrayBuffer(alphaBuf);
  46134. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46135. alphaBuf[i] = 255 - alphaBuf[i];
  46136. }
  46137. if (sw !== width || sh !== height) {
  46138. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46139. }
  46140. } else if (isArray(mask)) {
  46141. alphaBuf = new Uint8Array(width * height);
  46142. var numComps = this.numComps;
  46143. for (i = 0, ii = width * height; i < ii; ++i) {
  46144. var opacity = 0;
  46145. var imageOffset = i * numComps;
  46146. for (j = 0; j < numComps; ++j) {
  46147. var color = image[imageOffset + j];
  46148. var maskOffset = j * 2;
  46149. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46150. opacity = 255;
  46151. break;
  46152. }
  46153. }
  46154. alphaBuf[i] = opacity;
  46155. }
  46156. } else {
  46157. error('Unknown mask format.');
  46158. }
  46159. }
  46160. if (alphaBuf) {
  46161. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46162. rgbaBuf[j] = alphaBuf[i];
  46163. }
  46164. } else {
  46165. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46166. rgbaBuf[j] = 255;
  46167. }
  46168. }
  46169. },
  46170. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46171. var matte = this.smask && this.smask.matte;
  46172. if (!matte) {
  46173. return;
  46174. }
  46175. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46176. var matteR = matteRgb[0];
  46177. var matteG = matteRgb[1];
  46178. var matteB = matteRgb[2];
  46179. var length = width * height * 4;
  46180. var r, g, b;
  46181. for (var i = 0; i < length; i += 4) {
  46182. var alpha = buffer[i + 3];
  46183. if (alpha === 0) {
  46184. buffer[i] = 255;
  46185. buffer[i + 1] = 255;
  46186. buffer[i + 2] = 255;
  46187. continue;
  46188. }
  46189. var k = 255 / alpha;
  46190. r = (buffer[i] - matteR) * k + matteR;
  46191. g = (buffer[i + 1] - matteG) * k + matteG;
  46192. b = (buffer[i + 2] - matteB) * k + matteB;
  46193. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  46194. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  46195. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  46196. }
  46197. },
  46198. createImageData: function PDFImage_createImageData(forceRGBA) {
  46199. var drawWidth = this.drawWidth;
  46200. var drawHeight = this.drawHeight;
  46201. var imgData = {
  46202. width: drawWidth,
  46203. height: drawHeight
  46204. };
  46205. var numComps = this.numComps;
  46206. var originalWidth = this.width;
  46207. var originalHeight = this.height;
  46208. var bpc = this.bpc;
  46209. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  46210. var imgArray;
  46211. if (!forceRGBA) {
  46212. var kind;
  46213. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  46214. kind = ImageKind.GRAYSCALE_1BPP;
  46215. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  46216. kind = ImageKind.RGB_24BPP;
  46217. }
  46218. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  46219. imgData.kind = kind;
  46220. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46221. if (this.image instanceof DecodeStream) {
  46222. imgData.data = imgArray;
  46223. } else {
  46224. var newArray = new Uint8Array(imgArray.length);
  46225. newArray.set(imgArray);
  46226. imgData.data = newArray;
  46227. }
  46228. if (this.needsDecode) {
  46229. assert(kind === ImageKind.GRAYSCALE_1BPP);
  46230. var buffer = imgData.data;
  46231. for (var i = 0, ii = buffer.length; i < ii; i++) {
  46232. buffer[i] ^= 0xff;
  46233. }
  46234. }
  46235. return imgData;
  46236. }
  46237. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  46238. imgData.kind = ImageKind.RGB_24BPP;
  46239. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  46240. return imgData;
  46241. }
  46242. }
  46243. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46244. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  46245. var comps = this.getComponents(imgArray);
  46246. var alpha01, maybeUndoPreblend;
  46247. if (!forceRGBA && !this.smask && !this.mask) {
  46248. imgData.kind = ImageKind.RGB_24BPP;
  46249. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  46250. alpha01 = 0;
  46251. maybeUndoPreblend = false;
  46252. } else {
  46253. imgData.kind = ImageKind.RGBA_32BPP;
  46254. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  46255. alpha01 = 1;
  46256. maybeUndoPreblend = true;
  46257. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  46258. }
  46259. if (this.needsDecode) {
  46260. this.decodeBuffer(comps);
  46261. }
  46262. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  46263. if (maybeUndoPreblend) {
  46264. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  46265. }
  46266. return imgData;
  46267. },
  46268. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  46269. var numComps = this.numComps;
  46270. if (numComps !== 1) {
  46271. error('Reading gray scale from a color image: ' + numComps);
  46272. }
  46273. var width = this.width;
  46274. var height = this.height;
  46275. var bpc = this.bpc;
  46276. var rowBytes = width * numComps * bpc + 7 >> 3;
  46277. var imgArray = this.getImageBytes(height * rowBytes);
  46278. var comps = this.getComponents(imgArray);
  46279. var i, length;
  46280. if (bpc === 1) {
  46281. length = width * height;
  46282. if (this.needsDecode) {
  46283. for (i = 0; i < length; ++i) {
  46284. buffer[i] = comps[i] - 1 & 255;
  46285. }
  46286. } else {
  46287. for (i = 0; i < length; ++i) {
  46288. buffer[i] = -comps[i] & 255;
  46289. }
  46290. }
  46291. return;
  46292. }
  46293. if (this.needsDecode) {
  46294. this.decodeBuffer(comps);
  46295. }
  46296. length = width * height;
  46297. var scale = 255 / ((1 << bpc) - 1);
  46298. for (i = 0; i < length; ++i) {
  46299. buffer[i] = scale * comps[i] | 0;
  46300. }
  46301. },
  46302. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  46303. this.image.reset();
  46304. this.image.drawWidth = drawWidth || this.width;
  46305. this.image.drawHeight = drawHeight || this.height;
  46306. this.image.forceRGB = !!forceRGB;
  46307. return this.image.getBytes(length);
  46308. }
  46309. };
  46310. return PDFImage;
  46311. }();
  46312. exports.PDFImage = PDFImage;
  46313. /***/ }),
  46314. /* 35 */
  46315. /***/ (function(module, exports, __w_pdfjs_require__) {
  46316. "use strict";
  46317. var sharedUtil = __w_pdfjs_require__(0);
  46318. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  46319. var error = sharedUtil.error;
  46320. var log2 = sharedUtil.log2;
  46321. var readInt8 = sharedUtil.readInt8;
  46322. var readUint16 = sharedUtil.readUint16;
  46323. var readUint32 = sharedUtil.readUint32;
  46324. var shadow = sharedUtil.shadow;
  46325. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  46326. var Jbig2Image = function Jbig2ImageClosure() {
  46327. function ContextCache() {
  46328. }
  46329. ContextCache.prototype = {
  46330. getContexts: function (id) {
  46331. if (id in this) {
  46332. return this[id];
  46333. }
  46334. return this[id] = new Int8Array(1 << 16);
  46335. }
  46336. };
  46337. function DecodingContext(data, start, end) {
  46338. this.data = data;
  46339. this.start = start;
  46340. this.end = end;
  46341. }
  46342. DecodingContext.prototype = {
  46343. get decoder() {
  46344. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  46345. return shadow(this, 'decoder', decoder);
  46346. },
  46347. get contextCache() {
  46348. var cache = new ContextCache();
  46349. return shadow(this, 'contextCache', cache);
  46350. }
  46351. };
  46352. function decodeInteger(contextCache, procedure, decoder) {
  46353. var contexts = contextCache.getContexts(procedure);
  46354. var prev = 1;
  46355. function readBits(length) {
  46356. var v = 0;
  46357. for (var i = 0; i < length; i++) {
  46358. var bit = decoder.readBit(contexts, prev);
  46359. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  46360. v = v << 1 | bit;
  46361. }
  46362. return v >>> 0;
  46363. }
  46364. var sign = readBits(1);
  46365. 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);
  46366. return sign === 0 ? value : value > 0 ? -value : null;
  46367. }
  46368. function decodeIAID(contextCache, decoder, codeLength) {
  46369. var contexts = contextCache.getContexts('IAID');
  46370. var prev = 1;
  46371. for (var i = 0; i < codeLength; i++) {
  46372. var bit = decoder.readBit(contexts, prev);
  46373. prev = prev << 1 | bit;
  46374. }
  46375. if (codeLength < 31) {
  46376. return prev & (1 << codeLength) - 1;
  46377. }
  46378. return prev & 0x7FFFFFFF;
  46379. }
  46380. var SegmentTypes = [
  46381. 'SymbolDictionary',
  46382. null,
  46383. null,
  46384. null,
  46385. 'IntermediateTextRegion',
  46386. null,
  46387. 'ImmediateTextRegion',
  46388. 'ImmediateLosslessTextRegion',
  46389. null,
  46390. null,
  46391. null,
  46392. null,
  46393. null,
  46394. null,
  46395. null,
  46396. null,
  46397. 'patternDictionary',
  46398. null,
  46399. null,
  46400. null,
  46401. 'IntermediateHalftoneRegion',
  46402. null,
  46403. 'ImmediateHalftoneRegion',
  46404. 'ImmediateLosslessHalftoneRegion',
  46405. null,
  46406. null,
  46407. null,
  46408. null,
  46409. null,
  46410. null,
  46411. null,
  46412. null,
  46413. null,
  46414. null,
  46415. null,
  46416. null,
  46417. 'IntermediateGenericRegion',
  46418. null,
  46419. 'ImmediateGenericRegion',
  46420. 'ImmediateLosslessGenericRegion',
  46421. 'IntermediateGenericRefinementRegion',
  46422. null,
  46423. 'ImmediateGenericRefinementRegion',
  46424. 'ImmediateLosslessGenericRefinementRegion',
  46425. null,
  46426. null,
  46427. null,
  46428. null,
  46429. 'PageInformation',
  46430. 'EndOfPage',
  46431. 'EndOfStripe',
  46432. 'EndOfFile',
  46433. 'Profiles',
  46434. 'Tables',
  46435. null,
  46436. null,
  46437. null,
  46438. null,
  46439. null,
  46440. null,
  46441. null,
  46442. null,
  46443. 'Extension'
  46444. ];
  46445. var CodingTemplates = [
  46446. [
  46447. {
  46448. x: -1,
  46449. y: -2
  46450. },
  46451. {
  46452. x: 0,
  46453. y: -2
  46454. },
  46455. {
  46456. x: 1,
  46457. y: -2
  46458. },
  46459. {
  46460. x: -2,
  46461. y: -1
  46462. },
  46463. {
  46464. x: -1,
  46465. y: -1
  46466. },
  46467. {
  46468. x: 0,
  46469. y: -1
  46470. },
  46471. {
  46472. x: 1,
  46473. y: -1
  46474. },
  46475. {
  46476. x: 2,
  46477. y: -1
  46478. },
  46479. {
  46480. x: -4,
  46481. y: 0
  46482. },
  46483. {
  46484. x: -3,
  46485. y: 0
  46486. },
  46487. {
  46488. x: -2,
  46489. y: 0
  46490. },
  46491. {
  46492. x: -1,
  46493. y: 0
  46494. }
  46495. ],
  46496. [
  46497. {
  46498. x: -1,
  46499. y: -2
  46500. },
  46501. {
  46502. x: 0,
  46503. y: -2
  46504. },
  46505. {
  46506. x: 1,
  46507. y: -2
  46508. },
  46509. {
  46510. x: 2,
  46511. y: -2
  46512. },
  46513. {
  46514. x: -2,
  46515. y: -1
  46516. },
  46517. {
  46518. x: -1,
  46519. y: -1
  46520. },
  46521. {
  46522. x: 0,
  46523. y: -1
  46524. },
  46525. {
  46526. x: 1,
  46527. y: -1
  46528. },
  46529. {
  46530. x: 2,
  46531. y: -1
  46532. },
  46533. {
  46534. x: -3,
  46535. y: 0
  46536. },
  46537. {
  46538. x: -2,
  46539. y: 0
  46540. },
  46541. {
  46542. x: -1,
  46543. y: 0
  46544. }
  46545. ],
  46546. [
  46547. {
  46548. x: -1,
  46549. y: -2
  46550. },
  46551. {
  46552. x: 0,
  46553. y: -2
  46554. },
  46555. {
  46556. x: 1,
  46557. y: -2
  46558. },
  46559. {
  46560. x: -2,
  46561. y: -1
  46562. },
  46563. {
  46564. x: -1,
  46565. y: -1
  46566. },
  46567. {
  46568. x: 0,
  46569. y: -1
  46570. },
  46571. {
  46572. x: 1,
  46573. y: -1
  46574. },
  46575. {
  46576. x: -2,
  46577. y: 0
  46578. },
  46579. {
  46580. x: -1,
  46581. y: 0
  46582. }
  46583. ],
  46584. [
  46585. {
  46586. x: -3,
  46587. y: -1
  46588. },
  46589. {
  46590. x: -2,
  46591. y: -1
  46592. },
  46593. {
  46594. x: -1,
  46595. y: -1
  46596. },
  46597. {
  46598. x: 0,
  46599. y: -1
  46600. },
  46601. {
  46602. x: 1,
  46603. y: -1
  46604. },
  46605. {
  46606. x: -4,
  46607. y: 0
  46608. },
  46609. {
  46610. x: -3,
  46611. y: 0
  46612. },
  46613. {
  46614. x: -2,
  46615. y: 0
  46616. },
  46617. {
  46618. x: -1,
  46619. y: 0
  46620. }
  46621. ]
  46622. ];
  46623. var RefinementTemplates = [
  46624. {
  46625. coding: [
  46626. {
  46627. x: 0,
  46628. y: -1
  46629. },
  46630. {
  46631. x: 1,
  46632. y: -1
  46633. },
  46634. {
  46635. x: -1,
  46636. y: 0
  46637. }
  46638. ],
  46639. reference: [
  46640. {
  46641. x: 0,
  46642. y: -1
  46643. },
  46644. {
  46645. x: 1,
  46646. y: -1
  46647. },
  46648. {
  46649. x: -1,
  46650. y: 0
  46651. },
  46652. {
  46653. x: 0,
  46654. y: 0
  46655. },
  46656. {
  46657. x: 1,
  46658. y: 0
  46659. },
  46660. {
  46661. x: -1,
  46662. y: 1
  46663. },
  46664. {
  46665. x: 0,
  46666. y: 1
  46667. },
  46668. {
  46669. x: 1,
  46670. y: 1
  46671. }
  46672. ]
  46673. },
  46674. {
  46675. coding: [
  46676. {
  46677. x: -1,
  46678. y: -1
  46679. },
  46680. {
  46681. x: 0,
  46682. y: -1
  46683. },
  46684. {
  46685. x: 1,
  46686. y: -1
  46687. },
  46688. {
  46689. x: -1,
  46690. y: 0
  46691. }
  46692. ],
  46693. reference: [
  46694. {
  46695. x: 0,
  46696. y: -1
  46697. },
  46698. {
  46699. x: -1,
  46700. y: 0
  46701. },
  46702. {
  46703. x: 0,
  46704. y: 0
  46705. },
  46706. {
  46707. x: 1,
  46708. y: 0
  46709. },
  46710. {
  46711. x: 0,
  46712. y: 1
  46713. },
  46714. {
  46715. x: 1,
  46716. y: 1
  46717. }
  46718. ]
  46719. }
  46720. ];
  46721. var ReusedContexts = [
  46722. 0x9B25,
  46723. 0x0795,
  46724. 0x00E5,
  46725. 0x0195
  46726. ];
  46727. var RefinementReusedContexts = [
  46728. 0x0020,
  46729. 0x0008
  46730. ];
  46731. function decodeBitmapTemplate0(width, height, decodingContext) {
  46732. var decoder = decodingContext.decoder;
  46733. var contexts = decodingContext.contextCache.getContexts('GB');
  46734. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  46735. var OLD_PIXEL_MASK = 0x7BF7;
  46736. for (i = 0; i < height; i++) {
  46737. row = bitmap[i] = new Uint8Array(width);
  46738. row1 = i < 1 ? row : bitmap[i - 1];
  46739. row2 = i < 2 ? row : bitmap[i - 2];
  46740. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  46741. for (j = 0; j < width; j++) {
  46742. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  46743. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  46744. }
  46745. }
  46746. return bitmap;
  46747. }
  46748. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  46749. if (mmr) {
  46750. error('JBIG2 error: MMR encoding is not supported');
  46751. }
  46752. 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) {
  46753. return decodeBitmapTemplate0(width, height, decodingContext);
  46754. }
  46755. var useskip = !!skip;
  46756. var template = CodingTemplates[templateIndex].concat(at);
  46757. template.sort(function (a, b) {
  46758. return a.y - b.y || a.x - b.x;
  46759. });
  46760. var templateLength = template.length;
  46761. var templateX = new Int8Array(templateLength);
  46762. var templateY = new Int8Array(templateLength);
  46763. var changingTemplateEntries = [];
  46764. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  46765. var c, k;
  46766. for (k = 0; k < templateLength; k++) {
  46767. templateX[k] = template[k].x;
  46768. templateY[k] = template[k].y;
  46769. minX = Math.min(minX, template[k].x);
  46770. maxX = Math.max(maxX, template[k].x);
  46771. minY = Math.min(minY, template[k].y);
  46772. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  46773. reuseMask |= 1 << templateLength - 1 - k;
  46774. } else {
  46775. changingTemplateEntries.push(k);
  46776. }
  46777. }
  46778. var changingEntriesLength = changingTemplateEntries.length;
  46779. var changingTemplateX = new Int8Array(changingEntriesLength);
  46780. var changingTemplateY = new Int8Array(changingEntriesLength);
  46781. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  46782. for (c = 0; c < changingEntriesLength; c++) {
  46783. k = changingTemplateEntries[c];
  46784. changingTemplateX[c] = template[k].x;
  46785. changingTemplateY[c] = template[k].y;
  46786. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  46787. }
  46788. var sbb_left = -minX;
  46789. var sbb_top = -minY;
  46790. var sbb_right = width - maxX;
  46791. var pseudoPixelContext = ReusedContexts[templateIndex];
  46792. var row = new Uint8Array(width);
  46793. var bitmap = [];
  46794. var decoder = decodingContext.decoder;
  46795. var contexts = decodingContext.contextCache.getContexts('GB');
  46796. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  46797. for (var i = 0; i < height; i++) {
  46798. if (prediction) {
  46799. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46800. ltp ^= sltp;
  46801. if (ltp) {
  46802. bitmap.push(row);
  46803. continue;
  46804. }
  46805. }
  46806. row = new Uint8Array(row);
  46807. bitmap.push(row);
  46808. for (j = 0; j < width; j++) {
  46809. if (useskip && skip[i][j]) {
  46810. row[j] = 0;
  46811. continue;
  46812. }
  46813. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  46814. contextLabel = contextLabel << 1 & reuseMask;
  46815. for (k = 0; k < changingEntriesLength; k++) {
  46816. i0 = i + changingTemplateY[k];
  46817. j0 = j + changingTemplateX[k];
  46818. bit = bitmap[i0][j0];
  46819. if (bit) {
  46820. bit = changingTemplateBit[k];
  46821. contextLabel |= bit;
  46822. }
  46823. }
  46824. } else {
  46825. contextLabel = 0;
  46826. shift = templateLength - 1;
  46827. for (k = 0; k < templateLength; k++, shift--) {
  46828. j0 = j + templateX[k];
  46829. if (j0 >= 0 && j0 < width) {
  46830. i0 = i + templateY[k];
  46831. if (i0 >= 0) {
  46832. bit = bitmap[i0][j0];
  46833. if (bit) {
  46834. contextLabel |= bit << shift;
  46835. }
  46836. }
  46837. }
  46838. }
  46839. }
  46840. var pixel = decoder.readBit(contexts, contextLabel);
  46841. row[j] = pixel;
  46842. }
  46843. }
  46844. return bitmap;
  46845. }
  46846. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  46847. var codingTemplate = RefinementTemplates[templateIndex].coding;
  46848. if (templateIndex === 0) {
  46849. codingTemplate = codingTemplate.concat([at[0]]);
  46850. }
  46851. var codingTemplateLength = codingTemplate.length;
  46852. var codingTemplateX = new Int32Array(codingTemplateLength);
  46853. var codingTemplateY = new Int32Array(codingTemplateLength);
  46854. var k;
  46855. for (k = 0; k < codingTemplateLength; k++) {
  46856. codingTemplateX[k] = codingTemplate[k].x;
  46857. codingTemplateY[k] = codingTemplate[k].y;
  46858. }
  46859. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  46860. if (templateIndex === 0) {
  46861. referenceTemplate = referenceTemplate.concat([at[1]]);
  46862. }
  46863. var referenceTemplateLength = referenceTemplate.length;
  46864. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  46865. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  46866. for (k = 0; k < referenceTemplateLength; k++) {
  46867. referenceTemplateX[k] = referenceTemplate[k].x;
  46868. referenceTemplateY[k] = referenceTemplate[k].y;
  46869. }
  46870. var referenceWidth = referenceBitmap[0].length;
  46871. var referenceHeight = referenceBitmap.length;
  46872. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  46873. var bitmap = [];
  46874. var decoder = decodingContext.decoder;
  46875. var contexts = decodingContext.contextCache.getContexts('GR');
  46876. var ltp = 0;
  46877. for (var i = 0; i < height; i++) {
  46878. if (prediction) {
  46879. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46880. ltp ^= sltp;
  46881. if (ltp) {
  46882. error('JBIG2 error: prediction is not supported');
  46883. }
  46884. }
  46885. var row = new Uint8Array(width);
  46886. bitmap.push(row);
  46887. for (var j = 0; j < width; j++) {
  46888. var i0, j0;
  46889. var contextLabel = 0;
  46890. for (k = 0; k < codingTemplateLength; k++) {
  46891. i0 = i + codingTemplateY[k];
  46892. j0 = j + codingTemplateX[k];
  46893. if (i0 < 0 || j0 < 0 || j0 >= width) {
  46894. contextLabel <<= 1;
  46895. } else {
  46896. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  46897. }
  46898. }
  46899. for (k = 0; k < referenceTemplateLength; k++) {
  46900. i0 = i + referenceTemplateY[k] + offsetY;
  46901. j0 = j + referenceTemplateX[k] + offsetX;
  46902. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  46903. contextLabel <<= 1;
  46904. } else {
  46905. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  46906. }
  46907. }
  46908. var pixel = decoder.readBit(contexts, contextLabel);
  46909. row[j] = pixel;
  46910. }
  46911. }
  46912. return bitmap;
  46913. }
  46914. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  46915. if (huffman) {
  46916. error('JBIG2 error: huffman is not supported');
  46917. }
  46918. var newSymbols = [];
  46919. var currentHeight = 0;
  46920. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  46921. var decoder = decodingContext.decoder;
  46922. var contextCache = decodingContext.contextCache;
  46923. while (newSymbols.length < numberOfNewSymbols) {
  46924. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  46925. currentHeight += deltaHeight;
  46926. var currentWidth = 0;
  46927. while (true) {
  46928. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  46929. if (deltaWidth === null) {
  46930. break;
  46931. }
  46932. currentWidth += deltaWidth;
  46933. var bitmap;
  46934. if (refinement) {
  46935. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  46936. if (numberOfInstances > 1) {
  46937. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  46938. } else {
  46939. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  46940. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  46941. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  46942. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  46943. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  46944. }
  46945. } else {
  46946. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  46947. }
  46948. newSymbols.push(bitmap);
  46949. }
  46950. }
  46951. var exportedSymbols = [];
  46952. var flags = [], currentFlag = false;
  46953. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  46954. while (flags.length < totalSymbolsLength) {
  46955. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  46956. while (runLength--) {
  46957. flags.push(currentFlag);
  46958. }
  46959. currentFlag = !currentFlag;
  46960. }
  46961. for (var i = 0, ii = symbols.length; i < ii; i++) {
  46962. if (flags[i]) {
  46963. exportedSymbols.push(symbols[i]);
  46964. }
  46965. }
  46966. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  46967. if (flags[i]) {
  46968. exportedSymbols.push(newSymbols[j]);
  46969. }
  46970. }
  46971. return exportedSymbols;
  46972. }
  46973. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  46974. if (huffman) {
  46975. error('JBIG2 error: huffman is not supported');
  46976. }
  46977. var bitmap = [];
  46978. var i, row;
  46979. for (i = 0; i < height; i++) {
  46980. row = new Uint8Array(width);
  46981. if (defaultPixelValue) {
  46982. for (var j = 0; j < width; j++) {
  46983. row[j] = defaultPixelValue;
  46984. }
  46985. }
  46986. bitmap.push(row);
  46987. }
  46988. var decoder = decodingContext.decoder;
  46989. var contextCache = decodingContext.contextCache;
  46990. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  46991. var firstS = 0;
  46992. i = 0;
  46993. while (i < numberOfSymbolInstances) {
  46994. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  46995. stripT += deltaT;
  46996. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  46997. firstS += deltaFirstS;
  46998. var currentS = firstS;
  46999. do {
  47000. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47001. var t = stripSize * stripT + currentT;
  47002. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47003. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47004. var symbolBitmap = inputSymbols[symbolId];
  47005. var symbolWidth = symbolBitmap[0].length;
  47006. var symbolHeight = symbolBitmap.length;
  47007. if (applyRefinement) {
  47008. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47009. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47010. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47011. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47012. symbolWidth += rdw;
  47013. symbolHeight += rdh;
  47014. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47015. }
  47016. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47017. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47018. var s2, t2, symbolRow;
  47019. if (transposed) {
  47020. for (s2 = 0; s2 < symbolHeight; s2++) {
  47021. row = bitmap[offsetS + s2];
  47022. if (!row) {
  47023. continue;
  47024. }
  47025. symbolRow = symbolBitmap[s2];
  47026. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47027. switch (combinationOperator) {
  47028. case 0:
  47029. for (t2 = 0; t2 < maxWidth; t2++) {
  47030. row[offsetT + t2] |= symbolRow[t2];
  47031. }
  47032. break;
  47033. case 2:
  47034. for (t2 = 0; t2 < maxWidth; t2++) {
  47035. row[offsetT + t2] ^= symbolRow[t2];
  47036. }
  47037. break;
  47038. default:
  47039. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47040. }
  47041. }
  47042. currentS += symbolHeight - 1;
  47043. } else {
  47044. for (t2 = 0; t2 < symbolHeight; t2++) {
  47045. row = bitmap[offsetT + t2];
  47046. if (!row) {
  47047. continue;
  47048. }
  47049. symbolRow = symbolBitmap[t2];
  47050. switch (combinationOperator) {
  47051. case 0:
  47052. for (s2 = 0; s2 < symbolWidth; s2++) {
  47053. row[offsetS + s2] |= symbolRow[s2];
  47054. }
  47055. break;
  47056. case 2:
  47057. for (s2 = 0; s2 < symbolWidth; s2++) {
  47058. row[offsetS + s2] ^= symbolRow[s2];
  47059. }
  47060. break;
  47061. default:
  47062. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47063. }
  47064. }
  47065. currentS += symbolWidth - 1;
  47066. }
  47067. i++;
  47068. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47069. if (deltaS === null) {
  47070. break;
  47071. }
  47072. currentS += deltaS + dsOffset;
  47073. } while (true);
  47074. }
  47075. return bitmap;
  47076. }
  47077. function readSegmentHeader(data, start) {
  47078. var segmentHeader = {};
  47079. segmentHeader.number = readUint32(data, start);
  47080. var flags = data[start + 4];
  47081. var segmentType = flags & 0x3F;
  47082. if (!SegmentTypes[segmentType]) {
  47083. error('JBIG2 error: invalid segment type: ' + segmentType);
  47084. }
  47085. segmentHeader.type = segmentType;
  47086. segmentHeader.typeName = SegmentTypes[segmentType];
  47087. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47088. var pageAssociationFieldSize = !!(flags & 0x40);
  47089. var referredFlags = data[start + 5];
  47090. var referredToCount = referredFlags >> 5 & 7;
  47091. var retainBits = [referredFlags & 31];
  47092. var position = start + 6;
  47093. if (referredFlags === 7) {
  47094. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47095. position += 3;
  47096. var bytes = referredToCount + 7 >> 3;
  47097. retainBits[0] = data[position++];
  47098. while (--bytes > 0) {
  47099. retainBits.push(data[position++]);
  47100. }
  47101. } else if (referredFlags === 5 || referredFlags === 6) {
  47102. error('JBIG2 error: invalid referred-to flags');
  47103. }
  47104. segmentHeader.retainBits = retainBits;
  47105. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47106. var referredTo = [];
  47107. var i, ii;
  47108. for (i = 0; i < referredToCount; i++) {
  47109. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47110. referredTo.push(number);
  47111. position += referredToSegmentNumberSize;
  47112. }
  47113. segmentHeader.referredTo = referredTo;
  47114. if (!pageAssociationFieldSize) {
  47115. segmentHeader.pageAssociation = data[position++];
  47116. } else {
  47117. segmentHeader.pageAssociation = readUint32(data, position);
  47118. position += 4;
  47119. }
  47120. segmentHeader.length = readUint32(data, position);
  47121. position += 4;
  47122. if (segmentHeader.length === 0xFFFFFFFF) {
  47123. if (segmentType === 38) {
  47124. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47125. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47126. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47127. var searchPatternLength = 6;
  47128. var searchPattern = new Uint8Array(searchPatternLength);
  47129. if (!genericRegionMmr) {
  47130. searchPattern[0] = 0xFF;
  47131. searchPattern[1] = 0xAC;
  47132. }
  47133. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47134. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47135. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47136. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47137. for (i = position, ii = data.length; i < ii; i++) {
  47138. var j = 0;
  47139. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47140. j++;
  47141. }
  47142. if (j === searchPatternLength) {
  47143. segmentHeader.length = i + searchPatternLength;
  47144. break;
  47145. }
  47146. }
  47147. if (segmentHeader.length === 0xFFFFFFFF) {
  47148. error('JBIG2 error: segment end was not found');
  47149. }
  47150. } else {
  47151. error('JBIG2 error: invalid unknown segment length');
  47152. }
  47153. }
  47154. segmentHeader.headerEnd = position;
  47155. return segmentHeader;
  47156. }
  47157. function readSegments(header, data, start, end) {
  47158. var segments = [];
  47159. var position = start;
  47160. while (position < end) {
  47161. var segmentHeader = readSegmentHeader(data, position);
  47162. position = segmentHeader.headerEnd;
  47163. var segment = {
  47164. header: segmentHeader,
  47165. data: data
  47166. };
  47167. if (!header.randomAccess) {
  47168. segment.start = position;
  47169. position += segmentHeader.length;
  47170. segment.end = position;
  47171. }
  47172. segments.push(segment);
  47173. if (segmentHeader.type === 51) {
  47174. break;
  47175. }
  47176. }
  47177. if (header.randomAccess) {
  47178. for (var i = 0, ii = segments.length; i < ii; i++) {
  47179. segments[i].start = position;
  47180. position += segments[i].header.length;
  47181. segments[i].end = position;
  47182. }
  47183. }
  47184. return segments;
  47185. }
  47186. function readRegionSegmentInformation(data, start) {
  47187. return {
  47188. width: readUint32(data, start),
  47189. height: readUint32(data, start + 4),
  47190. x: readUint32(data, start + 8),
  47191. y: readUint32(data, start + 12),
  47192. combinationOperator: data[start + 16] & 7
  47193. };
  47194. }
  47195. var RegionSegmentInformationFieldLength = 17;
  47196. function processSegment(segment, visitor) {
  47197. var header = segment.header;
  47198. var data = segment.data, position = segment.start, end = segment.end;
  47199. var args, at, i, atLength;
  47200. switch (header.type) {
  47201. case 0:
  47202. var dictionary = {};
  47203. var dictionaryFlags = readUint16(data, position);
  47204. dictionary.huffman = !!(dictionaryFlags & 1);
  47205. dictionary.refinement = !!(dictionaryFlags & 2);
  47206. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  47207. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  47208. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  47209. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  47210. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  47211. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  47212. dictionary.template = dictionaryFlags >> 10 & 3;
  47213. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  47214. position += 2;
  47215. if (!dictionary.huffman) {
  47216. atLength = dictionary.template === 0 ? 4 : 1;
  47217. at = [];
  47218. for (i = 0; i < atLength; i++) {
  47219. at.push({
  47220. x: readInt8(data, position),
  47221. y: readInt8(data, position + 1)
  47222. });
  47223. position += 2;
  47224. }
  47225. dictionary.at = at;
  47226. }
  47227. if (dictionary.refinement && !dictionary.refinementTemplate) {
  47228. at = [];
  47229. for (i = 0; i < 2; i++) {
  47230. at.push({
  47231. x: readInt8(data, position),
  47232. y: readInt8(data, position + 1)
  47233. });
  47234. position += 2;
  47235. }
  47236. dictionary.refinementAt = at;
  47237. }
  47238. dictionary.numberOfExportedSymbols = readUint32(data, position);
  47239. position += 4;
  47240. dictionary.numberOfNewSymbols = readUint32(data, position);
  47241. position += 4;
  47242. args = [
  47243. dictionary,
  47244. header.number,
  47245. header.referredTo,
  47246. data,
  47247. position,
  47248. end
  47249. ];
  47250. break;
  47251. case 6:
  47252. case 7:
  47253. var textRegion = {};
  47254. textRegion.info = readRegionSegmentInformation(data, position);
  47255. position += RegionSegmentInformationFieldLength;
  47256. var textRegionSegmentFlags = readUint16(data, position);
  47257. position += 2;
  47258. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  47259. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  47260. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  47261. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  47262. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  47263. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  47264. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  47265. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  47266. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  47267. if (textRegion.huffman) {
  47268. var textRegionHuffmanFlags = readUint16(data, position);
  47269. position += 2;
  47270. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  47271. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  47272. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  47273. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  47274. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  47275. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  47276. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  47277. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  47278. }
  47279. if (textRegion.refinement && !textRegion.refinementTemplate) {
  47280. at = [];
  47281. for (i = 0; i < 2; i++) {
  47282. at.push({
  47283. x: readInt8(data, position),
  47284. y: readInt8(data, position + 1)
  47285. });
  47286. position += 2;
  47287. }
  47288. textRegion.refinementAt = at;
  47289. }
  47290. textRegion.numberOfSymbolInstances = readUint32(data, position);
  47291. position += 4;
  47292. if (textRegion.huffman) {
  47293. error('JBIG2 error: huffman is not supported');
  47294. }
  47295. args = [
  47296. textRegion,
  47297. header.referredTo,
  47298. data,
  47299. position,
  47300. end
  47301. ];
  47302. break;
  47303. case 38:
  47304. case 39:
  47305. var genericRegion = {};
  47306. genericRegion.info = readRegionSegmentInformation(data, position);
  47307. position += RegionSegmentInformationFieldLength;
  47308. var genericRegionSegmentFlags = data[position++];
  47309. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  47310. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  47311. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  47312. if (!genericRegion.mmr) {
  47313. atLength = genericRegion.template === 0 ? 4 : 1;
  47314. at = [];
  47315. for (i = 0; i < atLength; i++) {
  47316. at.push({
  47317. x: readInt8(data, position),
  47318. y: readInt8(data, position + 1)
  47319. });
  47320. position += 2;
  47321. }
  47322. genericRegion.at = at;
  47323. }
  47324. args = [
  47325. genericRegion,
  47326. data,
  47327. position,
  47328. end
  47329. ];
  47330. break;
  47331. case 48:
  47332. var pageInfo = {
  47333. width: readUint32(data, position),
  47334. height: readUint32(data, position + 4),
  47335. resolutionX: readUint32(data, position + 8),
  47336. resolutionY: readUint32(data, position + 12)
  47337. };
  47338. if (pageInfo.height === 0xFFFFFFFF) {
  47339. delete pageInfo.height;
  47340. }
  47341. var pageSegmentFlags = data[position + 16];
  47342. readUint16(data, position + 17);
  47343. pageInfo.lossless = !!(pageSegmentFlags & 1);
  47344. pageInfo.refinement = !!(pageSegmentFlags & 2);
  47345. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  47346. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  47347. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  47348. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  47349. args = [pageInfo];
  47350. break;
  47351. case 49:
  47352. break;
  47353. case 50:
  47354. break;
  47355. case 51:
  47356. break;
  47357. case 62:
  47358. break;
  47359. default:
  47360. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  47361. }
  47362. var callbackName = 'on' + header.typeName;
  47363. if (callbackName in visitor) {
  47364. visitor[callbackName].apply(visitor, args);
  47365. }
  47366. }
  47367. function processSegments(segments, visitor) {
  47368. for (var i = 0, ii = segments.length; i < ii; i++) {
  47369. processSegment(segments[i], visitor);
  47370. }
  47371. }
  47372. function parseJbig2(data, start, end) {
  47373. var position = start;
  47374. 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) {
  47375. error('JBIG2 error: invalid header');
  47376. }
  47377. var header = {};
  47378. position += 8;
  47379. var flags = data[position++];
  47380. header.randomAccess = !(flags & 1);
  47381. if (!(flags & 2)) {
  47382. header.numberOfPages = readUint32(data, position);
  47383. position += 4;
  47384. }
  47385. readSegments(header, data, position, end);
  47386. error('Not implemented');
  47387. }
  47388. function parseJbig2Chunks(chunks) {
  47389. var visitor = new SimpleSegmentVisitor();
  47390. for (var i = 0, ii = chunks.length; i < ii; i++) {
  47391. var chunk = chunks[i];
  47392. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  47393. processSegments(segments, visitor);
  47394. }
  47395. return visitor.buffer;
  47396. }
  47397. function SimpleSegmentVisitor() {
  47398. }
  47399. SimpleSegmentVisitor.prototype = {
  47400. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  47401. this.currentPageInfo = info;
  47402. var rowSize = info.width + 7 >> 3;
  47403. var buffer = new Uint8Array(rowSize * info.height);
  47404. if (info.defaultPixelValue) {
  47405. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47406. buffer[i] = 0xFF;
  47407. }
  47408. }
  47409. this.buffer = buffer;
  47410. },
  47411. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  47412. var pageInfo = this.currentPageInfo;
  47413. var width = regionInfo.width, height = regionInfo.height;
  47414. var rowSize = pageInfo.width + 7 >> 3;
  47415. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  47416. var buffer = this.buffer;
  47417. var mask0 = 128 >> (regionInfo.x & 7);
  47418. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  47419. var i, j, mask, offset;
  47420. switch (combinationOperator) {
  47421. case 0:
  47422. for (i = 0; i < height; i++) {
  47423. mask = mask0;
  47424. offset = offset0;
  47425. for (j = 0; j < width; j++) {
  47426. if (bitmap[i][j]) {
  47427. buffer[offset] |= mask;
  47428. }
  47429. mask >>= 1;
  47430. if (!mask) {
  47431. mask = 128;
  47432. offset++;
  47433. }
  47434. }
  47435. offset0 += rowSize;
  47436. }
  47437. break;
  47438. case 2:
  47439. for (i = 0; i < height; i++) {
  47440. mask = mask0;
  47441. offset = offset0;
  47442. for (j = 0; j < width; j++) {
  47443. if (bitmap[i][j]) {
  47444. buffer[offset] ^= mask;
  47445. }
  47446. mask >>= 1;
  47447. if (!mask) {
  47448. mask = 128;
  47449. offset++;
  47450. }
  47451. }
  47452. offset0 += rowSize;
  47453. }
  47454. break;
  47455. default:
  47456. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47457. }
  47458. },
  47459. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  47460. var regionInfo = region.info;
  47461. var decodingContext = new DecodingContext(data, start, end);
  47462. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  47463. this.drawBitmap(regionInfo, bitmap);
  47464. },
  47465. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  47466. this.onImmediateGenericRegion.apply(this, arguments);
  47467. },
  47468. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  47469. var huffmanTables;
  47470. if (dictionary.huffman) {
  47471. error('JBIG2 error: huffman is not supported');
  47472. }
  47473. var symbols = this.symbols;
  47474. if (!symbols) {
  47475. this.symbols = symbols = {};
  47476. }
  47477. var inputSymbols = [];
  47478. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47479. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47480. }
  47481. var decodingContext = new DecodingContext(data, start, end);
  47482. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  47483. },
  47484. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  47485. var regionInfo = region.info;
  47486. var huffmanTables;
  47487. var symbols = this.symbols;
  47488. var inputSymbols = [];
  47489. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47490. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47491. }
  47492. var symbolCodeLength = log2(inputSymbols.length);
  47493. var decodingContext = new DecodingContext(data, start, end);
  47494. 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);
  47495. this.drawBitmap(regionInfo, bitmap);
  47496. },
  47497. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  47498. this.onImmediateTextRegion.apply(this, arguments);
  47499. }
  47500. };
  47501. function Jbig2Image() {
  47502. }
  47503. Jbig2Image.prototype = {
  47504. parseChunks: function Jbig2Image_parseChunks(chunks) {
  47505. return parseJbig2Chunks(chunks);
  47506. }
  47507. };
  47508. return Jbig2Image;
  47509. }();
  47510. exports.Jbig2Image = Jbig2Image;
  47511. /***/ }),
  47512. /* 36 */
  47513. /***/ (function(module, exports, __w_pdfjs_require__) {
  47514. "use strict";
  47515. var sharedUtil = __w_pdfjs_require__(0);
  47516. var error = sharedUtil.error;
  47517. var JpegImage = function JpegImageClosure() {
  47518. var dctZigZag = new Uint8Array([
  47519. 0,
  47520. 1,
  47521. 8,
  47522. 16,
  47523. 9,
  47524. 2,
  47525. 3,
  47526. 10,
  47527. 17,
  47528. 24,
  47529. 32,
  47530. 25,
  47531. 18,
  47532. 11,
  47533. 4,
  47534. 5,
  47535. 12,
  47536. 19,
  47537. 26,
  47538. 33,
  47539. 40,
  47540. 48,
  47541. 41,
  47542. 34,
  47543. 27,
  47544. 20,
  47545. 13,
  47546. 6,
  47547. 7,
  47548. 14,
  47549. 21,
  47550. 28,
  47551. 35,
  47552. 42,
  47553. 49,
  47554. 56,
  47555. 57,
  47556. 50,
  47557. 43,
  47558. 36,
  47559. 29,
  47560. 22,
  47561. 15,
  47562. 23,
  47563. 30,
  47564. 37,
  47565. 44,
  47566. 51,
  47567. 58,
  47568. 59,
  47569. 52,
  47570. 45,
  47571. 38,
  47572. 31,
  47573. 39,
  47574. 46,
  47575. 53,
  47576. 60,
  47577. 61,
  47578. 54,
  47579. 47,
  47580. 55,
  47581. 62,
  47582. 63
  47583. ]);
  47584. var dctCos1 = 4017;
  47585. var dctSin1 = 799;
  47586. var dctCos3 = 3406;
  47587. var dctSin3 = 2276;
  47588. var dctCos6 = 1567;
  47589. var dctSin6 = 3784;
  47590. var dctSqrt2 = 5793;
  47591. var dctSqrt1d2 = 2896;
  47592. function JpegImage() {
  47593. this.decodeTransform = null;
  47594. this.colorTransform = -1;
  47595. }
  47596. function buildHuffmanTable(codeLengths, values) {
  47597. var k = 0, code = [], i, j, length = 16;
  47598. while (length > 0 && !codeLengths[length - 1]) {
  47599. length--;
  47600. }
  47601. code.push({
  47602. children: [],
  47603. index: 0
  47604. });
  47605. var p = code[0], q;
  47606. for (i = 0; i < length; i++) {
  47607. for (j = 0; j < codeLengths[i]; j++) {
  47608. p = code.pop();
  47609. p.children[p.index] = values[k];
  47610. while (p.index > 0) {
  47611. p = code.pop();
  47612. }
  47613. p.index++;
  47614. code.push(p);
  47615. while (code.length <= i) {
  47616. code.push(q = {
  47617. children: [],
  47618. index: 0
  47619. });
  47620. p.children[p.index] = q.children;
  47621. p = q;
  47622. }
  47623. k++;
  47624. }
  47625. if (i + 1 < length) {
  47626. code.push(q = {
  47627. children: [],
  47628. index: 0
  47629. });
  47630. p.children[p.index] = q.children;
  47631. p = q;
  47632. }
  47633. }
  47634. return code[0].children;
  47635. }
  47636. function getBlockBufferOffset(component, row, col) {
  47637. return 64 * ((component.blocksPerLine + 1) * row + col);
  47638. }
  47639. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  47640. var mcusPerLine = frame.mcusPerLine;
  47641. var progressive = frame.progressive;
  47642. var startOffset = offset, bitsData = 0, bitsCount = 0;
  47643. function readBit() {
  47644. if (bitsCount > 0) {
  47645. bitsCount--;
  47646. return bitsData >> bitsCount & 1;
  47647. }
  47648. bitsData = data[offset++];
  47649. if (bitsData === 0xFF) {
  47650. var nextByte = data[offset++];
  47651. if (nextByte) {
  47652. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  47653. }
  47654. }
  47655. bitsCount = 7;
  47656. return bitsData >>> 7;
  47657. }
  47658. function decodeHuffman(tree) {
  47659. var node = tree;
  47660. while (true) {
  47661. node = node[readBit()];
  47662. if (typeof node === 'number') {
  47663. return node;
  47664. }
  47665. if (typeof node !== 'object') {
  47666. error('JPEG error: invalid huffman sequence');
  47667. }
  47668. }
  47669. }
  47670. function receive(length) {
  47671. var n = 0;
  47672. while (length > 0) {
  47673. n = n << 1 | readBit();
  47674. length--;
  47675. }
  47676. return n;
  47677. }
  47678. function receiveAndExtend(length) {
  47679. if (length === 1) {
  47680. return readBit() === 1 ? 1 : -1;
  47681. }
  47682. var n = receive(length);
  47683. if (n >= 1 << length - 1) {
  47684. return n;
  47685. }
  47686. return n + (-1 << length) + 1;
  47687. }
  47688. function decodeBaseline(component, offset) {
  47689. var t = decodeHuffman(component.huffmanTableDC);
  47690. var diff = t === 0 ? 0 : receiveAndExtend(t);
  47691. component.blockData[offset] = component.pred += diff;
  47692. var k = 1;
  47693. while (k < 64) {
  47694. var rs = decodeHuffman(component.huffmanTableAC);
  47695. var s = rs & 15, r = rs >> 4;
  47696. if (s === 0) {
  47697. if (r < 15) {
  47698. break;
  47699. }
  47700. k += 16;
  47701. continue;
  47702. }
  47703. k += r;
  47704. var z = dctZigZag[k];
  47705. component.blockData[offset + z] = receiveAndExtend(s);
  47706. k++;
  47707. }
  47708. }
  47709. function decodeDCFirst(component, offset) {
  47710. var t = decodeHuffman(component.huffmanTableDC);
  47711. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  47712. component.blockData[offset] = component.pred += diff;
  47713. }
  47714. function decodeDCSuccessive(component, offset) {
  47715. component.blockData[offset] |= readBit() << successive;
  47716. }
  47717. var eobrun = 0;
  47718. function decodeACFirst(component, offset) {
  47719. if (eobrun > 0) {
  47720. eobrun--;
  47721. return;
  47722. }
  47723. var k = spectralStart, e = spectralEnd;
  47724. while (k <= e) {
  47725. var rs = decodeHuffman(component.huffmanTableAC);
  47726. var s = rs & 15, r = rs >> 4;
  47727. if (s === 0) {
  47728. if (r < 15) {
  47729. eobrun = receive(r) + (1 << r) - 1;
  47730. break;
  47731. }
  47732. k += 16;
  47733. continue;
  47734. }
  47735. k += r;
  47736. var z = dctZigZag[k];
  47737. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  47738. k++;
  47739. }
  47740. }
  47741. var successiveACState = 0, successiveACNextValue;
  47742. function decodeACSuccessive(component, offset) {
  47743. var k = spectralStart;
  47744. var e = spectralEnd;
  47745. var r = 0;
  47746. var s;
  47747. var rs;
  47748. while (k <= e) {
  47749. var z = dctZigZag[k];
  47750. switch (successiveACState) {
  47751. case 0:
  47752. rs = decodeHuffman(component.huffmanTableAC);
  47753. s = rs & 15;
  47754. r = rs >> 4;
  47755. if (s === 0) {
  47756. if (r < 15) {
  47757. eobrun = receive(r) + (1 << r);
  47758. successiveACState = 4;
  47759. } else {
  47760. r = 16;
  47761. successiveACState = 1;
  47762. }
  47763. } else {
  47764. if (s !== 1) {
  47765. error('JPEG error: invalid ACn encoding');
  47766. }
  47767. successiveACNextValue = receiveAndExtend(s);
  47768. successiveACState = r ? 2 : 3;
  47769. }
  47770. continue;
  47771. case 1:
  47772. case 2:
  47773. if (component.blockData[offset + z]) {
  47774. component.blockData[offset + z] += readBit() << successive;
  47775. } else {
  47776. r--;
  47777. if (r === 0) {
  47778. successiveACState = successiveACState === 2 ? 3 : 0;
  47779. }
  47780. }
  47781. break;
  47782. case 3:
  47783. if (component.blockData[offset + z]) {
  47784. component.blockData[offset + z] += readBit() << successive;
  47785. } else {
  47786. component.blockData[offset + z] = successiveACNextValue << successive;
  47787. successiveACState = 0;
  47788. }
  47789. break;
  47790. case 4:
  47791. if (component.blockData[offset + z]) {
  47792. component.blockData[offset + z] += readBit() << successive;
  47793. }
  47794. break;
  47795. }
  47796. k++;
  47797. }
  47798. if (successiveACState === 4) {
  47799. eobrun--;
  47800. if (eobrun === 0) {
  47801. successiveACState = 0;
  47802. }
  47803. }
  47804. }
  47805. function decodeMcu(component, decode, mcu, row, col) {
  47806. var mcuRow = mcu / mcusPerLine | 0;
  47807. var mcuCol = mcu % mcusPerLine;
  47808. var blockRow = mcuRow * component.v + row;
  47809. var blockCol = mcuCol * component.h + col;
  47810. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47811. decode(component, offset);
  47812. }
  47813. function decodeBlock(component, decode, mcu) {
  47814. var blockRow = mcu / component.blocksPerLine | 0;
  47815. var blockCol = mcu % component.blocksPerLine;
  47816. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47817. decode(component, offset);
  47818. }
  47819. var componentsLength = components.length;
  47820. var component, i, j, k, n;
  47821. var decodeFn;
  47822. if (progressive) {
  47823. if (spectralStart === 0) {
  47824. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  47825. } else {
  47826. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  47827. }
  47828. } else {
  47829. decodeFn = decodeBaseline;
  47830. }
  47831. var mcu = 0, marker;
  47832. var mcuExpected;
  47833. if (componentsLength === 1) {
  47834. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  47835. } else {
  47836. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  47837. }
  47838. if (!resetInterval) {
  47839. resetInterval = mcuExpected;
  47840. }
  47841. var h, v;
  47842. while (mcu < mcuExpected) {
  47843. for (i = 0; i < componentsLength; i++) {
  47844. components[i].pred = 0;
  47845. }
  47846. eobrun = 0;
  47847. if (componentsLength === 1) {
  47848. component = components[0];
  47849. for (n = 0; n < resetInterval; n++) {
  47850. decodeBlock(component, decodeFn, mcu);
  47851. mcu++;
  47852. }
  47853. } else {
  47854. for (n = 0; n < resetInterval; n++) {
  47855. for (i = 0; i < componentsLength; i++) {
  47856. component = components[i];
  47857. h = component.h;
  47858. v = component.v;
  47859. for (j = 0; j < v; j++) {
  47860. for (k = 0; k < h; k++) {
  47861. decodeMcu(component, decodeFn, mcu, j, k);
  47862. }
  47863. }
  47864. }
  47865. mcu++;
  47866. }
  47867. }
  47868. bitsCount = 0;
  47869. marker = data[offset] << 8 | data[offset + 1];
  47870. while (data[offset] === 0x00 && offset < data.length - 1) {
  47871. offset++;
  47872. marker = data[offset] << 8 | data[offset + 1];
  47873. }
  47874. if (marker <= 0xFF00) {
  47875. error('JPEG error: marker was not found');
  47876. }
  47877. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  47878. offset += 2;
  47879. } else {
  47880. break;
  47881. }
  47882. }
  47883. return offset - startOffset;
  47884. }
  47885. function quantizeAndInverse(component, blockBufferOffset, p) {
  47886. var qt = component.quantizationTable, blockData = component.blockData;
  47887. var v0, v1, v2, v3, v4, v5, v6, v7;
  47888. var p0, p1, p2, p3, p4, p5, p6, p7;
  47889. var t;
  47890. if (!qt) {
  47891. error('JPEG error: missing required Quantization Table.');
  47892. }
  47893. for (var row = 0; row < 64; row += 8) {
  47894. p0 = blockData[blockBufferOffset + row];
  47895. p1 = blockData[blockBufferOffset + row + 1];
  47896. p2 = blockData[blockBufferOffset + row + 2];
  47897. p3 = blockData[blockBufferOffset + row + 3];
  47898. p4 = blockData[blockBufferOffset + row + 4];
  47899. p5 = blockData[blockBufferOffset + row + 5];
  47900. p6 = blockData[blockBufferOffset + row + 6];
  47901. p7 = blockData[blockBufferOffset + row + 7];
  47902. p0 *= qt[row];
  47903. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47904. t = dctSqrt2 * p0 + 512 >> 10;
  47905. p[row] = t;
  47906. p[row + 1] = t;
  47907. p[row + 2] = t;
  47908. p[row + 3] = t;
  47909. p[row + 4] = t;
  47910. p[row + 5] = t;
  47911. p[row + 6] = t;
  47912. p[row + 7] = t;
  47913. continue;
  47914. }
  47915. p1 *= qt[row + 1];
  47916. p2 *= qt[row + 2];
  47917. p3 *= qt[row + 3];
  47918. p4 *= qt[row + 4];
  47919. p5 *= qt[row + 5];
  47920. p6 *= qt[row + 6];
  47921. p7 *= qt[row + 7];
  47922. v0 = dctSqrt2 * p0 + 128 >> 8;
  47923. v1 = dctSqrt2 * p4 + 128 >> 8;
  47924. v2 = p2;
  47925. v3 = p6;
  47926. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  47927. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  47928. v5 = p3 << 4;
  47929. v6 = p5 << 4;
  47930. v0 = v0 + v1 + 1 >> 1;
  47931. v1 = v0 - v1;
  47932. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  47933. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  47934. v3 = t;
  47935. v4 = v4 + v6 + 1 >> 1;
  47936. v6 = v4 - v6;
  47937. v7 = v7 + v5 + 1 >> 1;
  47938. v5 = v7 - v5;
  47939. v0 = v0 + v3 + 1 >> 1;
  47940. v3 = v0 - v3;
  47941. v1 = v1 + v2 + 1 >> 1;
  47942. v2 = v1 - v2;
  47943. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  47944. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  47945. v7 = t;
  47946. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  47947. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  47948. v6 = t;
  47949. p[row] = v0 + v7;
  47950. p[row + 7] = v0 - v7;
  47951. p[row + 1] = v1 + v6;
  47952. p[row + 6] = v1 - v6;
  47953. p[row + 2] = v2 + v5;
  47954. p[row + 5] = v2 - v5;
  47955. p[row + 3] = v3 + v4;
  47956. p[row + 4] = v3 - v4;
  47957. }
  47958. for (var col = 0; col < 8; ++col) {
  47959. p0 = p[col];
  47960. p1 = p[col + 8];
  47961. p2 = p[col + 16];
  47962. p3 = p[col + 24];
  47963. p4 = p[col + 32];
  47964. p5 = p[col + 40];
  47965. p6 = p[col + 48];
  47966. p7 = p[col + 56];
  47967. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47968. t = dctSqrt2 * p0 + 8192 >> 14;
  47969. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  47970. blockData[blockBufferOffset + col] = t;
  47971. blockData[blockBufferOffset + col + 8] = t;
  47972. blockData[blockBufferOffset + col + 16] = t;
  47973. blockData[blockBufferOffset + col + 24] = t;
  47974. blockData[blockBufferOffset + col + 32] = t;
  47975. blockData[blockBufferOffset + col + 40] = t;
  47976. blockData[blockBufferOffset + col + 48] = t;
  47977. blockData[blockBufferOffset + col + 56] = t;
  47978. continue;
  47979. }
  47980. v0 = dctSqrt2 * p0 + 2048 >> 12;
  47981. v1 = dctSqrt2 * p4 + 2048 >> 12;
  47982. v2 = p2;
  47983. v3 = p6;
  47984. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  47985. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  47986. v5 = p3;
  47987. v6 = p5;
  47988. v0 = (v0 + v1 + 1 >> 1) + 4112;
  47989. v1 = v0 - v1;
  47990. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  47991. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  47992. v3 = t;
  47993. v4 = v4 + v6 + 1 >> 1;
  47994. v6 = v4 - v6;
  47995. v7 = v7 + v5 + 1 >> 1;
  47996. v5 = v7 - v5;
  47997. v0 = v0 + v3 + 1 >> 1;
  47998. v3 = v0 - v3;
  47999. v1 = v1 + v2 + 1 >> 1;
  48000. v2 = v1 - v2;
  48001. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48002. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48003. v7 = t;
  48004. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48005. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48006. v6 = t;
  48007. p0 = v0 + v7;
  48008. p7 = v0 - v7;
  48009. p1 = v1 + v6;
  48010. p6 = v1 - v6;
  48011. p2 = v2 + v5;
  48012. p5 = v2 - v5;
  48013. p3 = v3 + v4;
  48014. p4 = v3 - v4;
  48015. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48016. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48017. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48018. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48019. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48020. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48021. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48022. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48023. blockData[blockBufferOffset + col] = p0;
  48024. blockData[blockBufferOffset + col + 8] = p1;
  48025. blockData[blockBufferOffset + col + 16] = p2;
  48026. blockData[blockBufferOffset + col + 24] = p3;
  48027. blockData[blockBufferOffset + col + 32] = p4;
  48028. blockData[blockBufferOffset + col + 40] = p5;
  48029. blockData[blockBufferOffset + col + 48] = p6;
  48030. blockData[blockBufferOffset + col + 56] = p7;
  48031. }
  48032. }
  48033. function buildComponentData(frame, component) {
  48034. var blocksPerLine = component.blocksPerLine;
  48035. var blocksPerColumn = component.blocksPerColumn;
  48036. var computationBuffer = new Int16Array(64);
  48037. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48038. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48039. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48040. quantizeAndInverse(component, offset, computationBuffer);
  48041. }
  48042. }
  48043. return component.blockData;
  48044. }
  48045. function clamp0to255(a) {
  48046. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48047. }
  48048. JpegImage.prototype = {
  48049. parse: function parse(data) {
  48050. function readUint16() {
  48051. var value = data[offset] << 8 | data[offset + 1];
  48052. offset += 2;
  48053. return value;
  48054. }
  48055. function readDataBlock() {
  48056. var length = readUint16();
  48057. var array = data.subarray(offset, offset + length - 2);
  48058. offset += array.length;
  48059. return array;
  48060. }
  48061. function prepareComponents(frame) {
  48062. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48063. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48064. for (var i = 0; i < frame.components.length; i++) {
  48065. component = frame.components[i];
  48066. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48067. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48068. var blocksPerLineForMcu = mcusPerLine * component.h;
  48069. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48070. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48071. component.blockData = new Int16Array(blocksBufferSize);
  48072. component.blocksPerLine = blocksPerLine;
  48073. component.blocksPerColumn = blocksPerColumn;
  48074. }
  48075. frame.mcusPerLine = mcusPerLine;
  48076. frame.mcusPerColumn = mcusPerColumn;
  48077. }
  48078. var offset = 0;
  48079. var jfif = null;
  48080. var adobe = null;
  48081. var frame, resetInterval;
  48082. var quantizationTables = [];
  48083. var huffmanTablesAC = [], huffmanTablesDC = [];
  48084. var fileMarker = readUint16();
  48085. if (fileMarker !== 0xFFD8) {
  48086. error('JPEG error: SOI not found');
  48087. }
  48088. fileMarker = readUint16();
  48089. while (fileMarker !== 0xFFD9) {
  48090. var i, j, l;
  48091. switch (fileMarker) {
  48092. case 0xFFE0:
  48093. case 0xFFE1:
  48094. case 0xFFE2:
  48095. case 0xFFE3:
  48096. case 0xFFE4:
  48097. case 0xFFE5:
  48098. case 0xFFE6:
  48099. case 0xFFE7:
  48100. case 0xFFE8:
  48101. case 0xFFE9:
  48102. case 0xFFEA:
  48103. case 0xFFEB:
  48104. case 0xFFEC:
  48105. case 0xFFED:
  48106. case 0xFFEE:
  48107. case 0xFFEF:
  48108. case 0xFFFE:
  48109. var appData = readDataBlock();
  48110. if (fileMarker === 0xFFE0) {
  48111. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48112. jfif = {
  48113. version: {
  48114. major: appData[5],
  48115. minor: appData[6]
  48116. },
  48117. densityUnits: appData[7],
  48118. xDensity: appData[8] << 8 | appData[9],
  48119. yDensity: appData[10] << 8 | appData[11],
  48120. thumbWidth: appData[12],
  48121. thumbHeight: appData[13],
  48122. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48123. };
  48124. }
  48125. }
  48126. if (fileMarker === 0xFFEE) {
  48127. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48128. adobe = {
  48129. version: appData[5] << 8 | appData[6],
  48130. flags0: appData[7] << 8 | appData[8],
  48131. flags1: appData[9] << 8 | appData[10],
  48132. transformCode: appData[11]
  48133. };
  48134. }
  48135. }
  48136. break;
  48137. case 0xFFDB:
  48138. var quantizationTablesLength = readUint16();
  48139. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48140. var z;
  48141. while (offset < quantizationTablesEnd) {
  48142. var quantizationTableSpec = data[offset++];
  48143. var tableData = new Uint16Array(64);
  48144. if (quantizationTableSpec >> 4 === 0) {
  48145. for (j = 0; j < 64; j++) {
  48146. z = dctZigZag[j];
  48147. tableData[z] = data[offset++];
  48148. }
  48149. } else if (quantizationTableSpec >> 4 === 1) {
  48150. for (j = 0; j < 64; j++) {
  48151. z = dctZigZag[j];
  48152. tableData[z] = readUint16();
  48153. }
  48154. } else {
  48155. error('JPEG error: DQT - invalid table spec');
  48156. }
  48157. quantizationTables[quantizationTableSpec & 15] = tableData;
  48158. }
  48159. break;
  48160. case 0xFFC0:
  48161. case 0xFFC1:
  48162. case 0xFFC2:
  48163. if (frame) {
  48164. error('JPEG error: Only single frame JPEGs supported');
  48165. }
  48166. readUint16();
  48167. frame = {};
  48168. frame.extended = fileMarker === 0xFFC1;
  48169. frame.progressive = fileMarker === 0xFFC2;
  48170. frame.precision = data[offset++];
  48171. frame.scanLines = readUint16();
  48172. frame.samplesPerLine = readUint16();
  48173. frame.components = [];
  48174. frame.componentIds = {};
  48175. var componentsCount = data[offset++], componentId;
  48176. var maxH = 0, maxV = 0;
  48177. for (i = 0; i < componentsCount; i++) {
  48178. componentId = data[offset];
  48179. var h = data[offset + 1] >> 4;
  48180. var v = data[offset + 1] & 15;
  48181. if (maxH < h) {
  48182. maxH = h;
  48183. }
  48184. if (maxV < v) {
  48185. maxV = v;
  48186. }
  48187. var qId = data[offset + 2];
  48188. l = frame.components.push({
  48189. h: h,
  48190. v: v,
  48191. quantizationId: qId,
  48192. quantizationTable: null
  48193. });
  48194. frame.componentIds[componentId] = l - 1;
  48195. offset += 3;
  48196. }
  48197. frame.maxH = maxH;
  48198. frame.maxV = maxV;
  48199. prepareComponents(frame);
  48200. break;
  48201. case 0xFFC4:
  48202. var huffmanLength = readUint16();
  48203. for (i = 2; i < huffmanLength;) {
  48204. var huffmanTableSpec = data[offset++];
  48205. var codeLengths = new Uint8Array(16);
  48206. var codeLengthSum = 0;
  48207. for (j = 0; j < 16; j++, offset++) {
  48208. codeLengthSum += codeLengths[j] = data[offset];
  48209. }
  48210. var huffmanValues = new Uint8Array(codeLengthSum);
  48211. for (j = 0; j < codeLengthSum; j++, offset++) {
  48212. huffmanValues[j] = data[offset];
  48213. }
  48214. i += 17 + codeLengthSum;
  48215. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  48216. }
  48217. break;
  48218. case 0xFFDD:
  48219. readUint16();
  48220. resetInterval = readUint16();
  48221. break;
  48222. case 0xFFDA:
  48223. readUint16();
  48224. var selectorsCount = data[offset++];
  48225. var components = [], component;
  48226. for (i = 0; i < selectorsCount; i++) {
  48227. var componentIndex = frame.componentIds[data[offset++]];
  48228. component = frame.components[componentIndex];
  48229. var tableSpec = data[offset++];
  48230. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  48231. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  48232. components.push(component);
  48233. }
  48234. var spectralStart = data[offset++];
  48235. var spectralEnd = data[offset++];
  48236. var successiveApproximation = data[offset++];
  48237. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  48238. offset += processed;
  48239. break;
  48240. case 0xFFFF:
  48241. if (data[offset] !== 0xFF) {
  48242. offset--;
  48243. }
  48244. break;
  48245. default:
  48246. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  48247. offset -= 3;
  48248. break;
  48249. }
  48250. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  48251. }
  48252. fileMarker = readUint16();
  48253. }
  48254. this.width = frame.samplesPerLine;
  48255. this.height = frame.scanLines;
  48256. this.jfif = jfif;
  48257. this.adobe = adobe;
  48258. this.components = [];
  48259. for (i = 0; i < frame.components.length; i++) {
  48260. component = frame.components[i];
  48261. var quantizationTable = quantizationTables[component.quantizationId];
  48262. if (quantizationTable) {
  48263. component.quantizationTable = quantizationTable;
  48264. }
  48265. this.components.push({
  48266. output: buildComponentData(frame, component),
  48267. scaleX: component.h / frame.maxH,
  48268. scaleY: component.v / frame.maxV,
  48269. blocksPerLine: component.blocksPerLine,
  48270. blocksPerColumn: component.blocksPerColumn
  48271. });
  48272. }
  48273. this.numComponents = this.components.length;
  48274. },
  48275. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  48276. var scaleX = this.width / width, scaleY = this.height / height;
  48277. var component, componentScaleX, componentScaleY, blocksPerScanline;
  48278. var x, y, i, j, k;
  48279. var index;
  48280. var offset = 0;
  48281. var output;
  48282. var numComponents = this.components.length;
  48283. var dataLength = width * height * numComponents;
  48284. var data = new Uint8Array(dataLength);
  48285. var xScaleBlockOffset = new Uint32Array(width);
  48286. var mask3LSB = 0xfffffff8;
  48287. for (i = 0; i < numComponents; i++) {
  48288. component = this.components[i];
  48289. componentScaleX = component.scaleX * scaleX;
  48290. componentScaleY = component.scaleY * scaleY;
  48291. offset = i;
  48292. output = component.output;
  48293. blocksPerScanline = component.blocksPerLine + 1 << 3;
  48294. for (x = 0; x < width; x++) {
  48295. j = 0 | x * componentScaleX;
  48296. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  48297. }
  48298. for (y = 0; y < height; y++) {
  48299. j = 0 | y * componentScaleY;
  48300. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  48301. for (x = 0; x < width; x++) {
  48302. data[offset] = output[index + xScaleBlockOffset[x]];
  48303. offset += numComponents;
  48304. }
  48305. }
  48306. }
  48307. var transform = this.decodeTransform;
  48308. if (transform) {
  48309. for (i = 0; i < dataLength;) {
  48310. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  48311. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  48312. }
  48313. }
  48314. }
  48315. return data;
  48316. },
  48317. _isColorConversionNeeded: function isColorConversionNeeded() {
  48318. if (this.adobe && this.adobe.transformCode) {
  48319. return true;
  48320. } else if (this.numComponents === 3) {
  48321. if (!this.adobe && this.colorTransform === 0) {
  48322. return false;
  48323. }
  48324. return true;
  48325. }
  48326. if (!this.adobe && this.colorTransform === 1) {
  48327. return true;
  48328. }
  48329. return false;
  48330. },
  48331. _convertYccToRgb: function convertYccToRgb(data) {
  48332. var Y, Cb, Cr;
  48333. for (var i = 0, length = data.length; i < length; i += 3) {
  48334. Y = data[i];
  48335. Cb = data[i + 1];
  48336. Cr = data[i + 2];
  48337. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  48338. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  48339. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  48340. }
  48341. return data;
  48342. },
  48343. _convertYcckToRgb: function convertYcckToRgb(data) {
  48344. var Y, Cb, Cr, k;
  48345. var offset = 0;
  48346. for (var i = 0, length = data.length; i < length; i += 4) {
  48347. Y = data[i];
  48348. Cb = data[i + 1];
  48349. Cr = data[i + 2];
  48350. k = data[i + 3];
  48351. 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);
  48352. 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);
  48353. 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);
  48354. data[offset++] = clamp0to255(r);
  48355. data[offset++] = clamp0to255(g);
  48356. data[offset++] = clamp0to255(b);
  48357. }
  48358. return data;
  48359. },
  48360. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  48361. var Y, Cb, Cr;
  48362. for (var i = 0, length = data.length; i < length; i += 4) {
  48363. Y = data[i];
  48364. Cb = data[i + 1];
  48365. Cr = data[i + 2];
  48366. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  48367. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  48368. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  48369. }
  48370. return data;
  48371. },
  48372. _convertCmykToRgb: function convertCmykToRgb(data) {
  48373. var c, m, y, k;
  48374. var offset = 0;
  48375. var min = -255 * 255 * 255;
  48376. var scale = 1 / 255 / 255;
  48377. for (var i = 0, length = data.length; i < length; i += 4) {
  48378. c = data[i];
  48379. m = data[i + 1];
  48380. y = data[i + 2];
  48381. k = data[i + 3];
  48382. 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);
  48383. 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);
  48384. 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);
  48385. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  48386. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  48387. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  48388. }
  48389. return data;
  48390. },
  48391. getData: function getData(width, height, forceRGBoutput) {
  48392. if (this.numComponents > 4) {
  48393. error('JPEG error: Unsupported color mode');
  48394. }
  48395. var data = this._getLinearizedBlockData(width, height);
  48396. if (this.numComponents === 1 && forceRGBoutput) {
  48397. var dataLength = data.length;
  48398. var rgbData = new Uint8Array(dataLength * 3);
  48399. var offset = 0;
  48400. for (var i = 0; i < dataLength; i++) {
  48401. var grayColor = data[i];
  48402. rgbData[offset++] = grayColor;
  48403. rgbData[offset++] = grayColor;
  48404. rgbData[offset++] = grayColor;
  48405. }
  48406. return rgbData;
  48407. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  48408. return this._convertYccToRgb(data);
  48409. } else if (this.numComponents === 4) {
  48410. if (this._isColorConversionNeeded()) {
  48411. if (forceRGBoutput) {
  48412. return this._convertYcckToRgb(data);
  48413. }
  48414. return this._convertYcckToCmyk(data);
  48415. } else if (forceRGBoutput) {
  48416. return this._convertCmykToRgb(data);
  48417. }
  48418. }
  48419. return data;
  48420. }
  48421. };
  48422. return JpegImage;
  48423. }();
  48424. exports.JpegImage = JpegImage;
  48425. /***/ }),
  48426. /* 37 */
  48427. /***/ (function(module, exports, __w_pdfjs_require__) {
  48428. "use strict";
  48429. var sharedUtil = __w_pdfjs_require__(0);
  48430. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  48431. var getMetrics = getLookupTableFactory(function (t) {
  48432. t['Courier'] = 600;
  48433. t['Courier-Bold'] = 600;
  48434. t['Courier-BoldOblique'] = 600;
  48435. t['Courier-Oblique'] = 600;
  48436. t['Helvetica'] = getLookupTableFactory(function (t) {
  48437. t['space'] = 278;
  48438. t['exclam'] = 278;
  48439. t['quotedbl'] = 355;
  48440. t['numbersign'] = 556;
  48441. t['dollar'] = 556;
  48442. t['percent'] = 889;
  48443. t['ampersand'] = 667;
  48444. t['quoteright'] = 222;
  48445. t['parenleft'] = 333;
  48446. t['parenright'] = 333;
  48447. t['asterisk'] = 389;
  48448. t['plus'] = 584;
  48449. t['comma'] = 278;
  48450. t['hyphen'] = 333;
  48451. t['period'] = 278;
  48452. t['slash'] = 278;
  48453. t['zero'] = 556;
  48454. t['one'] = 556;
  48455. t['two'] = 556;
  48456. t['three'] = 556;
  48457. t['four'] = 556;
  48458. t['five'] = 556;
  48459. t['six'] = 556;
  48460. t['seven'] = 556;
  48461. t['eight'] = 556;
  48462. t['nine'] = 556;
  48463. t['colon'] = 278;
  48464. t['semicolon'] = 278;
  48465. t['less'] = 584;
  48466. t['equal'] = 584;
  48467. t['greater'] = 584;
  48468. t['question'] = 556;
  48469. t['at'] = 1015;
  48470. t['A'] = 667;
  48471. t['B'] = 667;
  48472. t['C'] = 722;
  48473. t['D'] = 722;
  48474. t['E'] = 667;
  48475. t['F'] = 611;
  48476. t['G'] = 778;
  48477. t['H'] = 722;
  48478. t['I'] = 278;
  48479. t['J'] = 500;
  48480. t['K'] = 667;
  48481. t['L'] = 556;
  48482. t['M'] = 833;
  48483. t['N'] = 722;
  48484. t['O'] = 778;
  48485. t['P'] = 667;
  48486. t['Q'] = 778;
  48487. t['R'] = 722;
  48488. t['S'] = 667;
  48489. t['T'] = 611;
  48490. t['U'] = 722;
  48491. t['V'] = 667;
  48492. t['W'] = 944;
  48493. t['X'] = 667;
  48494. t['Y'] = 667;
  48495. t['Z'] = 611;
  48496. t['bracketleft'] = 278;
  48497. t['backslash'] = 278;
  48498. t['bracketright'] = 278;
  48499. t['asciicircum'] = 469;
  48500. t['underscore'] = 556;
  48501. t['quoteleft'] = 222;
  48502. t['a'] = 556;
  48503. t['b'] = 556;
  48504. t['c'] = 500;
  48505. t['d'] = 556;
  48506. t['e'] = 556;
  48507. t['f'] = 278;
  48508. t['g'] = 556;
  48509. t['h'] = 556;
  48510. t['i'] = 222;
  48511. t['j'] = 222;
  48512. t['k'] = 500;
  48513. t['l'] = 222;
  48514. t['m'] = 833;
  48515. t['n'] = 556;
  48516. t['o'] = 556;
  48517. t['p'] = 556;
  48518. t['q'] = 556;
  48519. t['r'] = 333;
  48520. t['s'] = 500;
  48521. t['t'] = 278;
  48522. t['u'] = 556;
  48523. t['v'] = 500;
  48524. t['w'] = 722;
  48525. t['x'] = 500;
  48526. t['y'] = 500;
  48527. t['z'] = 500;
  48528. t['braceleft'] = 334;
  48529. t['bar'] = 260;
  48530. t['braceright'] = 334;
  48531. t['asciitilde'] = 584;
  48532. t['exclamdown'] = 333;
  48533. t['cent'] = 556;
  48534. t['sterling'] = 556;
  48535. t['fraction'] = 167;
  48536. t['yen'] = 556;
  48537. t['florin'] = 556;
  48538. t['section'] = 556;
  48539. t['currency'] = 556;
  48540. t['quotesingle'] = 191;
  48541. t['quotedblleft'] = 333;
  48542. t['guillemotleft'] = 556;
  48543. t['guilsinglleft'] = 333;
  48544. t['guilsinglright'] = 333;
  48545. t['fi'] = 500;
  48546. t['fl'] = 500;
  48547. t['endash'] = 556;
  48548. t['dagger'] = 556;
  48549. t['daggerdbl'] = 556;
  48550. t['periodcentered'] = 278;
  48551. t['paragraph'] = 537;
  48552. t['bullet'] = 350;
  48553. t['quotesinglbase'] = 222;
  48554. t['quotedblbase'] = 333;
  48555. t['quotedblright'] = 333;
  48556. t['guillemotright'] = 556;
  48557. t['ellipsis'] = 1000;
  48558. t['perthousand'] = 1000;
  48559. t['questiondown'] = 611;
  48560. t['grave'] = 333;
  48561. t['acute'] = 333;
  48562. t['circumflex'] = 333;
  48563. t['tilde'] = 333;
  48564. t['macron'] = 333;
  48565. t['breve'] = 333;
  48566. t['dotaccent'] = 333;
  48567. t['dieresis'] = 333;
  48568. t['ring'] = 333;
  48569. t['cedilla'] = 333;
  48570. t['hungarumlaut'] = 333;
  48571. t['ogonek'] = 333;
  48572. t['caron'] = 333;
  48573. t['emdash'] = 1000;
  48574. t['AE'] = 1000;
  48575. t['ordfeminine'] = 370;
  48576. t['Lslash'] = 556;
  48577. t['Oslash'] = 778;
  48578. t['OE'] = 1000;
  48579. t['ordmasculine'] = 365;
  48580. t['ae'] = 889;
  48581. t['dotlessi'] = 278;
  48582. t['lslash'] = 222;
  48583. t['oslash'] = 611;
  48584. t['oe'] = 944;
  48585. t['germandbls'] = 611;
  48586. t['Idieresis'] = 278;
  48587. t['eacute'] = 556;
  48588. t['abreve'] = 556;
  48589. t['uhungarumlaut'] = 556;
  48590. t['ecaron'] = 556;
  48591. t['Ydieresis'] = 667;
  48592. t['divide'] = 584;
  48593. t['Yacute'] = 667;
  48594. t['Acircumflex'] = 667;
  48595. t['aacute'] = 556;
  48596. t['Ucircumflex'] = 722;
  48597. t['yacute'] = 500;
  48598. t['scommaaccent'] = 500;
  48599. t['ecircumflex'] = 556;
  48600. t['Uring'] = 722;
  48601. t['Udieresis'] = 722;
  48602. t['aogonek'] = 556;
  48603. t['Uacute'] = 722;
  48604. t['uogonek'] = 556;
  48605. t['Edieresis'] = 667;
  48606. t['Dcroat'] = 722;
  48607. t['commaaccent'] = 250;
  48608. t['copyright'] = 737;
  48609. t['Emacron'] = 667;
  48610. t['ccaron'] = 500;
  48611. t['aring'] = 556;
  48612. t['Ncommaaccent'] = 722;
  48613. t['lacute'] = 222;
  48614. t['agrave'] = 556;
  48615. t['Tcommaaccent'] = 611;
  48616. t['Cacute'] = 722;
  48617. t['atilde'] = 556;
  48618. t['Edotaccent'] = 667;
  48619. t['scaron'] = 500;
  48620. t['scedilla'] = 500;
  48621. t['iacute'] = 278;
  48622. t['lozenge'] = 471;
  48623. t['Rcaron'] = 722;
  48624. t['Gcommaaccent'] = 778;
  48625. t['ucircumflex'] = 556;
  48626. t['acircumflex'] = 556;
  48627. t['Amacron'] = 667;
  48628. t['rcaron'] = 333;
  48629. t['ccedilla'] = 500;
  48630. t['Zdotaccent'] = 611;
  48631. t['Thorn'] = 667;
  48632. t['Omacron'] = 778;
  48633. t['Racute'] = 722;
  48634. t['Sacute'] = 667;
  48635. t['dcaron'] = 643;
  48636. t['Umacron'] = 722;
  48637. t['uring'] = 556;
  48638. t['threesuperior'] = 333;
  48639. t['Ograve'] = 778;
  48640. t['Agrave'] = 667;
  48641. t['Abreve'] = 667;
  48642. t['multiply'] = 584;
  48643. t['uacute'] = 556;
  48644. t['Tcaron'] = 611;
  48645. t['partialdiff'] = 476;
  48646. t['ydieresis'] = 500;
  48647. t['Nacute'] = 722;
  48648. t['icircumflex'] = 278;
  48649. t['Ecircumflex'] = 667;
  48650. t['adieresis'] = 556;
  48651. t['edieresis'] = 556;
  48652. t['cacute'] = 500;
  48653. t['nacute'] = 556;
  48654. t['umacron'] = 556;
  48655. t['Ncaron'] = 722;
  48656. t['Iacute'] = 278;
  48657. t['plusminus'] = 584;
  48658. t['brokenbar'] = 260;
  48659. t['registered'] = 737;
  48660. t['Gbreve'] = 778;
  48661. t['Idotaccent'] = 278;
  48662. t['summation'] = 600;
  48663. t['Egrave'] = 667;
  48664. t['racute'] = 333;
  48665. t['omacron'] = 556;
  48666. t['Zacute'] = 611;
  48667. t['Zcaron'] = 611;
  48668. t['greaterequal'] = 549;
  48669. t['Eth'] = 722;
  48670. t['Ccedilla'] = 722;
  48671. t['lcommaaccent'] = 222;
  48672. t['tcaron'] = 317;
  48673. t['eogonek'] = 556;
  48674. t['Uogonek'] = 722;
  48675. t['Aacute'] = 667;
  48676. t['Adieresis'] = 667;
  48677. t['egrave'] = 556;
  48678. t['zacute'] = 500;
  48679. t['iogonek'] = 222;
  48680. t['Oacute'] = 778;
  48681. t['oacute'] = 556;
  48682. t['amacron'] = 556;
  48683. t['sacute'] = 500;
  48684. t['idieresis'] = 278;
  48685. t['Ocircumflex'] = 778;
  48686. t['Ugrave'] = 722;
  48687. t['Delta'] = 612;
  48688. t['thorn'] = 556;
  48689. t['twosuperior'] = 333;
  48690. t['Odieresis'] = 778;
  48691. t['mu'] = 556;
  48692. t['igrave'] = 278;
  48693. t['ohungarumlaut'] = 556;
  48694. t['Eogonek'] = 667;
  48695. t['dcroat'] = 556;
  48696. t['threequarters'] = 834;
  48697. t['Scedilla'] = 667;
  48698. t['lcaron'] = 299;
  48699. t['Kcommaaccent'] = 667;
  48700. t['Lacute'] = 556;
  48701. t['trademark'] = 1000;
  48702. t['edotaccent'] = 556;
  48703. t['Igrave'] = 278;
  48704. t['Imacron'] = 278;
  48705. t['Lcaron'] = 556;
  48706. t['onehalf'] = 834;
  48707. t['lessequal'] = 549;
  48708. t['ocircumflex'] = 556;
  48709. t['ntilde'] = 556;
  48710. t['Uhungarumlaut'] = 722;
  48711. t['Eacute'] = 667;
  48712. t['emacron'] = 556;
  48713. t['gbreve'] = 556;
  48714. t['onequarter'] = 834;
  48715. t['Scaron'] = 667;
  48716. t['Scommaaccent'] = 667;
  48717. t['Ohungarumlaut'] = 778;
  48718. t['degree'] = 400;
  48719. t['ograve'] = 556;
  48720. t['Ccaron'] = 722;
  48721. t['ugrave'] = 556;
  48722. t['radical'] = 453;
  48723. t['Dcaron'] = 722;
  48724. t['rcommaaccent'] = 333;
  48725. t['Ntilde'] = 722;
  48726. t['otilde'] = 556;
  48727. t['Rcommaaccent'] = 722;
  48728. t['Lcommaaccent'] = 556;
  48729. t['Atilde'] = 667;
  48730. t['Aogonek'] = 667;
  48731. t['Aring'] = 667;
  48732. t['Otilde'] = 778;
  48733. t['zdotaccent'] = 500;
  48734. t['Ecaron'] = 667;
  48735. t['Iogonek'] = 278;
  48736. t['kcommaaccent'] = 500;
  48737. t['minus'] = 584;
  48738. t['Icircumflex'] = 278;
  48739. t['ncaron'] = 556;
  48740. t['tcommaaccent'] = 278;
  48741. t['logicalnot'] = 584;
  48742. t['odieresis'] = 556;
  48743. t['udieresis'] = 556;
  48744. t['notequal'] = 549;
  48745. t['gcommaaccent'] = 556;
  48746. t['eth'] = 556;
  48747. t['zcaron'] = 500;
  48748. t['ncommaaccent'] = 556;
  48749. t['onesuperior'] = 333;
  48750. t['imacron'] = 278;
  48751. t['Euro'] = 556;
  48752. });
  48753. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  48754. t['space'] = 278;
  48755. t['exclam'] = 333;
  48756. t['quotedbl'] = 474;
  48757. t['numbersign'] = 556;
  48758. t['dollar'] = 556;
  48759. t['percent'] = 889;
  48760. t['ampersand'] = 722;
  48761. t['quoteright'] = 278;
  48762. t['parenleft'] = 333;
  48763. t['parenright'] = 333;
  48764. t['asterisk'] = 389;
  48765. t['plus'] = 584;
  48766. t['comma'] = 278;
  48767. t['hyphen'] = 333;
  48768. t['period'] = 278;
  48769. t['slash'] = 278;
  48770. t['zero'] = 556;
  48771. t['one'] = 556;
  48772. t['two'] = 556;
  48773. t['three'] = 556;
  48774. t['four'] = 556;
  48775. t['five'] = 556;
  48776. t['six'] = 556;
  48777. t['seven'] = 556;
  48778. t['eight'] = 556;
  48779. t['nine'] = 556;
  48780. t['colon'] = 333;
  48781. t['semicolon'] = 333;
  48782. t['less'] = 584;
  48783. t['equal'] = 584;
  48784. t['greater'] = 584;
  48785. t['question'] = 611;
  48786. t['at'] = 975;
  48787. t['A'] = 722;
  48788. t['B'] = 722;
  48789. t['C'] = 722;
  48790. t['D'] = 722;
  48791. t['E'] = 667;
  48792. t['F'] = 611;
  48793. t['G'] = 778;
  48794. t['H'] = 722;
  48795. t['I'] = 278;
  48796. t['J'] = 556;
  48797. t['K'] = 722;
  48798. t['L'] = 611;
  48799. t['M'] = 833;
  48800. t['N'] = 722;
  48801. t['O'] = 778;
  48802. t['P'] = 667;
  48803. t['Q'] = 778;
  48804. t['R'] = 722;
  48805. t['S'] = 667;
  48806. t['T'] = 611;
  48807. t['U'] = 722;
  48808. t['V'] = 667;
  48809. t['W'] = 944;
  48810. t['X'] = 667;
  48811. t['Y'] = 667;
  48812. t['Z'] = 611;
  48813. t['bracketleft'] = 333;
  48814. t['backslash'] = 278;
  48815. t['bracketright'] = 333;
  48816. t['asciicircum'] = 584;
  48817. t['underscore'] = 556;
  48818. t['quoteleft'] = 278;
  48819. t['a'] = 556;
  48820. t['b'] = 611;
  48821. t['c'] = 556;
  48822. t['d'] = 611;
  48823. t['e'] = 556;
  48824. t['f'] = 333;
  48825. t['g'] = 611;
  48826. t['h'] = 611;
  48827. t['i'] = 278;
  48828. t['j'] = 278;
  48829. t['k'] = 556;
  48830. t['l'] = 278;
  48831. t['m'] = 889;
  48832. t['n'] = 611;
  48833. t['o'] = 611;
  48834. t['p'] = 611;
  48835. t['q'] = 611;
  48836. t['r'] = 389;
  48837. t['s'] = 556;
  48838. t['t'] = 333;
  48839. t['u'] = 611;
  48840. t['v'] = 556;
  48841. t['w'] = 778;
  48842. t['x'] = 556;
  48843. t['y'] = 556;
  48844. t['z'] = 500;
  48845. t['braceleft'] = 389;
  48846. t['bar'] = 280;
  48847. t['braceright'] = 389;
  48848. t['asciitilde'] = 584;
  48849. t['exclamdown'] = 333;
  48850. t['cent'] = 556;
  48851. t['sterling'] = 556;
  48852. t['fraction'] = 167;
  48853. t['yen'] = 556;
  48854. t['florin'] = 556;
  48855. t['section'] = 556;
  48856. t['currency'] = 556;
  48857. t['quotesingle'] = 238;
  48858. t['quotedblleft'] = 500;
  48859. t['guillemotleft'] = 556;
  48860. t['guilsinglleft'] = 333;
  48861. t['guilsinglright'] = 333;
  48862. t['fi'] = 611;
  48863. t['fl'] = 611;
  48864. t['endash'] = 556;
  48865. t['dagger'] = 556;
  48866. t['daggerdbl'] = 556;
  48867. t['periodcentered'] = 278;
  48868. t['paragraph'] = 556;
  48869. t['bullet'] = 350;
  48870. t['quotesinglbase'] = 278;
  48871. t['quotedblbase'] = 500;
  48872. t['quotedblright'] = 500;
  48873. t['guillemotright'] = 556;
  48874. t['ellipsis'] = 1000;
  48875. t['perthousand'] = 1000;
  48876. t['questiondown'] = 611;
  48877. t['grave'] = 333;
  48878. t['acute'] = 333;
  48879. t['circumflex'] = 333;
  48880. t['tilde'] = 333;
  48881. t['macron'] = 333;
  48882. t['breve'] = 333;
  48883. t['dotaccent'] = 333;
  48884. t['dieresis'] = 333;
  48885. t['ring'] = 333;
  48886. t['cedilla'] = 333;
  48887. t['hungarumlaut'] = 333;
  48888. t['ogonek'] = 333;
  48889. t['caron'] = 333;
  48890. t['emdash'] = 1000;
  48891. t['AE'] = 1000;
  48892. t['ordfeminine'] = 370;
  48893. t['Lslash'] = 611;
  48894. t['Oslash'] = 778;
  48895. t['OE'] = 1000;
  48896. t['ordmasculine'] = 365;
  48897. t['ae'] = 889;
  48898. t['dotlessi'] = 278;
  48899. t['lslash'] = 278;
  48900. t['oslash'] = 611;
  48901. t['oe'] = 944;
  48902. t['germandbls'] = 611;
  48903. t['Idieresis'] = 278;
  48904. t['eacute'] = 556;
  48905. t['abreve'] = 556;
  48906. t['uhungarumlaut'] = 611;
  48907. t['ecaron'] = 556;
  48908. t['Ydieresis'] = 667;
  48909. t['divide'] = 584;
  48910. t['Yacute'] = 667;
  48911. t['Acircumflex'] = 722;
  48912. t['aacute'] = 556;
  48913. t['Ucircumflex'] = 722;
  48914. t['yacute'] = 556;
  48915. t['scommaaccent'] = 556;
  48916. t['ecircumflex'] = 556;
  48917. t['Uring'] = 722;
  48918. t['Udieresis'] = 722;
  48919. t['aogonek'] = 556;
  48920. t['Uacute'] = 722;
  48921. t['uogonek'] = 611;
  48922. t['Edieresis'] = 667;
  48923. t['Dcroat'] = 722;
  48924. t['commaaccent'] = 250;
  48925. t['copyright'] = 737;
  48926. t['Emacron'] = 667;
  48927. t['ccaron'] = 556;
  48928. t['aring'] = 556;
  48929. t['Ncommaaccent'] = 722;
  48930. t['lacute'] = 278;
  48931. t['agrave'] = 556;
  48932. t['Tcommaaccent'] = 611;
  48933. t['Cacute'] = 722;
  48934. t['atilde'] = 556;
  48935. t['Edotaccent'] = 667;
  48936. t['scaron'] = 556;
  48937. t['scedilla'] = 556;
  48938. t['iacute'] = 278;
  48939. t['lozenge'] = 494;
  48940. t['Rcaron'] = 722;
  48941. t['Gcommaaccent'] = 778;
  48942. t['ucircumflex'] = 611;
  48943. t['acircumflex'] = 556;
  48944. t['Amacron'] = 722;
  48945. t['rcaron'] = 389;
  48946. t['ccedilla'] = 556;
  48947. t['Zdotaccent'] = 611;
  48948. t['Thorn'] = 667;
  48949. t['Omacron'] = 778;
  48950. t['Racute'] = 722;
  48951. t['Sacute'] = 667;
  48952. t['dcaron'] = 743;
  48953. t['Umacron'] = 722;
  48954. t['uring'] = 611;
  48955. t['threesuperior'] = 333;
  48956. t['Ograve'] = 778;
  48957. t['Agrave'] = 722;
  48958. t['Abreve'] = 722;
  48959. t['multiply'] = 584;
  48960. t['uacute'] = 611;
  48961. t['Tcaron'] = 611;
  48962. t['partialdiff'] = 494;
  48963. t['ydieresis'] = 556;
  48964. t['Nacute'] = 722;
  48965. t['icircumflex'] = 278;
  48966. t['Ecircumflex'] = 667;
  48967. t['adieresis'] = 556;
  48968. t['edieresis'] = 556;
  48969. t['cacute'] = 556;
  48970. t['nacute'] = 611;
  48971. t['umacron'] = 611;
  48972. t['Ncaron'] = 722;
  48973. t['Iacute'] = 278;
  48974. t['plusminus'] = 584;
  48975. t['brokenbar'] = 280;
  48976. t['registered'] = 737;
  48977. t['Gbreve'] = 778;
  48978. t['Idotaccent'] = 278;
  48979. t['summation'] = 600;
  48980. t['Egrave'] = 667;
  48981. t['racute'] = 389;
  48982. t['omacron'] = 611;
  48983. t['Zacute'] = 611;
  48984. t['Zcaron'] = 611;
  48985. t['greaterequal'] = 549;
  48986. t['Eth'] = 722;
  48987. t['Ccedilla'] = 722;
  48988. t['lcommaaccent'] = 278;
  48989. t['tcaron'] = 389;
  48990. t['eogonek'] = 556;
  48991. t['Uogonek'] = 722;
  48992. t['Aacute'] = 722;
  48993. t['Adieresis'] = 722;
  48994. t['egrave'] = 556;
  48995. t['zacute'] = 500;
  48996. t['iogonek'] = 278;
  48997. t['Oacute'] = 778;
  48998. t['oacute'] = 611;
  48999. t['amacron'] = 556;
  49000. t['sacute'] = 556;
  49001. t['idieresis'] = 278;
  49002. t['Ocircumflex'] = 778;
  49003. t['Ugrave'] = 722;
  49004. t['Delta'] = 612;
  49005. t['thorn'] = 611;
  49006. t['twosuperior'] = 333;
  49007. t['Odieresis'] = 778;
  49008. t['mu'] = 611;
  49009. t['igrave'] = 278;
  49010. t['ohungarumlaut'] = 611;
  49011. t['Eogonek'] = 667;
  49012. t['dcroat'] = 611;
  49013. t['threequarters'] = 834;
  49014. t['Scedilla'] = 667;
  49015. t['lcaron'] = 400;
  49016. t['Kcommaaccent'] = 722;
  49017. t['Lacute'] = 611;
  49018. t['trademark'] = 1000;
  49019. t['edotaccent'] = 556;
  49020. t['Igrave'] = 278;
  49021. t['Imacron'] = 278;
  49022. t['Lcaron'] = 611;
  49023. t['onehalf'] = 834;
  49024. t['lessequal'] = 549;
  49025. t['ocircumflex'] = 611;
  49026. t['ntilde'] = 611;
  49027. t['Uhungarumlaut'] = 722;
  49028. t['Eacute'] = 667;
  49029. t['emacron'] = 556;
  49030. t['gbreve'] = 611;
  49031. t['onequarter'] = 834;
  49032. t['Scaron'] = 667;
  49033. t['Scommaaccent'] = 667;
  49034. t['Ohungarumlaut'] = 778;
  49035. t['degree'] = 400;
  49036. t['ograve'] = 611;
  49037. t['Ccaron'] = 722;
  49038. t['ugrave'] = 611;
  49039. t['radical'] = 549;
  49040. t['Dcaron'] = 722;
  49041. t['rcommaaccent'] = 389;
  49042. t['Ntilde'] = 722;
  49043. t['otilde'] = 611;
  49044. t['Rcommaaccent'] = 722;
  49045. t['Lcommaaccent'] = 611;
  49046. t['Atilde'] = 722;
  49047. t['Aogonek'] = 722;
  49048. t['Aring'] = 722;
  49049. t['Otilde'] = 778;
  49050. t['zdotaccent'] = 500;
  49051. t['Ecaron'] = 667;
  49052. t['Iogonek'] = 278;
  49053. t['kcommaaccent'] = 556;
  49054. t['minus'] = 584;
  49055. t['Icircumflex'] = 278;
  49056. t['ncaron'] = 611;
  49057. t['tcommaaccent'] = 333;
  49058. t['logicalnot'] = 584;
  49059. t['odieresis'] = 611;
  49060. t['udieresis'] = 611;
  49061. t['notequal'] = 549;
  49062. t['gcommaaccent'] = 611;
  49063. t['eth'] = 611;
  49064. t['zcaron'] = 500;
  49065. t['ncommaaccent'] = 611;
  49066. t['onesuperior'] = 333;
  49067. t['imacron'] = 278;
  49068. t['Euro'] = 556;
  49069. });
  49070. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49071. t['space'] = 278;
  49072. t['exclam'] = 333;
  49073. t['quotedbl'] = 474;
  49074. t['numbersign'] = 556;
  49075. t['dollar'] = 556;
  49076. t['percent'] = 889;
  49077. t['ampersand'] = 722;
  49078. t['quoteright'] = 278;
  49079. t['parenleft'] = 333;
  49080. t['parenright'] = 333;
  49081. t['asterisk'] = 389;
  49082. t['plus'] = 584;
  49083. t['comma'] = 278;
  49084. t['hyphen'] = 333;
  49085. t['period'] = 278;
  49086. t['slash'] = 278;
  49087. t['zero'] = 556;
  49088. t['one'] = 556;
  49089. t['two'] = 556;
  49090. t['three'] = 556;
  49091. t['four'] = 556;
  49092. t['five'] = 556;
  49093. t['six'] = 556;
  49094. t['seven'] = 556;
  49095. t['eight'] = 556;
  49096. t['nine'] = 556;
  49097. t['colon'] = 333;
  49098. t['semicolon'] = 333;
  49099. t['less'] = 584;
  49100. t['equal'] = 584;
  49101. t['greater'] = 584;
  49102. t['question'] = 611;
  49103. t['at'] = 975;
  49104. t['A'] = 722;
  49105. t['B'] = 722;
  49106. t['C'] = 722;
  49107. t['D'] = 722;
  49108. t['E'] = 667;
  49109. t['F'] = 611;
  49110. t['G'] = 778;
  49111. t['H'] = 722;
  49112. t['I'] = 278;
  49113. t['J'] = 556;
  49114. t['K'] = 722;
  49115. t['L'] = 611;
  49116. t['M'] = 833;
  49117. t['N'] = 722;
  49118. t['O'] = 778;
  49119. t['P'] = 667;
  49120. t['Q'] = 778;
  49121. t['R'] = 722;
  49122. t['S'] = 667;
  49123. t['T'] = 611;
  49124. t['U'] = 722;
  49125. t['V'] = 667;
  49126. t['W'] = 944;
  49127. t['X'] = 667;
  49128. t['Y'] = 667;
  49129. t['Z'] = 611;
  49130. t['bracketleft'] = 333;
  49131. t['backslash'] = 278;
  49132. t['bracketright'] = 333;
  49133. t['asciicircum'] = 584;
  49134. t['underscore'] = 556;
  49135. t['quoteleft'] = 278;
  49136. t['a'] = 556;
  49137. t['b'] = 611;
  49138. t['c'] = 556;
  49139. t['d'] = 611;
  49140. t['e'] = 556;
  49141. t['f'] = 333;
  49142. t['g'] = 611;
  49143. t['h'] = 611;
  49144. t['i'] = 278;
  49145. t['j'] = 278;
  49146. t['k'] = 556;
  49147. t['l'] = 278;
  49148. t['m'] = 889;
  49149. t['n'] = 611;
  49150. t['o'] = 611;
  49151. t['p'] = 611;
  49152. t['q'] = 611;
  49153. t['r'] = 389;
  49154. t['s'] = 556;
  49155. t['t'] = 333;
  49156. t['u'] = 611;
  49157. t['v'] = 556;
  49158. t['w'] = 778;
  49159. t['x'] = 556;
  49160. t['y'] = 556;
  49161. t['z'] = 500;
  49162. t['braceleft'] = 389;
  49163. t['bar'] = 280;
  49164. t['braceright'] = 389;
  49165. t['asciitilde'] = 584;
  49166. t['exclamdown'] = 333;
  49167. t['cent'] = 556;
  49168. t['sterling'] = 556;
  49169. t['fraction'] = 167;
  49170. t['yen'] = 556;
  49171. t['florin'] = 556;
  49172. t['section'] = 556;
  49173. t['currency'] = 556;
  49174. t['quotesingle'] = 238;
  49175. t['quotedblleft'] = 500;
  49176. t['guillemotleft'] = 556;
  49177. t['guilsinglleft'] = 333;
  49178. t['guilsinglright'] = 333;
  49179. t['fi'] = 611;
  49180. t['fl'] = 611;
  49181. t['endash'] = 556;
  49182. t['dagger'] = 556;
  49183. t['daggerdbl'] = 556;
  49184. t['periodcentered'] = 278;
  49185. t['paragraph'] = 556;
  49186. t['bullet'] = 350;
  49187. t['quotesinglbase'] = 278;
  49188. t['quotedblbase'] = 500;
  49189. t['quotedblright'] = 500;
  49190. t['guillemotright'] = 556;
  49191. t['ellipsis'] = 1000;
  49192. t['perthousand'] = 1000;
  49193. t['questiondown'] = 611;
  49194. t['grave'] = 333;
  49195. t['acute'] = 333;
  49196. t['circumflex'] = 333;
  49197. t['tilde'] = 333;
  49198. t['macron'] = 333;
  49199. t['breve'] = 333;
  49200. t['dotaccent'] = 333;
  49201. t['dieresis'] = 333;
  49202. t['ring'] = 333;
  49203. t['cedilla'] = 333;
  49204. t['hungarumlaut'] = 333;
  49205. t['ogonek'] = 333;
  49206. t['caron'] = 333;
  49207. t['emdash'] = 1000;
  49208. t['AE'] = 1000;
  49209. t['ordfeminine'] = 370;
  49210. t['Lslash'] = 611;
  49211. t['Oslash'] = 778;
  49212. t['OE'] = 1000;
  49213. t['ordmasculine'] = 365;
  49214. t['ae'] = 889;
  49215. t['dotlessi'] = 278;
  49216. t['lslash'] = 278;
  49217. t['oslash'] = 611;
  49218. t['oe'] = 944;
  49219. t['germandbls'] = 611;
  49220. t['Idieresis'] = 278;
  49221. t['eacute'] = 556;
  49222. t['abreve'] = 556;
  49223. t['uhungarumlaut'] = 611;
  49224. t['ecaron'] = 556;
  49225. t['Ydieresis'] = 667;
  49226. t['divide'] = 584;
  49227. t['Yacute'] = 667;
  49228. t['Acircumflex'] = 722;
  49229. t['aacute'] = 556;
  49230. t['Ucircumflex'] = 722;
  49231. t['yacute'] = 556;
  49232. t['scommaaccent'] = 556;
  49233. t['ecircumflex'] = 556;
  49234. t['Uring'] = 722;
  49235. t['Udieresis'] = 722;
  49236. t['aogonek'] = 556;
  49237. t['Uacute'] = 722;
  49238. t['uogonek'] = 611;
  49239. t['Edieresis'] = 667;
  49240. t['Dcroat'] = 722;
  49241. t['commaaccent'] = 250;
  49242. t['copyright'] = 737;
  49243. t['Emacron'] = 667;
  49244. t['ccaron'] = 556;
  49245. t['aring'] = 556;
  49246. t['Ncommaaccent'] = 722;
  49247. t['lacute'] = 278;
  49248. t['agrave'] = 556;
  49249. t['Tcommaaccent'] = 611;
  49250. t['Cacute'] = 722;
  49251. t['atilde'] = 556;
  49252. t['Edotaccent'] = 667;
  49253. t['scaron'] = 556;
  49254. t['scedilla'] = 556;
  49255. t['iacute'] = 278;
  49256. t['lozenge'] = 494;
  49257. t['Rcaron'] = 722;
  49258. t['Gcommaaccent'] = 778;
  49259. t['ucircumflex'] = 611;
  49260. t['acircumflex'] = 556;
  49261. t['Amacron'] = 722;
  49262. t['rcaron'] = 389;
  49263. t['ccedilla'] = 556;
  49264. t['Zdotaccent'] = 611;
  49265. t['Thorn'] = 667;
  49266. t['Omacron'] = 778;
  49267. t['Racute'] = 722;
  49268. t['Sacute'] = 667;
  49269. t['dcaron'] = 743;
  49270. t['Umacron'] = 722;
  49271. t['uring'] = 611;
  49272. t['threesuperior'] = 333;
  49273. t['Ograve'] = 778;
  49274. t['Agrave'] = 722;
  49275. t['Abreve'] = 722;
  49276. t['multiply'] = 584;
  49277. t['uacute'] = 611;
  49278. t['Tcaron'] = 611;
  49279. t['partialdiff'] = 494;
  49280. t['ydieresis'] = 556;
  49281. t['Nacute'] = 722;
  49282. t['icircumflex'] = 278;
  49283. t['Ecircumflex'] = 667;
  49284. t['adieresis'] = 556;
  49285. t['edieresis'] = 556;
  49286. t['cacute'] = 556;
  49287. t['nacute'] = 611;
  49288. t['umacron'] = 611;
  49289. t['Ncaron'] = 722;
  49290. t['Iacute'] = 278;
  49291. t['plusminus'] = 584;
  49292. t['brokenbar'] = 280;
  49293. t['registered'] = 737;
  49294. t['Gbreve'] = 778;
  49295. t['Idotaccent'] = 278;
  49296. t['summation'] = 600;
  49297. t['Egrave'] = 667;
  49298. t['racute'] = 389;
  49299. t['omacron'] = 611;
  49300. t['Zacute'] = 611;
  49301. t['Zcaron'] = 611;
  49302. t['greaterequal'] = 549;
  49303. t['Eth'] = 722;
  49304. t['Ccedilla'] = 722;
  49305. t['lcommaaccent'] = 278;
  49306. t['tcaron'] = 389;
  49307. t['eogonek'] = 556;
  49308. t['Uogonek'] = 722;
  49309. t['Aacute'] = 722;
  49310. t['Adieresis'] = 722;
  49311. t['egrave'] = 556;
  49312. t['zacute'] = 500;
  49313. t['iogonek'] = 278;
  49314. t['Oacute'] = 778;
  49315. t['oacute'] = 611;
  49316. t['amacron'] = 556;
  49317. t['sacute'] = 556;
  49318. t['idieresis'] = 278;
  49319. t['Ocircumflex'] = 778;
  49320. t['Ugrave'] = 722;
  49321. t['Delta'] = 612;
  49322. t['thorn'] = 611;
  49323. t['twosuperior'] = 333;
  49324. t['Odieresis'] = 778;
  49325. t['mu'] = 611;
  49326. t['igrave'] = 278;
  49327. t['ohungarumlaut'] = 611;
  49328. t['Eogonek'] = 667;
  49329. t['dcroat'] = 611;
  49330. t['threequarters'] = 834;
  49331. t['Scedilla'] = 667;
  49332. t['lcaron'] = 400;
  49333. t['Kcommaaccent'] = 722;
  49334. t['Lacute'] = 611;
  49335. t['trademark'] = 1000;
  49336. t['edotaccent'] = 556;
  49337. t['Igrave'] = 278;
  49338. t['Imacron'] = 278;
  49339. t['Lcaron'] = 611;
  49340. t['onehalf'] = 834;
  49341. t['lessequal'] = 549;
  49342. t['ocircumflex'] = 611;
  49343. t['ntilde'] = 611;
  49344. t['Uhungarumlaut'] = 722;
  49345. t['Eacute'] = 667;
  49346. t['emacron'] = 556;
  49347. t['gbreve'] = 611;
  49348. t['onequarter'] = 834;
  49349. t['Scaron'] = 667;
  49350. t['Scommaaccent'] = 667;
  49351. t['Ohungarumlaut'] = 778;
  49352. t['degree'] = 400;
  49353. t['ograve'] = 611;
  49354. t['Ccaron'] = 722;
  49355. t['ugrave'] = 611;
  49356. t['radical'] = 549;
  49357. t['Dcaron'] = 722;
  49358. t['rcommaaccent'] = 389;
  49359. t['Ntilde'] = 722;
  49360. t['otilde'] = 611;
  49361. t['Rcommaaccent'] = 722;
  49362. t['Lcommaaccent'] = 611;
  49363. t['Atilde'] = 722;
  49364. t['Aogonek'] = 722;
  49365. t['Aring'] = 722;
  49366. t['Otilde'] = 778;
  49367. t['zdotaccent'] = 500;
  49368. t['Ecaron'] = 667;
  49369. t['Iogonek'] = 278;
  49370. t['kcommaaccent'] = 556;
  49371. t['minus'] = 584;
  49372. t['Icircumflex'] = 278;
  49373. t['ncaron'] = 611;
  49374. t['tcommaaccent'] = 333;
  49375. t['logicalnot'] = 584;
  49376. t['odieresis'] = 611;
  49377. t['udieresis'] = 611;
  49378. t['notequal'] = 549;
  49379. t['gcommaaccent'] = 611;
  49380. t['eth'] = 611;
  49381. t['zcaron'] = 500;
  49382. t['ncommaaccent'] = 611;
  49383. t['onesuperior'] = 333;
  49384. t['imacron'] = 278;
  49385. t['Euro'] = 556;
  49386. });
  49387. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  49388. t['space'] = 278;
  49389. t['exclam'] = 278;
  49390. t['quotedbl'] = 355;
  49391. t['numbersign'] = 556;
  49392. t['dollar'] = 556;
  49393. t['percent'] = 889;
  49394. t['ampersand'] = 667;
  49395. t['quoteright'] = 222;
  49396. t['parenleft'] = 333;
  49397. t['parenright'] = 333;
  49398. t['asterisk'] = 389;
  49399. t['plus'] = 584;
  49400. t['comma'] = 278;
  49401. t['hyphen'] = 333;
  49402. t['period'] = 278;
  49403. t['slash'] = 278;
  49404. t['zero'] = 556;
  49405. t['one'] = 556;
  49406. t['two'] = 556;
  49407. t['three'] = 556;
  49408. t['four'] = 556;
  49409. t['five'] = 556;
  49410. t['six'] = 556;
  49411. t['seven'] = 556;
  49412. t['eight'] = 556;
  49413. t['nine'] = 556;
  49414. t['colon'] = 278;
  49415. t['semicolon'] = 278;
  49416. t['less'] = 584;
  49417. t['equal'] = 584;
  49418. t['greater'] = 584;
  49419. t['question'] = 556;
  49420. t['at'] = 1015;
  49421. t['A'] = 667;
  49422. t['B'] = 667;
  49423. t['C'] = 722;
  49424. t['D'] = 722;
  49425. t['E'] = 667;
  49426. t['F'] = 611;
  49427. t['G'] = 778;
  49428. t['H'] = 722;
  49429. t['I'] = 278;
  49430. t['J'] = 500;
  49431. t['K'] = 667;
  49432. t['L'] = 556;
  49433. t['M'] = 833;
  49434. t['N'] = 722;
  49435. t['O'] = 778;
  49436. t['P'] = 667;
  49437. t['Q'] = 778;
  49438. t['R'] = 722;
  49439. t['S'] = 667;
  49440. t['T'] = 611;
  49441. t['U'] = 722;
  49442. t['V'] = 667;
  49443. t['W'] = 944;
  49444. t['X'] = 667;
  49445. t['Y'] = 667;
  49446. t['Z'] = 611;
  49447. t['bracketleft'] = 278;
  49448. t['backslash'] = 278;
  49449. t['bracketright'] = 278;
  49450. t['asciicircum'] = 469;
  49451. t['underscore'] = 556;
  49452. t['quoteleft'] = 222;
  49453. t['a'] = 556;
  49454. t['b'] = 556;
  49455. t['c'] = 500;
  49456. t['d'] = 556;
  49457. t['e'] = 556;
  49458. t['f'] = 278;
  49459. t['g'] = 556;
  49460. t['h'] = 556;
  49461. t['i'] = 222;
  49462. t['j'] = 222;
  49463. t['k'] = 500;
  49464. t['l'] = 222;
  49465. t['m'] = 833;
  49466. t['n'] = 556;
  49467. t['o'] = 556;
  49468. t['p'] = 556;
  49469. t['q'] = 556;
  49470. t['r'] = 333;
  49471. t['s'] = 500;
  49472. t['t'] = 278;
  49473. t['u'] = 556;
  49474. t['v'] = 500;
  49475. t['w'] = 722;
  49476. t['x'] = 500;
  49477. t['y'] = 500;
  49478. t['z'] = 500;
  49479. t['braceleft'] = 334;
  49480. t['bar'] = 260;
  49481. t['braceright'] = 334;
  49482. t['asciitilde'] = 584;
  49483. t['exclamdown'] = 333;
  49484. t['cent'] = 556;
  49485. t['sterling'] = 556;
  49486. t['fraction'] = 167;
  49487. t['yen'] = 556;
  49488. t['florin'] = 556;
  49489. t['section'] = 556;
  49490. t['currency'] = 556;
  49491. t['quotesingle'] = 191;
  49492. t['quotedblleft'] = 333;
  49493. t['guillemotleft'] = 556;
  49494. t['guilsinglleft'] = 333;
  49495. t['guilsinglright'] = 333;
  49496. t['fi'] = 500;
  49497. t['fl'] = 500;
  49498. t['endash'] = 556;
  49499. t['dagger'] = 556;
  49500. t['daggerdbl'] = 556;
  49501. t['periodcentered'] = 278;
  49502. t['paragraph'] = 537;
  49503. t['bullet'] = 350;
  49504. t['quotesinglbase'] = 222;
  49505. t['quotedblbase'] = 333;
  49506. t['quotedblright'] = 333;
  49507. t['guillemotright'] = 556;
  49508. t['ellipsis'] = 1000;
  49509. t['perthousand'] = 1000;
  49510. t['questiondown'] = 611;
  49511. t['grave'] = 333;
  49512. t['acute'] = 333;
  49513. t['circumflex'] = 333;
  49514. t['tilde'] = 333;
  49515. t['macron'] = 333;
  49516. t['breve'] = 333;
  49517. t['dotaccent'] = 333;
  49518. t['dieresis'] = 333;
  49519. t['ring'] = 333;
  49520. t['cedilla'] = 333;
  49521. t['hungarumlaut'] = 333;
  49522. t['ogonek'] = 333;
  49523. t['caron'] = 333;
  49524. t['emdash'] = 1000;
  49525. t['AE'] = 1000;
  49526. t['ordfeminine'] = 370;
  49527. t['Lslash'] = 556;
  49528. t['Oslash'] = 778;
  49529. t['OE'] = 1000;
  49530. t['ordmasculine'] = 365;
  49531. t['ae'] = 889;
  49532. t['dotlessi'] = 278;
  49533. t['lslash'] = 222;
  49534. t['oslash'] = 611;
  49535. t['oe'] = 944;
  49536. t['germandbls'] = 611;
  49537. t['Idieresis'] = 278;
  49538. t['eacute'] = 556;
  49539. t['abreve'] = 556;
  49540. t['uhungarumlaut'] = 556;
  49541. t['ecaron'] = 556;
  49542. t['Ydieresis'] = 667;
  49543. t['divide'] = 584;
  49544. t['Yacute'] = 667;
  49545. t['Acircumflex'] = 667;
  49546. t['aacute'] = 556;
  49547. t['Ucircumflex'] = 722;
  49548. t['yacute'] = 500;
  49549. t['scommaaccent'] = 500;
  49550. t['ecircumflex'] = 556;
  49551. t['Uring'] = 722;
  49552. t['Udieresis'] = 722;
  49553. t['aogonek'] = 556;
  49554. t['Uacute'] = 722;
  49555. t['uogonek'] = 556;
  49556. t['Edieresis'] = 667;
  49557. t['Dcroat'] = 722;
  49558. t['commaaccent'] = 250;
  49559. t['copyright'] = 737;
  49560. t['Emacron'] = 667;
  49561. t['ccaron'] = 500;
  49562. t['aring'] = 556;
  49563. t['Ncommaaccent'] = 722;
  49564. t['lacute'] = 222;
  49565. t['agrave'] = 556;
  49566. t['Tcommaaccent'] = 611;
  49567. t['Cacute'] = 722;
  49568. t['atilde'] = 556;
  49569. t['Edotaccent'] = 667;
  49570. t['scaron'] = 500;
  49571. t['scedilla'] = 500;
  49572. t['iacute'] = 278;
  49573. t['lozenge'] = 471;
  49574. t['Rcaron'] = 722;
  49575. t['Gcommaaccent'] = 778;
  49576. t['ucircumflex'] = 556;
  49577. t['acircumflex'] = 556;
  49578. t['Amacron'] = 667;
  49579. t['rcaron'] = 333;
  49580. t['ccedilla'] = 500;
  49581. t['Zdotaccent'] = 611;
  49582. t['Thorn'] = 667;
  49583. t['Omacron'] = 778;
  49584. t['Racute'] = 722;
  49585. t['Sacute'] = 667;
  49586. t['dcaron'] = 643;
  49587. t['Umacron'] = 722;
  49588. t['uring'] = 556;
  49589. t['threesuperior'] = 333;
  49590. t['Ograve'] = 778;
  49591. t['Agrave'] = 667;
  49592. t['Abreve'] = 667;
  49593. t['multiply'] = 584;
  49594. t['uacute'] = 556;
  49595. t['Tcaron'] = 611;
  49596. t['partialdiff'] = 476;
  49597. t['ydieresis'] = 500;
  49598. t['Nacute'] = 722;
  49599. t['icircumflex'] = 278;
  49600. t['Ecircumflex'] = 667;
  49601. t['adieresis'] = 556;
  49602. t['edieresis'] = 556;
  49603. t['cacute'] = 500;
  49604. t['nacute'] = 556;
  49605. t['umacron'] = 556;
  49606. t['Ncaron'] = 722;
  49607. t['Iacute'] = 278;
  49608. t['plusminus'] = 584;
  49609. t['brokenbar'] = 260;
  49610. t['registered'] = 737;
  49611. t['Gbreve'] = 778;
  49612. t['Idotaccent'] = 278;
  49613. t['summation'] = 600;
  49614. t['Egrave'] = 667;
  49615. t['racute'] = 333;
  49616. t['omacron'] = 556;
  49617. t['Zacute'] = 611;
  49618. t['Zcaron'] = 611;
  49619. t['greaterequal'] = 549;
  49620. t['Eth'] = 722;
  49621. t['Ccedilla'] = 722;
  49622. t['lcommaaccent'] = 222;
  49623. t['tcaron'] = 317;
  49624. t['eogonek'] = 556;
  49625. t['Uogonek'] = 722;
  49626. t['Aacute'] = 667;
  49627. t['Adieresis'] = 667;
  49628. t['egrave'] = 556;
  49629. t['zacute'] = 500;
  49630. t['iogonek'] = 222;
  49631. t['Oacute'] = 778;
  49632. t['oacute'] = 556;
  49633. t['amacron'] = 556;
  49634. t['sacute'] = 500;
  49635. t['idieresis'] = 278;
  49636. t['Ocircumflex'] = 778;
  49637. t['Ugrave'] = 722;
  49638. t['Delta'] = 612;
  49639. t['thorn'] = 556;
  49640. t['twosuperior'] = 333;
  49641. t['Odieresis'] = 778;
  49642. t['mu'] = 556;
  49643. t['igrave'] = 278;
  49644. t['ohungarumlaut'] = 556;
  49645. t['Eogonek'] = 667;
  49646. t['dcroat'] = 556;
  49647. t['threequarters'] = 834;
  49648. t['Scedilla'] = 667;
  49649. t['lcaron'] = 299;
  49650. t['Kcommaaccent'] = 667;
  49651. t['Lacute'] = 556;
  49652. t['trademark'] = 1000;
  49653. t['edotaccent'] = 556;
  49654. t['Igrave'] = 278;
  49655. t['Imacron'] = 278;
  49656. t['Lcaron'] = 556;
  49657. t['onehalf'] = 834;
  49658. t['lessequal'] = 549;
  49659. t['ocircumflex'] = 556;
  49660. t['ntilde'] = 556;
  49661. t['Uhungarumlaut'] = 722;
  49662. t['Eacute'] = 667;
  49663. t['emacron'] = 556;
  49664. t['gbreve'] = 556;
  49665. t['onequarter'] = 834;
  49666. t['Scaron'] = 667;
  49667. t['Scommaaccent'] = 667;
  49668. t['Ohungarumlaut'] = 778;
  49669. t['degree'] = 400;
  49670. t['ograve'] = 556;
  49671. t['Ccaron'] = 722;
  49672. t['ugrave'] = 556;
  49673. t['radical'] = 453;
  49674. t['Dcaron'] = 722;
  49675. t['rcommaaccent'] = 333;
  49676. t['Ntilde'] = 722;
  49677. t['otilde'] = 556;
  49678. t['Rcommaaccent'] = 722;
  49679. t['Lcommaaccent'] = 556;
  49680. t['Atilde'] = 667;
  49681. t['Aogonek'] = 667;
  49682. t['Aring'] = 667;
  49683. t['Otilde'] = 778;
  49684. t['zdotaccent'] = 500;
  49685. t['Ecaron'] = 667;
  49686. t['Iogonek'] = 278;
  49687. t['kcommaaccent'] = 500;
  49688. t['minus'] = 584;
  49689. t['Icircumflex'] = 278;
  49690. t['ncaron'] = 556;
  49691. t['tcommaaccent'] = 278;
  49692. t['logicalnot'] = 584;
  49693. t['odieresis'] = 556;
  49694. t['udieresis'] = 556;
  49695. t['notequal'] = 549;
  49696. t['gcommaaccent'] = 556;
  49697. t['eth'] = 556;
  49698. t['zcaron'] = 500;
  49699. t['ncommaaccent'] = 556;
  49700. t['onesuperior'] = 333;
  49701. t['imacron'] = 278;
  49702. t['Euro'] = 556;
  49703. });
  49704. t['Symbol'] = getLookupTableFactory(function (t) {
  49705. t['space'] = 250;
  49706. t['exclam'] = 333;
  49707. t['universal'] = 713;
  49708. t['numbersign'] = 500;
  49709. t['existential'] = 549;
  49710. t['percent'] = 833;
  49711. t['ampersand'] = 778;
  49712. t['suchthat'] = 439;
  49713. t['parenleft'] = 333;
  49714. t['parenright'] = 333;
  49715. t['asteriskmath'] = 500;
  49716. t['plus'] = 549;
  49717. t['comma'] = 250;
  49718. t['minus'] = 549;
  49719. t['period'] = 250;
  49720. t['slash'] = 278;
  49721. t['zero'] = 500;
  49722. t['one'] = 500;
  49723. t['two'] = 500;
  49724. t['three'] = 500;
  49725. t['four'] = 500;
  49726. t['five'] = 500;
  49727. t['six'] = 500;
  49728. t['seven'] = 500;
  49729. t['eight'] = 500;
  49730. t['nine'] = 500;
  49731. t['colon'] = 278;
  49732. t['semicolon'] = 278;
  49733. t['less'] = 549;
  49734. t['equal'] = 549;
  49735. t['greater'] = 549;
  49736. t['question'] = 444;
  49737. t['congruent'] = 549;
  49738. t['Alpha'] = 722;
  49739. t['Beta'] = 667;
  49740. t['Chi'] = 722;
  49741. t['Delta'] = 612;
  49742. t['Epsilon'] = 611;
  49743. t['Phi'] = 763;
  49744. t['Gamma'] = 603;
  49745. t['Eta'] = 722;
  49746. t['Iota'] = 333;
  49747. t['theta1'] = 631;
  49748. t['Kappa'] = 722;
  49749. t['Lambda'] = 686;
  49750. t['Mu'] = 889;
  49751. t['Nu'] = 722;
  49752. t['Omicron'] = 722;
  49753. t['Pi'] = 768;
  49754. t['Theta'] = 741;
  49755. t['Rho'] = 556;
  49756. t['Sigma'] = 592;
  49757. t['Tau'] = 611;
  49758. t['Upsilon'] = 690;
  49759. t['sigma1'] = 439;
  49760. t['Omega'] = 768;
  49761. t['Xi'] = 645;
  49762. t['Psi'] = 795;
  49763. t['Zeta'] = 611;
  49764. t['bracketleft'] = 333;
  49765. t['therefore'] = 863;
  49766. t['bracketright'] = 333;
  49767. t['perpendicular'] = 658;
  49768. t['underscore'] = 500;
  49769. t['radicalex'] = 500;
  49770. t['alpha'] = 631;
  49771. t['beta'] = 549;
  49772. t['chi'] = 549;
  49773. t['delta'] = 494;
  49774. t['epsilon'] = 439;
  49775. t['phi'] = 521;
  49776. t['gamma'] = 411;
  49777. t['eta'] = 603;
  49778. t['iota'] = 329;
  49779. t['phi1'] = 603;
  49780. t['kappa'] = 549;
  49781. t['lambda'] = 549;
  49782. t['mu'] = 576;
  49783. t['nu'] = 521;
  49784. t['omicron'] = 549;
  49785. t['pi'] = 549;
  49786. t['theta'] = 521;
  49787. t['rho'] = 549;
  49788. t['sigma'] = 603;
  49789. t['tau'] = 439;
  49790. t['upsilon'] = 576;
  49791. t['omega1'] = 713;
  49792. t['omega'] = 686;
  49793. t['xi'] = 493;
  49794. t['psi'] = 686;
  49795. t['zeta'] = 494;
  49796. t['braceleft'] = 480;
  49797. t['bar'] = 200;
  49798. t['braceright'] = 480;
  49799. t['similar'] = 549;
  49800. t['Euro'] = 750;
  49801. t['Upsilon1'] = 620;
  49802. t['minute'] = 247;
  49803. t['lessequal'] = 549;
  49804. t['fraction'] = 167;
  49805. t['infinity'] = 713;
  49806. t['florin'] = 500;
  49807. t['club'] = 753;
  49808. t['diamond'] = 753;
  49809. t['heart'] = 753;
  49810. t['spade'] = 753;
  49811. t['arrowboth'] = 1042;
  49812. t['arrowleft'] = 987;
  49813. t['arrowup'] = 603;
  49814. t['arrowright'] = 987;
  49815. t['arrowdown'] = 603;
  49816. t['degree'] = 400;
  49817. t['plusminus'] = 549;
  49818. t['second'] = 411;
  49819. t['greaterequal'] = 549;
  49820. t['multiply'] = 549;
  49821. t['proportional'] = 713;
  49822. t['partialdiff'] = 494;
  49823. t['bullet'] = 460;
  49824. t['divide'] = 549;
  49825. t['notequal'] = 549;
  49826. t['equivalence'] = 549;
  49827. t['approxequal'] = 549;
  49828. t['ellipsis'] = 1000;
  49829. t['arrowvertex'] = 603;
  49830. t['arrowhorizex'] = 1000;
  49831. t['carriagereturn'] = 658;
  49832. t['aleph'] = 823;
  49833. t['Ifraktur'] = 686;
  49834. t['Rfraktur'] = 795;
  49835. t['weierstrass'] = 987;
  49836. t['circlemultiply'] = 768;
  49837. t['circleplus'] = 768;
  49838. t['emptyset'] = 823;
  49839. t['intersection'] = 768;
  49840. t['union'] = 768;
  49841. t['propersuperset'] = 713;
  49842. t['reflexsuperset'] = 713;
  49843. t['notsubset'] = 713;
  49844. t['propersubset'] = 713;
  49845. t['reflexsubset'] = 713;
  49846. t['element'] = 713;
  49847. t['notelement'] = 713;
  49848. t['angle'] = 768;
  49849. t['gradient'] = 713;
  49850. t['registerserif'] = 790;
  49851. t['copyrightserif'] = 790;
  49852. t['trademarkserif'] = 890;
  49853. t['product'] = 823;
  49854. t['radical'] = 549;
  49855. t['dotmath'] = 250;
  49856. t['logicalnot'] = 713;
  49857. t['logicaland'] = 603;
  49858. t['logicalor'] = 603;
  49859. t['arrowdblboth'] = 1042;
  49860. t['arrowdblleft'] = 987;
  49861. t['arrowdblup'] = 603;
  49862. t['arrowdblright'] = 987;
  49863. t['arrowdbldown'] = 603;
  49864. t['lozenge'] = 494;
  49865. t['angleleft'] = 329;
  49866. t['registersans'] = 790;
  49867. t['copyrightsans'] = 790;
  49868. t['trademarksans'] = 786;
  49869. t['summation'] = 713;
  49870. t['parenlefttp'] = 384;
  49871. t['parenleftex'] = 384;
  49872. t['parenleftbt'] = 384;
  49873. t['bracketlefttp'] = 384;
  49874. t['bracketleftex'] = 384;
  49875. t['bracketleftbt'] = 384;
  49876. t['bracelefttp'] = 494;
  49877. t['braceleftmid'] = 494;
  49878. t['braceleftbt'] = 494;
  49879. t['braceex'] = 494;
  49880. t['angleright'] = 329;
  49881. t['integral'] = 274;
  49882. t['integraltp'] = 686;
  49883. t['integralex'] = 686;
  49884. t['integralbt'] = 686;
  49885. t['parenrighttp'] = 384;
  49886. t['parenrightex'] = 384;
  49887. t['parenrightbt'] = 384;
  49888. t['bracketrighttp'] = 384;
  49889. t['bracketrightex'] = 384;
  49890. t['bracketrightbt'] = 384;
  49891. t['bracerighttp'] = 494;
  49892. t['bracerightmid'] = 494;
  49893. t['bracerightbt'] = 494;
  49894. t['apple'] = 790;
  49895. });
  49896. t['Times-Roman'] = getLookupTableFactory(function (t) {
  49897. t['space'] = 250;
  49898. t['exclam'] = 333;
  49899. t['quotedbl'] = 408;
  49900. t['numbersign'] = 500;
  49901. t['dollar'] = 500;
  49902. t['percent'] = 833;
  49903. t['ampersand'] = 778;
  49904. t['quoteright'] = 333;
  49905. t['parenleft'] = 333;
  49906. t['parenright'] = 333;
  49907. t['asterisk'] = 500;
  49908. t['plus'] = 564;
  49909. t['comma'] = 250;
  49910. t['hyphen'] = 333;
  49911. t['period'] = 250;
  49912. t['slash'] = 278;
  49913. t['zero'] = 500;
  49914. t['one'] = 500;
  49915. t['two'] = 500;
  49916. t['three'] = 500;
  49917. t['four'] = 500;
  49918. t['five'] = 500;
  49919. t['six'] = 500;
  49920. t['seven'] = 500;
  49921. t['eight'] = 500;
  49922. t['nine'] = 500;
  49923. t['colon'] = 278;
  49924. t['semicolon'] = 278;
  49925. t['less'] = 564;
  49926. t['equal'] = 564;
  49927. t['greater'] = 564;
  49928. t['question'] = 444;
  49929. t['at'] = 921;
  49930. t['A'] = 722;
  49931. t['B'] = 667;
  49932. t['C'] = 667;
  49933. t['D'] = 722;
  49934. t['E'] = 611;
  49935. t['F'] = 556;
  49936. t['G'] = 722;
  49937. t['H'] = 722;
  49938. t['I'] = 333;
  49939. t['J'] = 389;
  49940. t['K'] = 722;
  49941. t['L'] = 611;
  49942. t['M'] = 889;
  49943. t['N'] = 722;
  49944. t['O'] = 722;
  49945. t['P'] = 556;
  49946. t['Q'] = 722;
  49947. t['R'] = 667;
  49948. t['S'] = 556;
  49949. t['T'] = 611;
  49950. t['U'] = 722;
  49951. t['V'] = 722;
  49952. t['W'] = 944;
  49953. t['X'] = 722;
  49954. t['Y'] = 722;
  49955. t['Z'] = 611;
  49956. t['bracketleft'] = 333;
  49957. t['backslash'] = 278;
  49958. t['bracketright'] = 333;
  49959. t['asciicircum'] = 469;
  49960. t['underscore'] = 500;
  49961. t['quoteleft'] = 333;
  49962. t['a'] = 444;
  49963. t['b'] = 500;
  49964. t['c'] = 444;
  49965. t['d'] = 500;
  49966. t['e'] = 444;
  49967. t['f'] = 333;
  49968. t['g'] = 500;
  49969. t['h'] = 500;
  49970. t['i'] = 278;
  49971. t['j'] = 278;
  49972. t['k'] = 500;
  49973. t['l'] = 278;
  49974. t['m'] = 778;
  49975. t['n'] = 500;
  49976. t['o'] = 500;
  49977. t['p'] = 500;
  49978. t['q'] = 500;
  49979. t['r'] = 333;
  49980. t['s'] = 389;
  49981. t['t'] = 278;
  49982. t['u'] = 500;
  49983. t['v'] = 500;
  49984. t['w'] = 722;
  49985. t['x'] = 500;
  49986. t['y'] = 500;
  49987. t['z'] = 444;
  49988. t['braceleft'] = 480;
  49989. t['bar'] = 200;
  49990. t['braceright'] = 480;
  49991. t['asciitilde'] = 541;
  49992. t['exclamdown'] = 333;
  49993. t['cent'] = 500;
  49994. t['sterling'] = 500;
  49995. t['fraction'] = 167;
  49996. t['yen'] = 500;
  49997. t['florin'] = 500;
  49998. t['section'] = 500;
  49999. t['currency'] = 500;
  50000. t['quotesingle'] = 180;
  50001. t['quotedblleft'] = 444;
  50002. t['guillemotleft'] = 500;
  50003. t['guilsinglleft'] = 333;
  50004. t['guilsinglright'] = 333;
  50005. t['fi'] = 556;
  50006. t['fl'] = 556;
  50007. t['endash'] = 500;
  50008. t['dagger'] = 500;
  50009. t['daggerdbl'] = 500;
  50010. t['periodcentered'] = 250;
  50011. t['paragraph'] = 453;
  50012. t['bullet'] = 350;
  50013. t['quotesinglbase'] = 333;
  50014. t['quotedblbase'] = 444;
  50015. t['quotedblright'] = 444;
  50016. t['guillemotright'] = 500;
  50017. t['ellipsis'] = 1000;
  50018. t['perthousand'] = 1000;
  50019. t['questiondown'] = 444;
  50020. t['grave'] = 333;
  50021. t['acute'] = 333;
  50022. t['circumflex'] = 333;
  50023. t['tilde'] = 333;
  50024. t['macron'] = 333;
  50025. t['breve'] = 333;
  50026. t['dotaccent'] = 333;
  50027. t['dieresis'] = 333;
  50028. t['ring'] = 333;
  50029. t['cedilla'] = 333;
  50030. t['hungarumlaut'] = 333;
  50031. t['ogonek'] = 333;
  50032. t['caron'] = 333;
  50033. t['emdash'] = 1000;
  50034. t['AE'] = 889;
  50035. t['ordfeminine'] = 276;
  50036. t['Lslash'] = 611;
  50037. t['Oslash'] = 722;
  50038. t['OE'] = 889;
  50039. t['ordmasculine'] = 310;
  50040. t['ae'] = 667;
  50041. t['dotlessi'] = 278;
  50042. t['lslash'] = 278;
  50043. t['oslash'] = 500;
  50044. t['oe'] = 722;
  50045. t['germandbls'] = 500;
  50046. t['Idieresis'] = 333;
  50047. t['eacute'] = 444;
  50048. t['abreve'] = 444;
  50049. t['uhungarumlaut'] = 500;
  50050. t['ecaron'] = 444;
  50051. t['Ydieresis'] = 722;
  50052. t['divide'] = 564;
  50053. t['Yacute'] = 722;
  50054. t['Acircumflex'] = 722;
  50055. t['aacute'] = 444;
  50056. t['Ucircumflex'] = 722;
  50057. t['yacute'] = 500;
  50058. t['scommaaccent'] = 389;
  50059. t['ecircumflex'] = 444;
  50060. t['Uring'] = 722;
  50061. t['Udieresis'] = 722;
  50062. t['aogonek'] = 444;
  50063. t['Uacute'] = 722;
  50064. t['uogonek'] = 500;
  50065. t['Edieresis'] = 611;
  50066. t['Dcroat'] = 722;
  50067. t['commaaccent'] = 250;
  50068. t['copyright'] = 760;
  50069. t['Emacron'] = 611;
  50070. t['ccaron'] = 444;
  50071. t['aring'] = 444;
  50072. t['Ncommaaccent'] = 722;
  50073. t['lacute'] = 278;
  50074. t['agrave'] = 444;
  50075. t['Tcommaaccent'] = 611;
  50076. t['Cacute'] = 667;
  50077. t['atilde'] = 444;
  50078. t['Edotaccent'] = 611;
  50079. t['scaron'] = 389;
  50080. t['scedilla'] = 389;
  50081. t['iacute'] = 278;
  50082. t['lozenge'] = 471;
  50083. t['Rcaron'] = 667;
  50084. t['Gcommaaccent'] = 722;
  50085. t['ucircumflex'] = 500;
  50086. t['acircumflex'] = 444;
  50087. t['Amacron'] = 722;
  50088. t['rcaron'] = 333;
  50089. t['ccedilla'] = 444;
  50090. t['Zdotaccent'] = 611;
  50091. t['Thorn'] = 556;
  50092. t['Omacron'] = 722;
  50093. t['Racute'] = 667;
  50094. t['Sacute'] = 556;
  50095. t['dcaron'] = 588;
  50096. t['Umacron'] = 722;
  50097. t['uring'] = 500;
  50098. t['threesuperior'] = 300;
  50099. t['Ograve'] = 722;
  50100. t['Agrave'] = 722;
  50101. t['Abreve'] = 722;
  50102. t['multiply'] = 564;
  50103. t['uacute'] = 500;
  50104. t['Tcaron'] = 611;
  50105. t['partialdiff'] = 476;
  50106. t['ydieresis'] = 500;
  50107. t['Nacute'] = 722;
  50108. t['icircumflex'] = 278;
  50109. t['Ecircumflex'] = 611;
  50110. t['adieresis'] = 444;
  50111. t['edieresis'] = 444;
  50112. t['cacute'] = 444;
  50113. t['nacute'] = 500;
  50114. t['umacron'] = 500;
  50115. t['Ncaron'] = 722;
  50116. t['Iacute'] = 333;
  50117. t['plusminus'] = 564;
  50118. t['brokenbar'] = 200;
  50119. t['registered'] = 760;
  50120. t['Gbreve'] = 722;
  50121. t['Idotaccent'] = 333;
  50122. t['summation'] = 600;
  50123. t['Egrave'] = 611;
  50124. t['racute'] = 333;
  50125. t['omacron'] = 500;
  50126. t['Zacute'] = 611;
  50127. t['Zcaron'] = 611;
  50128. t['greaterequal'] = 549;
  50129. t['Eth'] = 722;
  50130. t['Ccedilla'] = 667;
  50131. t['lcommaaccent'] = 278;
  50132. t['tcaron'] = 326;
  50133. t['eogonek'] = 444;
  50134. t['Uogonek'] = 722;
  50135. t['Aacute'] = 722;
  50136. t['Adieresis'] = 722;
  50137. t['egrave'] = 444;
  50138. t['zacute'] = 444;
  50139. t['iogonek'] = 278;
  50140. t['Oacute'] = 722;
  50141. t['oacute'] = 500;
  50142. t['amacron'] = 444;
  50143. t['sacute'] = 389;
  50144. t['idieresis'] = 278;
  50145. t['Ocircumflex'] = 722;
  50146. t['Ugrave'] = 722;
  50147. t['Delta'] = 612;
  50148. t['thorn'] = 500;
  50149. t['twosuperior'] = 300;
  50150. t['Odieresis'] = 722;
  50151. t['mu'] = 500;
  50152. t['igrave'] = 278;
  50153. t['ohungarumlaut'] = 500;
  50154. t['Eogonek'] = 611;
  50155. t['dcroat'] = 500;
  50156. t['threequarters'] = 750;
  50157. t['Scedilla'] = 556;
  50158. t['lcaron'] = 344;
  50159. t['Kcommaaccent'] = 722;
  50160. t['Lacute'] = 611;
  50161. t['trademark'] = 980;
  50162. t['edotaccent'] = 444;
  50163. t['Igrave'] = 333;
  50164. t['Imacron'] = 333;
  50165. t['Lcaron'] = 611;
  50166. t['onehalf'] = 750;
  50167. t['lessequal'] = 549;
  50168. t['ocircumflex'] = 500;
  50169. t['ntilde'] = 500;
  50170. t['Uhungarumlaut'] = 722;
  50171. t['Eacute'] = 611;
  50172. t['emacron'] = 444;
  50173. t['gbreve'] = 500;
  50174. t['onequarter'] = 750;
  50175. t['Scaron'] = 556;
  50176. t['Scommaaccent'] = 556;
  50177. t['Ohungarumlaut'] = 722;
  50178. t['degree'] = 400;
  50179. t['ograve'] = 500;
  50180. t['Ccaron'] = 667;
  50181. t['ugrave'] = 500;
  50182. t['radical'] = 453;
  50183. t['Dcaron'] = 722;
  50184. t['rcommaaccent'] = 333;
  50185. t['Ntilde'] = 722;
  50186. t['otilde'] = 500;
  50187. t['Rcommaaccent'] = 667;
  50188. t['Lcommaaccent'] = 611;
  50189. t['Atilde'] = 722;
  50190. t['Aogonek'] = 722;
  50191. t['Aring'] = 722;
  50192. t['Otilde'] = 722;
  50193. t['zdotaccent'] = 444;
  50194. t['Ecaron'] = 611;
  50195. t['Iogonek'] = 333;
  50196. t['kcommaaccent'] = 500;
  50197. t['minus'] = 564;
  50198. t['Icircumflex'] = 333;
  50199. t['ncaron'] = 500;
  50200. t['tcommaaccent'] = 278;
  50201. t['logicalnot'] = 564;
  50202. t['odieresis'] = 500;
  50203. t['udieresis'] = 500;
  50204. t['notequal'] = 549;
  50205. t['gcommaaccent'] = 500;
  50206. t['eth'] = 500;
  50207. t['zcaron'] = 444;
  50208. t['ncommaaccent'] = 500;
  50209. t['onesuperior'] = 300;
  50210. t['imacron'] = 278;
  50211. t['Euro'] = 500;
  50212. });
  50213. t['Times-Bold'] = getLookupTableFactory(function (t) {
  50214. t['space'] = 250;
  50215. t['exclam'] = 333;
  50216. t['quotedbl'] = 555;
  50217. t['numbersign'] = 500;
  50218. t['dollar'] = 500;
  50219. t['percent'] = 1000;
  50220. t['ampersand'] = 833;
  50221. t['quoteright'] = 333;
  50222. t['parenleft'] = 333;
  50223. t['parenright'] = 333;
  50224. t['asterisk'] = 500;
  50225. t['plus'] = 570;
  50226. t['comma'] = 250;
  50227. t['hyphen'] = 333;
  50228. t['period'] = 250;
  50229. t['slash'] = 278;
  50230. t['zero'] = 500;
  50231. t['one'] = 500;
  50232. t['two'] = 500;
  50233. t['three'] = 500;
  50234. t['four'] = 500;
  50235. t['five'] = 500;
  50236. t['six'] = 500;
  50237. t['seven'] = 500;
  50238. t['eight'] = 500;
  50239. t['nine'] = 500;
  50240. t['colon'] = 333;
  50241. t['semicolon'] = 333;
  50242. t['less'] = 570;
  50243. t['equal'] = 570;
  50244. t['greater'] = 570;
  50245. t['question'] = 500;
  50246. t['at'] = 930;
  50247. t['A'] = 722;
  50248. t['B'] = 667;
  50249. t['C'] = 722;
  50250. t['D'] = 722;
  50251. t['E'] = 667;
  50252. t['F'] = 611;
  50253. t['G'] = 778;
  50254. t['H'] = 778;
  50255. t['I'] = 389;
  50256. t['J'] = 500;
  50257. t['K'] = 778;
  50258. t['L'] = 667;
  50259. t['M'] = 944;
  50260. t['N'] = 722;
  50261. t['O'] = 778;
  50262. t['P'] = 611;
  50263. t['Q'] = 778;
  50264. t['R'] = 722;
  50265. t['S'] = 556;
  50266. t['T'] = 667;
  50267. t['U'] = 722;
  50268. t['V'] = 722;
  50269. t['W'] = 1000;
  50270. t['X'] = 722;
  50271. t['Y'] = 722;
  50272. t['Z'] = 667;
  50273. t['bracketleft'] = 333;
  50274. t['backslash'] = 278;
  50275. t['bracketright'] = 333;
  50276. t['asciicircum'] = 581;
  50277. t['underscore'] = 500;
  50278. t['quoteleft'] = 333;
  50279. t['a'] = 500;
  50280. t['b'] = 556;
  50281. t['c'] = 444;
  50282. t['d'] = 556;
  50283. t['e'] = 444;
  50284. t['f'] = 333;
  50285. t['g'] = 500;
  50286. t['h'] = 556;
  50287. t['i'] = 278;
  50288. t['j'] = 333;
  50289. t['k'] = 556;
  50290. t['l'] = 278;
  50291. t['m'] = 833;
  50292. t['n'] = 556;
  50293. t['o'] = 500;
  50294. t['p'] = 556;
  50295. t['q'] = 556;
  50296. t['r'] = 444;
  50297. t['s'] = 389;
  50298. t['t'] = 333;
  50299. t['u'] = 556;
  50300. t['v'] = 500;
  50301. t['w'] = 722;
  50302. t['x'] = 500;
  50303. t['y'] = 500;
  50304. t['z'] = 444;
  50305. t['braceleft'] = 394;
  50306. t['bar'] = 220;
  50307. t['braceright'] = 394;
  50308. t['asciitilde'] = 520;
  50309. t['exclamdown'] = 333;
  50310. t['cent'] = 500;
  50311. t['sterling'] = 500;
  50312. t['fraction'] = 167;
  50313. t['yen'] = 500;
  50314. t['florin'] = 500;
  50315. t['section'] = 500;
  50316. t['currency'] = 500;
  50317. t['quotesingle'] = 278;
  50318. t['quotedblleft'] = 500;
  50319. t['guillemotleft'] = 500;
  50320. t['guilsinglleft'] = 333;
  50321. t['guilsinglright'] = 333;
  50322. t['fi'] = 556;
  50323. t['fl'] = 556;
  50324. t['endash'] = 500;
  50325. t['dagger'] = 500;
  50326. t['daggerdbl'] = 500;
  50327. t['periodcentered'] = 250;
  50328. t['paragraph'] = 540;
  50329. t['bullet'] = 350;
  50330. t['quotesinglbase'] = 333;
  50331. t['quotedblbase'] = 500;
  50332. t['quotedblright'] = 500;
  50333. t['guillemotright'] = 500;
  50334. t['ellipsis'] = 1000;
  50335. t['perthousand'] = 1000;
  50336. t['questiondown'] = 500;
  50337. t['grave'] = 333;
  50338. t['acute'] = 333;
  50339. t['circumflex'] = 333;
  50340. t['tilde'] = 333;
  50341. t['macron'] = 333;
  50342. t['breve'] = 333;
  50343. t['dotaccent'] = 333;
  50344. t['dieresis'] = 333;
  50345. t['ring'] = 333;
  50346. t['cedilla'] = 333;
  50347. t['hungarumlaut'] = 333;
  50348. t['ogonek'] = 333;
  50349. t['caron'] = 333;
  50350. t['emdash'] = 1000;
  50351. t['AE'] = 1000;
  50352. t['ordfeminine'] = 300;
  50353. t['Lslash'] = 667;
  50354. t['Oslash'] = 778;
  50355. t['OE'] = 1000;
  50356. t['ordmasculine'] = 330;
  50357. t['ae'] = 722;
  50358. t['dotlessi'] = 278;
  50359. t['lslash'] = 278;
  50360. t['oslash'] = 500;
  50361. t['oe'] = 722;
  50362. t['germandbls'] = 556;
  50363. t['Idieresis'] = 389;
  50364. t['eacute'] = 444;
  50365. t['abreve'] = 500;
  50366. t['uhungarumlaut'] = 556;
  50367. t['ecaron'] = 444;
  50368. t['Ydieresis'] = 722;
  50369. t['divide'] = 570;
  50370. t['Yacute'] = 722;
  50371. t['Acircumflex'] = 722;
  50372. t['aacute'] = 500;
  50373. t['Ucircumflex'] = 722;
  50374. t['yacute'] = 500;
  50375. t['scommaaccent'] = 389;
  50376. t['ecircumflex'] = 444;
  50377. t['Uring'] = 722;
  50378. t['Udieresis'] = 722;
  50379. t['aogonek'] = 500;
  50380. t['Uacute'] = 722;
  50381. t['uogonek'] = 556;
  50382. t['Edieresis'] = 667;
  50383. t['Dcroat'] = 722;
  50384. t['commaaccent'] = 250;
  50385. t['copyright'] = 747;
  50386. t['Emacron'] = 667;
  50387. t['ccaron'] = 444;
  50388. t['aring'] = 500;
  50389. t['Ncommaaccent'] = 722;
  50390. t['lacute'] = 278;
  50391. t['agrave'] = 500;
  50392. t['Tcommaaccent'] = 667;
  50393. t['Cacute'] = 722;
  50394. t['atilde'] = 500;
  50395. t['Edotaccent'] = 667;
  50396. t['scaron'] = 389;
  50397. t['scedilla'] = 389;
  50398. t['iacute'] = 278;
  50399. t['lozenge'] = 494;
  50400. t['Rcaron'] = 722;
  50401. t['Gcommaaccent'] = 778;
  50402. t['ucircumflex'] = 556;
  50403. t['acircumflex'] = 500;
  50404. t['Amacron'] = 722;
  50405. t['rcaron'] = 444;
  50406. t['ccedilla'] = 444;
  50407. t['Zdotaccent'] = 667;
  50408. t['Thorn'] = 611;
  50409. t['Omacron'] = 778;
  50410. t['Racute'] = 722;
  50411. t['Sacute'] = 556;
  50412. t['dcaron'] = 672;
  50413. t['Umacron'] = 722;
  50414. t['uring'] = 556;
  50415. t['threesuperior'] = 300;
  50416. t['Ograve'] = 778;
  50417. t['Agrave'] = 722;
  50418. t['Abreve'] = 722;
  50419. t['multiply'] = 570;
  50420. t['uacute'] = 556;
  50421. t['Tcaron'] = 667;
  50422. t['partialdiff'] = 494;
  50423. t['ydieresis'] = 500;
  50424. t['Nacute'] = 722;
  50425. t['icircumflex'] = 278;
  50426. t['Ecircumflex'] = 667;
  50427. t['adieresis'] = 500;
  50428. t['edieresis'] = 444;
  50429. t['cacute'] = 444;
  50430. t['nacute'] = 556;
  50431. t['umacron'] = 556;
  50432. t['Ncaron'] = 722;
  50433. t['Iacute'] = 389;
  50434. t['plusminus'] = 570;
  50435. t['brokenbar'] = 220;
  50436. t['registered'] = 747;
  50437. t['Gbreve'] = 778;
  50438. t['Idotaccent'] = 389;
  50439. t['summation'] = 600;
  50440. t['Egrave'] = 667;
  50441. t['racute'] = 444;
  50442. t['omacron'] = 500;
  50443. t['Zacute'] = 667;
  50444. t['Zcaron'] = 667;
  50445. t['greaterequal'] = 549;
  50446. t['Eth'] = 722;
  50447. t['Ccedilla'] = 722;
  50448. t['lcommaaccent'] = 278;
  50449. t['tcaron'] = 416;
  50450. t['eogonek'] = 444;
  50451. t['Uogonek'] = 722;
  50452. t['Aacute'] = 722;
  50453. t['Adieresis'] = 722;
  50454. t['egrave'] = 444;
  50455. t['zacute'] = 444;
  50456. t['iogonek'] = 278;
  50457. t['Oacute'] = 778;
  50458. t['oacute'] = 500;
  50459. t['amacron'] = 500;
  50460. t['sacute'] = 389;
  50461. t['idieresis'] = 278;
  50462. t['Ocircumflex'] = 778;
  50463. t['Ugrave'] = 722;
  50464. t['Delta'] = 612;
  50465. t['thorn'] = 556;
  50466. t['twosuperior'] = 300;
  50467. t['Odieresis'] = 778;
  50468. t['mu'] = 556;
  50469. t['igrave'] = 278;
  50470. t['ohungarumlaut'] = 500;
  50471. t['Eogonek'] = 667;
  50472. t['dcroat'] = 556;
  50473. t['threequarters'] = 750;
  50474. t['Scedilla'] = 556;
  50475. t['lcaron'] = 394;
  50476. t['Kcommaaccent'] = 778;
  50477. t['Lacute'] = 667;
  50478. t['trademark'] = 1000;
  50479. t['edotaccent'] = 444;
  50480. t['Igrave'] = 389;
  50481. t['Imacron'] = 389;
  50482. t['Lcaron'] = 667;
  50483. t['onehalf'] = 750;
  50484. t['lessequal'] = 549;
  50485. t['ocircumflex'] = 500;
  50486. t['ntilde'] = 556;
  50487. t['Uhungarumlaut'] = 722;
  50488. t['Eacute'] = 667;
  50489. t['emacron'] = 444;
  50490. t['gbreve'] = 500;
  50491. t['onequarter'] = 750;
  50492. t['Scaron'] = 556;
  50493. t['Scommaaccent'] = 556;
  50494. t['Ohungarumlaut'] = 778;
  50495. t['degree'] = 400;
  50496. t['ograve'] = 500;
  50497. t['Ccaron'] = 722;
  50498. t['ugrave'] = 556;
  50499. t['radical'] = 549;
  50500. t['Dcaron'] = 722;
  50501. t['rcommaaccent'] = 444;
  50502. t['Ntilde'] = 722;
  50503. t['otilde'] = 500;
  50504. t['Rcommaaccent'] = 722;
  50505. t['Lcommaaccent'] = 667;
  50506. t['Atilde'] = 722;
  50507. t['Aogonek'] = 722;
  50508. t['Aring'] = 722;
  50509. t['Otilde'] = 778;
  50510. t['zdotaccent'] = 444;
  50511. t['Ecaron'] = 667;
  50512. t['Iogonek'] = 389;
  50513. t['kcommaaccent'] = 556;
  50514. t['minus'] = 570;
  50515. t['Icircumflex'] = 389;
  50516. t['ncaron'] = 556;
  50517. t['tcommaaccent'] = 333;
  50518. t['logicalnot'] = 570;
  50519. t['odieresis'] = 500;
  50520. t['udieresis'] = 556;
  50521. t['notequal'] = 549;
  50522. t['gcommaaccent'] = 500;
  50523. t['eth'] = 500;
  50524. t['zcaron'] = 444;
  50525. t['ncommaaccent'] = 556;
  50526. t['onesuperior'] = 300;
  50527. t['imacron'] = 278;
  50528. t['Euro'] = 500;
  50529. });
  50530. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  50531. t['space'] = 250;
  50532. t['exclam'] = 389;
  50533. t['quotedbl'] = 555;
  50534. t['numbersign'] = 500;
  50535. t['dollar'] = 500;
  50536. t['percent'] = 833;
  50537. t['ampersand'] = 778;
  50538. t['quoteright'] = 333;
  50539. t['parenleft'] = 333;
  50540. t['parenright'] = 333;
  50541. t['asterisk'] = 500;
  50542. t['plus'] = 570;
  50543. t['comma'] = 250;
  50544. t['hyphen'] = 333;
  50545. t['period'] = 250;
  50546. t['slash'] = 278;
  50547. t['zero'] = 500;
  50548. t['one'] = 500;
  50549. t['two'] = 500;
  50550. t['three'] = 500;
  50551. t['four'] = 500;
  50552. t['five'] = 500;
  50553. t['six'] = 500;
  50554. t['seven'] = 500;
  50555. t['eight'] = 500;
  50556. t['nine'] = 500;
  50557. t['colon'] = 333;
  50558. t['semicolon'] = 333;
  50559. t['less'] = 570;
  50560. t['equal'] = 570;
  50561. t['greater'] = 570;
  50562. t['question'] = 500;
  50563. t['at'] = 832;
  50564. t['A'] = 667;
  50565. t['B'] = 667;
  50566. t['C'] = 667;
  50567. t['D'] = 722;
  50568. t['E'] = 667;
  50569. t['F'] = 667;
  50570. t['G'] = 722;
  50571. t['H'] = 778;
  50572. t['I'] = 389;
  50573. t['J'] = 500;
  50574. t['K'] = 667;
  50575. t['L'] = 611;
  50576. t['M'] = 889;
  50577. t['N'] = 722;
  50578. t['O'] = 722;
  50579. t['P'] = 611;
  50580. t['Q'] = 722;
  50581. t['R'] = 667;
  50582. t['S'] = 556;
  50583. t['T'] = 611;
  50584. t['U'] = 722;
  50585. t['V'] = 667;
  50586. t['W'] = 889;
  50587. t['X'] = 667;
  50588. t['Y'] = 611;
  50589. t['Z'] = 611;
  50590. t['bracketleft'] = 333;
  50591. t['backslash'] = 278;
  50592. t['bracketright'] = 333;
  50593. t['asciicircum'] = 570;
  50594. t['underscore'] = 500;
  50595. t['quoteleft'] = 333;
  50596. t['a'] = 500;
  50597. t['b'] = 500;
  50598. t['c'] = 444;
  50599. t['d'] = 500;
  50600. t['e'] = 444;
  50601. t['f'] = 333;
  50602. t['g'] = 500;
  50603. t['h'] = 556;
  50604. t['i'] = 278;
  50605. t['j'] = 278;
  50606. t['k'] = 500;
  50607. t['l'] = 278;
  50608. t['m'] = 778;
  50609. t['n'] = 556;
  50610. t['o'] = 500;
  50611. t['p'] = 500;
  50612. t['q'] = 500;
  50613. t['r'] = 389;
  50614. t['s'] = 389;
  50615. t['t'] = 278;
  50616. t['u'] = 556;
  50617. t['v'] = 444;
  50618. t['w'] = 667;
  50619. t['x'] = 500;
  50620. t['y'] = 444;
  50621. t['z'] = 389;
  50622. t['braceleft'] = 348;
  50623. t['bar'] = 220;
  50624. t['braceright'] = 348;
  50625. t['asciitilde'] = 570;
  50626. t['exclamdown'] = 389;
  50627. t['cent'] = 500;
  50628. t['sterling'] = 500;
  50629. t['fraction'] = 167;
  50630. t['yen'] = 500;
  50631. t['florin'] = 500;
  50632. t['section'] = 500;
  50633. t['currency'] = 500;
  50634. t['quotesingle'] = 278;
  50635. t['quotedblleft'] = 500;
  50636. t['guillemotleft'] = 500;
  50637. t['guilsinglleft'] = 333;
  50638. t['guilsinglright'] = 333;
  50639. t['fi'] = 556;
  50640. t['fl'] = 556;
  50641. t['endash'] = 500;
  50642. t['dagger'] = 500;
  50643. t['daggerdbl'] = 500;
  50644. t['periodcentered'] = 250;
  50645. t['paragraph'] = 500;
  50646. t['bullet'] = 350;
  50647. t['quotesinglbase'] = 333;
  50648. t['quotedblbase'] = 500;
  50649. t['quotedblright'] = 500;
  50650. t['guillemotright'] = 500;
  50651. t['ellipsis'] = 1000;
  50652. t['perthousand'] = 1000;
  50653. t['questiondown'] = 500;
  50654. t['grave'] = 333;
  50655. t['acute'] = 333;
  50656. t['circumflex'] = 333;
  50657. t['tilde'] = 333;
  50658. t['macron'] = 333;
  50659. t['breve'] = 333;
  50660. t['dotaccent'] = 333;
  50661. t['dieresis'] = 333;
  50662. t['ring'] = 333;
  50663. t['cedilla'] = 333;
  50664. t['hungarumlaut'] = 333;
  50665. t['ogonek'] = 333;
  50666. t['caron'] = 333;
  50667. t['emdash'] = 1000;
  50668. t['AE'] = 944;
  50669. t['ordfeminine'] = 266;
  50670. t['Lslash'] = 611;
  50671. t['Oslash'] = 722;
  50672. t['OE'] = 944;
  50673. t['ordmasculine'] = 300;
  50674. t['ae'] = 722;
  50675. t['dotlessi'] = 278;
  50676. t['lslash'] = 278;
  50677. t['oslash'] = 500;
  50678. t['oe'] = 722;
  50679. t['germandbls'] = 500;
  50680. t['Idieresis'] = 389;
  50681. t['eacute'] = 444;
  50682. t['abreve'] = 500;
  50683. t['uhungarumlaut'] = 556;
  50684. t['ecaron'] = 444;
  50685. t['Ydieresis'] = 611;
  50686. t['divide'] = 570;
  50687. t['Yacute'] = 611;
  50688. t['Acircumflex'] = 667;
  50689. t['aacute'] = 500;
  50690. t['Ucircumflex'] = 722;
  50691. t['yacute'] = 444;
  50692. t['scommaaccent'] = 389;
  50693. t['ecircumflex'] = 444;
  50694. t['Uring'] = 722;
  50695. t['Udieresis'] = 722;
  50696. t['aogonek'] = 500;
  50697. t['Uacute'] = 722;
  50698. t['uogonek'] = 556;
  50699. t['Edieresis'] = 667;
  50700. t['Dcroat'] = 722;
  50701. t['commaaccent'] = 250;
  50702. t['copyright'] = 747;
  50703. t['Emacron'] = 667;
  50704. t['ccaron'] = 444;
  50705. t['aring'] = 500;
  50706. t['Ncommaaccent'] = 722;
  50707. t['lacute'] = 278;
  50708. t['agrave'] = 500;
  50709. t['Tcommaaccent'] = 611;
  50710. t['Cacute'] = 667;
  50711. t['atilde'] = 500;
  50712. t['Edotaccent'] = 667;
  50713. t['scaron'] = 389;
  50714. t['scedilla'] = 389;
  50715. t['iacute'] = 278;
  50716. t['lozenge'] = 494;
  50717. t['Rcaron'] = 667;
  50718. t['Gcommaaccent'] = 722;
  50719. t['ucircumflex'] = 556;
  50720. t['acircumflex'] = 500;
  50721. t['Amacron'] = 667;
  50722. t['rcaron'] = 389;
  50723. t['ccedilla'] = 444;
  50724. t['Zdotaccent'] = 611;
  50725. t['Thorn'] = 611;
  50726. t['Omacron'] = 722;
  50727. t['Racute'] = 667;
  50728. t['Sacute'] = 556;
  50729. t['dcaron'] = 608;
  50730. t['Umacron'] = 722;
  50731. t['uring'] = 556;
  50732. t['threesuperior'] = 300;
  50733. t['Ograve'] = 722;
  50734. t['Agrave'] = 667;
  50735. t['Abreve'] = 667;
  50736. t['multiply'] = 570;
  50737. t['uacute'] = 556;
  50738. t['Tcaron'] = 611;
  50739. t['partialdiff'] = 494;
  50740. t['ydieresis'] = 444;
  50741. t['Nacute'] = 722;
  50742. t['icircumflex'] = 278;
  50743. t['Ecircumflex'] = 667;
  50744. t['adieresis'] = 500;
  50745. t['edieresis'] = 444;
  50746. t['cacute'] = 444;
  50747. t['nacute'] = 556;
  50748. t['umacron'] = 556;
  50749. t['Ncaron'] = 722;
  50750. t['Iacute'] = 389;
  50751. t['plusminus'] = 570;
  50752. t['brokenbar'] = 220;
  50753. t['registered'] = 747;
  50754. t['Gbreve'] = 722;
  50755. t['Idotaccent'] = 389;
  50756. t['summation'] = 600;
  50757. t['Egrave'] = 667;
  50758. t['racute'] = 389;
  50759. t['omacron'] = 500;
  50760. t['Zacute'] = 611;
  50761. t['Zcaron'] = 611;
  50762. t['greaterequal'] = 549;
  50763. t['Eth'] = 722;
  50764. t['Ccedilla'] = 667;
  50765. t['lcommaaccent'] = 278;
  50766. t['tcaron'] = 366;
  50767. t['eogonek'] = 444;
  50768. t['Uogonek'] = 722;
  50769. t['Aacute'] = 667;
  50770. t['Adieresis'] = 667;
  50771. t['egrave'] = 444;
  50772. t['zacute'] = 389;
  50773. t['iogonek'] = 278;
  50774. t['Oacute'] = 722;
  50775. t['oacute'] = 500;
  50776. t['amacron'] = 500;
  50777. t['sacute'] = 389;
  50778. t['idieresis'] = 278;
  50779. t['Ocircumflex'] = 722;
  50780. t['Ugrave'] = 722;
  50781. t['Delta'] = 612;
  50782. t['thorn'] = 500;
  50783. t['twosuperior'] = 300;
  50784. t['Odieresis'] = 722;
  50785. t['mu'] = 576;
  50786. t['igrave'] = 278;
  50787. t['ohungarumlaut'] = 500;
  50788. t['Eogonek'] = 667;
  50789. t['dcroat'] = 500;
  50790. t['threequarters'] = 750;
  50791. t['Scedilla'] = 556;
  50792. t['lcaron'] = 382;
  50793. t['Kcommaaccent'] = 667;
  50794. t['Lacute'] = 611;
  50795. t['trademark'] = 1000;
  50796. t['edotaccent'] = 444;
  50797. t['Igrave'] = 389;
  50798. t['Imacron'] = 389;
  50799. t['Lcaron'] = 611;
  50800. t['onehalf'] = 750;
  50801. t['lessequal'] = 549;
  50802. t['ocircumflex'] = 500;
  50803. t['ntilde'] = 556;
  50804. t['Uhungarumlaut'] = 722;
  50805. t['Eacute'] = 667;
  50806. t['emacron'] = 444;
  50807. t['gbreve'] = 500;
  50808. t['onequarter'] = 750;
  50809. t['Scaron'] = 556;
  50810. t['Scommaaccent'] = 556;
  50811. t['Ohungarumlaut'] = 722;
  50812. t['degree'] = 400;
  50813. t['ograve'] = 500;
  50814. t['Ccaron'] = 667;
  50815. t['ugrave'] = 556;
  50816. t['radical'] = 549;
  50817. t['Dcaron'] = 722;
  50818. t['rcommaaccent'] = 389;
  50819. t['Ntilde'] = 722;
  50820. t['otilde'] = 500;
  50821. t['Rcommaaccent'] = 667;
  50822. t['Lcommaaccent'] = 611;
  50823. t['Atilde'] = 667;
  50824. t['Aogonek'] = 667;
  50825. t['Aring'] = 667;
  50826. t['Otilde'] = 722;
  50827. t['zdotaccent'] = 389;
  50828. t['Ecaron'] = 667;
  50829. t['Iogonek'] = 389;
  50830. t['kcommaaccent'] = 500;
  50831. t['minus'] = 606;
  50832. t['Icircumflex'] = 389;
  50833. t['ncaron'] = 556;
  50834. t['tcommaaccent'] = 278;
  50835. t['logicalnot'] = 606;
  50836. t['odieresis'] = 500;
  50837. t['udieresis'] = 556;
  50838. t['notequal'] = 549;
  50839. t['gcommaaccent'] = 500;
  50840. t['eth'] = 500;
  50841. t['zcaron'] = 389;
  50842. t['ncommaaccent'] = 556;
  50843. t['onesuperior'] = 300;
  50844. t['imacron'] = 278;
  50845. t['Euro'] = 500;
  50846. });
  50847. t['Times-Italic'] = getLookupTableFactory(function (t) {
  50848. t['space'] = 250;
  50849. t['exclam'] = 333;
  50850. t['quotedbl'] = 420;
  50851. t['numbersign'] = 500;
  50852. t['dollar'] = 500;
  50853. t['percent'] = 833;
  50854. t['ampersand'] = 778;
  50855. t['quoteright'] = 333;
  50856. t['parenleft'] = 333;
  50857. t['parenright'] = 333;
  50858. t['asterisk'] = 500;
  50859. t['plus'] = 675;
  50860. t['comma'] = 250;
  50861. t['hyphen'] = 333;
  50862. t['period'] = 250;
  50863. t['slash'] = 278;
  50864. t['zero'] = 500;
  50865. t['one'] = 500;
  50866. t['two'] = 500;
  50867. t['three'] = 500;
  50868. t['four'] = 500;
  50869. t['five'] = 500;
  50870. t['six'] = 500;
  50871. t['seven'] = 500;
  50872. t['eight'] = 500;
  50873. t['nine'] = 500;
  50874. t['colon'] = 333;
  50875. t['semicolon'] = 333;
  50876. t['less'] = 675;
  50877. t['equal'] = 675;
  50878. t['greater'] = 675;
  50879. t['question'] = 500;
  50880. t['at'] = 920;
  50881. t['A'] = 611;
  50882. t['B'] = 611;
  50883. t['C'] = 667;
  50884. t['D'] = 722;
  50885. t['E'] = 611;
  50886. t['F'] = 611;
  50887. t['G'] = 722;
  50888. t['H'] = 722;
  50889. t['I'] = 333;
  50890. t['J'] = 444;
  50891. t['K'] = 667;
  50892. t['L'] = 556;
  50893. t['M'] = 833;
  50894. t['N'] = 667;
  50895. t['O'] = 722;
  50896. t['P'] = 611;
  50897. t['Q'] = 722;
  50898. t['R'] = 611;
  50899. t['S'] = 500;
  50900. t['T'] = 556;
  50901. t['U'] = 722;
  50902. t['V'] = 611;
  50903. t['W'] = 833;
  50904. t['X'] = 611;
  50905. t['Y'] = 556;
  50906. t['Z'] = 556;
  50907. t['bracketleft'] = 389;
  50908. t['backslash'] = 278;
  50909. t['bracketright'] = 389;
  50910. t['asciicircum'] = 422;
  50911. t['underscore'] = 500;
  50912. t['quoteleft'] = 333;
  50913. t['a'] = 500;
  50914. t['b'] = 500;
  50915. t['c'] = 444;
  50916. t['d'] = 500;
  50917. t['e'] = 444;
  50918. t['f'] = 278;
  50919. t['g'] = 500;
  50920. t['h'] = 500;
  50921. t['i'] = 278;
  50922. t['j'] = 278;
  50923. t['k'] = 444;
  50924. t['l'] = 278;
  50925. t['m'] = 722;
  50926. t['n'] = 500;
  50927. t['o'] = 500;
  50928. t['p'] = 500;
  50929. t['q'] = 500;
  50930. t['r'] = 389;
  50931. t['s'] = 389;
  50932. t['t'] = 278;
  50933. t['u'] = 500;
  50934. t['v'] = 444;
  50935. t['w'] = 667;
  50936. t['x'] = 444;
  50937. t['y'] = 444;
  50938. t['z'] = 389;
  50939. t['braceleft'] = 400;
  50940. t['bar'] = 275;
  50941. t['braceright'] = 400;
  50942. t['asciitilde'] = 541;
  50943. t['exclamdown'] = 389;
  50944. t['cent'] = 500;
  50945. t['sterling'] = 500;
  50946. t['fraction'] = 167;
  50947. t['yen'] = 500;
  50948. t['florin'] = 500;
  50949. t['section'] = 500;
  50950. t['currency'] = 500;
  50951. t['quotesingle'] = 214;
  50952. t['quotedblleft'] = 556;
  50953. t['guillemotleft'] = 500;
  50954. t['guilsinglleft'] = 333;
  50955. t['guilsinglright'] = 333;
  50956. t['fi'] = 500;
  50957. t['fl'] = 500;
  50958. t['endash'] = 500;
  50959. t['dagger'] = 500;
  50960. t['daggerdbl'] = 500;
  50961. t['periodcentered'] = 250;
  50962. t['paragraph'] = 523;
  50963. t['bullet'] = 350;
  50964. t['quotesinglbase'] = 333;
  50965. t['quotedblbase'] = 556;
  50966. t['quotedblright'] = 556;
  50967. t['guillemotright'] = 500;
  50968. t['ellipsis'] = 889;
  50969. t['perthousand'] = 1000;
  50970. t['questiondown'] = 500;
  50971. t['grave'] = 333;
  50972. t['acute'] = 333;
  50973. t['circumflex'] = 333;
  50974. t['tilde'] = 333;
  50975. t['macron'] = 333;
  50976. t['breve'] = 333;
  50977. t['dotaccent'] = 333;
  50978. t['dieresis'] = 333;
  50979. t['ring'] = 333;
  50980. t['cedilla'] = 333;
  50981. t['hungarumlaut'] = 333;
  50982. t['ogonek'] = 333;
  50983. t['caron'] = 333;
  50984. t['emdash'] = 889;
  50985. t['AE'] = 889;
  50986. t['ordfeminine'] = 276;
  50987. t['Lslash'] = 556;
  50988. t['Oslash'] = 722;
  50989. t['OE'] = 944;
  50990. t['ordmasculine'] = 310;
  50991. t['ae'] = 667;
  50992. t['dotlessi'] = 278;
  50993. t['lslash'] = 278;
  50994. t['oslash'] = 500;
  50995. t['oe'] = 667;
  50996. t['germandbls'] = 500;
  50997. t['Idieresis'] = 333;
  50998. t['eacute'] = 444;
  50999. t['abreve'] = 500;
  51000. t['uhungarumlaut'] = 500;
  51001. t['ecaron'] = 444;
  51002. t['Ydieresis'] = 556;
  51003. t['divide'] = 675;
  51004. t['Yacute'] = 556;
  51005. t['Acircumflex'] = 611;
  51006. t['aacute'] = 500;
  51007. t['Ucircumflex'] = 722;
  51008. t['yacute'] = 444;
  51009. t['scommaaccent'] = 389;
  51010. t['ecircumflex'] = 444;
  51011. t['Uring'] = 722;
  51012. t['Udieresis'] = 722;
  51013. t['aogonek'] = 500;
  51014. t['Uacute'] = 722;
  51015. t['uogonek'] = 500;
  51016. t['Edieresis'] = 611;
  51017. t['Dcroat'] = 722;
  51018. t['commaaccent'] = 250;
  51019. t['copyright'] = 760;
  51020. t['Emacron'] = 611;
  51021. t['ccaron'] = 444;
  51022. t['aring'] = 500;
  51023. t['Ncommaaccent'] = 667;
  51024. t['lacute'] = 278;
  51025. t['agrave'] = 500;
  51026. t['Tcommaaccent'] = 556;
  51027. t['Cacute'] = 667;
  51028. t['atilde'] = 500;
  51029. t['Edotaccent'] = 611;
  51030. t['scaron'] = 389;
  51031. t['scedilla'] = 389;
  51032. t['iacute'] = 278;
  51033. t['lozenge'] = 471;
  51034. t['Rcaron'] = 611;
  51035. t['Gcommaaccent'] = 722;
  51036. t['ucircumflex'] = 500;
  51037. t['acircumflex'] = 500;
  51038. t['Amacron'] = 611;
  51039. t['rcaron'] = 389;
  51040. t['ccedilla'] = 444;
  51041. t['Zdotaccent'] = 556;
  51042. t['Thorn'] = 611;
  51043. t['Omacron'] = 722;
  51044. t['Racute'] = 611;
  51045. t['Sacute'] = 500;
  51046. t['dcaron'] = 544;
  51047. t['Umacron'] = 722;
  51048. t['uring'] = 500;
  51049. t['threesuperior'] = 300;
  51050. t['Ograve'] = 722;
  51051. t['Agrave'] = 611;
  51052. t['Abreve'] = 611;
  51053. t['multiply'] = 675;
  51054. t['uacute'] = 500;
  51055. t['Tcaron'] = 556;
  51056. t['partialdiff'] = 476;
  51057. t['ydieresis'] = 444;
  51058. t['Nacute'] = 667;
  51059. t['icircumflex'] = 278;
  51060. t['Ecircumflex'] = 611;
  51061. t['adieresis'] = 500;
  51062. t['edieresis'] = 444;
  51063. t['cacute'] = 444;
  51064. t['nacute'] = 500;
  51065. t['umacron'] = 500;
  51066. t['Ncaron'] = 667;
  51067. t['Iacute'] = 333;
  51068. t['plusminus'] = 675;
  51069. t['brokenbar'] = 275;
  51070. t['registered'] = 760;
  51071. t['Gbreve'] = 722;
  51072. t['Idotaccent'] = 333;
  51073. t['summation'] = 600;
  51074. t['Egrave'] = 611;
  51075. t['racute'] = 389;
  51076. t['omacron'] = 500;
  51077. t['Zacute'] = 556;
  51078. t['Zcaron'] = 556;
  51079. t['greaterequal'] = 549;
  51080. t['Eth'] = 722;
  51081. t['Ccedilla'] = 667;
  51082. t['lcommaaccent'] = 278;
  51083. t['tcaron'] = 300;
  51084. t['eogonek'] = 444;
  51085. t['Uogonek'] = 722;
  51086. t['Aacute'] = 611;
  51087. t['Adieresis'] = 611;
  51088. t['egrave'] = 444;
  51089. t['zacute'] = 389;
  51090. t['iogonek'] = 278;
  51091. t['Oacute'] = 722;
  51092. t['oacute'] = 500;
  51093. t['amacron'] = 500;
  51094. t['sacute'] = 389;
  51095. t['idieresis'] = 278;
  51096. t['Ocircumflex'] = 722;
  51097. t['Ugrave'] = 722;
  51098. t['Delta'] = 612;
  51099. t['thorn'] = 500;
  51100. t['twosuperior'] = 300;
  51101. t['Odieresis'] = 722;
  51102. t['mu'] = 500;
  51103. t['igrave'] = 278;
  51104. t['ohungarumlaut'] = 500;
  51105. t['Eogonek'] = 611;
  51106. t['dcroat'] = 500;
  51107. t['threequarters'] = 750;
  51108. t['Scedilla'] = 500;
  51109. t['lcaron'] = 300;
  51110. t['Kcommaaccent'] = 667;
  51111. t['Lacute'] = 556;
  51112. t['trademark'] = 980;
  51113. t['edotaccent'] = 444;
  51114. t['Igrave'] = 333;
  51115. t['Imacron'] = 333;
  51116. t['Lcaron'] = 611;
  51117. t['onehalf'] = 750;
  51118. t['lessequal'] = 549;
  51119. t['ocircumflex'] = 500;
  51120. t['ntilde'] = 500;
  51121. t['Uhungarumlaut'] = 722;
  51122. t['Eacute'] = 611;
  51123. t['emacron'] = 444;
  51124. t['gbreve'] = 500;
  51125. t['onequarter'] = 750;
  51126. t['Scaron'] = 500;
  51127. t['Scommaaccent'] = 500;
  51128. t['Ohungarumlaut'] = 722;
  51129. t['degree'] = 400;
  51130. t['ograve'] = 500;
  51131. t['Ccaron'] = 667;
  51132. t['ugrave'] = 500;
  51133. t['radical'] = 453;
  51134. t['Dcaron'] = 722;
  51135. t['rcommaaccent'] = 389;
  51136. t['Ntilde'] = 667;
  51137. t['otilde'] = 500;
  51138. t['Rcommaaccent'] = 611;
  51139. t['Lcommaaccent'] = 556;
  51140. t['Atilde'] = 611;
  51141. t['Aogonek'] = 611;
  51142. t['Aring'] = 611;
  51143. t['Otilde'] = 722;
  51144. t['zdotaccent'] = 389;
  51145. t['Ecaron'] = 611;
  51146. t['Iogonek'] = 333;
  51147. t['kcommaaccent'] = 444;
  51148. t['minus'] = 675;
  51149. t['Icircumflex'] = 333;
  51150. t['ncaron'] = 500;
  51151. t['tcommaaccent'] = 278;
  51152. t['logicalnot'] = 675;
  51153. t['odieresis'] = 500;
  51154. t['udieresis'] = 500;
  51155. t['notequal'] = 549;
  51156. t['gcommaaccent'] = 500;
  51157. t['eth'] = 500;
  51158. t['zcaron'] = 389;
  51159. t['ncommaaccent'] = 500;
  51160. t['onesuperior'] = 300;
  51161. t['imacron'] = 278;
  51162. t['Euro'] = 500;
  51163. });
  51164. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51165. t['space'] = 278;
  51166. t['a1'] = 974;
  51167. t['a2'] = 961;
  51168. t['a202'] = 974;
  51169. t['a3'] = 980;
  51170. t['a4'] = 719;
  51171. t['a5'] = 789;
  51172. t['a119'] = 790;
  51173. t['a118'] = 791;
  51174. t['a117'] = 690;
  51175. t['a11'] = 960;
  51176. t['a12'] = 939;
  51177. t['a13'] = 549;
  51178. t['a14'] = 855;
  51179. t['a15'] = 911;
  51180. t['a16'] = 933;
  51181. t['a105'] = 911;
  51182. t['a17'] = 945;
  51183. t['a18'] = 974;
  51184. t['a19'] = 755;
  51185. t['a20'] = 846;
  51186. t['a21'] = 762;
  51187. t['a22'] = 761;
  51188. t['a23'] = 571;
  51189. t['a24'] = 677;
  51190. t['a25'] = 763;
  51191. t['a26'] = 760;
  51192. t['a27'] = 759;
  51193. t['a28'] = 754;
  51194. t['a6'] = 494;
  51195. t['a7'] = 552;
  51196. t['a8'] = 537;
  51197. t['a9'] = 577;
  51198. t['a10'] = 692;
  51199. t['a29'] = 786;
  51200. t['a30'] = 788;
  51201. t['a31'] = 788;
  51202. t['a32'] = 790;
  51203. t['a33'] = 793;
  51204. t['a34'] = 794;
  51205. t['a35'] = 816;
  51206. t['a36'] = 823;
  51207. t['a37'] = 789;
  51208. t['a38'] = 841;
  51209. t['a39'] = 823;
  51210. t['a40'] = 833;
  51211. t['a41'] = 816;
  51212. t['a42'] = 831;
  51213. t['a43'] = 923;
  51214. t['a44'] = 744;
  51215. t['a45'] = 723;
  51216. t['a46'] = 749;
  51217. t['a47'] = 790;
  51218. t['a48'] = 792;
  51219. t['a49'] = 695;
  51220. t['a50'] = 776;
  51221. t['a51'] = 768;
  51222. t['a52'] = 792;
  51223. t['a53'] = 759;
  51224. t['a54'] = 707;
  51225. t['a55'] = 708;
  51226. t['a56'] = 682;
  51227. t['a57'] = 701;
  51228. t['a58'] = 826;
  51229. t['a59'] = 815;
  51230. t['a60'] = 789;
  51231. t['a61'] = 789;
  51232. t['a62'] = 707;
  51233. t['a63'] = 687;
  51234. t['a64'] = 696;
  51235. t['a65'] = 689;
  51236. t['a66'] = 786;
  51237. t['a67'] = 787;
  51238. t['a68'] = 713;
  51239. t['a69'] = 791;
  51240. t['a70'] = 785;
  51241. t['a71'] = 791;
  51242. t['a72'] = 873;
  51243. t['a73'] = 761;
  51244. t['a74'] = 762;
  51245. t['a203'] = 762;
  51246. t['a75'] = 759;
  51247. t['a204'] = 759;
  51248. t['a76'] = 892;
  51249. t['a77'] = 892;
  51250. t['a78'] = 788;
  51251. t['a79'] = 784;
  51252. t['a81'] = 438;
  51253. t['a82'] = 138;
  51254. t['a83'] = 277;
  51255. t['a84'] = 415;
  51256. t['a97'] = 392;
  51257. t['a98'] = 392;
  51258. t['a99'] = 668;
  51259. t['a100'] = 668;
  51260. t['a89'] = 390;
  51261. t['a90'] = 390;
  51262. t['a93'] = 317;
  51263. t['a94'] = 317;
  51264. t['a91'] = 276;
  51265. t['a92'] = 276;
  51266. t['a205'] = 509;
  51267. t['a85'] = 509;
  51268. t['a206'] = 410;
  51269. t['a86'] = 410;
  51270. t['a87'] = 234;
  51271. t['a88'] = 234;
  51272. t['a95'] = 334;
  51273. t['a96'] = 334;
  51274. t['a101'] = 732;
  51275. t['a102'] = 544;
  51276. t['a103'] = 544;
  51277. t['a104'] = 910;
  51278. t['a106'] = 667;
  51279. t['a107'] = 760;
  51280. t['a108'] = 760;
  51281. t['a112'] = 776;
  51282. t['a111'] = 595;
  51283. t['a110'] = 694;
  51284. t['a109'] = 626;
  51285. t['a120'] = 788;
  51286. t['a121'] = 788;
  51287. t['a122'] = 788;
  51288. t['a123'] = 788;
  51289. t['a124'] = 788;
  51290. t['a125'] = 788;
  51291. t['a126'] = 788;
  51292. t['a127'] = 788;
  51293. t['a128'] = 788;
  51294. t['a129'] = 788;
  51295. t['a130'] = 788;
  51296. t['a131'] = 788;
  51297. t['a132'] = 788;
  51298. t['a133'] = 788;
  51299. t['a134'] = 788;
  51300. t['a135'] = 788;
  51301. t['a136'] = 788;
  51302. t['a137'] = 788;
  51303. t['a138'] = 788;
  51304. t['a139'] = 788;
  51305. t['a140'] = 788;
  51306. t['a141'] = 788;
  51307. t['a142'] = 788;
  51308. t['a143'] = 788;
  51309. t['a144'] = 788;
  51310. t['a145'] = 788;
  51311. t['a146'] = 788;
  51312. t['a147'] = 788;
  51313. t['a148'] = 788;
  51314. t['a149'] = 788;
  51315. t['a150'] = 788;
  51316. t['a151'] = 788;
  51317. t['a152'] = 788;
  51318. t['a153'] = 788;
  51319. t['a154'] = 788;
  51320. t['a155'] = 788;
  51321. t['a156'] = 788;
  51322. t['a157'] = 788;
  51323. t['a158'] = 788;
  51324. t['a159'] = 788;
  51325. t['a160'] = 894;
  51326. t['a161'] = 838;
  51327. t['a163'] = 1016;
  51328. t['a164'] = 458;
  51329. t['a196'] = 748;
  51330. t['a165'] = 924;
  51331. t['a192'] = 748;
  51332. t['a166'] = 918;
  51333. t['a167'] = 927;
  51334. t['a168'] = 928;
  51335. t['a169'] = 928;
  51336. t['a170'] = 834;
  51337. t['a171'] = 873;
  51338. t['a172'] = 828;
  51339. t['a173'] = 924;
  51340. t['a162'] = 924;
  51341. t['a174'] = 917;
  51342. t['a175'] = 930;
  51343. t['a176'] = 931;
  51344. t['a177'] = 463;
  51345. t['a178'] = 883;
  51346. t['a179'] = 836;
  51347. t['a193'] = 836;
  51348. t['a180'] = 867;
  51349. t['a199'] = 867;
  51350. t['a181'] = 696;
  51351. t['a200'] = 696;
  51352. t['a182'] = 874;
  51353. t['a201'] = 874;
  51354. t['a183'] = 760;
  51355. t['a184'] = 946;
  51356. t['a197'] = 771;
  51357. t['a185'] = 865;
  51358. t['a194'] = 771;
  51359. t['a198'] = 888;
  51360. t['a186'] = 967;
  51361. t['a195'] = 888;
  51362. t['a187'] = 831;
  51363. t['a188'] = 873;
  51364. t['a189'] = 927;
  51365. t['a190'] = 970;
  51366. t['a191'] = 918;
  51367. });
  51368. });
  51369. exports.getMetrics = getMetrics;
  51370. /***/ }),
  51371. /* 38 */
  51372. /***/ (function(module, exports, __w_pdfjs_require__) {
  51373. "use strict";
  51374. var sharedUtil = __w_pdfjs_require__(0);
  51375. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  51376. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  51377. var MASK_HIGH = 0xffff0000;
  51378. var MASK_LOW = 0xffff;
  51379. function MurmurHash3_64(seed) {
  51380. var SEED = 0xc3d2e1f0;
  51381. this.h1 = seed ? seed & 0xffffffff : SEED;
  51382. this.h2 = seed ? seed & 0xffffffff : SEED;
  51383. }
  51384. var alwaysUseUint32ArrayView = false;
  51385. try {
  51386. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  51387. } catch (e) {
  51388. alwaysUseUint32ArrayView = true;
  51389. }
  51390. MurmurHash3_64.prototype = {
  51391. update: function MurmurHash3_64_update(input) {
  51392. var useUint32ArrayView = alwaysUseUint32ArrayView;
  51393. var i;
  51394. if (typeof input === 'string') {
  51395. var data = new Uint8Array(input.length * 2);
  51396. var length = 0;
  51397. for (i = 0; i < input.length; i++) {
  51398. var code = input.charCodeAt(i);
  51399. if (code <= 0xff) {
  51400. data[length++] = code;
  51401. } else {
  51402. data[length++] = code >>> 8;
  51403. data[length++] = code & 0xff;
  51404. }
  51405. }
  51406. } else if (input instanceof Uint8Array) {
  51407. data = input;
  51408. length = data.length;
  51409. } else if (typeof input === 'object' && 'length' in input) {
  51410. data = input;
  51411. length = data.length;
  51412. useUint32ArrayView = true;
  51413. } else {
  51414. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  51415. }
  51416. var blockCounts = length >> 2;
  51417. var tailLength = length - blockCounts * 4;
  51418. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  51419. var k1 = 0;
  51420. var k2 = 0;
  51421. var h1 = this.h1;
  51422. var h2 = this.h2;
  51423. var C1 = 0xcc9e2d51;
  51424. var C2 = 0x1b873593;
  51425. var C1_LOW = C1 & MASK_LOW;
  51426. var C2_LOW = C2 & MASK_LOW;
  51427. for (i = 0; i < blockCounts; i++) {
  51428. if (i & 1) {
  51429. k1 = dataUint32[i];
  51430. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51431. k1 = k1 << 15 | k1 >>> 17;
  51432. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51433. h1 ^= k1;
  51434. h1 = h1 << 13 | h1 >>> 19;
  51435. h1 = h1 * 5 + 0xe6546b64;
  51436. } else {
  51437. k2 = dataUint32[i];
  51438. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  51439. k2 = k2 << 15 | k2 >>> 17;
  51440. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  51441. h2 ^= k2;
  51442. h2 = h2 << 13 | h2 >>> 19;
  51443. h2 = h2 * 5 + 0xe6546b64;
  51444. }
  51445. }
  51446. k1 = 0;
  51447. switch (tailLength) {
  51448. case 3:
  51449. k1 ^= data[blockCounts * 4 + 2] << 16;
  51450. case 2:
  51451. k1 ^= data[blockCounts * 4 + 1] << 8;
  51452. case 1:
  51453. k1 ^= data[blockCounts * 4];
  51454. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51455. k1 = k1 << 15 | k1 >>> 17;
  51456. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51457. if (blockCounts & 1) {
  51458. h1 ^= k1;
  51459. } else {
  51460. h2 ^= k1;
  51461. }
  51462. }
  51463. this.h1 = h1;
  51464. this.h2 = h2;
  51465. return this;
  51466. },
  51467. hexdigest: function MurmurHash3_64_hexdigest() {
  51468. var h1 = this.h1;
  51469. var h2 = this.h2;
  51470. h1 ^= h2 >>> 1;
  51471. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  51472. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  51473. h1 ^= h2 >>> 1;
  51474. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  51475. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  51476. h1 ^= h2 >>> 1;
  51477. for (var i = 0, arr = [
  51478. h1,
  51479. h2
  51480. ], str = ''; i < arr.length; i++) {
  51481. var hex = (arr[i] >>> 0).toString(16);
  51482. while (hex.length < 8) {
  51483. hex = '0' + hex;
  51484. }
  51485. str += hex;
  51486. }
  51487. return str;
  51488. }
  51489. };
  51490. return MurmurHash3_64;
  51491. }();
  51492. exports.MurmurHash3_64 = MurmurHash3_64;
  51493. /***/ }),
  51494. /* 39 */
  51495. /***/ (function(module, exports, __w_pdfjs_require__) {
  51496. "use strict";
  51497. var sharedUtil = __w_pdfjs_require__(0);
  51498. var coreWorker = __w_pdfjs_require__(23);
  51499. var OK_RESPONSE = 200;
  51500. var PARTIAL_CONTENT_RESPONSE = 206;
  51501. function NetworkManager(url, args) {
  51502. this.url = url;
  51503. args = args || {};
  51504. this.isHttp = /^https?:/i.test(url);
  51505. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  51506. this.withCredentials = args.withCredentials || false;
  51507. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  51508. return new XMLHttpRequest();
  51509. };
  51510. this.currXhrId = 0;
  51511. this.pendingRequests = Object.create(null);
  51512. this.loadedRequests = Object.create(null);
  51513. }
  51514. function getArrayBuffer(xhr) {
  51515. var data = xhr.response;
  51516. if (typeof data !== 'string') {
  51517. return data;
  51518. }
  51519. var length = data.length;
  51520. var array = new Uint8Array(length);
  51521. for (var i = 0; i < length; i++) {
  51522. array[i] = data.charCodeAt(i) & 0xFF;
  51523. }
  51524. return array.buffer;
  51525. }
  51526. var supportsMozChunked = function supportsMozChunkedClosure() {
  51527. try {
  51528. var x = new XMLHttpRequest();
  51529. x.open('GET', 'https://example.com');
  51530. x.responseType = 'moz-chunked-arraybuffer';
  51531. return x.responseType === 'moz-chunked-arraybuffer';
  51532. } catch (e) {
  51533. return false;
  51534. }
  51535. }();
  51536. NetworkManager.prototype = {
  51537. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  51538. var args = {
  51539. begin: begin,
  51540. end: end
  51541. };
  51542. for (var prop in listeners) {
  51543. args[prop] = listeners[prop];
  51544. }
  51545. return this.request(args);
  51546. },
  51547. requestFull: function NetworkManager_requestFull(listeners) {
  51548. return this.request(listeners);
  51549. },
  51550. request: function NetworkManager_request(args) {
  51551. var xhr = this.getXhr();
  51552. var xhrId = this.currXhrId++;
  51553. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  51554. xhr.open('GET', this.url);
  51555. xhr.withCredentials = this.withCredentials;
  51556. for (var property in this.httpHeaders) {
  51557. var value = this.httpHeaders[property];
  51558. if (typeof value === 'undefined') {
  51559. continue;
  51560. }
  51561. xhr.setRequestHeader(property, value);
  51562. }
  51563. if (this.isHttp && 'begin' in args && 'end' in args) {
  51564. var rangeStr = args.begin + '-' + (args.end - 1);
  51565. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  51566. pendingRequest.expectedStatus = 206;
  51567. } else {
  51568. pendingRequest.expectedStatus = 200;
  51569. }
  51570. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  51571. if (useMozChunkedLoading) {
  51572. xhr.responseType = 'moz-chunked-arraybuffer';
  51573. pendingRequest.onProgressiveData = args.onProgressiveData;
  51574. pendingRequest.mozChunked = true;
  51575. } else {
  51576. xhr.responseType = 'arraybuffer';
  51577. }
  51578. if (args.onError) {
  51579. xhr.onerror = function (evt) {
  51580. args.onError(xhr.status);
  51581. };
  51582. }
  51583. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  51584. xhr.onprogress = this.onProgress.bind(this, xhrId);
  51585. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  51586. pendingRequest.onDone = args.onDone;
  51587. pendingRequest.onError = args.onError;
  51588. pendingRequest.onProgress = args.onProgress;
  51589. xhr.send(null);
  51590. return xhrId;
  51591. },
  51592. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  51593. var pendingRequest = this.pendingRequests[xhrId];
  51594. if (!pendingRequest) {
  51595. return;
  51596. }
  51597. if (pendingRequest.mozChunked) {
  51598. var chunk = getArrayBuffer(pendingRequest.xhr);
  51599. pendingRequest.onProgressiveData(chunk);
  51600. }
  51601. var onProgress = pendingRequest.onProgress;
  51602. if (onProgress) {
  51603. onProgress(evt);
  51604. }
  51605. },
  51606. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  51607. var pendingRequest = this.pendingRequests[xhrId];
  51608. if (!pendingRequest) {
  51609. return;
  51610. }
  51611. var xhr = pendingRequest.xhr;
  51612. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  51613. pendingRequest.onHeadersReceived();
  51614. delete pendingRequest.onHeadersReceived;
  51615. }
  51616. if (xhr.readyState !== 4) {
  51617. return;
  51618. }
  51619. if (!(xhrId in this.pendingRequests)) {
  51620. return;
  51621. }
  51622. delete this.pendingRequests[xhrId];
  51623. if (xhr.status === 0 && this.isHttp) {
  51624. if (pendingRequest.onError) {
  51625. pendingRequest.onError(xhr.status);
  51626. }
  51627. return;
  51628. }
  51629. var xhrStatus = xhr.status || OK_RESPONSE;
  51630. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  51631. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  51632. if (pendingRequest.onError) {
  51633. pendingRequest.onError(xhr.status);
  51634. }
  51635. return;
  51636. }
  51637. this.loadedRequests[xhrId] = true;
  51638. var chunk = getArrayBuffer(xhr);
  51639. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  51640. var rangeHeader = xhr.getResponseHeader('Content-Range');
  51641. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  51642. var begin = parseInt(matches[1], 10);
  51643. pendingRequest.onDone({
  51644. begin: begin,
  51645. chunk: chunk
  51646. });
  51647. } else if (pendingRequest.onProgressiveData) {
  51648. pendingRequest.onDone(null);
  51649. } else if (chunk) {
  51650. pendingRequest.onDone({
  51651. begin: 0,
  51652. chunk: chunk
  51653. });
  51654. } else if (pendingRequest.onError) {
  51655. pendingRequest.onError(xhr.status);
  51656. }
  51657. },
  51658. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  51659. for (var xhrId in this.pendingRequests) {
  51660. return true;
  51661. }
  51662. return false;
  51663. },
  51664. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  51665. return this.pendingRequests[xhrId].xhr;
  51666. },
  51667. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  51668. return !!this.pendingRequests[xhrId].onProgressiveData;
  51669. },
  51670. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  51671. return xhrId in this.pendingRequests;
  51672. },
  51673. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  51674. return xhrId in this.loadedRequests;
  51675. },
  51676. abortAllRequests: function NetworkManager_abortAllRequests() {
  51677. for (var xhrId in this.pendingRequests) {
  51678. this.abortRequest(xhrId | 0);
  51679. }
  51680. },
  51681. abortRequest: function NetworkManager_abortRequest(xhrId) {
  51682. var xhr = this.pendingRequests[xhrId].xhr;
  51683. delete this.pendingRequests[xhrId];
  51684. xhr.abort();
  51685. }
  51686. };
  51687. var assert = sharedUtil.assert;
  51688. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51689. var isInt = sharedUtil.isInt;
  51690. var MissingPDFException = sharedUtil.MissingPDFException;
  51691. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  51692. function PDFNetworkStream(options) {
  51693. this._options = options;
  51694. var source = options.source;
  51695. this._manager = new NetworkManager(source.url, {
  51696. httpHeaders: source.httpHeaders,
  51697. withCredentials: source.withCredentials
  51698. });
  51699. this._rangeChunkSize = source.rangeChunkSize;
  51700. this._fullRequestReader = null;
  51701. this._rangeRequestReaders = [];
  51702. }
  51703. PDFNetworkStream.prototype = {
  51704. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  51705. var i = this._rangeRequestReaders.indexOf(reader);
  51706. if (i >= 0) {
  51707. this._rangeRequestReaders.splice(i, 1);
  51708. }
  51709. },
  51710. getFullReader: function PDFNetworkStream_getFullReader() {
  51711. assert(!this._fullRequestReader);
  51712. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  51713. return this._fullRequestReader;
  51714. },
  51715. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  51716. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  51717. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  51718. this._rangeRequestReaders.push(reader);
  51719. return reader;
  51720. },
  51721. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  51722. if (this._fullRequestReader) {
  51723. this._fullRequestReader.cancel(reason);
  51724. }
  51725. var readers = this._rangeRequestReaders.slice(0);
  51726. readers.forEach(function (reader) {
  51727. reader.cancel(reason);
  51728. });
  51729. }
  51730. };
  51731. function PDFNetworkStreamFullRequestReader(manager, options) {
  51732. this._manager = manager;
  51733. var source = options.source;
  51734. var args = {
  51735. onHeadersReceived: this._onHeadersReceived.bind(this),
  51736. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  51737. onDone: this._onDone.bind(this),
  51738. onError: this._onError.bind(this),
  51739. onProgress: this._onProgress.bind(this)
  51740. };
  51741. this._url = source.url;
  51742. this._fullRequestId = manager.requestFull(args);
  51743. this._headersReceivedCapability = createPromiseCapability();
  51744. this._disableRange = options.disableRange || false;
  51745. this._contentLength = source.length;
  51746. this._rangeChunkSize = source.rangeChunkSize;
  51747. if (!this._rangeChunkSize && !this._disableRange) {
  51748. this._disableRange = true;
  51749. }
  51750. this._isStreamingSupported = false;
  51751. this._isRangeSupported = false;
  51752. this._cachedChunks = [];
  51753. this._requests = [];
  51754. this._done = false;
  51755. this._storedError = undefined;
  51756. this.onProgress = null;
  51757. }
  51758. PDFNetworkStreamFullRequestReader.prototype = {
  51759. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  51760. if (this._disableRange) {
  51761. return false;
  51762. }
  51763. var networkManager = this._manager;
  51764. if (!networkManager.isHttp) {
  51765. return false;
  51766. }
  51767. var fullRequestXhrId = this._fullRequestId;
  51768. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  51769. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  51770. return false;
  51771. }
  51772. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  51773. if (contentEncoding !== 'identity') {
  51774. return false;
  51775. }
  51776. var length = fullRequestXhr.getResponseHeader('Content-Length');
  51777. length = parseInt(length, 10);
  51778. if (!isInt(length)) {
  51779. return false;
  51780. }
  51781. this._contentLength = length;
  51782. if (length <= 2 * this._rangeChunkSize) {
  51783. return false;
  51784. }
  51785. return true;
  51786. },
  51787. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  51788. if (this._validateRangeRequestCapabilities()) {
  51789. this._isRangeSupported = true;
  51790. }
  51791. var networkManager = this._manager;
  51792. var fullRequestXhrId = this._fullRequestId;
  51793. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  51794. this._isStreamingSupported = true;
  51795. } else if (this._isRangeSupported) {
  51796. networkManager.abortRequest(fullRequestXhrId);
  51797. }
  51798. this._headersReceivedCapability.resolve();
  51799. },
  51800. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  51801. if (this._requests.length > 0) {
  51802. var requestCapability = this._requests.shift();
  51803. requestCapability.resolve({
  51804. value: chunk,
  51805. done: false
  51806. });
  51807. } else {
  51808. this._cachedChunks.push(chunk);
  51809. }
  51810. },
  51811. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  51812. if (args) {
  51813. this._onProgressiveData(args.chunk);
  51814. }
  51815. this._done = true;
  51816. if (this._cachedChunks.length > 0) {
  51817. return;
  51818. }
  51819. this._requests.forEach(function (requestCapability) {
  51820. requestCapability.resolve({
  51821. value: undefined,
  51822. done: true
  51823. });
  51824. });
  51825. this._requests = [];
  51826. },
  51827. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  51828. var url = this._url;
  51829. var exception;
  51830. if (status === 404 || status === 0 && /^file:/.test(url)) {
  51831. exception = new MissingPDFException('Missing PDF "' + url + '".');
  51832. } else {
  51833. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  51834. }
  51835. this._storedError = exception;
  51836. this._headersReceivedCapability.reject(exception);
  51837. this._requests.forEach(function (requestCapability) {
  51838. requestCapability.reject(exception);
  51839. });
  51840. this._requests = [];
  51841. this._cachedChunks = [];
  51842. },
  51843. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  51844. if (this.onProgress) {
  51845. this.onProgress({
  51846. loaded: data.loaded,
  51847. total: data.lengthComputable ? data.total : this._contentLength
  51848. });
  51849. }
  51850. },
  51851. get isRangeSupported() {
  51852. return this._isRangeSupported;
  51853. },
  51854. get isStreamingSupported() {
  51855. return this._isStreamingSupported;
  51856. },
  51857. get contentLength() {
  51858. return this._contentLength;
  51859. },
  51860. get headersReady() {
  51861. return this._headersReceivedCapability.promise;
  51862. },
  51863. read: function PDFNetworkStreamFullRequestReader_read() {
  51864. if (this._storedError) {
  51865. return Promise.reject(this._storedError);
  51866. }
  51867. if (this._cachedChunks.length > 0) {
  51868. var chunk = this._cachedChunks.shift();
  51869. return Promise.resolve(chunk);
  51870. }
  51871. if (this._done) {
  51872. return Promise.resolve({
  51873. value: undefined,
  51874. done: true
  51875. });
  51876. }
  51877. var requestCapability = createPromiseCapability();
  51878. this._requests.push(requestCapability);
  51879. return requestCapability.promise;
  51880. },
  51881. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  51882. this._done = true;
  51883. this._headersReceivedCapability.reject(reason);
  51884. this._requests.forEach(function (requestCapability) {
  51885. requestCapability.resolve({
  51886. value: undefined,
  51887. done: true
  51888. });
  51889. });
  51890. this._requests = [];
  51891. if (this._manager.isPendingRequest(this._fullRequestId)) {
  51892. this._manager.abortRequest(this._fullRequestId);
  51893. }
  51894. this._fullRequestReader = null;
  51895. }
  51896. };
  51897. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  51898. this._manager = manager;
  51899. var args = {
  51900. onDone: this._onDone.bind(this),
  51901. onProgress: this._onProgress.bind(this)
  51902. };
  51903. this._requestId = manager.requestRange(begin, end, args);
  51904. this._requests = [];
  51905. this._queuedChunk = null;
  51906. this._done = false;
  51907. this.onProgress = null;
  51908. this.onClosed = null;
  51909. }
  51910. PDFNetworkStreamRangeRequestReader.prototype = {
  51911. _close: function PDFNetworkStreamRangeRequestReader_close() {
  51912. if (this.onClosed) {
  51913. this.onClosed(this);
  51914. }
  51915. },
  51916. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  51917. var chunk = data.chunk;
  51918. if (this._requests.length > 0) {
  51919. var requestCapability = this._requests.shift();
  51920. requestCapability.resolve({
  51921. value: chunk,
  51922. done: false
  51923. });
  51924. } else {
  51925. this._queuedChunk = chunk;
  51926. }
  51927. this._done = true;
  51928. this._requests.forEach(function (requestCapability) {
  51929. requestCapability.resolve({
  51930. value: undefined,
  51931. done: true
  51932. });
  51933. });
  51934. this._requests = [];
  51935. this._close();
  51936. },
  51937. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  51938. if (!this.isStreamingSupported && this.onProgress) {
  51939. this.onProgress({ loaded: evt.loaded });
  51940. }
  51941. },
  51942. get isStreamingSupported() {
  51943. return false;
  51944. },
  51945. read: function PDFNetworkStreamRangeRequestReader_read() {
  51946. if (this._queuedChunk !== null) {
  51947. var chunk = this._queuedChunk;
  51948. this._queuedChunk = null;
  51949. return Promise.resolve({
  51950. value: chunk,
  51951. done: false
  51952. });
  51953. }
  51954. if (this._done) {
  51955. return Promise.resolve({
  51956. value: undefined,
  51957. done: true
  51958. });
  51959. }
  51960. var requestCapability = createPromiseCapability();
  51961. this._requests.push(requestCapability);
  51962. return requestCapability.promise;
  51963. },
  51964. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  51965. this._done = true;
  51966. this._requests.forEach(function (requestCapability) {
  51967. requestCapability.resolve({
  51968. value: undefined,
  51969. done: true
  51970. });
  51971. });
  51972. this._requests = [];
  51973. if (this._manager.isPendingRequest(this._requestId)) {
  51974. this._manager.abortRequest(this._requestId);
  51975. }
  51976. this._close();
  51977. }
  51978. };
  51979. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  51980. exports.PDFNetworkStream = PDFNetworkStream;
  51981. exports.NetworkManager = NetworkManager;
  51982. /***/ }),
  51983. /* 40 */
  51984. /***/ (function(module, exports, __w_pdfjs_require__) {
  51985. "use strict";
  51986. var sharedUtil = __w_pdfjs_require__(0);
  51987. var corePrimitives = __w_pdfjs_require__(1);
  51988. var coreFunction = __w_pdfjs_require__(7);
  51989. var coreColorSpace = __w_pdfjs_require__(4);
  51990. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51991. var MissingDataException = sharedUtil.MissingDataException;
  51992. var Util = sharedUtil.Util;
  51993. var assert = sharedUtil.assert;
  51994. var error = sharedUtil.error;
  51995. var info = sharedUtil.info;
  51996. var warn = sharedUtil.warn;
  51997. var isStream = corePrimitives.isStream;
  51998. var PDFFunction = coreFunction.PDFFunction;
  51999. var ColorSpace = coreColorSpace.ColorSpace;
  52000. var ShadingType = {
  52001. FUNCTION_BASED: 1,
  52002. AXIAL: 2,
  52003. RADIAL: 3,
  52004. FREE_FORM_MESH: 4,
  52005. LATTICE_FORM_MESH: 5,
  52006. COONS_PATCH_MESH: 6,
  52007. TENSOR_PATCH_MESH: 7
  52008. };
  52009. var Pattern = function PatternClosure() {
  52010. function Pattern() {
  52011. error('should not call Pattern constructor');
  52012. }
  52013. Pattern.prototype = {
  52014. getPattern: function Pattern_getPattern(ctx) {
  52015. error('Should not call Pattern.getStyle: ' + ctx);
  52016. }
  52017. };
  52018. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52019. var dict = isStream(shading) ? shading.dict : shading;
  52020. var type = dict.get('ShadingType');
  52021. try {
  52022. switch (type) {
  52023. case ShadingType.AXIAL:
  52024. case ShadingType.RADIAL:
  52025. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52026. case ShadingType.FREE_FORM_MESH:
  52027. case ShadingType.LATTICE_FORM_MESH:
  52028. case ShadingType.COONS_PATCH_MESH:
  52029. case ShadingType.TENSOR_PATCH_MESH:
  52030. return new Shadings.Mesh(shading, matrix, xref, res);
  52031. default:
  52032. throw new Error('Unsupported ShadingType: ' + type);
  52033. }
  52034. } catch (ex) {
  52035. if (ex instanceof MissingDataException) {
  52036. throw ex;
  52037. }
  52038. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52039. warn(ex);
  52040. return new Shadings.Dummy();
  52041. }
  52042. };
  52043. return Pattern;
  52044. }();
  52045. var Shadings = {};
  52046. Shadings.SMALL_NUMBER = 1e-6;
  52047. Shadings.RadialAxial = function RadialAxialClosure() {
  52048. function RadialAxial(dict, matrix, xref, res) {
  52049. this.matrix = matrix;
  52050. this.coordsArr = dict.getArray('Coords');
  52051. this.shadingType = dict.get('ShadingType');
  52052. this.type = 'Pattern';
  52053. var cs = dict.get('ColorSpace', 'CS');
  52054. cs = ColorSpace.parse(cs, xref, res);
  52055. this.cs = cs;
  52056. var t0 = 0.0, t1 = 1.0;
  52057. if (dict.has('Domain')) {
  52058. var domainArr = dict.getArray('Domain');
  52059. t0 = domainArr[0];
  52060. t1 = domainArr[1];
  52061. }
  52062. var extendStart = false, extendEnd = false;
  52063. if (dict.has('Extend')) {
  52064. var extendArr = dict.getArray('Extend');
  52065. extendStart = extendArr[0];
  52066. extendEnd = extendArr[1];
  52067. }
  52068. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52069. var x1 = this.coordsArr[0];
  52070. var y1 = this.coordsArr[1];
  52071. var r1 = this.coordsArr[2];
  52072. var x2 = this.coordsArr[3];
  52073. var y2 = this.coordsArr[4];
  52074. var r2 = this.coordsArr[5];
  52075. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52076. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52077. warn('Unsupported radial gradient.');
  52078. }
  52079. }
  52080. this.extendStart = extendStart;
  52081. this.extendEnd = extendEnd;
  52082. var fnObj = dict.get('Function');
  52083. var fn = PDFFunction.parseArray(xref, fnObj);
  52084. var diff = t1 - t0;
  52085. var step = diff / 10;
  52086. var colorStops = this.colorStops = [];
  52087. if (t0 >= t1 || step <= 0) {
  52088. info('Bad shading domain.');
  52089. return;
  52090. }
  52091. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52092. var rgbColor;
  52093. for (var i = t0; i <= t1; i += step) {
  52094. ratio[0] = i;
  52095. fn(ratio, 0, color, 0);
  52096. rgbColor = cs.getRgb(color, 0);
  52097. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52098. colorStops.push([
  52099. (i - t0) / diff,
  52100. cssColor
  52101. ]);
  52102. }
  52103. var background = 'transparent';
  52104. if (dict.has('Background')) {
  52105. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52106. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52107. }
  52108. if (!extendStart) {
  52109. colorStops.unshift([
  52110. 0,
  52111. background
  52112. ]);
  52113. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52114. }
  52115. if (!extendEnd) {
  52116. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52117. colorStops.push([
  52118. 1,
  52119. background
  52120. ]);
  52121. }
  52122. this.colorStops = colorStops;
  52123. }
  52124. RadialAxial.prototype = {
  52125. getIR: function RadialAxial_getIR() {
  52126. var coordsArr = this.coordsArr;
  52127. var shadingType = this.shadingType;
  52128. var type, p0, p1, r0, r1;
  52129. if (shadingType === ShadingType.AXIAL) {
  52130. p0 = [
  52131. coordsArr[0],
  52132. coordsArr[1]
  52133. ];
  52134. p1 = [
  52135. coordsArr[2],
  52136. coordsArr[3]
  52137. ];
  52138. r0 = null;
  52139. r1 = null;
  52140. type = 'axial';
  52141. } else if (shadingType === ShadingType.RADIAL) {
  52142. p0 = [
  52143. coordsArr[0],
  52144. coordsArr[1]
  52145. ];
  52146. p1 = [
  52147. coordsArr[3],
  52148. coordsArr[4]
  52149. ];
  52150. r0 = coordsArr[2];
  52151. r1 = coordsArr[5];
  52152. type = 'radial';
  52153. } else {
  52154. error('getPattern type unknown: ' + shadingType);
  52155. }
  52156. var matrix = this.matrix;
  52157. if (matrix) {
  52158. p0 = Util.applyTransform(p0, matrix);
  52159. p1 = Util.applyTransform(p1, matrix);
  52160. if (shadingType === ShadingType.RADIAL) {
  52161. var scale = Util.singularValueDecompose2dScale(matrix);
  52162. r0 *= scale[0];
  52163. r1 *= scale[1];
  52164. }
  52165. }
  52166. return [
  52167. 'RadialAxial',
  52168. type,
  52169. this.colorStops,
  52170. p0,
  52171. p1,
  52172. r0,
  52173. r1
  52174. ];
  52175. }
  52176. };
  52177. return RadialAxial;
  52178. }();
  52179. Shadings.Mesh = function MeshClosure() {
  52180. function MeshStreamReader(stream, context) {
  52181. this.stream = stream;
  52182. this.context = context;
  52183. this.buffer = 0;
  52184. this.bufferLength = 0;
  52185. var numComps = context.numComps;
  52186. this.tmpCompsBuf = new Float32Array(numComps);
  52187. var csNumComps = context.colorSpace.numComps;
  52188. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  52189. }
  52190. MeshStreamReader.prototype = {
  52191. get hasData() {
  52192. if (this.stream.end) {
  52193. return this.stream.pos < this.stream.end;
  52194. }
  52195. if (this.bufferLength > 0) {
  52196. return true;
  52197. }
  52198. var nextByte = this.stream.getByte();
  52199. if (nextByte < 0) {
  52200. return false;
  52201. }
  52202. this.buffer = nextByte;
  52203. this.bufferLength = 8;
  52204. return true;
  52205. },
  52206. readBits: function MeshStreamReader_readBits(n) {
  52207. var buffer = this.buffer;
  52208. var bufferLength = this.bufferLength;
  52209. if (n === 32) {
  52210. if (bufferLength === 0) {
  52211. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  52212. }
  52213. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  52214. var nextByte = this.stream.getByte();
  52215. this.buffer = nextByte & (1 << bufferLength) - 1;
  52216. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  52217. }
  52218. if (n === 8 && bufferLength === 0) {
  52219. return this.stream.getByte();
  52220. }
  52221. while (bufferLength < n) {
  52222. buffer = buffer << 8 | this.stream.getByte();
  52223. bufferLength += 8;
  52224. }
  52225. bufferLength -= n;
  52226. this.bufferLength = bufferLength;
  52227. this.buffer = buffer & (1 << bufferLength) - 1;
  52228. return buffer >> bufferLength;
  52229. },
  52230. align: function MeshStreamReader_align() {
  52231. this.buffer = 0;
  52232. this.bufferLength = 0;
  52233. },
  52234. readFlag: function MeshStreamReader_readFlag() {
  52235. return this.readBits(this.context.bitsPerFlag);
  52236. },
  52237. readCoordinate: function MeshStreamReader_readCoordinate() {
  52238. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  52239. var xi = this.readBits(bitsPerCoordinate);
  52240. var yi = this.readBits(bitsPerCoordinate);
  52241. var decode = this.context.decode;
  52242. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  52243. return [
  52244. xi * scale * (decode[1] - decode[0]) + decode[0],
  52245. yi * scale * (decode[3] - decode[2]) + decode[2]
  52246. ];
  52247. },
  52248. readComponents: function MeshStreamReader_readComponents() {
  52249. var numComps = this.context.numComps;
  52250. var bitsPerComponent = this.context.bitsPerComponent;
  52251. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  52252. var decode = this.context.decode;
  52253. var components = this.tmpCompsBuf;
  52254. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  52255. var ci = this.readBits(bitsPerComponent);
  52256. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  52257. }
  52258. var color = this.tmpCsCompsBuf;
  52259. if (this.context.colorFn) {
  52260. this.context.colorFn(components, 0, color, 0);
  52261. }
  52262. return this.context.colorSpace.getRgb(color, 0);
  52263. }
  52264. };
  52265. function decodeType4Shading(mesh, reader) {
  52266. var coords = mesh.coords;
  52267. var colors = mesh.colors;
  52268. var operators = [];
  52269. var ps = [];
  52270. var verticesLeft = 0;
  52271. while (reader.hasData) {
  52272. var f = reader.readFlag();
  52273. var coord = reader.readCoordinate();
  52274. var color = reader.readComponents();
  52275. if (verticesLeft === 0) {
  52276. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  52277. switch (f) {
  52278. case 0:
  52279. verticesLeft = 3;
  52280. break;
  52281. case 1:
  52282. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  52283. verticesLeft = 1;
  52284. break;
  52285. case 2:
  52286. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  52287. verticesLeft = 1;
  52288. break;
  52289. }
  52290. operators.push(f);
  52291. }
  52292. ps.push(coords.length);
  52293. coords.push(coord);
  52294. colors.push(color);
  52295. verticesLeft--;
  52296. reader.align();
  52297. }
  52298. mesh.figures.push({
  52299. type: 'triangles',
  52300. coords: new Int32Array(ps),
  52301. colors: new Int32Array(ps)
  52302. });
  52303. }
  52304. function decodeType5Shading(mesh, reader, verticesPerRow) {
  52305. var coords = mesh.coords;
  52306. var colors = mesh.colors;
  52307. var ps = [];
  52308. while (reader.hasData) {
  52309. var coord = reader.readCoordinate();
  52310. var color = reader.readComponents();
  52311. ps.push(coords.length);
  52312. coords.push(coord);
  52313. colors.push(color);
  52314. }
  52315. mesh.figures.push({
  52316. type: 'lattice',
  52317. coords: new Int32Array(ps),
  52318. colors: new Int32Array(ps),
  52319. verticesPerRow: verticesPerRow
  52320. });
  52321. }
  52322. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  52323. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  52324. var TRIANGLE_DENSITY = 20;
  52325. var getB = function getBClosure() {
  52326. function buildB(count) {
  52327. var lut = [];
  52328. for (var i = 0; i <= count; i++) {
  52329. var t = i / count, t_ = 1 - t;
  52330. lut.push(new Float32Array([
  52331. t_ * t_ * t_,
  52332. 3 * t * t_ * t_,
  52333. 3 * t * t * t_,
  52334. t * t * t
  52335. ]));
  52336. }
  52337. return lut;
  52338. }
  52339. var cache = [];
  52340. return function getB(count) {
  52341. if (!cache[count]) {
  52342. cache[count] = buildB(count);
  52343. }
  52344. return cache[count];
  52345. };
  52346. }();
  52347. function buildFigureFromPatch(mesh, index) {
  52348. var figure = mesh.figures[index];
  52349. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  52350. var coords = mesh.coords, colors = mesh.colors;
  52351. var pi = figure.coords;
  52352. var ci = figure.colors;
  52353. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52354. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52355. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52356. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52357. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  52358. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  52359. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  52360. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  52361. var verticesPerRow = splitXBy + 1;
  52362. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  52363. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  52364. var k = 0;
  52365. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  52366. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  52367. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  52368. for (var row = 0; row <= splitYBy; row++) {
  52369. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  52370. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  52371. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  52372. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  52373. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  52374. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  52375. for (var col = 0; col <= splitXBy; col++, k++) {
  52376. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  52377. continue;
  52378. }
  52379. var x = 0, y = 0;
  52380. var q = 0;
  52381. for (var i = 0; i <= 3; i++) {
  52382. for (var j = 0; j <= 3; j++, q++) {
  52383. var m = bRow[row][i] * bCol[col][j];
  52384. x += coords[pi[q]][0] * m;
  52385. y += coords[pi[q]][1] * m;
  52386. }
  52387. }
  52388. figureCoords[k] = coords.length;
  52389. coords.push([
  52390. x,
  52391. y
  52392. ]);
  52393. figureColors[k] = colors.length;
  52394. var newColor = new Uint8Array(3);
  52395. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  52396. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  52397. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  52398. colors.push(newColor);
  52399. }
  52400. }
  52401. figureCoords[0] = pi[0];
  52402. figureColors[0] = ci[0];
  52403. figureCoords[splitXBy] = pi[3];
  52404. figureColors[splitXBy] = ci[1];
  52405. figureCoords[verticesPerRow * splitYBy] = pi[12];
  52406. figureColors[verticesPerRow * splitYBy] = ci[2];
  52407. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  52408. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  52409. mesh.figures[index] = {
  52410. type: 'lattice',
  52411. coords: figureCoords,
  52412. colors: figureColors,
  52413. verticesPerRow: verticesPerRow
  52414. };
  52415. }
  52416. function decodeType6Shading(mesh, reader) {
  52417. var coords = mesh.coords;
  52418. var colors = mesh.colors;
  52419. var ps = new Int32Array(16);
  52420. var cs = new Int32Array(4);
  52421. while (reader.hasData) {
  52422. var f = reader.readFlag();
  52423. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  52424. var i, ii;
  52425. var pi = coords.length;
  52426. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  52427. coords.push(reader.readCoordinate());
  52428. }
  52429. var ci = colors.length;
  52430. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52431. colors.push(reader.readComponents());
  52432. }
  52433. var tmp1, tmp2, tmp3, tmp4;
  52434. switch (f) {
  52435. case 0:
  52436. ps[12] = pi + 3;
  52437. ps[13] = pi + 4;
  52438. ps[14] = pi + 5;
  52439. ps[15] = pi + 6;
  52440. ps[8] = pi + 2;
  52441. ps[11] = pi + 7;
  52442. ps[4] = pi + 1;
  52443. ps[7] = pi + 8;
  52444. ps[0] = pi;
  52445. ps[1] = pi + 11;
  52446. ps[2] = pi + 10;
  52447. ps[3] = pi + 9;
  52448. cs[2] = ci + 1;
  52449. cs[3] = ci + 2;
  52450. cs[0] = ci;
  52451. cs[1] = ci + 3;
  52452. break;
  52453. case 1:
  52454. tmp1 = ps[12];
  52455. tmp2 = ps[13];
  52456. tmp3 = ps[14];
  52457. tmp4 = ps[15];
  52458. ps[12] = tmp4;
  52459. ps[13] = pi + 0;
  52460. ps[14] = pi + 1;
  52461. ps[15] = pi + 2;
  52462. ps[8] = tmp3;
  52463. ps[11] = pi + 3;
  52464. ps[4] = tmp2;
  52465. ps[7] = pi + 4;
  52466. ps[0] = tmp1;
  52467. ps[1] = pi + 7;
  52468. ps[2] = pi + 6;
  52469. ps[3] = pi + 5;
  52470. tmp1 = cs[2];
  52471. tmp2 = cs[3];
  52472. cs[2] = tmp2;
  52473. cs[3] = ci;
  52474. cs[0] = tmp1;
  52475. cs[1] = ci + 1;
  52476. break;
  52477. case 2:
  52478. tmp1 = ps[15];
  52479. tmp2 = ps[11];
  52480. ps[12] = ps[3];
  52481. ps[13] = pi + 0;
  52482. ps[14] = pi + 1;
  52483. ps[15] = pi + 2;
  52484. ps[8] = ps[7];
  52485. ps[11] = pi + 3;
  52486. ps[4] = tmp2;
  52487. ps[7] = pi + 4;
  52488. ps[0] = tmp1;
  52489. ps[1] = pi + 7;
  52490. ps[2] = pi + 6;
  52491. ps[3] = pi + 5;
  52492. tmp1 = cs[3];
  52493. cs[2] = cs[1];
  52494. cs[3] = ci;
  52495. cs[0] = tmp1;
  52496. cs[1] = ci + 1;
  52497. break;
  52498. case 3:
  52499. ps[12] = ps[0];
  52500. ps[13] = pi + 0;
  52501. ps[14] = pi + 1;
  52502. ps[15] = pi + 2;
  52503. ps[8] = ps[1];
  52504. ps[11] = pi + 3;
  52505. ps[4] = ps[2];
  52506. ps[7] = pi + 4;
  52507. ps[0] = ps[3];
  52508. ps[1] = pi + 7;
  52509. ps[2] = pi + 6;
  52510. ps[3] = pi + 5;
  52511. cs[2] = cs[0];
  52512. cs[3] = ci;
  52513. cs[0] = cs[1];
  52514. cs[1] = ci + 1;
  52515. break;
  52516. }
  52517. ps[5] = coords.length;
  52518. coords.push([
  52519. (-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,
  52520. (-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
  52521. ]);
  52522. ps[6] = coords.length;
  52523. coords.push([
  52524. (-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,
  52525. (-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
  52526. ]);
  52527. ps[9] = coords.length;
  52528. coords.push([
  52529. (-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,
  52530. (-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
  52531. ]);
  52532. ps[10] = coords.length;
  52533. coords.push([
  52534. (-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,
  52535. (-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
  52536. ]);
  52537. mesh.figures.push({
  52538. type: 'patch',
  52539. coords: new Int32Array(ps),
  52540. colors: new Int32Array(cs)
  52541. });
  52542. }
  52543. }
  52544. function decodeType7Shading(mesh, reader) {
  52545. var coords = mesh.coords;
  52546. var colors = mesh.colors;
  52547. var ps = new Int32Array(16);
  52548. var cs = new Int32Array(4);
  52549. while (reader.hasData) {
  52550. var f = reader.readFlag();
  52551. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  52552. var i, ii;
  52553. var pi = coords.length;
  52554. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  52555. coords.push(reader.readCoordinate());
  52556. }
  52557. var ci = colors.length;
  52558. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52559. colors.push(reader.readComponents());
  52560. }
  52561. var tmp1, tmp2, tmp3, tmp4;
  52562. switch (f) {
  52563. case 0:
  52564. ps[12] = pi + 3;
  52565. ps[13] = pi + 4;
  52566. ps[14] = pi + 5;
  52567. ps[15] = pi + 6;
  52568. ps[8] = pi + 2;
  52569. ps[9] = pi + 13;
  52570. ps[10] = pi + 14;
  52571. ps[11] = pi + 7;
  52572. ps[4] = pi + 1;
  52573. ps[5] = pi + 12;
  52574. ps[6] = pi + 15;
  52575. ps[7] = pi + 8;
  52576. ps[0] = pi;
  52577. ps[1] = pi + 11;
  52578. ps[2] = pi + 10;
  52579. ps[3] = pi + 9;
  52580. cs[2] = ci + 1;
  52581. cs[3] = ci + 2;
  52582. cs[0] = ci;
  52583. cs[1] = ci + 3;
  52584. break;
  52585. case 1:
  52586. tmp1 = ps[12];
  52587. tmp2 = ps[13];
  52588. tmp3 = ps[14];
  52589. tmp4 = ps[15];
  52590. ps[12] = tmp4;
  52591. ps[13] = pi + 0;
  52592. ps[14] = pi + 1;
  52593. ps[15] = pi + 2;
  52594. ps[8] = tmp3;
  52595. ps[9] = pi + 9;
  52596. ps[10] = pi + 10;
  52597. ps[11] = pi + 3;
  52598. ps[4] = tmp2;
  52599. ps[5] = pi + 8;
  52600. ps[6] = pi + 11;
  52601. ps[7] = pi + 4;
  52602. ps[0] = tmp1;
  52603. ps[1] = pi + 7;
  52604. ps[2] = pi + 6;
  52605. ps[3] = pi + 5;
  52606. tmp1 = cs[2];
  52607. tmp2 = cs[3];
  52608. cs[2] = tmp2;
  52609. cs[3] = ci;
  52610. cs[0] = tmp1;
  52611. cs[1] = ci + 1;
  52612. break;
  52613. case 2:
  52614. tmp1 = ps[15];
  52615. tmp2 = ps[11];
  52616. ps[12] = ps[3];
  52617. ps[13] = pi + 0;
  52618. ps[14] = pi + 1;
  52619. ps[15] = pi + 2;
  52620. ps[8] = ps[7];
  52621. ps[9] = pi + 9;
  52622. ps[10] = pi + 10;
  52623. ps[11] = pi + 3;
  52624. ps[4] = tmp2;
  52625. ps[5] = pi + 8;
  52626. ps[6] = pi + 11;
  52627. ps[7] = pi + 4;
  52628. ps[0] = tmp1;
  52629. ps[1] = pi + 7;
  52630. ps[2] = pi + 6;
  52631. ps[3] = pi + 5;
  52632. tmp1 = cs[3];
  52633. cs[2] = cs[1];
  52634. cs[3] = ci;
  52635. cs[0] = tmp1;
  52636. cs[1] = ci + 1;
  52637. break;
  52638. case 3:
  52639. ps[12] = ps[0];
  52640. ps[13] = pi + 0;
  52641. ps[14] = pi + 1;
  52642. ps[15] = pi + 2;
  52643. ps[8] = ps[1];
  52644. ps[9] = pi + 9;
  52645. ps[10] = pi + 10;
  52646. ps[11] = pi + 3;
  52647. ps[4] = ps[2];
  52648. ps[5] = pi + 8;
  52649. ps[6] = pi + 11;
  52650. ps[7] = pi + 4;
  52651. ps[0] = ps[3];
  52652. ps[1] = pi + 7;
  52653. ps[2] = pi + 6;
  52654. ps[3] = pi + 5;
  52655. cs[2] = cs[0];
  52656. cs[3] = ci;
  52657. cs[0] = cs[1];
  52658. cs[1] = ci + 1;
  52659. break;
  52660. }
  52661. mesh.figures.push({
  52662. type: 'patch',
  52663. coords: new Int32Array(ps),
  52664. colors: new Int32Array(cs)
  52665. });
  52666. }
  52667. }
  52668. function updateBounds(mesh) {
  52669. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  52670. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  52671. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  52672. minX = minX > x ? x : minX;
  52673. minY = minY > y ? y : minY;
  52674. maxX = maxX < x ? x : maxX;
  52675. maxY = maxY < y ? y : maxY;
  52676. }
  52677. mesh.bounds = [
  52678. minX,
  52679. minY,
  52680. maxX,
  52681. maxY
  52682. ];
  52683. }
  52684. function packData(mesh) {
  52685. var i, ii, j, jj;
  52686. var coords = mesh.coords;
  52687. var coordsPacked = new Float32Array(coords.length * 2);
  52688. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  52689. var xy = coords[i];
  52690. coordsPacked[j++] = xy[0];
  52691. coordsPacked[j++] = xy[1];
  52692. }
  52693. mesh.coords = coordsPacked;
  52694. var colors = mesh.colors;
  52695. var colorsPacked = new Uint8Array(colors.length * 3);
  52696. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  52697. var c = colors[i];
  52698. colorsPacked[j++] = c[0];
  52699. colorsPacked[j++] = c[1];
  52700. colorsPacked[j++] = c[2];
  52701. }
  52702. mesh.colors = colorsPacked;
  52703. var figures = mesh.figures;
  52704. for (i = 0, ii = figures.length; i < ii; i++) {
  52705. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  52706. for (j = 0, jj = ps.length; j < jj; j++) {
  52707. ps[j] *= 2;
  52708. cs[j] *= 3;
  52709. }
  52710. }
  52711. }
  52712. function Mesh(stream, matrix, xref, res) {
  52713. assert(isStream(stream), 'Mesh data is not a stream');
  52714. var dict = stream.dict;
  52715. this.matrix = matrix;
  52716. this.shadingType = dict.get('ShadingType');
  52717. this.type = 'Pattern';
  52718. this.bbox = dict.getArray('BBox');
  52719. var cs = dict.get('ColorSpace', 'CS');
  52720. cs = ColorSpace.parse(cs, xref, res);
  52721. this.cs = cs;
  52722. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  52723. var fnObj = dict.get('Function');
  52724. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  52725. this.coords = [];
  52726. this.colors = [];
  52727. this.figures = [];
  52728. var decodeContext = {
  52729. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  52730. bitsPerComponent: dict.get('BitsPerComponent'),
  52731. bitsPerFlag: dict.get('BitsPerFlag'),
  52732. decode: dict.getArray('Decode'),
  52733. colorFn: fn,
  52734. colorSpace: cs,
  52735. numComps: fn ? 1 : cs.numComps
  52736. };
  52737. var reader = new MeshStreamReader(stream, decodeContext);
  52738. var patchMesh = false;
  52739. switch (this.shadingType) {
  52740. case ShadingType.FREE_FORM_MESH:
  52741. decodeType4Shading(this, reader);
  52742. break;
  52743. case ShadingType.LATTICE_FORM_MESH:
  52744. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  52745. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  52746. decodeType5Shading(this, reader, verticesPerRow);
  52747. break;
  52748. case ShadingType.COONS_PATCH_MESH:
  52749. decodeType6Shading(this, reader);
  52750. patchMesh = true;
  52751. break;
  52752. case ShadingType.TENSOR_PATCH_MESH:
  52753. decodeType7Shading(this, reader);
  52754. patchMesh = true;
  52755. break;
  52756. default:
  52757. error('Unsupported mesh type.');
  52758. break;
  52759. }
  52760. if (patchMesh) {
  52761. updateBounds(this);
  52762. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  52763. buildFigureFromPatch(this, i);
  52764. }
  52765. }
  52766. updateBounds(this);
  52767. packData(this);
  52768. }
  52769. Mesh.prototype = {
  52770. getIR: function Mesh_getIR() {
  52771. return [
  52772. 'Mesh',
  52773. this.shadingType,
  52774. this.coords,
  52775. this.colors,
  52776. this.figures,
  52777. this.bounds,
  52778. this.matrix,
  52779. this.bbox,
  52780. this.background
  52781. ];
  52782. }
  52783. };
  52784. return Mesh;
  52785. }();
  52786. Shadings.Dummy = function DummyClosure() {
  52787. function Dummy() {
  52788. this.type = 'Pattern';
  52789. }
  52790. Dummy.prototype = {
  52791. getIR: function Dummy_getIR() {
  52792. return ['Dummy'];
  52793. }
  52794. };
  52795. return Dummy;
  52796. }();
  52797. function getTilingPatternIR(operatorList, dict, args) {
  52798. var matrix = dict.getArray('Matrix');
  52799. var bbox = dict.getArray('BBox');
  52800. var xstep = dict.get('XStep');
  52801. var ystep = dict.get('YStep');
  52802. var paintType = dict.get('PaintType');
  52803. var tilingType = dict.get('TilingType');
  52804. return [
  52805. 'TilingPattern',
  52806. args,
  52807. operatorList,
  52808. matrix,
  52809. bbox,
  52810. xstep,
  52811. ystep,
  52812. paintType,
  52813. tilingType
  52814. ];
  52815. }
  52816. exports.Pattern = Pattern;
  52817. exports.getTilingPatternIR = getTilingPatternIR;
  52818. /***/ }),
  52819. /* 41 */
  52820. /***/ (function(module, exports, __w_pdfjs_require__) {
  52821. "use strict";
  52822. var sharedUtil = __w_pdfjs_require__(0);
  52823. var coreStream = __w_pdfjs_require__(2);
  52824. var coreChunkedStream = __w_pdfjs_require__(16);
  52825. var coreDocument = __w_pdfjs_require__(31);
  52826. var warn = sharedUtil.warn;
  52827. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  52828. var shadow = sharedUtil.shadow;
  52829. var NotImplementedException = sharedUtil.NotImplementedException;
  52830. var MissingDataException = sharedUtil.MissingDataException;
  52831. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52832. var Util = sharedUtil.Util;
  52833. var Stream = coreStream.Stream;
  52834. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  52835. var PDFDocument = coreDocument.PDFDocument;
  52836. var BasePdfManager = function BasePdfManagerClosure() {
  52837. function BasePdfManager() {
  52838. throw new Error('Cannot initialize BaseManagerManager');
  52839. }
  52840. BasePdfManager.prototype = {
  52841. get docId() {
  52842. return this._docId;
  52843. },
  52844. get password() {
  52845. return this._password;
  52846. },
  52847. get docBaseUrl() {
  52848. var docBaseUrl = null;
  52849. if (this._docBaseUrl) {
  52850. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  52851. if (absoluteUrl) {
  52852. docBaseUrl = absoluteUrl.href;
  52853. } else {
  52854. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  52855. }
  52856. }
  52857. return shadow(this, 'docBaseUrl', docBaseUrl);
  52858. },
  52859. onLoadedStream: function BasePdfManager_onLoadedStream() {
  52860. throw new NotImplementedException();
  52861. },
  52862. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  52863. return this.ensure(this.pdfDocument, prop, args);
  52864. },
  52865. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  52866. return this.ensure(this.pdfDocument.xref, prop, args);
  52867. },
  52868. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  52869. return this.ensure(this.pdfDocument.catalog, prop, args);
  52870. },
  52871. getPage: function BasePdfManager_getPage(pageIndex) {
  52872. return this.pdfDocument.getPage(pageIndex);
  52873. },
  52874. cleanup: function BasePdfManager_cleanup() {
  52875. return this.pdfDocument.cleanup();
  52876. },
  52877. ensure: function BasePdfManager_ensure(obj, prop, args) {
  52878. return new NotImplementedException();
  52879. },
  52880. requestRange: function BasePdfManager_requestRange(begin, end) {
  52881. return new NotImplementedException();
  52882. },
  52883. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  52884. return new NotImplementedException();
  52885. },
  52886. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  52887. return new NotImplementedException();
  52888. },
  52889. updatePassword: function BasePdfManager_updatePassword(password) {
  52890. this._password = password;
  52891. },
  52892. terminate: function BasePdfManager_terminate() {
  52893. return new NotImplementedException();
  52894. }
  52895. };
  52896. return BasePdfManager;
  52897. }();
  52898. var LocalPdfManager = function LocalPdfManagerClosure() {
  52899. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  52900. this._docId = docId;
  52901. this._password = password;
  52902. this._docBaseUrl = docBaseUrl;
  52903. this.evaluatorOptions = evaluatorOptions;
  52904. var stream = new Stream(data);
  52905. this.pdfDocument = new PDFDocument(this, stream);
  52906. this._loadedStreamCapability = createPromiseCapability();
  52907. this._loadedStreamCapability.resolve(stream);
  52908. }
  52909. Util.inherit(LocalPdfManager, BasePdfManager, {
  52910. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  52911. return new Promise(function (resolve, reject) {
  52912. try {
  52913. var value = obj[prop];
  52914. var result;
  52915. if (typeof value === 'function') {
  52916. result = value.apply(obj, args);
  52917. } else {
  52918. result = value;
  52919. }
  52920. resolve(result);
  52921. } catch (e) {
  52922. reject(e);
  52923. }
  52924. });
  52925. },
  52926. requestRange: function LocalPdfManager_requestRange(begin, end) {
  52927. return Promise.resolve();
  52928. },
  52929. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  52930. },
  52931. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  52932. return this._loadedStreamCapability.promise;
  52933. },
  52934. terminate: function LocalPdfManager_terminate() {
  52935. }
  52936. });
  52937. return LocalPdfManager;
  52938. }();
  52939. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  52940. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  52941. this._docId = docId;
  52942. this._password = args.password;
  52943. this._docBaseUrl = docBaseUrl;
  52944. this.msgHandler = args.msgHandler;
  52945. this.evaluatorOptions = evaluatorOptions;
  52946. var params = {
  52947. msgHandler: args.msgHandler,
  52948. url: args.url,
  52949. length: args.length,
  52950. disableAutoFetch: args.disableAutoFetch,
  52951. rangeChunkSize: args.rangeChunkSize
  52952. };
  52953. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  52954. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  52955. }
  52956. Util.inherit(NetworkPdfManager, BasePdfManager, {
  52957. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  52958. var pdfManager = this;
  52959. return new Promise(function (resolve, reject) {
  52960. function ensureHelper() {
  52961. try {
  52962. var result;
  52963. var value = obj[prop];
  52964. if (typeof value === 'function') {
  52965. result = value.apply(obj, args);
  52966. } else {
  52967. result = value;
  52968. }
  52969. resolve(result);
  52970. } catch (e) {
  52971. if (!(e instanceof MissingDataException)) {
  52972. reject(e);
  52973. return;
  52974. }
  52975. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  52976. }
  52977. }
  52978. ensureHelper();
  52979. });
  52980. },
  52981. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  52982. return this.streamManager.requestRange(begin, end);
  52983. },
  52984. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  52985. this.streamManager.requestAllChunks();
  52986. },
  52987. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  52988. this.streamManager.onReceiveData({ chunk: chunk });
  52989. },
  52990. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  52991. return this.streamManager.onLoadedStream();
  52992. },
  52993. terminate: function NetworkPdfManager_terminate() {
  52994. this.streamManager.abort();
  52995. }
  52996. });
  52997. return NetworkPdfManager;
  52998. }();
  52999. exports.LocalPdfManager = LocalPdfManager;
  53000. exports.NetworkPdfManager = NetworkPdfManager;
  53001. /***/ }),
  53002. /* 42 */
  53003. /***/ (function(module, exports, __w_pdfjs_require__) {
  53004. "use strict";
  53005. var sharedUtil = __w_pdfjs_require__(0);
  53006. var corePrimitives = __w_pdfjs_require__(1);
  53007. var error = sharedUtil.error;
  53008. var isSpace = sharedUtil.isSpace;
  53009. var EOF = corePrimitives.EOF;
  53010. var PostScriptParser = function PostScriptParserClosure() {
  53011. function PostScriptParser(lexer) {
  53012. this.lexer = lexer;
  53013. this.operators = [];
  53014. this.token = null;
  53015. this.prev = null;
  53016. }
  53017. PostScriptParser.prototype = {
  53018. nextToken: function PostScriptParser_nextToken() {
  53019. this.prev = this.token;
  53020. this.token = this.lexer.getToken();
  53021. },
  53022. accept: function PostScriptParser_accept(type) {
  53023. if (this.token.type === type) {
  53024. this.nextToken();
  53025. return true;
  53026. }
  53027. return false;
  53028. },
  53029. expect: function PostScriptParser_expect(type) {
  53030. if (this.accept(type)) {
  53031. return true;
  53032. }
  53033. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53034. },
  53035. parse: function PostScriptParser_parse() {
  53036. this.nextToken();
  53037. this.expect(PostScriptTokenTypes.LBRACE);
  53038. this.parseBlock();
  53039. this.expect(PostScriptTokenTypes.RBRACE);
  53040. return this.operators;
  53041. },
  53042. parseBlock: function PostScriptParser_parseBlock() {
  53043. while (true) {
  53044. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53045. this.operators.push(this.prev.value);
  53046. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53047. this.operators.push(this.prev.value);
  53048. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53049. this.parseCondition();
  53050. } else {
  53051. return;
  53052. }
  53053. }
  53054. },
  53055. parseCondition: function PostScriptParser_parseCondition() {
  53056. var conditionLocation = this.operators.length;
  53057. this.operators.push(null, null);
  53058. this.parseBlock();
  53059. this.expect(PostScriptTokenTypes.RBRACE);
  53060. if (this.accept(PostScriptTokenTypes.IF)) {
  53061. this.operators[conditionLocation] = this.operators.length;
  53062. this.operators[conditionLocation + 1] = 'jz';
  53063. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53064. var jumpLocation = this.operators.length;
  53065. this.operators.push(null, null);
  53066. var endOfTrue = this.operators.length;
  53067. this.parseBlock();
  53068. this.expect(PostScriptTokenTypes.RBRACE);
  53069. this.expect(PostScriptTokenTypes.IFELSE);
  53070. this.operators[jumpLocation] = this.operators.length;
  53071. this.operators[jumpLocation + 1] = 'j';
  53072. this.operators[conditionLocation] = endOfTrue;
  53073. this.operators[conditionLocation + 1] = 'jz';
  53074. } else {
  53075. error('PS Function: error parsing conditional.');
  53076. }
  53077. }
  53078. };
  53079. return PostScriptParser;
  53080. }();
  53081. var PostScriptTokenTypes = {
  53082. LBRACE: 0,
  53083. RBRACE: 1,
  53084. NUMBER: 2,
  53085. OPERATOR: 3,
  53086. IF: 4,
  53087. IFELSE: 5
  53088. };
  53089. var PostScriptToken = function PostScriptTokenClosure() {
  53090. function PostScriptToken(type, value) {
  53091. this.type = type;
  53092. this.value = value;
  53093. }
  53094. var opCache = Object.create(null);
  53095. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53096. var opValue = opCache[op];
  53097. if (opValue) {
  53098. return opValue;
  53099. }
  53100. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53101. };
  53102. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53103. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53104. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53105. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53106. return PostScriptToken;
  53107. }();
  53108. var PostScriptLexer = function PostScriptLexerClosure() {
  53109. function PostScriptLexer(stream) {
  53110. this.stream = stream;
  53111. this.nextChar();
  53112. this.strBuf = [];
  53113. }
  53114. PostScriptLexer.prototype = {
  53115. nextChar: function PostScriptLexer_nextChar() {
  53116. return this.currentChar = this.stream.getByte();
  53117. },
  53118. getToken: function PostScriptLexer_getToken() {
  53119. var comment = false;
  53120. var ch = this.currentChar;
  53121. while (true) {
  53122. if (ch < 0) {
  53123. return EOF;
  53124. }
  53125. if (comment) {
  53126. if (ch === 0x0A || ch === 0x0D) {
  53127. comment = false;
  53128. }
  53129. } else if (ch === 0x25) {
  53130. comment = true;
  53131. } else if (!isSpace(ch)) {
  53132. break;
  53133. }
  53134. ch = this.nextChar();
  53135. }
  53136. switch (ch | 0) {
  53137. case 0x30:
  53138. case 0x31:
  53139. case 0x32:
  53140. case 0x33:
  53141. case 0x34:
  53142. case 0x35:
  53143. case 0x36:
  53144. case 0x37:
  53145. case 0x38:
  53146. case 0x39:
  53147. case 0x2B:
  53148. case 0x2D:
  53149. case 0x2E:
  53150. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53151. case 0x7B:
  53152. this.nextChar();
  53153. return PostScriptToken.LBRACE;
  53154. case 0x7D:
  53155. this.nextChar();
  53156. return PostScriptToken.RBRACE;
  53157. }
  53158. var strBuf = this.strBuf;
  53159. strBuf.length = 0;
  53160. strBuf[0] = String.fromCharCode(ch);
  53161. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53162. strBuf.push(String.fromCharCode(ch));
  53163. }
  53164. var str = strBuf.join('');
  53165. switch (str.toLowerCase()) {
  53166. case 'if':
  53167. return PostScriptToken.IF;
  53168. case 'ifelse':
  53169. return PostScriptToken.IFELSE;
  53170. default:
  53171. return PostScriptToken.getOperator(str);
  53172. }
  53173. },
  53174. getNumber: function PostScriptLexer_getNumber() {
  53175. var ch = this.currentChar;
  53176. var strBuf = this.strBuf;
  53177. strBuf.length = 0;
  53178. strBuf[0] = String.fromCharCode(ch);
  53179. while ((ch = this.nextChar()) >= 0) {
  53180. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  53181. strBuf.push(String.fromCharCode(ch));
  53182. } else {
  53183. break;
  53184. }
  53185. }
  53186. var value = parseFloat(strBuf.join(''));
  53187. if (isNaN(value)) {
  53188. error('Invalid floating point number: ' + value);
  53189. }
  53190. return value;
  53191. }
  53192. };
  53193. return PostScriptLexer;
  53194. }();
  53195. exports.PostScriptLexer = PostScriptLexer;
  53196. exports.PostScriptParser = PostScriptParser;
  53197. /***/ }),
  53198. /* 43 */
  53199. /***/ (function(module, exports, __w_pdfjs_require__) {
  53200. "use strict";
  53201. var sharedUtil = __w_pdfjs_require__(0);
  53202. var coreStream = __w_pdfjs_require__(2);
  53203. var coreEncodings = __w_pdfjs_require__(5);
  53204. var warn = sharedUtil.warn;
  53205. var isSpace = sharedUtil.isSpace;
  53206. var Stream = coreStream.Stream;
  53207. var getEncoding = coreEncodings.getEncoding;
  53208. var HINTING_ENABLED = false;
  53209. var Type1CharString = function Type1CharStringClosure() {
  53210. var COMMAND_MAP = {
  53211. 'hstem': [1],
  53212. 'vstem': [3],
  53213. 'vmoveto': [4],
  53214. 'rlineto': [5],
  53215. 'hlineto': [6],
  53216. 'vlineto': [7],
  53217. 'rrcurveto': [8],
  53218. 'callsubr': [10],
  53219. 'flex': [
  53220. 12,
  53221. 35
  53222. ],
  53223. 'drop': [
  53224. 12,
  53225. 18
  53226. ],
  53227. 'endchar': [14],
  53228. 'rmoveto': [21],
  53229. 'hmoveto': [22],
  53230. 'vhcurveto': [30],
  53231. 'hvcurveto': [31]
  53232. };
  53233. function Type1CharString() {
  53234. this.width = 0;
  53235. this.lsb = 0;
  53236. this.flexing = false;
  53237. this.output = [];
  53238. this.stack = [];
  53239. }
  53240. Type1CharString.prototype = {
  53241. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  53242. var count = encoded.length;
  53243. var error = false;
  53244. var wx, sbx, subrNumber;
  53245. for (var i = 0; i < count; i++) {
  53246. var value = encoded[i];
  53247. if (value < 32) {
  53248. if (value === 12) {
  53249. value = (value << 8) + encoded[++i];
  53250. }
  53251. switch (value) {
  53252. case 1:
  53253. if (!HINTING_ENABLED) {
  53254. this.stack = [];
  53255. break;
  53256. }
  53257. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53258. break;
  53259. case 3:
  53260. if (!HINTING_ENABLED) {
  53261. this.stack = [];
  53262. break;
  53263. }
  53264. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53265. break;
  53266. case 4:
  53267. if (this.flexing) {
  53268. if (this.stack.length < 1) {
  53269. error = true;
  53270. break;
  53271. }
  53272. var dy = this.stack.pop();
  53273. this.stack.push(0, dy);
  53274. break;
  53275. }
  53276. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  53277. break;
  53278. case 5:
  53279. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  53280. break;
  53281. case 6:
  53282. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  53283. break;
  53284. case 7:
  53285. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  53286. break;
  53287. case 8:
  53288. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  53289. break;
  53290. case 9:
  53291. this.stack = [];
  53292. break;
  53293. case 10:
  53294. if (this.stack.length < 1) {
  53295. error = true;
  53296. break;
  53297. }
  53298. subrNumber = this.stack.pop();
  53299. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  53300. break;
  53301. case 11:
  53302. return error;
  53303. case 13:
  53304. if (this.stack.length < 2) {
  53305. error = true;
  53306. break;
  53307. }
  53308. wx = this.stack.pop();
  53309. sbx = this.stack.pop();
  53310. this.lsb = sbx;
  53311. this.width = wx;
  53312. this.stack.push(wx, sbx);
  53313. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  53314. break;
  53315. case 14:
  53316. this.output.push(COMMAND_MAP.endchar[0]);
  53317. break;
  53318. case 21:
  53319. if (this.flexing) {
  53320. break;
  53321. }
  53322. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  53323. break;
  53324. case 22:
  53325. if (this.flexing) {
  53326. this.stack.push(0);
  53327. break;
  53328. }
  53329. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  53330. break;
  53331. case 30:
  53332. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  53333. break;
  53334. case 31:
  53335. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  53336. break;
  53337. case (12 << 8) + 0:
  53338. this.stack = [];
  53339. break;
  53340. case (12 << 8) + 1:
  53341. if (!HINTING_ENABLED) {
  53342. this.stack = [];
  53343. break;
  53344. }
  53345. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53346. break;
  53347. case (12 << 8) + 2:
  53348. if (!HINTING_ENABLED) {
  53349. this.stack = [];
  53350. break;
  53351. }
  53352. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53353. break;
  53354. case (12 << 8) + 6:
  53355. if (seacAnalysisEnabled) {
  53356. this.seac = this.stack.splice(-4, 4);
  53357. error = this.executeCommand(0, COMMAND_MAP.endchar);
  53358. } else {
  53359. error = this.executeCommand(4, COMMAND_MAP.endchar);
  53360. }
  53361. break;
  53362. case (12 << 8) + 7:
  53363. if (this.stack.length < 4) {
  53364. error = true;
  53365. break;
  53366. }
  53367. this.stack.pop();
  53368. wx = this.stack.pop();
  53369. var sby = this.stack.pop();
  53370. sbx = this.stack.pop();
  53371. this.lsb = sbx;
  53372. this.width = wx;
  53373. this.stack.push(wx, sbx, sby);
  53374. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  53375. break;
  53376. case (12 << 8) + 12:
  53377. if (this.stack.length < 2) {
  53378. error = true;
  53379. break;
  53380. }
  53381. var num2 = this.stack.pop();
  53382. var num1 = this.stack.pop();
  53383. this.stack.push(num1 / num2);
  53384. break;
  53385. case (12 << 8) + 16:
  53386. if (this.stack.length < 2) {
  53387. error = true;
  53388. break;
  53389. }
  53390. subrNumber = this.stack.pop();
  53391. var numArgs = this.stack.pop();
  53392. if (subrNumber === 0 && numArgs === 3) {
  53393. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  53394. 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]);
  53395. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  53396. this.flexing = false;
  53397. this.stack.push(flexArgs[15], flexArgs[16]);
  53398. } else if (subrNumber === 1 && numArgs === 0) {
  53399. this.flexing = true;
  53400. }
  53401. break;
  53402. case (12 << 8) + 17:
  53403. break;
  53404. case (12 << 8) + 33:
  53405. this.stack = [];
  53406. break;
  53407. default:
  53408. warn('Unknown type 1 charstring command of "' + value + '"');
  53409. break;
  53410. }
  53411. if (error) {
  53412. break;
  53413. }
  53414. continue;
  53415. } else if (value <= 246) {
  53416. value = value - 139;
  53417. } else if (value <= 250) {
  53418. value = (value - 247) * 256 + encoded[++i] + 108;
  53419. } else if (value <= 254) {
  53420. value = -((value - 251) * 256) - encoded[++i] - 108;
  53421. } else {
  53422. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  53423. }
  53424. this.stack.push(value);
  53425. }
  53426. return error;
  53427. },
  53428. executeCommand: function (howManyArgs, command, keepStack) {
  53429. var stackLength = this.stack.length;
  53430. if (howManyArgs > stackLength) {
  53431. return true;
  53432. }
  53433. var start = stackLength - howManyArgs;
  53434. for (var i = start; i < stackLength; i++) {
  53435. var value = this.stack[i];
  53436. if (value === (value | 0)) {
  53437. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  53438. } else {
  53439. value = 65536 * value | 0;
  53440. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  53441. }
  53442. }
  53443. this.output.push.apply(this.output, command);
  53444. if (keepStack) {
  53445. this.stack.splice(start, howManyArgs);
  53446. } else {
  53447. this.stack.length = 0;
  53448. }
  53449. return false;
  53450. }
  53451. };
  53452. return Type1CharString;
  53453. }();
  53454. var Type1Parser = function Type1ParserClosure() {
  53455. var EEXEC_ENCRYPT_KEY = 55665;
  53456. var CHAR_STRS_ENCRYPT_KEY = 4330;
  53457. function isHexDigit(code) {
  53458. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  53459. }
  53460. function decrypt(data, key, discardNumber) {
  53461. if (discardNumber >= data.length) {
  53462. return new Uint8Array(0);
  53463. }
  53464. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  53465. for (i = 0; i < discardNumber; i++) {
  53466. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  53467. }
  53468. var count = data.length - discardNumber;
  53469. var decrypted = new Uint8Array(count);
  53470. for (i = discardNumber, j = 0; j < count; i++, j++) {
  53471. var value = data[i];
  53472. decrypted[j] = value ^ r >> 8;
  53473. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53474. }
  53475. return decrypted;
  53476. }
  53477. function decryptAscii(data, key, discardNumber) {
  53478. var r = key | 0, c1 = 52845, c2 = 22719;
  53479. var count = data.length, maybeLength = count >>> 1;
  53480. var decrypted = new Uint8Array(maybeLength);
  53481. var i, j;
  53482. for (i = 0, j = 0; i < count; i++) {
  53483. var digit1 = data[i];
  53484. if (!isHexDigit(digit1)) {
  53485. continue;
  53486. }
  53487. i++;
  53488. var digit2;
  53489. while (i < count && !isHexDigit(digit2 = data[i])) {
  53490. i++;
  53491. }
  53492. if (i < count) {
  53493. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  53494. decrypted[j++] = value ^ r >> 8;
  53495. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53496. }
  53497. }
  53498. return Array.prototype.slice.call(decrypted, discardNumber, j);
  53499. }
  53500. function isSpecial(c) {
  53501. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  53502. }
  53503. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  53504. if (encrypted) {
  53505. var data = stream.getBytes();
  53506. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  53507. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  53508. }
  53509. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  53510. this.stream = stream;
  53511. this.nextChar();
  53512. }
  53513. Type1Parser.prototype = {
  53514. readNumberArray: function Type1Parser_readNumberArray() {
  53515. this.getToken();
  53516. var array = [];
  53517. while (true) {
  53518. var token = this.getToken();
  53519. if (token === null || token === ']' || token === '}') {
  53520. break;
  53521. }
  53522. array.push(parseFloat(token || 0));
  53523. }
  53524. return array;
  53525. },
  53526. readNumber: function Type1Parser_readNumber() {
  53527. var token = this.getToken();
  53528. return parseFloat(token || 0);
  53529. },
  53530. readInt: function Type1Parser_readInt() {
  53531. var token = this.getToken();
  53532. return parseInt(token || 0, 10) | 0;
  53533. },
  53534. readBoolean: function Type1Parser_readBoolean() {
  53535. var token = this.getToken();
  53536. return token === 'true' ? 1 : 0;
  53537. },
  53538. nextChar: function Type1_nextChar() {
  53539. return this.currentChar = this.stream.getByte();
  53540. },
  53541. getToken: function Type1Parser_getToken() {
  53542. var comment = false;
  53543. var ch = this.currentChar;
  53544. while (true) {
  53545. if (ch === -1) {
  53546. return null;
  53547. }
  53548. if (comment) {
  53549. if (ch === 0x0A || ch === 0x0D) {
  53550. comment = false;
  53551. }
  53552. } else if (ch === 0x25) {
  53553. comment = true;
  53554. } else if (!isSpace(ch)) {
  53555. break;
  53556. }
  53557. ch = this.nextChar();
  53558. }
  53559. if (isSpecial(ch)) {
  53560. this.nextChar();
  53561. return String.fromCharCode(ch);
  53562. }
  53563. var token = '';
  53564. do {
  53565. token += String.fromCharCode(ch);
  53566. ch = this.nextChar();
  53567. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  53568. return token;
  53569. },
  53570. extractFontProgram: function Type1Parser_extractFontProgram() {
  53571. var stream = this.stream;
  53572. var subrs = [], charstrings = [];
  53573. var privateData = Object.create(null);
  53574. privateData['lenIV'] = 4;
  53575. var program = {
  53576. subrs: [],
  53577. charstrings: [],
  53578. properties: { 'privateData': privateData }
  53579. };
  53580. var token, length, data, lenIV, encoded;
  53581. while ((token = this.getToken()) !== null) {
  53582. if (token !== '/') {
  53583. continue;
  53584. }
  53585. token = this.getToken();
  53586. switch (token) {
  53587. case 'CharStrings':
  53588. this.getToken();
  53589. this.getToken();
  53590. this.getToken();
  53591. this.getToken();
  53592. while (true) {
  53593. token = this.getToken();
  53594. if (token === null || token === 'end') {
  53595. break;
  53596. }
  53597. if (token !== '/') {
  53598. continue;
  53599. }
  53600. var glyph = this.getToken();
  53601. length = this.readInt();
  53602. this.getToken();
  53603. data = stream.makeSubStream(stream.pos, length);
  53604. lenIV = program.properties.privateData['lenIV'];
  53605. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53606. stream.skip(length);
  53607. this.nextChar();
  53608. token = this.getToken();
  53609. if (token === 'noaccess') {
  53610. this.getToken();
  53611. }
  53612. charstrings.push({
  53613. glyph: glyph,
  53614. encoded: encoded
  53615. });
  53616. }
  53617. break;
  53618. case 'Subrs':
  53619. this.readInt();
  53620. this.getToken();
  53621. while ((token = this.getToken()) === 'dup') {
  53622. var index = this.readInt();
  53623. length = this.readInt();
  53624. this.getToken();
  53625. data = stream.makeSubStream(stream.pos, length);
  53626. lenIV = program.properties.privateData['lenIV'];
  53627. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53628. stream.skip(length);
  53629. this.nextChar();
  53630. token = this.getToken();
  53631. if (token === 'noaccess') {
  53632. this.getToken();
  53633. }
  53634. subrs[index] = encoded;
  53635. }
  53636. break;
  53637. case 'BlueValues':
  53638. case 'OtherBlues':
  53639. case 'FamilyBlues':
  53640. case 'FamilyOtherBlues':
  53641. var blueArray = this.readNumberArray();
  53642. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  53643. program.properties.privateData[token] = blueArray;
  53644. }
  53645. break;
  53646. case 'StemSnapH':
  53647. case 'StemSnapV':
  53648. program.properties.privateData[token] = this.readNumberArray();
  53649. break;
  53650. case 'StdHW':
  53651. case 'StdVW':
  53652. program.properties.privateData[token] = this.readNumberArray()[0];
  53653. break;
  53654. case 'BlueShift':
  53655. case 'lenIV':
  53656. case 'BlueFuzz':
  53657. case 'BlueScale':
  53658. case 'LanguageGroup':
  53659. case 'ExpansionFactor':
  53660. program.properties.privateData[token] = this.readNumber();
  53661. break;
  53662. case 'ForceBold':
  53663. program.properties.privateData[token] = this.readBoolean();
  53664. break;
  53665. }
  53666. }
  53667. for (var i = 0; i < charstrings.length; i++) {
  53668. glyph = charstrings[i].glyph;
  53669. encoded = charstrings[i].encoded;
  53670. var charString = new Type1CharString();
  53671. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  53672. var output = charString.output;
  53673. if (error) {
  53674. output = [14];
  53675. }
  53676. program.charstrings.push({
  53677. glyphName: glyph,
  53678. charstring: output,
  53679. width: charString.width,
  53680. lsb: charString.lsb,
  53681. seac: charString.seac
  53682. });
  53683. }
  53684. return program;
  53685. },
  53686. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  53687. var token;
  53688. while ((token = this.getToken()) !== null) {
  53689. if (token !== '/') {
  53690. continue;
  53691. }
  53692. token = this.getToken();
  53693. switch (token) {
  53694. case 'FontMatrix':
  53695. var matrix = this.readNumberArray();
  53696. properties.fontMatrix = matrix;
  53697. break;
  53698. case 'Encoding':
  53699. var encodingArg = this.getToken();
  53700. var encoding;
  53701. if (!/^\d+$/.test(encodingArg)) {
  53702. encoding = getEncoding(encodingArg);
  53703. } else {
  53704. encoding = [];
  53705. var size = parseInt(encodingArg, 10) | 0;
  53706. this.getToken();
  53707. for (var j = 0; j < size; j++) {
  53708. token = this.getToken();
  53709. while (token !== 'dup' && token !== 'def') {
  53710. token = this.getToken();
  53711. if (token === null) {
  53712. return;
  53713. }
  53714. }
  53715. if (token === 'def') {
  53716. break;
  53717. }
  53718. var index = this.readInt();
  53719. this.getToken();
  53720. var glyph = this.getToken();
  53721. encoding[index] = glyph;
  53722. this.getToken();
  53723. }
  53724. }
  53725. properties.builtInEncoding = encoding;
  53726. break;
  53727. case 'FontBBox':
  53728. var fontBBox = this.readNumberArray();
  53729. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  53730. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  53731. properties.ascentScaled = true;
  53732. break;
  53733. }
  53734. }
  53735. }
  53736. };
  53737. return Type1Parser;
  53738. }();
  53739. exports.Type1Parser = Type1Parser;
  53740. /***/ }),
  53741. /* 44 */
  53742. /***/ (function(module, exports, __w_pdfjs_require__) {
  53743. "use strict";
  53744. var sharedUtil = __w_pdfjs_require__(0);
  53745. var displayDOMUtils = __w_pdfjs_require__(3);
  53746. var displayPatternHelper = __w_pdfjs_require__(46);
  53747. var displayWebGL = __w_pdfjs_require__(25);
  53748. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  53749. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  53750. var ImageKind = sharedUtil.ImageKind;
  53751. var OPS = sharedUtil.OPS;
  53752. var TextRenderingMode = sharedUtil.TextRenderingMode;
  53753. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  53754. var Util = sharedUtil.Util;
  53755. var assert = sharedUtil.assert;
  53756. var info = sharedUtil.info;
  53757. var isNum = sharedUtil.isNum;
  53758. var isArray = sharedUtil.isArray;
  53759. var isLittleEndian = sharedUtil.isLittleEndian;
  53760. var error = sharedUtil.error;
  53761. var shadow = sharedUtil.shadow;
  53762. var warn = sharedUtil.warn;
  53763. var TilingPattern = displayPatternHelper.TilingPattern;
  53764. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  53765. var WebGLUtils = displayWebGL.WebGLUtils;
  53766. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  53767. var MIN_FONT_SIZE = 16;
  53768. var MAX_FONT_SIZE = 100;
  53769. var MAX_GROUP_SIZE = 4096;
  53770. var MIN_WIDTH_FACTOR = 0.65;
  53771. var COMPILE_TYPE3_GLYPHS = true;
  53772. var MAX_SIZE_TO_COMPILE = 1000;
  53773. var FULL_CHUNK_HEIGHT = 16;
  53774. var HasCanvasTypedArraysCached = {
  53775. get value() {
  53776. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  53777. }
  53778. };
  53779. var IsLittleEndianCached = {
  53780. get value() {
  53781. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  53782. }
  53783. };
  53784. function addContextCurrentTransform(ctx) {
  53785. if (!ctx.mozCurrentTransform) {
  53786. ctx._originalSave = ctx.save;
  53787. ctx._originalRestore = ctx.restore;
  53788. ctx._originalRotate = ctx.rotate;
  53789. ctx._originalScale = ctx.scale;
  53790. ctx._originalTranslate = ctx.translate;
  53791. ctx._originalTransform = ctx.transform;
  53792. ctx._originalSetTransform = ctx.setTransform;
  53793. ctx._transformMatrix = ctx._transformMatrix || [
  53794. 1,
  53795. 0,
  53796. 0,
  53797. 1,
  53798. 0,
  53799. 0
  53800. ];
  53801. ctx._transformStack = [];
  53802. Object.defineProperty(ctx, 'mozCurrentTransform', {
  53803. get: function getCurrentTransform() {
  53804. return this._transformMatrix;
  53805. }
  53806. });
  53807. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  53808. get: function getCurrentTransformInverse() {
  53809. var m = this._transformMatrix;
  53810. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  53811. var ad_bc = a * d - b * c;
  53812. var bc_ad = b * c - a * d;
  53813. return [
  53814. d / ad_bc,
  53815. b / bc_ad,
  53816. c / bc_ad,
  53817. a / ad_bc,
  53818. (d * e - c * f) / bc_ad,
  53819. (b * e - a * f) / ad_bc
  53820. ];
  53821. }
  53822. });
  53823. ctx.save = function ctxSave() {
  53824. var old = this._transformMatrix;
  53825. this._transformStack.push(old);
  53826. this._transformMatrix = old.slice(0, 6);
  53827. this._originalSave();
  53828. };
  53829. ctx.restore = function ctxRestore() {
  53830. var prev = this._transformStack.pop();
  53831. if (prev) {
  53832. this._transformMatrix = prev;
  53833. this._originalRestore();
  53834. }
  53835. };
  53836. ctx.translate = function ctxTranslate(x, y) {
  53837. var m = this._transformMatrix;
  53838. m[4] = m[0] * x + m[2] * y + m[4];
  53839. m[5] = m[1] * x + m[3] * y + m[5];
  53840. this._originalTranslate(x, y);
  53841. };
  53842. ctx.scale = function ctxScale(x, y) {
  53843. var m = this._transformMatrix;
  53844. m[0] = m[0] * x;
  53845. m[1] = m[1] * x;
  53846. m[2] = m[2] * y;
  53847. m[3] = m[3] * y;
  53848. this._originalScale(x, y);
  53849. };
  53850. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  53851. var m = this._transformMatrix;
  53852. this._transformMatrix = [
  53853. m[0] * a + m[2] * b,
  53854. m[1] * a + m[3] * b,
  53855. m[0] * c + m[2] * d,
  53856. m[1] * c + m[3] * d,
  53857. m[0] * e + m[2] * f + m[4],
  53858. m[1] * e + m[3] * f + m[5]
  53859. ];
  53860. ctx._originalTransform(a, b, c, d, e, f);
  53861. };
  53862. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  53863. this._transformMatrix = [
  53864. a,
  53865. b,
  53866. c,
  53867. d,
  53868. e,
  53869. f
  53870. ];
  53871. ctx._originalSetTransform(a, b, c, d, e, f);
  53872. };
  53873. ctx.rotate = function ctxRotate(angle) {
  53874. var cosValue = Math.cos(angle);
  53875. var sinValue = Math.sin(angle);
  53876. var m = this._transformMatrix;
  53877. this._transformMatrix = [
  53878. m[0] * cosValue + m[2] * sinValue,
  53879. m[1] * cosValue + m[3] * sinValue,
  53880. m[0] * -sinValue + m[2] * cosValue,
  53881. m[1] * -sinValue + m[3] * cosValue,
  53882. m[4],
  53883. m[5]
  53884. ];
  53885. this._originalRotate(angle);
  53886. };
  53887. }
  53888. }
  53889. var CachedCanvases = function CachedCanvasesClosure() {
  53890. function CachedCanvases(canvasFactory) {
  53891. this.canvasFactory = canvasFactory;
  53892. this.cache = Object.create(null);
  53893. }
  53894. CachedCanvases.prototype = {
  53895. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  53896. var canvasEntry;
  53897. if (this.cache[id] !== undefined) {
  53898. canvasEntry = this.cache[id];
  53899. this.canvasFactory.reset(canvasEntry, width, height);
  53900. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  53901. } else {
  53902. canvasEntry = this.canvasFactory.create(width, height);
  53903. this.cache[id] = canvasEntry;
  53904. }
  53905. if (trackTransform) {
  53906. addContextCurrentTransform(canvasEntry.context);
  53907. }
  53908. return canvasEntry;
  53909. },
  53910. clear: function () {
  53911. for (var id in this.cache) {
  53912. var canvasEntry = this.cache[id];
  53913. this.canvasFactory.destroy(canvasEntry);
  53914. delete this.cache[id];
  53915. }
  53916. }
  53917. };
  53918. return CachedCanvases;
  53919. }();
  53920. function compileType3Glyph(imgData) {
  53921. var POINT_TO_PROCESS_LIMIT = 1000;
  53922. var width = imgData.width, height = imgData.height;
  53923. var i, j, j0, width1 = width + 1;
  53924. var points = new Uint8Array(width1 * (height + 1));
  53925. var POINT_TYPES = new Uint8Array([
  53926. 0,
  53927. 2,
  53928. 4,
  53929. 0,
  53930. 1,
  53931. 0,
  53932. 5,
  53933. 4,
  53934. 8,
  53935. 10,
  53936. 0,
  53937. 8,
  53938. 0,
  53939. 2,
  53940. 1,
  53941. 0
  53942. ]);
  53943. var lineSize = width + 7 & ~7, data0 = imgData.data;
  53944. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  53945. for (i = 0, ii = data0.length; i < ii; i++) {
  53946. var mask = 128, elem = data0[i];
  53947. while (mask > 0) {
  53948. data[pos++] = elem & mask ? 0 : 255;
  53949. mask >>= 1;
  53950. }
  53951. }
  53952. var count = 0;
  53953. pos = 0;
  53954. if (data[pos] !== 0) {
  53955. points[0] = 1;
  53956. ++count;
  53957. }
  53958. for (j = 1; j < width; j++) {
  53959. if (data[pos] !== data[pos + 1]) {
  53960. points[j] = data[pos] ? 2 : 1;
  53961. ++count;
  53962. }
  53963. pos++;
  53964. }
  53965. if (data[pos] !== 0) {
  53966. points[j] = 2;
  53967. ++count;
  53968. }
  53969. for (i = 1; i < height; i++) {
  53970. pos = i * lineSize;
  53971. j0 = i * width1;
  53972. if (data[pos - lineSize] !== data[pos]) {
  53973. points[j0] = data[pos] ? 1 : 8;
  53974. ++count;
  53975. }
  53976. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  53977. for (j = 1; j < width; j++) {
  53978. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  53979. if (POINT_TYPES[sum]) {
  53980. points[j0 + j] = POINT_TYPES[sum];
  53981. ++count;
  53982. }
  53983. pos++;
  53984. }
  53985. if (data[pos - lineSize] !== data[pos]) {
  53986. points[j0 + j] = data[pos] ? 2 : 4;
  53987. ++count;
  53988. }
  53989. if (count > POINT_TO_PROCESS_LIMIT) {
  53990. return null;
  53991. }
  53992. }
  53993. pos = lineSize * (height - 1);
  53994. j0 = i * width1;
  53995. if (data[pos] !== 0) {
  53996. points[j0] = 8;
  53997. ++count;
  53998. }
  53999. for (j = 1; j < width; j++) {
  54000. if (data[pos] !== data[pos + 1]) {
  54001. points[j0 + j] = data[pos] ? 4 : 8;
  54002. ++count;
  54003. }
  54004. pos++;
  54005. }
  54006. if (data[pos] !== 0) {
  54007. points[j0 + j] = 4;
  54008. ++count;
  54009. }
  54010. if (count > POINT_TO_PROCESS_LIMIT) {
  54011. return null;
  54012. }
  54013. var steps = new Int32Array([
  54014. 0,
  54015. width1,
  54016. -1,
  54017. 0,
  54018. -width1,
  54019. 0,
  54020. 0,
  54021. 0,
  54022. 1
  54023. ]);
  54024. var outlines = [];
  54025. for (i = 0; count && i <= height; i++) {
  54026. var p = i * width1;
  54027. var end = p + width;
  54028. while (p < end && !points[p]) {
  54029. p++;
  54030. }
  54031. if (p === end) {
  54032. continue;
  54033. }
  54034. var coords = [
  54035. p % width1,
  54036. i
  54037. ];
  54038. var type = points[p], p0 = p, pp;
  54039. do {
  54040. var step = steps[type];
  54041. do {
  54042. p += step;
  54043. } while (!points[p]);
  54044. pp = points[p];
  54045. if (pp !== 5 && pp !== 10) {
  54046. type = pp;
  54047. points[p] = 0;
  54048. } else {
  54049. type = pp & 0x33 * type >> 4;
  54050. points[p] &= type >> 2 | type << 2;
  54051. }
  54052. coords.push(p % width1);
  54053. coords.push(p / width1 | 0);
  54054. --count;
  54055. } while (p0 !== p);
  54056. outlines.push(coords);
  54057. --i;
  54058. }
  54059. var drawOutline = function (c) {
  54060. c.save();
  54061. c.scale(1 / width, -1 / height);
  54062. c.translate(0, -height);
  54063. c.beginPath();
  54064. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54065. var o = outlines[i];
  54066. c.moveTo(o[0], o[1]);
  54067. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54068. c.lineTo(o[j], o[j + 1]);
  54069. }
  54070. }
  54071. c.fill();
  54072. c.beginPath();
  54073. c.restore();
  54074. };
  54075. return drawOutline;
  54076. }
  54077. var CanvasExtraState = function CanvasExtraStateClosure() {
  54078. function CanvasExtraState(old) {
  54079. this.alphaIsShape = false;
  54080. this.fontSize = 0;
  54081. this.fontSizeScale = 1;
  54082. this.textMatrix = IDENTITY_MATRIX;
  54083. this.textMatrixScale = 1;
  54084. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54085. this.leading = 0;
  54086. this.x = 0;
  54087. this.y = 0;
  54088. this.lineX = 0;
  54089. this.lineY = 0;
  54090. this.charSpacing = 0;
  54091. this.wordSpacing = 0;
  54092. this.textHScale = 1;
  54093. this.textRenderingMode = TextRenderingMode.FILL;
  54094. this.textRise = 0;
  54095. this.fillColor = '#000000';
  54096. this.strokeColor = '#000000';
  54097. this.patternFill = false;
  54098. this.fillAlpha = 1;
  54099. this.strokeAlpha = 1;
  54100. this.lineWidth = 1;
  54101. this.activeSMask = null;
  54102. this.resumeSMaskCtx = null;
  54103. this.old = old;
  54104. }
  54105. CanvasExtraState.prototype = {
  54106. clone: function CanvasExtraState_clone() {
  54107. return Object.create(this);
  54108. },
  54109. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54110. this.x = x;
  54111. this.y = y;
  54112. }
  54113. };
  54114. return CanvasExtraState;
  54115. }();
  54116. var CanvasGraphics = function CanvasGraphicsClosure() {
  54117. var EXECUTION_TIME = 15;
  54118. var EXECUTION_STEPS = 10;
  54119. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54120. this.ctx = canvasCtx;
  54121. this.current = new CanvasExtraState();
  54122. this.stateStack = [];
  54123. this.pendingClip = null;
  54124. this.pendingEOFill = false;
  54125. this.res = null;
  54126. this.xobjs = null;
  54127. this.commonObjs = commonObjs;
  54128. this.objs = objs;
  54129. this.canvasFactory = canvasFactory;
  54130. this.imageLayer = imageLayer;
  54131. this.groupStack = [];
  54132. this.processingType3 = null;
  54133. this.baseTransform = null;
  54134. this.baseTransformStack = [];
  54135. this.groupLevel = 0;
  54136. this.smaskStack = [];
  54137. this.smaskCounter = 0;
  54138. this.tempSMask = null;
  54139. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54140. if (canvasCtx) {
  54141. addContextCurrentTransform(canvasCtx);
  54142. }
  54143. this.cachedGetSinglePixelWidth = null;
  54144. }
  54145. function putBinaryImageData(ctx, imgData) {
  54146. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54147. ctx.putImageData(imgData, 0, 0);
  54148. return;
  54149. }
  54150. var height = imgData.height, width = imgData.width;
  54151. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54152. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54153. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54154. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54155. var srcPos = 0, destPos;
  54156. var src = imgData.data;
  54157. var dest = chunkImgData.data;
  54158. var i, j, thisChunkHeight, elemsInThisChunk;
  54159. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54160. var srcLength = src.byteLength;
  54161. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54162. var dest32DataLength = dest32.length;
  54163. var fullSrcDiff = width + 7 >> 3;
  54164. var white = 0xFFFFFFFF;
  54165. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54166. for (i = 0; i < totalChunks; i++) {
  54167. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54168. destPos = 0;
  54169. for (j = 0; j < thisChunkHeight; j++) {
  54170. var srcDiff = srcLength - srcPos;
  54171. var k = 0;
  54172. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54173. var kEndUnrolled = kEnd & ~7;
  54174. var mask = 0;
  54175. var srcByte = 0;
  54176. for (; k < kEndUnrolled; k += 8) {
  54177. srcByte = src[srcPos++];
  54178. dest32[destPos++] = srcByte & 128 ? white : black;
  54179. dest32[destPos++] = srcByte & 64 ? white : black;
  54180. dest32[destPos++] = srcByte & 32 ? white : black;
  54181. dest32[destPos++] = srcByte & 16 ? white : black;
  54182. dest32[destPos++] = srcByte & 8 ? white : black;
  54183. dest32[destPos++] = srcByte & 4 ? white : black;
  54184. dest32[destPos++] = srcByte & 2 ? white : black;
  54185. dest32[destPos++] = srcByte & 1 ? white : black;
  54186. }
  54187. for (; k < kEnd; k++) {
  54188. if (mask === 0) {
  54189. srcByte = src[srcPos++];
  54190. mask = 128;
  54191. }
  54192. dest32[destPos++] = srcByte & mask ? white : black;
  54193. mask >>= 1;
  54194. }
  54195. }
  54196. while (destPos < dest32DataLength) {
  54197. dest32[destPos++] = 0;
  54198. }
  54199. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54200. }
  54201. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  54202. j = 0;
  54203. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  54204. for (i = 0; i < fullChunks; i++) {
  54205. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54206. srcPos += elemsInThisChunk;
  54207. ctx.putImageData(chunkImgData, 0, j);
  54208. j += FULL_CHUNK_HEIGHT;
  54209. }
  54210. if (i < totalChunks) {
  54211. elemsInThisChunk = width * partialChunkHeight * 4;
  54212. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54213. ctx.putImageData(chunkImgData, 0, j);
  54214. }
  54215. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  54216. thisChunkHeight = FULL_CHUNK_HEIGHT;
  54217. elemsInThisChunk = width * thisChunkHeight;
  54218. for (i = 0; i < totalChunks; i++) {
  54219. if (i >= fullChunks) {
  54220. thisChunkHeight = partialChunkHeight;
  54221. elemsInThisChunk = width * thisChunkHeight;
  54222. }
  54223. destPos = 0;
  54224. for (j = elemsInThisChunk; j--;) {
  54225. dest[destPos++] = src[srcPos++];
  54226. dest[destPos++] = src[srcPos++];
  54227. dest[destPos++] = src[srcPos++];
  54228. dest[destPos++] = 255;
  54229. }
  54230. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54231. }
  54232. } else {
  54233. error('bad image kind: ' + imgData.kind);
  54234. }
  54235. }
  54236. function putBinaryImageMask(ctx, imgData) {
  54237. var height = imgData.height, width = imgData.width;
  54238. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54239. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54240. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54241. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54242. var srcPos = 0;
  54243. var src = imgData.data;
  54244. var dest = chunkImgData.data;
  54245. for (var i = 0; i < totalChunks; i++) {
  54246. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54247. var destPos = 3;
  54248. for (var j = 0; j < thisChunkHeight; j++) {
  54249. var mask = 0;
  54250. for (var k = 0; k < width; k++) {
  54251. if (!mask) {
  54252. var elem = src[srcPos++];
  54253. mask = 128;
  54254. }
  54255. dest[destPos] = elem & mask ? 0 : 255;
  54256. destPos += 4;
  54257. mask >>= 1;
  54258. }
  54259. }
  54260. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54261. }
  54262. }
  54263. function copyCtxState(sourceCtx, destCtx) {
  54264. var properties = [
  54265. 'strokeStyle',
  54266. 'fillStyle',
  54267. 'fillRule',
  54268. 'globalAlpha',
  54269. 'lineWidth',
  54270. 'lineCap',
  54271. 'lineJoin',
  54272. 'miterLimit',
  54273. 'globalCompositeOperation',
  54274. 'font'
  54275. ];
  54276. for (var i = 0, ii = properties.length; i < ii; i++) {
  54277. var property = properties[i];
  54278. if (sourceCtx[property] !== undefined) {
  54279. destCtx[property] = sourceCtx[property];
  54280. }
  54281. }
  54282. if (sourceCtx.setLineDash !== undefined) {
  54283. destCtx.setLineDash(sourceCtx.getLineDash());
  54284. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  54285. }
  54286. }
  54287. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  54288. var length = bytes.length;
  54289. for (var i = 3; i < length; i += 4) {
  54290. var alpha = bytes[i];
  54291. if (alpha === 0) {
  54292. bytes[i - 3] = r0;
  54293. bytes[i - 2] = g0;
  54294. bytes[i - 1] = b0;
  54295. } else if (alpha < 255) {
  54296. var alpha_ = 255 - alpha;
  54297. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  54298. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  54299. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  54300. }
  54301. }
  54302. }
  54303. function composeSMaskAlpha(maskData, layerData, transferMap) {
  54304. var length = maskData.length;
  54305. var scale = 1 / 255;
  54306. for (var i = 3; i < length; i += 4) {
  54307. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  54308. layerData[i] = layerData[i] * alpha * scale | 0;
  54309. }
  54310. }
  54311. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  54312. var length = maskData.length;
  54313. for (var i = 3; i < length; i += 4) {
  54314. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  54315. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  54316. }
  54317. }
  54318. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  54319. var hasBackdrop = !!backdrop;
  54320. var r0 = hasBackdrop ? backdrop[0] : 0;
  54321. var g0 = hasBackdrop ? backdrop[1] : 0;
  54322. var b0 = hasBackdrop ? backdrop[2] : 0;
  54323. var composeFn;
  54324. if (subtype === 'Luminosity') {
  54325. composeFn = composeSMaskLuminosity;
  54326. } else {
  54327. composeFn = composeSMaskAlpha;
  54328. }
  54329. var PIXELS_TO_PROCESS = 1048576;
  54330. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  54331. for (var row = 0; row < height; row += chunkSize) {
  54332. var chunkHeight = Math.min(chunkSize, height - row);
  54333. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  54334. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  54335. if (hasBackdrop) {
  54336. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  54337. }
  54338. composeFn(maskData.data, layerData.data, transferMap);
  54339. maskCtx.putImageData(layerData, 0, row);
  54340. }
  54341. }
  54342. function composeSMask(ctx, smask, layerCtx) {
  54343. var mask = smask.canvas;
  54344. var maskCtx = smask.context;
  54345. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  54346. var backdrop = smask.backdrop || null;
  54347. if (!smask.transferMap && WebGLUtils.isEnabled) {
  54348. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  54349. subtype: smask.subtype,
  54350. backdrop: backdrop
  54351. });
  54352. ctx.setTransform(1, 0, 0, 1, 0, 0);
  54353. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  54354. return;
  54355. }
  54356. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  54357. ctx.drawImage(mask, 0, 0);
  54358. }
  54359. var LINE_CAP_STYLES = [
  54360. 'butt',
  54361. 'round',
  54362. 'square'
  54363. ];
  54364. var LINE_JOIN_STYLES = [
  54365. 'miter',
  54366. 'round',
  54367. 'bevel'
  54368. ];
  54369. var NORMAL_CLIP = {};
  54370. var EO_CLIP = {};
  54371. CanvasGraphics.prototype = {
  54372. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  54373. var width = this.ctx.canvas.width;
  54374. var height = this.ctx.canvas.height;
  54375. this.ctx.save();
  54376. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  54377. this.ctx.fillRect(0, 0, width, height);
  54378. this.ctx.restore();
  54379. if (transparency) {
  54380. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  54381. this.compositeCtx = this.ctx;
  54382. this.transparentCanvas = transparentCanvas.canvas;
  54383. this.ctx = transparentCanvas.context;
  54384. this.ctx.save();
  54385. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  54386. }
  54387. this.ctx.save();
  54388. if (transform) {
  54389. this.ctx.transform.apply(this.ctx, transform);
  54390. }
  54391. this.ctx.transform.apply(this.ctx, viewport.transform);
  54392. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  54393. if (this.imageLayer) {
  54394. this.imageLayer.beginLayout();
  54395. }
  54396. },
  54397. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  54398. var argsArray = operatorList.argsArray;
  54399. var fnArray = operatorList.fnArray;
  54400. var i = executionStartIdx || 0;
  54401. var argsArrayLen = argsArray.length;
  54402. if (argsArrayLen === i) {
  54403. return i;
  54404. }
  54405. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  54406. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  54407. var steps = 0;
  54408. var commonObjs = this.commonObjs;
  54409. var objs = this.objs;
  54410. var fnId;
  54411. while (true) {
  54412. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  54413. stepper.breakIt(i, continueCallback);
  54414. return i;
  54415. }
  54416. fnId = fnArray[i];
  54417. if (fnId !== OPS.dependency) {
  54418. this[fnId].apply(this, argsArray[i]);
  54419. } else {
  54420. var deps = argsArray[i];
  54421. for (var n = 0, nn = deps.length; n < nn; n++) {
  54422. var depObjId = deps[n];
  54423. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  54424. var objsPool = common ? commonObjs : objs;
  54425. if (!objsPool.isResolved(depObjId)) {
  54426. objsPool.get(depObjId, continueCallback);
  54427. return i;
  54428. }
  54429. }
  54430. }
  54431. i++;
  54432. if (i === argsArrayLen) {
  54433. return i;
  54434. }
  54435. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  54436. if (Date.now() > endTime) {
  54437. continueCallback();
  54438. return i;
  54439. }
  54440. steps = 0;
  54441. }
  54442. }
  54443. },
  54444. endDrawing: function CanvasGraphics_endDrawing() {
  54445. if (this.current.activeSMask !== null) {
  54446. this.endSMaskGroup();
  54447. }
  54448. this.ctx.restore();
  54449. if (this.transparentCanvas) {
  54450. this.ctx = this.compositeCtx;
  54451. this.ctx.save();
  54452. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  54453. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  54454. this.ctx.restore();
  54455. this.transparentCanvas = null;
  54456. }
  54457. this.cachedCanvases.clear();
  54458. WebGLUtils.clear();
  54459. if (this.imageLayer) {
  54460. this.imageLayer.endLayout();
  54461. }
  54462. },
  54463. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  54464. this.current.lineWidth = width;
  54465. this.ctx.lineWidth = width;
  54466. },
  54467. setLineCap: function CanvasGraphics_setLineCap(style) {
  54468. this.ctx.lineCap = LINE_CAP_STYLES[style];
  54469. },
  54470. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  54471. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  54472. },
  54473. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  54474. this.ctx.miterLimit = limit;
  54475. },
  54476. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  54477. var ctx = this.ctx;
  54478. if (ctx.setLineDash !== undefined) {
  54479. ctx.setLineDash(dashArray);
  54480. ctx.lineDashOffset = dashPhase;
  54481. }
  54482. },
  54483. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  54484. },
  54485. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  54486. },
  54487. setGState: function CanvasGraphics_setGState(states) {
  54488. for (var i = 0, ii = states.length; i < ii; i++) {
  54489. var state = states[i];
  54490. var key = state[0];
  54491. var value = state[1];
  54492. switch (key) {
  54493. case 'LW':
  54494. this.setLineWidth(value);
  54495. break;
  54496. case 'LC':
  54497. this.setLineCap(value);
  54498. break;
  54499. case 'LJ':
  54500. this.setLineJoin(value);
  54501. break;
  54502. case 'ML':
  54503. this.setMiterLimit(value);
  54504. break;
  54505. case 'D':
  54506. this.setDash(value[0], value[1]);
  54507. break;
  54508. case 'RI':
  54509. this.setRenderingIntent(value);
  54510. break;
  54511. case 'FL':
  54512. this.setFlatness(value);
  54513. break;
  54514. case 'Font':
  54515. this.setFont(value[0], value[1]);
  54516. break;
  54517. case 'CA':
  54518. this.current.strokeAlpha = state[1];
  54519. break;
  54520. case 'ca':
  54521. this.current.fillAlpha = state[1];
  54522. this.ctx.globalAlpha = state[1];
  54523. break;
  54524. case 'BM':
  54525. if (value && value.name && value.name !== 'Normal') {
  54526. var mode = value.name.replace(/([A-Z])/g, function (c) {
  54527. return '-' + c.toLowerCase();
  54528. }).substring(1);
  54529. this.ctx.globalCompositeOperation = mode;
  54530. if (this.ctx.globalCompositeOperation !== mode) {
  54531. warn('globalCompositeOperation "' + mode + '" is not supported');
  54532. }
  54533. } else {
  54534. this.ctx.globalCompositeOperation = 'source-over';
  54535. }
  54536. break;
  54537. case 'SMask':
  54538. if (this.current.activeSMask) {
  54539. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  54540. this.suspendSMaskGroup();
  54541. } else {
  54542. this.endSMaskGroup();
  54543. }
  54544. }
  54545. this.current.activeSMask = value ? this.tempSMask : null;
  54546. if (this.current.activeSMask) {
  54547. this.beginSMaskGroup();
  54548. }
  54549. this.tempSMask = null;
  54550. break;
  54551. }
  54552. }
  54553. },
  54554. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  54555. var activeSMask = this.current.activeSMask;
  54556. var drawnWidth = activeSMask.canvas.width;
  54557. var drawnHeight = activeSMask.canvas.height;
  54558. var cacheId = 'smaskGroupAt' + this.groupLevel;
  54559. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  54560. var currentCtx = this.ctx;
  54561. var currentTransform = currentCtx.mozCurrentTransform;
  54562. this.ctx.save();
  54563. var groupCtx = scratchCanvas.context;
  54564. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  54565. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  54566. groupCtx.transform.apply(groupCtx, currentTransform);
  54567. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  54568. copyCtxState(currentCtx, groupCtx);
  54569. this.ctx = groupCtx;
  54570. this.setGState([
  54571. [
  54572. 'BM',
  54573. 'Normal'
  54574. ],
  54575. [
  54576. 'ca',
  54577. 1
  54578. ],
  54579. [
  54580. 'CA',
  54581. 1
  54582. ]
  54583. ]);
  54584. this.groupStack.push(currentCtx);
  54585. this.groupLevel++;
  54586. },
  54587. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54588. var groupCtx = this.ctx;
  54589. this.groupLevel--;
  54590. this.ctx = this.groupStack.pop();
  54591. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54592. this.ctx.restore();
  54593. this.ctx.save();
  54594. copyCtxState(groupCtx, this.ctx);
  54595. this.current.resumeSMaskCtx = groupCtx;
  54596. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54597. this.ctx.transform.apply(this.ctx, deltaTransform);
  54598. groupCtx.save();
  54599. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  54600. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  54601. groupCtx.restore();
  54602. },
  54603. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54604. var groupCtx = this.current.resumeSMaskCtx;
  54605. var currentCtx = this.ctx;
  54606. this.ctx = groupCtx;
  54607. this.groupStack.push(currentCtx);
  54608. this.groupLevel++;
  54609. },
  54610. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54611. var groupCtx = this.ctx;
  54612. this.groupLevel--;
  54613. this.ctx = this.groupStack.pop();
  54614. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54615. this.ctx.restore();
  54616. copyCtxState(groupCtx, this.ctx);
  54617. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54618. this.ctx.transform.apply(this.ctx, deltaTransform);
  54619. },
  54620. save: function CanvasGraphics_save() {
  54621. this.ctx.save();
  54622. var old = this.current;
  54623. this.stateStack.push(old);
  54624. this.current = old.clone();
  54625. this.current.resumeSMaskCtx = null;
  54626. },
  54627. restore: function CanvasGraphics_restore() {
  54628. if (this.current.resumeSMaskCtx) {
  54629. this.resumeSMaskGroup();
  54630. }
  54631. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  54632. this.endSMaskGroup();
  54633. }
  54634. if (this.stateStack.length !== 0) {
  54635. this.current = this.stateStack.pop();
  54636. this.ctx.restore();
  54637. this.pendingClip = null;
  54638. this.cachedGetSinglePixelWidth = null;
  54639. }
  54640. },
  54641. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  54642. this.ctx.transform(a, b, c, d, e, f);
  54643. this.cachedGetSinglePixelWidth = null;
  54644. },
  54645. constructPath: function CanvasGraphics_constructPath(ops, args) {
  54646. var ctx = this.ctx;
  54647. var current = this.current;
  54648. var x = current.x, y = current.y;
  54649. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  54650. switch (ops[i] | 0) {
  54651. case OPS.rectangle:
  54652. x = args[j++];
  54653. y = args[j++];
  54654. var width = args[j++];
  54655. var height = args[j++];
  54656. if (width === 0) {
  54657. width = this.getSinglePixelWidth();
  54658. }
  54659. if (height === 0) {
  54660. height = this.getSinglePixelWidth();
  54661. }
  54662. var xw = x + width;
  54663. var yh = y + height;
  54664. this.ctx.moveTo(x, y);
  54665. this.ctx.lineTo(xw, y);
  54666. this.ctx.lineTo(xw, yh);
  54667. this.ctx.lineTo(x, yh);
  54668. this.ctx.lineTo(x, y);
  54669. this.ctx.closePath();
  54670. break;
  54671. case OPS.moveTo:
  54672. x = args[j++];
  54673. y = args[j++];
  54674. ctx.moveTo(x, y);
  54675. break;
  54676. case OPS.lineTo:
  54677. x = args[j++];
  54678. y = args[j++];
  54679. ctx.lineTo(x, y);
  54680. break;
  54681. case OPS.curveTo:
  54682. x = args[j + 4];
  54683. y = args[j + 5];
  54684. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  54685. j += 6;
  54686. break;
  54687. case OPS.curveTo2:
  54688. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  54689. x = args[j + 2];
  54690. y = args[j + 3];
  54691. j += 4;
  54692. break;
  54693. case OPS.curveTo3:
  54694. x = args[j + 2];
  54695. y = args[j + 3];
  54696. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  54697. j += 4;
  54698. break;
  54699. case OPS.closePath:
  54700. ctx.closePath();
  54701. break;
  54702. }
  54703. }
  54704. current.setCurrentPoint(x, y);
  54705. },
  54706. closePath: function CanvasGraphics_closePath() {
  54707. this.ctx.closePath();
  54708. },
  54709. stroke: function CanvasGraphics_stroke(consumePath) {
  54710. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54711. var ctx = this.ctx;
  54712. var strokeColor = this.current.strokeColor;
  54713. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  54714. ctx.globalAlpha = this.current.strokeAlpha;
  54715. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  54716. ctx.save();
  54717. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  54718. ctx.stroke();
  54719. ctx.restore();
  54720. } else {
  54721. ctx.stroke();
  54722. }
  54723. if (consumePath) {
  54724. this.consumePath();
  54725. }
  54726. ctx.globalAlpha = this.current.fillAlpha;
  54727. },
  54728. closeStroke: function CanvasGraphics_closeStroke() {
  54729. this.closePath();
  54730. this.stroke();
  54731. },
  54732. fill: function CanvasGraphics_fill(consumePath) {
  54733. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54734. var ctx = this.ctx;
  54735. var fillColor = this.current.fillColor;
  54736. var isPatternFill = this.current.patternFill;
  54737. var needRestore = false;
  54738. if (isPatternFill) {
  54739. ctx.save();
  54740. if (this.baseTransform) {
  54741. ctx.setTransform.apply(ctx, this.baseTransform);
  54742. }
  54743. ctx.fillStyle = fillColor.getPattern(ctx, this);
  54744. needRestore = true;
  54745. }
  54746. if (this.pendingEOFill) {
  54747. ctx.fill('evenodd');
  54748. this.pendingEOFill = false;
  54749. } else {
  54750. ctx.fill();
  54751. }
  54752. if (needRestore) {
  54753. ctx.restore();
  54754. }
  54755. if (consumePath) {
  54756. this.consumePath();
  54757. }
  54758. },
  54759. eoFill: function CanvasGraphics_eoFill() {
  54760. this.pendingEOFill = true;
  54761. this.fill();
  54762. },
  54763. fillStroke: function CanvasGraphics_fillStroke() {
  54764. this.fill(false);
  54765. this.stroke(false);
  54766. this.consumePath();
  54767. },
  54768. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  54769. this.pendingEOFill = true;
  54770. this.fillStroke();
  54771. },
  54772. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  54773. this.closePath();
  54774. this.fillStroke();
  54775. },
  54776. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  54777. this.pendingEOFill = true;
  54778. this.closePath();
  54779. this.fillStroke();
  54780. },
  54781. endPath: function CanvasGraphics_endPath() {
  54782. this.consumePath();
  54783. },
  54784. clip: function CanvasGraphics_clip() {
  54785. this.pendingClip = NORMAL_CLIP;
  54786. },
  54787. eoClip: function CanvasGraphics_eoClip() {
  54788. this.pendingClip = EO_CLIP;
  54789. },
  54790. beginText: function CanvasGraphics_beginText() {
  54791. this.current.textMatrix = IDENTITY_MATRIX;
  54792. this.current.textMatrixScale = 1;
  54793. this.current.x = this.current.lineX = 0;
  54794. this.current.y = this.current.lineY = 0;
  54795. },
  54796. endText: function CanvasGraphics_endText() {
  54797. var paths = this.pendingTextPaths;
  54798. var ctx = this.ctx;
  54799. if (paths === undefined) {
  54800. ctx.beginPath();
  54801. return;
  54802. }
  54803. ctx.save();
  54804. ctx.beginPath();
  54805. for (var i = 0; i < paths.length; i++) {
  54806. var path = paths[i];
  54807. ctx.setTransform.apply(ctx, path.transform);
  54808. ctx.translate(path.x, path.y);
  54809. path.addToPath(ctx, path.fontSize);
  54810. }
  54811. ctx.restore();
  54812. ctx.clip();
  54813. ctx.beginPath();
  54814. delete this.pendingTextPaths;
  54815. },
  54816. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  54817. this.current.charSpacing = spacing;
  54818. },
  54819. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  54820. this.current.wordSpacing = spacing;
  54821. },
  54822. setHScale: function CanvasGraphics_setHScale(scale) {
  54823. this.current.textHScale = scale / 100;
  54824. },
  54825. setLeading: function CanvasGraphics_setLeading(leading) {
  54826. this.current.leading = -leading;
  54827. },
  54828. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  54829. var fontObj = this.commonObjs.get(fontRefName);
  54830. var current = this.current;
  54831. if (!fontObj) {
  54832. error('Can\'t find font for ' + fontRefName);
  54833. }
  54834. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  54835. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  54836. warn('Invalid font matrix for font ' + fontRefName);
  54837. }
  54838. if (size < 0) {
  54839. size = -size;
  54840. current.fontDirection = -1;
  54841. } else {
  54842. current.fontDirection = 1;
  54843. }
  54844. this.current.font = fontObj;
  54845. this.current.fontSize = size;
  54846. if (fontObj.isType3Font) {
  54847. return;
  54848. }
  54849. var name = fontObj.loadedName || 'sans-serif';
  54850. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  54851. var italic = fontObj.italic ? 'italic' : 'normal';
  54852. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  54853. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  54854. this.current.fontSizeScale = size / browserFontSize;
  54855. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  54856. this.ctx.font = rule;
  54857. },
  54858. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  54859. this.current.textRenderingMode = mode;
  54860. },
  54861. setTextRise: function CanvasGraphics_setTextRise(rise) {
  54862. this.current.textRise = rise;
  54863. },
  54864. moveText: function CanvasGraphics_moveText(x, y) {
  54865. this.current.x = this.current.lineX += x;
  54866. this.current.y = this.current.lineY += y;
  54867. },
  54868. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  54869. this.setLeading(-y);
  54870. this.moveText(x, y);
  54871. },
  54872. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  54873. this.current.textMatrix = [
  54874. a,
  54875. b,
  54876. c,
  54877. d,
  54878. e,
  54879. f
  54880. ];
  54881. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  54882. this.current.x = this.current.lineX = 0;
  54883. this.current.y = this.current.lineY = 0;
  54884. },
  54885. nextLine: function CanvasGraphics_nextLine() {
  54886. this.moveText(0, this.current.leading);
  54887. },
  54888. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  54889. var ctx = this.ctx;
  54890. var current = this.current;
  54891. var font = current.font;
  54892. var textRenderingMode = current.textRenderingMode;
  54893. var fontSize = current.fontSize / current.fontSizeScale;
  54894. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54895. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  54896. var addToPath;
  54897. if (font.disableFontFace || isAddToPathSet) {
  54898. addToPath = font.getPathGenerator(this.commonObjs, character);
  54899. }
  54900. if (font.disableFontFace) {
  54901. ctx.save();
  54902. ctx.translate(x, y);
  54903. ctx.beginPath();
  54904. addToPath(ctx, fontSize);
  54905. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54906. ctx.fill();
  54907. }
  54908. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54909. ctx.stroke();
  54910. }
  54911. ctx.restore();
  54912. } else {
  54913. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54914. ctx.fillText(character, x, y);
  54915. }
  54916. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54917. ctx.strokeText(character, x, y);
  54918. }
  54919. }
  54920. if (isAddToPathSet) {
  54921. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  54922. paths.push({
  54923. transform: ctx.mozCurrentTransform,
  54924. x: x,
  54925. y: y,
  54926. fontSize: fontSize,
  54927. addToPath: addToPath
  54928. });
  54929. }
  54930. },
  54931. get isFontSubpixelAAEnabled() {
  54932. var ctx = this.canvasFactory.create(10, 10).context;
  54933. ctx.scale(1.5, 1);
  54934. ctx.fillText('I', 0, 10);
  54935. var data = ctx.getImageData(0, 0, 10, 10).data;
  54936. var enabled = false;
  54937. for (var i = 3; i < data.length; i += 4) {
  54938. if (data[i] > 0 && data[i] < 255) {
  54939. enabled = true;
  54940. break;
  54941. }
  54942. }
  54943. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  54944. },
  54945. showText: function CanvasGraphics_showText(glyphs) {
  54946. var current = this.current;
  54947. var font = current.font;
  54948. if (font.isType3Font) {
  54949. return this.showType3Text(glyphs);
  54950. }
  54951. var fontSize = current.fontSize;
  54952. if (fontSize === 0) {
  54953. return;
  54954. }
  54955. var ctx = this.ctx;
  54956. var fontSizeScale = current.fontSizeScale;
  54957. var charSpacing = current.charSpacing;
  54958. var wordSpacing = current.wordSpacing;
  54959. var fontDirection = current.fontDirection;
  54960. var textHScale = current.textHScale * fontDirection;
  54961. var glyphsLength = glyphs.length;
  54962. var vertical = font.vertical;
  54963. var spacingDir = vertical ? 1 : -1;
  54964. var defaultVMetrics = font.defaultVMetrics;
  54965. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  54966. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  54967. ctx.save();
  54968. ctx.transform.apply(ctx, current.textMatrix);
  54969. ctx.translate(current.x, current.y + current.textRise);
  54970. if (current.patternFill) {
  54971. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  54972. }
  54973. if (fontDirection > 0) {
  54974. ctx.scale(textHScale, -1);
  54975. } else {
  54976. ctx.scale(textHScale, 1);
  54977. }
  54978. var lineWidth = current.lineWidth;
  54979. var scale = current.textMatrixScale;
  54980. if (scale === 0 || lineWidth === 0) {
  54981. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54982. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54983. this.cachedGetSinglePixelWidth = null;
  54984. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  54985. }
  54986. } else {
  54987. lineWidth /= scale;
  54988. }
  54989. if (fontSizeScale !== 1.0) {
  54990. ctx.scale(fontSizeScale, fontSizeScale);
  54991. lineWidth /= fontSizeScale;
  54992. }
  54993. ctx.lineWidth = lineWidth;
  54994. var x = 0, i;
  54995. for (i = 0; i < glyphsLength; ++i) {
  54996. var glyph = glyphs[i];
  54997. if (isNum(glyph)) {
  54998. x += spacingDir * glyph * fontSize / 1000;
  54999. continue;
  55000. }
  55001. var restoreNeeded = false;
  55002. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55003. var character = glyph.fontChar;
  55004. var accent = glyph.accent;
  55005. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55006. var width = glyph.width;
  55007. if (vertical) {
  55008. var vmetric, vx, vy;
  55009. vmetric = glyph.vmetric || defaultVMetrics;
  55010. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55011. vx = -vx * widthAdvanceScale;
  55012. vy = vmetric[2] * widthAdvanceScale;
  55013. width = vmetric ? -vmetric[0] : width;
  55014. scaledX = vx / fontSizeScale;
  55015. scaledY = (x + vy) / fontSizeScale;
  55016. } else {
  55017. scaledX = x / fontSizeScale;
  55018. scaledY = 0;
  55019. }
  55020. if (font.remeasure && width > 0) {
  55021. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55022. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55023. var characterScaleX = width / measuredWidth;
  55024. restoreNeeded = true;
  55025. ctx.save();
  55026. ctx.scale(characterScaleX, 1);
  55027. scaledX /= characterScaleX;
  55028. } else if (width !== measuredWidth) {
  55029. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55030. }
  55031. }
  55032. if (glyph.isInFont || font.missingFile) {
  55033. if (simpleFillText && !accent) {
  55034. ctx.fillText(character, scaledX, scaledY);
  55035. } else {
  55036. this.paintChar(character, scaledX, scaledY);
  55037. if (accent) {
  55038. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55039. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55040. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55041. }
  55042. }
  55043. }
  55044. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55045. x += charWidth;
  55046. if (restoreNeeded) {
  55047. ctx.restore();
  55048. }
  55049. }
  55050. if (vertical) {
  55051. current.y -= x * textHScale;
  55052. } else {
  55053. current.x += x * textHScale;
  55054. }
  55055. ctx.restore();
  55056. },
  55057. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55058. var ctx = this.ctx;
  55059. var current = this.current;
  55060. var font = current.font;
  55061. var fontSize = current.fontSize;
  55062. var fontDirection = current.fontDirection;
  55063. var spacingDir = font.vertical ? 1 : -1;
  55064. var charSpacing = current.charSpacing;
  55065. var wordSpacing = current.wordSpacing;
  55066. var textHScale = current.textHScale * fontDirection;
  55067. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55068. var glyphsLength = glyphs.length;
  55069. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55070. var i, glyph, width, spacingLength;
  55071. if (isTextInvisible || fontSize === 0) {
  55072. return;
  55073. }
  55074. this.cachedGetSinglePixelWidth = null;
  55075. ctx.save();
  55076. ctx.transform.apply(ctx, current.textMatrix);
  55077. ctx.translate(current.x, current.y);
  55078. ctx.scale(textHScale, fontDirection);
  55079. for (i = 0; i < glyphsLength; ++i) {
  55080. glyph = glyphs[i];
  55081. if (isNum(glyph)) {
  55082. spacingLength = spacingDir * glyph * fontSize / 1000;
  55083. this.ctx.translate(spacingLength, 0);
  55084. current.x += spacingLength * textHScale;
  55085. continue;
  55086. }
  55087. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55088. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55089. if (!operatorList) {
  55090. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55091. continue;
  55092. }
  55093. this.processingType3 = glyph;
  55094. this.save();
  55095. ctx.scale(fontSize, fontSize);
  55096. ctx.transform.apply(ctx, fontMatrix);
  55097. this.executeOperatorList(operatorList);
  55098. this.restore();
  55099. var transformed = Util.applyTransform([
  55100. glyph.width,
  55101. 0
  55102. ], fontMatrix);
  55103. width = transformed[0] * fontSize + spacing;
  55104. ctx.translate(width, 0);
  55105. current.x += width * textHScale;
  55106. }
  55107. ctx.restore();
  55108. this.processingType3 = null;
  55109. },
  55110. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55111. },
  55112. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55113. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55114. this.clip();
  55115. this.endPath();
  55116. },
  55117. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55118. var pattern;
  55119. if (IR[0] === 'TilingPattern') {
  55120. var color = IR[1];
  55121. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55122. var self = this;
  55123. var canvasGraphicsFactory = {
  55124. createCanvasGraphics: function (ctx) {
  55125. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55126. }
  55127. };
  55128. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55129. } else {
  55130. pattern = getShadingPatternFromIR(IR);
  55131. }
  55132. return pattern;
  55133. },
  55134. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55135. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55136. },
  55137. setFillColorN: function CanvasGraphics_setFillColorN() {
  55138. this.current.fillColor = this.getColorN_Pattern(arguments);
  55139. this.current.patternFill = true;
  55140. },
  55141. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55142. var color = Util.makeCssRgb(r, g, b);
  55143. this.ctx.strokeStyle = color;
  55144. this.current.strokeColor = color;
  55145. },
  55146. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55147. var color = Util.makeCssRgb(r, g, b);
  55148. this.ctx.fillStyle = color;
  55149. this.current.fillColor = color;
  55150. this.current.patternFill = false;
  55151. },
  55152. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55153. var ctx = this.ctx;
  55154. this.save();
  55155. var pattern = getShadingPatternFromIR(patternIR);
  55156. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55157. var inv = ctx.mozCurrentTransformInverse;
  55158. if (inv) {
  55159. var canvas = ctx.canvas;
  55160. var width = canvas.width;
  55161. var height = canvas.height;
  55162. var bl = Util.applyTransform([
  55163. 0,
  55164. 0
  55165. ], inv);
  55166. var br = Util.applyTransform([
  55167. 0,
  55168. height
  55169. ], inv);
  55170. var ul = Util.applyTransform([
  55171. width,
  55172. 0
  55173. ], inv);
  55174. var ur = Util.applyTransform([
  55175. width,
  55176. height
  55177. ], inv);
  55178. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55179. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  55180. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  55181. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  55182. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  55183. } else {
  55184. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  55185. }
  55186. this.restore();
  55187. },
  55188. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  55189. error('Should not call beginInlineImage');
  55190. },
  55191. beginImageData: function CanvasGraphics_beginImageData() {
  55192. error('Should not call beginImageData');
  55193. },
  55194. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  55195. this.save();
  55196. this.baseTransformStack.push(this.baseTransform);
  55197. if (isArray(matrix) && matrix.length === 6) {
  55198. this.transform.apply(this, matrix);
  55199. }
  55200. this.baseTransform = this.ctx.mozCurrentTransform;
  55201. if (isArray(bbox) && bbox.length === 4) {
  55202. var width = bbox[2] - bbox[0];
  55203. var height = bbox[3] - bbox[1];
  55204. this.ctx.rect(bbox[0], bbox[1], width, height);
  55205. this.clip();
  55206. this.endPath();
  55207. }
  55208. },
  55209. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  55210. this.restore();
  55211. this.baseTransform = this.baseTransformStack.pop();
  55212. },
  55213. beginGroup: function CanvasGraphics_beginGroup(group) {
  55214. this.save();
  55215. var currentCtx = this.ctx;
  55216. if (!group.isolated) {
  55217. info('TODO: Support non-isolated groups.');
  55218. }
  55219. if (group.knockout) {
  55220. warn('Knockout groups not supported.');
  55221. }
  55222. var currentTransform = currentCtx.mozCurrentTransform;
  55223. if (group.matrix) {
  55224. currentCtx.transform.apply(currentCtx, group.matrix);
  55225. }
  55226. assert(group.bbox, 'Bounding box is required.');
  55227. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  55228. var canvasBounds = [
  55229. 0,
  55230. 0,
  55231. currentCtx.canvas.width,
  55232. currentCtx.canvas.height
  55233. ];
  55234. bounds = Util.intersect(bounds, canvasBounds) || [
  55235. 0,
  55236. 0,
  55237. 0,
  55238. 0
  55239. ];
  55240. var offsetX = Math.floor(bounds[0]);
  55241. var offsetY = Math.floor(bounds[1]);
  55242. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  55243. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  55244. var scaleX = 1, scaleY = 1;
  55245. if (drawnWidth > MAX_GROUP_SIZE) {
  55246. scaleX = drawnWidth / MAX_GROUP_SIZE;
  55247. drawnWidth = MAX_GROUP_SIZE;
  55248. }
  55249. if (drawnHeight > MAX_GROUP_SIZE) {
  55250. scaleY = drawnHeight / MAX_GROUP_SIZE;
  55251. drawnHeight = MAX_GROUP_SIZE;
  55252. }
  55253. var cacheId = 'groupAt' + this.groupLevel;
  55254. if (group.smask) {
  55255. cacheId += '_smask_' + this.smaskCounter++ % 2;
  55256. }
  55257. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55258. var groupCtx = scratchCanvas.context;
  55259. groupCtx.scale(1 / scaleX, 1 / scaleY);
  55260. groupCtx.translate(-offsetX, -offsetY);
  55261. groupCtx.transform.apply(groupCtx, currentTransform);
  55262. if (group.smask) {
  55263. this.smaskStack.push({
  55264. canvas: scratchCanvas.canvas,
  55265. context: groupCtx,
  55266. offsetX: offsetX,
  55267. offsetY: offsetY,
  55268. scaleX: scaleX,
  55269. scaleY: scaleY,
  55270. subtype: group.smask.subtype,
  55271. backdrop: group.smask.backdrop,
  55272. transferMap: group.smask.transferMap || null,
  55273. startTransformInverse: null
  55274. });
  55275. } else {
  55276. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  55277. currentCtx.translate(offsetX, offsetY);
  55278. currentCtx.scale(scaleX, scaleY);
  55279. }
  55280. copyCtxState(currentCtx, groupCtx);
  55281. this.ctx = groupCtx;
  55282. this.setGState([
  55283. [
  55284. 'BM',
  55285. 'Normal'
  55286. ],
  55287. [
  55288. 'ca',
  55289. 1
  55290. ],
  55291. [
  55292. 'CA',
  55293. 1
  55294. ]
  55295. ]);
  55296. this.groupStack.push(currentCtx);
  55297. this.groupLevel++;
  55298. this.current.activeSMask = null;
  55299. },
  55300. endGroup: function CanvasGraphics_endGroup(group) {
  55301. this.groupLevel--;
  55302. var groupCtx = this.ctx;
  55303. this.ctx = this.groupStack.pop();
  55304. if (this.ctx.imageSmoothingEnabled !== undefined) {
  55305. this.ctx.imageSmoothingEnabled = false;
  55306. } else {
  55307. this.ctx.mozImageSmoothingEnabled = false;
  55308. }
  55309. if (group.smask) {
  55310. this.tempSMask = this.smaskStack.pop();
  55311. } else {
  55312. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  55313. }
  55314. this.restore();
  55315. },
  55316. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  55317. this.save();
  55318. this.current = new CanvasExtraState();
  55319. if (this.baseTransform) {
  55320. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  55321. }
  55322. },
  55323. endAnnotations: function CanvasGraphics_endAnnotations() {
  55324. this.restore();
  55325. },
  55326. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  55327. this.save();
  55328. if (isArray(rect) && rect.length === 4) {
  55329. var width = rect[2] - rect[0];
  55330. var height = rect[3] - rect[1];
  55331. this.ctx.rect(rect[0], rect[1], width, height);
  55332. this.clip();
  55333. this.endPath();
  55334. }
  55335. this.transform.apply(this, transform);
  55336. this.transform.apply(this, matrix);
  55337. },
  55338. endAnnotation: function CanvasGraphics_endAnnotation() {
  55339. this.restore();
  55340. },
  55341. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  55342. var domImage = this.objs.get(objId);
  55343. if (!domImage) {
  55344. warn('Dependent image isn\'t ready yet');
  55345. return;
  55346. }
  55347. this.save();
  55348. var ctx = this.ctx;
  55349. ctx.scale(1 / w, -1 / h);
  55350. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  55351. if (this.imageLayer) {
  55352. var currentTransform = ctx.mozCurrentTransformInverse;
  55353. var position = this.getCanvasPosition(0, 0);
  55354. this.imageLayer.appendImage({
  55355. objId: objId,
  55356. left: position[0],
  55357. top: position[1],
  55358. width: w / currentTransform[0],
  55359. height: h / currentTransform[3]
  55360. });
  55361. }
  55362. this.restore();
  55363. },
  55364. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  55365. var ctx = this.ctx;
  55366. var width = img.width, height = img.height;
  55367. var fillColor = this.current.fillColor;
  55368. var isPatternFill = this.current.patternFill;
  55369. var glyph = this.processingType3;
  55370. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  55371. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  55372. glyph.compiled = compileType3Glyph({
  55373. data: img.data,
  55374. width: width,
  55375. height: height
  55376. });
  55377. } else {
  55378. glyph.compiled = null;
  55379. }
  55380. }
  55381. if (glyph && glyph.compiled) {
  55382. glyph.compiled(ctx);
  55383. return;
  55384. }
  55385. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55386. var maskCtx = maskCanvas.context;
  55387. maskCtx.save();
  55388. putBinaryImageMask(maskCtx, img);
  55389. maskCtx.globalCompositeOperation = 'source-in';
  55390. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55391. maskCtx.fillRect(0, 0, width, height);
  55392. maskCtx.restore();
  55393. this.paintInlineImageXObject(maskCanvas.canvas);
  55394. },
  55395. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  55396. var width = imgData.width;
  55397. var height = imgData.height;
  55398. var fillColor = this.current.fillColor;
  55399. var isPatternFill = this.current.patternFill;
  55400. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55401. var maskCtx = maskCanvas.context;
  55402. maskCtx.save();
  55403. putBinaryImageMask(maskCtx, imgData);
  55404. maskCtx.globalCompositeOperation = 'source-in';
  55405. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55406. maskCtx.fillRect(0, 0, width, height);
  55407. maskCtx.restore();
  55408. var ctx = this.ctx;
  55409. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55410. ctx.save();
  55411. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  55412. ctx.scale(1, -1);
  55413. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55414. ctx.restore();
  55415. }
  55416. },
  55417. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  55418. var ctx = this.ctx;
  55419. var fillColor = this.current.fillColor;
  55420. var isPatternFill = this.current.patternFill;
  55421. for (var i = 0, ii = images.length; i < ii; i++) {
  55422. var image = images[i];
  55423. var width = image.width, height = image.height;
  55424. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55425. var maskCtx = maskCanvas.context;
  55426. maskCtx.save();
  55427. putBinaryImageMask(maskCtx, image);
  55428. maskCtx.globalCompositeOperation = 'source-in';
  55429. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55430. maskCtx.fillRect(0, 0, width, height);
  55431. maskCtx.restore();
  55432. ctx.save();
  55433. ctx.transform.apply(ctx, image.transform);
  55434. ctx.scale(1, -1);
  55435. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55436. ctx.restore();
  55437. }
  55438. },
  55439. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  55440. var imgData = this.objs.get(objId);
  55441. if (!imgData) {
  55442. warn('Dependent image isn\'t ready yet');
  55443. return;
  55444. }
  55445. this.paintInlineImageXObject(imgData);
  55446. },
  55447. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  55448. var imgData = this.objs.get(objId);
  55449. if (!imgData) {
  55450. warn('Dependent image isn\'t ready yet');
  55451. return;
  55452. }
  55453. var width = imgData.width;
  55454. var height = imgData.height;
  55455. var map = [];
  55456. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55457. map.push({
  55458. transform: [
  55459. scaleX,
  55460. 0,
  55461. 0,
  55462. scaleY,
  55463. positions[i],
  55464. positions[i + 1]
  55465. ],
  55466. x: 0,
  55467. y: 0,
  55468. w: width,
  55469. h: height
  55470. });
  55471. }
  55472. this.paintInlineImageXObjectGroup(imgData, map);
  55473. },
  55474. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  55475. var width = imgData.width;
  55476. var height = imgData.height;
  55477. var ctx = this.ctx;
  55478. this.save();
  55479. ctx.scale(1 / width, -1 / height);
  55480. var currentTransform = ctx.mozCurrentTransformInverse;
  55481. var a = currentTransform[0], b = currentTransform[1];
  55482. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  55483. var c = currentTransform[2], d = currentTransform[3];
  55484. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  55485. var imgToPaint, tmpCanvas;
  55486. if (imgData instanceof HTMLElement || !imgData.data) {
  55487. imgToPaint = imgData;
  55488. } else {
  55489. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  55490. var tmpCtx = tmpCanvas.context;
  55491. putBinaryImageData(tmpCtx, imgData);
  55492. imgToPaint = tmpCanvas.canvas;
  55493. }
  55494. var paintWidth = width, paintHeight = height;
  55495. var tmpCanvasId = 'prescale1';
  55496. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  55497. var newWidth = paintWidth, newHeight = paintHeight;
  55498. if (widthScale > 2 && paintWidth > 1) {
  55499. newWidth = Math.ceil(paintWidth / 2);
  55500. widthScale /= paintWidth / newWidth;
  55501. }
  55502. if (heightScale > 2 && paintHeight > 1) {
  55503. newHeight = Math.ceil(paintHeight / 2);
  55504. heightScale /= paintHeight / newHeight;
  55505. }
  55506. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  55507. tmpCtx = tmpCanvas.context;
  55508. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  55509. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  55510. imgToPaint = tmpCanvas.canvas;
  55511. paintWidth = newWidth;
  55512. paintHeight = newHeight;
  55513. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  55514. }
  55515. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  55516. if (this.imageLayer) {
  55517. var position = this.getCanvasPosition(0, -height);
  55518. this.imageLayer.appendImage({
  55519. imgData: imgData,
  55520. left: position[0],
  55521. top: position[1],
  55522. width: width / currentTransform[0],
  55523. height: height / currentTransform[3]
  55524. });
  55525. }
  55526. this.restore();
  55527. },
  55528. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  55529. var ctx = this.ctx;
  55530. var w = imgData.width;
  55531. var h = imgData.height;
  55532. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  55533. var tmpCtx = tmpCanvas.context;
  55534. putBinaryImageData(tmpCtx, imgData);
  55535. for (var i = 0, ii = map.length; i < ii; i++) {
  55536. var entry = map[i];
  55537. ctx.save();
  55538. ctx.transform.apply(ctx, entry.transform);
  55539. ctx.scale(1, -1);
  55540. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  55541. if (this.imageLayer) {
  55542. var position = this.getCanvasPosition(entry.x, entry.y);
  55543. this.imageLayer.appendImage({
  55544. imgData: imgData,
  55545. left: position[0],
  55546. top: position[1],
  55547. width: w,
  55548. height: h
  55549. });
  55550. }
  55551. ctx.restore();
  55552. }
  55553. },
  55554. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  55555. this.ctx.fillRect(0, 0, 1, 1);
  55556. },
  55557. paintXObject: function CanvasGraphics_paintXObject() {
  55558. warn('Unsupported \'paintXObject\' command.');
  55559. },
  55560. markPoint: function CanvasGraphics_markPoint(tag) {
  55561. },
  55562. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  55563. },
  55564. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  55565. },
  55566. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  55567. },
  55568. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  55569. },
  55570. beginCompat: function CanvasGraphics_beginCompat() {
  55571. },
  55572. endCompat: function CanvasGraphics_endCompat() {
  55573. },
  55574. consumePath: function CanvasGraphics_consumePath() {
  55575. var ctx = this.ctx;
  55576. if (this.pendingClip) {
  55577. if (this.pendingClip === EO_CLIP) {
  55578. ctx.clip('evenodd');
  55579. } else {
  55580. ctx.clip();
  55581. }
  55582. this.pendingClip = null;
  55583. }
  55584. ctx.beginPath();
  55585. },
  55586. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  55587. if (this.cachedGetSinglePixelWidth === null) {
  55588. this.ctx.save();
  55589. var inverse = this.ctx.mozCurrentTransformInverse;
  55590. this.ctx.restore();
  55591. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  55592. }
  55593. return this.cachedGetSinglePixelWidth;
  55594. },
  55595. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  55596. var transform = this.ctx.mozCurrentTransform;
  55597. return [
  55598. transform[0] * x + transform[2] * y + transform[4],
  55599. transform[1] * x + transform[3] * y + transform[5]
  55600. ];
  55601. }
  55602. };
  55603. for (var op in OPS) {
  55604. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  55605. }
  55606. return CanvasGraphics;
  55607. }();
  55608. exports.CanvasGraphics = CanvasGraphics;
  55609. /***/ }),
  55610. /* 45 */
  55611. /***/ (function(module, exports, __w_pdfjs_require__) {
  55612. "use strict";
  55613. var sharedUtil = __w_pdfjs_require__(0);
  55614. var assert = sharedUtil.assert;
  55615. var bytesToString = sharedUtil.bytesToString;
  55616. var string32 = sharedUtil.string32;
  55617. var shadow = sharedUtil.shadow;
  55618. var warn = sharedUtil.warn;
  55619. function FontLoader(docId) {
  55620. this.docId = docId;
  55621. this.styleElement = null;
  55622. this.nativeFontFaces = [];
  55623. this.loadTestFontId = 0;
  55624. this.loadingContext = {
  55625. requests: [],
  55626. nextRequestId: 0
  55627. };
  55628. }
  55629. FontLoader.prototype = {
  55630. insertRule: function fontLoaderInsertRule(rule) {
  55631. var styleElement = this.styleElement;
  55632. if (!styleElement) {
  55633. styleElement = this.styleElement = document.createElement('style');
  55634. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  55635. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  55636. }
  55637. var styleSheet = styleElement.sheet;
  55638. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  55639. },
  55640. clear: function fontLoaderClear() {
  55641. if (this.styleElement) {
  55642. this.styleElement.remove();
  55643. this.styleElement = null;
  55644. }
  55645. this.nativeFontFaces.forEach(function (nativeFontFace) {
  55646. document.fonts.delete(nativeFontFace);
  55647. });
  55648. this.nativeFontFaces.length = 0;
  55649. }
  55650. };
  55651. var getLoadTestFont = function () {
  55652. 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==');
  55653. };
  55654. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  55655. get: function () {
  55656. return shadow(this, 'loadTestFont', getLoadTestFont());
  55657. },
  55658. configurable: true
  55659. });
  55660. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  55661. this.nativeFontFaces.push(nativeFontFace);
  55662. document.fonts.add(nativeFontFace);
  55663. };
  55664. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  55665. var rules = [];
  55666. var fontsToLoad = [];
  55667. var fontLoadPromises = [];
  55668. var getNativeFontPromise = function (nativeFontFace) {
  55669. return nativeFontFace.loaded.catch(function (e) {
  55670. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  55671. });
  55672. };
  55673. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  55674. for (var i = 0, ii = fonts.length; i < ii; i++) {
  55675. var font = fonts[i];
  55676. if (font.attached || font.loading === false) {
  55677. continue;
  55678. }
  55679. font.attached = true;
  55680. if (isFontLoadingAPISupported) {
  55681. var nativeFontFace = font.createNativeFontFace();
  55682. if (nativeFontFace) {
  55683. this.addNativeFontFace(nativeFontFace);
  55684. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  55685. }
  55686. } else {
  55687. var rule = font.createFontFaceRule();
  55688. if (rule) {
  55689. this.insertRule(rule);
  55690. rules.push(rule);
  55691. fontsToLoad.push(font);
  55692. }
  55693. }
  55694. }
  55695. var request = this.queueLoadingCallback(callback);
  55696. if (isFontLoadingAPISupported) {
  55697. Promise.all(fontLoadPromises).then(function () {
  55698. request.complete();
  55699. });
  55700. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  55701. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  55702. } else {
  55703. request.complete();
  55704. }
  55705. };
  55706. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  55707. function LoadLoader_completeRequest() {
  55708. assert(!request.end, 'completeRequest() cannot be called twice');
  55709. request.end = Date.now();
  55710. while (context.requests.length > 0 && context.requests[0].end) {
  55711. var otherRequest = context.requests.shift();
  55712. setTimeout(otherRequest.callback, 0);
  55713. }
  55714. }
  55715. var context = this.loadingContext;
  55716. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  55717. var request = {
  55718. id: requestId,
  55719. complete: LoadLoader_completeRequest,
  55720. callback: callback,
  55721. started: Date.now()
  55722. };
  55723. context.requests.push(request);
  55724. return request;
  55725. };
  55726. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  55727. function int32(data, offset) {
  55728. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  55729. }
  55730. function spliceString(s, offset, remove, insert) {
  55731. var chunk1 = s.substr(0, offset);
  55732. var chunk2 = s.substr(offset + remove);
  55733. return chunk1 + insert + chunk2;
  55734. }
  55735. var i, ii;
  55736. var canvas = document.createElement('canvas');
  55737. canvas.width = 1;
  55738. canvas.height = 1;
  55739. var ctx = canvas.getContext('2d');
  55740. var called = 0;
  55741. function isFontReady(name, callback) {
  55742. called++;
  55743. if (called > 30) {
  55744. warn('Load test font never loaded.');
  55745. callback();
  55746. return;
  55747. }
  55748. ctx.font = '30px ' + name;
  55749. ctx.fillText('.', 0, 20);
  55750. var imageData = ctx.getImageData(0, 0, 1, 1);
  55751. if (imageData.data[3] > 0) {
  55752. callback();
  55753. return;
  55754. }
  55755. setTimeout(isFontReady.bind(null, name, callback));
  55756. }
  55757. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  55758. var data = this.loadTestFont;
  55759. var COMMENT_OFFSET = 976;
  55760. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  55761. var CFF_CHECKSUM_OFFSET = 16;
  55762. var XXXX_VALUE = 0x58585858;
  55763. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  55764. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  55765. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  55766. }
  55767. if (i < loadTestFontId.length) {
  55768. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  55769. }
  55770. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  55771. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  55772. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  55773. this.insertRule(rule);
  55774. var names = [];
  55775. for (i = 0, ii = fonts.length; i < ii; i++) {
  55776. names.push(fonts[i].loadedName);
  55777. }
  55778. names.push(loadTestFontId);
  55779. var div = document.createElement('div');
  55780. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  55781. for (i = 0, ii = names.length; i < ii; ++i) {
  55782. var span = document.createElement('span');
  55783. span.textContent = 'Hi';
  55784. span.style.fontFamily = names[i];
  55785. div.appendChild(span);
  55786. }
  55787. document.body.appendChild(div);
  55788. isFontReady(loadTestFontId, function () {
  55789. document.body.removeChild(div);
  55790. request.complete();
  55791. });
  55792. };
  55793. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  55794. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  55795. if (typeof navigator === 'undefined') {
  55796. return true;
  55797. }
  55798. var supported = false;
  55799. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  55800. if (m && m[1] >= 14) {
  55801. supported = true;
  55802. }
  55803. return supported;
  55804. };
  55805. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  55806. get: function () {
  55807. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  55808. },
  55809. enumerable: true,
  55810. configurable: true
  55811. });
  55812. var IsEvalSupportedCached = {
  55813. get value() {
  55814. return shadow(this, 'value', sharedUtil.isEvalSupported());
  55815. }
  55816. };
  55817. var FontFaceObject = function FontFaceObjectClosure() {
  55818. function FontFaceObject(translatedData, options) {
  55819. this.compiledGlyphs = Object.create(null);
  55820. for (var i in translatedData) {
  55821. this[i] = translatedData[i];
  55822. }
  55823. this.options = options;
  55824. }
  55825. FontFaceObject.prototype = {
  55826. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  55827. if (!this.data) {
  55828. return null;
  55829. }
  55830. if (this.options.disableFontFace) {
  55831. this.disableFontFace = true;
  55832. return null;
  55833. }
  55834. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  55835. if (this.options.fontRegistry) {
  55836. this.options.fontRegistry.registerFont(this);
  55837. }
  55838. return nativeFontFace;
  55839. },
  55840. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  55841. if (!this.data) {
  55842. return null;
  55843. }
  55844. if (this.options.disableFontFace) {
  55845. this.disableFontFace = true;
  55846. return null;
  55847. }
  55848. var data = bytesToString(new Uint8Array(this.data));
  55849. var fontName = this.loadedName;
  55850. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  55851. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  55852. if (this.options.fontRegistry) {
  55853. this.options.fontRegistry.registerFont(this, url);
  55854. }
  55855. return rule;
  55856. },
  55857. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  55858. if (!(character in this.compiledGlyphs)) {
  55859. var cmds = objs.get(this.loadedName + '_path_' + character);
  55860. var current, i, len;
  55861. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  55862. var args, js = '';
  55863. for (i = 0, len = cmds.length; i < len; i++) {
  55864. current = cmds[i];
  55865. if (current.args !== undefined) {
  55866. args = current.args.join(',');
  55867. } else {
  55868. args = '';
  55869. }
  55870. js += 'c.' + current.cmd + '(' + args + ');\n';
  55871. }
  55872. this.compiledGlyphs[character] = new Function('c', 'size', js);
  55873. } else {
  55874. this.compiledGlyphs[character] = function (c, size) {
  55875. for (i = 0, len = cmds.length; i < len; i++) {
  55876. current = cmds[i];
  55877. if (current.cmd === 'scale') {
  55878. current.args = [
  55879. size,
  55880. -size
  55881. ];
  55882. }
  55883. c[current.cmd].apply(c, current.args);
  55884. }
  55885. };
  55886. }
  55887. }
  55888. return this.compiledGlyphs[character];
  55889. }
  55890. };
  55891. return FontFaceObject;
  55892. }();
  55893. exports.FontFaceObject = FontFaceObject;
  55894. exports.FontLoader = FontLoader;
  55895. /***/ }),
  55896. /* 46 */
  55897. /***/ (function(module, exports, __w_pdfjs_require__) {
  55898. "use strict";
  55899. var sharedUtil = __w_pdfjs_require__(0);
  55900. var displayWebGL = __w_pdfjs_require__(25);
  55901. var Util = sharedUtil.Util;
  55902. var info = sharedUtil.info;
  55903. var isArray = sharedUtil.isArray;
  55904. var error = sharedUtil.error;
  55905. var WebGLUtils = displayWebGL.WebGLUtils;
  55906. var ShadingIRs = {};
  55907. ShadingIRs.RadialAxial = {
  55908. fromIR: function RadialAxial_fromIR(raw) {
  55909. var type = raw[1];
  55910. var colorStops = raw[2];
  55911. var p0 = raw[3];
  55912. var p1 = raw[4];
  55913. var r0 = raw[5];
  55914. var r1 = raw[6];
  55915. return {
  55916. type: 'Pattern',
  55917. getPattern: function RadialAxial_getPattern(ctx) {
  55918. var grad;
  55919. if (type === 'axial') {
  55920. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  55921. } else if (type === 'radial') {
  55922. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  55923. }
  55924. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  55925. var c = colorStops[i];
  55926. grad.addColorStop(c[0], c[1]);
  55927. }
  55928. return grad;
  55929. }
  55930. };
  55931. }
  55932. };
  55933. var createMeshCanvas = function createMeshCanvasClosure() {
  55934. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  55935. var coords = context.coords, colors = context.colors;
  55936. var bytes = data.data, rowSize = data.width * 4;
  55937. var tmp;
  55938. if (coords[p1 + 1] > coords[p2 + 1]) {
  55939. tmp = p1;
  55940. p1 = p2;
  55941. p2 = tmp;
  55942. tmp = c1;
  55943. c1 = c2;
  55944. c2 = tmp;
  55945. }
  55946. if (coords[p2 + 1] > coords[p3 + 1]) {
  55947. tmp = p2;
  55948. p2 = p3;
  55949. p3 = tmp;
  55950. tmp = c2;
  55951. c2 = c3;
  55952. c3 = tmp;
  55953. }
  55954. if (coords[p1 + 1] > coords[p2 + 1]) {
  55955. tmp = p1;
  55956. p1 = p2;
  55957. p2 = tmp;
  55958. tmp = c1;
  55959. c1 = c2;
  55960. c2 = tmp;
  55961. }
  55962. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  55963. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  55964. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  55965. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  55966. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  55967. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  55968. if (y1 >= y3) {
  55969. return;
  55970. }
  55971. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  55972. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  55973. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  55974. var minY = Math.round(y1), maxY = Math.round(y3);
  55975. var xa, car, cag, cab;
  55976. var xb, cbr, cbg, cbb;
  55977. var k;
  55978. for (var y = minY; y <= maxY; y++) {
  55979. if (y < y2) {
  55980. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  55981. xa = x1 - (x1 - x2) * k;
  55982. car = c1r - (c1r - c2r) * k;
  55983. cag = c1g - (c1g - c2g) * k;
  55984. cab = c1b - (c1b - c2b) * k;
  55985. } else {
  55986. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  55987. xa = x2 - (x2 - x3) * k;
  55988. car = c2r - (c2r - c3r) * k;
  55989. cag = c2g - (c2g - c3g) * k;
  55990. cab = c2b - (c2b - c3b) * k;
  55991. }
  55992. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  55993. xb = x1 - (x1 - x3) * k;
  55994. cbr = c1r - (c1r - c3r) * k;
  55995. cbg = c1g - (c1g - c3g) * k;
  55996. cbb = c1b - (c1b - c3b) * k;
  55997. var x1_ = Math.round(Math.min(xa, xb));
  55998. var x2_ = Math.round(Math.max(xa, xb));
  55999. var j = rowSize * y + x1_ * 4;
  56000. for (var x = x1_; x <= x2_; x++) {
  56001. k = (xa - x) / (xa - xb);
  56002. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56003. bytes[j++] = car - (car - cbr) * k | 0;
  56004. bytes[j++] = cag - (cag - cbg) * k | 0;
  56005. bytes[j++] = cab - (cab - cbb) * k | 0;
  56006. bytes[j++] = 255;
  56007. }
  56008. }
  56009. }
  56010. function drawFigure(data, figure, context) {
  56011. var ps = figure.coords;
  56012. var cs = figure.colors;
  56013. var i, ii;
  56014. switch (figure.type) {
  56015. case 'lattice':
  56016. var verticesPerRow = figure.verticesPerRow;
  56017. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56018. var cols = verticesPerRow - 1;
  56019. for (i = 0; i < rows; i++) {
  56020. var q = i * verticesPerRow;
  56021. for (var j = 0; j < cols; j++, q++) {
  56022. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56023. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56024. }
  56025. }
  56026. break;
  56027. case 'triangles':
  56028. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56029. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56030. }
  56031. break;
  56032. default:
  56033. error('illigal figure');
  56034. break;
  56035. }
  56036. }
  56037. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56038. var EXPECTED_SCALE = 1.1;
  56039. var MAX_PATTERN_SIZE = 3000;
  56040. var BORDER_SIZE = 2;
  56041. var offsetX = Math.floor(bounds[0]);
  56042. var offsetY = Math.floor(bounds[1]);
  56043. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56044. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56045. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56046. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56047. var scaleX = boundsWidth / width;
  56048. var scaleY = boundsHeight / height;
  56049. var context = {
  56050. coords: coords,
  56051. colors: colors,
  56052. offsetX: -offsetX,
  56053. offsetY: -offsetY,
  56054. scaleX: 1 / scaleX,
  56055. scaleY: 1 / scaleY
  56056. };
  56057. var paddedWidth = width + BORDER_SIZE * 2;
  56058. var paddedHeight = height + BORDER_SIZE * 2;
  56059. var canvas, tmpCanvas, i, ii;
  56060. if (WebGLUtils.isEnabled) {
  56061. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56062. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56063. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56064. canvas = tmpCanvas.canvas;
  56065. } else {
  56066. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56067. var tmpCtx = tmpCanvas.context;
  56068. var data = tmpCtx.createImageData(width, height);
  56069. if (backgroundColor) {
  56070. var bytes = data.data;
  56071. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56072. bytes[i] = backgroundColor[0];
  56073. bytes[i + 1] = backgroundColor[1];
  56074. bytes[i + 2] = backgroundColor[2];
  56075. bytes[i + 3] = 255;
  56076. }
  56077. }
  56078. for (i = 0; i < figures.length; i++) {
  56079. drawFigure(data, figures[i], context);
  56080. }
  56081. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56082. canvas = tmpCanvas.canvas;
  56083. }
  56084. return {
  56085. canvas: canvas,
  56086. offsetX: offsetX - BORDER_SIZE * scaleX,
  56087. offsetY: offsetY - BORDER_SIZE * scaleY,
  56088. scaleX: scaleX,
  56089. scaleY: scaleY
  56090. };
  56091. }
  56092. return createMeshCanvas;
  56093. }();
  56094. ShadingIRs.Mesh = {
  56095. fromIR: function Mesh_fromIR(raw) {
  56096. var coords = raw[2];
  56097. var colors = raw[3];
  56098. var figures = raw[4];
  56099. var bounds = raw[5];
  56100. var matrix = raw[6];
  56101. var background = raw[8];
  56102. return {
  56103. type: 'Pattern',
  56104. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56105. var scale;
  56106. if (shadingFill) {
  56107. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56108. } else {
  56109. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56110. if (matrix) {
  56111. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56112. scale = [
  56113. scale[0] * matrixScale[0],
  56114. scale[1] * matrixScale[1]
  56115. ];
  56116. }
  56117. }
  56118. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56119. if (!shadingFill) {
  56120. ctx.setTransform.apply(ctx, owner.baseTransform);
  56121. if (matrix) {
  56122. ctx.transform.apply(ctx, matrix);
  56123. }
  56124. }
  56125. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56126. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56127. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56128. }
  56129. };
  56130. }
  56131. };
  56132. ShadingIRs.Dummy = {
  56133. fromIR: function Dummy_fromIR() {
  56134. return {
  56135. type: 'Pattern',
  56136. getPattern: function Dummy_fromIR_getPattern() {
  56137. return 'hotpink';
  56138. }
  56139. };
  56140. }
  56141. };
  56142. function getShadingPatternFromIR(raw) {
  56143. var shadingIR = ShadingIRs[raw[0]];
  56144. if (!shadingIR) {
  56145. error('Unknown IR type: ' + raw[0]);
  56146. }
  56147. return shadingIR.fromIR(raw);
  56148. }
  56149. var TilingPattern = function TilingPatternClosure() {
  56150. var PaintType = {
  56151. COLORED: 1,
  56152. UNCOLORED: 2
  56153. };
  56154. var MAX_PATTERN_SIZE = 3000;
  56155. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56156. this.operatorList = IR[2];
  56157. this.matrix = IR[3] || [
  56158. 1,
  56159. 0,
  56160. 0,
  56161. 1,
  56162. 0,
  56163. 0
  56164. ];
  56165. this.bbox = IR[4];
  56166. this.xstep = IR[5];
  56167. this.ystep = IR[6];
  56168. this.paintType = IR[7];
  56169. this.tilingType = IR[8];
  56170. this.color = color;
  56171. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56172. this.baseTransform = baseTransform;
  56173. this.type = 'Pattern';
  56174. this.ctx = ctx;
  56175. }
  56176. TilingPattern.prototype = {
  56177. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56178. var operatorList = this.operatorList;
  56179. var bbox = this.bbox;
  56180. var xstep = this.xstep;
  56181. var ystep = this.ystep;
  56182. var paintType = this.paintType;
  56183. var tilingType = this.tilingType;
  56184. var color = this.color;
  56185. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  56186. info('TilingType: ' + tilingType);
  56187. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  56188. var topLeft = [
  56189. x0,
  56190. y0
  56191. ];
  56192. var botRight = [
  56193. x0 + xstep,
  56194. y0 + ystep
  56195. ];
  56196. var width = botRight[0] - topLeft[0];
  56197. var height = botRight[1] - topLeft[1];
  56198. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  56199. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  56200. var combinedScale = [
  56201. matrixScale[0] * curMatrixScale[0],
  56202. matrixScale[1] * curMatrixScale[1]
  56203. ];
  56204. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  56205. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  56206. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  56207. var tmpCtx = tmpCanvas.context;
  56208. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  56209. graphics.groupLevel = owner.groupLevel;
  56210. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  56211. this.setScale(width, height, xstep, ystep);
  56212. this.transformToScale(graphics);
  56213. var tmpTranslate = [
  56214. 1,
  56215. 0,
  56216. 0,
  56217. 1,
  56218. -topLeft[0],
  56219. -topLeft[1]
  56220. ];
  56221. graphics.transform.apply(graphics, tmpTranslate);
  56222. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  56223. graphics.executeOperatorList(operatorList);
  56224. return tmpCanvas.canvas;
  56225. },
  56226. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  56227. this.scale = [
  56228. width / xstep,
  56229. height / ystep
  56230. ];
  56231. },
  56232. transformToScale: function TilingPattern_transformToScale(graphics) {
  56233. var scale = this.scale;
  56234. var tmpScale = [
  56235. scale[0],
  56236. 0,
  56237. 0,
  56238. scale[1],
  56239. 0,
  56240. 0
  56241. ];
  56242. graphics.transform.apply(graphics, tmpScale);
  56243. },
  56244. scaleToContext: function TilingPattern_scaleToContext() {
  56245. var scale = this.scale;
  56246. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  56247. },
  56248. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  56249. if (bbox && isArray(bbox) && bbox.length === 4) {
  56250. var bboxWidth = x1 - x0;
  56251. var bboxHeight = y1 - y0;
  56252. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  56253. graphics.clip();
  56254. graphics.endPath();
  56255. }
  56256. },
  56257. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  56258. switch (paintType) {
  56259. case PaintType.COLORED:
  56260. var ctx = this.ctx;
  56261. context.fillStyle = ctx.fillStyle;
  56262. context.strokeStyle = ctx.strokeStyle;
  56263. break;
  56264. case PaintType.UNCOLORED:
  56265. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  56266. context.fillStyle = cssColor;
  56267. context.strokeStyle = cssColor;
  56268. break;
  56269. default:
  56270. error('Unsupported paint type: ' + paintType);
  56271. }
  56272. },
  56273. getPattern: function TilingPattern_getPattern(ctx, owner) {
  56274. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  56275. ctx = this.ctx;
  56276. ctx.setTransform.apply(ctx, this.baseTransform);
  56277. ctx.transform.apply(ctx, this.matrix);
  56278. this.scaleToContext();
  56279. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  56280. }
  56281. };
  56282. return TilingPattern;
  56283. }();
  56284. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  56285. exports.TilingPattern = TilingPattern;
  56286. /***/ }),
  56287. /* 47 */
  56288. /***/ (function(module, exports, __w_pdfjs_require__) {
  56289. "use strict";
  56290. /* WEBPACK VAR INJECTION */(function(global) {
  56291. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  56292. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  56293. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  56294. var isAndroid = /Android/.test(userAgent);
  56295. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  56296. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  56297. var isChrome = userAgent.indexOf('Chrom') >= 0;
  56298. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  56299. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  56300. var isIE = userAgent.indexOf('Trident') >= 0;
  56301. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  56302. var isOpera = userAgent.indexOf('Opera') >= 0;
  56303. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  56304. var hasDOM = typeof window === 'object' && typeof document === 'object';
  56305. if (typeof PDFJS === 'undefined') {
  56306. globalScope.PDFJS = {};
  56307. }
  56308. PDFJS.compatibilityChecked = true;
  56309. (function checkTypedArrayCompatibility() {
  56310. if (typeof Uint8Array !== 'undefined') {
  56311. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  56312. Uint8Array.prototype.subarray = function subarray(start, end) {
  56313. return new Uint8Array(this.slice(start, end));
  56314. };
  56315. Float32Array.prototype.subarray = function subarray(start, end) {
  56316. return new Float32Array(this.slice(start, end));
  56317. };
  56318. }
  56319. if (typeof Float64Array === 'undefined') {
  56320. globalScope.Float64Array = Float32Array;
  56321. }
  56322. return;
  56323. }
  56324. function subarray(start, end) {
  56325. return new TypedArray(this.slice(start, end));
  56326. }
  56327. function setArrayOffset(array, offset) {
  56328. if (arguments.length < 2) {
  56329. offset = 0;
  56330. }
  56331. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  56332. this[offset] = array[i] & 0xFF;
  56333. }
  56334. }
  56335. function TypedArray(arg1) {
  56336. var result, i, n;
  56337. if (typeof arg1 === 'number') {
  56338. result = [];
  56339. for (i = 0; i < arg1; ++i) {
  56340. result[i] = 0;
  56341. }
  56342. } else if ('slice' in arg1) {
  56343. result = arg1.slice(0);
  56344. } else {
  56345. result = [];
  56346. for (i = 0, n = arg1.length; i < n; ++i) {
  56347. result[i] = arg1[i];
  56348. }
  56349. }
  56350. result.subarray = subarray;
  56351. result.buffer = result;
  56352. result.byteLength = result.length;
  56353. result.set = setArrayOffset;
  56354. if (typeof arg1 === 'object' && arg1.buffer) {
  56355. result.buffer = arg1.buffer;
  56356. }
  56357. return result;
  56358. }
  56359. globalScope.Uint8Array = TypedArray;
  56360. globalScope.Int8Array = TypedArray;
  56361. globalScope.Uint32Array = TypedArray;
  56362. globalScope.Int32Array = TypedArray;
  56363. globalScope.Uint16Array = TypedArray;
  56364. globalScope.Float32Array = TypedArray;
  56365. globalScope.Float64Array = TypedArray;
  56366. }());
  56367. (function normalizeURLObject() {
  56368. if (!globalScope.URL) {
  56369. globalScope.URL = globalScope.webkitURL;
  56370. }
  56371. }());
  56372. (function checkObjectDefinePropertyCompatibility() {
  56373. if (typeof Object.defineProperty !== 'undefined') {
  56374. var definePropertyPossible = true;
  56375. try {
  56376. if (hasDOM) {
  56377. Object.defineProperty(new Image(), 'id', { value: 'test' });
  56378. }
  56379. var Test = function Test() {
  56380. };
  56381. Test.prototype = {
  56382. get id() {
  56383. }
  56384. };
  56385. Object.defineProperty(new Test(), 'id', {
  56386. value: '',
  56387. configurable: true,
  56388. enumerable: true,
  56389. writable: false
  56390. });
  56391. } catch (e) {
  56392. definePropertyPossible = false;
  56393. }
  56394. if (definePropertyPossible) {
  56395. return;
  56396. }
  56397. }
  56398. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  56399. delete obj[name];
  56400. if ('get' in def) {
  56401. obj.__defineGetter__(name, def['get']);
  56402. }
  56403. if ('set' in def) {
  56404. obj.__defineSetter__(name, def['set']);
  56405. }
  56406. if ('value' in def) {
  56407. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  56408. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  56409. return value;
  56410. });
  56411. return value;
  56412. });
  56413. obj[name] = def.value;
  56414. }
  56415. };
  56416. }());
  56417. (function checkXMLHttpRequestResponseCompatibility() {
  56418. if (typeof XMLHttpRequest === 'undefined') {
  56419. return;
  56420. }
  56421. var xhrPrototype = XMLHttpRequest.prototype;
  56422. var xhr = new XMLHttpRequest();
  56423. if (!('overrideMimeType' in xhr)) {
  56424. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  56425. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  56426. }
  56427. });
  56428. }
  56429. if ('responseType' in xhr) {
  56430. return;
  56431. }
  56432. Object.defineProperty(xhrPrototype, 'responseType', {
  56433. get: function xmlHttpRequestGetResponseType() {
  56434. return this._responseType || 'text';
  56435. },
  56436. set: function xmlHttpRequestSetResponseType(value) {
  56437. if (value === 'text' || value === 'arraybuffer') {
  56438. this._responseType = value;
  56439. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  56440. this.overrideMimeType('text/plain; charset=x-user-defined');
  56441. }
  56442. }
  56443. }
  56444. });
  56445. if (typeof VBArray !== 'undefined') {
  56446. Object.defineProperty(xhrPrototype, 'response', {
  56447. get: function xmlHttpRequestResponseGet() {
  56448. if (this.responseType === 'arraybuffer') {
  56449. return new Uint8Array(new VBArray(this.responseBody).toArray());
  56450. }
  56451. return this.responseText;
  56452. }
  56453. });
  56454. return;
  56455. }
  56456. Object.defineProperty(xhrPrototype, 'response', {
  56457. get: function xmlHttpRequestResponseGet() {
  56458. if (this.responseType !== 'arraybuffer') {
  56459. return this.responseText;
  56460. }
  56461. var text = this.responseText;
  56462. var i, n = text.length;
  56463. var result = new Uint8Array(n);
  56464. for (i = 0; i < n; ++i) {
  56465. result[i] = text.charCodeAt(i) & 0xFF;
  56466. }
  56467. return result.buffer;
  56468. }
  56469. });
  56470. }());
  56471. (function checkWindowBtoaCompatibility() {
  56472. if ('btoa' in globalScope) {
  56473. return;
  56474. }
  56475. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56476. globalScope.btoa = function (chars) {
  56477. var buffer = '';
  56478. var i, n;
  56479. for (i = 0, n = chars.length; i < n; i += 3) {
  56480. var b1 = chars.charCodeAt(i) & 0xFF;
  56481. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  56482. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  56483. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  56484. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  56485. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  56486. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  56487. }
  56488. return buffer;
  56489. };
  56490. }());
  56491. (function checkWindowAtobCompatibility() {
  56492. if ('atob' in globalScope) {
  56493. return;
  56494. }
  56495. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56496. globalScope.atob = function (input) {
  56497. input = input.replace(/=+$/, '');
  56498. if (input.length % 4 === 1) {
  56499. throw new Error('bad atob input');
  56500. }
  56501. 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) {
  56502. buffer = digits.indexOf(buffer);
  56503. }
  56504. return output;
  56505. };
  56506. }());
  56507. (function checkFunctionPrototypeBindCompatibility() {
  56508. if (typeof Function.prototype.bind !== 'undefined') {
  56509. return;
  56510. }
  56511. Function.prototype.bind = function functionPrototypeBind(obj) {
  56512. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  56513. var bound = function functionPrototypeBindBound() {
  56514. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  56515. return fn.apply(obj, args);
  56516. };
  56517. return bound;
  56518. };
  56519. }());
  56520. (function checkDatasetProperty() {
  56521. if (!hasDOM) {
  56522. return;
  56523. }
  56524. var div = document.createElement('div');
  56525. if ('dataset' in div) {
  56526. return;
  56527. }
  56528. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  56529. get: function () {
  56530. if (this._dataset) {
  56531. return this._dataset;
  56532. }
  56533. var dataset = {};
  56534. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  56535. var attribute = this.attributes[j];
  56536. if (attribute.name.substring(0, 5) !== 'data-') {
  56537. continue;
  56538. }
  56539. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  56540. return ch.toUpperCase();
  56541. });
  56542. dataset[key] = attribute.value;
  56543. }
  56544. Object.defineProperty(this, '_dataset', {
  56545. value: dataset,
  56546. writable: false,
  56547. enumerable: false
  56548. });
  56549. return dataset;
  56550. },
  56551. enumerable: true
  56552. });
  56553. }());
  56554. (function checkClassListProperty() {
  56555. function changeList(element, itemName, add, remove) {
  56556. var s = element.className || '';
  56557. var list = s.split(/\s+/g);
  56558. if (list[0] === '') {
  56559. list.shift();
  56560. }
  56561. var index = list.indexOf(itemName);
  56562. if (index < 0 && add) {
  56563. list.push(itemName);
  56564. }
  56565. if (index >= 0 && remove) {
  56566. list.splice(index, 1);
  56567. }
  56568. element.className = list.join(' ');
  56569. return index >= 0;
  56570. }
  56571. if (!hasDOM) {
  56572. return;
  56573. }
  56574. var div = document.createElement('div');
  56575. if ('classList' in div) {
  56576. return;
  56577. }
  56578. var classListPrototype = {
  56579. add: function (name) {
  56580. changeList(this.element, name, true, false);
  56581. },
  56582. contains: function (name) {
  56583. return changeList(this.element, name, false, false);
  56584. },
  56585. remove: function (name) {
  56586. changeList(this.element, name, false, true);
  56587. },
  56588. toggle: function (name) {
  56589. changeList(this.element, name, true, true);
  56590. }
  56591. };
  56592. Object.defineProperty(HTMLElement.prototype, 'classList', {
  56593. get: function () {
  56594. if (this._classList) {
  56595. return this._classList;
  56596. }
  56597. var classList = Object.create(classListPrototype, {
  56598. element: {
  56599. value: this,
  56600. writable: false,
  56601. enumerable: true
  56602. }
  56603. });
  56604. Object.defineProperty(this, '_classList', {
  56605. value: classList,
  56606. writable: false,
  56607. enumerable: false
  56608. });
  56609. return classList;
  56610. },
  56611. enumerable: true
  56612. });
  56613. }());
  56614. (function checkWorkerConsoleCompatibility() {
  56615. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  56616. return;
  56617. }
  56618. var consoleTimer = {};
  56619. var workerConsole = {
  56620. log: function log() {
  56621. var args = Array.prototype.slice.call(arguments);
  56622. globalScope.postMessage({
  56623. targetName: 'main',
  56624. action: 'console_log',
  56625. data: args
  56626. });
  56627. },
  56628. error: function error() {
  56629. var args = Array.prototype.slice.call(arguments);
  56630. globalScope.postMessage({
  56631. targetName: 'main',
  56632. action: 'console_error',
  56633. data: args
  56634. });
  56635. },
  56636. time: function time(name) {
  56637. consoleTimer[name] = Date.now();
  56638. },
  56639. timeEnd: function timeEnd(name) {
  56640. var time = consoleTimer[name];
  56641. if (!time) {
  56642. throw new Error('Unknown timer name ' + name);
  56643. }
  56644. this.log('Timer:', name, Date.now() - time);
  56645. }
  56646. };
  56647. globalScope.console = workerConsole;
  56648. }());
  56649. (function checkConsoleCompatibility() {
  56650. if (!hasDOM) {
  56651. return;
  56652. }
  56653. if (!('console' in window)) {
  56654. window.console = {
  56655. log: function () {
  56656. },
  56657. error: function () {
  56658. },
  56659. warn: function () {
  56660. }
  56661. };
  56662. return;
  56663. }
  56664. if (!('bind' in console.log)) {
  56665. console.log = function (fn) {
  56666. return function (msg) {
  56667. return fn(msg);
  56668. };
  56669. }(console.log);
  56670. console.error = function (fn) {
  56671. return function (msg) {
  56672. return fn(msg);
  56673. };
  56674. }(console.error);
  56675. console.warn = function (fn) {
  56676. return function (msg) {
  56677. return fn(msg);
  56678. };
  56679. }(console.warn);
  56680. return;
  56681. }
  56682. }());
  56683. (function checkOnClickCompatibility() {
  56684. function ignoreIfTargetDisabled(event) {
  56685. if (isDisabled(event.target)) {
  56686. event.stopPropagation();
  56687. }
  56688. }
  56689. function isDisabled(node) {
  56690. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  56691. }
  56692. if (isOpera) {
  56693. document.addEventListener('click', ignoreIfTargetDisabled, true);
  56694. }
  56695. }());
  56696. (function checkOnBlobSupport() {
  56697. if (isIE || isIOSChrome) {
  56698. PDFJS.disableCreateObjectURL = true;
  56699. }
  56700. }());
  56701. (function checkNavigatorLanguage() {
  56702. if (typeof navigator === 'undefined') {
  56703. return;
  56704. }
  56705. if ('language' in navigator) {
  56706. return;
  56707. }
  56708. PDFJS.locale = navigator.userLanguage || 'en-US';
  56709. }());
  56710. (function checkRangeRequests() {
  56711. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  56712. PDFJS.disableRange = true;
  56713. PDFJS.disableStream = true;
  56714. }
  56715. }());
  56716. (function checkHistoryManipulation() {
  56717. if (!hasDOM) {
  56718. return;
  56719. }
  56720. if (!history.pushState || isAndroidPre3) {
  56721. PDFJS.disableHistory = true;
  56722. }
  56723. }());
  56724. (function checkSetPresenceInImageData() {
  56725. if (!hasDOM) {
  56726. return;
  56727. }
  56728. if (window.CanvasPixelArray) {
  56729. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  56730. window.CanvasPixelArray.prototype.set = function (arr) {
  56731. for (var i = 0, ii = this.length; i < ii; i++) {
  56732. this[i] = arr[i];
  56733. }
  56734. };
  56735. }
  56736. } else {
  56737. var polyfill = false, versionMatch;
  56738. if (isChrome) {
  56739. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  56740. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  56741. } else if (isAndroid) {
  56742. polyfill = isAndroidPre5;
  56743. } else if (isSafari) {
  56744. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  56745. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  56746. }
  56747. if (polyfill) {
  56748. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  56749. var createImageData = contextPrototype.createImageData;
  56750. contextPrototype.createImageData = function (w, h) {
  56751. var imageData = createImageData.call(this, w, h);
  56752. imageData.data.set = function (arr) {
  56753. for (var i = 0, ii = this.length; i < ii; i++) {
  56754. this[i] = arr[i];
  56755. }
  56756. };
  56757. return imageData;
  56758. };
  56759. contextPrototype = null;
  56760. }
  56761. }
  56762. }());
  56763. (function checkRequestAnimationFrame() {
  56764. function fakeRequestAnimationFrame(callback) {
  56765. window.setTimeout(callback, 20);
  56766. }
  56767. if (!hasDOM) {
  56768. return;
  56769. }
  56770. if (isIOS) {
  56771. window.requestAnimationFrame = fakeRequestAnimationFrame;
  56772. return;
  56773. }
  56774. if ('requestAnimationFrame' in window) {
  56775. return;
  56776. }
  56777. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  56778. }());
  56779. (function checkCanvasSizeLimitation() {
  56780. if (isIOS || isAndroid) {
  56781. PDFJS.maxCanvasPixels = 5242880;
  56782. }
  56783. }());
  56784. (function checkFullscreenSupport() {
  56785. if (!hasDOM) {
  56786. return;
  56787. }
  56788. if (isIE && window.parent !== window) {
  56789. PDFJS.disableFullscreen = true;
  56790. }
  56791. }());
  56792. (function checkCurrentScript() {
  56793. if (!hasDOM) {
  56794. return;
  56795. }
  56796. if ('currentScript' in document) {
  56797. return;
  56798. }
  56799. Object.defineProperty(document, 'currentScript', {
  56800. get: function () {
  56801. var scripts = document.getElementsByTagName('script');
  56802. return scripts[scripts.length - 1];
  56803. },
  56804. enumerable: true,
  56805. configurable: true
  56806. });
  56807. }());
  56808. (function checkInputTypeNumberAssign() {
  56809. if (!hasDOM) {
  56810. return;
  56811. }
  56812. var el = document.createElement('input');
  56813. try {
  56814. el.type = 'number';
  56815. } catch (ex) {
  56816. var inputProto = el.constructor.prototype;
  56817. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  56818. Object.defineProperty(inputProto, 'type', {
  56819. get: function () {
  56820. return typeProperty.get.call(this);
  56821. },
  56822. set: function (value) {
  56823. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  56824. },
  56825. enumerable: true,
  56826. configurable: true
  56827. });
  56828. }
  56829. }());
  56830. (function checkDocumentReadyState() {
  56831. if (!hasDOM) {
  56832. return;
  56833. }
  56834. if (!document.attachEvent) {
  56835. return;
  56836. }
  56837. var documentProto = document.constructor.prototype;
  56838. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  56839. Object.defineProperty(documentProto, 'readyState', {
  56840. get: function () {
  56841. var value = readyStateProto.get.call(this);
  56842. return value === 'interactive' ? 'loading' : value;
  56843. },
  56844. set: function (value) {
  56845. readyStateProto.set.call(this, value);
  56846. },
  56847. enumerable: true,
  56848. configurable: true
  56849. });
  56850. }());
  56851. (function checkChildNodeRemove() {
  56852. if (!hasDOM) {
  56853. return;
  56854. }
  56855. if (typeof Element.prototype.remove !== 'undefined') {
  56856. return;
  56857. }
  56858. Element.prototype.remove = function () {
  56859. if (this.parentNode) {
  56860. this.parentNode.removeChild(this);
  56861. }
  56862. };
  56863. }());
  56864. (function checkPromise() {
  56865. if (globalScope.Promise) {
  56866. if (typeof globalScope.Promise.all !== 'function') {
  56867. globalScope.Promise.all = function (iterable) {
  56868. var count = 0, results = [], resolve, reject;
  56869. var promise = new globalScope.Promise(function (resolve_, reject_) {
  56870. resolve = resolve_;
  56871. reject = reject_;
  56872. });
  56873. iterable.forEach(function (p, i) {
  56874. count++;
  56875. p.then(function (result) {
  56876. results[i] = result;
  56877. count--;
  56878. if (count === 0) {
  56879. resolve(results);
  56880. }
  56881. }, reject);
  56882. });
  56883. if (count === 0) {
  56884. resolve(results);
  56885. }
  56886. return promise;
  56887. };
  56888. }
  56889. if (typeof globalScope.Promise.resolve !== 'function') {
  56890. globalScope.Promise.resolve = function (value) {
  56891. return new globalScope.Promise(function (resolve) {
  56892. resolve(value);
  56893. });
  56894. };
  56895. }
  56896. if (typeof globalScope.Promise.reject !== 'function') {
  56897. globalScope.Promise.reject = function (reason) {
  56898. return new globalScope.Promise(function (resolve, reject) {
  56899. reject(reason);
  56900. });
  56901. };
  56902. }
  56903. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  56904. globalScope.Promise.prototype.catch = function (onReject) {
  56905. return globalScope.Promise.prototype.then(undefined, onReject);
  56906. };
  56907. }
  56908. return;
  56909. }
  56910. var STATUS_PENDING = 0;
  56911. var STATUS_RESOLVED = 1;
  56912. var STATUS_REJECTED = 2;
  56913. var REJECTION_TIMEOUT = 500;
  56914. var HandlerManager = {
  56915. handlers: [],
  56916. running: false,
  56917. unhandledRejections: [],
  56918. pendingRejectionCheck: false,
  56919. scheduleHandlers: function scheduleHandlers(promise) {
  56920. if (promise._status === STATUS_PENDING) {
  56921. return;
  56922. }
  56923. this.handlers = this.handlers.concat(promise._handlers);
  56924. promise._handlers = [];
  56925. if (this.running) {
  56926. return;
  56927. }
  56928. this.running = true;
  56929. setTimeout(this.runHandlers.bind(this), 0);
  56930. },
  56931. runHandlers: function runHandlers() {
  56932. var RUN_TIMEOUT = 1;
  56933. var timeoutAt = Date.now() + RUN_TIMEOUT;
  56934. while (this.handlers.length > 0) {
  56935. var handler = this.handlers.shift();
  56936. var nextStatus = handler.thisPromise._status;
  56937. var nextValue = handler.thisPromise._value;
  56938. try {
  56939. if (nextStatus === STATUS_RESOLVED) {
  56940. if (typeof handler.onResolve === 'function') {
  56941. nextValue = handler.onResolve(nextValue);
  56942. }
  56943. } else if (typeof handler.onReject === 'function') {
  56944. nextValue = handler.onReject(nextValue);
  56945. nextStatus = STATUS_RESOLVED;
  56946. if (handler.thisPromise._unhandledRejection) {
  56947. this.removeUnhandeledRejection(handler.thisPromise);
  56948. }
  56949. }
  56950. } catch (ex) {
  56951. nextStatus = STATUS_REJECTED;
  56952. nextValue = ex;
  56953. }
  56954. handler.nextPromise._updateStatus(nextStatus, nextValue);
  56955. if (Date.now() >= timeoutAt) {
  56956. break;
  56957. }
  56958. }
  56959. if (this.handlers.length > 0) {
  56960. setTimeout(this.runHandlers.bind(this), 0);
  56961. return;
  56962. }
  56963. this.running = false;
  56964. },
  56965. addUnhandledRejection: function addUnhandledRejection(promise) {
  56966. this.unhandledRejections.push({
  56967. promise: promise,
  56968. time: Date.now()
  56969. });
  56970. this.scheduleRejectionCheck();
  56971. },
  56972. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  56973. promise._unhandledRejection = false;
  56974. for (var i = 0; i < this.unhandledRejections.length; i++) {
  56975. if (this.unhandledRejections[i].promise === promise) {
  56976. this.unhandledRejections.splice(i);
  56977. i--;
  56978. }
  56979. }
  56980. },
  56981. scheduleRejectionCheck: function scheduleRejectionCheck() {
  56982. if (this.pendingRejectionCheck) {
  56983. return;
  56984. }
  56985. this.pendingRejectionCheck = true;
  56986. setTimeout(function rejectionCheck() {
  56987. this.pendingRejectionCheck = false;
  56988. var now = Date.now();
  56989. for (var i = 0; i < this.unhandledRejections.length; i++) {
  56990. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  56991. var unhandled = this.unhandledRejections[i].promise._value;
  56992. var msg = 'Unhandled rejection: ' + unhandled;
  56993. if (unhandled.stack) {
  56994. msg += '\n' + unhandled.stack;
  56995. }
  56996. try {
  56997. throw new Error(msg);
  56998. } catch (_) {
  56999. console.warn(msg);
  57000. }
  57001. this.unhandledRejections.splice(i);
  57002. i--;
  57003. }
  57004. }
  57005. if (this.unhandledRejections.length) {
  57006. this.scheduleRejectionCheck();
  57007. }
  57008. }.bind(this), REJECTION_TIMEOUT);
  57009. }
  57010. };
  57011. var Promise = function Promise(resolver) {
  57012. this._status = STATUS_PENDING;
  57013. this._handlers = [];
  57014. try {
  57015. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  57016. } catch (e) {
  57017. this._reject(e);
  57018. }
  57019. };
  57020. Promise.all = function Promise_all(promises) {
  57021. var resolveAll, rejectAll;
  57022. var deferred = new Promise(function (resolve, reject) {
  57023. resolveAll = resolve;
  57024. rejectAll = reject;
  57025. });
  57026. var unresolved = promises.length;
  57027. var results = [];
  57028. if (unresolved === 0) {
  57029. resolveAll(results);
  57030. return deferred;
  57031. }
  57032. function reject(reason) {
  57033. if (deferred._status === STATUS_REJECTED) {
  57034. return;
  57035. }
  57036. results = [];
  57037. rejectAll(reason);
  57038. }
  57039. for (var i = 0, ii = promises.length; i < ii; ++i) {
  57040. var promise = promises[i];
  57041. var resolve = function (i) {
  57042. return function (value) {
  57043. if (deferred._status === STATUS_REJECTED) {
  57044. return;
  57045. }
  57046. results[i] = value;
  57047. unresolved--;
  57048. if (unresolved === 0) {
  57049. resolveAll(results);
  57050. }
  57051. };
  57052. }(i);
  57053. if (Promise.isPromise(promise)) {
  57054. promise.then(resolve, reject);
  57055. } else {
  57056. resolve(promise);
  57057. }
  57058. }
  57059. return deferred;
  57060. };
  57061. Promise.isPromise = function Promise_isPromise(value) {
  57062. return value && typeof value.then === 'function';
  57063. };
  57064. Promise.resolve = function Promise_resolve(value) {
  57065. return new Promise(function (resolve) {
  57066. resolve(value);
  57067. });
  57068. };
  57069. Promise.reject = function Promise_reject(reason) {
  57070. return new Promise(function (resolve, reject) {
  57071. reject(reason);
  57072. });
  57073. };
  57074. Promise.prototype = {
  57075. _status: null,
  57076. _value: null,
  57077. _handlers: null,
  57078. _unhandledRejection: null,
  57079. _updateStatus: function Promise__updateStatus(status, value) {
  57080. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  57081. return;
  57082. }
  57083. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  57084. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  57085. return;
  57086. }
  57087. this._status = status;
  57088. this._value = value;
  57089. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  57090. this._unhandledRejection = true;
  57091. HandlerManager.addUnhandledRejection(this);
  57092. }
  57093. HandlerManager.scheduleHandlers(this);
  57094. },
  57095. _resolve: function Promise_resolve(value) {
  57096. this._updateStatus(STATUS_RESOLVED, value);
  57097. },
  57098. _reject: function Promise_reject(reason) {
  57099. this._updateStatus(STATUS_REJECTED, reason);
  57100. },
  57101. then: function Promise_then(onResolve, onReject) {
  57102. var nextPromise = new Promise(function (resolve, reject) {
  57103. this.resolve = resolve;
  57104. this.reject = reject;
  57105. });
  57106. this._handlers.push({
  57107. thisPromise: this,
  57108. onResolve: onResolve,
  57109. onReject: onReject,
  57110. nextPromise: nextPromise
  57111. });
  57112. HandlerManager.scheduleHandlers(this);
  57113. return nextPromise;
  57114. },
  57115. catch: function Promise_catch(onReject) {
  57116. return this.then(undefined, onReject);
  57117. }
  57118. };
  57119. globalScope.Promise = Promise;
  57120. }());
  57121. (function checkWeakMap() {
  57122. if (globalScope.WeakMap) {
  57123. return;
  57124. }
  57125. var id = 0;
  57126. function WeakMap() {
  57127. this.id = '$weakmap' + id++;
  57128. }
  57129. WeakMap.prototype = {
  57130. has: function (obj) {
  57131. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  57132. },
  57133. get: function (obj, defaultValue) {
  57134. return this.has(obj) ? obj[this.id] : defaultValue;
  57135. },
  57136. set: function (obj, value) {
  57137. Object.defineProperty(obj, this.id, {
  57138. value: value,
  57139. enumerable: false,
  57140. configurable: true
  57141. });
  57142. },
  57143. delete: function (obj) {
  57144. delete obj[this.id];
  57145. }
  57146. };
  57147. globalScope.WeakMap = WeakMap;
  57148. }());
  57149. (function checkURLConstructor() {
  57150. var hasWorkingUrl = false;
  57151. try {
  57152. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  57153. var u = new URL('b', 'http://a');
  57154. u.pathname = 'c%20d';
  57155. hasWorkingUrl = u.href === 'http://a/c%20d';
  57156. }
  57157. } catch (e) {
  57158. }
  57159. if (hasWorkingUrl) {
  57160. return;
  57161. }
  57162. var relative = Object.create(null);
  57163. relative['ftp'] = 21;
  57164. relative['file'] = 0;
  57165. relative['gopher'] = 70;
  57166. relative['http'] = 80;
  57167. relative['https'] = 443;
  57168. relative['ws'] = 80;
  57169. relative['wss'] = 443;
  57170. var relativePathDotMapping = Object.create(null);
  57171. relativePathDotMapping['%2e'] = '.';
  57172. relativePathDotMapping['.%2e'] = '..';
  57173. relativePathDotMapping['%2e.'] = '..';
  57174. relativePathDotMapping['%2e%2e'] = '..';
  57175. function isRelativeScheme(scheme) {
  57176. return relative[scheme] !== undefined;
  57177. }
  57178. function invalid() {
  57179. clear.call(this);
  57180. this._isInvalid = true;
  57181. }
  57182. function IDNAToASCII(h) {
  57183. if (h === '') {
  57184. invalid.call(this);
  57185. }
  57186. return h.toLowerCase();
  57187. }
  57188. function percentEscape(c) {
  57189. var unicode = c.charCodeAt(0);
  57190. if (unicode > 0x20 && unicode < 0x7F && [
  57191. 0x22,
  57192. 0x23,
  57193. 0x3C,
  57194. 0x3E,
  57195. 0x3F,
  57196. 0x60
  57197. ].indexOf(unicode) === -1) {
  57198. return c;
  57199. }
  57200. return encodeURIComponent(c);
  57201. }
  57202. function percentEscapeQuery(c) {
  57203. var unicode = c.charCodeAt(0);
  57204. if (unicode > 0x20 && unicode < 0x7F && [
  57205. 0x22,
  57206. 0x23,
  57207. 0x3C,
  57208. 0x3E,
  57209. 0x60
  57210. ].indexOf(unicode) === -1) {
  57211. return c;
  57212. }
  57213. return encodeURIComponent(c);
  57214. }
  57215. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  57216. function parse(input, stateOverride, base) {
  57217. function err(message) {
  57218. errors.push(message);
  57219. }
  57220. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  57221. loop:
  57222. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  57223. var c = input[cursor];
  57224. switch (state) {
  57225. case 'scheme start':
  57226. if (c && ALPHA.test(c)) {
  57227. buffer += c.toLowerCase();
  57228. state = 'scheme';
  57229. } else if (!stateOverride) {
  57230. buffer = '';
  57231. state = 'no scheme';
  57232. continue;
  57233. } else {
  57234. err('Invalid scheme.');
  57235. break loop;
  57236. }
  57237. break;
  57238. case 'scheme':
  57239. if (c && ALPHANUMERIC.test(c)) {
  57240. buffer += c.toLowerCase();
  57241. } else if (c === ':') {
  57242. this._scheme = buffer;
  57243. buffer = '';
  57244. if (stateOverride) {
  57245. break loop;
  57246. }
  57247. if (isRelativeScheme(this._scheme)) {
  57248. this._isRelative = true;
  57249. }
  57250. if (this._scheme === 'file') {
  57251. state = 'relative';
  57252. } else if (this._isRelative && base && base._scheme === this._scheme) {
  57253. state = 'relative or authority';
  57254. } else if (this._isRelative) {
  57255. state = 'authority first slash';
  57256. } else {
  57257. state = 'scheme data';
  57258. }
  57259. } else if (!stateOverride) {
  57260. buffer = '';
  57261. cursor = 0;
  57262. state = 'no scheme';
  57263. continue;
  57264. } else if (EOF === c) {
  57265. break loop;
  57266. } else {
  57267. err('Code point not allowed in scheme: ' + c);
  57268. break loop;
  57269. }
  57270. break;
  57271. case 'scheme data':
  57272. if (c === '?') {
  57273. this._query = '?';
  57274. state = 'query';
  57275. } else if (c === '#') {
  57276. this._fragment = '#';
  57277. state = 'fragment';
  57278. } else {
  57279. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57280. this._schemeData += percentEscape(c);
  57281. }
  57282. }
  57283. break;
  57284. case 'no scheme':
  57285. if (!base || !isRelativeScheme(base._scheme)) {
  57286. err('Missing scheme.');
  57287. invalid.call(this);
  57288. } else {
  57289. state = 'relative';
  57290. continue;
  57291. }
  57292. break;
  57293. case 'relative or authority':
  57294. if (c === '/' && input[cursor + 1] === '/') {
  57295. state = 'authority ignore slashes';
  57296. } else {
  57297. err('Expected /, got: ' + c);
  57298. state = 'relative';
  57299. continue;
  57300. }
  57301. break;
  57302. case 'relative':
  57303. this._isRelative = true;
  57304. if ('file' !== this._scheme) {
  57305. this._scheme = base._scheme;
  57306. }
  57307. if (EOF === c) {
  57308. this._host = base._host;
  57309. this._port = base._port;
  57310. this._path = base._path.slice();
  57311. this._query = base._query;
  57312. this._username = base._username;
  57313. this._password = base._password;
  57314. break loop;
  57315. } else if (c === '/' || c === '\\') {
  57316. if (c === '\\') {
  57317. err('\\ is an invalid code point.');
  57318. }
  57319. state = 'relative slash';
  57320. } else if (c === '?') {
  57321. this._host = base._host;
  57322. this._port = base._port;
  57323. this._path = base._path.slice();
  57324. this._query = '?';
  57325. this._username = base._username;
  57326. this._password = base._password;
  57327. state = 'query';
  57328. } else if (c === '#') {
  57329. this._host = base._host;
  57330. this._port = base._port;
  57331. this._path = base._path.slice();
  57332. this._query = base._query;
  57333. this._fragment = '#';
  57334. this._username = base._username;
  57335. this._password = base._password;
  57336. state = 'fragment';
  57337. } else {
  57338. var nextC = input[cursor + 1];
  57339. var nextNextC = input[cursor + 2];
  57340. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  57341. this._host = base._host;
  57342. this._port = base._port;
  57343. this._username = base._username;
  57344. this._password = base._password;
  57345. this._path = base._path.slice();
  57346. this._path.pop();
  57347. }
  57348. state = 'relative path';
  57349. continue;
  57350. }
  57351. break;
  57352. case 'relative slash':
  57353. if (c === '/' || c === '\\') {
  57354. if (c === '\\') {
  57355. err('\\ is an invalid code point.');
  57356. }
  57357. if (this._scheme === 'file') {
  57358. state = 'file host';
  57359. } else {
  57360. state = 'authority ignore slashes';
  57361. }
  57362. } else {
  57363. if ('file' !== this._scheme) {
  57364. this._host = base._host;
  57365. this._port = base._port;
  57366. this._username = base._username;
  57367. this._password = base._password;
  57368. }
  57369. state = 'relative path';
  57370. continue;
  57371. }
  57372. break;
  57373. case 'authority first slash':
  57374. if (c === '/') {
  57375. state = 'authority second slash';
  57376. } else {
  57377. err('Expected \'/\', got: ' + c);
  57378. state = 'authority ignore slashes';
  57379. continue;
  57380. }
  57381. break;
  57382. case 'authority second slash':
  57383. state = 'authority ignore slashes';
  57384. if ('/' !== c) {
  57385. err('Expected \'/\', got: ' + c);
  57386. continue;
  57387. }
  57388. break;
  57389. case 'authority ignore slashes':
  57390. if ('/' !== c && '\\' !== c) {
  57391. state = 'authority';
  57392. continue;
  57393. } else {
  57394. err('Expected authority, got: ' + c);
  57395. }
  57396. break;
  57397. case 'authority':
  57398. if (c === '@') {
  57399. if (seenAt) {
  57400. err('@ already seen.');
  57401. buffer += '%40';
  57402. }
  57403. seenAt = true;
  57404. for (var i = 0; i < buffer.length; i++) {
  57405. var cp = buffer[i];
  57406. if (cp === '\t' || cp === '\n' || cp === '\r') {
  57407. err('Invalid whitespace in authority.');
  57408. continue;
  57409. }
  57410. if (cp === ':' && this._password === null) {
  57411. this._password = '';
  57412. continue;
  57413. }
  57414. var tempC = percentEscape(cp);
  57415. if (null !== this._password) {
  57416. this._password += tempC;
  57417. } else {
  57418. this._username += tempC;
  57419. }
  57420. }
  57421. buffer = '';
  57422. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57423. cursor -= buffer.length;
  57424. buffer = '';
  57425. state = 'host';
  57426. continue;
  57427. } else {
  57428. buffer += c;
  57429. }
  57430. break;
  57431. case 'file host':
  57432. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57433. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  57434. state = 'relative path';
  57435. } else if (buffer.length === 0) {
  57436. state = 'relative path start';
  57437. } else {
  57438. this._host = IDNAToASCII.call(this, buffer);
  57439. buffer = '';
  57440. state = 'relative path start';
  57441. }
  57442. continue;
  57443. } else if (c === '\t' || c === '\n' || c === '\r') {
  57444. err('Invalid whitespace in file host.');
  57445. } else {
  57446. buffer += c;
  57447. }
  57448. break;
  57449. case 'host':
  57450. case 'hostname':
  57451. if (c === ':' && !seenBracket) {
  57452. this._host = IDNAToASCII.call(this, buffer);
  57453. buffer = '';
  57454. state = 'port';
  57455. if (stateOverride === 'hostname') {
  57456. break loop;
  57457. }
  57458. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57459. this._host = IDNAToASCII.call(this, buffer);
  57460. buffer = '';
  57461. state = 'relative path start';
  57462. if (stateOverride) {
  57463. break loop;
  57464. }
  57465. continue;
  57466. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57467. if (c === '[') {
  57468. seenBracket = true;
  57469. } else if (c === ']') {
  57470. seenBracket = false;
  57471. }
  57472. buffer += c;
  57473. } else {
  57474. err('Invalid code point in host/hostname: ' + c);
  57475. }
  57476. break;
  57477. case 'port':
  57478. if (/[0-9]/.test(c)) {
  57479. buffer += c;
  57480. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  57481. if ('' !== buffer) {
  57482. var temp = parseInt(buffer, 10);
  57483. if (temp !== relative[this._scheme]) {
  57484. this._port = temp + '';
  57485. }
  57486. buffer = '';
  57487. }
  57488. if (stateOverride) {
  57489. break loop;
  57490. }
  57491. state = 'relative path start';
  57492. continue;
  57493. } else if (c === '\t' || c === '\n' || c === '\r') {
  57494. err('Invalid code point in port: ' + c);
  57495. } else {
  57496. invalid.call(this);
  57497. }
  57498. break;
  57499. case 'relative path start':
  57500. if (c === '\\') {
  57501. err('\'\\\' not allowed in path.');
  57502. }
  57503. state = 'relative path';
  57504. if ('/' !== c && '\\' !== c) {
  57505. continue;
  57506. }
  57507. break;
  57508. case 'relative path':
  57509. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  57510. if (c === '\\') {
  57511. err('\\ not allowed in relative path.');
  57512. }
  57513. var tmp;
  57514. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  57515. buffer = tmp;
  57516. }
  57517. if (buffer === '..') {
  57518. this._path.pop();
  57519. if ('/' !== c && '\\' !== c) {
  57520. this._path.push('');
  57521. }
  57522. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  57523. this._path.push('');
  57524. } else if ('.' !== buffer) {
  57525. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  57526. buffer = buffer[0] + ':';
  57527. }
  57528. this._path.push(buffer);
  57529. }
  57530. buffer = '';
  57531. if (c === '?') {
  57532. this._query = '?';
  57533. state = 'query';
  57534. } else if (c === '#') {
  57535. this._fragment = '#';
  57536. state = 'fragment';
  57537. }
  57538. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57539. buffer += percentEscape(c);
  57540. }
  57541. break;
  57542. case 'query':
  57543. if (!stateOverride && c === '#') {
  57544. this._fragment = '#';
  57545. state = 'fragment';
  57546. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57547. this._query += percentEscapeQuery(c);
  57548. }
  57549. break;
  57550. case 'fragment':
  57551. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57552. this._fragment += c;
  57553. }
  57554. break;
  57555. }
  57556. cursor++;
  57557. }
  57558. }
  57559. function clear() {
  57560. this._scheme = '';
  57561. this._schemeData = '';
  57562. this._username = '';
  57563. this._password = null;
  57564. this._host = '';
  57565. this._port = '';
  57566. this._path = [];
  57567. this._query = '';
  57568. this._fragment = '';
  57569. this._isInvalid = false;
  57570. this._isRelative = false;
  57571. }
  57572. function JURL(url, base) {
  57573. if (base !== undefined && !(base instanceof JURL)) {
  57574. base = new JURL(String(base));
  57575. }
  57576. this._url = url;
  57577. clear.call(this);
  57578. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  57579. parse.call(this, input, null, base);
  57580. }
  57581. JURL.prototype = {
  57582. toString: function () {
  57583. return this.href;
  57584. },
  57585. get href() {
  57586. if (this._isInvalid) {
  57587. return this._url;
  57588. }
  57589. var authority = '';
  57590. if ('' !== this._username || null !== this._password) {
  57591. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  57592. }
  57593. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  57594. },
  57595. set href(href) {
  57596. clear.call(this);
  57597. parse.call(this, href);
  57598. },
  57599. get protocol() {
  57600. return this._scheme + ':';
  57601. },
  57602. set protocol(protocol) {
  57603. if (this._isInvalid) {
  57604. return;
  57605. }
  57606. parse.call(this, protocol + ':', 'scheme start');
  57607. },
  57608. get host() {
  57609. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  57610. },
  57611. set host(host) {
  57612. if (this._isInvalid || !this._isRelative) {
  57613. return;
  57614. }
  57615. parse.call(this, host, 'host');
  57616. },
  57617. get hostname() {
  57618. return this._host;
  57619. },
  57620. set hostname(hostname) {
  57621. if (this._isInvalid || !this._isRelative) {
  57622. return;
  57623. }
  57624. parse.call(this, hostname, 'hostname');
  57625. },
  57626. get port() {
  57627. return this._port;
  57628. },
  57629. set port(port) {
  57630. if (this._isInvalid || !this._isRelative) {
  57631. return;
  57632. }
  57633. parse.call(this, port, 'port');
  57634. },
  57635. get pathname() {
  57636. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  57637. },
  57638. set pathname(pathname) {
  57639. if (this._isInvalid || !this._isRelative) {
  57640. return;
  57641. }
  57642. this._path = [];
  57643. parse.call(this, pathname, 'relative path start');
  57644. },
  57645. get search() {
  57646. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  57647. },
  57648. set search(search) {
  57649. if (this._isInvalid || !this._isRelative) {
  57650. return;
  57651. }
  57652. this._query = '?';
  57653. if (search[0] === '?') {
  57654. search = search.slice(1);
  57655. }
  57656. parse.call(this, search, 'query');
  57657. },
  57658. get hash() {
  57659. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  57660. },
  57661. set hash(hash) {
  57662. if (this._isInvalid) {
  57663. return;
  57664. }
  57665. this._fragment = '#';
  57666. if (hash[0] === '#') {
  57667. hash = hash.slice(1);
  57668. }
  57669. parse.call(this, hash, 'fragment');
  57670. },
  57671. get origin() {
  57672. var host;
  57673. if (this._isInvalid || !this._scheme) {
  57674. return '';
  57675. }
  57676. switch (this._scheme) {
  57677. case 'data':
  57678. case 'file':
  57679. case 'javascript':
  57680. case 'mailto':
  57681. return 'null';
  57682. }
  57683. host = this.host;
  57684. if (!host) {
  57685. return '';
  57686. }
  57687. return this._scheme + '://' + host;
  57688. }
  57689. };
  57690. var OriginalURL = globalScope.URL;
  57691. if (OriginalURL) {
  57692. JURL.createObjectURL = function (blob) {
  57693. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  57694. };
  57695. JURL.revokeObjectURL = function (url) {
  57696. OriginalURL.revokeObjectURL(url);
  57697. };
  57698. }
  57699. globalScope.URL = JURL;
  57700. }());
  57701. }
  57702. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  57703. /***/ }),
  57704. /* 48 */
  57705. /***/ (function(module, exports, __w_pdfjs_require__) {
  57706. "use strict";
  57707. var pdfjsVersion = '1.7.316';
  57708. var pdfjsBuild = '59392fd5';
  57709. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57710. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  57711. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57712. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57713. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57714. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57715. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57716. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57717. exports.build = pdfjsDisplayAPI.build;
  57718. exports.version = pdfjsDisplayAPI.version;
  57719. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57720. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57721. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57722. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57723. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57724. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57725. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57726. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57727. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57728. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57729. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57730. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57731. exports.OPS = pdfjsSharedUtil.OPS;
  57732. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57733. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57734. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57735. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57736. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57737. exports.shadow = pdfjsSharedUtil.shadow;
  57738. exports.createBlob = pdfjsSharedUtil.createBlob;
  57739. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57740. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57741. /***/ })
  57742. /******/ ]);
  57743. });