pdf.combined.js 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975
  1. /* Copyright 2012 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 (root, factory) {
  16. 'use strict';
  17. if (typeof define === 'function' && define.amd) {
  18. define('pdfjs-dist/build/pdf.combined', ['exports'], factory);
  19. } else if (typeof exports !== 'undefined') {
  20. factory(exports);
  21. } else {
  22. factory(root['pdfjsDistBuildPdfCombined'] = {});
  23. }
  24. }(this, function (exports) {
  25. 'use strict';
  26. var pdfjsVersion = '1.6.343';
  27. var pdfjsBuild = '7c96da4';
  28. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  29. var pdfjsLibs = {};
  30. (function pdfjsWrapper() {
  31. (function (root, factory) {
  32. factory(root.pdfjsCoreArithmeticDecoder = {});
  33. }(this, function (exports) {
  34. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  35. var QeTable = [
  36. {
  37. qe: 0x5601,
  38. nmps: 1,
  39. nlps: 1,
  40. switchFlag: 1
  41. },
  42. {
  43. qe: 0x3401,
  44. nmps: 2,
  45. nlps: 6,
  46. switchFlag: 0
  47. },
  48. {
  49. qe: 0x1801,
  50. nmps: 3,
  51. nlps: 9,
  52. switchFlag: 0
  53. },
  54. {
  55. qe: 0x0AC1,
  56. nmps: 4,
  57. nlps: 12,
  58. switchFlag: 0
  59. },
  60. {
  61. qe: 0x0521,
  62. nmps: 5,
  63. nlps: 29,
  64. switchFlag: 0
  65. },
  66. {
  67. qe: 0x0221,
  68. nmps: 38,
  69. nlps: 33,
  70. switchFlag: 0
  71. },
  72. {
  73. qe: 0x5601,
  74. nmps: 7,
  75. nlps: 6,
  76. switchFlag: 1
  77. },
  78. {
  79. qe: 0x5401,
  80. nmps: 8,
  81. nlps: 14,
  82. switchFlag: 0
  83. },
  84. {
  85. qe: 0x4801,
  86. nmps: 9,
  87. nlps: 14,
  88. switchFlag: 0
  89. },
  90. {
  91. qe: 0x3801,
  92. nmps: 10,
  93. nlps: 14,
  94. switchFlag: 0
  95. },
  96. {
  97. qe: 0x3001,
  98. nmps: 11,
  99. nlps: 17,
  100. switchFlag: 0
  101. },
  102. {
  103. qe: 0x2401,
  104. nmps: 12,
  105. nlps: 18,
  106. switchFlag: 0
  107. },
  108. {
  109. qe: 0x1C01,
  110. nmps: 13,
  111. nlps: 20,
  112. switchFlag: 0
  113. },
  114. {
  115. qe: 0x1601,
  116. nmps: 29,
  117. nlps: 21,
  118. switchFlag: 0
  119. },
  120. {
  121. qe: 0x5601,
  122. nmps: 15,
  123. nlps: 14,
  124. switchFlag: 1
  125. },
  126. {
  127. qe: 0x5401,
  128. nmps: 16,
  129. nlps: 14,
  130. switchFlag: 0
  131. },
  132. {
  133. qe: 0x5101,
  134. nmps: 17,
  135. nlps: 15,
  136. switchFlag: 0
  137. },
  138. {
  139. qe: 0x4801,
  140. nmps: 18,
  141. nlps: 16,
  142. switchFlag: 0
  143. },
  144. {
  145. qe: 0x3801,
  146. nmps: 19,
  147. nlps: 17,
  148. switchFlag: 0
  149. },
  150. {
  151. qe: 0x3401,
  152. nmps: 20,
  153. nlps: 18,
  154. switchFlag: 0
  155. },
  156. {
  157. qe: 0x3001,
  158. nmps: 21,
  159. nlps: 19,
  160. switchFlag: 0
  161. },
  162. {
  163. qe: 0x2801,
  164. nmps: 22,
  165. nlps: 19,
  166. switchFlag: 0
  167. },
  168. {
  169. qe: 0x2401,
  170. nmps: 23,
  171. nlps: 20,
  172. switchFlag: 0
  173. },
  174. {
  175. qe: 0x2201,
  176. nmps: 24,
  177. nlps: 21,
  178. switchFlag: 0
  179. },
  180. {
  181. qe: 0x1C01,
  182. nmps: 25,
  183. nlps: 22,
  184. switchFlag: 0
  185. },
  186. {
  187. qe: 0x1801,
  188. nmps: 26,
  189. nlps: 23,
  190. switchFlag: 0
  191. },
  192. {
  193. qe: 0x1601,
  194. nmps: 27,
  195. nlps: 24,
  196. switchFlag: 0
  197. },
  198. {
  199. qe: 0x1401,
  200. nmps: 28,
  201. nlps: 25,
  202. switchFlag: 0
  203. },
  204. {
  205. qe: 0x1201,
  206. nmps: 29,
  207. nlps: 26,
  208. switchFlag: 0
  209. },
  210. {
  211. qe: 0x1101,
  212. nmps: 30,
  213. nlps: 27,
  214. switchFlag: 0
  215. },
  216. {
  217. qe: 0x0AC1,
  218. nmps: 31,
  219. nlps: 28,
  220. switchFlag: 0
  221. },
  222. {
  223. qe: 0x09C1,
  224. nmps: 32,
  225. nlps: 29,
  226. switchFlag: 0
  227. },
  228. {
  229. qe: 0x08A1,
  230. nmps: 33,
  231. nlps: 30,
  232. switchFlag: 0
  233. },
  234. {
  235. qe: 0x0521,
  236. nmps: 34,
  237. nlps: 31,
  238. switchFlag: 0
  239. },
  240. {
  241. qe: 0x0441,
  242. nmps: 35,
  243. nlps: 32,
  244. switchFlag: 0
  245. },
  246. {
  247. qe: 0x02A1,
  248. nmps: 36,
  249. nlps: 33,
  250. switchFlag: 0
  251. },
  252. {
  253. qe: 0x0221,
  254. nmps: 37,
  255. nlps: 34,
  256. switchFlag: 0
  257. },
  258. {
  259. qe: 0x0141,
  260. nmps: 38,
  261. nlps: 35,
  262. switchFlag: 0
  263. },
  264. {
  265. qe: 0x0111,
  266. nmps: 39,
  267. nlps: 36,
  268. switchFlag: 0
  269. },
  270. {
  271. qe: 0x0085,
  272. nmps: 40,
  273. nlps: 37,
  274. switchFlag: 0
  275. },
  276. {
  277. qe: 0x0049,
  278. nmps: 41,
  279. nlps: 38,
  280. switchFlag: 0
  281. },
  282. {
  283. qe: 0x0025,
  284. nmps: 42,
  285. nlps: 39,
  286. switchFlag: 0
  287. },
  288. {
  289. qe: 0x0015,
  290. nmps: 43,
  291. nlps: 40,
  292. switchFlag: 0
  293. },
  294. {
  295. qe: 0x0009,
  296. nmps: 44,
  297. nlps: 41,
  298. switchFlag: 0
  299. },
  300. {
  301. qe: 0x0005,
  302. nmps: 45,
  303. nlps: 42,
  304. switchFlag: 0
  305. },
  306. {
  307. qe: 0x0001,
  308. nmps: 45,
  309. nlps: 43,
  310. switchFlag: 0
  311. },
  312. {
  313. qe: 0x5601,
  314. nmps: 46,
  315. nlps: 46,
  316. switchFlag: 0
  317. }
  318. ];
  319. function ArithmeticDecoder(data, start, end) {
  320. this.data = data;
  321. this.bp = start;
  322. this.dataEnd = end;
  323. this.chigh = data[start];
  324. this.clow = 0;
  325. this.byteIn();
  326. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  327. this.clow = this.clow << 7 & 0xFFFF;
  328. this.ct -= 7;
  329. this.a = 0x8000;
  330. }
  331. ArithmeticDecoder.prototype = {
  332. byteIn: function ArithmeticDecoder_byteIn() {
  333. var data = this.data;
  334. var bp = this.bp;
  335. if (data[bp] === 0xFF) {
  336. var b1 = data[bp + 1];
  337. if (b1 > 0x8F) {
  338. this.clow += 0xFF00;
  339. this.ct = 8;
  340. } else {
  341. bp++;
  342. this.clow += data[bp] << 9;
  343. this.ct = 7;
  344. this.bp = bp;
  345. }
  346. } else {
  347. bp++;
  348. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  349. this.ct = 8;
  350. this.bp = bp;
  351. }
  352. if (this.clow > 0xFFFF) {
  353. this.chigh += this.clow >> 16;
  354. this.clow &= 0xFFFF;
  355. }
  356. },
  357. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  358. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  359. var qeTableIcx = QeTable[cx_index];
  360. var qeIcx = qeTableIcx.qe;
  361. var d;
  362. var a = this.a - qeIcx;
  363. if (this.chigh < qeIcx) {
  364. if (a < qeIcx) {
  365. a = qeIcx;
  366. d = cx_mps;
  367. cx_index = qeTableIcx.nmps;
  368. } else {
  369. a = qeIcx;
  370. d = 1 ^ cx_mps;
  371. if (qeTableIcx.switchFlag === 1) {
  372. cx_mps = d;
  373. }
  374. cx_index = qeTableIcx.nlps;
  375. }
  376. } else {
  377. this.chigh -= qeIcx;
  378. if ((a & 0x8000) !== 0) {
  379. this.a = a;
  380. return cx_mps;
  381. }
  382. if (a < qeIcx) {
  383. d = 1 ^ cx_mps;
  384. if (qeTableIcx.switchFlag === 1) {
  385. cx_mps = d;
  386. }
  387. cx_index = qeTableIcx.nlps;
  388. } else {
  389. d = cx_mps;
  390. cx_index = qeTableIcx.nmps;
  391. }
  392. }
  393. do {
  394. if (this.ct === 0) {
  395. this.byteIn();
  396. }
  397. a <<= 1;
  398. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  399. this.clow = this.clow << 1 & 0xFFFF;
  400. this.ct--;
  401. } while ((a & 0x8000) === 0);
  402. this.a = a;
  403. contexts[pos] = cx_index << 1 | cx_mps;
  404. return d;
  405. }
  406. };
  407. return ArithmeticDecoder;
  408. }();
  409. exports.ArithmeticDecoder = ArithmeticDecoder;
  410. }));
  411. (function (root, factory) {
  412. factory(root.pdfjsCoreBidi = {});
  413. }(this, function (exports) {
  414. var baseTypes = [
  415. 'BN',
  416. 'BN',
  417. 'BN',
  418. 'BN',
  419. 'BN',
  420. 'BN',
  421. 'BN',
  422. 'BN',
  423. 'BN',
  424. 'S',
  425. 'B',
  426. 'S',
  427. 'WS',
  428. 'B',
  429. 'BN',
  430. 'BN',
  431. 'BN',
  432. 'BN',
  433. 'BN',
  434. 'BN',
  435. 'BN',
  436. 'BN',
  437. 'BN',
  438. 'BN',
  439. 'BN',
  440. 'BN',
  441. 'BN',
  442. 'BN',
  443. 'B',
  444. 'B',
  445. 'B',
  446. 'S',
  447. 'WS',
  448. 'ON',
  449. 'ON',
  450. 'ET',
  451. 'ET',
  452. 'ET',
  453. 'ON',
  454. 'ON',
  455. 'ON',
  456. 'ON',
  457. 'ON',
  458. 'ON',
  459. 'CS',
  460. 'ON',
  461. 'CS',
  462. 'ON',
  463. 'EN',
  464. 'EN',
  465. 'EN',
  466. 'EN',
  467. 'EN',
  468. 'EN',
  469. 'EN',
  470. 'EN',
  471. 'EN',
  472. 'EN',
  473. 'ON',
  474. 'ON',
  475. 'ON',
  476. 'ON',
  477. 'ON',
  478. 'ON',
  479. 'ON',
  480. 'L',
  481. 'L',
  482. 'L',
  483. 'L',
  484. 'L',
  485. 'L',
  486. 'L',
  487. 'L',
  488. 'L',
  489. 'L',
  490. 'L',
  491. 'L',
  492. 'L',
  493. 'L',
  494. 'L',
  495. 'L',
  496. 'L',
  497. 'L',
  498. 'L',
  499. 'L',
  500. 'L',
  501. 'L',
  502. 'L',
  503. 'L',
  504. 'L',
  505. 'L',
  506. 'ON',
  507. 'ON',
  508. 'ON',
  509. 'ON',
  510. 'ON',
  511. 'ON',
  512. 'L',
  513. 'L',
  514. 'L',
  515. 'L',
  516. 'L',
  517. 'L',
  518. 'L',
  519. 'L',
  520. 'L',
  521. 'L',
  522. 'L',
  523. 'L',
  524. 'L',
  525. 'L',
  526. 'L',
  527. 'L',
  528. 'L',
  529. 'L',
  530. 'L',
  531. 'L',
  532. 'L',
  533. 'L',
  534. 'L',
  535. 'L',
  536. 'L',
  537. 'L',
  538. 'ON',
  539. 'ON',
  540. 'ON',
  541. 'ON',
  542. 'BN',
  543. 'BN',
  544. 'BN',
  545. 'BN',
  546. 'BN',
  547. 'BN',
  548. 'B',
  549. 'BN',
  550. 'BN',
  551. 'BN',
  552. 'BN',
  553. 'BN',
  554. 'BN',
  555. 'BN',
  556. 'BN',
  557. 'BN',
  558. 'BN',
  559. 'BN',
  560. 'BN',
  561. 'BN',
  562. 'BN',
  563. 'BN',
  564. 'BN',
  565. 'BN',
  566. 'BN',
  567. 'BN',
  568. 'BN',
  569. 'BN',
  570. 'BN',
  571. 'BN',
  572. 'BN',
  573. 'BN',
  574. 'BN',
  575. 'CS',
  576. 'ON',
  577. 'ET',
  578. 'ET',
  579. 'ET',
  580. 'ET',
  581. 'ON',
  582. 'ON',
  583. 'ON',
  584. 'ON',
  585. 'L',
  586. 'ON',
  587. 'ON',
  588. 'ON',
  589. 'ON',
  590. 'ON',
  591. 'ET',
  592. 'ET',
  593. 'EN',
  594. 'EN',
  595. 'ON',
  596. 'L',
  597. 'ON',
  598. 'ON',
  599. 'ON',
  600. 'EN',
  601. 'L',
  602. 'ON',
  603. 'ON',
  604. 'ON',
  605. 'ON',
  606. 'ON',
  607. 'L',
  608. 'L',
  609. 'L',
  610. 'L',
  611. 'L',
  612. 'L',
  613. 'L',
  614. 'L',
  615. 'L',
  616. 'L',
  617. 'L',
  618. 'L',
  619. 'L',
  620. 'L',
  621. 'L',
  622. 'L',
  623. 'L',
  624. 'L',
  625. 'L',
  626. 'L',
  627. 'L',
  628. 'L',
  629. 'L',
  630. 'ON',
  631. 'L',
  632. 'L',
  633. 'L',
  634. 'L',
  635. 'L',
  636. 'L',
  637. 'L',
  638. 'L',
  639. 'L',
  640. 'L',
  641. 'L',
  642. 'L',
  643. 'L',
  644. 'L',
  645. 'L',
  646. 'L',
  647. 'L',
  648. 'L',
  649. 'L',
  650. 'L',
  651. 'L',
  652. 'L',
  653. 'L',
  654. 'L',
  655. 'L',
  656. 'L',
  657. 'L',
  658. 'L',
  659. 'L',
  660. 'L',
  661. 'L',
  662. 'ON',
  663. 'L',
  664. 'L',
  665. 'L',
  666. 'L',
  667. 'L',
  668. 'L',
  669. 'L',
  670. 'L'
  671. ];
  672. var arabicTypes = [
  673. 'AL',
  674. 'AL',
  675. 'AL',
  676. 'AL',
  677. 'AL',
  678. 'AL',
  679. 'AL',
  680. 'AL',
  681. 'AL',
  682. 'AL',
  683. 'AL',
  684. 'AL',
  685. 'CS',
  686. 'AL',
  687. 'ON',
  688. 'ON',
  689. 'NSM',
  690. 'NSM',
  691. 'NSM',
  692. 'NSM',
  693. 'NSM',
  694. 'NSM',
  695. 'AL',
  696. 'AL',
  697. 'AL',
  698. 'AL',
  699. 'AL',
  700. 'AL',
  701. 'AL',
  702. 'AL',
  703. 'AL',
  704. 'AL',
  705. 'AL',
  706. 'AL',
  707. 'AL',
  708. 'AL',
  709. 'AL',
  710. 'AL',
  711. 'AL',
  712. 'AL',
  713. 'AL',
  714. 'AL',
  715. 'AL',
  716. 'AL',
  717. 'AL',
  718. 'AL',
  719. 'AL',
  720. 'AL',
  721. 'AL',
  722. 'AL',
  723. 'AL',
  724. 'AL',
  725. 'AL',
  726. 'AL',
  727. 'AL',
  728. 'AL',
  729. 'AL',
  730. 'AL',
  731. 'AL',
  732. 'AL',
  733. 'AL',
  734. 'AL',
  735. 'AL',
  736. 'AL',
  737. 'AL',
  738. 'AL',
  739. 'AL',
  740. 'AL',
  741. 'AL',
  742. 'AL',
  743. 'AL',
  744. 'AL',
  745. 'AL',
  746. 'AL',
  747. 'AL',
  748. 'NSM',
  749. 'NSM',
  750. 'NSM',
  751. 'NSM',
  752. 'NSM',
  753. 'NSM',
  754. 'NSM',
  755. 'NSM',
  756. 'NSM',
  757. 'NSM',
  758. 'NSM',
  759. 'NSM',
  760. 'NSM',
  761. 'NSM',
  762. 'AL',
  763. 'AL',
  764. 'AL',
  765. 'AL',
  766. 'AL',
  767. 'AL',
  768. 'AL',
  769. 'AN',
  770. 'AN',
  771. 'AN',
  772. 'AN',
  773. 'AN',
  774. 'AN',
  775. 'AN',
  776. 'AN',
  777. 'AN',
  778. 'AN',
  779. 'ET',
  780. 'AN',
  781. 'AN',
  782. 'AL',
  783. 'AL',
  784. 'AL',
  785. 'NSM',
  786. 'AL',
  787. 'AL',
  788. 'AL',
  789. 'AL',
  790. 'AL',
  791. 'AL',
  792. 'AL',
  793. 'AL',
  794. 'AL',
  795. 'AL',
  796. 'AL',
  797. 'AL',
  798. 'AL',
  799. 'AL',
  800. 'AL',
  801. 'AL',
  802. 'AL',
  803. 'AL',
  804. 'AL',
  805. 'AL',
  806. 'AL',
  807. 'AL',
  808. 'AL',
  809. 'AL',
  810. 'AL',
  811. 'AL',
  812. 'AL',
  813. 'AL',
  814. 'AL',
  815. 'AL',
  816. 'AL',
  817. 'AL',
  818. 'AL',
  819. 'AL',
  820. 'AL',
  821. 'AL',
  822. 'AL',
  823. 'AL',
  824. 'AL',
  825. 'AL',
  826. 'AL',
  827. 'AL',
  828. 'AL',
  829. 'AL',
  830. 'AL',
  831. 'AL',
  832. 'AL',
  833. 'AL',
  834. 'AL',
  835. 'AL',
  836. 'AL',
  837. 'AL',
  838. 'AL',
  839. 'AL',
  840. 'AL',
  841. 'AL',
  842. 'AL',
  843. 'AL',
  844. 'AL',
  845. 'AL',
  846. 'AL',
  847. 'AL',
  848. 'AL',
  849. 'AL',
  850. 'AL',
  851. 'AL',
  852. 'AL',
  853. 'AL',
  854. 'AL',
  855. 'AL',
  856. 'AL',
  857. 'AL',
  858. 'AL',
  859. 'AL',
  860. 'AL',
  861. 'AL',
  862. 'AL',
  863. 'AL',
  864. 'AL',
  865. 'AL',
  866. 'AL',
  867. 'AL',
  868. 'AL',
  869. 'AL',
  870. 'AL',
  871. 'AL',
  872. 'AL',
  873. 'AL',
  874. 'AL',
  875. 'AL',
  876. 'AL',
  877. 'AL',
  878. 'AL',
  879. 'AL',
  880. 'AL',
  881. 'AL',
  882. 'AL',
  883. 'AL',
  884. 'AL',
  885. 'AL',
  886. 'AL',
  887. 'NSM',
  888. 'NSM',
  889. 'NSM',
  890. 'NSM',
  891. 'NSM',
  892. 'NSM',
  893. 'NSM',
  894. 'NSM',
  895. 'NSM',
  896. 'NSM',
  897. 'NSM',
  898. 'NSM',
  899. 'NSM',
  900. 'NSM',
  901. 'NSM',
  902. 'NSM',
  903. 'NSM',
  904. 'NSM',
  905. 'NSM',
  906. 'ON',
  907. 'NSM',
  908. 'NSM',
  909. 'NSM',
  910. 'NSM',
  911. 'AL',
  912. 'AL',
  913. 'AL',
  914. 'AL',
  915. 'AL',
  916. 'AL',
  917. 'AL',
  918. 'AL',
  919. 'AL',
  920. 'AL',
  921. 'AL',
  922. 'AL',
  923. 'AL',
  924. 'AL',
  925. 'AL',
  926. 'AL',
  927. 'AL',
  928. 'AL'
  929. ];
  930. function isOdd(i) {
  931. return (i & 1) !== 0;
  932. }
  933. function isEven(i) {
  934. return (i & 1) === 0;
  935. }
  936. function findUnequal(arr, start, value) {
  937. for (var j = start, jj = arr.length; j < jj; ++j) {
  938. if (arr[j] !== value) {
  939. return j;
  940. }
  941. }
  942. return j;
  943. }
  944. function setValues(arr, start, end, value) {
  945. for (var j = start; j < end; ++j) {
  946. arr[j] = value;
  947. }
  948. }
  949. function reverseValues(arr, start, end) {
  950. for (var i = start, j = end - 1; i < j; ++i, --j) {
  951. var temp = arr[i];
  952. arr[i] = arr[j];
  953. arr[j] = temp;
  954. }
  955. }
  956. function createBidiText(str, isLTR, vertical) {
  957. return {
  958. str: str,
  959. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  960. };
  961. }
  962. var chars = [];
  963. var types = [];
  964. function bidi(str, startLevel, vertical) {
  965. var isLTR = true;
  966. var strLength = str.length;
  967. if (strLength === 0 || vertical) {
  968. return createBidiText(str, isLTR, vertical);
  969. }
  970. chars.length = strLength;
  971. types.length = strLength;
  972. var numBidi = 0;
  973. var i, ii;
  974. for (i = 0; i < strLength; ++i) {
  975. chars[i] = str.charAt(i);
  976. var charCode = str.charCodeAt(i);
  977. var charType = 'L';
  978. if (charCode <= 0x00ff) {
  979. charType = baseTypes[charCode];
  980. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  981. charType = 'R';
  982. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  983. charType = arabicTypes[charCode & 0xff];
  984. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  985. charType = 'AL';
  986. }
  987. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  988. numBidi++;
  989. }
  990. types[i] = charType;
  991. }
  992. if (numBidi === 0) {
  993. isLTR = true;
  994. return createBidiText(str, isLTR);
  995. }
  996. if (startLevel === -1) {
  997. if (strLength / numBidi < 0.3) {
  998. isLTR = true;
  999. startLevel = 0;
  1000. } else {
  1001. isLTR = false;
  1002. startLevel = 1;
  1003. }
  1004. }
  1005. var levels = [];
  1006. for (i = 0; i < strLength; ++i) {
  1007. levels[i] = startLevel;
  1008. }
  1009. var e = isOdd(startLevel) ? 'R' : 'L';
  1010. var sor = e;
  1011. var eor = sor;
  1012. var lastType = sor;
  1013. for (i = 0; i < strLength; ++i) {
  1014. if (types[i] === 'NSM') {
  1015. types[i] = lastType;
  1016. } else {
  1017. lastType = types[i];
  1018. }
  1019. }
  1020. lastType = sor;
  1021. var t;
  1022. for (i = 0; i < strLength; ++i) {
  1023. t = types[i];
  1024. if (t === 'EN') {
  1025. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  1026. } else if (t === 'R' || t === 'L' || t === 'AL') {
  1027. lastType = t;
  1028. }
  1029. }
  1030. for (i = 0; i < strLength; ++i) {
  1031. t = types[i];
  1032. if (t === 'AL') {
  1033. types[i] = 'R';
  1034. }
  1035. }
  1036. for (i = 1; i < strLength - 1; ++i) {
  1037. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  1038. types[i] = 'EN';
  1039. }
  1040. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  1041. types[i] = types[i - 1];
  1042. }
  1043. }
  1044. for (i = 0; i < strLength; ++i) {
  1045. if (types[i] === 'EN') {
  1046. var j;
  1047. for (j = i - 1; j >= 0; --j) {
  1048. if (types[j] !== 'ET') {
  1049. break;
  1050. }
  1051. types[j] = 'EN';
  1052. }
  1053. for (j = i + 1; j < strLength; ++j) {
  1054. if (types[j] !== 'ET') {
  1055. break;
  1056. }
  1057. types[j] = 'EN';
  1058. }
  1059. }
  1060. }
  1061. for (i = 0; i < strLength; ++i) {
  1062. t = types[i];
  1063. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  1064. types[i] = 'ON';
  1065. }
  1066. }
  1067. lastType = sor;
  1068. for (i = 0; i < strLength; ++i) {
  1069. t = types[i];
  1070. if (t === 'EN') {
  1071. types[i] = lastType === 'L' ? 'L' : 'EN';
  1072. } else if (t === 'R' || t === 'L') {
  1073. lastType = t;
  1074. }
  1075. }
  1076. for (i = 0; i < strLength; ++i) {
  1077. if (types[i] === 'ON') {
  1078. var end = findUnequal(types, i + 1, 'ON');
  1079. var before = sor;
  1080. if (i > 0) {
  1081. before = types[i - 1];
  1082. }
  1083. var after = eor;
  1084. if (end + 1 < strLength) {
  1085. after = types[end + 1];
  1086. }
  1087. if (before !== 'L') {
  1088. before = 'R';
  1089. }
  1090. if (after !== 'L') {
  1091. after = 'R';
  1092. }
  1093. if (before === after) {
  1094. setValues(types, i, end, before);
  1095. }
  1096. i = end - 1;
  1097. }
  1098. }
  1099. for (i = 0; i < strLength; ++i) {
  1100. if (types[i] === 'ON') {
  1101. types[i] = e;
  1102. }
  1103. }
  1104. for (i = 0; i < strLength; ++i) {
  1105. t = types[i];
  1106. if (isEven(levels[i])) {
  1107. if (t === 'R') {
  1108. levels[i] += 1;
  1109. } else if (t === 'AN' || t === 'EN') {
  1110. levels[i] += 2;
  1111. }
  1112. } else {
  1113. if (t === 'L' || t === 'AN' || t === 'EN') {
  1114. levels[i] += 1;
  1115. }
  1116. }
  1117. }
  1118. var highestLevel = -1;
  1119. var lowestOddLevel = 99;
  1120. var level;
  1121. for (i = 0, ii = levels.length; i < ii; ++i) {
  1122. level = levels[i];
  1123. if (highestLevel < level) {
  1124. highestLevel = level;
  1125. }
  1126. if (lowestOddLevel > level && isOdd(level)) {
  1127. lowestOddLevel = level;
  1128. }
  1129. }
  1130. for (level = highestLevel; level >= lowestOddLevel; --level) {
  1131. var start = -1;
  1132. for (i = 0, ii = levels.length; i < ii; ++i) {
  1133. if (levels[i] < level) {
  1134. if (start >= 0) {
  1135. reverseValues(chars, start, i);
  1136. start = -1;
  1137. }
  1138. } else if (start < 0) {
  1139. start = i;
  1140. }
  1141. }
  1142. if (start >= 0) {
  1143. reverseValues(chars, start, levels.length);
  1144. }
  1145. }
  1146. for (i = 0, ii = chars.length; i < ii; ++i) {
  1147. var ch = chars[i];
  1148. if (ch === '<' || ch === '>') {
  1149. chars[i] = '';
  1150. }
  1151. }
  1152. return createBidiText(chars.join(''), isLTR);
  1153. }
  1154. exports.bidi = bidi;
  1155. }));
  1156. (function (root, factory) {
  1157. factory(root.pdfjsCoreCharsets = {});
  1158. }(this, function (exports) {
  1159. var ISOAdobeCharset = [
  1160. '.notdef',
  1161. 'space',
  1162. 'exclam',
  1163. 'quotedbl',
  1164. 'numbersign',
  1165. 'dollar',
  1166. 'percent',
  1167. 'ampersand',
  1168. 'quoteright',
  1169. 'parenleft',
  1170. 'parenright',
  1171. 'asterisk',
  1172. 'plus',
  1173. 'comma',
  1174. 'hyphen',
  1175. 'period',
  1176. 'slash',
  1177. 'zero',
  1178. 'one',
  1179. 'two',
  1180. 'three',
  1181. 'four',
  1182. 'five',
  1183. 'six',
  1184. 'seven',
  1185. 'eight',
  1186. 'nine',
  1187. 'colon',
  1188. 'semicolon',
  1189. 'less',
  1190. 'equal',
  1191. 'greater',
  1192. 'question',
  1193. 'at',
  1194. 'A',
  1195. 'B',
  1196. 'C',
  1197. 'D',
  1198. 'E',
  1199. 'F',
  1200. 'G',
  1201. 'H',
  1202. 'I',
  1203. 'J',
  1204. 'K',
  1205. 'L',
  1206. 'M',
  1207. 'N',
  1208. 'O',
  1209. 'P',
  1210. 'Q',
  1211. 'R',
  1212. 'S',
  1213. 'T',
  1214. 'U',
  1215. 'V',
  1216. 'W',
  1217. 'X',
  1218. 'Y',
  1219. 'Z',
  1220. 'bracketleft',
  1221. 'backslash',
  1222. 'bracketright',
  1223. 'asciicircum',
  1224. 'underscore',
  1225. 'quoteleft',
  1226. 'a',
  1227. 'b',
  1228. 'c',
  1229. 'd',
  1230. 'e',
  1231. 'f',
  1232. 'g',
  1233. 'h',
  1234. 'i',
  1235. 'j',
  1236. 'k',
  1237. 'l',
  1238. 'm',
  1239. 'n',
  1240. 'o',
  1241. 'p',
  1242. 'q',
  1243. 'r',
  1244. 's',
  1245. 't',
  1246. 'u',
  1247. 'v',
  1248. 'w',
  1249. 'x',
  1250. 'y',
  1251. 'z',
  1252. 'braceleft',
  1253. 'bar',
  1254. 'braceright',
  1255. 'asciitilde',
  1256. 'exclamdown',
  1257. 'cent',
  1258. 'sterling',
  1259. 'fraction',
  1260. 'yen',
  1261. 'florin',
  1262. 'section',
  1263. 'currency',
  1264. 'quotesingle',
  1265. 'quotedblleft',
  1266. 'guillemotleft',
  1267. 'guilsinglleft',
  1268. 'guilsinglright',
  1269. 'fi',
  1270. 'fl',
  1271. 'endash',
  1272. 'dagger',
  1273. 'daggerdbl',
  1274. 'periodcentered',
  1275. 'paragraph',
  1276. 'bullet',
  1277. 'quotesinglbase',
  1278. 'quotedblbase',
  1279. 'quotedblright',
  1280. 'guillemotright',
  1281. 'ellipsis',
  1282. 'perthousand',
  1283. 'questiondown',
  1284. 'grave',
  1285. 'acute',
  1286. 'circumflex',
  1287. 'tilde',
  1288. 'macron',
  1289. 'breve',
  1290. 'dotaccent',
  1291. 'dieresis',
  1292. 'ring',
  1293. 'cedilla',
  1294. 'hungarumlaut',
  1295. 'ogonek',
  1296. 'caron',
  1297. 'emdash',
  1298. 'AE',
  1299. 'ordfeminine',
  1300. 'Lslash',
  1301. 'Oslash',
  1302. 'OE',
  1303. 'ordmasculine',
  1304. 'ae',
  1305. 'dotlessi',
  1306. 'lslash',
  1307. 'oslash',
  1308. 'oe',
  1309. 'germandbls',
  1310. 'onesuperior',
  1311. 'logicalnot',
  1312. 'mu',
  1313. 'trademark',
  1314. 'Eth',
  1315. 'onehalf',
  1316. 'plusminus',
  1317. 'Thorn',
  1318. 'onequarter',
  1319. 'divide',
  1320. 'brokenbar',
  1321. 'degree',
  1322. 'thorn',
  1323. 'threequarters',
  1324. 'twosuperior',
  1325. 'registered',
  1326. 'minus',
  1327. 'eth',
  1328. 'multiply',
  1329. 'threesuperior',
  1330. 'copyright',
  1331. 'Aacute',
  1332. 'Acircumflex',
  1333. 'Adieresis',
  1334. 'Agrave',
  1335. 'Aring',
  1336. 'Atilde',
  1337. 'Ccedilla',
  1338. 'Eacute',
  1339. 'Ecircumflex',
  1340. 'Edieresis',
  1341. 'Egrave',
  1342. 'Iacute',
  1343. 'Icircumflex',
  1344. 'Idieresis',
  1345. 'Igrave',
  1346. 'Ntilde',
  1347. 'Oacute',
  1348. 'Ocircumflex',
  1349. 'Odieresis',
  1350. 'Ograve',
  1351. 'Otilde',
  1352. 'Scaron',
  1353. 'Uacute',
  1354. 'Ucircumflex',
  1355. 'Udieresis',
  1356. 'Ugrave',
  1357. 'Yacute',
  1358. 'Ydieresis',
  1359. 'Zcaron',
  1360. 'aacute',
  1361. 'acircumflex',
  1362. 'adieresis',
  1363. 'agrave',
  1364. 'aring',
  1365. 'atilde',
  1366. 'ccedilla',
  1367. 'eacute',
  1368. 'ecircumflex',
  1369. 'edieresis',
  1370. 'egrave',
  1371. 'iacute',
  1372. 'icircumflex',
  1373. 'idieresis',
  1374. 'igrave',
  1375. 'ntilde',
  1376. 'oacute',
  1377. 'ocircumflex',
  1378. 'odieresis',
  1379. 'ograve',
  1380. 'otilde',
  1381. 'scaron',
  1382. 'uacute',
  1383. 'ucircumflex',
  1384. 'udieresis',
  1385. 'ugrave',
  1386. 'yacute',
  1387. 'ydieresis',
  1388. 'zcaron'
  1389. ];
  1390. var ExpertCharset = [
  1391. '.notdef',
  1392. 'space',
  1393. 'exclamsmall',
  1394. 'Hungarumlautsmall',
  1395. 'dollaroldstyle',
  1396. 'dollarsuperior',
  1397. 'ampersandsmall',
  1398. 'Acutesmall',
  1399. 'parenleftsuperior',
  1400. 'parenrightsuperior',
  1401. 'twodotenleader',
  1402. 'onedotenleader',
  1403. 'comma',
  1404. 'hyphen',
  1405. 'period',
  1406. 'fraction',
  1407. 'zerooldstyle',
  1408. 'oneoldstyle',
  1409. 'twooldstyle',
  1410. 'threeoldstyle',
  1411. 'fouroldstyle',
  1412. 'fiveoldstyle',
  1413. 'sixoldstyle',
  1414. 'sevenoldstyle',
  1415. 'eightoldstyle',
  1416. 'nineoldstyle',
  1417. 'colon',
  1418. 'semicolon',
  1419. 'commasuperior',
  1420. 'threequartersemdash',
  1421. 'periodsuperior',
  1422. 'questionsmall',
  1423. 'asuperior',
  1424. 'bsuperior',
  1425. 'centsuperior',
  1426. 'dsuperior',
  1427. 'esuperior',
  1428. 'isuperior',
  1429. 'lsuperior',
  1430. 'msuperior',
  1431. 'nsuperior',
  1432. 'osuperior',
  1433. 'rsuperior',
  1434. 'ssuperior',
  1435. 'tsuperior',
  1436. 'ff',
  1437. 'fi',
  1438. 'fl',
  1439. 'ffi',
  1440. 'ffl',
  1441. 'parenleftinferior',
  1442. 'parenrightinferior',
  1443. 'Circumflexsmall',
  1444. 'hyphensuperior',
  1445. 'Gravesmall',
  1446. 'Asmall',
  1447. 'Bsmall',
  1448. 'Csmall',
  1449. 'Dsmall',
  1450. 'Esmall',
  1451. 'Fsmall',
  1452. 'Gsmall',
  1453. 'Hsmall',
  1454. 'Ismall',
  1455. 'Jsmall',
  1456. 'Ksmall',
  1457. 'Lsmall',
  1458. 'Msmall',
  1459. 'Nsmall',
  1460. 'Osmall',
  1461. 'Psmall',
  1462. 'Qsmall',
  1463. 'Rsmall',
  1464. 'Ssmall',
  1465. 'Tsmall',
  1466. 'Usmall',
  1467. 'Vsmall',
  1468. 'Wsmall',
  1469. 'Xsmall',
  1470. 'Ysmall',
  1471. 'Zsmall',
  1472. 'colonmonetary',
  1473. 'onefitted',
  1474. 'rupiah',
  1475. 'Tildesmall',
  1476. 'exclamdownsmall',
  1477. 'centoldstyle',
  1478. 'Lslashsmall',
  1479. 'Scaronsmall',
  1480. 'Zcaronsmall',
  1481. 'Dieresissmall',
  1482. 'Brevesmall',
  1483. 'Caronsmall',
  1484. 'Dotaccentsmall',
  1485. 'Macronsmall',
  1486. 'figuredash',
  1487. 'hypheninferior',
  1488. 'Ogoneksmall',
  1489. 'Ringsmall',
  1490. 'Cedillasmall',
  1491. 'onequarter',
  1492. 'onehalf',
  1493. 'threequarters',
  1494. 'questiondownsmall',
  1495. 'oneeighth',
  1496. 'threeeighths',
  1497. 'fiveeighths',
  1498. 'seveneighths',
  1499. 'onethird',
  1500. 'twothirds',
  1501. 'zerosuperior',
  1502. 'onesuperior',
  1503. 'twosuperior',
  1504. 'threesuperior',
  1505. 'foursuperior',
  1506. 'fivesuperior',
  1507. 'sixsuperior',
  1508. 'sevensuperior',
  1509. 'eightsuperior',
  1510. 'ninesuperior',
  1511. 'zeroinferior',
  1512. 'oneinferior',
  1513. 'twoinferior',
  1514. 'threeinferior',
  1515. 'fourinferior',
  1516. 'fiveinferior',
  1517. 'sixinferior',
  1518. 'seveninferior',
  1519. 'eightinferior',
  1520. 'nineinferior',
  1521. 'centinferior',
  1522. 'dollarinferior',
  1523. 'periodinferior',
  1524. 'commainferior',
  1525. 'Agravesmall',
  1526. 'Aacutesmall',
  1527. 'Acircumflexsmall',
  1528. 'Atildesmall',
  1529. 'Adieresissmall',
  1530. 'Aringsmall',
  1531. 'AEsmall',
  1532. 'Ccedillasmall',
  1533. 'Egravesmall',
  1534. 'Eacutesmall',
  1535. 'Ecircumflexsmall',
  1536. 'Edieresissmall',
  1537. 'Igravesmall',
  1538. 'Iacutesmall',
  1539. 'Icircumflexsmall',
  1540. 'Idieresissmall',
  1541. 'Ethsmall',
  1542. 'Ntildesmall',
  1543. 'Ogravesmall',
  1544. 'Oacutesmall',
  1545. 'Ocircumflexsmall',
  1546. 'Otildesmall',
  1547. 'Odieresissmall',
  1548. 'OEsmall',
  1549. 'Oslashsmall',
  1550. 'Ugravesmall',
  1551. 'Uacutesmall',
  1552. 'Ucircumflexsmall',
  1553. 'Udieresissmall',
  1554. 'Yacutesmall',
  1555. 'Thornsmall',
  1556. 'Ydieresissmall'
  1557. ];
  1558. var ExpertSubsetCharset = [
  1559. '.notdef',
  1560. 'space',
  1561. 'dollaroldstyle',
  1562. 'dollarsuperior',
  1563. 'parenleftsuperior',
  1564. 'parenrightsuperior',
  1565. 'twodotenleader',
  1566. 'onedotenleader',
  1567. 'comma',
  1568. 'hyphen',
  1569. 'period',
  1570. 'fraction',
  1571. 'zerooldstyle',
  1572. 'oneoldstyle',
  1573. 'twooldstyle',
  1574. 'threeoldstyle',
  1575. 'fouroldstyle',
  1576. 'fiveoldstyle',
  1577. 'sixoldstyle',
  1578. 'sevenoldstyle',
  1579. 'eightoldstyle',
  1580. 'nineoldstyle',
  1581. 'colon',
  1582. 'semicolon',
  1583. 'commasuperior',
  1584. 'threequartersemdash',
  1585. 'periodsuperior',
  1586. 'asuperior',
  1587. 'bsuperior',
  1588. 'centsuperior',
  1589. 'dsuperior',
  1590. 'esuperior',
  1591. 'isuperior',
  1592. 'lsuperior',
  1593. 'msuperior',
  1594. 'nsuperior',
  1595. 'osuperior',
  1596. 'rsuperior',
  1597. 'ssuperior',
  1598. 'tsuperior',
  1599. 'ff',
  1600. 'fi',
  1601. 'fl',
  1602. 'ffi',
  1603. 'ffl',
  1604. 'parenleftinferior',
  1605. 'parenrightinferior',
  1606. 'hyphensuperior',
  1607. 'colonmonetary',
  1608. 'onefitted',
  1609. 'rupiah',
  1610. 'centoldstyle',
  1611. 'figuredash',
  1612. 'hypheninferior',
  1613. 'onequarter',
  1614. 'onehalf',
  1615. 'threequarters',
  1616. 'oneeighth',
  1617. 'threeeighths',
  1618. 'fiveeighths',
  1619. 'seveneighths',
  1620. 'onethird',
  1621. 'twothirds',
  1622. 'zerosuperior',
  1623. 'onesuperior',
  1624. 'twosuperior',
  1625. 'threesuperior',
  1626. 'foursuperior',
  1627. 'fivesuperior',
  1628. 'sixsuperior',
  1629. 'sevensuperior',
  1630. 'eightsuperior',
  1631. 'ninesuperior',
  1632. 'zeroinferior',
  1633. 'oneinferior',
  1634. 'twoinferior',
  1635. 'threeinferior',
  1636. 'fourinferior',
  1637. 'fiveinferior',
  1638. 'sixinferior',
  1639. 'seveninferior',
  1640. 'eightinferior',
  1641. 'nineinferior',
  1642. 'centinferior',
  1643. 'dollarinferior',
  1644. 'periodinferior',
  1645. 'commainferior'
  1646. ];
  1647. exports.ISOAdobeCharset = ISOAdobeCharset;
  1648. exports.ExpertCharset = ExpertCharset;
  1649. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  1650. }));
  1651. (function (root, factory) {
  1652. factory(root.pdfjsCoreEncodings = {});
  1653. }(this, function (exports) {
  1654. var ExpertEncoding = [
  1655. '',
  1656. '',
  1657. '',
  1658. '',
  1659. '',
  1660. '',
  1661. '',
  1662. '',
  1663. '',
  1664. '',
  1665. '',
  1666. '',
  1667. '',
  1668. '',
  1669. '',
  1670. '',
  1671. '',
  1672. '',
  1673. '',
  1674. '',
  1675. '',
  1676. '',
  1677. '',
  1678. '',
  1679. '',
  1680. '',
  1681. '',
  1682. '',
  1683. '',
  1684. '',
  1685. '',
  1686. '',
  1687. 'space',
  1688. 'exclamsmall',
  1689. 'Hungarumlautsmall',
  1690. '',
  1691. 'dollaroldstyle',
  1692. 'dollarsuperior',
  1693. 'ampersandsmall',
  1694. 'Acutesmall',
  1695. 'parenleftsuperior',
  1696. 'parenrightsuperior',
  1697. 'twodotenleader',
  1698. 'onedotenleader',
  1699. 'comma',
  1700. 'hyphen',
  1701. 'period',
  1702. 'fraction',
  1703. 'zerooldstyle',
  1704. 'oneoldstyle',
  1705. 'twooldstyle',
  1706. 'threeoldstyle',
  1707. 'fouroldstyle',
  1708. 'fiveoldstyle',
  1709. 'sixoldstyle',
  1710. 'sevenoldstyle',
  1711. 'eightoldstyle',
  1712. 'nineoldstyle',
  1713. 'colon',
  1714. 'semicolon',
  1715. 'commasuperior',
  1716. 'threequartersemdash',
  1717. 'periodsuperior',
  1718. 'questionsmall',
  1719. '',
  1720. 'asuperior',
  1721. 'bsuperior',
  1722. 'centsuperior',
  1723. 'dsuperior',
  1724. 'esuperior',
  1725. '',
  1726. '',
  1727. 'isuperior',
  1728. '',
  1729. '',
  1730. 'lsuperior',
  1731. 'msuperior',
  1732. 'nsuperior',
  1733. 'osuperior',
  1734. '',
  1735. '',
  1736. 'rsuperior',
  1737. 'ssuperior',
  1738. 'tsuperior',
  1739. '',
  1740. 'ff',
  1741. 'fi',
  1742. 'fl',
  1743. 'ffi',
  1744. 'ffl',
  1745. 'parenleftinferior',
  1746. '',
  1747. 'parenrightinferior',
  1748. 'Circumflexsmall',
  1749. 'hyphensuperior',
  1750. 'Gravesmall',
  1751. 'Asmall',
  1752. 'Bsmall',
  1753. 'Csmall',
  1754. 'Dsmall',
  1755. 'Esmall',
  1756. 'Fsmall',
  1757. 'Gsmall',
  1758. 'Hsmall',
  1759. 'Ismall',
  1760. 'Jsmall',
  1761. 'Ksmall',
  1762. 'Lsmall',
  1763. 'Msmall',
  1764. 'Nsmall',
  1765. 'Osmall',
  1766. 'Psmall',
  1767. 'Qsmall',
  1768. 'Rsmall',
  1769. 'Ssmall',
  1770. 'Tsmall',
  1771. 'Usmall',
  1772. 'Vsmall',
  1773. 'Wsmall',
  1774. 'Xsmall',
  1775. 'Ysmall',
  1776. 'Zsmall',
  1777. 'colonmonetary',
  1778. 'onefitted',
  1779. 'rupiah',
  1780. 'Tildesmall',
  1781. '',
  1782. '',
  1783. '',
  1784. '',
  1785. '',
  1786. '',
  1787. '',
  1788. '',
  1789. '',
  1790. '',
  1791. '',
  1792. '',
  1793. '',
  1794. '',
  1795. '',
  1796. '',
  1797. '',
  1798. '',
  1799. '',
  1800. '',
  1801. '',
  1802. '',
  1803. '',
  1804. '',
  1805. '',
  1806. '',
  1807. '',
  1808. '',
  1809. '',
  1810. '',
  1811. '',
  1812. '',
  1813. '',
  1814. '',
  1815. 'exclamdownsmall',
  1816. 'centoldstyle',
  1817. 'Lslashsmall',
  1818. '',
  1819. '',
  1820. 'Scaronsmall',
  1821. 'Zcaronsmall',
  1822. 'Dieresissmall',
  1823. 'Brevesmall',
  1824. 'Caronsmall',
  1825. '',
  1826. 'Dotaccentsmall',
  1827. '',
  1828. '',
  1829. 'Macronsmall',
  1830. '',
  1831. '',
  1832. 'figuredash',
  1833. 'hypheninferior',
  1834. '',
  1835. '',
  1836. 'Ogoneksmall',
  1837. 'Ringsmall',
  1838. 'Cedillasmall',
  1839. '',
  1840. '',
  1841. '',
  1842. 'onequarter',
  1843. 'onehalf',
  1844. 'threequarters',
  1845. 'questiondownsmall',
  1846. 'oneeighth',
  1847. 'threeeighths',
  1848. 'fiveeighths',
  1849. 'seveneighths',
  1850. 'onethird',
  1851. 'twothirds',
  1852. '',
  1853. '',
  1854. 'zerosuperior',
  1855. 'onesuperior',
  1856. 'twosuperior',
  1857. 'threesuperior',
  1858. 'foursuperior',
  1859. 'fivesuperior',
  1860. 'sixsuperior',
  1861. 'sevensuperior',
  1862. 'eightsuperior',
  1863. 'ninesuperior',
  1864. 'zeroinferior',
  1865. 'oneinferior',
  1866. 'twoinferior',
  1867. 'threeinferior',
  1868. 'fourinferior',
  1869. 'fiveinferior',
  1870. 'sixinferior',
  1871. 'seveninferior',
  1872. 'eightinferior',
  1873. 'nineinferior',
  1874. 'centinferior',
  1875. 'dollarinferior',
  1876. 'periodinferior',
  1877. 'commainferior',
  1878. 'Agravesmall',
  1879. 'Aacutesmall',
  1880. 'Acircumflexsmall',
  1881. 'Atildesmall',
  1882. 'Adieresissmall',
  1883. 'Aringsmall',
  1884. 'AEsmall',
  1885. 'Ccedillasmall',
  1886. 'Egravesmall',
  1887. 'Eacutesmall',
  1888. 'Ecircumflexsmall',
  1889. 'Edieresissmall',
  1890. 'Igravesmall',
  1891. 'Iacutesmall',
  1892. 'Icircumflexsmall',
  1893. 'Idieresissmall',
  1894. 'Ethsmall',
  1895. 'Ntildesmall',
  1896. 'Ogravesmall',
  1897. 'Oacutesmall',
  1898. 'Ocircumflexsmall',
  1899. 'Otildesmall',
  1900. 'Odieresissmall',
  1901. 'OEsmall',
  1902. 'Oslashsmall',
  1903. 'Ugravesmall',
  1904. 'Uacutesmall',
  1905. 'Ucircumflexsmall',
  1906. 'Udieresissmall',
  1907. 'Yacutesmall',
  1908. 'Thornsmall',
  1909. 'Ydieresissmall'
  1910. ];
  1911. var MacExpertEncoding = [
  1912. '',
  1913. '',
  1914. '',
  1915. '',
  1916. '',
  1917. '',
  1918. '',
  1919. '',
  1920. '',
  1921. '',
  1922. '',
  1923. '',
  1924. '',
  1925. '',
  1926. '',
  1927. '',
  1928. '',
  1929. '',
  1930. '',
  1931. '',
  1932. '',
  1933. '',
  1934. '',
  1935. '',
  1936. '',
  1937. '',
  1938. '',
  1939. '',
  1940. '',
  1941. '',
  1942. '',
  1943. '',
  1944. 'space',
  1945. 'exclamsmall',
  1946. 'Hungarumlautsmall',
  1947. 'centoldstyle',
  1948. 'dollaroldstyle',
  1949. 'dollarsuperior',
  1950. 'ampersandsmall',
  1951. 'Acutesmall',
  1952. 'parenleftsuperior',
  1953. 'parenrightsuperior',
  1954. 'twodotenleader',
  1955. 'onedotenleader',
  1956. 'comma',
  1957. 'hyphen',
  1958. 'period',
  1959. 'fraction',
  1960. 'zerooldstyle',
  1961. 'oneoldstyle',
  1962. 'twooldstyle',
  1963. 'threeoldstyle',
  1964. 'fouroldstyle',
  1965. 'fiveoldstyle',
  1966. 'sixoldstyle',
  1967. 'sevenoldstyle',
  1968. 'eightoldstyle',
  1969. 'nineoldstyle',
  1970. 'colon',
  1971. 'semicolon',
  1972. '',
  1973. 'threequartersemdash',
  1974. '',
  1975. 'questionsmall',
  1976. '',
  1977. '',
  1978. '',
  1979. '',
  1980. 'Ethsmall',
  1981. '',
  1982. '',
  1983. 'onequarter',
  1984. 'onehalf',
  1985. 'threequarters',
  1986. 'oneeighth',
  1987. 'threeeighths',
  1988. 'fiveeighths',
  1989. 'seveneighths',
  1990. 'onethird',
  1991. 'twothirds',
  1992. '',
  1993. '',
  1994. '',
  1995. '',
  1996. '',
  1997. '',
  1998. 'ff',
  1999. 'fi',
  2000. 'fl',
  2001. 'ffi',
  2002. 'ffl',
  2003. 'parenleftinferior',
  2004. '',
  2005. 'parenrightinferior',
  2006. 'Circumflexsmall',
  2007. 'hypheninferior',
  2008. 'Gravesmall',
  2009. 'Asmall',
  2010. 'Bsmall',
  2011. 'Csmall',
  2012. 'Dsmall',
  2013. 'Esmall',
  2014. 'Fsmall',
  2015. 'Gsmall',
  2016. 'Hsmall',
  2017. 'Ismall',
  2018. 'Jsmall',
  2019. 'Ksmall',
  2020. 'Lsmall',
  2021. 'Msmall',
  2022. 'Nsmall',
  2023. 'Osmall',
  2024. 'Psmall',
  2025. 'Qsmall',
  2026. 'Rsmall',
  2027. 'Ssmall',
  2028. 'Tsmall',
  2029. 'Usmall',
  2030. 'Vsmall',
  2031. 'Wsmall',
  2032. 'Xsmall',
  2033. 'Ysmall',
  2034. 'Zsmall',
  2035. 'colonmonetary',
  2036. 'onefitted',
  2037. 'rupiah',
  2038. 'Tildesmall',
  2039. '',
  2040. '',
  2041. 'asuperior',
  2042. 'centsuperior',
  2043. '',
  2044. '',
  2045. '',
  2046. '',
  2047. 'Aacutesmall',
  2048. 'Agravesmall',
  2049. 'Acircumflexsmall',
  2050. 'Adieresissmall',
  2051. 'Atildesmall',
  2052. 'Aringsmall',
  2053. 'Ccedillasmall',
  2054. 'Eacutesmall',
  2055. 'Egravesmall',
  2056. 'Ecircumflexsmall',
  2057. 'Edieresissmall',
  2058. 'Iacutesmall',
  2059. 'Igravesmall',
  2060. 'Icircumflexsmall',
  2061. 'Idieresissmall',
  2062. 'Ntildesmall',
  2063. 'Oacutesmall',
  2064. 'Ogravesmall',
  2065. 'Ocircumflexsmall',
  2066. 'Odieresissmall',
  2067. 'Otildesmall',
  2068. 'Uacutesmall',
  2069. 'Ugravesmall',
  2070. 'Ucircumflexsmall',
  2071. 'Udieresissmall',
  2072. '',
  2073. 'eightsuperior',
  2074. 'fourinferior',
  2075. 'threeinferior',
  2076. 'sixinferior',
  2077. 'eightinferior',
  2078. 'seveninferior',
  2079. 'Scaronsmall',
  2080. '',
  2081. 'centinferior',
  2082. 'twoinferior',
  2083. '',
  2084. 'Dieresissmall',
  2085. '',
  2086. 'Caronsmall',
  2087. 'osuperior',
  2088. 'fiveinferior',
  2089. '',
  2090. 'commainferior',
  2091. 'periodinferior',
  2092. 'Yacutesmall',
  2093. '',
  2094. 'dollarinferior',
  2095. '',
  2096. 'Thornsmall',
  2097. '',
  2098. 'nineinferior',
  2099. 'zeroinferior',
  2100. 'Zcaronsmall',
  2101. 'AEsmall',
  2102. 'Oslashsmall',
  2103. 'questiondownsmall',
  2104. 'oneinferior',
  2105. 'Lslashsmall',
  2106. '',
  2107. '',
  2108. '',
  2109. '',
  2110. '',
  2111. '',
  2112. 'Cedillasmall',
  2113. '',
  2114. '',
  2115. '',
  2116. '',
  2117. '',
  2118. 'OEsmall',
  2119. 'figuredash',
  2120. 'hyphensuperior',
  2121. '',
  2122. '',
  2123. '',
  2124. '',
  2125. 'exclamdownsmall',
  2126. '',
  2127. 'Ydieresissmall',
  2128. '',
  2129. 'onesuperior',
  2130. 'twosuperior',
  2131. 'threesuperior',
  2132. 'foursuperior',
  2133. 'fivesuperior',
  2134. 'sixsuperior',
  2135. 'sevensuperior',
  2136. 'ninesuperior',
  2137. 'zerosuperior',
  2138. '',
  2139. 'esuperior',
  2140. 'rsuperior',
  2141. 'tsuperior',
  2142. '',
  2143. '',
  2144. 'isuperior',
  2145. 'ssuperior',
  2146. 'dsuperior',
  2147. '',
  2148. '',
  2149. '',
  2150. '',
  2151. '',
  2152. 'lsuperior',
  2153. 'Ogoneksmall',
  2154. 'Brevesmall',
  2155. 'Macronsmall',
  2156. 'bsuperior',
  2157. 'nsuperior',
  2158. 'msuperior',
  2159. 'commasuperior',
  2160. 'periodsuperior',
  2161. 'Dotaccentsmall',
  2162. 'Ringsmall'
  2163. ];
  2164. var MacRomanEncoding = [
  2165. '',
  2166. '',
  2167. '',
  2168. '',
  2169. '',
  2170. '',
  2171. '',
  2172. '',
  2173. '',
  2174. '',
  2175. '',
  2176. '',
  2177. '',
  2178. '',
  2179. '',
  2180. '',
  2181. '',
  2182. '',
  2183. '',
  2184. '',
  2185. '',
  2186. '',
  2187. '',
  2188. '',
  2189. '',
  2190. '',
  2191. '',
  2192. '',
  2193. '',
  2194. '',
  2195. '',
  2196. '',
  2197. 'space',
  2198. 'exclam',
  2199. 'quotedbl',
  2200. 'numbersign',
  2201. 'dollar',
  2202. 'percent',
  2203. 'ampersand',
  2204. 'quotesingle',
  2205. 'parenleft',
  2206. 'parenright',
  2207. 'asterisk',
  2208. 'plus',
  2209. 'comma',
  2210. 'hyphen',
  2211. 'period',
  2212. 'slash',
  2213. 'zero',
  2214. 'one',
  2215. 'two',
  2216. 'three',
  2217. 'four',
  2218. 'five',
  2219. 'six',
  2220. 'seven',
  2221. 'eight',
  2222. 'nine',
  2223. 'colon',
  2224. 'semicolon',
  2225. 'less',
  2226. 'equal',
  2227. 'greater',
  2228. 'question',
  2229. 'at',
  2230. 'A',
  2231. 'B',
  2232. 'C',
  2233. 'D',
  2234. 'E',
  2235. 'F',
  2236. 'G',
  2237. 'H',
  2238. 'I',
  2239. 'J',
  2240. 'K',
  2241. 'L',
  2242. 'M',
  2243. 'N',
  2244. 'O',
  2245. 'P',
  2246. 'Q',
  2247. 'R',
  2248. 'S',
  2249. 'T',
  2250. 'U',
  2251. 'V',
  2252. 'W',
  2253. 'X',
  2254. 'Y',
  2255. 'Z',
  2256. 'bracketleft',
  2257. 'backslash',
  2258. 'bracketright',
  2259. 'asciicircum',
  2260. 'underscore',
  2261. 'grave',
  2262. 'a',
  2263. 'b',
  2264. 'c',
  2265. 'd',
  2266. 'e',
  2267. 'f',
  2268. 'g',
  2269. 'h',
  2270. 'i',
  2271. 'j',
  2272. 'k',
  2273. 'l',
  2274. 'm',
  2275. 'n',
  2276. 'o',
  2277. 'p',
  2278. 'q',
  2279. 'r',
  2280. 's',
  2281. 't',
  2282. 'u',
  2283. 'v',
  2284. 'w',
  2285. 'x',
  2286. 'y',
  2287. 'z',
  2288. 'braceleft',
  2289. 'bar',
  2290. 'braceright',
  2291. 'asciitilde',
  2292. '',
  2293. 'Adieresis',
  2294. 'Aring',
  2295. 'Ccedilla',
  2296. 'Eacute',
  2297. 'Ntilde',
  2298. 'Odieresis',
  2299. 'Udieresis',
  2300. 'aacute',
  2301. 'agrave',
  2302. 'acircumflex',
  2303. 'adieresis',
  2304. 'atilde',
  2305. 'aring',
  2306. 'ccedilla',
  2307. 'eacute',
  2308. 'egrave',
  2309. 'ecircumflex',
  2310. 'edieresis',
  2311. 'iacute',
  2312. 'igrave',
  2313. 'icircumflex',
  2314. 'idieresis',
  2315. 'ntilde',
  2316. 'oacute',
  2317. 'ograve',
  2318. 'ocircumflex',
  2319. 'odieresis',
  2320. 'otilde',
  2321. 'uacute',
  2322. 'ugrave',
  2323. 'ucircumflex',
  2324. 'udieresis',
  2325. 'dagger',
  2326. 'degree',
  2327. 'cent',
  2328. 'sterling',
  2329. 'section',
  2330. 'bullet',
  2331. 'paragraph',
  2332. 'germandbls',
  2333. 'registered',
  2334. 'copyright',
  2335. 'trademark',
  2336. 'acute',
  2337. 'dieresis',
  2338. 'notequal',
  2339. 'AE',
  2340. 'Oslash',
  2341. 'infinity',
  2342. 'plusminus',
  2343. 'lessequal',
  2344. 'greaterequal',
  2345. 'yen',
  2346. 'mu',
  2347. 'partialdiff',
  2348. 'summation',
  2349. 'product',
  2350. 'pi',
  2351. 'integral',
  2352. 'ordfeminine',
  2353. 'ordmasculine',
  2354. 'Omega',
  2355. 'ae',
  2356. 'oslash',
  2357. 'questiondown',
  2358. 'exclamdown',
  2359. 'logicalnot',
  2360. 'radical',
  2361. 'florin',
  2362. 'approxequal',
  2363. 'Delta',
  2364. 'guillemotleft',
  2365. 'guillemotright',
  2366. 'ellipsis',
  2367. 'space',
  2368. 'Agrave',
  2369. 'Atilde',
  2370. 'Otilde',
  2371. 'OE',
  2372. 'oe',
  2373. 'endash',
  2374. 'emdash',
  2375. 'quotedblleft',
  2376. 'quotedblright',
  2377. 'quoteleft',
  2378. 'quoteright',
  2379. 'divide',
  2380. 'lozenge',
  2381. 'ydieresis',
  2382. 'Ydieresis',
  2383. 'fraction',
  2384. 'currency',
  2385. 'guilsinglleft',
  2386. 'guilsinglright',
  2387. 'fi',
  2388. 'fl',
  2389. 'daggerdbl',
  2390. 'periodcentered',
  2391. 'quotesinglbase',
  2392. 'quotedblbase',
  2393. 'perthousand',
  2394. 'Acircumflex',
  2395. 'Ecircumflex',
  2396. 'Aacute',
  2397. 'Edieresis',
  2398. 'Egrave',
  2399. 'Iacute',
  2400. 'Icircumflex',
  2401. 'Idieresis',
  2402. 'Igrave',
  2403. 'Oacute',
  2404. 'Ocircumflex',
  2405. 'apple',
  2406. 'Ograve',
  2407. 'Uacute',
  2408. 'Ucircumflex',
  2409. 'Ugrave',
  2410. 'dotlessi',
  2411. 'circumflex',
  2412. 'tilde',
  2413. 'macron',
  2414. 'breve',
  2415. 'dotaccent',
  2416. 'ring',
  2417. 'cedilla',
  2418. 'hungarumlaut',
  2419. 'ogonek',
  2420. 'caron'
  2421. ];
  2422. var StandardEncoding = [
  2423. '',
  2424. '',
  2425. '',
  2426. '',
  2427. '',
  2428. '',
  2429. '',
  2430. '',
  2431. '',
  2432. '',
  2433. '',
  2434. '',
  2435. '',
  2436. '',
  2437. '',
  2438. '',
  2439. '',
  2440. '',
  2441. '',
  2442. '',
  2443. '',
  2444. '',
  2445. '',
  2446. '',
  2447. '',
  2448. '',
  2449. '',
  2450. '',
  2451. '',
  2452. '',
  2453. '',
  2454. '',
  2455. 'space',
  2456. 'exclam',
  2457. 'quotedbl',
  2458. 'numbersign',
  2459. 'dollar',
  2460. 'percent',
  2461. 'ampersand',
  2462. 'quoteright',
  2463. 'parenleft',
  2464. 'parenright',
  2465. 'asterisk',
  2466. 'plus',
  2467. 'comma',
  2468. 'hyphen',
  2469. 'period',
  2470. 'slash',
  2471. 'zero',
  2472. 'one',
  2473. 'two',
  2474. 'three',
  2475. 'four',
  2476. 'five',
  2477. 'six',
  2478. 'seven',
  2479. 'eight',
  2480. 'nine',
  2481. 'colon',
  2482. 'semicolon',
  2483. 'less',
  2484. 'equal',
  2485. 'greater',
  2486. 'question',
  2487. 'at',
  2488. 'A',
  2489. 'B',
  2490. 'C',
  2491. 'D',
  2492. 'E',
  2493. 'F',
  2494. 'G',
  2495. 'H',
  2496. 'I',
  2497. 'J',
  2498. 'K',
  2499. 'L',
  2500. 'M',
  2501. 'N',
  2502. 'O',
  2503. 'P',
  2504. 'Q',
  2505. 'R',
  2506. 'S',
  2507. 'T',
  2508. 'U',
  2509. 'V',
  2510. 'W',
  2511. 'X',
  2512. 'Y',
  2513. 'Z',
  2514. 'bracketleft',
  2515. 'backslash',
  2516. 'bracketright',
  2517. 'asciicircum',
  2518. 'underscore',
  2519. 'quoteleft',
  2520. 'a',
  2521. 'b',
  2522. 'c',
  2523. 'd',
  2524. 'e',
  2525. 'f',
  2526. 'g',
  2527. 'h',
  2528. 'i',
  2529. 'j',
  2530. 'k',
  2531. 'l',
  2532. 'm',
  2533. 'n',
  2534. 'o',
  2535. 'p',
  2536. 'q',
  2537. 'r',
  2538. 's',
  2539. 't',
  2540. 'u',
  2541. 'v',
  2542. 'w',
  2543. 'x',
  2544. 'y',
  2545. 'z',
  2546. 'braceleft',
  2547. 'bar',
  2548. 'braceright',
  2549. 'asciitilde',
  2550. '',
  2551. '',
  2552. '',
  2553. '',
  2554. '',
  2555. '',
  2556. '',
  2557. '',
  2558. '',
  2559. '',
  2560. '',
  2561. '',
  2562. '',
  2563. '',
  2564. '',
  2565. '',
  2566. '',
  2567. '',
  2568. '',
  2569. '',
  2570. '',
  2571. '',
  2572. '',
  2573. '',
  2574. '',
  2575. '',
  2576. '',
  2577. '',
  2578. '',
  2579. '',
  2580. '',
  2581. '',
  2582. '',
  2583. '',
  2584. 'exclamdown',
  2585. 'cent',
  2586. 'sterling',
  2587. 'fraction',
  2588. 'yen',
  2589. 'florin',
  2590. 'section',
  2591. 'currency',
  2592. 'quotesingle',
  2593. 'quotedblleft',
  2594. 'guillemotleft',
  2595. 'guilsinglleft',
  2596. 'guilsinglright',
  2597. 'fi',
  2598. 'fl',
  2599. '',
  2600. 'endash',
  2601. 'dagger',
  2602. 'daggerdbl',
  2603. 'periodcentered',
  2604. '',
  2605. 'paragraph',
  2606. 'bullet',
  2607. 'quotesinglbase',
  2608. 'quotedblbase',
  2609. 'quotedblright',
  2610. 'guillemotright',
  2611. 'ellipsis',
  2612. 'perthousand',
  2613. '',
  2614. 'questiondown',
  2615. '',
  2616. 'grave',
  2617. 'acute',
  2618. 'circumflex',
  2619. 'tilde',
  2620. 'macron',
  2621. 'breve',
  2622. 'dotaccent',
  2623. 'dieresis',
  2624. '',
  2625. 'ring',
  2626. 'cedilla',
  2627. '',
  2628. 'hungarumlaut',
  2629. 'ogonek',
  2630. 'caron',
  2631. 'emdash',
  2632. '',
  2633. '',
  2634. '',
  2635. '',
  2636. '',
  2637. '',
  2638. '',
  2639. '',
  2640. '',
  2641. '',
  2642. '',
  2643. '',
  2644. '',
  2645. '',
  2646. '',
  2647. '',
  2648. 'AE',
  2649. '',
  2650. 'ordfeminine',
  2651. '',
  2652. '',
  2653. '',
  2654. '',
  2655. 'Lslash',
  2656. 'Oslash',
  2657. 'OE',
  2658. 'ordmasculine',
  2659. '',
  2660. '',
  2661. '',
  2662. '',
  2663. '',
  2664. 'ae',
  2665. '',
  2666. '',
  2667. '',
  2668. 'dotlessi',
  2669. '',
  2670. '',
  2671. 'lslash',
  2672. 'oslash',
  2673. 'oe',
  2674. 'germandbls'
  2675. ];
  2676. var WinAnsiEncoding = [
  2677. '',
  2678. '',
  2679. '',
  2680. '',
  2681. '',
  2682. '',
  2683. '',
  2684. '',
  2685. '',
  2686. '',
  2687. '',
  2688. '',
  2689. '',
  2690. '',
  2691. '',
  2692. '',
  2693. '',
  2694. '',
  2695. '',
  2696. '',
  2697. '',
  2698. '',
  2699. '',
  2700. '',
  2701. '',
  2702. '',
  2703. '',
  2704. '',
  2705. '',
  2706. '',
  2707. '',
  2708. '',
  2709. 'space',
  2710. 'exclam',
  2711. 'quotedbl',
  2712. 'numbersign',
  2713. 'dollar',
  2714. 'percent',
  2715. 'ampersand',
  2716. 'quotesingle',
  2717. 'parenleft',
  2718. 'parenright',
  2719. 'asterisk',
  2720. 'plus',
  2721. 'comma',
  2722. 'hyphen',
  2723. 'period',
  2724. 'slash',
  2725. 'zero',
  2726. 'one',
  2727. 'two',
  2728. 'three',
  2729. 'four',
  2730. 'five',
  2731. 'six',
  2732. 'seven',
  2733. 'eight',
  2734. 'nine',
  2735. 'colon',
  2736. 'semicolon',
  2737. 'less',
  2738. 'equal',
  2739. 'greater',
  2740. 'question',
  2741. 'at',
  2742. 'A',
  2743. 'B',
  2744. 'C',
  2745. 'D',
  2746. 'E',
  2747. 'F',
  2748. 'G',
  2749. 'H',
  2750. 'I',
  2751. 'J',
  2752. 'K',
  2753. 'L',
  2754. 'M',
  2755. 'N',
  2756. 'O',
  2757. 'P',
  2758. 'Q',
  2759. 'R',
  2760. 'S',
  2761. 'T',
  2762. 'U',
  2763. 'V',
  2764. 'W',
  2765. 'X',
  2766. 'Y',
  2767. 'Z',
  2768. 'bracketleft',
  2769. 'backslash',
  2770. 'bracketright',
  2771. 'asciicircum',
  2772. 'underscore',
  2773. 'grave',
  2774. 'a',
  2775. 'b',
  2776. 'c',
  2777. 'd',
  2778. 'e',
  2779. 'f',
  2780. 'g',
  2781. 'h',
  2782. 'i',
  2783. 'j',
  2784. 'k',
  2785. 'l',
  2786. 'm',
  2787. 'n',
  2788. 'o',
  2789. 'p',
  2790. 'q',
  2791. 'r',
  2792. 's',
  2793. 't',
  2794. 'u',
  2795. 'v',
  2796. 'w',
  2797. 'x',
  2798. 'y',
  2799. 'z',
  2800. 'braceleft',
  2801. 'bar',
  2802. 'braceright',
  2803. 'asciitilde',
  2804. 'bullet',
  2805. 'Euro',
  2806. 'bullet',
  2807. 'quotesinglbase',
  2808. 'florin',
  2809. 'quotedblbase',
  2810. 'ellipsis',
  2811. 'dagger',
  2812. 'daggerdbl',
  2813. 'circumflex',
  2814. 'perthousand',
  2815. 'Scaron',
  2816. 'guilsinglleft',
  2817. 'OE',
  2818. 'bullet',
  2819. 'Zcaron',
  2820. 'bullet',
  2821. 'bullet',
  2822. 'quoteleft',
  2823. 'quoteright',
  2824. 'quotedblleft',
  2825. 'quotedblright',
  2826. 'bullet',
  2827. 'endash',
  2828. 'emdash',
  2829. 'tilde',
  2830. 'trademark',
  2831. 'scaron',
  2832. 'guilsinglright',
  2833. 'oe',
  2834. 'bullet',
  2835. 'zcaron',
  2836. 'Ydieresis',
  2837. 'space',
  2838. 'exclamdown',
  2839. 'cent',
  2840. 'sterling',
  2841. 'currency',
  2842. 'yen',
  2843. 'brokenbar',
  2844. 'section',
  2845. 'dieresis',
  2846. 'copyright',
  2847. 'ordfeminine',
  2848. 'guillemotleft',
  2849. 'logicalnot',
  2850. 'hyphen',
  2851. 'registered',
  2852. 'macron',
  2853. 'degree',
  2854. 'plusminus',
  2855. 'twosuperior',
  2856. 'threesuperior',
  2857. 'acute',
  2858. 'mu',
  2859. 'paragraph',
  2860. 'periodcentered',
  2861. 'cedilla',
  2862. 'onesuperior',
  2863. 'ordmasculine',
  2864. 'guillemotright',
  2865. 'onequarter',
  2866. 'onehalf',
  2867. 'threequarters',
  2868. 'questiondown',
  2869. 'Agrave',
  2870. 'Aacute',
  2871. 'Acircumflex',
  2872. 'Atilde',
  2873. 'Adieresis',
  2874. 'Aring',
  2875. 'AE',
  2876. 'Ccedilla',
  2877. 'Egrave',
  2878. 'Eacute',
  2879. 'Ecircumflex',
  2880. 'Edieresis',
  2881. 'Igrave',
  2882. 'Iacute',
  2883. 'Icircumflex',
  2884. 'Idieresis',
  2885. 'Eth',
  2886. 'Ntilde',
  2887. 'Ograve',
  2888. 'Oacute',
  2889. 'Ocircumflex',
  2890. 'Otilde',
  2891. 'Odieresis',
  2892. 'multiply',
  2893. 'Oslash',
  2894. 'Ugrave',
  2895. 'Uacute',
  2896. 'Ucircumflex',
  2897. 'Udieresis',
  2898. 'Yacute',
  2899. 'Thorn',
  2900. 'germandbls',
  2901. 'agrave',
  2902. 'aacute',
  2903. 'acircumflex',
  2904. 'atilde',
  2905. 'adieresis',
  2906. 'aring',
  2907. 'ae',
  2908. 'ccedilla',
  2909. 'egrave',
  2910. 'eacute',
  2911. 'ecircumflex',
  2912. 'edieresis',
  2913. 'igrave',
  2914. 'iacute',
  2915. 'icircumflex',
  2916. 'idieresis',
  2917. 'eth',
  2918. 'ntilde',
  2919. 'ograve',
  2920. 'oacute',
  2921. 'ocircumflex',
  2922. 'otilde',
  2923. 'odieresis',
  2924. 'divide',
  2925. 'oslash',
  2926. 'ugrave',
  2927. 'uacute',
  2928. 'ucircumflex',
  2929. 'udieresis',
  2930. 'yacute',
  2931. 'thorn',
  2932. 'ydieresis'
  2933. ];
  2934. var SymbolSetEncoding = [
  2935. '',
  2936. '',
  2937. '',
  2938. '',
  2939. '',
  2940. '',
  2941. '',
  2942. '',
  2943. '',
  2944. '',
  2945. '',
  2946. '',
  2947. '',
  2948. '',
  2949. '',
  2950. '',
  2951. '',
  2952. '',
  2953. '',
  2954. '',
  2955. '',
  2956. '',
  2957. '',
  2958. '',
  2959. '',
  2960. '',
  2961. '',
  2962. '',
  2963. '',
  2964. '',
  2965. '',
  2966. '',
  2967. 'space',
  2968. 'exclam',
  2969. 'universal',
  2970. 'numbersign',
  2971. 'existential',
  2972. 'percent',
  2973. 'ampersand',
  2974. 'suchthat',
  2975. 'parenleft',
  2976. 'parenright',
  2977. 'asteriskmath',
  2978. 'plus',
  2979. 'comma',
  2980. 'minus',
  2981. 'period',
  2982. 'slash',
  2983. 'zero',
  2984. 'one',
  2985. 'two',
  2986. 'three',
  2987. 'four',
  2988. 'five',
  2989. 'six',
  2990. 'seven',
  2991. 'eight',
  2992. 'nine',
  2993. 'colon',
  2994. 'semicolon',
  2995. 'less',
  2996. 'equal',
  2997. 'greater',
  2998. 'question',
  2999. 'congruent',
  3000. 'Alpha',
  3001. 'Beta',
  3002. 'Chi',
  3003. 'Delta',
  3004. 'Epsilon',
  3005. 'Phi',
  3006. 'Gamma',
  3007. 'Eta',
  3008. 'Iota',
  3009. 'theta1',
  3010. 'Kappa',
  3011. 'Lambda',
  3012. 'Mu',
  3013. 'Nu',
  3014. 'Omicron',
  3015. 'Pi',
  3016. 'Theta',
  3017. 'Rho',
  3018. 'Sigma',
  3019. 'Tau',
  3020. 'Upsilon',
  3021. 'sigma1',
  3022. 'Omega',
  3023. 'Xi',
  3024. 'Psi',
  3025. 'Zeta',
  3026. 'bracketleft',
  3027. 'therefore',
  3028. 'bracketright',
  3029. 'perpendicular',
  3030. 'underscore',
  3031. 'radicalex',
  3032. 'alpha',
  3033. 'beta',
  3034. 'chi',
  3035. 'delta',
  3036. 'epsilon',
  3037. 'phi',
  3038. 'gamma',
  3039. 'eta',
  3040. 'iota',
  3041. 'phi1',
  3042. 'kappa',
  3043. 'lambda',
  3044. 'mu',
  3045. 'nu',
  3046. 'omicron',
  3047. 'pi',
  3048. 'theta',
  3049. 'rho',
  3050. 'sigma',
  3051. 'tau',
  3052. 'upsilon',
  3053. 'omega1',
  3054. 'omega',
  3055. 'xi',
  3056. 'psi',
  3057. 'zeta',
  3058. 'braceleft',
  3059. 'bar',
  3060. 'braceright',
  3061. 'similar',
  3062. '',
  3063. '',
  3064. '',
  3065. '',
  3066. '',
  3067. '',
  3068. '',
  3069. '',
  3070. '',
  3071. '',
  3072. '',
  3073. '',
  3074. '',
  3075. '',
  3076. '',
  3077. '',
  3078. '',
  3079. '',
  3080. '',
  3081. '',
  3082. '',
  3083. '',
  3084. '',
  3085. '',
  3086. '',
  3087. '',
  3088. '',
  3089. '',
  3090. '',
  3091. '',
  3092. '',
  3093. '',
  3094. '',
  3095. 'Euro',
  3096. 'Upsilon1',
  3097. 'minute',
  3098. 'lessequal',
  3099. 'fraction',
  3100. 'infinity',
  3101. 'florin',
  3102. 'club',
  3103. 'diamond',
  3104. 'heart',
  3105. 'spade',
  3106. 'arrowboth',
  3107. 'arrowleft',
  3108. 'arrowup',
  3109. 'arrowright',
  3110. 'arrowdown',
  3111. 'degree',
  3112. 'plusminus',
  3113. 'second',
  3114. 'greaterequal',
  3115. 'multiply',
  3116. 'proportional',
  3117. 'partialdiff',
  3118. 'bullet',
  3119. 'divide',
  3120. 'notequal',
  3121. 'equivalence',
  3122. 'approxequal',
  3123. 'ellipsis',
  3124. 'arrowvertex',
  3125. 'arrowhorizex',
  3126. 'carriagereturn',
  3127. 'aleph',
  3128. 'Ifraktur',
  3129. 'Rfraktur',
  3130. 'weierstrass',
  3131. 'circlemultiply',
  3132. 'circleplus',
  3133. 'emptyset',
  3134. 'intersection',
  3135. 'union',
  3136. 'propersuperset',
  3137. 'reflexsuperset',
  3138. 'notsubset',
  3139. 'propersubset',
  3140. 'reflexsubset',
  3141. 'element',
  3142. 'notelement',
  3143. 'angle',
  3144. 'gradient',
  3145. 'registerserif',
  3146. 'copyrightserif',
  3147. 'trademarkserif',
  3148. 'product',
  3149. 'radical',
  3150. 'dotmath',
  3151. 'logicalnot',
  3152. 'logicaland',
  3153. 'logicalor',
  3154. 'arrowdblboth',
  3155. 'arrowdblleft',
  3156. 'arrowdblup',
  3157. 'arrowdblright',
  3158. 'arrowdbldown',
  3159. 'lozenge',
  3160. 'angleleft',
  3161. 'registersans',
  3162. 'copyrightsans',
  3163. 'trademarksans',
  3164. 'summation',
  3165. 'parenlefttp',
  3166. 'parenleftex',
  3167. 'parenleftbt',
  3168. 'bracketlefttp',
  3169. 'bracketleftex',
  3170. 'bracketleftbt',
  3171. 'bracelefttp',
  3172. 'braceleftmid',
  3173. 'braceleftbt',
  3174. 'braceex',
  3175. '',
  3176. 'angleright',
  3177. 'integral',
  3178. 'integraltp',
  3179. 'integralex',
  3180. 'integralbt',
  3181. 'parenrighttp',
  3182. 'parenrightex',
  3183. 'parenrightbt',
  3184. 'bracketrighttp',
  3185. 'bracketrightex',
  3186. 'bracketrightbt',
  3187. 'bracerighttp',
  3188. 'bracerightmid',
  3189. 'bracerightbt'
  3190. ];
  3191. var ZapfDingbatsEncoding = [
  3192. '',
  3193. '',
  3194. '',
  3195. '',
  3196. '',
  3197. '',
  3198. '',
  3199. '',
  3200. '',
  3201. '',
  3202. '',
  3203. '',
  3204. '',
  3205. '',
  3206. '',
  3207. '',
  3208. '',
  3209. '',
  3210. '',
  3211. '',
  3212. '',
  3213. '',
  3214. '',
  3215. '',
  3216. '',
  3217. '',
  3218. '',
  3219. '',
  3220. '',
  3221. '',
  3222. '',
  3223. '',
  3224. 'space',
  3225. 'a1',
  3226. 'a2',
  3227. 'a202',
  3228. 'a3',
  3229. 'a4',
  3230. 'a5',
  3231. 'a119',
  3232. 'a118',
  3233. 'a117',
  3234. 'a11',
  3235. 'a12',
  3236. 'a13',
  3237. 'a14',
  3238. 'a15',
  3239. 'a16',
  3240. 'a105',
  3241. 'a17',
  3242. 'a18',
  3243. 'a19',
  3244. 'a20',
  3245. 'a21',
  3246. 'a22',
  3247. 'a23',
  3248. 'a24',
  3249. 'a25',
  3250. 'a26',
  3251. 'a27',
  3252. 'a28',
  3253. 'a6',
  3254. 'a7',
  3255. 'a8',
  3256. 'a9',
  3257. 'a10',
  3258. 'a29',
  3259. 'a30',
  3260. 'a31',
  3261. 'a32',
  3262. 'a33',
  3263. 'a34',
  3264. 'a35',
  3265. 'a36',
  3266. 'a37',
  3267. 'a38',
  3268. 'a39',
  3269. 'a40',
  3270. 'a41',
  3271. 'a42',
  3272. 'a43',
  3273. 'a44',
  3274. 'a45',
  3275. 'a46',
  3276. 'a47',
  3277. 'a48',
  3278. 'a49',
  3279. 'a50',
  3280. 'a51',
  3281. 'a52',
  3282. 'a53',
  3283. 'a54',
  3284. 'a55',
  3285. 'a56',
  3286. 'a57',
  3287. 'a58',
  3288. 'a59',
  3289. 'a60',
  3290. 'a61',
  3291. 'a62',
  3292. 'a63',
  3293. 'a64',
  3294. 'a65',
  3295. 'a66',
  3296. 'a67',
  3297. 'a68',
  3298. 'a69',
  3299. 'a70',
  3300. 'a71',
  3301. 'a72',
  3302. 'a73',
  3303. 'a74',
  3304. 'a203',
  3305. 'a75',
  3306. 'a204',
  3307. 'a76',
  3308. 'a77',
  3309. 'a78',
  3310. 'a79',
  3311. 'a81',
  3312. 'a82',
  3313. 'a83',
  3314. 'a84',
  3315. 'a97',
  3316. 'a98',
  3317. 'a99',
  3318. 'a100',
  3319. '',
  3320. 'a89',
  3321. 'a90',
  3322. 'a93',
  3323. 'a94',
  3324. 'a91',
  3325. 'a92',
  3326. 'a205',
  3327. 'a85',
  3328. 'a206',
  3329. 'a86',
  3330. 'a87',
  3331. 'a88',
  3332. 'a95',
  3333. 'a96',
  3334. '',
  3335. '',
  3336. '',
  3337. '',
  3338. '',
  3339. '',
  3340. '',
  3341. '',
  3342. '',
  3343. '',
  3344. '',
  3345. '',
  3346. '',
  3347. '',
  3348. '',
  3349. '',
  3350. '',
  3351. '',
  3352. '',
  3353. 'a101',
  3354. 'a102',
  3355. 'a103',
  3356. 'a104',
  3357. 'a106',
  3358. 'a107',
  3359. 'a108',
  3360. 'a112',
  3361. 'a111',
  3362. 'a110',
  3363. 'a109',
  3364. 'a120',
  3365. 'a121',
  3366. 'a122',
  3367. 'a123',
  3368. 'a124',
  3369. 'a125',
  3370. 'a126',
  3371. 'a127',
  3372. 'a128',
  3373. 'a129',
  3374. 'a130',
  3375. 'a131',
  3376. 'a132',
  3377. 'a133',
  3378. 'a134',
  3379. 'a135',
  3380. 'a136',
  3381. 'a137',
  3382. 'a138',
  3383. 'a139',
  3384. 'a140',
  3385. 'a141',
  3386. 'a142',
  3387. 'a143',
  3388. 'a144',
  3389. 'a145',
  3390. 'a146',
  3391. 'a147',
  3392. 'a148',
  3393. 'a149',
  3394. 'a150',
  3395. 'a151',
  3396. 'a152',
  3397. 'a153',
  3398. 'a154',
  3399. 'a155',
  3400. 'a156',
  3401. 'a157',
  3402. 'a158',
  3403. 'a159',
  3404. 'a160',
  3405. 'a161',
  3406. 'a163',
  3407. 'a164',
  3408. 'a196',
  3409. 'a165',
  3410. 'a192',
  3411. 'a166',
  3412. 'a167',
  3413. 'a168',
  3414. 'a169',
  3415. 'a170',
  3416. 'a171',
  3417. 'a172',
  3418. 'a173',
  3419. 'a162',
  3420. 'a174',
  3421. 'a175',
  3422. 'a176',
  3423. 'a177',
  3424. 'a178',
  3425. 'a179',
  3426. 'a193',
  3427. 'a180',
  3428. 'a199',
  3429. 'a181',
  3430. 'a200',
  3431. 'a182',
  3432. '',
  3433. 'a201',
  3434. 'a183',
  3435. 'a184',
  3436. 'a197',
  3437. 'a185',
  3438. 'a194',
  3439. 'a198',
  3440. 'a186',
  3441. 'a195',
  3442. 'a187',
  3443. 'a188',
  3444. 'a189',
  3445. 'a190',
  3446. 'a191'
  3447. ];
  3448. function getEncoding(encodingName) {
  3449. switch (encodingName) {
  3450. case 'WinAnsiEncoding':
  3451. return WinAnsiEncoding;
  3452. case 'StandardEncoding':
  3453. return StandardEncoding;
  3454. case 'MacRomanEncoding':
  3455. return MacRomanEncoding;
  3456. case 'SymbolSetEncoding':
  3457. return SymbolSetEncoding;
  3458. case 'ZapfDingbatsEncoding':
  3459. return ZapfDingbatsEncoding;
  3460. case 'ExpertEncoding':
  3461. return ExpertEncoding;
  3462. case 'MacExpertEncoding':
  3463. return MacExpertEncoding;
  3464. default:
  3465. return null;
  3466. }
  3467. }
  3468. exports.WinAnsiEncoding = WinAnsiEncoding;
  3469. exports.StandardEncoding = StandardEncoding;
  3470. exports.MacRomanEncoding = MacRomanEncoding;
  3471. exports.SymbolSetEncoding = SymbolSetEncoding;
  3472. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  3473. exports.ExpertEncoding = ExpertEncoding;
  3474. exports.getEncoding = getEncoding;
  3475. }));
  3476. (function (root, factory) {
  3477. factory(root.pdfjsSharedUtil = {});
  3478. }(this, function (exports) {
  3479. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  3480. var FONT_IDENTITY_MATRIX = [
  3481. 0.001,
  3482. 0,
  3483. 0,
  3484. 0.001,
  3485. 0,
  3486. 0
  3487. ];
  3488. var TextRenderingMode = {
  3489. FILL: 0,
  3490. STROKE: 1,
  3491. FILL_STROKE: 2,
  3492. INVISIBLE: 3,
  3493. FILL_ADD_TO_PATH: 4,
  3494. STROKE_ADD_TO_PATH: 5,
  3495. FILL_STROKE_ADD_TO_PATH: 6,
  3496. ADD_TO_PATH: 7,
  3497. FILL_STROKE_MASK: 3,
  3498. ADD_TO_PATH_FLAG: 4
  3499. };
  3500. var ImageKind = {
  3501. GRAYSCALE_1BPP: 1,
  3502. RGB_24BPP: 2,
  3503. RGBA_32BPP: 3
  3504. };
  3505. var AnnotationType = {
  3506. TEXT: 1,
  3507. LINK: 2,
  3508. FREETEXT: 3,
  3509. LINE: 4,
  3510. SQUARE: 5,
  3511. CIRCLE: 6,
  3512. POLYGON: 7,
  3513. POLYLINE: 8,
  3514. HIGHLIGHT: 9,
  3515. UNDERLINE: 10,
  3516. SQUIGGLY: 11,
  3517. STRIKEOUT: 12,
  3518. STAMP: 13,
  3519. CARET: 14,
  3520. INK: 15,
  3521. POPUP: 16,
  3522. FILEATTACHMENT: 17,
  3523. SOUND: 18,
  3524. MOVIE: 19,
  3525. WIDGET: 20,
  3526. SCREEN: 21,
  3527. PRINTERMARK: 22,
  3528. TRAPNET: 23,
  3529. WATERMARK: 24,
  3530. THREED: 25,
  3531. REDACT: 26
  3532. };
  3533. var AnnotationFlag = {
  3534. INVISIBLE: 0x01,
  3535. HIDDEN: 0x02,
  3536. PRINT: 0x04,
  3537. NOZOOM: 0x08,
  3538. NOROTATE: 0x10,
  3539. NOVIEW: 0x20,
  3540. READONLY: 0x40,
  3541. LOCKED: 0x80,
  3542. TOGGLENOVIEW: 0x100,
  3543. LOCKEDCONTENTS: 0x200
  3544. };
  3545. var AnnotationFieldFlag = {
  3546. READONLY: 0x0000001,
  3547. REQUIRED: 0x0000002,
  3548. NOEXPORT: 0x0000004,
  3549. MULTILINE: 0x0001000,
  3550. PASSWORD: 0x0002000,
  3551. NOTOGGLETOOFF: 0x0004000,
  3552. RADIO: 0x0008000,
  3553. PUSHBUTTON: 0x0010000,
  3554. COMBO: 0x0020000,
  3555. EDIT: 0x0040000,
  3556. SORT: 0x0080000,
  3557. FILESELECT: 0x0100000,
  3558. MULTISELECT: 0x0200000,
  3559. DONOTSPELLCHECK: 0x0400000,
  3560. DONOTSCROLL: 0x0800000,
  3561. COMB: 0x1000000,
  3562. RICHTEXT: 0x2000000,
  3563. RADIOSINUNISON: 0x2000000,
  3564. COMMITONSELCHANGE: 0x4000000
  3565. };
  3566. var AnnotationBorderStyleType = {
  3567. SOLID: 1,
  3568. DASHED: 2,
  3569. BEVELED: 3,
  3570. INSET: 4,
  3571. UNDERLINE: 5
  3572. };
  3573. var StreamType = {
  3574. UNKNOWN: 0,
  3575. FLATE: 1,
  3576. LZW: 2,
  3577. DCT: 3,
  3578. JPX: 4,
  3579. JBIG: 5,
  3580. A85: 6,
  3581. AHX: 7,
  3582. CCF: 8,
  3583. RL: 9
  3584. };
  3585. var FontType = {
  3586. UNKNOWN: 0,
  3587. TYPE1: 1,
  3588. TYPE1C: 2,
  3589. CIDFONTTYPE0: 3,
  3590. CIDFONTTYPE0C: 4,
  3591. TRUETYPE: 5,
  3592. CIDFONTTYPE2: 6,
  3593. TYPE3: 7,
  3594. OPENTYPE: 8,
  3595. TYPE0: 9,
  3596. MMTYPE1: 10
  3597. };
  3598. var VERBOSITY_LEVELS = {
  3599. errors: 0,
  3600. warnings: 1,
  3601. infos: 5
  3602. };
  3603. var OPS = {
  3604. dependency: 1,
  3605. setLineWidth: 2,
  3606. setLineCap: 3,
  3607. setLineJoin: 4,
  3608. setMiterLimit: 5,
  3609. setDash: 6,
  3610. setRenderingIntent: 7,
  3611. setFlatness: 8,
  3612. setGState: 9,
  3613. save: 10,
  3614. restore: 11,
  3615. transform: 12,
  3616. moveTo: 13,
  3617. lineTo: 14,
  3618. curveTo: 15,
  3619. curveTo2: 16,
  3620. curveTo3: 17,
  3621. closePath: 18,
  3622. rectangle: 19,
  3623. stroke: 20,
  3624. closeStroke: 21,
  3625. fill: 22,
  3626. eoFill: 23,
  3627. fillStroke: 24,
  3628. eoFillStroke: 25,
  3629. closeFillStroke: 26,
  3630. closeEOFillStroke: 27,
  3631. endPath: 28,
  3632. clip: 29,
  3633. eoClip: 30,
  3634. beginText: 31,
  3635. endText: 32,
  3636. setCharSpacing: 33,
  3637. setWordSpacing: 34,
  3638. setHScale: 35,
  3639. setLeading: 36,
  3640. setFont: 37,
  3641. setTextRenderingMode: 38,
  3642. setTextRise: 39,
  3643. moveText: 40,
  3644. setLeadingMoveText: 41,
  3645. setTextMatrix: 42,
  3646. nextLine: 43,
  3647. showText: 44,
  3648. showSpacedText: 45,
  3649. nextLineShowText: 46,
  3650. nextLineSetSpacingShowText: 47,
  3651. setCharWidth: 48,
  3652. setCharWidthAndBounds: 49,
  3653. setStrokeColorSpace: 50,
  3654. setFillColorSpace: 51,
  3655. setStrokeColor: 52,
  3656. setStrokeColorN: 53,
  3657. setFillColor: 54,
  3658. setFillColorN: 55,
  3659. setStrokeGray: 56,
  3660. setFillGray: 57,
  3661. setStrokeRGBColor: 58,
  3662. setFillRGBColor: 59,
  3663. setStrokeCMYKColor: 60,
  3664. setFillCMYKColor: 61,
  3665. shadingFill: 62,
  3666. beginInlineImage: 63,
  3667. beginImageData: 64,
  3668. endInlineImage: 65,
  3669. paintXObject: 66,
  3670. markPoint: 67,
  3671. markPointProps: 68,
  3672. beginMarkedContent: 69,
  3673. beginMarkedContentProps: 70,
  3674. endMarkedContent: 71,
  3675. beginCompat: 72,
  3676. endCompat: 73,
  3677. paintFormXObjectBegin: 74,
  3678. paintFormXObjectEnd: 75,
  3679. beginGroup: 76,
  3680. endGroup: 77,
  3681. beginAnnotations: 78,
  3682. endAnnotations: 79,
  3683. beginAnnotation: 80,
  3684. endAnnotation: 81,
  3685. paintJpegXObject: 82,
  3686. paintImageMaskXObject: 83,
  3687. paintImageMaskXObjectGroup: 84,
  3688. paintImageXObject: 85,
  3689. paintInlineImageXObject: 86,
  3690. paintInlineImageXObjectGroup: 87,
  3691. paintImageXObjectRepeat: 88,
  3692. paintImageMaskXObjectRepeat: 89,
  3693. paintSolidColorImageMask: 90,
  3694. constructPath: 91
  3695. };
  3696. var verbosity = VERBOSITY_LEVELS.warnings;
  3697. function setVerbosityLevel(level) {
  3698. verbosity = level;
  3699. }
  3700. function getVerbosityLevel() {
  3701. return verbosity;
  3702. }
  3703. function info(msg) {
  3704. if (verbosity >= VERBOSITY_LEVELS.infos) {
  3705. console.log('Info: ' + msg);
  3706. }
  3707. }
  3708. function warn(msg) {
  3709. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  3710. console.log('Warning: ' + msg);
  3711. }
  3712. }
  3713. function deprecated(details) {
  3714. console.log('Deprecated API usage: ' + details);
  3715. }
  3716. function error(msg) {
  3717. if (verbosity >= VERBOSITY_LEVELS.errors) {
  3718. console.log('Error: ' + msg);
  3719. console.log(backtrace());
  3720. }
  3721. throw new Error(msg);
  3722. }
  3723. function backtrace() {
  3724. try {
  3725. throw new Error();
  3726. } catch (e) {
  3727. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  3728. }
  3729. }
  3730. function assert(cond, msg) {
  3731. if (!cond) {
  3732. error(msg);
  3733. }
  3734. }
  3735. var UNSUPPORTED_FEATURES = {
  3736. unknown: 'unknown',
  3737. forms: 'forms',
  3738. javaScript: 'javaScript',
  3739. smask: 'smask',
  3740. shadingPattern: 'shadingPattern',
  3741. font: 'font'
  3742. };
  3743. function isSameOrigin(baseUrl, otherUrl) {
  3744. try {
  3745. var base = new URL(baseUrl);
  3746. if (!base.origin || base.origin === 'null') {
  3747. return false;
  3748. }
  3749. } catch (e) {
  3750. return false;
  3751. }
  3752. var other = new URL(otherUrl, base);
  3753. return base.origin === other.origin;
  3754. }
  3755. function isValidProtocol(url) {
  3756. if (!url) {
  3757. return false;
  3758. }
  3759. switch (url.protocol) {
  3760. case 'http:':
  3761. case 'https:':
  3762. case 'ftp:':
  3763. case 'mailto:':
  3764. case 'tel:':
  3765. return true;
  3766. default:
  3767. return false;
  3768. }
  3769. }
  3770. function createValidAbsoluteUrl(url, baseUrl) {
  3771. if (!url) {
  3772. return null;
  3773. }
  3774. try {
  3775. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3776. if (isValidProtocol(absoluteUrl)) {
  3777. return absoluteUrl;
  3778. }
  3779. } catch (ex) {
  3780. }
  3781. return null;
  3782. }
  3783. function shadow(obj, prop, value) {
  3784. Object.defineProperty(obj, prop, {
  3785. value: value,
  3786. enumerable: true,
  3787. configurable: true,
  3788. writable: false
  3789. });
  3790. return value;
  3791. }
  3792. function getLookupTableFactory(initializer) {
  3793. var lookup;
  3794. return function () {
  3795. if (initializer) {
  3796. lookup = Object.create(null);
  3797. initializer(lookup);
  3798. initializer = null;
  3799. }
  3800. return lookup;
  3801. };
  3802. }
  3803. var PasswordResponses = {
  3804. NEED_PASSWORD: 1,
  3805. INCORRECT_PASSWORD: 2
  3806. };
  3807. var PasswordException = function PasswordExceptionClosure() {
  3808. function PasswordException(msg, code) {
  3809. this.name = 'PasswordException';
  3810. this.message = msg;
  3811. this.code = code;
  3812. }
  3813. PasswordException.prototype = new Error();
  3814. PasswordException.constructor = PasswordException;
  3815. return PasswordException;
  3816. }();
  3817. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  3818. function UnknownErrorException(msg, details) {
  3819. this.name = 'UnknownErrorException';
  3820. this.message = msg;
  3821. this.details = details;
  3822. }
  3823. UnknownErrorException.prototype = new Error();
  3824. UnknownErrorException.constructor = UnknownErrorException;
  3825. return UnknownErrorException;
  3826. }();
  3827. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  3828. function InvalidPDFException(msg) {
  3829. this.name = 'InvalidPDFException';
  3830. this.message = msg;
  3831. }
  3832. InvalidPDFException.prototype = new Error();
  3833. InvalidPDFException.constructor = InvalidPDFException;
  3834. return InvalidPDFException;
  3835. }();
  3836. var MissingPDFException = function MissingPDFExceptionClosure() {
  3837. function MissingPDFException(msg) {
  3838. this.name = 'MissingPDFException';
  3839. this.message = msg;
  3840. }
  3841. MissingPDFException.prototype = new Error();
  3842. MissingPDFException.constructor = MissingPDFException;
  3843. return MissingPDFException;
  3844. }();
  3845. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  3846. function UnexpectedResponseException(msg, status) {
  3847. this.name = 'UnexpectedResponseException';
  3848. this.message = msg;
  3849. this.status = status;
  3850. }
  3851. UnexpectedResponseException.prototype = new Error();
  3852. UnexpectedResponseException.constructor = UnexpectedResponseException;
  3853. return UnexpectedResponseException;
  3854. }();
  3855. var NotImplementedException = function NotImplementedExceptionClosure() {
  3856. function NotImplementedException(msg) {
  3857. this.message = msg;
  3858. }
  3859. NotImplementedException.prototype = new Error();
  3860. NotImplementedException.prototype.name = 'NotImplementedException';
  3861. NotImplementedException.constructor = NotImplementedException;
  3862. return NotImplementedException;
  3863. }();
  3864. var MissingDataException = function MissingDataExceptionClosure() {
  3865. function MissingDataException(begin, end) {
  3866. this.begin = begin;
  3867. this.end = end;
  3868. this.message = 'Missing data [' + begin + ', ' + end + ')';
  3869. }
  3870. MissingDataException.prototype = new Error();
  3871. MissingDataException.prototype.name = 'MissingDataException';
  3872. MissingDataException.constructor = MissingDataException;
  3873. return MissingDataException;
  3874. }();
  3875. var XRefParseException = function XRefParseExceptionClosure() {
  3876. function XRefParseException(msg) {
  3877. this.message = msg;
  3878. }
  3879. XRefParseException.prototype = new Error();
  3880. XRefParseException.prototype.name = 'XRefParseException';
  3881. XRefParseException.constructor = XRefParseException;
  3882. return XRefParseException;
  3883. }();
  3884. var NullCharactersRegExp = /\x00/g;
  3885. function removeNullCharacters(str) {
  3886. if (typeof str !== 'string') {
  3887. warn('The argument for removeNullCharacters must be a string.');
  3888. return str;
  3889. }
  3890. return str.replace(NullCharactersRegExp, '');
  3891. }
  3892. function bytesToString(bytes) {
  3893. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  3894. var length = bytes.length;
  3895. var MAX_ARGUMENT_COUNT = 8192;
  3896. if (length < MAX_ARGUMENT_COUNT) {
  3897. return String.fromCharCode.apply(null, bytes);
  3898. }
  3899. var strBuf = [];
  3900. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3901. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3902. var chunk = bytes.subarray(i, chunkEnd);
  3903. strBuf.push(String.fromCharCode.apply(null, chunk));
  3904. }
  3905. return strBuf.join('');
  3906. }
  3907. function stringToBytes(str) {
  3908. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  3909. var length = str.length;
  3910. var bytes = new Uint8Array(length);
  3911. for (var i = 0; i < length; ++i) {
  3912. bytes[i] = str.charCodeAt(i) & 0xFF;
  3913. }
  3914. return bytes;
  3915. }
  3916. function arrayByteLength(arr) {
  3917. if (arr.length !== undefined) {
  3918. return arr.length;
  3919. }
  3920. assert(arr.byteLength !== undefined);
  3921. return arr.byteLength;
  3922. }
  3923. function arraysToBytes(arr) {
  3924. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  3925. return arr[0];
  3926. }
  3927. var resultLength = 0;
  3928. var i, ii = arr.length;
  3929. var item, itemLength;
  3930. for (i = 0; i < ii; i++) {
  3931. item = arr[i];
  3932. itemLength = arrayByteLength(item);
  3933. resultLength += itemLength;
  3934. }
  3935. var pos = 0;
  3936. var data = new Uint8Array(resultLength);
  3937. for (i = 0; i < ii; i++) {
  3938. item = arr[i];
  3939. if (!(item instanceof Uint8Array)) {
  3940. if (typeof item === 'string') {
  3941. item = stringToBytes(item);
  3942. } else {
  3943. item = new Uint8Array(item);
  3944. }
  3945. }
  3946. itemLength = item.byteLength;
  3947. data.set(item, pos);
  3948. pos += itemLength;
  3949. }
  3950. return data;
  3951. }
  3952. function string32(value) {
  3953. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3954. }
  3955. function log2(x) {
  3956. var n = 1, i = 0;
  3957. while (x > n) {
  3958. n <<= 1;
  3959. i++;
  3960. }
  3961. return i;
  3962. }
  3963. function readInt8(data, start) {
  3964. return data[start] << 24 >> 24;
  3965. }
  3966. function readUint16(data, offset) {
  3967. return data[offset] << 8 | data[offset + 1];
  3968. }
  3969. function readUint32(data, offset) {
  3970. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  3971. }
  3972. function isLittleEndian() {
  3973. var buffer8 = new Uint8Array(2);
  3974. buffer8[0] = 1;
  3975. var buffer16 = new Uint16Array(buffer8.buffer);
  3976. return buffer16[0] === 1;
  3977. }
  3978. function isEvalSupported() {
  3979. try {
  3980. new Function('');
  3981. return true;
  3982. } catch (e) {
  3983. return false;
  3984. }
  3985. }
  3986. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  3987. function Uint32ArrayView(buffer, length) {
  3988. this.buffer = buffer;
  3989. this.byteLength = buffer.length;
  3990. this.length = length === undefined ? this.byteLength >> 2 : length;
  3991. ensureUint32ArrayViewProps(this.length);
  3992. }
  3993. Uint32ArrayView.prototype = Object.create(null);
  3994. var uint32ArrayViewSetters = 0;
  3995. function createUint32ArrayProp(index) {
  3996. return {
  3997. get: function () {
  3998. var buffer = this.buffer, offset = index << 2;
  3999. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  4000. },
  4001. set: function (value) {
  4002. var buffer = this.buffer, offset = index << 2;
  4003. buffer[offset] = value & 255;
  4004. buffer[offset + 1] = value >> 8 & 255;
  4005. buffer[offset + 2] = value >> 16 & 255;
  4006. buffer[offset + 3] = value >>> 24 & 255;
  4007. }
  4008. };
  4009. }
  4010. function ensureUint32ArrayViewProps(length) {
  4011. while (uint32ArrayViewSetters < length) {
  4012. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  4013. uint32ArrayViewSetters++;
  4014. }
  4015. }
  4016. return Uint32ArrayView;
  4017. }();
  4018. exports.Uint32ArrayView = Uint32ArrayView;
  4019. var IDENTITY_MATRIX = [
  4020. 1,
  4021. 0,
  4022. 0,
  4023. 1,
  4024. 0,
  4025. 0
  4026. ];
  4027. var Util = function UtilClosure() {
  4028. function Util() {
  4029. }
  4030. var rgbBuf = [
  4031. 'rgb(',
  4032. 0,
  4033. ',',
  4034. 0,
  4035. ',',
  4036. 0,
  4037. ')'
  4038. ];
  4039. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  4040. rgbBuf[1] = r;
  4041. rgbBuf[3] = g;
  4042. rgbBuf[5] = b;
  4043. return rgbBuf.join('');
  4044. };
  4045. Util.transform = function Util_transform(m1, m2) {
  4046. return [
  4047. m1[0] * m2[0] + m1[2] * m2[1],
  4048. m1[1] * m2[0] + m1[3] * m2[1],
  4049. m1[0] * m2[2] + m1[2] * m2[3],
  4050. m1[1] * m2[2] + m1[3] * m2[3],
  4051. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  4052. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  4053. ];
  4054. };
  4055. Util.applyTransform = function Util_applyTransform(p, m) {
  4056. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  4057. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  4058. return [
  4059. xt,
  4060. yt
  4061. ];
  4062. };
  4063. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  4064. var d = m[0] * m[3] - m[1] * m[2];
  4065. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  4066. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  4067. return [
  4068. xt,
  4069. yt
  4070. ];
  4071. };
  4072. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  4073. var p1 = Util.applyTransform(r, m);
  4074. var p2 = Util.applyTransform(r.slice(2, 4), m);
  4075. var p3 = Util.applyTransform([
  4076. r[0],
  4077. r[3]
  4078. ], m);
  4079. var p4 = Util.applyTransform([
  4080. r[2],
  4081. r[1]
  4082. ], m);
  4083. return [
  4084. Math.min(p1[0], p2[0], p3[0], p4[0]),
  4085. Math.min(p1[1], p2[1], p3[1], p4[1]),
  4086. Math.max(p1[0], p2[0], p3[0], p4[0]),
  4087. Math.max(p1[1], p2[1], p3[1], p4[1])
  4088. ];
  4089. };
  4090. Util.inverseTransform = function Util_inverseTransform(m) {
  4091. var d = m[0] * m[3] - m[1] * m[2];
  4092. return [
  4093. m[3] / d,
  4094. -m[1] / d,
  4095. -m[2] / d,
  4096. m[0] / d,
  4097. (m[2] * m[5] - m[4] * m[3]) / d,
  4098. (m[4] * m[1] - m[5] * m[0]) / d
  4099. ];
  4100. };
  4101. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  4102. return [
  4103. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  4104. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  4105. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  4106. ];
  4107. };
  4108. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  4109. var transpose = [
  4110. m[0],
  4111. m[2],
  4112. m[1],
  4113. m[3]
  4114. ];
  4115. var a = m[0] * transpose[0] + m[1] * transpose[2];
  4116. var b = m[0] * transpose[1] + m[1] * transpose[3];
  4117. var c = m[2] * transpose[0] + m[3] * transpose[2];
  4118. var d = m[2] * transpose[1] + m[3] * transpose[3];
  4119. var first = (a + d) / 2;
  4120. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  4121. var sx = first + second || 1;
  4122. var sy = first - second || 1;
  4123. return [
  4124. Math.sqrt(sx),
  4125. Math.sqrt(sy)
  4126. ];
  4127. };
  4128. Util.normalizeRect = function Util_normalizeRect(rect) {
  4129. var r = rect.slice(0);
  4130. if (rect[0] > rect[2]) {
  4131. r[0] = rect[2];
  4132. r[2] = rect[0];
  4133. }
  4134. if (rect[1] > rect[3]) {
  4135. r[1] = rect[3];
  4136. r[3] = rect[1];
  4137. }
  4138. return r;
  4139. };
  4140. Util.intersect = function Util_intersect(rect1, rect2) {
  4141. function compare(a, b) {
  4142. return a - b;
  4143. }
  4144. var orderedX = [
  4145. rect1[0],
  4146. rect1[2],
  4147. rect2[0],
  4148. rect2[2]
  4149. ].sort(compare), orderedY = [
  4150. rect1[1],
  4151. rect1[3],
  4152. rect2[1],
  4153. rect2[3]
  4154. ].sort(compare), result = [];
  4155. rect1 = Util.normalizeRect(rect1);
  4156. rect2 = Util.normalizeRect(rect2);
  4157. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  4158. result[0] = orderedX[1];
  4159. result[2] = orderedX[2];
  4160. } else {
  4161. return false;
  4162. }
  4163. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  4164. result[1] = orderedY[1];
  4165. result[3] = orderedY[2];
  4166. } else {
  4167. return false;
  4168. }
  4169. return result;
  4170. };
  4171. Util.sign = function Util_sign(num) {
  4172. return num < 0 ? -1 : 1;
  4173. };
  4174. var ROMAN_NUMBER_MAP = [
  4175. '',
  4176. 'C',
  4177. 'CC',
  4178. 'CCC',
  4179. 'CD',
  4180. 'D',
  4181. 'DC',
  4182. 'DCC',
  4183. 'DCCC',
  4184. 'CM',
  4185. '',
  4186. 'X',
  4187. 'XX',
  4188. 'XXX',
  4189. 'XL',
  4190. 'L',
  4191. 'LX',
  4192. 'LXX',
  4193. 'LXXX',
  4194. 'XC',
  4195. '',
  4196. 'I',
  4197. 'II',
  4198. 'III',
  4199. 'IV',
  4200. 'V',
  4201. 'VI',
  4202. 'VII',
  4203. 'VIII',
  4204. 'IX'
  4205. ];
  4206. Util.toRoman = function Util_toRoman(number, lowerCase) {
  4207. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  4208. var pos, romanBuf = [];
  4209. while (number >= 1000) {
  4210. number -= 1000;
  4211. romanBuf.push('M');
  4212. }
  4213. pos = number / 100 | 0;
  4214. number %= 100;
  4215. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  4216. pos = number / 10 | 0;
  4217. number %= 10;
  4218. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  4219. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  4220. var romanStr = romanBuf.join('');
  4221. return lowerCase ? romanStr.toLowerCase() : romanStr;
  4222. };
  4223. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  4224. Array.prototype.push.apply(arr1, arr2);
  4225. };
  4226. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  4227. Array.prototype.unshift.apply(arr1, arr2);
  4228. };
  4229. Util.extendObj = function extendObj(obj1, obj2) {
  4230. for (var key in obj2) {
  4231. obj1[key] = obj2[key];
  4232. }
  4233. };
  4234. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  4235. while (dict && !dict.has(name)) {
  4236. dict = dict.get('Parent');
  4237. }
  4238. if (!dict) {
  4239. return null;
  4240. }
  4241. return getArray ? dict.getArray(name) : dict.get(name);
  4242. };
  4243. Util.inherit = function Util_inherit(sub, base, prototype) {
  4244. sub.prototype = Object.create(base.prototype);
  4245. sub.prototype.constructor = sub;
  4246. for (var prop in prototype) {
  4247. sub.prototype[prop] = prototype[prop];
  4248. }
  4249. };
  4250. Util.loadScript = function Util_loadScript(src, callback) {
  4251. var script = document.createElement('script');
  4252. var loaded = false;
  4253. script.setAttribute('src', src);
  4254. if (callback) {
  4255. script.onload = function () {
  4256. if (!loaded) {
  4257. callback();
  4258. }
  4259. loaded = true;
  4260. };
  4261. }
  4262. document.getElementsByTagName('head')[0].appendChild(script);
  4263. };
  4264. return Util;
  4265. }();
  4266. var PageViewport = function PageViewportClosure() {
  4267. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  4268. this.viewBox = viewBox;
  4269. this.scale = scale;
  4270. this.rotation = rotation;
  4271. this.offsetX = offsetX;
  4272. this.offsetY = offsetY;
  4273. var centerX = (viewBox[2] + viewBox[0]) / 2;
  4274. var centerY = (viewBox[3] + viewBox[1]) / 2;
  4275. var rotateA, rotateB, rotateC, rotateD;
  4276. rotation = rotation % 360;
  4277. rotation = rotation < 0 ? rotation + 360 : rotation;
  4278. switch (rotation) {
  4279. case 180:
  4280. rotateA = -1;
  4281. rotateB = 0;
  4282. rotateC = 0;
  4283. rotateD = 1;
  4284. break;
  4285. case 90:
  4286. rotateA = 0;
  4287. rotateB = 1;
  4288. rotateC = 1;
  4289. rotateD = 0;
  4290. break;
  4291. case 270:
  4292. rotateA = 0;
  4293. rotateB = -1;
  4294. rotateC = -1;
  4295. rotateD = 0;
  4296. break;
  4297. default:
  4298. rotateA = 1;
  4299. rotateB = 0;
  4300. rotateC = 0;
  4301. rotateD = -1;
  4302. break;
  4303. }
  4304. if (dontFlip) {
  4305. rotateC = -rotateC;
  4306. rotateD = -rotateD;
  4307. }
  4308. var offsetCanvasX, offsetCanvasY;
  4309. var width, height;
  4310. if (rotateA === 0) {
  4311. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  4312. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  4313. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  4314. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  4315. } else {
  4316. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  4317. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  4318. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  4319. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  4320. }
  4321. this.transform = [
  4322. rotateA * scale,
  4323. rotateB * scale,
  4324. rotateC * scale,
  4325. rotateD * scale,
  4326. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  4327. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  4328. ];
  4329. this.width = width;
  4330. this.height = height;
  4331. this.fontScale = scale;
  4332. }
  4333. PageViewport.prototype = {
  4334. clone: function PageViewPort_clone(args) {
  4335. args = args || {};
  4336. var scale = 'scale' in args ? args.scale : this.scale;
  4337. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  4338. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  4339. },
  4340. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  4341. return Util.applyTransform([
  4342. x,
  4343. y
  4344. ], this.transform);
  4345. },
  4346. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  4347. var tl = Util.applyTransform([
  4348. rect[0],
  4349. rect[1]
  4350. ], this.transform);
  4351. var br = Util.applyTransform([
  4352. rect[2],
  4353. rect[3]
  4354. ], this.transform);
  4355. return [
  4356. tl[0],
  4357. tl[1],
  4358. br[0],
  4359. br[1]
  4360. ];
  4361. },
  4362. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  4363. return Util.applyInverseTransform([
  4364. x,
  4365. y
  4366. ], this.transform);
  4367. }
  4368. };
  4369. return PageViewport;
  4370. }();
  4371. var PDFStringTranslateTable = [
  4372. 0,
  4373. 0,
  4374. 0,
  4375. 0,
  4376. 0,
  4377. 0,
  4378. 0,
  4379. 0,
  4380. 0,
  4381. 0,
  4382. 0,
  4383. 0,
  4384. 0,
  4385. 0,
  4386. 0,
  4387. 0,
  4388. 0,
  4389. 0,
  4390. 0,
  4391. 0,
  4392. 0,
  4393. 0,
  4394. 0,
  4395. 0,
  4396. 0x2D8,
  4397. 0x2C7,
  4398. 0x2C6,
  4399. 0x2D9,
  4400. 0x2DD,
  4401. 0x2DB,
  4402. 0x2DA,
  4403. 0x2DC,
  4404. 0,
  4405. 0,
  4406. 0,
  4407. 0,
  4408. 0,
  4409. 0,
  4410. 0,
  4411. 0,
  4412. 0,
  4413. 0,
  4414. 0,
  4415. 0,
  4416. 0,
  4417. 0,
  4418. 0,
  4419. 0,
  4420. 0,
  4421. 0,
  4422. 0,
  4423. 0,
  4424. 0,
  4425. 0,
  4426. 0,
  4427. 0,
  4428. 0,
  4429. 0,
  4430. 0,
  4431. 0,
  4432. 0,
  4433. 0,
  4434. 0,
  4435. 0,
  4436. 0,
  4437. 0,
  4438. 0,
  4439. 0,
  4440. 0,
  4441. 0,
  4442. 0,
  4443. 0,
  4444. 0,
  4445. 0,
  4446. 0,
  4447. 0,
  4448. 0,
  4449. 0,
  4450. 0,
  4451. 0,
  4452. 0,
  4453. 0,
  4454. 0,
  4455. 0,
  4456. 0,
  4457. 0,
  4458. 0,
  4459. 0,
  4460. 0,
  4461. 0,
  4462. 0,
  4463. 0,
  4464. 0,
  4465. 0,
  4466. 0,
  4467. 0,
  4468. 0,
  4469. 0,
  4470. 0,
  4471. 0,
  4472. 0,
  4473. 0,
  4474. 0,
  4475. 0,
  4476. 0,
  4477. 0,
  4478. 0,
  4479. 0,
  4480. 0,
  4481. 0,
  4482. 0,
  4483. 0,
  4484. 0,
  4485. 0,
  4486. 0,
  4487. 0,
  4488. 0,
  4489. 0,
  4490. 0,
  4491. 0,
  4492. 0,
  4493. 0,
  4494. 0,
  4495. 0,
  4496. 0,
  4497. 0,
  4498. 0,
  4499. 0,
  4500. 0x2022,
  4501. 0x2020,
  4502. 0x2021,
  4503. 0x2026,
  4504. 0x2014,
  4505. 0x2013,
  4506. 0x192,
  4507. 0x2044,
  4508. 0x2039,
  4509. 0x203A,
  4510. 0x2212,
  4511. 0x2030,
  4512. 0x201E,
  4513. 0x201C,
  4514. 0x201D,
  4515. 0x2018,
  4516. 0x2019,
  4517. 0x201A,
  4518. 0x2122,
  4519. 0xFB01,
  4520. 0xFB02,
  4521. 0x141,
  4522. 0x152,
  4523. 0x160,
  4524. 0x178,
  4525. 0x17D,
  4526. 0x131,
  4527. 0x142,
  4528. 0x153,
  4529. 0x161,
  4530. 0x17E,
  4531. 0,
  4532. 0x20AC
  4533. ];
  4534. function stringToPDFString(str) {
  4535. var i, n = str.length, strBuf = [];
  4536. if (str[0] === '\xFE' && str[1] === '\xFF') {
  4537. for (i = 2; i < n; i += 2) {
  4538. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  4539. }
  4540. } else {
  4541. for (i = 0; i < n; ++i) {
  4542. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  4543. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  4544. }
  4545. }
  4546. return strBuf.join('');
  4547. }
  4548. function stringToUTF8String(str) {
  4549. return decodeURIComponent(escape(str));
  4550. }
  4551. function utf8StringToString(str) {
  4552. return unescape(encodeURIComponent(str));
  4553. }
  4554. function isEmptyObj(obj) {
  4555. for (var key in obj) {
  4556. return false;
  4557. }
  4558. return true;
  4559. }
  4560. function isBool(v) {
  4561. return typeof v === 'boolean';
  4562. }
  4563. function isInt(v) {
  4564. return typeof v === 'number' && (v | 0) === v;
  4565. }
  4566. function isNum(v) {
  4567. return typeof v === 'number';
  4568. }
  4569. function isString(v) {
  4570. return typeof v === 'string';
  4571. }
  4572. function isArray(v) {
  4573. return v instanceof Array;
  4574. }
  4575. function isArrayBuffer(v) {
  4576. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  4577. }
  4578. function isSpace(ch) {
  4579. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  4580. }
  4581. function createPromiseCapability() {
  4582. var capability = {};
  4583. capability.promise = new Promise(function (resolve, reject) {
  4584. capability.resolve = resolve;
  4585. capability.reject = reject;
  4586. });
  4587. return capability;
  4588. }
  4589. (function PromiseClosure() {
  4590. if (globalScope.Promise) {
  4591. if (typeof globalScope.Promise.all !== 'function') {
  4592. globalScope.Promise.all = function (iterable) {
  4593. var count = 0, results = [], resolve, reject;
  4594. var promise = new globalScope.Promise(function (resolve_, reject_) {
  4595. resolve = resolve_;
  4596. reject = reject_;
  4597. });
  4598. iterable.forEach(function (p, i) {
  4599. count++;
  4600. p.then(function (result) {
  4601. results[i] = result;
  4602. count--;
  4603. if (count === 0) {
  4604. resolve(results);
  4605. }
  4606. }, reject);
  4607. });
  4608. if (count === 0) {
  4609. resolve(results);
  4610. }
  4611. return promise;
  4612. };
  4613. }
  4614. if (typeof globalScope.Promise.resolve !== 'function') {
  4615. globalScope.Promise.resolve = function (value) {
  4616. return new globalScope.Promise(function (resolve) {
  4617. resolve(value);
  4618. });
  4619. };
  4620. }
  4621. if (typeof globalScope.Promise.reject !== 'function') {
  4622. globalScope.Promise.reject = function (reason) {
  4623. return new globalScope.Promise(function (resolve, reject) {
  4624. reject(reason);
  4625. });
  4626. };
  4627. }
  4628. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  4629. globalScope.Promise.prototype.catch = function (onReject) {
  4630. return globalScope.Promise.prototype.then(undefined, onReject);
  4631. };
  4632. }
  4633. return;
  4634. }
  4635. var STATUS_PENDING = 0;
  4636. var STATUS_RESOLVED = 1;
  4637. var STATUS_REJECTED = 2;
  4638. var REJECTION_TIMEOUT = 500;
  4639. var HandlerManager = {
  4640. handlers: [],
  4641. running: false,
  4642. unhandledRejections: [],
  4643. pendingRejectionCheck: false,
  4644. scheduleHandlers: function scheduleHandlers(promise) {
  4645. if (promise._status === STATUS_PENDING) {
  4646. return;
  4647. }
  4648. this.handlers = this.handlers.concat(promise._handlers);
  4649. promise._handlers = [];
  4650. if (this.running) {
  4651. return;
  4652. }
  4653. this.running = true;
  4654. setTimeout(this.runHandlers.bind(this), 0);
  4655. },
  4656. runHandlers: function runHandlers() {
  4657. var RUN_TIMEOUT = 1;
  4658. var timeoutAt = Date.now() + RUN_TIMEOUT;
  4659. while (this.handlers.length > 0) {
  4660. var handler = this.handlers.shift();
  4661. var nextStatus = handler.thisPromise._status;
  4662. var nextValue = handler.thisPromise._value;
  4663. try {
  4664. if (nextStatus === STATUS_RESOLVED) {
  4665. if (typeof handler.onResolve === 'function') {
  4666. nextValue = handler.onResolve(nextValue);
  4667. }
  4668. } else if (typeof handler.onReject === 'function') {
  4669. nextValue = handler.onReject(nextValue);
  4670. nextStatus = STATUS_RESOLVED;
  4671. if (handler.thisPromise._unhandledRejection) {
  4672. this.removeUnhandeledRejection(handler.thisPromise);
  4673. }
  4674. }
  4675. } catch (ex) {
  4676. nextStatus = STATUS_REJECTED;
  4677. nextValue = ex;
  4678. }
  4679. handler.nextPromise._updateStatus(nextStatus, nextValue);
  4680. if (Date.now() >= timeoutAt) {
  4681. break;
  4682. }
  4683. }
  4684. if (this.handlers.length > 0) {
  4685. setTimeout(this.runHandlers.bind(this), 0);
  4686. return;
  4687. }
  4688. this.running = false;
  4689. },
  4690. addUnhandledRejection: function addUnhandledRejection(promise) {
  4691. this.unhandledRejections.push({
  4692. promise: promise,
  4693. time: Date.now()
  4694. });
  4695. this.scheduleRejectionCheck();
  4696. },
  4697. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  4698. promise._unhandledRejection = false;
  4699. for (var i = 0; i < this.unhandledRejections.length; i++) {
  4700. if (this.unhandledRejections[i].promise === promise) {
  4701. this.unhandledRejections.splice(i);
  4702. i--;
  4703. }
  4704. }
  4705. },
  4706. scheduleRejectionCheck: function scheduleRejectionCheck() {
  4707. if (this.pendingRejectionCheck) {
  4708. return;
  4709. }
  4710. this.pendingRejectionCheck = true;
  4711. setTimeout(function rejectionCheck() {
  4712. this.pendingRejectionCheck = false;
  4713. var now = Date.now();
  4714. for (var i = 0; i < this.unhandledRejections.length; i++) {
  4715. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  4716. var unhandled = this.unhandledRejections[i].promise._value;
  4717. var msg = 'Unhandled rejection: ' + unhandled;
  4718. if (unhandled.stack) {
  4719. msg += '\n' + unhandled.stack;
  4720. }
  4721. warn(msg);
  4722. this.unhandledRejections.splice(i);
  4723. i--;
  4724. }
  4725. }
  4726. if (this.unhandledRejections.length) {
  4727. this.scheduleRejectionCheck();
  4728. }
  4729. }.bind(this), REJECTION_TIMEOUT);
  4730. }
  4731. };
  4732. var Promise = function Promise(resolver) {
  4733. this._status = STATUS_PENDING;
  4734. this._handlers = [];
  4735. try {
  4736. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  4737. } catch (e) {
  4738. this._reject(e);
  4739. }
  4740. };
  4741. Promise.all = function Promise_all(promises) {
  4742. var resolveAll, rejectAll;
  4743. var deferred = new Promise(function (resolve, reject) {
  4744. resolveAll = resolve;
  4745. rejectAll = reject;
  4746. });
  4747. var unresolved = promises.length;
  4748. var results = [];
  4749. if (unresolved === 0) {
  4750. resolveAll(results);
  4751. return deferred;
  4752. }
  4753. function reject(reason) {
  4754. if (deferred._status === STATUS_REJECTED) {
  4755. return;
  4756. }
  4757. results = [];
  4758. rejectAll(reason);
  4759. }
  4760. for (var i = 0, ii = promises.length; i < ii; ++i) {
  4761. var promise = promises[i];
  4762. var resolve = function (i) {
  4763. return function (value) {
  4764. if (deferred._status === STATUS_REJECTED) {
  4765. return;
  4766. }
  4767. results[i] = value;
  4768. unresolved--;
  4769. if (unresolved === 0) {
  4770. resolveAll(results);
  4771. }
  4772. };
  4773. }(i);
  4774. if (Promise.isPromise(promise)) {
  4775. promise.then(resolve, reject);
  4776. } else {
  4777. resolve(promise);
  4778. }
  4779. }
  4780. return deferred;
  4781. };
  4782. Promise.isPromise = function Promise_isPromise(value) {
  4783. return value && typeof value.then === 'function';
  4784. };
  4785. Promise.resolve = function Promise_resolve(value) {
  4786. return new Promise(function (resolve) {
  4787. resolve(value);
  4788. });
  4789. };
  4790. Promise.reject = function Promise_reject(reason) {
  4791. return new Promise(function (resolve, reject) {
  4792. reject(reason);
  4793. });
  4794. };
  4795. Promise.prototype = {
  4796. _status: null,
  4797. _value: null,
  4798. _handlers: null,
  4799. _unhandledRejection: null,
  4800. _updateStatus: function Promise__updateStatus(status, value) {
  4801. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  4802. return;
  4803. }
  4804. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  4805. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  4806. return;
  4807. }
  4808. this._status = status;
  4809. this._value = value;
  4810. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  4811. this._unhandledRejection = true;
  4812. HandlerManager.addUnhandledRejection(this);
  4813. }
  4814. HandlerManager.scheduleHandlers(this);
  4815. },
  4816. _resolve: function Promise_resolve(value) {
  4817. this._updateStatus(STATUS_RESOLVED, value);
  4818. },
  4819. _reject: function Promise_reject(reason) {
  4820. this._updateStatus(STATUS_REJECTED, reason);
  4821. },
  4822. then: function Promise_then(onResolve, onReject) {
  4823. var nextPromise = new Promise(function (resolve, reject) {
  4824. this.resolve = resolve;
  4825. this.reject = reject;
  4826. });
  4827. this._handlers.push({
  4828. thisPromise: this,
  4829. onResolve: onResolve,
  4830. onReject: onReject,
  4831. nextPromise: nextPromise
  4832. });
  4833. HandlerManager.scheduleHandlers(this);
  4834. return nextPromise;
  4835. },
  4836. catch: function Promise_catch(onReject) {
  4837. return this.then(undefined, onReject);
  4838. }
  4839. };
  4840. globalScope.Promise = Promise;
  4841. }());
  4842. (function WeakMapClosure() {
  4843. if (globalScope.WeakMap) {
  4844. return;
  4845. }
  4846. var id = 0;
  4847. function WeakMap() {
  4848. this.id = '$weakmap' + id++;
  4849. }
  4850. WeakMap.prototype = {
  4851. has: function (obj) {
  4852. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  4853. },
  4854. get: function (obj, defaultValue) {
  4855. return this.has(obj) ? obj[this.id] : defaultValue;
  4856. },
  4857. set: function (obj, value) {
  4858. Object.defineProperty(obj, this.id, {
  4859. value: value,
  4860. enumerable: false,
  4861. configurable: true
  4862. });
  4863. },
  4864. delete: function (obj) {
  4865. delete obj[this.id];
  4866. }
  4867. };
  4868. globalScope.WeakMap = WeakMap;
  4869. }());
  4870. var StatTimer = function StatTimerClosure() {
  4871. function rpad(str, pad, length) {
  4872. while (str.length < length) {
  4873. str += pad;
  4874. }
  4875. return str;
  4876. }
  4877. function StatTimer() {
  4878. this.started = Object.create(null);
  4879. this.times = [];
  4880. this.enabled = true;
  4881. }
  4882. StatTimer.prototype = {
  4883. time: function StatTimer_time(name) {
  4884. if (!this.enabled) {
  4885. return;
  4886. }
  4887. if (name in this.started) {
  4888. warn('Timer is already running for ' + name);
  4889. }
  4890. this.started[name] = Date.now();
  4891. },
  4892. timeEnd: function StatTimer_timeEnd(name) {
  4893. if (!this.enabled) {
  4894. return;
  4895. }
  4896. if (!(name in this.started)) {
  4897. warn('Timer has not been started for ' + name);
  4898. }
  4899. this.times.push({
  4900. 'name': name,
  4901. 'start': this.started[name],
  4902. 'end': Date.now()
  4903. });
  4904. delete this.started[name];
  4905. },
  4906. toString: function StatTimer_toString() {
  4907. var i, ii;
  4908. var times = this.times;
  4909. var out = '';
  4910. var longest = 0;
  4911. for (i = 0, ii = times.length; i < ii; ++i) {
  4912. var name = times[i]['name'];
  4913. if (name.length > longest) {
  4914. longest = name.length;
  4915. }
  4916. }
  4917. for (i = 0, ii = times.length; i < ii; ++i) {
  4918. var span = times[i];
  4919. var duration = span.end - span.start;
  4920. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  4921. }
  4922. return out;
  4923. }
  4924. };
  4925. return StatTimer;
  4926. }();
  4927. var createBlob = function createBlob(data, contentType) {
  4928. if (typeof Blob !== 'undefined') {
  4929. return new Blob([data], { type: contentType });
  4930. }
  4931. warn('The "Blob" constructor is not supported.');
  4932. };
  4933. var createObjectURL = function createObjectURLClosure() {
  4934. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  4935. return function createObjectURL(data, contentType, forceDataSchema) {
  4936. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  4937. var blob = createBlob(data, contentType);
  4938. return URL.createObjectURL(blob);
  4939. }
  4940. var buffer = 'data:' + contentType + ';base64,';
  4941. for (var i = 0, ii = data.length; i < ii; i += 3) {
  4942. var b1 = data[i] & 0xFF;
  4943. var b2 = data[i + 1] & 0xFF;
  4944. var b3 = data[i + 2] & 0xFF;
  4945. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  4946. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  4947. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  4948. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  4949. }
  4950. return buffer;
  4951. };
  4952. }();
  4953. function MessageHandler(sourceName, targetName, comObj) {
  4954. this.sourceName = sourceName;
  4955. this.targetName = targetName;
  4956. this.comObj = comObj;
  4957. this.callbackIndex = 1;
  4958. this.postMessageTransfers = true;
  4959. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  4960. var ah = this.actionHandler = Object.create(null);
  4961. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  4962. var data = event.data;
  4963. if (data.targetName !== this.sourceName) {
  4964. return;
  4965. }
  4966. if (data.isReply) {
  4967. var callbackId = data.callbackId;
  4968. if (data.callbackId in callbacksCapabilities) {
  4969. var callback = callbacksCapabilities[callbackId];
  4970. delete callbacksCapabilities[callbackId];
  4971. if ('error' in data) {
  4972. callback.reject(data.error);
  4973. } else {
  4974. callback.resolve(data.data);
  4975. }
  4976. } else {
  4977. error('Cannot resolve callback ' + callbackId);
  4978. }
  4979. } else if (data.action in ah) {
  4980. var action = ah[data.action];
  4981. if (data.callbackId) {
  4982. var sourceName = this.sourceName;
  4983. var targetName = data.sourceName;
  4984. Promise.resolve().then(function () {
  4985. return action[0].call(action[1], data.data);
  4986. }).then(function (result) {
  4987. comObj.postMessage({
  4988. sourceName: sourceName,
  4989. targetName: targetName,
  4990. isReply: true,
  4991. callbackId: data.callbackId,
  4992. data: result
  4993. });
  4994. }, function (reason) {
  4995. if (reason instanceof Error) {
  4996. reason = reason + '';
  4997. }
  4998. comObj.postMessage({
  4999. sourceName: sourceName,
  5000. targetName: targetName,
  5001. isReply: true,
  5002. callbackId: data.callbackId,
  5003. error: reason
  5004. });
  5005. });
  5006. } else {
  5007. action[0].call(action[1], data.data);
  5008. }
  5009. } else {
  5010. error('Unknown action from worker: ' + data.action);
  5011. }
  5012. }.bind(this);
  5013. comObj.addEventListener('message', this._onComObjOnMessage);
  5014. }
  5015. MessageHandler.prototype = {
  5016. on: function messageHandlerOn(actionName, handler, scope) {
  5017. var ah = this.actionHandler;
  5018. if (ah[actionName]) {
  5019. error('There is already an actionName called "' + actionName + '"');
  5020. }
  5021. ah[actionName] = [
  5022. handler,
  5023. scope
  5024. ];
  5025. },
  5026. send: function messageHandlerSend(actionName, data, transfers) {
  5027. var message = {
  5028. sourceName: this.sourceName,
  5029. targetName: this.targetName,
  5030. action: actionName,
  5031. data: data
  5032. };
  5033. this.postMessage(message, transfers);
  5034. },
  5035. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  5036. var callbackId = this.callbackIndex++;
  5037. var message = {
  5038. sourceName: this.sourceName,
  5039. targetName: this.targetName,
  5040. action: actionName,
  5041. data: data,
  5042. callbackId: callbackId
  5043. };
  5044. var capability = createPromiseCapability();
  5045. this.callbacksCapabilities[callbackId] = capability;
  5046. try {
  5047. this.postMessage(message, transfers);
  5048. } catch (e) {
  5049. capability.reject(e);
  5050. }
  5051. return capability.promise;
  5052. },
  5053. postMessage: function (message, transfers) {
  5054. if (transfers && this.postMessageTransfers) {
  5055. this.comObj.postMessage(message, transfers);
  5056. } else {
  5057. this.comObj.postMessage(message);
  5058. }
  5059. },
  5060. destroy: function () {
  5061. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  5062. }
  5063. };
  5064. function loadJpegStream(id, imageUrl, objs) {
  5065. var img = new Image();
  5066. img.onload = function loadJpegStream_onloadClosure() {
  5067. objs.resolve(id, img);
  5068. };
  5069. img.onerror = function loadJpegStream_onerrorClosure() {
  5070. objs.resolve(id, null);
  5071. warn('Error during JPEG image loading');
  5072. };
  5073. img.src = imageUrl;
  5074. }
  5075. /* Any copyright is dedicated to the Public Domain.
  5076. * http://creativecommons.org/publicdomain/zero/1.0/ */
  5077. (function checkURLConstructor(scope) {
  5078. var hasWorkingUrl = false;
  5079. try {
  5080. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  5081. var u = new URL('b', 'http://a');
  5082. u.pathname = 'c%20d';
  5083. hasWorkingUrl = u.href === 'http://a/c%20d';
  5084. }
  5085. } catch (e) {
  5086. }
  5087. if (hasWorkingUrl) {
  5088. return;
  5089. }
  5090. var relative = Object.create(null);
  5091. relative['ftp'] = 21;
  5092. relative['file'] = 0;
  5093. relative['gopher'] = 70;
  5094. relative['http'] = 80;
  5095. relative['https'] = 443;
  5096. relative['ws'] = 80;
  5097. relative['wss'] = 443;
  5098. var relativePathDotMapping = Object.create(null);
  5099. relativePathDotMapping['%2e'] = '.';
  5100. relativePathDotMapping['.%2e'] = '..';
  5101. relativePathDotMapping['%2e.'] = '..';
  5102. relativePathDotMapping['%2e%2e'] = '..';
  5103. function isRelativeScheme(scheme) {
  5104. return relative[scheme] !== undefined;
  5105. }
  5106. function invalid() {
  5107. clear.call(this);
  5108. this._isInvalid = true;
  5109. }
  5110. function IDNAToASCII(h) {
  5111. if ('' === h) {
  5112. invalid.call(this);
  5113. }
  5114. return h.toLowerCase();
  5115. }
  5116. function percentEscape(c) {
  5117. var unicode = c.charCodeAt(0);
  5118. if (unicode > 0x20 && unicode < 0x7F && [
  5119. 0x22,
  5120. 0x23,
  5121. 0x3C,
  5122. 0x3E,
  5123. 0x3F,
  5124. 0x60
  5125. ].indexOf(unicode) === -1) {
  5126. return c;
  5127. }
  5128. return encodeURIComponent(c);
  5129. }
  5130. function percentEscapeQuery(c) {
  5131. var unicode = c.charCodeAt(0);
  5132. if (unicode > 0x20 && unicode < 0x7F && [
  5133. 0x22,
  5134. 0x23,
  5135. 0x3C,
  5136. 0x3E,
  5137. 0x60
  5138. ].indexOf(unicode) === -1) {
  5139. return c;
  5140. }
  5141. return encodeURIComponent(c);
  5142. }
  5143. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  5144. function parse(input, stateOverride, base) {
  5145. function err(message) {
  5146. errors.push(message);
  5147. }
  5148. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  5149. loop:
  5150. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  5151. var c = input[cursor];
  5152. switch (state) {
  5153. case 'scheme start':
  5154. if (c && ALPHA.test(c)) {
  5155. buffer += c.toLowerCase();
  5156. state = 'scheme';
  5157. } else if (!stateOverride) {
  5158. buffer = '';
  5159. state = 'no scheme';
  5160. continue;
  5161. } else {
  5162. err('Invalid scheme.');
  5163. break loop;
  5164. }
  5165. break;
  5166. case 'scheme':
  5167. if (c && ALPHANUMERIC.test(c)) {
  5168. buffer += c.toLowerCase();
  5169. } else if (':' === c) {
  5170. this._scheme = buffer;
  5171. buffer = '';
  5172. if (stateOverride) {
  5173. break loop;
  5174. }
  5175. if (isRelativeScheme(this._scheme)) {
  5176. this._isRelative = true;
  5177. }
  5178. if ('file' === this._scheme) {
  5179. state = 'relative';
  5180. } else if (this._isRelative && base && base._scheme === this._scheme) {
  5181. state = 'relative or authority';
  5182. } else if (this._isRelative) {
  5183. state = 'authority first slash';
  5184. } else {
  5185. state = 'scheme data';
  5186. }
  5187. } else if (!stateOverride) {
  5188. buffer = '';
  5189. cursor = 0;
  5190. state = 'no scheme';
  5191. continue;
  5192. } else if (EOF === c) {
  5193. break loop;
  5194. } else {
  5195. err('Code point not allowed in scheme: ' + c);
  5196. break loop;
  5197. }
  5198. break;
  5199. case 'scheme data':
  5200. if ('?' === c) {
  5201. this._query = '?';
  5202. state = 'query';
  5203. } else if ('#' === c) {
  5204. this._fragment = '#';
  5205. state = 'fragment';
  5206. } else {
  5207. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  5208. this._schemeData += percentEscape(c);
  5209. }
  5210. }
  5211. break;
  5212. case 'no scheme':
  5213. if (!base || !isRelativeScheme(base._scheme)) {
  5214. err('Missing scheme.');
  5215. invalid.call(this);
  5216. } else {
  5217. state = 'relative';
  5218. continue;
  5219. }
  5220. break;
  5221. case 'relative or authority':
  5222. if ('/' === c && '/' === input[cursor + 1]) {
  5223. state = 'authority ignore slashes';
  5224. } else {
  5225. err('Expected /, got: ' + c);
  5226. state = 'relative';
  5227. continue;
  5228. }
  5229. break;
  5230. case 'relative':
  5231. this._isRelative = true;
  5232. if ('file' !== this._scheme) {
  5233. this._scheme = base._scheme;
  5234. }
  5235. if (EOF === c) {
  5236. this._host = base._host;
  5237. this._port = base._port;
  5238. this._path = base._path.slice();
  5239. this._query = base._query;
  5240. this._username = base._username;
  5241. this._password = base._password;
  5242. break loop;
  5243. } else if ('/' === c || '\\' === c) {
  5244. if ('\\' === c) {
  5245. err('\\ is an invalid code point.');
  5246. }
  5247. state = 'relative slash';
  5248. } else if ('?' === c) {
  5249. this._host = base._host;
  5250. this._port = base._port;
  5251. this._path = base._path.slice();
  5252. this._query = '?';
  5253. this._username = base._username;
  5254. this._password = base._password;
  5255. state = 'query';
  5256. } else if ('#' === c) {
  5257. this._host = base._host;
  5258. this._port = base._port;
  5259. this._path = base._path.slice();
  5260. this._query = base._query;
  5261. this._fragment = '#';
  5262. this._username = base._username;
  5263. this._password = base._password;
  5264. state = 'fragment';
  5265. } else {
  5266. var nextC = input[cursor + 1];
  5267. var nextNextC = input[cursor + 2];
  5268. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  5269. this._host = base._host;
  5270. this._port = base._port;
  5271. this._username = base._username;
  5272. this._password = base._password;
  5273. this._path = base._path.slice();
  5274. this._path.pop();
  5275. }
  5276. state = 'relative path';
  5277. continue;
  5278. }
  5279. break;
  5280. case 'relative slash':
  5281. if ('/' === c || '\\' === c) {
  5282. if ('\\' === c) {
  5283. err('\\ is an invalid code point.');
  5284. }
  5285. if ('file' === this._scheme) {
  5286. state = 'file host';
  5287. } else {
  5288. state = 'authority ignore slashes';
  5289. }
  5290. } else {
  5291. if ('file' !== this._scheme) {
  5292. this._host = base._host;
  5293. this._port = base._port;
  5294. this._username = base._username;
  5295. this._password = base._password;
  5296. }
  5297. state = 'relative path';
  5298. continue;
  5299. }
  5300. break;
  5301. case 'authority first slash':
  5302. if ('/' === c) {
  5303. state = 'authority second slash';
  5304. } else {
  5305. err('Expected \'/\', got: ' + c);
  5306. state = 'authority ignore slashes';
  5307. continue;
  5308. }
  5309. break;
  5310. case 'authority second slash':
  5311. state = 'authority ignore slashes';
  5312. if ('/' !== c) {
  5313. err('Expected \'/\', got: ' + c);
  5314. continue;
  5315. }
  5316. break;
  5317. case 'authority ignore slashes':
  5318. if ('/' !== c && '\\' !== c) {
  5319. state = 'authority';
  5320. continue;
  5321. } else {
  5322. err('Expected authority, got: ' + c);
  5323. }
  5324. break;
  5325. case 'authority':
  5326. if ('@' === c) {
  5327. if (seenAt) {
  5328. err('@ already seen.');
  5329. buffer += '%40';
  5330. }
  5331. seenAt = true;
  5332. for (var i = 0; i < buffer.length; i++) {
  5333. var cp = buffer[i];
  5334. if ('\t' === cp || '\n' === cp || '\r' === cp) {
  5335. err('Invalid whitespace in authority.');
  5336. continue;
  5337. }
  5338. if (':' === cp && null === this._password) {
  5339. this._password = '';
  5340. continue;
  5341. }
  5342. var tempC = percentEscape(cp);
  5343. if (null !== this._password) {
  5344. this._password += tempC;
  5345. } else {
  5346. this._username += tempC;
  5347. }
  5348. }
  5349. buffer = '';
  5350. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  5351. cursor -= buffer.length;
  5352. buffer = '';
  5353. state = 'host';
  5354. continue;
  5355. } else {
  5356. buffer += c;
  5357. }
  5358. break;
  5359. case 'file host':
  5360. if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  5361. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  5362. state = 'relative path';
  5363. } else if (buffer.length === 0) {
  5364. state = 'relative path start';
  5365. } else {
  5366. this._host = IDNAToASCII.call(this, buffer);
  5367. buffer = '';
  5368. state = 'relative path start';
  5369. }
  5370. continue;
  5371. } else if ('\t' === c || '\n' === c || '\r' === c) {
  5372. err('Invalid whitespace in file host.');
  5373. } else {
  5374. buffer += c;
  5375. }
  5376. break;
  5377. case 'host':
  5378. case 'hostname':
  5379. if (':' === c && !seenBracket) {
  5380. this._host = IDNAToASCII.call(this, buffer);
  5381. buffer = '';
  5382. state = 'port';
  5383. if ('hostname' === stateOverride) {
  5384. break loop;
  5385. }
  5386. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  5387. this._host = IDNAToASCII.call(this, buffer);
  5388. buffer = '';
  5389. state = 'relative path start';
  5390. if (stateOverride) {
  5391. break loop;
  5392. }
  5393. continue;
  5394. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  5395. if ('[' === c) {
  5396. seenBracket = true;
  5397. } else if (']' === c) {
  5398. seenBracket = false;
  5399. }
  5400. buffer += c;
  5401. } else {
  5402. err('Invalid code point in host/hostname: ' + c);
  5403. }
  5404. break;
  5405. case 'port':
  5406. if (/[0-9]/.test(c)) {
  5407. buffer += c;
  5408. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c || stateOverride) {
  5409. if ('' !== buffer) {
  5410. var temp = parseInt(buffer, 10);
  5411. if (temp !== relative[this._scheme]) {
  5412. this._port = temp + '';
  5413. }
  5414. buffer = '';
  5415. }
  5416. if (stateOverride) {
  5417. break loop;
  5418. }
  5419. state = 'relative path start';
  5420. continue;
  5421. } else if ('\t' === c || '\n' === c || '\r' === c) {
  5422. err('Invalid code point in port: ' + c);
  5423. } else {
  5424. invalid.call(this);
  5425. }
  5426. break;
  5427. case 'relative path start':
  5428. if ('\\' === c) {
  5429. err('\'\\\' not allowed in path.');
  5430. }
  5431. state = 'relative path';
  5432. if ('/' !== c && '\\' !== c) {
  5433. continue;
  5434. }
  5435. break;
  5436. case 'relative path':
  5437. if (EOF === c || '/' === c || '\\' === c || !stateOverride && ('?' === c || '#' === c)) {
  5438. if ('\\' === c) {
  5439. err('\\ not allowed in relative path.');
  5440. }
  5441. var tmp;
  5442. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  5443. buffer = tmp;
  5444. }
  5445. if ('..' === buffer) {
  5446. this._path.pop();
  5447. if ('/' !== c && '\\' !== c) {
  5448. this._path.push('');
  5449. }
  5450. } else if ('.' === buffer && '/' !== c && '\\' !== c) {
  5451. this._path.push('');
  5452. } else if ('.' !== buffer) {
  5453. if ('file' === this._scheme && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  5454. buffer = buffer[0] + ':';
  5455. }
  5456. this._path.push(buffer);
  5457. }
  5458. buffer = '';
  5459. if ('?' === c) {
  5460. this._query = '?';
  5461. state = 'query';
  5462. } else if ('#' === c) {
  5463. this._fragment = '#';
  5464. state = 'fragment';
  5465. }
  5466. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  5467. buffer += percentEscape(c);
  5468. }
  5469. break;
  5470. case 'query':
  5471. if (!stateOverride && '#' === c) {
  5472. this._fragment = '#';
  5473. state = 'fragment';
  5474. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  5475. this._query += percentEscapeQuery(c);
  5476. }
  5477. break;
  5478. case 'fragment':
  5479. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  5480. this._fragment += c;
  5481. }
  5482. break;
  5483. }
  5484. cursor++;
  5485. }
  5486. }
  5487. function clear() {
  5488. this._scheme = '';
  5489. this._schemeData = '';
  5490. this._username = '';
  5491. this._password = null;
  5492. this._host = '';
  5493. this._port = '';
  5494. this._path = [];
  5495. this._query = '';
  5496. this._fragment = '';
  5497. this._isInvalid = false;
  5498. this._isRelative = false;
  5499. }
  5500. function JURL(url, base)
  5501. {
  5502. if (base !== undefined && !(base instanceof JURL)) {
  5503. base = new JURL(String(base));
  5504. }
  5505. this._url = url;
  5506. clear.call(this);
  5507. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  5508. parse.call(this, input, null, base);
  5509. }
  5510. JURL.prototype = {
  5511. toString: function () {
  5512. return this.href;
  5513. },
  5514. get href() {
  5515. if (this._isInvalid) {
  5516. return this._url;
  5517. }
  5518. var authority = '';
  5519. if ('' !== this._username || null !== this._password) {
  5520. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  5521. }
  5522. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  5523. },
  5524. set href(href) {
  5525. clear.call(this);
  5526. parse.call(this, href);
  5527. },
  5528. get protocol() {
  5529. return this._scheme + ':';
  5530. },
  5531. set protocol(protocol) {
  5532. if (this._isInvalid) {
  5533. return;
  5534. }
  5535. parse.call(this, protocol + ':', 'scheme start');
  5536. },
  5537. get host() {
  5538. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  5539. },
  5540. set host(host) {
  5541. if (this._isInvalid || !this._isRelative) {
  5542. return;
  5543. }
  5544. parse.call(this, host, 'host');
  5545. },
  5546. get hostname() {
  5547. return this._host;
  5548. },
  5549. set hostname(hostname) {
  5550. if (this._isInvalid || !this._isRelative) {
  5551. return;
  5552. }
  5553. parse.call(this, hostname, 'hostname');
  5554. },
  5555. get port() {
  5556. return this._port;
  5557. },
  5558. set port(port) {
  5559. if (this._isInvalid || !this._isRelative) {
  5560. return;
  5561. }
  5562. parse.call(this, port, 'port');
  5563. },
  5564. get pathname() {
  5565. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  5566. },
  5567. set pathname(pathname) {
  5568. if (this._isInvalid || !this._isRelative) {
  5569. return;
  5570. }
  5571. this._path = [];
  5572. parse.call(this, pathname, 'relative path start');
  5573. },
  5574. get search() {
  5575. return this._isInvalid || !this._query || '?' === this._query ? '' : this._query;
  5576. },
  5577. set search(search) {
  5578. if (this._isInvalid || !this._isRelative) {
  5579. return;
  5580. }
  5581. this._query = '?';
  5582. if ('?' === search[0]) {
  5583. search = search.slice(1);
  5584. }
  5585. parse.call(this, search, 'query');
  5586. },
  5587. get hash() {
  5588. return this._isInvalid || !this._fragment || '#' === this._fragment ? '' : this._fragment;
  5589. },
  5590. set hash(hash) {
  5591. if (this._isInvalid) {
  5592. return;
  5593. }
  5594. this._fragment = '#';
  5595. if ('#' === hash[0]) {
  5596. hash = hash.slice(1);
  5597. }
  5598. parse.call(this, hash, 'fragment');
  5599. },
  5600. get origin() {
  5601. var host;
  5602. if (this._isInvalid || !this._scheme) {
  5603. return '';
  5604. }
  5605. switch (this._scheme) {
  5606. case 'data':
  5607. case 'file':
  5608. case 'javascript':
  5609. case 'mailto':
  5610. return 'null';
  5611. }
  5612. host = this.host;
  5613. if (!host) {
  5614. return '';
  5615. }
  5616. return this._scheme + '://' + host;
  5617. }
  5618. };
  5619. var OriginalURL = scope.URL;
  5620. if (OriginalURL) {
  5621. JURL.createObjectURL = function (blob) {
  5622. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  5623. };
  5624. JURL.revokeObjectURL = function (url) {
  5625. OriginalURL.revokeObjectURL(url);
  5626. };
  5627. }
  5628. scope.URL = JURL;
  5629. }(globalScope));
  5630. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  5631. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  5632. exports.OPS = OPS;
  5633. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  5634. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  5635. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  5636. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  5637. exports.AnnotationFlag = AnnotationFlag;
  5638. exports.AnnotationType = AnnotationType;
  5639. exports.FontType = FontType;
  5640. exports.ImageKind = ImageKind;
  5641. exports.InvalidPDFException = InvalidPDFException;
  5642. exports.MessageHandler = MessageHandler;
  5643. exports.MissingDataException = MissingDataException;
  5644. exports.MissingPDFException = MissingPDFException;
  5645. exports.NotImplementedException = NotImplementedException;
  5646. exports.PageViewport = PageViewport;
  5647. exports.PasswordException = PasswordException;
  5648. exports.PasswordResponses = PasswordResponses;
  5649. exports.StatTimer = StatTimer;
  5650. exports.StreamType = StreamType;
  5651. exports.TextRenderingMode = TextRenderingMode;
  5652. exports.UnexpectedResponseException = UnexpectedResponseException;
  5653. exports.UnknownErrorException = UnknownErrorException;
  5654. exports.Util = Util;
  5655. exports.XRefParseException = XRefParseException;
  5656. exports.arrayByteLength = arrayByteLength;
  5657. exports.arraysToBytes = arraysToBytes;
  5658. exports.assert = assert;
  5659. exports.bytesToString = bytesToString;
  5660. exports.createBlob = createBlob;
  5661. exports.createPromiseCapability = createPromiseCapability;
  5662. exports.createObjectURL = createObjectURL;
  5663. exports.deprecated = deprecated;
  5664. exports.error = error;
  5665. exports.getLookupTableFactory = getLookupTableFactory;
  5666. exports.getVerbosityLevel = getVerbosityLevel;
  5667. exports.globalScope = globalScope;
  5668. exports.info = info;
  5669. exports.isArray = isArray;
  5670. exports.isArrayBuffer = isArrayBuffer;
  5671. exports.isBool = isBool;
  5672. exports.isEmptyObj = isEmptyObj;
  5673. exports.isInt = isInt;
  5674. exports.isNum = isNum;
  5675. exports.isString = isString;
  5676. exports.isSpace = isSpace;
  5677. exports.isSameOrigin = isSameOrigin;
  5678. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  5679. exports.isLittleEndian = isLittleEndian;
  5680. exports.isEvalSupported = isEvalSupported;
  5681. exports.loadJpegStream = loadJpegStream;
  5682. exports.log2 = log2;
  5683. exports.readInt8 = readInt8;
  5684. exports.readUint16 = readUint16;
  5685. exports.readUint32 = readUint32;
  5686. exports.removeNullCharacters = removeNullCharacters;
  5687. exports.setVerbosityLevel = setVerbosityLevel;
  5688. exports.shadow = shadow;
  5689. exports.string32 = string32;
  5690. exports.stringToBytes = stringToBytes;
  5691. exports.stringToPDFString = stringToPDFString;
  5692. exports.stringToUTF8String = stringToUTF8String;
  5693. exports.utf8StringToString = utf8StringToString;
  5694. exports.warn = warn;
  5695. }));
  5696. (function (root, factory) {
  5697. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5698. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5699. var error = sharedUtil.error;
  5700. var info = sharedUtil.info;
  5701. var bytesToString = sharedUtil.bytesToString;
  5702. var warn = sharedUtil.warn;
  5703. var isArray = sharedUtil.isArray;
  5704. var Util = sharedUtil.Util;
  5705. var stringToBytes = sharedUtil.stringToBytes;
  5706. var assert = sharedUtil.assert;
  5707. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5708. var ExpertCharset = coreCharsets.ExpertCharset;
  5709. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5710. var StandardEncoding = coreEncodings.StandardEncoding;
  5711. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5712. var MAX_SUBR_NESTING = 10;
  5713. var CFFStandardStrings = [
  5714. '.notdef',
  5715. 'space',
  5716. 'exclam',
  5717. 'quotedbl',
  5718. 'numbersign',
  5719. 'dollar',
  5720. 'percent',
  5721. 'ampersand',
  5722. 'quoteright',
  5723. 'parenleft',
  5724. 'parenright',
  5725. 'asterisk',
  5726. 'plus',
  5727. 'comma',
  5728. 'hyphen',
  5729. 'period',
  5730. 'slash',
  5731. 'zero',
  5732. 'one',
  5733. 'two',
  5734. 'three',
  5735. 'four',
  5736. 'five',
  5737. 'six',
  5738. 'seven',
  5739. 'eight',
  5740. 'nine',
  5741. 'colon',
  5742. 'semicolon',
  5743. 'less',
  5744. 'equal',
  5745. 'greater',
  5746. 'question',
  5747. 'at',
  5748. 'A',
  5749. 'B',
  5750. 'C',
  5751. 'D',
  5752. 'E',
  5753. 'F',
  5754. 'G',
  5755. 'H',
  5756. 'I',
  5757. 'J',
  5758. 'K',
  5759. 'L',
  5760. 'M',
  5761. 'N',
  5762. 'O',
  5763. 'P',
  5764. 'Q',
  5765. 'R',
  5766. 'S',
  5767. 'T',
  5768. 'U',
  5769. 'V',
  5770. 'W',
  5771. 'X',
  5772. 'Y',
  5773. 'Z',
  5774. 'bracketleft',
  5775. 'backslash',
  5776. 'bracketright',
  5777. 'asciicircum',
  5778. 'underscore',
  5779. 'quoteleft',
  5780. 'a',
  5781. 'b',
  5782. 'c',
  5783. 'd',
  5784. 'e',
  5785. 'f',
  5786. 'g',
  5787. 'h',
  5788. 'i',
  5789. 'j',
  5790. 'k',
  5791. 'l',
  5792. 'm',
  5793. 'n',
  5794. 'o',
  5795. 'p',
  5796. 'q',
  5797. 'r',
  5798. 's',
  5799. 't',
  5800. 'u',
  5801. 'v',
  5802. 'w',
  5803. 'x',
  5804. 'y',
  5805. 'z',
  5806. 'braceleft',
  5807. 'bar',
  5808. 'braceright',
  5809. 'asciitilde',
  5810. 'exclamdown',
  5811. 'cent',
  5812. 'sterling',
  5813. 'fraction',
  5814. 'yen',
  5815. 'florin',
  5816. 'section',
  5817. 'currency',
  5818. 'quotesingle',
  5819. 'quotedblleft',
  5820. 'guillemotleft',
  5821. 'guilsinglleft',
  5822. 'guilsinglright',
  5823. 'fi',
  5824. 'fl',
  5825. 'endash',
  5826. 'dagger',
  5827. 'daggerdbl',
  5828. 'periodcentered',
  5829. 'paragraph',
  5830. 'bullet',
  5831. 'quotesinglbase',
  5832. 'quotedblbase',
  5833. 'quotedblright',
  5834. 'guillemotright',
  5835. 'ellipsis',
  5836. 'perthousand',
  5837. 'questiondown',
  5838. 'grave',
  5839. 'acute',
  5840. 'circumflex',
  5841. 'tilde',
  5842. 'macron',
  5843. 'breve',
  5844. 'dotaccent',
  5845. 'dieresis',
  5846. 'ring',
  5847. 'cedilla',
  5848. 'hungarumlaut',
  5849. 'ogonek',
  5850. 'caron',
  5851. 'emdash',
  5852. 'AE',
  5853. 'ordfeminine',
  5854. 'Lslash',
  5855. 'Oslash',
  5856. 'OE',
  5857. 'ordmasculine',
  5858. 'ae',
  5859. 'dotlessi',
  5860. 'lslash',
  5861. 'oslash',
  5862. 'oe',
  5863. 'germandbls',
  5864. 'onesuperior',
  5865. 'logicalnot',
  5866. 'mu',
  5867. 'trademark',
  5868. 'Eth',
  5869. 'onehalf',
  5870. 'plusminus',
  5871. 'Thorn',
  5872. 'onequarter',
  5873. 'divide',
  5874. 'brokenbar',
  5875. 'degree',
  5876. 'thorn',
  5877. 'threequarters',
  5878. 'twosuperior',
  5879. 'registered',
  5880. 'minus',
  5881. 'eth',
  5882. 'multiply',
  5883. 'threesuperior',
  5884. 'copyright',
  5885. 'Aacute',
  5886. 'Acircumflex',
  5887. 'Adieresis',
  5888. 'Agrave',
  5889. 'Aring',
  5890. 'Atilde',
  5891. 'Ccedilla',
  5892. 'Eacute',
  5893. 'Ecircumflex',
  5894. 'Edieresis',
  5895. 'Egrave',
  5896. 'Iacute',
  5897. 'Icircumflex',
  5898. 'Idieresis',
  5899. 'Igrave',
  5900. 'Ntilde',
  5901. 'Oacute',
  5902. 'Ocircumflex',
  5903. 'Odieresis',
  5904. 'Ograve',
  5905. 'Otilde',
  5906. 'Scaron',
  5907. 'Uacute',
  5908. 'Ucircumflex',
  5909. 'Udieresis',
  5910. 'Ugrave',
  5911. 'Yacute',
  5912. 'Ydieresis',
  5913. 'Zcaron',
  5914. 'aacute',
  5915. 'acircumflex',
  5916. 'adieresis',
  5917. 'agrave',
  5918. 'aring',
  5919. 'atilde',
  5920. 'ccedilla',
  5921. 'eacute',
  5922. 'ecircumflex',
  5923. 'edieresis',
  5924. 'egrave',
  5925. 'iacute',
  5926. 'icircumflex',
  5927. 'idieresis',
  5928. 'igrave',
  5929. 'ntilde',
  5930. 'oacute',
  5931. 'ocircumflex',
  5932. 'odieresis',
  5933. 'ograve',
  5934. 'otilde',
  5935. 'scaron',
  5936. 'uacute',
  5937. 'ucircumflex',
  5938. 'udieresis',
  5939. 'ugrave',
  5940. 'yacute',
  5941. 'ydieresis',
  5942. 'zcaron',
  5943. 'exclamsmall',
  5944. 'Hungarumlautsmall',
  5945. 'dollaroldstyle',
  5946. 'dollarsuperior',
  5947. 'ampersandsmall',
  5948. 'Acutesmall',
  5949. 'parenleftsuperior',
  5950. 'parenrightsuperior',
  5951. 'twodotenleader',
  5952. 'onedotenleader',
  5953. 'zerooldstyle',
  5954. 'oneoldstyle',
  5955. 'twooldstyle',
  5956. 'threeoldstyle',
  5957. 'fouroldstyle',
  5958. 'fiveoldstyle',
  5959. 'sixoldstyle',
  5960. 'sevenoldstyle',
  5961. 'eightoldstyle',
  5962. 'nineoldstyle',
  5963. 'commasuperior',
  5964. 'threequartersemdash',
  5965. 'periodsuperior',
  5966. 'questionsmall',
  5967. 'asuperior',
  5968. 'bsuperior',
  5969. 'centsuperior',
  5970. 'dsuperior',
  5971. 'esuperior',
  5972. 'isuperior',
  5973. 'lsuperior',
  5974. 'msuperior',
  5975. 'nsuperior',
  5976. 'osuperior',
  5977. 'rsuperior',
  5978. 'ssuperior',
  5979. 'tsuperior',
  5980. 'ff',
  5981. 'ffi',
  5982. 'ffl',
  5983. 'parenleftinferior',
  5984. 'parenrightinferior',
  5985. 'Circumflexsmall',
  5986. 'hyphensuperior',
  5987. 'Gravesmall',
  5988. 'Asmall',
  5989. 'Bsmall',
  5990. 'Csmall',
  5991. 'Dsmall',
  5992. 'Esmall',
  5993. 'Fsmall',
  5994. 'Gsmall',
  5995. 'Hsmall',
  5996. 'Ismall',
  5997. 'Jsmall',
  5998. 'Ksmall',
  5999. 'Lsmall',
  6000. 'Msmall',
  6001. 'Nsmall',
  6002. 'Osmall',
  6003. 'Psmall',
  6004. 'Qsmall',
  6005. 'Rsmall',
  6006. 'Ssmall',
  6007. 'Tsmall',
  6008. 'Usmall',
  6009. 'Vsmall',
  6010. 'Wsmall',
  6011. 'Xsmall',
  6012. 'Ysmall',
  6013. 'Zsmall',
  6014. 'colonmonetary',
  6015. 'onefitted',
  6016. 'rupiah',
  6017. 'Tildesmall',
  6018. 'exclamdownsmall',
  6019. 'centoldstyle',
  6020. 'Lslashsmall',
  6021. 'Scaronsmall',
  6022. 'Zcaronsmall',
  6023. 'Dieresissmall',
  6024. 'Brevesmall',
  6025. 'Caronsmall',
  6026. 'Dotaccentsmall',
  6027. 'Macronsmall',
  6028. 'figuredash',
  6029. 'hypheninferior',
  6030. 'Ogoneksmall',
  6031. 'Ringsmall',
  6032. 'Cedillasmall',
  6033. 'questiondownsmall',
  6034. 'oneeighth',
  6035. 'threeeighths',
  6036. 'fiveeighths',
  6037. 'seveneighths',
  6038. 'onethird',
  6039. 'twothirds',
  6040. 'zerosuperior',
  6041. 'foursuperior',
  6042. 'fivesuperior',
  6043. 'sixsuperior',
  6044. 'sevensuperior',
  6045. 'eightsuperior',
  6046. 'ninesuperior',
  6047. 'zeroinferior',
  6048. 'oneinferior',
  6049. 'twoinferior',
  6050. 'threeinferior',
  6051. 'fourinferior',
  6052. 'fiveinferior',
  6053. 'sixinferior',
  6054. 'seveninferior',
  6055. 'eightinferior',
  6056. 'nineinferior',
  6057. 'centinferior',
  6058. 'dollarinferior',
  6059. 'periodinferior',
  6060. 'commainferior',
  6061. 'Agravesmall',
  6062. 'Aacutesmall',
  6063. 'Acircumflexsmall',
  6064. 'Atildesmall',
  6065. 'Adieresissmall',
  6066. 'Aringsmall',
  6067. 'AEsmall',
  6068. 'Ccedillasmall',
  6069. 'Egravesmall',
  6070. 'Eacutesmall',
  6071. 'Ecircumflexsmall',
  6072. 'Edieresissmall',
  6073. 'Igravesmall',
  6074. 'Iacutesmall',
  6075. 'Icircumflexsmall',
  6076. 'Idieresissmall',
  6077. 'Ethsmall',
  6078. 'Ntildesmall',
  6079. 'Ogravesmall',
  6080. 'Oacutesmall',
  6081. 'Ocircumflexsmall',
  6082. 'Otildesmall',
  6083. 'Odieresissmall',
  6084. 'OEsmall',
  6085. 'Oslashsmall',
  6086. 'Ugravesmall',
  6087. 'Uacutesmall',
  6088. 'Ucircumflexsmall',
  6089. 'Udieresissmall',
  6090. 'Yacutesmall',
  6091. 'Thornsmall',
  6092. 'Ydieresissmall',
  6093. '001.000',
  6094. '001.001',
  6095. '001.002',
  6096. '001.003',
  6097. 'Black',
  6098. 'Bold',
  6099. 'Book',
  6100. 'Light',
  6101. 'Medium',
  6102. 'Regular',
  6103. 'Roman',
  6104. 'Semibold'
  6105. ];
  6106. var CFFParser = function CFFParserClosure() {
  6107. var CharstringValidationData = [
  6108. null,
  6109. {
  6110. id: 'hstem',
  6111. min: 2,
  6112. stackClearing: true,
  6113. stem: true
  6114. },
  6115. null,
  6116. {
  6117. id: 'vstem',
  6118. min: 2,
  6119. stackClearing: true,
  6120. stem: true
  6121. },
  6122. {
  6123. id: 'vmoveto',
  6124. min: 1,
  6125. stackClearing: true
  6126. },
  6127. {
  6128. id: 'rlineto',
  6129. min: 2,
  6130. resetStack: true
  6131. },
  6132. {
  6133. id: 'hlineto',
  6134. min: 1,
  6135. resetStack: true
  6136. },
  6137. {
  6138. id: 'vlineto',
  6139. min: 1,
  6140. resetStack: true
  6141. },
  6142. {
  6143. id: 'rrcurveto',
  6144. min: 6,
  6145. resetStack: true
  6146. },
  6147. null,
  6148. {
  6149. id: 'callsubr',
  6150. min: 1,
  6151. undefStack: true
  6152. },
  6153. {
  6154. id: 'return',
  6155. min: 0,
  6156. undefStack: true
  6157. },
  6158. null,
  6159. null,
  6160. {
  6161. id: 'endchar',
  6162. min: 0,
  6163. stackClearing: true
  6164. },
  6165. null,
  6166. null,
  6167. null,
  6168. {
  6169. id: 'hstemhm',
  6170. min: 2,
  6171. stackClearing: true,
  6172. stem: true
  6173. },
  6174. {
  6175. id: 'hintmask',
  6176. min: 0,
  6177. stackClearing: true
  6178. },
  6179. {
  6180. id: 'cntrmask',
  6181. min: 0,
  6182. stackClearing: true
  6183. },
  6184. {
  6185. id: 'rmoveto',
  6186. min: 2,
  6187. stackClearing: true
  6188. },
  6189. {
  6190. id: 'hmoveto',
  6191. min: 1,
  6192. stackClearing: true
  6193. },
  6194. {
  6195. id: 'vstemhm',
  6196. min: 2,
  6197. stackClearing: true,
  6198. stem: true
  6199. },
  6200. {
  6201. id: 'rcurveline',
  6202. min: 8,
  6203. resetStack: true
  6204. },
  6205. {
  6206. id: 'rlinecurve',
  6207. min: 8,
  6208. resetStack: true
  6209. },
  6210. {
  6211. id: 'vvcurveto',
  6212. min: 4,
  6213. resetStack: true
  6214. },
  6215. {
  6216. id: 'hhcurveto',
  6217. min: 4,
  6218. resetStack: true
  6219. },
  6220. null,
  6221. {
  6222. id: 'callgsubr',
  6223. min: 1,
  6224. undefStack: true
  6225. },
  6226. {
  6227. id: 'vhcurveto',
  6228. min: 4,
  6229. resetStack: true
  6230. },
  6231. {
  6232. id: 'hvcurveto',
  6233. min: 4,
  6234. resetStack: true
  6235. }
  6236. ];
  6237. var CharstringValidationData12 = [
  6238. null,
  6239. null,
  6240. null,
  6241. {
  6242. id: 'and',
  6243. min: 2,
  6244. stackDelta: -1
  6245. },
  6246. {
  6247. id: 'or',
  6248. min: 2,
  6249. stackDelta: -1
  6250. },
  6251. {
  6252. id: 'not',
  6253. min: 1,
  6254. stackDelta: 0
  6255. },
  6256. null,
  6257. null,
  6258. null,
  6259. {
  6260. id: 'abs',
  6261. min: 1,
  6262. stackDelta: 0
  6263. },
  6264. {
  6265. id: 'add',
  6266. min: 2,
  6267. stackDelta: -1,
  6268. stackFn: function stack_div(stack, index) {
  6269. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6270. }
  6271. },
  6272. {
  6273. id: 'sub',
  6274. min: 2,
  6275. stackDelta: -1,
  6276. stackFn: function stack_div(stack, index) {
  6277. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6278. }
  6279. },
  6280. {
  6281. id: 'div',
  6282. min: 2,
  6283. stackDelta: -1,
  6284. stackFn: function stack_div(stack, index) {
  6285. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6286. }
  6287. },
  6288. null,
  6289. {
  6290. id: 'neg',
  6291. min: 1,
  6292. stackDelta: 0,
  6293. stackFn: function stack_div(stack, index) {
  6294. stack[index - 1] = -stack[index - 1];
  6295. }
  6296. },
  6297. {
  6298. id: 'eq',
  6299. min: 2,
  6300. stackDelta: -1
  6301. },
  6302. null,
  6303. null,
  6304. {
  6305. id: 'drop',
  6306. min: 1,
  6307. stackDelta: -1
  6308. },
  6309. null,
  6310. {
  6311. id: 'put',
  6312. min: 2,
  6313. stackDelta: -2
  6314. },
  6315. {
  6316. id: 'get',
  6317. min: 1,
  6318. stackDelta: 0
  6319. },
  6320. {
  6321. id: 'ifelse',
  6322. min: 4,
  6323. stackDelta: -3
  6324. },
  6325. {
  6326. id: 'random',
  6327. min: 0,
  6328. stackDelta: 1
  6329. },
  6330. {
  6331. id: 'mul',
  6332. min: 2,
  6333. stackDelta: -1,
  6334. stackFn: function stack_div(stack, index) {
  6335. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6336. }
  6337. },
  6338. null,
  6339. {
  6340. id: 'sqrt',
  6341. min: 1,
  6342. stackDelta: 0
  6343. },
  6344. {
  6345. id: 'dup',
  6346. min: 1,
  6347. stackDelta: 1
  6348. },
  6349. {
  6350. id: 'exch',
  6351. min: 2,
  6352. stackDelta: 0
  6353. },
  6354. {
  6355. id: 'index',
  6356. min: 2,
  6357. stackDelta: 0
  6358. },
  6359. {
  6360. id: 'roll',
  6361. min: 3,
  6362. stackDelta: -2
  6363. },
  6364. null,
  6365. null,
  6366. null,
  6367. {
  6368. id: 'hflex',
  6369. min: 7,
  6370. resetStack: true
  6371. },
  6372. {
  6373. id: 'flex',
  6374. min: 13,
  6375. resetStack: true
  6376. },
  6377. {
  6378. id: 'hflex1',
  6379. min: 9,
  6380. resetStack: true
  6381. },
  6382. {
  6383. id: 'flex1',
  6384. min: 11,
  6385. resetStack: true
  6386. }
  6387. ];
  6388. function CFFParser(file, properties, seacAnalysisEnabled) {
  6389. this.bytes = file.getBytes();
  6390. this.properties = properties;
  6391. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6392. }
  6393. CFFParser.prototype = {
  6394. parse: function CFFParser_parse() {
  6395. var properties = this.properties;
  6396. var cff = new CFF();
  6397. this.cff = cff;
  6398. var header = this.parseHeader();
  6399. var nameIndex = this.parseIndex(header.endPos);
  6400. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6401. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6402. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6403. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6404. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6405. cff.header = header.obj;
  6406. cff.names = this.parseNameIndex(nameIndex.obj);
  6407. cff.strings = this.parseStringIndex(stringIndex.obj);
  6408. cff.topDict = topDict;
  6409. cff.globalSubrIndex = globalSubrIndex.obj;
  6410. this.parsePrivateDict(cff.topDict);
  6411. cff.isCIDFont = topDict.hasName('ROS');
  6412. var charStringOffset = topDict.getByName('CharStrings');
  6413. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6414. var fontMatrix = topDict.getByName('FontMatrix');
  6415. if (fontMatrix) {
  6416. properties.fontMatrix = fontMatrix;
  6417. }
  6418. var fontBBox = topDict.getByName('FontBBox');
  6419. if (fontBBox) {
  6420. properties.ascent = fontBBox[3];
  6421. properties.descent = fontBBox[1];
  6422. properties.ascentScaled = true;
  6423. }
  6424. var charset, encoding;
  6425. if (cff.isCIDFont) {
  6426. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6427. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6428. var dictRaw = fdArrayIndex.get(i);
  6429. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6430. this.parsePrivateDict(fontDict);
  6431. cff.fdArray.push(fontDict);
  6432. }
  6433. encoding = null;
  6434. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6435. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6436. } else {
  6437. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6438. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6439. }
  6440. cff.charset = charset;
  6441. cff.encoding = encoding;
  6442. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6443. cff.charStrings = charStringsAndSeacs.charStrings;
  6444. cff.seacs = charStringsAndSeacs.seacs;
  6445. cff.widths = charStringsAndSeacs.widths;
  6446. return cff;
  6447. },
  6448. parseHeader: function CFFParser_parseHeader() {
  6449. var bytes = this.bytes;
  6450. var bytesLength = bytes.length;
  6451. var offset = 0;
  6452. while (offset < bytesLength && bytes[offset] !== 1) {
  6453. ++offset;
  6454. }
  6455. if (offset >= bytesLength) {
  6456. error('Invalid CFF header');
  6457. } else if (offset !== 0) {
  6458. info('cff data is shifted');
  6459. bytes = bytes.subarray(offset);
  6460. this.bytes = bytes;
  6461. }
  6462. var major = bytes[0];
  6463. var minor = bytes[1];
  6464. var hdrSize = bytes[2];
  6465. var offSize = bytes[3];
  6466. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6467. return {
  6468. obj: header,
  6469. endPos: hdrSize
  6470. };
  6471. },
  6472. parseDict: function CFFParser_parseDict(dict) {
  6473. var pos = 0;
  6474. function parseOperand() {
  6475. var value = dict[pos++];
  6476. if (value === 30) {
  6477. return parseFloatOperand();
  6478. } else if (value === 28) {
  6479. value = dict[pos++];
  6480. value = (value << 24 | dict[pos++] << 16) >> 16;
  6481. return value;
  6482. } else if (value === 29) {
  6483. value = dict[pos++];
  6484. value = value << 8 | dict[pos++];
  6485. value = value << 8 | dict[pos++];
  6486. value = value << 8 | dict[pos++];
  6487. return value;
  6488. } else if (value >= 32 && value <= 246) {
  6489. return value - 139;
  6490. } else if (value >= 247 && value <= 250) {
  6491. return (value - 247) * 256 + dict[pos++] + 108;
  6492. } else if (value >= 251 && value <= 254) {
  6493. return -((value - 251) * 256) - dict[pos++] - 108;
  6494. } else {
  6495. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6496. return NaN;
  6497. }
  6498. }
  6499. function parseFloatOperand() {
  6500. var str = '';
  6501. var eof = 15;
  6502. var lookup = [
  6503. '0',
  6504. '1',
  6505. '2',
  6506. '3',
  6507. '4',
  6508. '5',
  6509. '6',
  6510. '7',
  6511. '8',
  6512. '9',
  6513. '.',
  6514. 'E',
  6515. 'E-',
  6516. null,
  6517. '-'
  6518. ];
  6519. var length = dict.length;
  6520. while (pos < length) {
  6521. var b = dict[pos++];
  6522. var b1 = b >> 4;
  6523. var b2 = b & 15;
  6524. if (b1 === eof) {
  6525. break;
  6526. }
  6527. str += lookup[b1];
  6528. if (b2 === eof) {
  6529. break;
  6530. }
  6531. str += lookup[b2];
  6532. }
  6533. return parseFloat(str);
  6534. }
  6535. var operands = [];
  6536. var entries = [];
  6537. pos = 0;
  6538. var end = dict.length;
  6539. while (pos < end) {
  6540. var b = dict[pos];
  6541. if (b <= 21) {
  6542. if (b === 12) {
  6543. b = b << 8 | dict[++pos];
  6544. }
  6545. entries.push([
  6546. b,
  6547. operands
  6548. ]);
  6549. operands = [];
  6550. ++pos;
  6551. } else {
  6552. operands.push(parseOperand());
  6553. }
  6554. }
  6555. return entries;
  6556. },
  6557. parseIndex: function CFFParser_parseIndex(pos) {
  6558. var cffIndex = new CFFIndex();
  6559. var bytes = this.bytes;
  6560. var count = bytes[pos++] << 8 | bytes[pos++];
  6561. var offsets = [];
  6562. var end = pos;
  6563. var i, ii;
  6564. if (count !== 0) {
  6565. var offsetSize = bytes[pos++];
  6566. var startPos = pos + (count + 1) * offsetSize - 1;
  6567. for (i = 0, ii = count + 1; i < ii; ++i) {
  6568. var offset = 0;
  6569. for (var j = 0; j < offsetSize; ++j) {
  6570. offset <<= 8;
  6571. offset += bytes[pos++];
  6572. }
  6573. offsets.push(startPos + offset);
  6574. }
  6575. end = offsets[count];
  6576. }
  6577. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6578. var offsetStart = offsets[i];
  6579. var offsetEnd = offsets[i + 1];
  6580. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6581. }
  6582. return {
  6583. obj: cffIndex,
  6584. endPos: end
  6585. };
  6586. },
  6587. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6588. var names = [];
  6589. for (var i = 0, ii = index.count; i < ii; ++i) {
  6590. var name = index.get(i);
  6591. var length = Math.min(name.length, 127);
  6592. var data = [];
  6593. for (var j = 0; j < length; ++j) {
  6594. var c = name[j];
  6595. if (j === 0 && c === 0) {
  6596. data[j] = c;
  6597. continue;
  6598. }
  6599. 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)
  6600. {
  6601. data[j] = 95;
  6602. continue;
  6603. }
  6604. data[j] = c;
  6605. }
  6606. names.push(bytesToString(data));
  6607. }
  6608. return names;
  6609. },
  6610. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6611. var strings = new CFFStrings();
  6612. for (var i = 0, ii = index.count; i < ii; ++i) {
  6613. var data = index.get(i);
  6614. strings.add(bytesToString(data));
  6615. }
  6616. return strings;
  6617. },
  6618. createDict: function CFFParser_createDict(Type, dict, strings) {
  6619. var cffDict = new Type(strings);
  6620. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6621. var pair = dict[i];
  6622. var key = pair[0];
  6623. var value = pair[1];
  6624. cffDict.setByKey(key, value);
  6625. }
  6626. return cffDict;
  6627. },
  6628. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6629. if (state.callDepth > MAX_SUBR_NESTING) {
  6630. return false;
  6631. }
  6632. var stackSize = state.stackSize;
  6633. var stack = state.stack;
  6634. var length = data.length;
  6635. for (var j = 0; j < length;) {
  6636. var value = data[j++];
  6637. var validationCommand = null;
  6638. if (value === 12) {
  6639. var q = data[j++];
  6640. if (q === 0) {
  6641. data[j - 2] = 139;
  6642. data[j - 1] = 22;
  6643. stackSize = 0;
  6644. } else {
  6645. validationCommand = CharstringValidationData12[q];
  6646. }
  6647. } else if (value === 28) {
  6648. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6649. j += 2;
  6650. stackSize++;
  6651. } else if (value === 14) {
  6652. if (stackSize >= 4) {
  6653. stackSize -= 4;
  6654. if (this.seacAnalysisEnabled) {
  6655. state.seac = stack.slice(stackSize, stackSize + 4);
  6656. return false;
  6657. }
  6658. }
  6659. validationCommand = CharstringValidationData[value];
  6660. } else if (value >= 32 && value <= 246) {
  6661. stack[stackSize] = value - 139;
  6662. stackSize++;
  6663. } else if (value >= 247 && value <= 254) {
  6664. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6665. j++;
  6666. stackSize++;
  6667. } else if (value === 255) {
  6668. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6669. j += 4;
  6670. stackSize++;
  6671. } else if (value === 19 || value === 20) {
  6672. state.hints += stackSize >> 1;
  6673. j += state.hints + 7 >> 3;
  6674. stackSize %= 2;
  6675. validationCommand = CharstringValidationData[value];
  6676. } else if (value === 10 || value === 29) {
  6677. var subrsIndex;
  6678. if (value === 10) {
  6679. subrsIndex = localSubrIndex;
  6680. } else {
  6681. subrsIndex = globalSubrIndex;
  6682. }
  6683. if (!subrsIndex) {
  6684. validationCommand = CharstringValidationData[value];
  6685. warn('Missing subrsIndex for ' + validationCommand.id);
  6686. return false;
  6687. }
  6688. var bias = 32768;
  6689. if (subrsIndex.count < 1240) {
  6690. bias = 107;
  6691. } else if (subrsIndex.count < 33900) {
  6692. bias = 1131;
  6693. }
  6694. var subrNumber = stack[--stackSize] + bias;
  6695. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6696. validationCommand = CharstringValidationData[value];
  6697. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6698. return false;
  6699. }
  6700. state.stackSize = stackSize;
  6701. state.callDepth++;
  6702. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6703. if (!valid) {
  6704. return false;
  6705. }
  6706. state.callDepth--;
  6707. stackSize = state.stackSize;
  6708. continue;
  6709. } else if (value === 11) {
  6710. state.stackSize = stackSize;
  6711. return true;
  6712. } else {
  6713. validationCommand = CharstringValidationData[value];
  6714. }
  6715. if (validationCommand) {
  6716. if (validationCommand.stem) {
  6717. state.hints += stackSize >> 1;
  6718. }
  6719. if ('min' in validationCommand) {
  6720. if (!state.undefStack && stackSize < validationCommand.min) {
  6721. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6722. return false;
  6723. }
  6724. }
  6725. if (state.firstStackClearing && validationCommand.stackClearing) {
  6726. state.firstStackClearing = false;
  6727. stackSize -= validationCommand.min;
  6728. if (stackSize >= 2 && validationCommand.stem) {
  6729. stackSize %= 2;
  6730. } else if (stackSize > 1) {
  6731. warn('Found too many parameters for stack-clearing command');
  6732. }
  6733. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6734. state.width = stack[stackSize - 1];
  6735. }
  6736. }
  6737. if ('stackDelta' in validationCommand) {
  6738. if ('stackFn' in validationCommand) {
  6739. validationCommand.stackFn(stack, stackSize);
  6740. }
  6741. stackSize += validationCommand.stackDelta;
  6742. } else if (validationCommand.stackClearing) {
  6743. stackSize = 0;
  6744. } else if (validationCommand.resetStack) {
  6745. stackSize = 0;
  6746. state.undefStack = false;
  6747. } else if (validationCommand.undefStack) {
  6748. stackSize = 0;
  6749. state.undefStack = true;
  6750. state.firstStackClearing = false;
  6751. }
  6752. }
  6753. }
  6754. state.stackSize = stackSize;
  6755. return true;
  6756. },
  6757. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6758. var seacs = [];
  6759. var widths = [];
  6760. var count = charStrings.count;
  6761. for (var i = 0; i < count; i++) {
  6762. var charstring = charStrings.get(i);
  6763. var state = {
  6764. callDepth: 0,
  6765. stackSize: 0,
  6766. stack: [],
  6767. undefStack: true,
  6768. hints: 0,
  6769. firstStackClearing: true,
  6770. seac: null,
  6771. width: null
  6772. };
  6773. var valid = true;
  6774. var localSubrToUse = null;
  6775. if (fdSelect && fdArray.length) {
  6776. var fdIndex = fdSelect.getFDIndex(i);
  6777. if (fdIndex === -1) {
  6778. warn('Glyph index is not in fd select.');
  6779. valid = false;
  6780. }
  6781. if (fdIndex >= fdArray.length) {
  6782. warn('Invalid fd index for glyph index.');
  6783. valid = false;
  6784. }
  6785. if (valid) {
  6786. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6787. }
  6788. } else if (localSubrIndex) {
  6789. localSubrToUse = localSubrIndex;
  6790. }
  6791. if (valid) {
  6792. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6793. }
  6794. if (state.width !== null) {
  6795. widths[i] = state.width;
  6796. }
  6797. if (state.seac !== null) {
  6798. seacs[i] = state.seac;
  6799. }
  6800. if (!valid) {
  6801. charStrings.set(i, new Uint8Array([14]));
  6802. }
  6803. }
  6804. return {
  6805. charStrings: charStrings,
  6806. seacs: seacs,
  6807. widths: widths
  6808. };
  6809. },
  6810. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6811. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6812. parentDict.setByKey(18, [
  6813. 0,
  6814. 0
  6815. ]);
  6816. parentDict.privateDict = privateDict;
  6817. },
  6818. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6819. if (!parentDict.hasName('Private')) {
  6820. this.emptyPrivateDictionary(parentDict);
  6821. return;
  6822. }
  6823. var privateOffset = parentDict.getByName('Private');
  6824. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6825. parentDict.removeByName('Private');
  6826. return;
  6827. }
  6828. var size = privateOffset[0];
  6829. var offset = privateOffset[1];
  6830. if (size === 0 || offset >= this.bytes.length) {
  6831. this.emptyPrivateDictionary(parentDict);
  6832. return;
  6833. }
  6834. var privateDictEnd = offset + size;
  6835. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6836. var dict = this.parseDict(dictData);
  6837. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6838. parentDict.privateDict = privateDict;
  6839. if (!privateDict.getByName('Subrs')) {
  6840. return;
  6841. }
  6842. var subrsOffset = privateDict.getByName('Subrs');
  6843. var relativeOffset = offset + subrsOffset;
  6844. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6845. this.emptyPrivateDictionary(parentDict);
  6846. return;
  6847. }
  6848. var subrsIndex = this.parseIndex(relativeOffset);
  6849. privateDict.subrsIndex = subrsIndex.obj;
  6850. },
  6851. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6852. if (pos === 0) {
  6853. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6854. } else if (pos === 1) {
  6855. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6856. } else if (pos === 2) {
  6857. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6858. }
  6859. var bytes = this.bytes;
  6860. var start = pos;
  6861. var format = bytes[pos++];
  6862. var charset = ['.notdef'];
  6863. var id, count, i;
  6864. length -= 1;
  6865. switch (format) {
  6866. case 0:
  6867. for (i = 0; i < length; i++) {
  6868. id = bytes[pos++] << 8 | bytes[pos++];
  6869. charset.push(cid ? id : strings.get(id));
  6870. }
  6871. break;
  6872. case 1:
  6873. while (charset.length <= length) {
  6874. id = bytes[pos++] << 8 | bytes[pos++];
  6875. count = bytes[pos++];
  6876. for (i = 0; i <= count; i++) {
  6877. charset.push(cid ? id++ : strings.get(id++));
  6878. }
  6879. }
  6880. break;
  6881. case 2:
  6882. while (charset.length <= length) {
  6883. id = bytes[pos++] << 8 | bytes[pos++];
  6884. count = bytes[pos++] << 8 | bytes[pos++];
  6885. for (i = 0; i <= count; i++) {
  6886. charset.push(cid ? id++ : strings.get(id++));
  6887. }
  6888. }
  6889. break;
  6890. default:
  6891. error('Unknown charset format');
  6892. }
  6893. var end = pos;
  6894. var raw = bytes.subarray(start, end);
  6895. return new CFFCharset(false, format, charset, raw);
  6896. },
  6897. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6898. var encoding = Object.create(null);
  6899. var bytes = this.bytes;
  6900. var predefined = false;
  6901. var hasSupplement = false;
  6902. var format, i, ii;
  6903. var raw = null;
  6904. function readSupplement() {
  6905. var supplementsCount = bytes[pos++];
  6906. for (i = 0; i < supplementsCount; i++) {
  6907. var code = bytes[pos++];
  6908. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6909. encoding[code] = charset.indexOf(strings.get(sid));
  6910. }
  6911. }
  6912. if (pos === 0 || pos === 1) {
  6913. predefined = true;
  6914. format = pos;
  6915. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6916. for (i = 0, ii = charset.length; i < ii; i++) {
  6917. var index = baseEncoding.indexOf(charset[i]);
  6918. if (index !== -1) {
  6919. encoding[index] = i;
  6920. }
  6921. }
  6922. } else {
  6923. var dataStart = pos;
  6924. format = bytes[pos++];
  6925. switch (format & 0x7f) {
  6926. case 0:
  6927. var glyphsCount = bytes[pos++];
  6928. for (i = 1; i <= glyphsCount; i++) {
  6929. encoding[bytes[pos++]] = i;
  6930. }
  6931. break;
  6932. case 1:
  6933. var rangesCount = bytes[pos++];
  6934. var gid = 1;
  6935. for (i = 0; i < rangesCount; i++) {
  6936. var start = bytes[pos++];
  6937. var left = bytes[pos++];
  6938. for (var j = start; j <= start + left; j++) {
  6939. encoding[j] = gid++;
  6940. }
  6941. }
  6942. break;
  6943. default:
  6944. error('Unknown encoding format: ' + format + ' in CFF');
  6945. break;
  6946. }
  6947. var dataEnd = pos;
  6948. if (format & 0x80) {
  6949. bytes[dataStart] &= 0x7f;
  6950. readSupplement();
  6951. hasSupplement = true;
  6952. }
  6953. raw = bytes.subarray(dataStart, dataEnd);
  6954. }
  6955. format = format & 0x7f;
  6956. return new CFFEncoding(predefined, format, encoding, raw);
  6957. },
  6958. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6959. var start = pos;
  6960. var bytes = this.bytes;
  6961. var format = bytes[pos++];
  6962. var fdSelect = [], rawBytes;
  6963. var i, invalidFirstGID = false;
  6964. switch (format) {
  6965. case 0:
  6966. for (i = 0; i < length; ++i) {
  6967. var id = bytes[pos++];
  6968. fdSelect.push(id);
  6969. }
  6970. rawBytes = bytes.subarray(start, pos);
  6971. break;
  6972. case 3:
  6973. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6974. for (i = 0; i < rangesCount; ++i) {
  6975. var first = bytes[pos++] << 8 | bytes[pos++];
  6976. if (i === 0 && first !== 0) {
  6977. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6978. invalidFirstGID = true;
  6979. first = 0;
  6980. }
  6981. var fdIndex = bytes[pos++];
  6982. var next = bytes[pos] << 8 | bytes[pos + 1];
  6983. for (var j = first; j < next; ++j) {
  6984. fdSelect.push(fdIndex);
  6985. }
  6986. }
  6987. pos += 2;
  6988. rawBytes = bytes.subarray(start, pos);
  6989. if (invalidFirstGID) {
  6990. rawBytes[3] = rawBytes[4] = 0;
  6991. }
  6992. break;
  6993. default:
  6994. error('parseFDSelect: Unknown format "' + format + '".');
  6995. break;
  6996. }
  6997. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  6998. return new CFFFDSelect(fdSelect, rawBytes);
  6999. }
  7000. };
  7001. return CFFParser;
  7002. }();
  7003. var CFF = function CFFClosure() {
  7004. function CFF() {
  7005. this.header = null;
  7006. this.names = [];
  7007. this.topDict = null;
  7008. this.strings = new CFFStrings();
  7009. this.globalSubrIndex = null;
  7010. this.encoding = null;
  7011. this.charset = null;
  7012. this.charStrings = null;
  7013. this.fdArray = [];
  7014. this.fdSelect = null;
  7015. this.isCIDFont = false;
  7016. }
  7017. return CFF;
  7018. }();
  7019. var CFFHeader = function CFFHeaderClosure() {
  7020. function CFFHeader(major, minor, hdrSize, offSize) {
  7021. this.major = major;
  7022. this.minor = minor;
  7023. this.hdrSize = hdrSize;
  7024. this.offSize = offSize;
  7025. }
  7026. return CFFHeader;
  7027. }();
  7028. var CFFStrings = function CFFStringsClosure() {
  7029. function CFFStrings() {
  7030. this.strings = [];
  7031. }
  7032. CFFStrings.prototype = {
  7033. get: function CFFStrings_get(index) {
  7034. if (index >= 0 && index <= 390) {
  7035. return CFFStandardStrings[index];
  7036. }
  7037. if (index - 391 <= this.strings.length) {
  7038. return this.strings[index - 391];
  7039. }
  7040. return CFFStandardStrings[0];
  7041. },
  7042. add: function CFFStrings_add(value) {
  7043. this.strings.push(value);
  7044. },
  7045. get count() {
  7046. return this.strings.length;
  7047. }
  7048. };
  7049. return CFFStrings;
  7050. }();
  7051. var CFFIndex = function CFFIndexClosure() {
  7052. function CFFIndex() {
  7053. this.objects = [];
  7054. this.length = 0;
  7055. }
  7056. CFFIndex.prototype = {
  7057. add: function CFFIndex_add(data) {
  7058. this.length += data.length;
  7059. this.objects.push(data);
  7060. },
  7061. set: function CFFIndex_set(index, data) {
  7062. this.length += data.length - this.objects[index].length;
  7063. this.objects[index] = data;
  7064. },
  7065. get: function CFFIndex_get(index) {
  7066. return this.objects[index];
  7067. },
  7068. get count() {
  7069. return this.objects.length;
  7070. }
  7071. };
  7072. return CFFIndex;
  7073. }();
  7074. var CFFDict = function CFFDictClosure() {
  7075. function CFFDict(tables, strings) {
  7076. this.keyToNameMap = tables.keyToNameMap;
  7077. this.nameToKeyMap = tables.nameToKeyMap;
  7078. this.defaults = tables.defaults;
  7079. this.types = tables.types;
  7080. this.opcodes = tables.opcodes;
  7081. this.order = tables.order;
  7082. this.strings = strings;
  7083. this.values = Object.create(null);
  7084. }
  7085. CFFDict.prototype = {
  7086. setByKey: function CFFDict_setByKey(key, value) {
  7087. if (!(key in this.keyToNameMap)) {
  7088. return false;
  7089. }
  7090. var valueLength = value.length;
  7091. if (valueLength === 0) {
  7092. return true;
  7093. }
  7094. for (var i = 0; i < valueLength; i++) {
  7095. if (isNaN(value[i])) {
  7096. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7097. return true;
  7098. }
  7099. }
  7100. var type = this.types[key];
  7101. if (type === 'num' || type === 'sid' || type === 'offset') {
  7102. value = value[0];
  7103. }
  7104. this.values[key] = value;
  7105. return true;
  7106. },
  7107. setByName: function CFFDict_setByName(name, value) {
  7108. if (!(name in this.nameToKeyMap)) {
  7109. error('Invalid dictionary name "' + name + '"');
  7110. }
  7111. this.values[this.nameToKeyMap[name]] = value;
  7112. },
  7113. hasName: function CFFDict_hasName(name) {
  7114. return this.nameToKeyMap[name] in this.values;
  7115. },
  7116. getByName: function CFFDict_getByName(name) {
  7117. if (!(name in this.nameToKeyMap)) {
  7118. error('Invalid dictionary name "' + name + '"');
  7119. }
  7120. var key = this.nameToKeyMap[name];
  7121. if (!(key in this.values)) {
  7122. return this.defaults[key];
  7123. }
  7124. return this.values[key];
  7125. },
  7126. removeByName: function CFFDict_removeByName(name) {
  7127. delete this.values[this.nameToKeyMap[name]];
  7128. }
  7129. };
  7130. CFFDict.createTables = function CFFDict_createTables(layout) {
  7131. var tables = {
  7132. keyToNameMap: {},
  7133. nameToKeyMap: {},
  7134. defaults: {},
  7135. types: {},
  7136. opcodes: {},
  7137. order: []
  7138. };
  7139. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7140. var entry = layout[i];
  7141. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7142. tables.keyToNameMap[key] = entry[1];
  7143. tables.nameToKeyMap[entry[1]] = key;
  7144. tables.types[key] = entry[2];
  7145. tables.defaults[key] = entry[3];
  7146. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7147. tables.order.push(key);
  7148. }
  7149. return tables;
  7150. };
  7151. return CFFDict;
  7152. }();
  7153. var CFFTopDict = function CFFTopDictClosure() {
  7154. var layout = [
  7155. [
  7156. [
  7157. 12,
  7158. 30
  7159. ],
  7160. 'ROS',
  7161. [
  7162. 'sid',
  7163. 'sid',
  7164. 'num'
  7165. ],
  7166. null
  7167. ],
  7168. [
  7169. [
  7170. 12,
  7171. 20
  7172. ],
  7173. 'SyntheticBase',
  7174. 'num',
  7175. null
  7176. ],
  7177. [
  7178. 0,
  7179. 'version',
  7180. 'sid',
  7181. null
  7182. ],
  7183. [
  7184. 1,
  7185. 'Notice',
  7186. 'sid',
  7187. null
  7188. ],
  7189. [
  7190. [
  7191. 12,
  7192. 0
  7193. ],
  7194. 'Copyright',
  7195. 'sid',
  7196. null
  7197. ],
  7198. [
  7199. 2,
  7200. 'FullName',
  7201. 'sid',
  7202. null
  7203. ],
  7204. [
  7205. 3,
  7206. 'FamilyName',
  7207. 'sid',
  7208. null
  7209. ],
  7210. [
  7211. 4,
  7212. 'Weight',
  7213. 'sid',
  7214. null
  7215. ],
  7216. [
  7217. [
  7218. 12,
  7219. 1
  7220. ],
  7221. 'isFixedPitch',
  7222. 'num',
  7223. 0
  7224. ],
  7225. [
  7226. [
  7227. 12,
  7228. 2
  7229. ],
  7230. 'ItalicAngle',
  7231. 'num',
  7232. 0
  7233. ],
  7234. [
  7235. [
  7236. 12,
  7237. 3
  7238. ],
  7239. 'UnderlinePosition',
  7240. 'num',
  7241. -100
  7242. ],
  7243. [
  7244. [
  7245. 12,
  7246. 4
  7247. ],
  7248. 'UnderlineThickness',
  7249. 'num',
  7250. 50
  7251. ],
  7252. [
  7253. [
  7254. 12,
  7255. 5
  7256. ],
  7257. 'PaintType',
  7258. 'num',
  7259. 0
  7260. ],
  7261. [
  7262. [
  7263. 12,
  7264. 6
  7265. ],
  7266. 'CharstringType',
  7267. 'num',
  7268. 2
  7269. ],
  7270. [
  7271. [
  7272. 12,
  7273. 7
  7274. ],
  7275. 'FontMatrix',
  7276. [
  7277. 'num',
  7278. 'num',
  7279. 'num',
  7280. 'num',
  7281. 'num',
  7282. 'num'
  7283. ],
  7284. [
  7285. 0.001,
  7286. 0,
  7287. 0,
  7288. 0.001,
  7289. 0,
  7290. 0
  7291. ]
  7292. ],
  7293. [
  7294. 13,
  7295. 'UniqueID',
  7296. 'num',
  7297. null
  7298. ],
  7299. [
  7300. 5,
  7301. 'FontBBox',
  7302. [
  7303. 'num',
  7304. 'num',
  7305. 'num',
  7306. 'num'
  7307. ],
  7308. [
  7309. 0,
  7310. 0,
  7311. 0,
  7312. 0
  7313. ]
  7314. ],
  7315. [
  7316. [
  7317. 12,
  7318. 8
  7319. ],
  7320. 'StrokeWidth',
  7321. 'num',
  7322. 0
  7323. ],
  7324. [
  7325. 14,
  7326. 'XUID',
  7327. 'array',
  7328. null
  7329. ],
  7330. [
  7331. 15,
  7332. 'charset',
  7333. 'offset',
  7334. 0
  7335. ],
  7336. [
  7337. 16,
  7338. 'Encoding',
  7339. 'offset',
  7340. 0
  7341. ],
  7342. [
  7343. 17,
  7344. 'CharStrings',
  7345. 'offset',
  7346. 0
  7347. ],
  7348. [
  7349. 18,
  7350. 'Private',
  7351. [
  7352. 'offset',
  7353. 'offset'
  7354. ],
  7355. null
  7356. ],
  7357. [
  7358. [
  7359. 12,
  7360. 21
  7361. ],
  7362. 'PostScript',
  7363. 'sid',
  7364. null
  7365. ],
  7366. [
  7367. [
  7368. 12,
  7369. 22
  7370. ],
  7371. 'BaseFontName',
  7372. 'sid',
  7373. null
  7374. ],
  7375. [
  7376. [
  7377. 12,
  7378. 23
  7379. ],
  7380. 'BaseFontBlend',
  7381. 'delta',
  7382. null
  7383. ],
  7384. [
  7385. [
  7386. 12,
  7387. 31
  7388. ],
  7389. 'CIDFontVersion',
  7390. 'num',
  7391. 0
  7392. ],
  7393. [
  7394. [
  7395. 12,
  7396. 32
  7397. ],
  7398. 'CIDFontRevision',
  7399. 'num',
  7400. 0
  7401. ],
  7402. [
  7403. [
  7404. 12,
  7405. 33
  7406. ],
  7407. 'CIDFontType',
  7408. 'num',
  7409. 0
  7410. ],
  7411. [
  7412. [
  7413. 12,
  7414. 34
  7415. ],
  7416. 'CIDCount',
  7417. 'num',
  7418. 8720
  7419. ],
  7420. [
  7421. [
  7422. 12,
  7423. 35
  7424. ],
  7425. 'UIDBase',
  7426. 'num',
  7427. null
  7428. ],
  7429. [
  7430. [
  7431. 12,
  7432. 37
  7433. ],
  7434. 'FDSelect',
  7435. 'offset',
  7436. null
  7437. ],
  7438. [
  7439. [
  7440. 12,
  7441. 36
  7442. ],
  7443. 'FDArray',
  7444. 'offset',
  7445. null
  7446. ],
  7447. [
  7448. [
  7449. 12,
  7450. 38
  7451. ],
  7452. 'FontName',
  7453. 'sid',
  7454. null
  7455. ]
  7456. ];
  7457. var tables = null;
  7458. function CFFTopDict(strings) {
  7459. if (tables === null) {
  7460. tables = CFFDict.createTables(layout);
  7461. }
  7462. CFFDict.call(this, tables, strings);
  7463. this.privateDict = null;
  7464. }
  7465. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7466. return CFFTopDict;
  7467. }();
  7468. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7469. var layout = [
  7470. [
  7471. 6,
  7472. 'BlueValues',
  7473. 'delta',
  7474. null
  7475. ],
  7476. [
  7477. 7,
  7478. 'OtherBlues',
  7479. 'delta',
  7480. null
  7481. ],
  7482. [
  7483. 8,
  7484. 'FamilyBlues',
  7485. 'delta',
  7486. null
  7487. ],
  7488. [
  7489. 9,
  7490. 'FamilyOtherBlues',
  7491. 'delta',
  7492. null
  7493. ],
  7494. [
  7495. [
  7496. 12,
  7497. 9
  7498. ],
  7499. 'BlueScale',
  7500. 'num',
  7501. 0.039625
  7502. ],
  7503. [
  7504. [
  7505. 12,
  7506. 10
  7507. ],
  7508. 'BlueShift',
  7509. 'num',
  7510. 7
  7511. ],
  7512. [
  7513. [
  7514. 12,
  7515. 11
  7516. ],
  7517. 'BlueFuzz',
  7518. 'num',
  7519. 1
  7520. ],
  7521. [
  7522. 10,
  7523. 'StdHW',
  7524. 'num',
  7525. null
  7526. ],
  7527. [
  7528. 11,
  7529. 'StdVW',
  7530. 'num',
  7531. null
  7532. ],
  7533. [
  7534. [
  7535. 12,
  7536. 12
  7537. ],
  7538. 'StemSnapH',
  7539. 'delta',
  7540. null
  7541. ],
  7542. [
  7543. [
  7544. 12,
  7545. 13
  7546. ],
  7547. 'StemSnapV',
  7548. 'delta',
  7549. null
  7550. ],
  7551. [
  7552. [
  7553. 12,
  7554. 14
  7555. ],
  7556. 'ForceBold',
  7557. 'num',
  7558. 0
  7559. ],
  7560. [
  7561. [
  7562. 12,
  7563. 17
  7564. ],
  7565. 'LanguageGroup',
  7566. 'num',
  7567. 0
  7568. ],
  7569. [
  7570. [
  7571. 12,
  7572. 18
  7573. ],
  7574. 'ExpansionFactor',
  7575. 'num',
  7576. 0.06
  7577. ],
  7578. [
  7579. [
  7580. 12,
  7581. 19
  7582. ],
  7583. 'initialRandomSeed',
  7584. 'num',
  7585. 0
  7586. ],
  7587. [
  7588. 20,
  7589. 'defaultWidthX',
  7590. 'num',
  7591. 0
  7592. ],
  7593. [
  7594. 21,
  7595. 'nominalWidthX',
  7596. 'num',
  7597. 0
  7598. ],
  7599. [
  7600. 19,
  7601. 'Subrs',
  7602. 'offset',
  7603. null
  7604. ]
  7605. ];
  7606. var tables = null;
  7607. function CFFPrivateDict(strings) {
  7608. if (tables === null) {
  7609. tables = CFFDict.createTables(layout);
  7610. }
  7611. CFFDict.call(this, tables, strings);
  7612. this.subrsIndex = null;
  7613. }
  7614. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7615. return CFFPrivateDict;
  7616. }();
  7617. var CFFCharsetPredefinedTypes = {
  7618. ISO_ADOBE: 0,
  7619. EXPERT: 1,
  7620. EXPERT_SUBSET: 2
  7621. };
  7622. var CFFCharset = function CFFCharsetClosure() {
  7623. function CFFCharset(predefined, format, charset, raw) {
  7624. this.predefined = predefined;
  7625. this.format = format;
  7626. this.charset = charset;
  7627. this.raw = raw;
  7628. }
  7629. return CFFCharset;
  7630. }();
  7631. var CFFEncoding = function CFFEncodingClosure() {
  7632. function CFFEncoding(predefined, format, encoding, raw) {
  7633. this.predefined = predefined;
  7634. this.format = format;
  7635. this.encoding = encoding;
  7636. this.raw = raw;
  7637. }
  7638. return CFFEncoding;
  7639. }();
  7640. var CFFFDSelect = function CFFFDSelectClosure() {
  7641. function CFFFDSelect(fdSelect, raw) {
  7642. this.fdSelect = fdSelect;
  7643. this.raw = raw;
  7644. }
  7645. CFFFDSelect.prototype = {
  7646. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7647. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7648. return -1;
  7649. }
  7650. return this.fdSelect[glyphIndex];
  7651. }
  7652. };
  7653. return CFFFDSelect;
  7654. }();
  7655. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7656. function CFFOffsetTracker() {
  7657. this.offsets = Object.create(null);
  7658. }
  7659. CFFOffsetTracker.prototype = {
  7660. isTracking: function CFFOffsetTracker_isTracking(key) {
  7661. return key in this.offsets;
  7662. },
  7663. track: function CFFOffsetTracker_track(key, location) {
  7664. if (key in this.offsets) {
  7665. error('Already tracking location of ' + key);
  7666. }
  7667. this.offsets[key] = location;
  7668. },
  7669. offset: function CFFOffsetTracker_offset(value) {
  7670. for (var key in this.offsets) {
  7671. this.offsets[key] += value;
  7672. }
  7673. },
  7674. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7675. if (!(key in this.offsets)) {
  7676. error('Not tracking location of ' + key);
  7677. }
  7678. var data = output.data;
  7679. var dataOffset = this.offsets[key];
  7680. var size = 5;
  7681. for (var i = 0, ii = values.length; i < ii; ++i) {
  7682. var offset0 = i * size + dataOffset;
  7683. var offset1 = offset0 + 1;
  7684. var offset2 = offset0 + 2;
  7685. var offset3 = offset0 + 3;
  7686. var offset4 = offset0 + 4;
  7687. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7688. error('writing to an offset that is not empty');
  7689. }
  7690. var value = values[i];
  7691. data[offset0] = 0x1d;
  7692. data[offset1] = value >> 24 & 0xFF;
  7693. data[offset2] = value >> 16 & 0xFF;
  7694. data[offset3] = value >> 8 & 0xFF;
  7695. data[offset4] = value & 0xFF;
  7696. }
  7697. }
  7698. };
  7699. return CFFOffsetTracker;
  7700. }();
  7701. var CFFCompiler = function CFFCompilerClosure() {
  7702. function CFFCompiler(cff) {
  7703. this.cff = cff;
  7704. }
  7705. CFFCompiler.prototype = {
  7706. compile: function CFFCompiler_compile() {
  7707. var cff = this.cff;
  7708. var output = {
  7709. data: [],
  7710. length: 0,
  7711. add: function CFFCompiler_add(data) {
  7712. this.data = this.data.concat(data);
  7713. this.length = this.data.length;
  7714. }
  7715. };
  7716. var header = this.compileHeader(cff.header);
  7717. output.add(header);
  7718. var nameIndex = this.compileNameIndex(cff.names);
  7719. output.add(nameIndex);
  7720. if (cff.isCIDFont) {
  7721. if (cff.topDict.hasName('FontMatrix')) {
  7722. var base = cff.topDict.getByName('FontMatrix');
  7723. cff.topDict.removeByName('FontMatrix');
  7724. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7725. var subDict = cff.fdArray[i];
  7726. var matrix = base.slice(0);
  7727. if (subDict.hasName('FontMatrix')) {
  7728. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7729. }
  7730. subDict.setByName('FontMatrix', matrix);
  7731. }
  7732. }
  7733. }
  7734. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7735. output.add(compiled.output);
  7736. var topDictTracker = compiled.trackers[0];
  7737. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7738. output.add(stringIndex);
  7739. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7740. output.add(globalSubrIndex);
  7741. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7742. if (cff.encoding.predefined) {
  7743. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7744. } else {
  7745. var encoding = this.compileEncoding(cff.encoding);
  7746. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7747. output.add(encoding);
  7748. }
  7749. }
  7750. if (cff.charset && cff.topDict.hasName('charset')) {
  7751. if (cff.charset.predefined) {
  7752. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7753. } else {
  7754. var charset = this.compileCharset(cff.charset);
  7755. topDictTracker.setEntryLocation('charset', [output.length], output);
  7756. output.add(charset);
  7757. }
  7758. }
  7759. var charStrings = this.compileCharStrings(cff.charStrings);
  7760. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7761. output.add(charStrings);
  7762. if (cff.isCIDFont) {
  7763. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7764. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7765. output.add(fdSelect);
  7766. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7767. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7768. output.add(compiled.output);
  7769. var fontDictTrackers = compiled.trackers;
  7770. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7771. }
  7772. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7773. output.add([0]);
  7774. return output.data;
  7775. },
  7776. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7777. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7778. return this.encodeInteger(value);
  7779. } else {
  7780. return this.encodeFloat(value);
  7781. }
  7782. },
  7783. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7784. var value = num.toString();
  7785. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7786. if (m) {
  7787. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7788. value = (Math.round(num * epsilon) / epsilon).toString();
  7789. }
  7790. var nibbles = '';
  7791. var i, ii;
  7792. for (i = 0, ii = value.length; i < ii; ++i) {
  7793. var a = value[i];
  7794. if (a === 'e') {
  7795. nibbles += value[++i] === '-' ? 'c' : 'b';
  7796. } else if (a === '.') {
  7797. nibbles += 'a';
  7798. } else if (a === '-') {
  7799. nibbles += 'e';
  7800. } else {
  7801. nibbles += a;
  7802. }
  7803. }
  7804. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7805. var out = [30];
  7806. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7807. out.push(parseInt(nibbles.substr(i, 2), 16));
  7808. }
  7809. return out;
  7810. },
  7811. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7812. var code;
  7813. if (value >= -107 && value <= 107) {
  7814. code = [value + 139];
  7815. } else if (value >= 108 && value <= 1131) {
  7816. value = value - 108;
  7817. code = [
  7818. (value >> 8) + 247,
  7819. value & 0xFF
  7820. ];
  7821. } else if (value >= -1131 && value <= -108) {
  7822. value = -value - 108;
  7823. code = [
  7824. (value >> 8) + 251,
  7825. value & 0xFF
  7826. ];
  7827. } else if (value >= -32768 && value <= 32767) {
  7828. code = [
  7829. 0x1c,
  7830. value >> 8 & 0xFF,
  7831. value & 0xFF
  7832. ];
  7833. } else {
  7834. code = [
  7835. 0x1d,
  7836. value >> 24 & 0xFF,
  7837. value >> 16 & 0xFF,
  7838. value >> 8 & 0xFF,
  7839. value & 0xFF
  7840. ];
  7841. }
  7842. return code;
  7843. },
  7844. compileHeader: function CFFCompiler_compileHeader(header) {
  7845. return [
  7846. header.major,
  7847. header.minor,
  7848. header.hdrSize,
  7849. header.offSize
  7850. ];
  7851. },
  7852. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7853. var nameIndex = new CFFIndex();
  7854. for (var i = 0, ii = names.length; i < ii; ++i) {
  7855. nameIndex.add(stringToBytes(names[i]));
  7856. }
  7857. return this.compileIndex(nameIndex);
  7858. },
  7859. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7860. var fontDictTrackers = [];
  7861. var fdArrayIndex = new CFFIndex();
  7862. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7863. var fontDict = dicts[i];
  7864. if (removeCidKeys) {
  7865. fontDict.removeByName('CIDFontVersion');
  7866. fontDict.removeByName('CIDFontRevision');
  7867. fontDict.removeByName('CIDFontType');
  7868. fontDict.removeByName('CIDCount');
  7869. fontDict.removeByName('UIDBase');
  7870. }
  7871. var fontDictTracker = new CFFOffsetTracker();
  7872. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7873. fontDictTrackers.push(fontDictTracker);
  7874. fdArrayIndex.add(fontDictData);
  7875. fontDictTracker.offset(length);
  7876. }
  7877. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7878. return {
  7879. trackers: fontDictTrackers,
  7880. output: fdArrayIndex
  7881. };
  7882. },
  7883. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7884. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7885. var fontDict = dicts[i];
  7886. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7887. var privateDict = fontDict.privateDict;
  7888. var privateDictTracker = new CFFOffsetTracker();
  7889. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7890. var outputLength = output.length;
  7891. privateDictTracker.offset(outputLength);
  7892. if (!privateDictData.length) {
  7893. outputLength = 0;
  7894. }
  7895. trackers[i].setEntryLocation('Private', [
  7896. privateDictData.length,
  7897. outputLength
  7898. ], output);
  7899. output.add(privateDictData);
  7900. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7901. var subrs = this.compileIndex(privateDict.subrsIndex);
  7902. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7903. output.add(subrs);
  7904. }
  7905. }
  7906. },
  7907. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7908. var out = [];
  7909. var order = dict.order;
  7910. for (var i = 0; i < order.length; ++i) {
  7911. var key = order[i];
  7912. if (!(key in dict.values)) {
  7913. continue;
  7914. }
  7915. var values = dict.values[key];
  7916. var types = dict.types[key];
  7917. if (!isArray(types)) {
  7918. types = [types];
  7919. }
  7920. if (!isArray(values)) {
  7921. values = [values];
  7922. }
  7923. if (values.length === 0) {
  7924. continue;
  7925. }
  7926. for (var j = 0, jj = types.length; j < jj; ++j) {
  7927. var type = types[j];
  7928. var value = values[j];
  7929. switch (type) {
  7930. case 'num':
  7931. case 'sid':
  7932. out = out.concat(this.encodeNumber(value));
  7933. break;
  7934. case 'offset':
  7935. var name = dict.keyToNameMap[key];
  7936. if (!offsetTracker.isTracking(name)) {
  7937. offsetTracker.track(name, out.length);
  7938. }
  7939. out = out.concat([
  7940. 0x1d,
  7941. 0,
  7942. 0,
  7943. 0,
  7944. 0
  7945. ]);
  7946. break;
  7947. case 'array':
  7948. case 'delta':
  7949. out = out.concat(this.encodeNumber(value));
  7950. for (var k = 1, kk = values.length; k < kk; ++k) {
  7951. out = out.concat(this.encodeNumber(values[k]));
  7952. }
  7953. break;
  7954. default:
  7955. error('Unknown data type of ' + type);
  7956. break;
  7957. }
  7958. }
  7959. out = out.concat(dict.opcodes[key]);
  7960. }
  7961. return out;
  7962. },
  7963. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7964. var stringIndex = new CFFIndex();
  7965. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7966. stringIndex.add(stringToBytes(strings[i]));
  7967. }
  7968. return this.compileIndex(stringIndex);
  7969. },
  7970. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7971. var globalSubrIndex = this.cff.globalSubrIndex;
  7972. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7973. },
  7974. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7975. return this.compileIndex(charStrings);
  7976. },
  7977. compileCharset: function CFFCompiler_compileCharset(charset) {
  7978. return this.compileTypedArray(charset.raw);
  7979. },
  7980. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7981. return this.compileTypedArray(encoding.raw);
  7982. },
  7983. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7984. return this.compileTypedArray(fdSelect);
  7985. },
  7986. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7987. var out = [];
  7988. for (var i = 0, ii = data.length; i < ii; ++i) {
  7989. out[i] = data[i];
  7990. }
  7991. return out;
  7992. },
  7993. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7994. trackers = trackers || [];
  7995. var objects = index.objects;
  7996. var count = objects.length;
  7997. if (count === 0) {
  7998. return [
  7999. 0,
  8000. 0,
  8001. 0
  8002. ];
  8003. }
  8004. var data = [
  8005. count >> 8 & 0xFF,
  8006. count & 0xff
  8007. ];
  8008. var lastOffset = 1, i;
  8009. for (i = 0; i < count; ++i) {
  8010. lastOffset += objects[i].length;
  8011. }
  8012. var offsetSize;
  8013. if (lastOffset < 0x100) {
  8014. offsetSize = 1;
  8015. } else if (lastOffset < 0x10000) {
  8016. offsetSize = 2;
  8017. } else if (lastOffset < 0x1000000) {
  8018. offsetSize = 3;
  8019. } else {
  8020. offsetSize = 4;
  8021. }
  8022. data.push(offsetSize);
  8023. var relativeOffset = 1;
  8024. for (i = 0; i < count + 1; i++) {
  8025. if (offsetSize === 1) {
  8026. data.push(relativeOffset & 0xFF);
  8027. } else if (offsetSize === 2) {
  8028. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8029. } else if (offsetSize === 3) {
  8030. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8031. } else {
  8032. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. }
  8034. if (objects[i]) {
  8035. relativeOffset += objects[i].length;
  8036. }
  8037. }
  8038. for (i = 0; i < count; i++) {
  8039. if (trackers[i]) {
  8040. trackers[i].offset(data.length);
  8041. }
  8042. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8043. data.push(objects[i][j]);
  8044. }
  8045. }
  8046. return data;
  8047. }
  8048. };
  8049. return CFFCompiler;
  8050. }();
  8051. exports.CFFStandardStrings = CFFStandardStrings;
  8052. exports.CFFParser = CFFParser;
  8053. exports.CFF = CFF;
  8054. exports.CFFHeader = CFFHeader;
  8055. exports.CFFStrings = CFFStrings;
  8056. exports.CFFIndex = CFFIndex;
  8057. exports.CFFCharset = CFFCharset;
  8058. exports.CFFTopDict = CFFTopDict;
  8059. exports.CFFPrivateDict = CFFPrivateDict;
  8060. exports.CFFCompiler = CFFCompiler;
  8061. }));
  8062. (function (root, factory) {
  8063. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8064. }(this, function (exports, sharedUtil) {
  8065. var MissingDataException = sharedUtil.MissingDataException;
  8066. var arrayByteLength = sharedUtil.arrayByteLength;
  8067. var arraysToBytes = sharedUtil.arraysToBytes;
  8068. var assert = sharedUtil.assert;
  8069. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8070. var isInt = sharedUtil.isInt;
  8071. var isEmptyObj = sharedUtil.isEmptyObj;
  8072. var ChunkedStream = function ChunkedStreamClosure() {
  8073. function ChunkedStream(length, chunkSize, manager) {
  8074. this.bytes = new Uint8Array(length);
  8075. this.start = 0;
  8076. this.pos = 0;
  8077. this.end = length;
  8078. this.chunkSize = chunkSize;
  8079. this.loadedChunks = [];
  8080. this.numChunksLoaded = 0;
  8081. this.numChunks = Math.ceil(length / chunkSize);
  8082. this.manager = manager;
  8083. this.progressiveDataLength = 0;
  8084. this.lastSuccessfulEnsureByteChunk = -1;
  8085. }
  8086. ChunkedStream.prototype = {
  8087. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8088. var chunks = [];
  8089. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8090. if (!this.loadedChunks[chunk]) {
  8091. chunks.push(chunk);
  8092. }
  8093. }
  8094. return chunks;
  8095. },
  8096. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8097. return [this];
  8098. },
  8099. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8100. return this.numChunksLoaded === this.numChunks;
  8101. },
  8102. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8103. var end = begin + chunk.byteLength;
  8104. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8105. var length = this.bytes.length;
  8106. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8107. this.bytes.set(new Uint8Array(chunk), begin);
  8108. var chunkSize = this.chunkSize;
  8109. var beginChunk = Math.floor(begin / chunkSize);
  8110. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8111. var curChunk;
  8112. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8113. if (!this.loadedChunks[curChunk]) {
  8114. this.loadedChunks[curChunk] = true;
  8115. ++this.numChunksLoaded;
  8116. }
  8117. }
  8118. },
  8119. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8120. var position = this.progressiveDataLength;
  8121. var beginChunk = Math.floor(position / this.chunkSize);
  8122. this.bytes.set(new Uint8Array(data), position);
  8123. position += data.byteLength;
  8124. this.progressiveDataLength = position;
  8125. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8126. var curChunk;
  8127. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8128. if (!this.loadedChunks[curChunk]) {
  8129. this.loadedChunks[curChunk] = true;
  8130. ++this.numChunksLoaded;
  8131. }
  8132. }
  8133. },
  8134. ensureByte: function ChunkedStream_ensureByte(pos) {
  8135. var chunk = Math.floor(pos / this.chunkSize);
  8136. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8137. return;
  8138. }
  8139. if (!this.loadedChunks[chunk]) {
  8140. throw new MissingDataException(pos, pos + 1);
  8141. }
  8142. this.lastSuccessfulEnsureByteChunk = chunk;
  8143. },
  8144. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8145. if (begin >= end) {
  8146. return;
  8147. }
  8148. if (end <= this.progressiveDataLength) {
  8149. return;
  8150. }
  8151. var chunkSize = this.chunkSize;
  8152. var beginChunk = Math.floor(begin / chunkSize);
  8153. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8154. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8155. if (!this.loadedChunks[chunk]) {
  8156. throw new MissingDataException(begin, end);
  8157. }
  8158. }
  8159. },
  8160. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8161. var chunk, numChunks = this.numChunks;
  8162. for (var i = 0; i < numChunks; ++i) {
  8163. chunk = (beginChunk + i) % numChunks;
  8164. if (!this.loadedChunks[chunk]) {
  8165. return chunk;
  8166. }
  8167. }
  8168. return null;
  8169. },
  8170. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8171. return !!this.loadedChunks[chunk];
  8172. },
  8173. get length() {
  8174. return this.end - this.start;
  8175. },
  8176. get isEmpty() {
  8177. return this.length === 0;
  8178. },
  8179. getByte: function ChunkedStream_getByte() {
  8180. var pos = this.pos;
  8181. if (pos >= this.end) {
  8182. return -1;
  8183. }
  8184. this.ensureByte(pos);
  8185. return this.bytes[this.pos++];
  8186. },
  8187. getUint16: function ChunkedStream_getUint16() {
  8188. var b0 = this.getByte();
  8189. var b1 = this.getByte();
  8190. if (b0 === -1 || b1 === -1) {
  8191. return -1;
  8192. }
  8193. return (b0 << 8) + b1;
  8194. },
  8195. getInt32: function ChunkedStream_getInt32() {
  8196. var b0 = this.getByte();
  8197. var b1 = this.getByte();
  8198. var b2 = this.getByte();
  8199. var b3 = this.getByte();
  8200. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8201. },
  8202. getBytes: function ChunkedStream_getBytes(length) {
  8203. var bytes = this.bytes;
  8204. var pos = this.pos;
  8205. var strEnd = this.end;
  8206. if (!length) {
  8207. this.ensureRange(pos, strEnd);
  8208. return bytes.subarray(pos, strEnd);
  8209. }
  8210. var end = pos + length;
  8211. if (end > strEnd) {
  8212. end = strEnd;
  8213. }
  8214. this.ensureRange(pos, end);
  8215. this.pos = end;
  8216. return bytes.subarray(pos, end);
  8217. },
  8218. peekByte: function ChunkedStream_peekByte() {
  8219. var peekedByte = this.getByte();
  8220. this.pos--;
  8221. return peekedByte;
  8222. },
  8223. peekBytes: function ChunkedStream_peekBytes(length) {
  8224. var bytes = this.getBytes(length);
  8225. this.pos -= bytes.length;
  8226. return bytes;
  8227. },
  8228. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8229. this.ensureRange(begin, end);
  8230. return this.bytes.subarray(begin, end);
  8231. },
  8232. skip: function ChunkedStream_skip(n) {
  8233. if (!n) {
  8234. n = 1;
  8235. }
  8236. this.pos += n;
  8237. },
  8238. reset: function ChunkedStream_reset() {
  8239. this.pos = this.start;
  8240. },
  8241. moveStart: function ChunkedStream_moveStart() {
  8242. this.start = this.pos;
  8243. },
  8244. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8245. this.ensureRange(start, start + length);
  8246. function ChunkedStreamSubstream() {
  8247. }
  8248. ChunkedStreamSubstream.prototype = Object.create(this);
  8249. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8250. var chunkSize = this.chunkSize;
  8251. var beginChunk = Math.floor(this.start / chunkSize);
  8252. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8253. var missingChunks = [];
  8254. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8255. if (!this.loadedChunks[chunk]) {
  8256. missingChunks.push(chunk);
  8257. }
  8258. }
  8259. return missingChunks;
  8260. };
  8261. var subStream = new ChunkedStreamSubstream();
  8262. subStream.pos = subStream.start = start;
  8263. subStream.end = start + length || this.end;
  8264. subStream.dict = dict;
  8265. return subStream;
  8266. },
  8267. isStream: true
  8268. };
  8269. return ChunkedStream;
  8270. }();
  8271. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8272. function ChunkedStreamManager(pdfNetworkStream, args) {
  8273. var chunkSize = args.rangeChunkSize;
  8274. var length = args.length;
  8275. this.stream = new ChunkedStream(length, chunkSize, this);
  8276. this.length = length;
  8277. this.chunkSize = chunkSize;
  8278. this.pdfNetworkStream = pdfNetworkStream;
  8279. this.url = args.url;
  8280. this.disableAutoFetch = args.disableAutoFetch;
  8281. this.msgHandler = args.msgHandler;
  8282. this.currRequestId = 0;
  8283. this.chunksNeededByRequest = Object.create(null);
  8284. this.requestsByChunk = Object.create(null);
  8285. this.promisesByRequest = Object.create(null);
  8286. this.progressiveDataLength = 0;
  8287. this.aborted = false;
  8288. this._loadedStreamCapability = createPromiseCapability();
  8289. }
  8290. ChunkedStreamManager.prototype = {
  8291. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8292. return this._loadedStreamCapability.promise;
  8293. },
  8294. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8295. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8296. if (!rangeReader.isStreamingSupported) {
  8297. rangeReader.onProgress = this.onProgress.bind(this);
  8298. }
  8299. var chunks = [], loaded = 0;
  8300. var manager = this;
  8301. var promise = new Promise(function (resolve, reject) {
  8302. var readChunk = function (chunk) {
  8303. try {
  8304. if (!chunk.done) {
  8305. var data = chunk.value;
  8306. chunks.push(data);
  8307. loaded += arrayByteLength(data);
  8308. if (rangeReader.isStreamingSupported) {
  8309. manager.onProgress({ loaded: loaded });
  8310. }
  8311. rangeReader.read().then(readChunk, reject);
  8312. return;
  8313. }
  8314. var chunkData = arraysToBytes(chunks);
  8315. chunks = null;
  8316. resolve(chunkData);
  8317. } catch (e) {
  8318. reject(e);
  8319. }
  8320. };
  8321. rangeReader.read().then(readChunk, reject);
  8322. });
  8323. promise.then(function (data) {
  8324. if (this.aborted) {
  8325. return;
  8326. }
  8327. this.onReceiveData({
  8328. chunk: data,
  8329. begin: begin
  8330. });
  8331. }.bind(this));
  8332. },
  8333. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8334. var missingChunks = this.stream.getMissingChunks();
  8335. this._requestChunks(missingChunks);
  8336. return this._loadedStreamCapability.promise;
  8337. },
  8338. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8339. var requestId = this.currRequestId++;
  8340. var i, ii;
  8341. var chunksNeeded = Object.create(null);
  8342. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8343. for (i = 0, ii = chunks.length; i < ii; i++) {
  8344. if (!this.stream.hasChunk(chunks[i])) {
  8345. chunksNeeded[chunks[i]] = true;
  8346. }
  8347. }
  8348. if (isEmptyObj(chunksNeeded)) {
  8349. return Promise.resolve();
  8350. }
  8351. var capability = createPromiseCapability();
  8352. this.promisesByRequest[requestId] = capability;
  8353. var chunksToRequest = [];
  8354. for (var chunk in chunksNeeded) {
  8355. chunk = chunk | 0;
  8356. if (!(chunk in this.requestsByChunk)) {
  8357. this.requestsByChunk[chunk] = [];
  8358. chunksToRequest.push(chunk);
  8359. }
  8360. this.requestsByChunk[chunk].push(requestId);
  8361. }
  8362. if (!chunksToRequest.length) {
  8363. return capability.promise;
  8364. }
  8365. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8366. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8367. var groupedChunk = groupedChunksToRequest[i];
  8368. var begin = groupedChunk.beginChunk * this.chunkSize;
  8369. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8370. this.sendRequest(begin, end);
  8371. }
  8372. return capability.promise;
  8373. },
  8374. getStream: function ChunkedStreamManager_getStream() {
  8375. return this.stream;
  8376. },
  8377. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8378. end = Math.min(end, this.length);
  8379. var beginChunk = this.getBeginChunk(begin);
  8380. var endChunk = this.getEndChunk(end);
  8381. var chunks = [];
  8382. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8383. chunks.push(chunk);
  8384. }
  8385. return this._requestChunks(chunks);
  8386. },
  8387. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8388. ranges = ranges || [];
  8389. var chunksToRequest = [];
  8390. for (var i = 0; i < ranges.length; i++) {
  8391. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8392. var endChunk = this.getEndChunk(ranges[i].end);
  8393. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8394. if (chunksToRequest.indexOf(chunk) < 0) {
  8395. chunksToRequest.push(chunk);
  8396. }
  8397. }
  8398. }
  8399. chunksToRequest.sort(function (a, b) {
  8400. return a - b;
  8401. });
  8402. return this._requestChunks(chunksToRequest);
  8403. },
  8404. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8405. var groupedChunks = [];
  8406. var beginChunk = -1;
  8407. var prevChunk = -1;
  8408. for (var i = 0; i < chunks.length; ++i) {
  8409. var chunk = chunks[i];
  8410. if (beginChunk < 0) {
  8411. beginChunk = chunk;
  8412. }
  8413. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8414. groupedChunks.push({
  8415. beginChunk: beginChunk,
  8416. endChunk: prevChunk + 1
  8417. });
  8418. beginChunk = chunk;
  8419. }
  8420. if (i + 1 === chunks.length) {
  8421. groupedChunks.push({
  8422. beginChunk: beginChunk,
  8423. endChunk: chunk + 1
  8424. });
  8425. }
  8426. prevChunk = chunk;
  8427. }
  8428. return groupedChunks;
  8429. },
  8430. onProgress: function ChunkedStreamManager_onProgress(args) {
  8431. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8432. this.msgHandler.send('DocProgress', {
  8433. loaded: bytesLoaded,
  8434. total: this.length
  8435. });
  8436. },
  8437. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8438. var chunk = args.chunk;
  8439. var isProgressive = args.begin === undefined;
  8440. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8441. var end = begin + chunk.byteLength;
  8442. var beginChunk = Math.floor(begin / this.chunkSize);
  8443. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8444. if (isProgressive) {
  8445. this.stream.onReceiveProgressiveData(chunk);
  8446. this.progressiveDataLength = end;
  8447. } else {
  8448. this.stream.onReceiveData(begin, chunk);
  8449. }
  8450. if (this.stream.allChunksLoaded()) {
  8451. this._loadedStreamCapability.resolve(this.stream);
  8452. }
  8453. var loadedRequests = [];
  8454. var i, requestId;
  8455. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8456. var requestIds = this.requestsByChunk[chunk] || [];
  8457. delete this.requestsByChunk[chunk];
  8458. for (i = 0; i < requestIds.length; ++i) {
  8459. requestId = requestIds[i];
  8460. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8461. if (chunk in chunksNeeded) {
  8462. delete chunksNeeded[chunk];
  8463. }
  8464. if (!isEmptyObj(chunksNeeded)) {
  8465. continue;
  8466. }
  8467. loadedRequests.push(requestId);
  8468. }
  8469. }
  8470. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8471. var nextEmptyChunk;
  8472. if (this.stream.numChunksLoaded === 1) {
  8473. var lastChunk = this.stream.numChunks - 1;
  8474. if (!this.stream.hasChunk(lastChunk)) {
  8475. nextEmptyChunk = lastChunk;
  8476. }
  8477. } else {
  8478. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8479. }
  8480. if (isInt(nextEmptyChunk)) {
  8481. this._requestChunks([nextEmptyChunk]);
  8482. }
  8483. }
  8484. for (i = 0; i < loadedRequests.length; ++i) {
  8485. requestId = loadedRequests[i];
  8486. var capability = this.promisesByRequest[requestId];
  8487. delete this.promisesByRequest[requestId];
  8488. capability.resolve();
  8489. }
  8490. this.msgHandler.send('DocProgress', {
  8491. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8492. total: this.length
  8493. });
  8494. },
  8495. onError: function ChunkedStreamManager_onError(err) {
  8496. this._loadedStreamCapability.reject(err);
  8497. },
  8498. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8499. var chunk = Math.floor(begin / this.chunkSize);
  8500. return chunk;
  8501. },
  8502. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8503. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8504. return chunk;
  8505. },
  8506. abort: function ChunkedStreamManager_abort() {
  8507. this.aborted = true;
  8508. if (this.pdfNetworkStream) {
  8509. this.pdfNetworkStream.cancelAllRequests('abort');
  8510. }
  8511. for (var requestId in this.promisesByRequest) {
  8512. var capability = this.promisesByRequest[requestId];
  8513. capability.reject(new Error('Request was aborted'));
  8514. }
  8515. }
  8516. };
  8517. return ChunkedStreamManager;
  8518. }();
  8519. exports.ChunkedStream = ChunkedStream;
  8520. exports.ChunkedStreamManager = ChunkedStreamManager;
  8521. }));
  8522. (function (root, factory) {
  8523. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8524. }(this, function (exports, sharedUtil) {
  8525. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8526. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8527. t['A'] = 0x0041;
  8528. t['AE'] = 0x00C6;
  8529. t['AEacute'] = 0x01FC;
  8530. t['AEmacron'] = 0x01E2;
  8531. t['AEsmall'] = 0xF7E6;
  8532. t['Aacute'] = 0x00C1;
  8533. t['Aacutesmall'] = 0xF7E1;
  8534. t['Abreve'] = 0x0102;
  8535. t['Abreveacute'] = 0x1EAE;
  8536. t['Abrevecyrillic'] = 0x04D0;
  8537. t['Abrevedotbelow'] = 0x1EB6;
  8538. t['Abrevegrave'] = 0x1EB0;
  8539. t['Abrevehookabove'] = 0x1EB2;
  8540. t['Abrevetilde'] = 0x1EB4;
  8541. t['Acaron'] = 0x01CD;
  8542. t['Acircle'] = 0x24B6;
  8543. t['Acircumflex'] = 0x00C2;
  8544. t['Acircumflexacute'] = 0x1EA4;
  8545. t['Acircumflexdotbelow'] = 0x1EAC;
  8546. t['Acircumflexgrave'] = 0x1EA6;
  8547. t['Acircumflexhookabove'] = 0x1EA8;
  8548. t['Acircumflexsmall'] = 0xF7E2;
  8549. t['Acircumflextilde'] = 0x1EAA;
  8550. t['Acute'] = 0xF6C9;
  8551. t['Acutesmall'] = 0xF7B4;
  8552. t['Acyrillic'] = 0x0410;
  8553. t['Adblgrave'] = 0x0200;
  8554. t['Adieresis'] = 0x00C4;
  8555. t['Adieresiscyrillic'] = 0x04D2;
  8556. t['Adieresismacron'] = 0x01DE;
  8557. t['Adieresissmall'] = 0xF7E4;
  8558. t['Adotbelow'] = 0x1EA0;
  8559. t['Adotmacron'] = 0x01E0;
  8560. t['Agrave'] = 0x00C0;
  8561. t['Agravesmall'] = 0xF7E0;
  8562. t['Ahookabove'] = 0x1EA2;
  8563. t['Aiecyrillic'] = 0x04D4;
  8564. t['Ainvertedbreve'] = 0x0202;
  8565. t['Alpha'] = 0x0391;
  8566. t['Alphatonos'] = 0x0386;
  8567. t['Amacron'] = 0x0100;
  8568. t['Amonospace'] = 0xFF21;
  8569. t['Aogonek'] = 0x0104;
  8570. t['Aring'] = 0x00C5;
  8571. t['Aringacute'] = 0x01FA;
  8572. t['Aringbelow'] = 0x1E00;
  8573. t['Aringsmall'] = 0xF7E5;
  8574. t['Asmall'] = 0xF761;
  8575. t['Atilde'] = 0x00C3;
  8576. t['Atildesmall'] = 0xF7E3;
  8577. t['Aybarmenian'] = 0x0531;
  8578. t['B'] = 0x0042;
  8579. t['Bcircle'] = 0x24B7;
  8580. t['Bdotaccent'] = 0x1E02;
  8581. t['Bdotbelow'] = 0x1E04;
  8582. t['Becyrillic'] = 0x0411;
  8583. t['Benarmenian'] = 0x0532;
  8584. t['Beta'] = 0x0392;
  8585. t['Bhook'] = 0x0181;
  8586. t['Blinebelow'] = 0x1E06;
  8587. t['Bmonospace'] = 0xFF22;
  8588. t['Brevesmall'] = 0xF6F4;
  8589. t['Bsmall'] = 0xF762;
  8590. t['Btopbar'] = 0x0182;
  8591. t['C'] = 0x0043;
  8592. t['Caarmenian'] = 0x053E;
  8593. t['Cacute'] = 0x0106;
  8594. t['Caron'] = 0xF6CA;
  8595. t['Caronsmall'] = 0xF6F5;
  8596. t['Ccaron'] = 0x010C;
  8597. t['Ccedilla'] = 0x00C7;
  8598. t['Ccedillaacute'] = 0x1E08;
  8599. t['Ccedillasmall'] = 0xF7E7;
  8600. t['Ccircle'] = 0x24B8;
  8601. t['Ccircumflex'] = 0x0108;
  8602. t['Cdot'] = 0x010A;
  8603. t['Cdotaccent'] = 0x010A;
  8604. t['Cedillasmall'] = 0xF7B8;
  8605. t['Chaarmenian'] = 0x0549;
  8606. t['Cheabkhasiancyrillic'] = 0x04BC;
  8607. t['Checyrillic'] = 0x0427;
  8608. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8609. t['Chedescendercyrillic'] = 0x04B6;
  8610. t['Chedieresiscyrillic'] = 0x04F4;
  8611. t['Cheharmenian'] = 0x0543;
  8612. t['Chekhakassiancyrillic'] = 0x04CB;
  8613. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8614. t['Chi'] = 0x03A7;
  8615. t['Chook'] = 0x0187;
  8616. t['Circumflexsmall'] = 0xF6F6;
  8617. t['Cmonospace'] = 0xFF23;
  8618. t['Coarmenian'] = 0x0551;
  8619. t['Csmall'] = 0xF763;
  8620. t['D'] = 0x0044;
  8621. t['DZ'] = 0x01F1;
  8622. t['DZcaron'] = 0x01C4;
  8623. t['Daarmenian'] = 0x0534;
  8624. t['Dafrican'] = 0x0189;
  8625. t['Dcaron'] = 0x010E;
  8626. t['Dcedilla'] = 0x1E10;
  8627. t['Dcircle'] = 0x24B9;
  8628. t['Dcircumflexbelow'] = 0x1E12;
  8629. t['Dcroat'] = 0x0110;
  8630. t['Ddotaccent'] = 0x1E0A;
  8631. t['Ddotbelow'] = 0x1E0C;
  8632. t['Decyrillic'] = 0x0414;
  8633. t['Deicoptic'] = 0x03EE;
  8634. t['Delta'] = 0x2206;
  8635. t['Deltagreek'] = 0x0394;
  8636. t['Dhook'] = 0x018A;
  8637. t['Dieresis'] = 0xF6CB;
  8638. t['DieresisAcute'] = 0xF6CC;
  8639. t['DieresisGrave'] = 0xF6CD;
  8640. t['Dieresissmall'] = 0xF7A8;
  8641. t['Digammagreek'] = 0x03DC;
  8642. t['Djecyrillic'] = 0x0402;
  8643. t['Dlinebelow'] = 0x1E0E;
  8644. t['Dmonospace'] = 0xFF24;
  8645. t['Dotaccentsmall'] = 0xF6F7;
  8646. t['Dslash'] = 0x0110;
  8647. t['Dsmall'] = 0xF764;
  8648. t['Dtopbar'] = 0x018B;
  8649. t['Dz'] = 0x01F2;
  8650. t['Dzcaron'] = 0x01C5;
  8651. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8652. t['Dzecyrillic'] = 0x0405;
  8653. t['Dzhecyrillic'] = 0x040F;
  8654. t['E'] = 0x0045;
  8655. t['Eacute'] = 0x00C9;
  8656. t['Eacutesmall'] = 0xF7E9;
  8657. t['Ebreve'] = 0x0114;
  8658. t['Ecaron'] = 0x011A;
  8659. t['Ecedillabreve'] = 0x1E1C;
  8660. t['Echarmenian'] = 0x0535;
  8661. t['Ecircle'] = 0x24BA;
  8662. t['Ecircumflex'] = 0x00CA;
  8663. t['Ecircumflexacute'] = 0x1EBE;
  8664. t['Ecircumflexbelow'] = 0x1E18;
  8665. t['Ecircumflexdotbelow'] = 0x1EC6;
  8666. t['Ecircumflexgrave'] = 0x1EC0;
  8667. t['Ecircumflexhookabove'] = 0x1EC2;
  8668. t['Ecircumflexsmall'] = 0xF7EA;
  8669. t['Ecircumflextilde'] = 0x1EC4;
  8670. t['Ecyrillic'] = 0x0404;
  8671. t['Edblgrave'] = 0x0204;
  8672. t['Edieresis'] = 0x00CB;
  8673. t['Edieresissmall'] = 0xF7EB;
  8674. t['Edot'] = 0x0116;
  8675. t['Edotaccent'] = 0x0116;
  8676. t['Edotbelow'] = 0x1EB8;
  8677. t['Efcyrillic'] = 0x0424;
  8678. t['Egrave'] = 0x00C8;
  8679. t['Egravesmall'] = 0xF7E8;
  8680. t['Eharmenian'] = 0x0537;
  8681. t['Ehookabove'] = 0x1EBA;
  8682. t['Eightroman'] = 0x2167;
  8683. t['Einvertedbreve'] = 0x0206;
  8684. t['Eiotifiedcyrillic'] = 0x0464;
  8685. t['Elcyrillic'] = 0x041B;
  8686. t['Elevenroman'] = 0x216A;
  8687. t['Emacron'] = 0x0112;
  8688. t['Emacronacute'] = 0x1E16;
  8689. t['Emacrongrave'] = 0x1E14;
  8690. t['Emcyrillic'] = 0x041C;
  8691. t['Emonospace'] = 0xFF25;
  8692. t['Encyrillic'] = 0x041D;
  8693. t['Endescendercyrillic'] = 0x04A2;
  8694. t['Eng'] = 0x014A;
  8695. t['Enghecyrillic'] = 0x04A4;
  8696. t['Enhookcyrillic'] = 0x04C7;
  8697. t['Eogonek'] = 0x0118;
  8698. t['Eopen'] = 0x0190;
  8699. t['Epsilon'] = 0x0395;
  8700. t['Epsilontonos'] = 0x0388;
  8701. t['Ercyrillic'] = 0x0420;
  8702. t['Ereversed'] = 0x018E;
  8703. t['Ereversedcyrillic'] = 0x042D;
  8704. t['Escyrillic'] = 0x0421;
  8705. t['Esdescendercyrillic'] = 0x04AA;
  8706. t['Esh'] = 0x01A9;
  8707. t['Esmall'] = 0xF765;
  8708. t['Eta'] = 0x0397;
  8709. t['Etarmenian'] = 0x0538;
  8710. t['Etatonos'] = 0x0389;
  8711. t['Eth'] = 0x00D0;
  8712. t['Ethsmall'] = 0xF7F0;
  8713. t['Etilde'] = 0x1EBC;
  8714. t['Etildebelow'] = 0x1E1A;
  8715. t['Euro'] = 0x20AC;
  8716. t['Ezh'] = 0x01B7;
  8717. t['Ezhcaron'] = 0x01EE;
  8718. t['Ezhreversed'] = 0x01B8;
  8719. t['F'] = 0x0046;
  8720. t['Fcircle'] = 0x24BB;
  8721. t['Fdotaccent'] = 0x1E1E;
  8722. t['Feharmenian'] = 0x0556;
  8723. t['Feicoptic'] = 0x03E4;
  8724. t['Fhook'] = 0x0191;
  8725. t['Fitacyrillic'] = 0x0472;
  8726. t['Fiveroman'] = 0x2164;
  8727. t['Fmonospace'] = 0xFF26;
  8728. t['Fourroman'] = 0x2163;
  8729. t['Fsmall'] = 0xF766;
  8730. t['G'] = 0x0047;
  8731. t['GBsquare'] = 0x3387;
  8732. t['Gacute'] = 0x01F4;
  8733. t['Gamma'] = 0x0393;
  8734. t['Gammaafrican'] = 0x0194;
  8735. t['Gangiacoptic'] = 0x03EA;
  8736. t['Gbreve'] = 0x011E;
  8737. t['Gcaron'] = 0x01E6;
  8738. t['Gcedilla'] = 0x0122;
  8739. t['Gcircle'] = 0x24BC;
  8740. t['Gcircumflex'] = 0x011C;
  8741. t['Gcommaaccent'] = 0x0122;
  8742. t['Gdot'] = 0x0120;
  8743. t['Gdotaccent'] = 0x0120;
  8744. t['Gecyrillic'] = 0x0413;
  8745. t['Ghadarmenian'] = 0x0542;
  8746. t['Ghemiddlehookcyrillic'] = 0x0494;
  8747. t['Ghestrokecyrillic'] = 0x0492;
  8748. t['Gheupturncyrillic'] = 0x0490;
  8749. t['Ghook'] = 0x0193;
  8750. t['Gimarmenian'] = 0x0533;
  8751. t['Gjecyrillic'] = 0x0403;
  8752. t['Gmacron'] = 0x1E20;
  8753. t['Gmonospace'] = 0xFF27;
  8754. t['Grave'] = 0xF6CE;
  8755. t['Gravesmall'] = 0xF760;
  8756. t['Gsmall'] = 0xF767;
  8757. t['Gsmallhook'] = 0x029B;
  8758. t['Gstroke'] = 0x01E4;
  8759. t['H'] = 0x0048;
  8760. t['H18533'] = 0x25CF;
  8761. t['H18543'] = 0x25AA;
  8762. t['H18551'] = 0x25AB;
  8763. t['H22073'] = 0x25A1;
  8764. t['HPsquare'] = 0x33CB;
  8765. t['Haabkhasiancyrillic'] = 0x04A8;
  8766. t['Hadescendercyrillic'] = 0x04B2;
  8767. t['Hardsigncyrillic'] = 0x042A;
  8768. t['Hbar'] = 0x0126;
  8769. t['Hbrevebelow'] = 0x1E2A;
  8770. t['Hcedilla'] = 0x1E28;
  8771. t['Hcircle'] = 0x24BD;
  8772. t['Hcircumflex'] = 0x0124;
  8773. t['Hdieresis'] = 0x1E26;
  8774. t['Hdotaccent'] = 0x1E22;
  8775. t['Hdotbelow'] = 0x1E24;
  8776. t['Hmonospace'] = 0xFF28;
  8777. t['Hoarmenian'] = 0x0540;
  8778. t['Horicoptic'] = 0x03E8;
  8779. t['Hsmall'] = 0xF768;
  8780. t['Hungarumlaut'] = 0xF6CF;
  8781. t['Hungarumlautsmall'] = 0xF6F8;
  8782. t['Hzsquare'] = 0x3390;
  8783. t['I'] = 0x0049;
  8784. t['IAcyrillic'] = 0x042F;
  8785. t['IJ'] = 0x0132;
  8786. t['IUcyrillic'] = 0x042E;
  8787. t['Iacute'] = 0x00CD;
  8788. t['Iacutesmall'] = 0xF7ED;
  8789. t['Ibreve'] = 0x012C;
  8790. t['Icaron'] = 0x01CF;
  8791. t['Icircle'] = 0x24BE;
  8792. t['Icircumflex'] = 0x00CE;
  8793. t['Icircumflexsmall'] = 0xF7EE;
  8794. t['Icyrillic'] = 0x0406;
  8795. t['Idblgrave'] = 0x0208;
  8796. t['Idieresis'] = 0x00CF;
  8797. t['Idieresisacute'] = 0x1E2E;
  8798. t['Idieresiscyrillic'] = 0x04E4;
  8799. t['Idieresissmall'] = 0xF7EF;
  8800. t['Idot'] = 0x0130;
  8801. t['Idotaccent'] = 0x0130;
  8802. t['Idotbelow'] = 0x1ECA;
  8803. t['Iebrevecyrillic'] = 0x04D6;
  8804. t['Iecyrillic'] = 0x0415;
  8805. t['Ifraktur'] = 0x2111;
  8806. t['Igrave'] = 0x00CC;
  8807. t['Igravesmall'] = 0xF7EC;
  8808. t['Ihookabove'] = 0x1EC8;
  8809. t['Iicyrillic'] = 0x0418;
  8810. t['Iinvertedbreve'] = 0x020A;
  8811. t['Iishortcyrillic'] = 0x0419;
  8812. t['Imacron'] = 0x012A;
  8813. t['Imacroncyrillic'] = 0x04E2;
  8814. t['Imonospace'] = 0xFF29;
  8815. t['Iniarmenian'] = 0x053B;
  8816. t['Iocyrillic'] = 0x0401;
  8817. t['Iogonek'] = 0x012E;
  8818. t['Iota'] = 0x0399;
  8819. t['Iotaafrican'] = 0x0196;
  8820. t['Iotadieresis'] = 0x03AA;
  8821. t['Iotatonos'] = 0x038A;
  8822. t['Ismall'] = 0xF769;
  8823. t['Istroke'] = 0x0197;
  8824. t['Itilde'] = 0x0128;
  8825. t['Itildebelow'] = 0x1E2C;
  8826. t['Izhitsacyrillic'] = 0x0474;
  8827. t['Izhitsadblgravecyrillic'] = 0x0476;
  8828. t['J'] = 0x004A;
  8829. t['Jaarmenian'] = 0x0541;
  8830. t['Jcircle'] = 0x24BF;
  8831. t['Jcircumflex'] = 0x0134;
  8832. t['Jecyrillic'] = 0x0408;
  8833. t['Jheharmenian'] = 0x054B;
  8834. t['Jmonospace'] = 0xFF2A;
  8835. t['Jsmall'] = 0xF76A;
  8836. t['K'] = 0x004B;
  8837. t['KBsquare'] = 0x3385;
  8838. t['KKsquare'] = 0x33CD;
  8839. t['Kabashkircyrillic'] = 0x04A0;
  8840. t['Kacute'] = 0x1E30;
  8841. t['Kacyrillic'] = 0x041A;
  8842. t['Kadescendercyrillic'] = 0x049A;
  8843. t['Kahookcyrillic'] = 0x04C3;
  8844. t['Kappa'] = 0x039A;
  8845. t['Kastrokecyrillic'] = 0x049E;
  8846. t['Kaverticalstrokecyrillic'] = 0x049C;
  8847. t['Kcaron'] = 0x01E8;
  8848. t['Kcedilla'] = 0x0136;
  8849. t['Kcircle'] = 0x24C0;
  8850. t['Kcommaaccent'] = 0x0136;
  8851. t['Kdotbelow'] = 0x1E32;
  8852. t['Keharmenian'] = 0x0554;
  8853. t['Kenarmenian'] = 0x053F;
  8854. t['Khacyrillic'] = 0x0425;
  8855. t['Kheicoptic'] = 0x03E6;
  8856. t['Khook'] = 0x0198;
  8857. t['Kjecyrillic'] = 0x040C;
  8858. t['Klinebelow'] = 0x1E34;
  8859. t['Kmonospace'] = 0xFF2B;
  8860. t['Koppacyrillic'] = 0x0480;
  8861. t['Koppagreek'] = 0x03DE;
  8862. t['Ksicyrillic'] = 0x046E;
  8863. t['Ksmall'] = 0xF76B;
  8864. t['L'] = 0x004C;
  8865. t['LJ'] = 0x01C7;
  8866. t['LL'] = 0xF6BF;
  8867. t['Lacute'] = 0x0139;
  8868. t['Lambda'] = 0x039B;
  8869. t['Lcaron'] = 0x013D;
  8870. t['Lcedilla'] = 0x013B;
  8871. t['Lcircle'] = 0x24C1;
  8872. t['Lcircumflexbelow'] = 0x1E3C;
  8873. t['Lcommaaccent'] = 0x013B;
  8874. t['Ldot'] = 0x013F;
  8875. t['Ldotaccent'] = 0x013F;
  8876. t['Ldotbelow'] = 0x1E36;
  8877. t['Ldotbelowmacron'] = 0x1E38;
  8878. t['Liwnarmenian'] = 0x053C;
  8879. t['Lj'] = 0x01C8;
  8880. t['Ljecyrillic'] = 0x0409;
  8881. t['Llinebelow'] = 0x1E3A;
  8882. t['Lmonospace'] = 0xFF2C;
  8883. t['Lslash'] = 0x0141;
  8884. t['Lslashsmall'] = 0xF6F9;
  8885. t['Lsmall'] = 0xF76C;
  8886. t['M'] = 0x004D;
  8887. t['MBsquare'] = 0x3386;
  8888. t['Macron'] = 0xF6D0;
  8889. t['Macronsmall'] = 0xF7AF;
  8890. t['Macute'] = 0x1E3E;
  8891. t['Mcircle'] = 0x24C2;
  8892. t['Mdotaccent'] = 0x1E40;
  8893. t['Mdotbelow'] = 0x1E42;
  8894. t['Menarmenian'] = 0x0544;
  8895. t['Mmonospace'] = 0xFF2D;
  8896. t['Msmall'] = 0xF76D;
  8897. t['Mturned'] = 0x019C;
  8898. t['Mu'] = 0x039C;
  8899. t['N'] = 0x004E;
  8900. t['NJ'] = 0x01CA;
  8901. t['Nacute'] = 0x0143;
  8902. t['Ncaron'] = 0x0147;
  8903. t['Ncedilla'] = 0x0145;
  8904. t['Ncircle'] = 0x24C3;
  8905. t['Ncircumflexbelow'] = 0x1E4A;
  8906. t['Ncommaaccent'] = 0x0145;
  8907. t['Ndotaccent'] = 0x1E44;
  8908. t['Ndotbelow'] = 0x1E46;
  8909. t['Nhookleft'] = 0x019D;
  8910. t['Nineroman'] = 0x2168;
  8911. t['Nj'] = 0x01CB;
  8912. t['Njecyrillic'] = 0x040A;
  8913. t['Nlinebelow'] = 0x1E48;
  8914. t['Nmonospace'] = 0xFF2E;
  8915. t['Nowarmenian'] = 0x0546;
  8916. t['Nsmall'] = 0xF76E;
  8917. t['Ntilde'] = 0x00D1;
  8918. t['Ntildesmall'] = 0xF7F1;
  8919. t['Nu'] = 0x039D;
  8920. t['O'] = 0x004F;
  8921. t['OE'] = 0x0152;
  8922. t['OEsmall'] = 0xF6FA;
  8923. t['Oacute'] = 0x00D3;
  8924. t['Oacutesmall'] = 0xF7F3;
  8925. t['Obarredcyrillic'] = 0x04E8;
  8926. t['Obarreddieresiscyrillic'] = 0x04EA;
  8927. t['Obreve'] = 0x014E;
  8928. t['Ocaron'] = 0x01D1;
  8929. t['Ocenteredtilde'] = 0x019F;
  8930. t['Ocircle'] = 0x24C4;
  8931. t['Ocircumflex'] = 0x00D4;
  8932. t['Ocircumflexacute'] = 0x1ED0;
  8933. t['Ocircumflexdotbelow'] = 0x1ED8;
  8934. t['Ocircumflexgrave'] = 0x1ED2;
  8935. t['Ocircumflexhookabove'] = 0x1ED4;
  8936. t['Ocircumflexsmall'] = 0xF7F4;
  8937. t['Ocircumflextilde'] = 0x1ED6;
  8938. t['Ocyrillic'] = 0x041E;
  8939. t['Odblacute'] = 0x0150;
  8940. t['Odblgrave'] = 0x020C;
  8941. t['Odieresis'] = 0x00D6;
  8942. t['Odieresiscyrillic'] = 0x04E6;
  8943. t['Odieresissmall'] = 0xF7F6;
  8944. t['Odotbelow'] = 0x1ECC;
  8945. t['Ogoneksmall'] = 0xF6FB;
  8946. t['Ograve'] = 0x00D2;
  8947. t['Ogravesmall'] = 0xF7F2;
  8948. t['Oharmenian'] = 0x0555;
  8949. t['Ohm'] = 0x2126;
  8950. t['Ohookabove'] = 0x1ECE;
  8951. t['Ohorn'] = 0x01A0;
  8952. t['Ohornacute'] = 0x1EDA;
  8953. t['Ohorndotbelow'] = 0x1EE2;
  8954. t['Ohorngrave'] = 0x1EDC;
  8955. t['Ohornhookabove'] = 0x1EDE;
  8956. t['Ohorntilde'] = 0x1EE0;
  8957. t['Ohungarumlaut'] = 0x0150;
  8958. t['Oi'] = 0x01A2;
  8959. t['Oinvertedbreve'] = 0x020E;
  8960. t['Omacron'] = 0x014C;
  8961. t['Omacronacute'] = 0x1E52;
  8962. t['Omacrongrave'] = 0x1E50;
  8963. t['Omega'] = 0x2126;
  8964. t['Omegacyrillic'] = 0x0460;
  8965. t['Omegagreek'] = 0x03A9;
  8966. t['Omegaroundcyrillic'] = 0x047A;
  8967. t['Omegatitlocyrillic'] = 0x047C;
  8968. t['Omegatonos'] = 0x038F;
  8969. t['Omicron'] = 0x039F;
  8970. t['Omicrontonos'] = 0x038C;
  8971. t['Omonospace'] = 0xFF2F;
  8972. t['Oneroman'] = 0x2160;
  8973. t['Oogonek'] = 0x01EA;
  8974. t['Oogonekmacron'] = 0x01EC;
  8975. t['Oopen'] = 0x0186;
  8976. t['Oslash'] = 0x00D8;
  8977. t['Oslashacute'] = 0x01FE;
  8978. t['Oslashsmall'] = 0xF7F8;
  8979. t['Osmall'] = 0xF76F;
  8980. t['Ostrokeacute'] = 0x01FE;
  8981. t['Otcyrillic'] = 0x047E;
  8982. t['Otilde'] = 0x00D5;
  8983. t['Otildeacute'] = 0x1E4C;
  8984. t['Otildedieresis'] = 0x1E4E;
  8985. t['Otildesmall'] = 0xF7F5;
  8986. t['P'] = 0x0050;
  8987. t['Pacute'] = 0x1E54;
  8988. t['Pcircle'] = 0x24C5;
  8989. t['Pdotaccent'] = 0x1E56;
  8990. t['Pecyrillic'] = 0x041F;
  8991. t['Peharmenian'] = 0x054A;
  8992. t['Pemiddlehookcyrillic'] = 0x04A6;
  8993. t['Phi'] = 0x03A6;
  8994. t['Phook'] = 0x01A4;
  8995. t['Pi'] = 0x03A0;
  8996. t['Piwrarmenian'] = 0x0553;
  8997. t['Pmonospace'] = 0xFF30;
  8998. t['Psi'] = 0x03A8;
  8999. t['Psicyrillic'] = 0x0470;
  9000. t['Psmall'] = 0xF770;
  9001. t['Q'] = 0x0051;
  9002. t['Qcircle'] = 0x24C6;
  9003. t['Qmonospace'] = 0xFF31;
  9004. t['Qsmall'] = 0xF771;
  9005. t['R'] = 0x0052;
  9006. t['Raarmenian'] = 0x054C;
  9007. t['Racute'] = 0x0154;
  9008. t['Rcaron'] = 0x0158;
  9009. t['Rcedilla'] = 0x0156;
  9010. t['Rcircle'] = 0x24C7;
  9011. t['Rcommaaccent'] = 0x0156;
  9012. t['Rdblgrave'] = 0x0210;
  9013. t['Rdotaccent'] = 0x1E58;
  9014. t['Rdotbelow'] = 0x1E5A;
  9015. t['Rdotbelowmacron'] = 0x1E5C;
  9016. t['Reharmenian'] = 0x0550;
  9017. t['Rfraktur'] = 0x211C;
  9018. t['Rho'] = 0x03A1;
  9019. t['Ringsmall'] = 0xF6FC;
  9020. t['Rinvertedbreve'] = 0x0212;
  9021. t['Rlinebelow'] = 0x1E5E;
  9022. t['Rmonospace'] = 0xFF32;
  9023. t['Rsmall'] = 0xF772;
  9024. t['Rsmallinverted'] = 0x0281;
  9025. t['Rsmallinvertedsuperior'] = 0x02B6;
  9026. t['S'] = 0x0053;
  9027. t['SF010000'] = 0x250C;
  9028. t['SF020000'] = 0x2514;
  9029. t['SF030000'] = 0x2510;
  9030. t['SF040000'] = 0x2518;
  9031. t['SF050000'] = 0x253C;
  9032. t['SF060000'] = 0x252C;
  9033. t['SF070000'] = 0x2534;
  9034. t['SF080000'] = 0x251C;
  9035. t['SF090000'] = 0x2524;
  9036. t['SF100000'] = 0x2500;
  9037. t['SF110000'] = 0x2502;
  9038. t['SF190000'] = 0x2561;
  9039. t['SF200000'] = 0x2562;
  9040. t['SF210000'] = 0x2556;
  9041. t['SF220000'] = 0x2555;
  9042. t['SF230000'] = 0x2563;
  9043. t['SF240000'] = 0x2551;
  9044. t['SF250000'] = 0x2557;
  9045. t['SF260000'] = 0x255D;
  9046. t['SF270000'] = 0x255C;
  9047. t['SF280000'] = 0x255B;
  9048. t['SF360000'] = 0x255E;
  9049. t['SF370000'] = 0x255F;
  9050. t['SF380000'] = 0x255A;
  9051. t['SF390000'] = 0x2554;
  9052. t['SF400000'] = 0x2569;
  9053. t['SF410000'] = 0x2566;
  9054. t['SF420000'] = 0x2560;
  9055. t['SF430000'] = 0x2550;
  9056. t['SF440000'] = 0x256C;
  9057. t['SF450000'] = 0x2567;
  9058. t['SF460000'] = 0x2568;
  9059. t['SF470000'] = 0x2564;
  9060. t['SF480000'] = 0x2565;
  9061. t['SF490000'] = 0x2559;
  9062. t['SF500000'] = 0x2558;
  9063. t['SF510000'] = 0x2552;
  9064. t['SF520000'] = 0x2553;
  9065. t['SF530000'] = 0x256B;
  9066. t['SF540000'] = 0x256A;
  9067. t['Sacute'] = 0x015A;
  9068. t['Sacutedotaccent'] = 0x1E64;
  9069. t['Sampigreek'] = 0x03E0;
  9070. t['Scaron'] = 0x0160;
  9071. t['Scarondotaccent'] = 0x1E66;
  9072. t['Scaronsmall'] = 0xF6FD;
  9073. t['Scedilla'] = 0x015E;
  9074. t['Schwa'] = 0x018F;
  9075. t['Schwacyrillic'] = 0x04D8;
  9076. t['Schwadieresiscyrillic'] = 0x04DA;
  9077. t['Scircle'] = 0x24C8;
  9078. t['Scircumflex'] = 0x015C;
  9079. t['Scommaaccent'] = 0x0218;
  9080. t['Sdotaccent'] = 0x1E60;
  9081. t['Sdotbelow'] = 0x1E62;
  9082. t['Sdotbelowdotaccent'] = 0x1E68;
  9083. t['Seharmenian'] = 0x054D;
  9084. t['Sevenroman'] = 0x2166;
  9085. t['Shaarmenian'] = 0x0547;
  9086. t['Shacyrillic'] = 0x0428;
  9087. t['Shchacyrillic'] = 0x0429;
  9088. t['Sheicoptic'] = 0x03E2;
  9089. t['Shhacyrillic'] = 0x04BA;
  9090. t['Shimacoptic'] = 0x03EC;
  9091. t['Sigma'] = 0x03A3;
  9092. t['Sixroman'] = 0x2165;
  9093. t['Smonospace'] = 0xFF33;
  9094. t['Softsigncyrillic'] = 0x042C;
  9095. t['Ssmall'] = 0xF773;
  9096. t['Stigmagreek'] = 0x03DA;
  9097. t['T'] = 0x0054;
  9098. t['Tau'] = 0x03A4;
  9099. t['Tbar'] = 0x0166;
  9100. t['Tcaron'] = 0x0164;
  9101. t['Tcedilla'] = 0x0162;
  9102. t['Tcircle'] = 0x24C9;
  9103. t['Tcircumflexbelow'] = 0x1E70;
  9104. t['Tcommaaccent'] = 0x0162;
  9105. t['Tdotaccent'] = 0x1E6A;
  9106. t['Tdotbelow'] = 0x1E6C;
  9107. t['Tecyrillic'] = 0x0422;
  9108. t['Tedescendercyrillic'] = 0x04AC;
  9109. t['Tenroman'] = 0x2169;
  9110. t['Tetsecyrillic'] = 0x04B4;
  9111. t['Theta'] = 0x0398;
  9112. t['Thook'] = 0x01AC;
  9113. t['Thorn'] = 0x00DE;
  9114. t['Thornsmall'] = 0xF7FE;
  9115. t['Threeroman'] = 0x2162;
  9116. t['Tildesmall'] = 0xF6FE;
  9117. t['Tiwnarmenian'] = 0x054F;
  9118. t['Tlinebelow'] = 0x1E6E;
  9119. t['Tmonospace'] = 0xFF34;
  9120. t['Toarmenian'] = 0x0539;
  9121. t['Tonefive'] = 0x01BC;
  9122. t['Tonesix'] = 0x0184;
  9123. t['Tonetwo'] = 0x01A7;
  9124. t['Tretroflexhook'] = 0x01AE;
  9125. t['Tsecyrillic'] = 0x0426;
  9126. t['Tshecyrillic'] = 0x040B;
  9127. t['Tsmall'] = 0xF774;
  9128. t['Twelveroman'] = 0x216B;
  9129. t['Tworoman'] = 0x2161;
  9130. t['U'] = 0x0055;
  9131. t['Uacute'] = 0x00DA;
  9132. t['Uacutesmall'] = 0xF7FA;
  9133. t['Ubreve'] = 0x016C;
  9134. t['Ucaron'] = 0x01D3;
  9135. t['Ucircle'] = 0x24CA;
  9136. t['Ucircumflex'] = 0x00DB;
  9137. t['Ucircumflexbelow'] = 0x1E76;
  9138. t['Ucircumflexsmall'] = 0xF7FB;
  9139. t['Ucyrillic'] = 0x0423;
  9140. t['Udblacute'] = 0x0170;
  9141. t['Udblgrave'] = 0x0214;
  9142. t['Udieresis'] = 0x00DC;
  9143. t['Udieresisacute'] = 0x01D7;
  9144. t['Udieresisbelow'] = 0x1E72;
  9145. t['Udieresiscaron'] = 0x01D9;
  9146. t['Udieresiscyrillic'] = 0x04F0;
  9147. t['Udieresisgrave'] = 0x01DB;
  9148. t['Udieresismacron'] = 0x01D5;
  9149. t['Udieresissmall'] = 0xF7FC;
  9150. t['Udotbelow'] = 0x1EE4;
  9151. t['Ugrave'] = 0x00D9;
  9152. t['Ugravesmall'] = 0xF7F9;
  9153. t['Uhookabove'] = 0x1EE6;
  9154. t['Uhorn'] = 0x01AF;
  9155. t['Uhornacute'] = 0x1EE8;
  9156. t['Uhorndotbelow'] = 0x1EF0;
  9157. t['Uhorngrave'] = 0x1EEA;
  9158. t['Uhornhookabove'] = 0x1EEC;
  9159. t['Uhorntilde'] = 0x1EEE;
  9160. t['Uhungarumlaut'] = 0x0170;
  9161. t['Uhungarumlautcyrillic'] = 0x04F2;
  9162. t['Uinvertedbreve'] = 0x0216;
  9163. t['Ukcyrillic'] = 0x0478;
  9164. t['Umacron'] = 0x016A;
  9165. t['Umacroncyrillic'] = 0x04EE;
  9166. t['Umacrondieresis'] = 0x1E7A;
  9167. t['Umonospace'] = 0xFF35;
  9168. t['Uogonek'] = 0x0172;
  9169. t['Upsilon'] = 0x03A5;
  9170. t['Upsilon1'] = 0x03D2;
  9171. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9172. t['Upsilonafrican'] = 0x01B1;
  9173. t['Upsilondieresis'] = 0x03AB;
  9174. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9175. t['Upsilonhooksymbol'] = 0x03D2;
  9176. t['Upsilontonos'] = 0x038E;
  9177. t['Uring'] = 0x016E;
  9178. t['Ushortcyrillic'] = 0x040E;
  9179. t['Usmall'] = 0xF775;
  9180. t['Ustraightcyrillic'] = 0x04AE;
  9181. t['Ustraightstrokecyrillic'] = 0x04B0;
  9182. t['Utilde'] = 0x0168;
  9183. t['Utildeacute'] = 0x1E78;
  9184. t['Utildebelow'] = 0x1E74;
  9185. t['V'] = 0x0056;
  9186. t['Vcircle'] = 0x24CB;
  9187. t['Vdotbelow'] = 0x1E7E;
  9188. t['Vecyrillic'] = 0x0412;
  9189. t['Vewarmenian'] = 0x054E;
  9190. t['Vhook'] = 0x01B2;
  9191. t['Vmonospace'] = 0xFF36;
  9192. t['Voarmenian'] = 0x0548;
  9193. t['Vsmall'] = 0xF776;
  9194. t['Vtilde'] = 0x1E7C;
  9195. t['W'] = 0x0057;
  9196. t['Wacute'] = 0x1E82;
  9197. t['Wcircle'] = 0x24CC;
  9198. t['Wcircumflex'] = 0x0174;
  9199. t['Wdieresis'] = 0x1E84;
  9200. t['Wdotaccent'] = 0x1E86;
  9201. t['Wdotbelow'] = 0x1E88;
  9202. t['Wgrave'] = 0x1E80;
  9203. t['Wmonospace'] = 0xFF37;
  9204. t['Wsmall'] = 0xF777;
  9205. t['X'] = 0x0058;
  9206. t['Xcircle'] = 0x24CD;
  9207. t['Xdieresis'] = 0x1E8C;
  9208. t['Xdotaccent'] = 0x1E8A;
  9209. t['Xeharmenian'] = 0x053D;
  9210. t['Xi'] = 0x039E;
  9211. t['Xmonospace'] = 0xFF38;
  9212. t['Xsmall'] = 0xF778;
  9213. t['Y'] = 0x0059;
  9214. t['Yacute'] = 0x00DD;
  9215. t['Yacutesmall'] = 0xF7FD;
  9216. t['Yatcyrillic'] = 0x0462;
  9217. t['Ycircle'] = 0x24CE;
  9218. t['Ycircumflex'] = 0x0176;
  9219. t['Ydieresis'] = 0x0178;
  9220. t['Ydieresissmall'] = 0xF7FF;
  9221. t['Ydotaccent'] = 0x1E8E;
  9222. t['Ydotbelow'] = 0x1EF4;
  9223. t['Yericyrillic'] = 0x042B;
  9224. t['Yerudieresiscyrillic'] = 0x04F8;
  9225. t['Ygrave'] = 0x1EF2;
  9226. t['Yhook'] = 0x01B3;
  9227. t['Yhookabove'] = 0x1EF6;
  9228. t['Yiarmenian'] = 0x0545;
  9229. t['Yicyrillic'] = 0x0407;
  9230. t['Yiwnarmenian'] = 0x0552;
  9231. t['Ymonospace'] = 0xFF39;
  9232. t['Ysmall'] = 0xF779;
  9233. t['Ytilde'] = 0x1EF8;
  9234. t['Yusbigcyrillic'] = 0x046A;
  9235. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9236. t['Yuslittlecyrillic'] = 0x0466;
  9237. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9238. t['Z'] = 0x005A;
  9239. t['Zaarmenian'] = 0x0536;
  9240. t['Zacute'] = 0x0179;
  9241. t['Zcaron'] = 0x017D;
  9242. t['Zcaronsmall'] = 0xF6FF;
  9243. t['Zcircle'] = 0x24CF;
  9244. t['Zcircumflex'] = 0x1E90;
  9245. t['Zdot'] = 0x017B;
  9246. t['Zdotaccent'] = 0x017B;
  9247. t['Zdotbelow'] = 0x1E92;
  9248. t['Zecyrillic'] = 0x0417;
  9249. t['Zedescendercyrillic'] = 0x0498;
  9250. t['Zedieresiscyrillic'] = 0x04DE;
  9251. t['Zeta'] = 0x0396;
  9252. t['Zhearmenian'] = 0x053A;
  9253. t['Zhebrevecyrillic'] = 0x04C1;
  9254. t['Zhecyrillic'] = 0x0416;
  9255. t['Zhedescendercyrillic'] = 0x0496;
  9256. t['Zhedieresiscyrillic'] = 0x04DC;
  9257. t['Zlinebelow'] = 0x1E94;
  9258. t['Zmonospace'] = 0xFF3A;
  9259. t['Zsmall'] = 0xF77A;
  9260. t['Zstroke'] = 0x01B5;
  9261. t['a'] = 0x0061;
  9262. t['aabengali'] = 0x0986;
  9263. t['aacute'] = 0x00E1;
  9264. t['aadeva'] = 0x0906;
  9265. t['aagujarati'] = 0x0A86;
  9266. t['aagurmukhi'] = 0x0A06;
  9267. t['aamatragurmukhi'] = 0x0A3E;
  9268. t['aarusquare'] = 0x3303;
  9269. t['aavowelsignbengali'] = 0x09BE;
  9270. t['aavowelsigndeva'] = 0x093E;
  9271. t['aavowelsigngujarati'] = 0x0ABE;
  9272. t['abbreviationmarkarmenian'] = 0x055F;
  9273. t['abbreviationsigndeva'] = 0x0970;
  9274. t['abengali'] = 0x0985;
  9275. t['abopomofo'] = 0x311A;
  9276. t['abreve'] = 0x0103;
  9277. t['abreveacute'] = 0x1EAF;
  9278. t['abrevecyrillic'] = 0x04D1;
  9279. t['abrevedotbelow'] = 0x1EB7;
  9280. t['abrevegrave'] = 0x1EB1;
  9281. t['abrevehookabove'] = 0x1EB3;
  9282. t['abrevetilde'] = 0x1EB5;
  9283. t['acaron'] = 0x01CE;
  9284. t['acircle'] = 0x24D0;
  9285. t['acircumflex'] = 0x00E2;
  9286. t['acircumflexacute'] = 0x1EA5;
  9287. t['acircumflexdotbelow'] = 0x1EAD;
  9288. t['acircumflexgrave'] = 0x1EA7;
  9289. t['acircumflexhookabove'] = 0x1EA9;
  9290. t['acircumflextilde'] = 0x1EAB;
  9291. t['acute'] = 0x00B4;
  9292. t['acutebelowcmb'] = 0x0317;
  9293. t['acutecmb'] = 0x0301;
  9294. t['acutecomb'] = 0x0301;
  9295. t['acutedeva'] = 0x0954;
  9296. t['acutelowmod'] = 0x02CF;
  9297. t['acutetonecmb'] = 0x0341;
  9298. t['acyrillic'] = 0x0430;
  9299. t['adblgrave'] = 0x0201;
  9300. t['addakgurmukhi'] = 0x0A71;
  9301. t['adeva'] = 0x0905;
  9302. t['adieresis'] = 0x00E4;
  9303. t['adieresiscyrillic'] = 0x04D3;
  9304. t['adieresismacron'] = 0x01DF;
  9305. t['adotbelow'] = 0x1EA1;
  9306. t['adotmacron'] = 0x01E1;
  9307. t['ae'] = 0x00E6;
  9308. t['aeacute'] = 0x01FD;
  9309. t['aekorean'] = 0x3150;
  9310. t['aemacron'] = 0x01E3;
  9311. t['afii00208'] = 0x2015;
  9312. t['afii08941'] = 0x20A4;
  9313. t['afii10017'] = 0x0410;
  9314. t['afii10018'] = 0x0411;
  9315. t['afii10019'] = 0x0412;
  9316. t['afii10020'] = 0x0413;
  9317. t['afii10021'] = 0x0414;
  9318. t['afii10022'] = 0x0415;
  9319. t['afii10023'] = 0x0401;
  9320. t['afii10024'] = 0x0416;
  9321. t['afii10025'] = 0x0417;
  9322. t['afii10026'] = 0x0418;
  9323. t['afii10027'] = 0x0419;
  9324. t['afii10028'] = 0x041A;
  9325. t['afii10029'] = 0x041B;
  9326. t['afii10030'] = 0x041C;
  9327. t['afii10031'] = 0x041D;
  9328. t['afii10032'] = 0x041E;
  9329. t['afii10033'] = 0x041F;
  9330. t['afii10034'] = 0x0420;
  9331. t['afii10035'] = 0x0421;
  9332. t['afii10036'] = 0x0422;
  9333. t['afii10037'] = 0x0423;
  9334. t['afii10038'] = 0x0424;
  9335. t['afii10039'] = 0x0425;
  9336. t['afii10040'] = 0x0426;
  9337. t['afii10041'] = 0x0427;
  9338. t['afii10042'] = 0x0428;
  9339. t['afii10043'] = 0x0429;
  9340. t['afii10044'] = 0x042A;
  9341. t['afii10045'] = 0x042B;
  9342. t['afii10046'] = 0x042C;
  9343. t['afii10047'] = 0x042D;
  9344. t['afii10048'] = 0x042E;
  9345. t['afii10049'] = 0x042F;
  9346. t['afii10050'] = 0x0490;
  9347. t['afii10051'] = 0x0402;
  9348. t['afii10052'] = 0x0403;
  9349. t['afii10053'] = 0x0404;
  9350. t['afii10054'] = 0x0405;
  9351. t['afii10055'] = 0x0406;
  9352. t['afii10056'] = 0x0407;
  9353. t['afii10057'] = 0x0408;
  9354. t['afii10058'] = 0x0409;
  9355. t['afii10059'] = 0x040A;
  9356. t['afii10060'] = 0x040B;
  9357. t['afii10061'] = 0x040C;
  9358. t['afii10062'] = 0x040E;
  9359. t['afii10063'] = 0xF6C4;
  9360. t['afii10064'] = 0xF6C5;
  9361. t['afii10065'] = 0x0430;
  9362. t['afii10066'] = 0x0431;
  9363. t['afii10067'] = 0x0432;
  9364. t['afii10068'] = 0x0433;
  9365. t['afii10069'] = 0x0434;
  9366. t['afii10070'] = 0x0435;
  9367. t['afii10071'] = 0x0451;
  9368. t['afii10072'] = 0x0436;
  9369. t['afii10073'] = 0x0437;
  9370. t['afii10074'] = 0x0438;
  9371. t['afii10075'] = 0x0439;
  9372. t['afii10076'] = 0x043A;
  9373. t['afii10077'] = 0x043B;
  9374. t['afii10078'] = 0x043C;
  9375. t['afii10079'] = 0x043D;
  9376. t['afii10080'] = 0x043E;
  9377. t['afii10081'] = 0x043F;
  9378. t['afii10082'] = 0x0440;
  9379. t['afii10083'] = 0x0441;
  9380. t['afii10084'] = 0x0442;
  9381. t['afii10085'] = 0x0443;
  9382. t['afii10086'] = 0x0444;
  9383. t['afii10087'] = 0x0445;
  9384. t['afii10088'] = 0x0446;
  9385. t['afii10089'] = 0x0447;
  9386. t['afii10090'] = 0x0448;
  9387. t['afii10091'] = 0x0449;
  9388. t['afii10092'] = 0x044A;
  9389. t['afii10093'] = 0x044B;
  9390. t['afii10094'] = 0x044C;
  9391. t['afii10095'] = 0x044D;
  9392. t['afii10096'] = 0x044E;
  9393. t['afii10097'] = 0x044F;
  9394. t['afii10098'] = 0x0491;
  9395. t['afii10099'] = 0x0452;
  9396. t['afii10100'] = 0x0453;
  9397. t['afii10101'] = 0x0454;
  9398. t['afii10102'] = 0x0455;
  9399. t['afii10103'] = 0x0456;
  9400. t['afii10104'] = 0x0457;
  9401. t['afii10105'] = 0x0458;
  9402. t['afii10106'] = 0x0459;
  9403. t['afii10107'] = 0x045A;
  9404. t['afii10108'] = 0x045B;
  9405. t['afii10109'] = 0x045C;
  9406. t['afii10110'] = 0x045E;
  9407. t['afii10145'] = 0x040F;
  9408. t['afii10146'] = 0x0462;
  9409. t['afii10147'] = 0x0472;
  9410. t['afii10148'] = 0x0474;
  9411. t['afii10192'] = 0xF6C6;
  9412. t['afii10193'] = 0x045F;
  9413. t['afii10194'] = 0x0463;
  9414. t['afii10195'] = 0x0473;
  9415. t['afii10196'] = 0x0475;
  9416. t['afii10831'] = 0xF6C7;
  9417. t['afii10832'] = 0xF6C8;
  9418. t['afii10846'] = 0x04D9;
  9419. t['afii299'] = 0x200E;
  9420. t['afii300'] = 0x200F;
  9421. t['afii301'] = 0x200D;
  9422. t['afii57381'] = 0x066A;
  9423. t['afii57388'] = 0x060C;
  9424. t['afii57392'] = 0x0660;
  9425. t['afii57393'] = 0x0661;
  9426. t['afii57394'] = 0x0662;
  9427. t['afii57395'] = 0x0663;
  9428. t['afii57396'] = 0x0664;
  9429. t['afii57397'] = 0x0665;
  9430. t['afii57398'] = 0x0666;
  9431. t['afii57399'] = 0x0667;
  9432. t['afii57400'] = 0x0668;
  9433. t['afii57401'] = 0x0669;
  9434. t['afii57403'] = 0x061B;
  9435. t['afii57407'] = 0x061F;
  9436. t['afii57409'] = 0x0621;
  9437. t['afii57410'] = 0x0622;
  9438. t['afii57411'] = 0x0623;
  9439. t['afii57412'] = 0x0624;
  9440. t['afii57413'] = 0x0625;
  9441. t['afii57414'] = 0x0626;
  9442. t['afii57415'] = 0x0627;
  9443. t['afii57416'] = 0x0628;
  9444. t['afii57417'] = 0x0629;
  9445. t['afii57418'] = 0x062A;
  9446. t['afii57419'] = 0x062B;
  9447. t['afii57420'] = 0x062C;
  9448. t['afii57421'] = 0x062D;
  9449. t['afii57422'] = 0x062E;
  9450. t['afii57423'] = 0x062F;
  9451. t['afii57424'] = 0x0630;
  9452. t['afii57425'] = 0x0631;
  9453. t['afii57426'] = 0x0632;
  9454. t['afii57427'] = 0x0633;
  9455. t['afii57428'] = 0x0634;
  9456. t['afii57429'] = 0x0635;
  9457. t['afii57430'] = 0x0636;
  9458. t['afii57431'] = 0x0637;
  9459. t['afii57432'] = 0x0638;
  9460. t['afii57433'] = 0x0639;
  9461. t['afii57434'] = 0x063A;
  9462. t['afii57440'] = 0x0640;
  9463. t['afii57441'] = 0x0641;
  9464. t['afii57442'] = 0x0642;
  9465. t['afii57443'] = 0x0643;
  9466. t['afii57444'] = 0x0644;
  9467. t['afii57445'] = 0x0645;
  9468. t['afii57446'] = 0x0646;
  9469. t['afii57448'] = 0x0648;
  9470. t['afii57449'] = 0x0649;
  9471. t['afii57450'] = 0x064A;
  9472. t['afii57451'] = 0x064B;
  9473. t['afii57452'] = 0x064C;
  9474. t['afii57453'] = 0x064D;
  9475. t['afii57454'] = 0x064E;
  9476. t['afii57455'] = 0x064F;
  9477. t['afii57456'] = 0x0650;
  9478. t['afii57457'] = 0x0651;
  9479. t['afii57458'] = 0x0652;
  9480. t['afii57470'] = 0x0647;
  9481. t['afii57505'] = 0x06A4;
  9482. t['afii57506'] = 0x067E;
  9483. t['afii57507'] = 0x0686;
  9484. t['afii57508'] = 0x0698;
  9485. t['afii57509'] = 0x06AF;
  9486. t['afii57511'] = 0x0679;
  9487. t['afii57512'] = 0x0688;
  9488. t['afii57513'] = 0x0691;
  9489. t['afii57514'] = 0x06BA;
  9490. t['afii57519'] = 0x06D2;
  9491. t['afii57534'] = 0x06D5;
  9492. t['afii57636'] = 0x20AA;
  9493. t['afii57645'] = 0x05BE;
  9494. t['afii57658'] = 0x05C3;
  9495. t['afii57664'] = 0x05D0;
  9496. t['afii57665'] = 0x05D1;
  9497. t['afii57666'] = 0x05D2;
  9498. t['afii57667'] = 0x05D3;
  9499. t['afii57668'] = 0x05D4;
  9500. t['afii57669'] = 0x05D5;
  9501. t['afii57670'] = 0x05D6;
  9502. t['afii57671'] = 0x05D7;
  9503. t['afii57672'] = 0x05D8;
  9504. t['afii57673'] = 0x05D9;
  9505. t['afii57674'] = 0x05DA;
  9506. t['afii57675'] = 0x05DB;
  9507. t['afii57676'] = 0x05DC;
  9508. t['afii57677'] = 0x05DD;
  9509. t['afii57678'] = 0x05DE;
  9510. t['afii57679'] = 0x05DF;
  9511. t['afii57680'] = 0x05E0;
  9512. t['afii57681'] = 0x05E1;
  9513. t['afii57682'] = 0x05E2;
  9514. t['afii57683'] = 0x05E3;
  9515. t['afii57684'] = 0x05E4;
  9516. t['afii57685'] = 0x05E5;
  9517. t['afii57686'] = 0x05E6;
  9518. t['afii57687'] = 0x05E7;
  9519. t['afii57688'] = 0x05E8;
  9520. t['afii57689'] = 0x05E9;
  9521. t['afii57690'] = 0x05EA;
  9522. t['afii57694'] = 0xFB2A;
  9523. t['afii57695'] = 0xFB2B;
  9524. t['afii57700'] = 0xFB4B;
  9525. t['afii57705'] = 0xFB1F;
  9526. t['afii57716'] = 0x05F0;
  9527. t['afii57717'] = 0x05F1;
  9528. t['afii57718'] = 0x05F2;
  9529. t['afii57723'] = 0xFB35;
  9530. t['afii57793'] = 0x05B4;
  9531. t['afii57794'] = 0x05B5;
  9532. t['afii57795'] = 0x05B6;
  9533. t['afii57796'] = 0x05BB;
  9534. t['afii57797'] = 0x05B8;
  9535. t['afii57798'] = 0x05B7;
  9536. t['afii57799'] = 0x05B0;
  9537. t['afii57800'] = 0x05B2;
  9538. t['afii57801'] = 0x05B1;
  9539. t['afii57802'] = 0x05B3;
  9540. t['afii57803'] = 0x05C2;
  9541. t['afii57804'] = 0x05C1;
  9542. t['afii57806'] = 0x05B9;
  9543. t['afii57807'] = 0x05BC;
  9544. t['afii57839'] = 0x05BD;
  9545. t['afii57841'] = 0x05BF;
  9546. t['afii57842'] = 0x05C0;
  9547. t['afii57929'] = 0x02BC;
  9548. t['afii61248'] = 0x2105;
  9549. t['afii61289'] = 0x2113;
  9550. t['afii61352'] = 0x2116;
  9551. t['afii61573'] = 0x202C;
  9552. t['afii61574'] = 0x202D;
  9553. t['afii61575'] = 0x202E;
  9554. t['afii61664'] = 0x200C;
  9555. t['afii63167'] = 0x066D;
  9556. t['afii64937'] = 0x02BD;
  9557. t['agrave'] = 0x00E0;
  9558. t['agujarati'] = 0x0A85;
  9559. t['agurmukhi'] = 0x0A05;
  9560. t['ahiragana'] = 0x3042;
  9561. t['ahookabove'] = 0x1EA3;
  9562. t['aibengali'] = 0x0990;
  9563. t['aibopomofo'] = 0x311E;
  9564. t['aideva'] = 0x0910;
  9565. t['aiecyrillic'] = 0x04D5;
  9566. t['aigujarati'] = 0x0A90;
  9567. t['aigurmukhi'] = 0x0A10;
  9568. t['aimatragurmukhi'] = 0x0A48;
  9569. t['ainarabic'] = 0x0639;
  9570. t['ainfinalarabic'] = 0xFECA;
  9571. t['aininitialarabic'] = 0xFECB;
  9572. t['ainmedialarabic'] = 0xFECC;
  9573. t['ainvertedbreve'] = 0x0203;
  9574. t['aivowelsignbengali'] = 0x09C8;
  9575. t['aivowelsigndeva'] = 0x0948;
  9576. t['aivowelsigngujarati'] = 0x0AC8;
  9577. t['akatakana'] = 0x30A2;
  9578. t['akatakanahalfwidth'] = 0xFF71;
  9579. t['akorean'] = 0x314F;
  9580. t['alef'] = 0x05D0;
  9581. t['alefarabic'] = 0x0627;
  9582. t['alefdageshhebrew'] = 0xFB30;
  9583. t['aleffinalarabic'] = 0xFE8E;
  9584. t['alefhamzaabovearabic'] = 0x0623;
  9585. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9586. t['alefhamzabelowarabic'] = 0x0625;
  9587. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9588. t['alefhebrew'] = 0x05D0;
  9589. t['aleflamedhebrew'] = 0xFB4F;
  9590. t['alefmaddaabovearabic'] = 0x0622;
  9591. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9592. t['alefmaksuraarabic'] = 0x0649;
  9593. t['alefmaksurafinalarabic'] = 0xFEF0;
  9594. t['alefmaksurainitialarabic'] = 0xFEF3;
  9595. t['alefmaksuramedialarabic'] = 0xFEF4;
  9596. t['alefpatahhebrew'] = 0xFB2E;
  9597. t['alefqamatshebrew'] = 0xFB2F;
  9598. t['aleph'] = 0x2135;
  9599. t['allequal'] = 0x224C;
  9600. t['alpha'] = 0x03B1;
  9601. t['alphatonos'] = 0x03AC;
  9602. t['amacron'] = 0x0101;
  9603. t['amonospace'] = 0xFF41;
  9604. t['ampersand'] = 0x0026;
  9605. t['ampersandmonospace'] = 0xFF06;
  9606. t['ampersandsmall'] = 0xF726;
  9607. t['amsquare'] = 0x33C2;
  9608. t['anbopomofo'] = 0x3122;
  9609. t['angbopomofo'] = 0x3124;
  9610. t['angbracketleft'] = 0x3008;
  9611. t['angbracketright'] = 0x3009;
  9612. t['angkhankhuthai'] = 0x0E5A;
  9613. t['angle'] = 0x2220;
  9614. t['anglebracketleft'] = 0x3008;
  9615. t['anglebracketleftvertical'] = 0xFE3F;
  9616. t['anglebracketright'] = 0x3009;
  9617. t['anglebracketrightvertical'] = 0xFE40;
  9618. t['angleleft'] = 0x2329;
  9619. t['angleright'] = 0x232A;
  9620. t['angstrom'] = 0x212B;
  9621. t['anoteleia'] = 0x0387;
  9622. t['anudattadeva'] = 0x0952;
  9623. t['anusvarabengali'] = 0x0982;
  9624. t['anusvaradeva'] = 0x0902;
  9625. t['anusvaragujarati'] = 0x0A82;
  9626. t['aogonek'] = 0x0105;
  9627. t['apaatosquare'] = 0x3300;
  9628. t['aparen'] = 0x249C;
  9629. t['apostrophearmenian'] = 0x055A;
  9630. t['apostrophemod'] = 0x02BC;
  9631. t['apple'] = 0xF8FF;
  9632. t['approaches'] = 0x2250;
  9633. t['approxequal'] = 0x2248;
  9634. t['approxequalorimage'] = 0x2252;
  9635. t['approximatelyequal'] = 0x2245;
  9636. t['araeaekorean'] = 0x318E;
  9637. t['araeakorean'] = 0x318D;
  9638. t['arc'] = 0x2312;
  9639. t['arighthalfring'] = 0x1E9A;
  9640. t['aring'] = 0x00E5;
  9641. t['aringacute'] = 0x01FB;
  9642. t['aringbelow'] = 0x1E01;
  9643. t['arrowboth'] = 0x2194;
  9644. t['arrowdashdown'] = 0x21E3;
  9645. t['arrowdashleft'] = 0x21E0;
  9646. t['arrowdashright'] = 0x21E2;
  9647. t['arrowdashup'] = 0x21E1;
  9648. t['arrowdblboth'] = 0x21D4;
  9649. t['arrowdbldown'] = 0x21D3;
  9650. t['arrowdblleft'] = 0x21D0;
  9651. t['arrowdblright'] = 0x21D2;
  9652. t['arrowdblup'] = 0x21D1;
  9653. t['arrowdown'] = 0x2193;
  9654. t['arrowdownleft'] = 0x2199;
  9655. t['arrowdownright'] = 0x2198;
  9656. t['arrowdownwhite'] = 0x21E9;
  9657. t['arrowheaddownmod'] = 0x02C5;
  9658. t['arrowheadleftmod'] = 0x02C2;
  9659. t['arrowheadrightmod'] = 0x02C3;
  9660. t['arrowheadupmod'] = 0x02C4;
  9661. t['arrowhorizex'] = 0xF8E7;
  9662. t['arrowleft'] = 0x2190;
  9663. t['arrowleftdbl'] = 0x21D0;
  9664. t['arrowleftdblstroke'] = 0x21CD;
  9665. t['arrowleftoverright'] = 0x21C6;
  9666. t['arrowleftwhite'] = 0x21E6;
  9667. t['arrowright'] = 0x2192;
  9668. t['arrowrightdblstroke'] = 0x21CF;
  9669. t['arrowrightheavy'] = 0x279E;
  9670. t['arrowrightoverleft'] = 0x21C4;
  9671. t['arrowrightwhite'] = 0x21E8;
  9672. t['arrowtableft'] = 0x21E4;
  9673. t['arrowtabright'] = 0x21E5;
  9674. t['arrowup'] = 0x2191;
  9675. t['arrowupdn'] = 0x2195;
  9676. t['arrowupdnbse'] = 0x21A8;
  9677. t['arrowupdownbase'] = 0x21A8;
  9678. t['arrowupleft'] = 0x2196;
  9679. t['arrowupleftofdown'] = 0x21C5;
  9680. t['arrowupright'] = 0x2197;
  9681. t['arrowupwhite'] = 0x21E7;
  9682. t['arrowvertex'] = 0xF8E6;
  9683. t['asciicircum'] = 0x005E;
  9684. t['asciicircummonospace'] = 0xFF3E;
  9685. t['asciitilde'] = 0x007E;
  9686. t['asciitildemonospace'] = 0xFF5E;
  9687. t['ascript'] = 0x0251;
  9688. t['ascriptturned'] = 0x0252;
  9689. t['asmallhiragana'] = 0x3041;
  9690. t['asmallkatakana'] = 0x30A1;
  9691. t['asmallkatakanahalfwidth'] = 0xFF67;
  9692. t['asterisk'] = 0x002A;
  9693. t['asteriskaltonearabic'] = 0x066D;
  9694. t['asteriskarabic'] = 0x066D;
  9695. t['asteriskmath'] = 0x2217;
  9696. t['asteriskmonospace'] = 0xFF0A;
  9697. t['asterisksmall'] = 0xFE61;
  9698. t['asterism'] = 0x2042;
  9699. t['asuperior'] = 0xF6E9;
  9700. t['asymptoticallyequal'] = 0x2243;
  9701. t['at'] = 0x0040;
  9702. t['atilde'] = 0x00E3;
  9703. t['atmonospace'] = 0xFF20;
  9704. t['atsmall'] = 0xFE6B;
  9705. t['aturned'] = 0x0250;
  9706. t['aubengali'] = 0x0994;
  9707. t['aubopomofo'] = 0x3120;
  9708. t['audeva'] = 0x0914;
  9709. t['augujarati'] = 0x0A94;
  9710. t['augurmukhi'] = 0x0A14;
  9711. t['aulengthmarkbengali'] = 0x09D7;
  9712. t['aumatragurmukhi'] = 0x0A4C;
  9713. t['auvowelsignbengali'] = 0x09CC;
  9714. t['auvowelsigndeva'] = 0x094C;
  9715. t['auvowelsigngujarati'] = 0x0ACC;
  9716. t['avagrahadeva'] = 0x093D;
  9717. t['aybarmenian'] = 0x0561;
  9718. t['ayin'] = 0x05E2;
  9719. t['ayinaltonehebrew'] = 0xFB20;
  9720. t['ayinhebrew'] = 0x05E2;
  9721. t['b'] = 0x0062;
  9722. t['babengali'] = 0x09AC;
  9723. t['backslash'] = 0x005C;
  9724. t['backslashmonospace'] = 0xFF3C;
  9725. t['badeva'] = 0x092C;
  9726. t['bagujarati'] = 0x0AAC;
  9727. t['bagurmukhi'] = 0x0A2C;
  9728. t['bahiragana'] = 0x3070;
  9729. t['bahtthai'] = 0x0E3F;
  9730. t['bakatakana'] = 0x30D0;
  9731. t['bar'] = 0x007C;
  9732. t['barmonospace'] = 0xFF5C;
  9733. t['bbopomofo'] = 0x3105;
  9734. t['bcircle'] = 0x24D1;
  9735. t['bdotaccent'] = 0x1E03;
  9736. t['bdotbelow'] = 0x1E05;
  9737. t['beamedsixteenthnotes'] = 0x266C;
  9738. t['because'] = 0x2235;
  9739. t['becyrillic'] = 0x0431;
  9740. t['beharabic'] = 0x0628;
  9741. t['behfinalarabic'] = 0xFE90;
  9742. t['behinitialarabic'] = 0xFE91;
  9743. t['behiragana'] = 0x3079;
  9744. t['behmedialarabic'] = 0xFE92;
  9745. t['behmeeminitialarabic'] = 0xFC9F;
  9746. t['behmeemisolatedarabic'] = 0xFC08;
  9747. t['behnoonfinalarabic'] = 0xFC6D;
  9748. t['bekatakana'] = 0x30D9;
  9749. t['benarmenian'] = 0x0562;
  9750. t['bet'] = 0x05D1;
  9751. t['beta'] = 0x03B2;
  9752. t['betasymbolgreek'] = 0x03D0;
  9753. t['betdagesh'] = 0xFB31;
  9754. t['betdageshhebrew'] = 0xFB31;
  9755. t['bethebrew'] = 0x05D1;
  9756. t['betrafehebrew'] = 0xFB4C;
  9757. t['bhabengali'] = 0x09AD;
  9758. t['bhadeva'] = 0x092D;
  9759. t['bhagujarati'] = 0x0AAD;
  9760. t['bhagurmukhi'] = 0x0A2D;
  9761. t['bhook'] = 0x0253;
  9762. t['bihiragana'] = 0x3073;
  9763. t['bikatakana'] = 0x30D3;
  9764. t['bilabialclick'] = 0x0298;
  9765. t['bindigurmukhi'] = 0x0A02;
  9766. t['birusquare'] = 0x3331;
  9767. t['blackcircle'] = 0x25CF;
  9768. t['blackdiamond'] = 0x25C6;
  9769. t['blackdownpointingtriangle'] = 0x25BC;
  9770. t['blackleftpointingpointer'] = 0x25C4;
  9771. t['blackleftpointingtriangle'] = 0x25C0;
  9772. t['blacklenticularbracketleft'] = 0x3010;
  9773. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9774. t['blacklenticularbracketright'] = 0x3011;
  9775. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9776. t['blacklowerlefttriangle'] = 0x25E3;
  9777. t['blacklowerrighttriangle'] = 0x25E2;
  9778. t['blackrectangle'] = 0x25AC;
  9779. t['blackrightpointingpointer'] = 0x25BA;
  9780. t['blackrightpointingtriangle'] = 0x25B6;
  9781. t['blacksmallsquare'] = 0x25AA;
  9782. t['blacksmilingface'] = 0x263B;
  9783. t['blacksquare'] = 0x25A0;
  9784. t['blackstar'] = 0x2605;
  9785. t['blackupperlefttriangle'] = 0x25E4;
  9786. t['blackupperrighttriangle'] = 0x25E5;
  9787. t['blackuppointingsmalltriangle'] = 0x25B4;
  9788. t['blackuppointingtriangle'] = 0x25B2;
  9789. t['blank'] = 0x2423;
  9790. t['blinebelow'] = 0x1E07;
  9791. t['block'] = 0x2588;
  9792. t['bmonospace'] = 0xFF42;
  9793. t['bobaimaithai'] = 0x0E1A;
  9794. t['bohiragana'] = 0x307C;
  9795. t['bokatakana'] = 0x30DC;
  9796. t['bparen'] = 0x249D;
  9797. t['bqsquare'] = 0x33C3;
  9798. t['braceex'] = 0xF8F4;
  9799. t['braceleft'] = 0x007B;
  9800. t['braceleftbt'] = 0xF8F3;
  9801. t['braceleftmid'] = 0xF8F2;
  9802. t['braceleftmonospace'] = 0xFF5B;
  9803. t['braceleftsmall'] = 0xFE5B;
  9804. t['bracelefttp'] = 0xF8F1;
  9805. t['braceleftvertical'] = 0xFE37;
  9806. t['braceright'] = 0x007D;
  9807. t['bracerightbt'] = 0xF8FE;
  9808. t['bracerightmid'] = 0xF8FD;
  9809. t['bracerightmonospace'] = 0xFF5D;
  9810. t['bracerightsmall'] = 0xFE5C;
  9811. t['bracerighttp'] = 0xF8FC;
  9812. t['bracerightvertical'] = 0xFE38;
  9813. t['bracketleft'] = 0x005B;
  9814. t['bracketleftbt'] = 0xF8F0;
  9815. t['bracketleftex'] = 0xF8EF;
  9816. t['bracketleftmonospace'] = 0xFF3B;
  9817. t['bracketlefttp'] = 0xF8EE;
  9818. t['bracketright'] = 0x005D;
  9819. t['bracketrightbt'] = 0xF8FB;
  9820. t['bracketrightex'] = 0xF8FA;
  9821. t['bracketrightmonospace'] = 0xFF3D;
  9822. t['bracketrighttp'] = 0xF8F9;
  9823. t['breve'] = 0x02D8;
  9824. t['brevebelowcmb'] = 0x032E;
  9825. t['brevecmb'] = 0x0306;
  9826. t['breveinvertedbelowcmb'] = 0x032F;
  9827. t['breveinvertedcmb'] = 0x0311;
  9828. t['breveinverteddoublecmb'] = 0x0361;
  9829. t['bridgebelowcmb'] = 0x032A;
  9830. t['bridgeinvertedbelowcmb'] = 0x033A;
  9831. t['brokenbar'] = 0x00A6;
  9832. t['bstroke'] = 0x0180;
  9833. t['bsuperior'] = 0xF6EA;
  9834. t['btopbar'] = 0x0183;
  9835. t['buhiragana'] = 0x3076;
  9836. t['bukatakana'] = 0x30D6;
  9837. t['bullet'] = 0x2022;
  9838. t['bulletinverse'] = 0x25D8;
  9839. t['bulletoperator'] = 0x2219;
  9840. t['bullseye'] = 0x25CE;
  9841. t['c'] = 0x0063;
  9842. t['caarmenian'] = 0x056E;
  9843. t['cabengali'] = 0x099A;
  9844. t['cacute'] = 0x0107;
  9845. t['cadeva'] = 0x091A;
  9846. t['cagujarati'] = 0x0A9A;
  9847. t['cagurmukhi'] = 0x0A1A;
  9848. t['calsquare'] = 0x3388;
  9849. t['candrabindubengali'] = 0x0981;
  9850. t['candrabinducmb'] = 0x0310;
  9851. t['candrabindudeva'] = 0x0901;
  9852. t['candrabindugujarati'] = 0x0A81;
  9853. t['capslock'] = 0x21EA;
  9854. t['careof'] = 0x2105;
  9855. t['caron'] = 0x02C7;
  9856. t['caronbelowcmb'] = 0x032C;
  9857. t['caroncmb'] = 0x030C;
  9858. t['carriagereturn'] = 0x21B5;
  9859. t['cbopomofo'] = 0x3118;
  9860. t['ccaron'] = 0x010D;
  9861. t['ccedilla'] = 0x00E7;
  9862. t['ccedillaacute'] = 0x1E09;
  9863. t['ccircle'] = 0x24D2;
  9864. t['ccircumflex'] = 0x0109;
  9865. t['ccurl'] = 0x0255;
  9866. t['cdot'] = 0x010B;
  9867. t['cdotaccent'] = 0x010B;
  9868. t['cdsquare'] = 0x33C5;
  9869. t['cedilla'] = 0x00B8;
  9870. t['cedillacmb'] = 0x0327;
  9871. t['cent'] = 0x00A2;
  9872. t['centigrade'] = 0x2103;
  9873. t['centinferior'] = 0xF6DF;
  9874. t['centmonospace'] = 0xFFE0;
  9875. t['centoldstyle'] = 0xF7A2;
  9876. t['centsuperior'] = 0xF6E0;
  9877. t['chaarmenian'] = 0x0579;
  9878. t['chabengali'] = 0x099B;
  9879. t['chadeva'] = 0x091B;
  9880. t['chagujarati'] = 0x0A9B;
  9881. t['chagurmukhi'] = 0x0A1B;
  9882. t['chbopomofo'] = 0x3114;
  9883. t['cheabkhasiancyrillic'] = 0x04BD;
  9884. t['checkmark'] = 0x2713;
  9885. t['checyrillic'] = 0x0447;
  9886. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9887. t['chedescendercyrillic'] = 0x04B7;
  9888. t['chedieresiscyrillic'] = 0x04F5;
  9889. t['cheharmenian'] = 0x0573;
  9890. t['chekhakassiancyrillic'] = 0x04CC;
  9891. t['cheverticalstrokecyrillic'] = 0x04B9;
  9892. t['chi'] = 0x03C7;
  9893. t['chieuchacirclekorean'] = 0x3277;
  9894. t['chieuchaparenkorean'] = 0x3217;
  9895. t['chieuchcirclekorean'] = 0x3269;
  9896. t['chieuchkorean'] = 0x314A;
  9897. t['chieuchparenkorean'] = 0x3209;
  9898. t['chochangthai'] = 0x0E0A;
  9899. t['chochanthai'] = 0x0E08;
  9900. t['chochingthai'] = 0x0E09;
  9901. t['chochoethai'] = 0x0E0C;
  9902. t['chook'] = 0x0188;
  9903. t['cieucacirclekorean'] = 0x3276;
  9904. t['cieucaparenkorean'] = 0x3216;
  9905. t['cieuccirclekorean'] = 0x3268;
  9906. t['cieuckorean'] = 0x3148;
  9907. t['cieucparenkorean'] = 0x3208;
  9908. t['cieucuparenkorean'] = 0x321C;
  9909. t['circle'] = 0x25CB;
  9910. t['circlecopyrt'] = 0x00A9;
  9911. t['circlemultiply'] = 0x2297;
  9912. t['circleot'] = 0x2299;
  9913. t['circleplus'] = 0x2295;
  9914. t['circlepostalmark'] = 0x3036;
  9915. t['circlewithlefthalfblack'] = 0x25D0;
  9916. t['circlewithrighthalfblack'] = 0x25D1;
  9917. t['circumflex'] = 0x02C6;
  9918. t['circumflexbelowcmb'] = 0x032D;
  9919. t['circumflexcmb'] = 0x0302;
  9920. t['clear'] = 0x2327;
  9921. t['clickalveolar'] = 0x01C2;
  9922. t['clickdental'] = 0x01C0;
  9923. t['clicklateral'] = 0x01C1;
  9924. t['clickretroflex'] = 0x01C3;
  9925. t['club'] = 0x2663;
  9926. t['clubsuitblack'] = 0x2663;
  9927. t['clubsuitwhite'] = 0x2667;
  9928. t['cmcubedsquare'] = 0x33A4;
  9929. t['cmonospace'] = 0xFF43;
  9930. t['cmsquaredsquare'] = 0x33A0;
  9931. t['coarmenian'] = 0x0581;
  9932. t['colon'] = 0x003A;
  9933. t['colonmonetary'] = 0x20A1;
  9934. t['colonmonospace'] = 0xFF1A;
  9935. t['colonsign'] = 0x20A1;
  9936. t['colonsmall'] = 0xFE55;
  9937. t['colontriangularhalfmod'] = 0x02D1;
  9938. t['colontriangularmod'] = 0x02D0;
  9939. t['comma'] = 0x002C;
  9940. t['commaabovecmb'] = 0x0313;
  9941. t['commaaboverightcmb'] = 0x0315;
  9942. t['commaaccent'] = 0xF6C3;
  9943. t['commaarabic'] = 0x060C;
  9944. t['commaarmenian'] = 0x055D;
  9945. t['commainferior'] = 0xF6E1;
  9946. t['commamonospace'] = 0xFF0C;
  9947. t['commareversedabovecmb'] = 0x0314;
  9948. t['commareversedmod'] = 0x02BD;
  9949. t['commasmall'] = 0xFE50;
  9950. t['commasuperior'] = 0xF6E2;
  9951. t['commaturnedabovecmb'] = 0x0312;
  9952. t['commaturnedmod'] = 0x02BB;
  9953. t['compass'] = 0x263C;
  9954. t['congruent'] = 0x2245;
  9955. t['contourintegral'] = 0x222E;
  9956. t['control'] = 0x2303;
  9957. t['controlACK'] = 0x0006;
  9958. t['controlBEL'] = 0x0007;
  9959. t['controlBS'] = 0x0008;
  9960. t['controlCAN'] = 0x0018;
  9961. t['controlCR'] = 0x000D;
  9962. t['controlDC1'] = 0x0011;
  9963. t['controlDC2'] = 0x0012;
  9964. t['controlDC3'] = 0x0013;
  9965. t['controlDC4'] = 0x0014;
  9966. t['controlDEL'] = 0x007F;
  9967. t['controlDLE'] = 0x0010;
  9968. t['controlEM'] = 0x0019;
  9969. t['controlENQ'] = 0x0005;
  9970. t['controlEOT'] = 0x0004;
  9971. t['controlESC'] = 0x001B;
  9972. t['controlETB'] = 0x0017;
  9973. t['controlETX'] = 0x0003;
  9974. t['controlFF'] = 0x000C;
  9975. t['controlFS'] = 0x001C;
  9976. t['controlGS'] = 0x001D;
  9977. t['controlHT'] = 0x0009;
  9978. t['controlLF'] = 0x000A;
  9979. t['controlNAK'] = 0x0015;
  9980. t['controlRS'] = 0x001E;
  9981. t['controlSI'] = 0x000F;
  9982. t['controlSO'] = 0x000E;
  9983. t['controlSOT'] = 0x0002;
  9984. t['controlSTX'] = 0x0001;
  9985. t['controlSUB'] = 0x001A;
  9986. t['controlSYN'] = 0x0016;
  9987. t['controlUS'] = 0x001F;
  9988. t['controlVT'] = 0x000B;
  9989. t['copyright'] = 0x00A9;
  9990. t['copyrightsans'] = 0xF8E9;
  9991. t['copyrightserif'] = 0xF6D9;
  9992. t['cornerbracketleft'] = 0x300C;
  9993. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9994. t['cornerbracketleftvertical'] = 0xFE41;
  9995. t['cornerbracketright'] = 0x300D;
  9996. t['cornerbracketrighthalfwidth'] = 0xFF63;
  9997. t['cornerbracketrightvertical'] = 0xFE42;
  9998. t['corporationsquare'] = 0x337F;
  9999. t['cosquare'] = 0x33C7;
  10000. t['coverkgsquare'] = 0x33C6;
  10001. t['cparen'] = 0x249E;
  10002. t['cruzeiro'] = 0x20A2;
  10003. t['cstretched'] = 0x0297;
  10004. t['curlyand'] = 0x22CF;
  10005. t['curlyor'] = 0x22CE;
  10006. t['currency'] = 0x00A4;
  10007. t['cyrBreve'] = 0xF6D1;
  10008. t['cyrFlex'] = 0xF6D2;
  10009. t['cyrbreve'] = 0xF6D4;
  10010. t['cyrflex'] = 0xF6D5;
  10011. t['d'] = 0x0064;
  10012. t['daarmenian'] = 0x0564;
  10013. t['dabengali'] = 0x09A6;
  10014. t['dadarabic'] = 0x0636;
  10015. t['dadeva'] = 0x0926;
  10016. t['dadfinalarabic'] = 0xFEBE;
  10017. t['dadinitialarabic'] = 0xFEBF;
  10018. t['dadmedialarabic'] = 0xFEC0;
  10019. t['dagesh'] = 0x05BC;
  10020. t['dageshhebrew'] = 0x05BC;
  10021. t['dagger'] = 0x2020;
  10022. t['daggerdbl'] = 0x2021;
  10023. t['dagujarati'] = 0x0AA6;
  10024. t['dagurmukhi'] = 0x0A26;
  10025. t['dahiragana'] = 0x3060;
  10026. t['dakatakana'] = 0x30C0;
  10027. t['dalarabic'] = 0x062F;
  10028. t['dalet'] = 0x05D3;
  10029. t['daletdagesh'] = 0xFB33;
  10030. t['daletdageshhebrew'] = 0xFB33;
  10031. t['dalethebrew'] = 0x05D3;
  10032. t['dalfinalarabic'] = 0xFEAA;
  10033. t['dammaarabic'] = 0x064F;
  10034. t['dammalowarabic'] = 0x064F;
  10035. t['dammatanaltonearabic'] = 0x064C;
  10036. t['dammatanarabic'] = 0x064C;
  10037. t['danda'] = 0x0964;
  10038. t['dargahebrew'] = 0x05A7;
  10039. t['dargalefthebrew'] = 0x05A7;
  10040. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10041. t['dblGrave'] = 0xF6D3;
  10042. t['dblanglebracketleft'] = 0x300A;
  10043. t['dblanglebracketleftvertical'] = 0xFE3D;
  10044. t['dblanglebracketright'] = 0x300B;
  10045. t['dblanglebracketrightvertical'] = 0xFE3E;
  10046. t['dblarchinvertedbelowcmb'] = 0x032B;
  10047. t['dblarrowleft'] = 0x21D4;
  10048. t['dblarrowright'] = 0x21D2;
  10049. t['dbldanda'] = 0x0965;
  10050. t['dblgrave'] = 0xF6D6;
  10051. t['dblgravecmb'] = 0x030F;
  10052. t['dblintegral'] = 0x222C;
  10053. t['dbllowline'] = 0x2017;
  10054. t['dbllowlinecmb'] = 0x0333;
  10055. t['dbloverlinecmb'] = 0x033F;
  10056. t['dblprimemod'] = 0x02BA;
  10057. t['dblverticalbar'] = 0x2016;
  10058. t['dblverticallineabovecmb'] = 0x030E;
  10059. t['dbopomofo'] = 0x3109;
  10060. t['dbsquare'] = 0x33C8;
  10061. t['dcaron'] = 0x010F;
  10062. t['dcedilla'] = 0x1E11;
  10063. t['dcircle'] = 0x24D3;
  10064. t['dcircumflexbelow'] = 0x1E13;
  10065. t['dcroat'] = 0x0111;
  10066. t['ddabengali'] = 0x09A1;
  10067. t['ddadeva'] = 0x0921;
  10068. t['ddagujarati'] = 0x0AA1;
  10069. t['ddagurmukhi'] = 0x0A21;
  10070. t['ddalarabic'] = 0x0688;
  10071. t['ddalfinalarabic'] = 0xFB89;
  10072. t['dddhadeva'] = 0x095C;
  10073. t['ddhabengali'] = 0x09A2;
  10074. t['ddhadeva'] = 0x0922;
  10075. t['ddhagujarati'] = 0x0AA2;
  10076. t['ddhagurmukhi'] = 0x0A22;
  10077. t['ddotaccent'] = 0x1E0B;
  10078. t['ddotbelow'] = 0x1E0D;
  10079. t['decimalseparatorarabic'] = 0x066B;
  10080. t['decimalseparatorpersian'] = 0x066B;
  10081. t['decyrillic'] = 0x0434;
  10082. t['degree'] = 0x00B0;
  10083. t['dehihebrew'] = 0x05AD;
  10084. t['dehiragana'] = 0x3067;
  10085. t['deicoptic'] = 0x03EF;
  10086. t['dekatakana'] = 0x30C7;
  10087. t['deleteleft'] = 0x232B;
  10088. t['deleteright'] = 0x2326;
  10089. t['delta'] = 0x03B4;
  10090. t['deltaturned'] = 0x018D;
  10091. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10092. t['dezh'] = 0x02A4;
  10093. t['dhabengali'] = 0x09A7;
  10094. t['dhadeva'] = 0x0927;
  10095. t['dhagujarati'] = 0x0AA7;
  10096. t['dhagurmukhi'] = 0x0A27;
  10097. t['dhook'] = 0x0257;
  10098. t['dialytikatonos'] = 0x0385;
  10099. t['dialytikatonoscmb'] = 0x0344;
  10100. t['diamond'] = 0x2666;
  10101. t['diamondsuitwhite'] = 0x2662;
  10102. t['dieresis'] = 0x00A8;
  10103. t['dieresisacute'] = 0xF6D7;
  10104. t['dieresisbelowcmb'] = 0x0324;
  10105. t['dieresiscmb'] = 0x0308;
  10106. t['dieresisgrave'] = 0xF6D8;
  10107. t['dieresistonos'] = 0x0385;
  10108. t['dihiragana'] = 0x3062;
  10109. t['dikatakana'] = 0x30C2;
  10110. t['dittomark'] = 0x3003;
  10111. t['divide'] = 0x00F7;
  10112. t['divides'] = 0x2223;
  10113. t['divisionslash'] = 0x2215;
  10114. t['djecyrillic'] = 0x0452;
  10115. t['dkshade'] = 0x2593;
  10116. t['dlinebelow'] = 0x1E0F;
  10117. t['dlsquare'] = 0x3397;
  10118. t['dmacron'] = 0x0111;
  10119. t['dmonospace'] = 0xFF44;
  10120. t['dnblock'] = 0x2584;
  10121. t['dochadathai'] = 0x0E0E;
  10122. t['dodekthai'] = 0x0E14;
  10123. t['dohiragana'] = 0x3069;
  10124. t['dokatakana'] = 0x30C9;
  10125. t['dollar'] = 0x0024;
  10126. t['dollarinferior'] = 0xF6E3;
  10127. t['dollarmonospace'] = 0xFF04;
  10128. t['dollaroldstyle'] = 0xF724;
  10129. t['dollarsmall'] = 0xFE69;
  10130. t['dollarsuperior'] = 0xF6E4;
  10131. t['dong'] = 0x20AB;
  10132. t['dorusquare'] = 0x3326;
  10133. t['dotaccent'] = 0x02D9;
  10134. t['dotaccentcmb'] = 0x0307;
  10135. t['dotbelowcmb'] = 0x0323;
  10136. t['dotbelowcomb'] = 0x0323;
  10137. t['dotkatakana'] = 0x30FB;
  10138. t['dotlessi'] = 0x0131;
  10139. t['dotlessj'] = 0xF6BE;
  10140. t['dotlessjstrokehook'] = 0x0284;
  10141. t['dotmath'] = 0x22C5;
  10142. t['dottedcircle'] = 0x25CC;
  10143. t['doubleyodpatah'] = 0xFB1F;
  10144. t['doubleyodpatahhebrew'] = 0xFB1F;
  10145. t['downtackbelowcmb'] = 0x031E;
  10146. t['downtackmod'] = 0x02D5;
  10147. t['dparen'] = 0x249F;
  10148. t['dsuperior'] = 0xF6EB;
  10149. t['dtail'] = 0x0256;
  10150. t['dtopbar'] = 0x018C;
  10151. t['duhiragana'] = 0x3065;
  10152. t['dukatakana'] = 0x30C5;
  10153. t['dz'] = 0x01F3;
  10154. t['dzaltone'] = 0x02A3;
  10155. t['dzcaron'] = 0x01C6;
  10156. t['dzcurl'] = 0x02A5;
  10157. t['dzeabkhasiancyrillic'] = 0x04E1;
  10158. t['dzecyrillic'] = 0x0455;
  10159. t['dzhecyrillic'] = 0x045F;
  10160. t['e'] = 0x0065;
  10161. t['eacute'] = 0x00E9;
  10162. t['earth'] = 0x2641;
  10163. t['ebengali'] = 0x098F;
  10164. t['ebopomofo'] = 0x311C;
  10165. t['ebreve'] = 0x0115;
  10166. t['ecandradeva'] = 0x090D;
  10167. t['ecandragujarati'] = 0x0A8D;
  10168. t['ecandravowelsigndeva'] = 0x0945;
  10169. t['ecandravowelsigngujarati'] = 0x0AC5;
  10170. t['ecaron'] = 0x011B;
  10171. t['ecedillabreve'] = 0x1E1D;
  10172. t['echarmenian'] = 0x0565;
  10173. t['echyiwnarmenian'] = 0x0587;
  10174. t['ecircle'] = 0x24D4;
  10175. t['ecircumflex'] = 0x00EA;
  10176. t['ecircumflexacute'] = 0x1EBF;
  10177. t['ecircumflexbelow'] = 0x1E19;
  10178. t['ecircumflexdotbelow'] = 0x1EC7;
  10179. t['ecircumflexgrave'] = 0x1EC1;
  10180. t['ecircumflexhookabove'] = 0x1EC3;
  10181. t['ecircumflextilde'] = 0x1EC5;
  10182. t['ecyrillic'] = 0x0454;
  10183. t['edblgrave'] = 0x0205;
  10184. t['edeva'] = 0x090F;
  10185. t['edieresis'] = 0x00EB;
  10186. t['edot'] = 0x0117;
  10187. t['edotaccent'] = 0x0117;
  10188. t['edotbelow'] = 0x1EB9;
  10189. t['eegurmukhi'] = 0x0A0F;
  10190. t['eematragurmukhi'] = 0x0A47;
  10191. t['efcyrillic'] = 0x0444;
  10192. t['egrave'] = 0x00E8;
  10193. t['egujarati'] = 0x0A8F;
  10194. t['eharmenian'] = 0x0567;
  10195. t['ehbopomofo'] = 0x311D;
  10196. t['ehiragana'] = 0x3048;
  10197. t['ehookabove'] = 0x1EBB;
  10198. t['eibopomofo'] = 0x311F;
  10199. t['eight'] = 0x0038;
  10200. t['eightarabic'] = 0x0668;
  10201. t['eightbengali'] = 0x09EE;
  10202. t['eightcircle'] = 0x2467;
  10203. t['eightcircleinversesansserif'] = 0x2791;
  10204. t['eightdeva'] = 0x096E;
  10205. t['eighteencircle'] = 0x2471;
  10206. t['eighteenparen'] = 0x2485;
  10207. t['eighteenperiod'] = 0x2499;
  10208. t['eightgujarati'] = 0x0AEE;
  10209. t['eightgurmukhi'] = 0x0A6E;
  10210. t['eighthackarabic'] = 0x0668;
  10211. t['eighthangzhou'] = 0x3028;
  10212. t['eighthnotebeamed'] = 0x266B;
  10213. t['eightideographicparen'] = 0x3227;
  10214. t['eightinferior'] = 0x2088;
  10215. t['eightmonospace'] = 0xFF18;
  10216. t['eightoldstyle'] = 0xF738;
  10217. t['eightparen'] = 0x247B;
  10218. t['eightperiod'] = 0x248F;
  10219. t['eightpersian'] = 0x06F8;
  10220. t['eightroman'] = 0x2177;
  10221. t['eightsuperior'] = 0x2078;
  10222. t['eightthai'] = 0x0E58;
  10223. t['einvertedbreve'] = 0x0207;
  10224. t['eiotifiedcyrillic'] = 0x0465;
  10225. t['ekatakana'] = 0x30A8;
  10226. t['ekatakanahalfwidth'] = 0xFF74;
  10227. t['ekonkargurmukhi'] = 0x0A74;
  10228. t['ekorean'] = 0x3154;
  10229. t['elcyrillic'] = 0x043B;
  10230. t['element'] = 0x2208;
  10231. t['elevencircle'] = 0x246A;
  10232. t['elevenparen'] = 0x247E;
  10233. t['elevenperiod'] = 0x2492;
  10234. t['elevenroman'] = 0x217A;
  10235. t['ellipsis'] = 0x2026;
  10236. t['ellipsisvertical'] = 0x22EE;
  10237. t['emacron'] = 0x0113;
  10238. t['emacronacute'] = 0x1E17;
  10239. t['emacrongrave'] = 0x1E15;
  10240. t['emcyrillic'] = 0x043C;
  10241. t['emdash'] = 0x2014;
  10242. t['emdashvertical'] = 0xFE31;
  10243. t['emonospace'] = 0xFF45;
  10244. t['emphasismarkarmenian'] = 0x055B;
  10245. t['emptyset'] = 0x2205;
  10246. t['enbopomofo'] = 0x3123;
  10247. t['encyrillic'] = 0x043D;
  10248. t['endash'] = 0x2013;
  10249. t['endashvertical'] = 0xFE32;
  10250. t['endescendercyrillic'] = 0x04A3;
  10251. t['eng'] = 0x014B;
  10252. t['engbopomofo'] = 0x3125;
  10253. t['enghecyrillic'] = 0x04A5;
  10254. t['enhookcyrillic'] = 0x04C8;
  10255. t['enspace'] = 0x2002;
  10256. t['eogonek'] = 0x0119;
  10257. t['eokorean'] = 0x3153;
  10258. t['eopen'] = 0x025B;
  10259. t['eopenclosed'] = 0x029A;
  10260. t['eopenreversed'] = 0x025C;
  10261. t['eopenreversedclosed'] = 0x025E;
  10262. t['eopenreversedhook'] = 0x025D;
  10263. t['eparen'] = 0x24A0;
  10264. t['epsilon'] = 0x03B5;
  10265. t['epsilontonos'] = 0x03AD;
  10266. t['equal'] = 0x003D;
  10267. t['equalmonospace'] = 0xFF1D;
  10268. t['equalsmall'] = 0xFE66;
  10269. t['equalsuperior'] = 0x207C;
  10270. t['equivalence'] = 0x2261;
  10271. t['erbopomofo'] = 0x3126;
  10272. t['ercyrillic'] = 0x0440;
  10273. t['ereversed'] = 0x0258;
  10274. t['ereversedcyrillic'] = 0x044D;
  10275. t['escyrillic'] = 0x0441;
  10276. t['esdescendercyrillic'] = 0x04AB;
  10277. t['esh'] = 0x0283;
  10278. t['eshcurl'] = 0x0286;
  10279. t['eshortdeva'] = 0x090E;
  10280. t['eshortvowelsigndeva'] = 0x0946;
  10281. t['eshreversedloop'] = 0x01AA;
  10282. t['eshsquatreversed'] = 0x0285;
  10283. t['esmallhiragana'] = 0x3047;
  10284. t['esmallkatakana'] = 0x30A7;
  10285. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10286. t['estimated'] = 0x212E;
  10287. t['esuperior'] = 0xF6EC;
  10288. t['eta'] = 0x03B7;
  10289. t['etarmenian'] = 0x0568;
  10290. t['etatonos'] = 0x03AE;
  10291. t['eth'] = 0x00F0;
  10292. t['etilde'] = 0x1EBD;
  10293. t['etildebelow'] = 0x1E1B;
  10294. t['etnahtafoukhhebrew'] = 0x0591;
  10295. t['etnahtafoukhlefthebrew'] = 0x0591;
  10296. t['etnahtahebrew'] = 0x0591;
  10297. t['etnahtalefthebrew'] = 0x0591;
  10298. t['eturned'] = 0x01DD;
  10299. t['eukorean'] = 0x3161;
  10300. t['euro'] = 0x20AC;
  10301. t['evowelsignbengali'] = 0x09C7;
  10302. t['evowelsigndeva'] = 0x0947;
  10303. t['evowelsigngujarati'] = 0x0AC7;
  10304. t['exclam'] = 0x0021;
  10305. t['exclamarmenian'] = 0x055C;
  10306. t['exclamdbl'] = 0x203C;
  10307. t['exclamdown'] = 0x00A1;
  10308. t['exclamdownsmall'] = 0xF7A1;
  10309. t['exclammonospace'] = 0xFF01;
  10310. t['exclamsmall'] = 0xF721;
  10311. t['existential'] = 0x2203;
  10312. t['ezh'] = 0x0292;
  10313. t['ezhcaron'] = 0x01EF;
  10314. t['ezhcurl'] = 0x0293;
  10315. t['ezhreversed'] = 0x01B9;
  10316. t['ezhtail'] = 0x01BA;
  10317. t['f'] = 0x0066;
  10318. t['fadeva'] = 0x095E;
  10319. t['fagurmukhi'] = 0x0A5E;
  10320. t['fahrenheit'] = 0x2109;
  10321. t['fathaarabic'] = 0x064E;
  10322. t['fathalowarabic'] = 0x064E;
  10323. t['fathatanarabic'] = 0x064B;
  10324. t['fbopomofo'] = 0x3108;
  10325. t['fcircle'] = 0x24D5;
  10326. t['fdotaccent'] = 0x1E1F;
  10327. t['feharabic'] = 0x0641;
  10328. t['feharmenian'] = 0x0586;
  10329. t['fehfinalarabic'] = 0xFED2;
  10330. t['fehinitialarabic'] = 0xFED3;
  10331. t['fehmedialarabic'] = 0xFED4;
  10332. t['feicoptic'] = 0x03E5;
  10333. t['female'] = 0x2640;
  10334. t['ff'] = 0xFB00;
  10335. t['ffi'] = 0xFB03;
  10336. t['ffl'] = 0xFB04;
  10337. t['fi'] = 0xFB01;
  10338. t['fifteencircle'] = 0x246E;
  10339. t['fifteenparen'] = 0x2482;
  10340. t['fifteenperiod'] = 0x2496;
  10341. t['figuredash'] = 0x2012;
  10342. t['filledbox'] = 0x25A0;
  10343. t['filledrect'] = 0x25AC;
  10344. t['finalkaf'] = 0x05DA;
  10345. t['finalkafdagesh'] = 0xFB3A;
  10346. t['finalkafdageshhebrew'] = 0xFB3A;
  10347. t['finalkafhebrew'] = 0x05DA;
  10348. t['finalmem'] = 0x05DD;
  10349. t['finalmemhebrew'] = 0x05DD;
  10350. t['finalnun'] = 0x05DF;
  10351. t['finalnunhebrew'] = 0x05DF;
  10352. t['finalpe'] = 0x05E3;
  10353. t['finalpehebrew'] = 0x05E3;
  10354. t['finaltsadi'] = 0x05E5;
  10355. t['finaltsadihebrew'] = 0x05E5;
  10356. t['firsttonechinese'] = 0x02C9;
  10357. t['fisheye'] = 0x25C9;
  10358. t['fitacyrillic'] = 0x0473;
  10359. t['five'] = 0x0035;
  10360. t['fivearabic'] = 0x0665;
  10361. t['fivebengali'] = 0x09EB;
  10362. t['fivecircle'] = 0x2464;
  10363. t['fivecircleinversesansserif'] = 0x278E;
  10364. t['fivedeva'] = 0x096B;
  10365. t['fiveeighths'] = 0x215D;
  10366. t['fivegujarati'] = 0x0AEB;
  10367. t['fivegurmukhi'] = 0x0A6B;
  10368. t['fivehackarabic'] = 0x0665;
  10369. t['fivehangzhou'] = 0x3025;
  10370. t['fiveideographicparen'] = 0x3224;
  10371. t['fiveinferior'] = 0x2085;
  10372. t['fivemonospace'] = 0xFF15;
  10373. t['fiveoldstyle'] = 0xF735;
  10374. t['fiveparen'] = 0x2478;
  10375. t['fiveperiod'] = 0x248C;
  10376. t['fivepersian'] = 0x06F5;
  10377. t['fiveroman'] = 0x2174;
  10378. t['fivesuperior'] = 0x2075;
  10379. t['fivethai'] = 0x0E55;
  10380. t['fl'] = 0xFB02;
  10381. t['florin'] = 0x0192;
  10382. t['fmonospace'] = 0xFF46;
  10383. t['fmsquare'] = 0x3399;
  10384. t['fofanthai'] = 0x0E1F;
  10385. t['fofathai'] = 0x0E1D;
  10386. t['fongmanthai'] = 0x0E4F;
  10387. t['forall'] = 0x2200;
  10388. t['four'] = 0x0034;
  10389. t['fourarabic'] = 0x0664;
  10390. t['fourbengali'] = 0x09EA;
  10391. t['fourcircle'] = 0x2463;
  10392. t['fourcircleinversesansserif'] = 0x278D;
  10393. t['fourdeva'] = 0x096A;
  10394. t['fourgujarati'] = 0x0AEA;
  10395. t['fourgurmukhi'] = 0x0A6A;
  10396. t['fourhackarabic'] = 0x0664;
  10397. t['fourhangzhou'] = 0x3024;
  10398. t['fourideographicparen'] = 0x3223;
  10399. t['fourinferior'] = 0x2084;
  10400. t['fourmonospace'] = 0xFF14;
  10401. t['fournumeratorbengali'] = 0x09F7;
  10402. t['fouroldstyle'] = 0xF734;
  10403. t['fourparen'] = 0x2477;
  10404. t['fourperiod'] = 0x248B;
  10405. t['fourpersian'] = 0x06F4;
  10406. t['fourroman'] = 0x2173;
  10407. t['foursuperior'] = 0x2074;
  10408. t['fourteencircle'] = 0x246D;
  10409. t['fourteenparen'] = 0x2481;
  10410. t['fourteenperiod'] = 0x2495;
  10411. t['fourthai'] = 0x0E54;
  10412. t['fourthtonechinese'] = 0x02CB;
  10413. t['fparen'] = 0x24A1;
  10414. t['fraction'] = 0x2044;
  10415. t['franc'] = 0x20A3;
  10416. t['g'] = 0x0067;
  10417. t['gabengali'] = 0x0997;
  10418. t['gacute'] = 0x01F5;
  10419. t['gadeva'] = 0x0917;
  10420. t['gafarabic'] = 0x06AF;
  10421. t['gaffinalarabic'] = 0xFB93;
  10422. t['gafinitialarabic'] = 0xFB94;
  10423. t['gafmedialarabic'] = 0xFB95;
  10424. t['gagujarati'] = 0x0A97;
  10425. t['gagurmukhi'] = 0x0A17;
  10426. t['gahiragana'] = 0x304C;
  10427. t['gakatakana'] = 0x30AC;
  10428. t['gamma'] = 0x03B3;
  10429. t['gammalatinsmall'] = 0x0263;
  10430. t['gammasuperior'] = 0x02E0;
  10431. t['gangiacoptic'] = 0x03EB;
  10432. t['gbopomofo'] = 0x310D;
  10433. t['gbreve'] = 0x011F;
  10434. t['gcaron'] = 0x01E7;
  10435. t['gcedilla'] = 0x0123;
  10436. t['gcircle'] = 0x24D6;
  10437. t['gcircumflex'] = 0x011D;
  10438. t['gcommaaccent'] = 0x0123;
  10439. t['gdot'] = 0x0121;
  10440. t['gdotaccent'] = 0x0121;
  10441. t['gecyrillic'] = 0x0433;
  10442. t['gehiragana'] = 0x3052;
  10443. t['gekatakana'] = 0x30B2;
  10444. t['geometricallyequal'] = 0x2251;
  10445. t['gereshaccenthebrew'] = 0x059C;
  10446. t['gereshhebrew'] = 0x05F3;
  10447. t['gereshmuqdamhebrew'] = 0x059D;
  10448. t['germandbls'] = 0x00DF;
  10449. t['gershayimaccenthebrew'] = 0x059E;
  10450. t['gershayimhebrew'] = 0x05F4;
  10451. t['getamark'] = 0x3013;
  10452. t['ghabengali'] = 0x0998;
  10453. t['ghadarmenian'] = 0x0572;
  10454. t['ghadeva'] = 0x0918;
  10455. t['ghagujarati'] = 0x0A98;
  10456. t['ghagurmukhi'] = 0x0A18;
  10457. t['ghainarabic'] = 0x063A;
  10458. t['ghainfinalarabic'] = 0xFECE;
  10459. t['ghaininitialarabic'] = 0xFECF;
  10460. t['ghainmedialarabic'] = 0xFED0;
  10461. t['ghemiddlehookcyrillic'] = 0x0495;
  10462. t['ghestrokecyrillic'] = 0x0493;
  10463. t['gheupturncyrillic'] = 0x0491;
  10464. t['ghhadeva'] = 0x095A;
  10465. t['ghhagurmukhi'] = 0x0A5A;
  10466. t['ghook'] = 0x0260;
  10467. t['ghzsquare'] = 0x3393;
  10468. t['gihiragana'] = 0x304E;
  10469. t['gikatakana'] = 0x30AE;
  10470. t['gimarmenian'] = 0x0563;
  10471. t['gimel'] = 0x05D2;
  10472. t['gimeldagesh'] = 0xFB32;
  10473. t['gimeldageshhebrew'] = 0xFB32;
  10474. t['gimelhebrew'] = 0x05D2;
  10475. t['gjecyrillic'] = 0x0453;
  10476. t['glottalinvertedstroke'] = 0x01BE;
  10477. t['glottalstop'] = 0x0294;
  10478. t['glottalstopinverted'] = 0x0296;
  10479. t['glottalstopmod'] = 0x02C0;
  10480. t['glottalstopreversed'] = 0x0295;
  10481. t['glottalstopreversedmod'] = 0x02C1;
  10482. t['glottalstopreversedsuperior'] = 0x02E4;
  10483. t['glottalstopstroke'] = 0x02A1;
  10484. t['glottalstopstrokereversed'] = 0x02A2;
  10485. t['gmacron'] = 0x1E21;
  10486. t['gmonospace'] = 0xFF47;
  10487. t['gohiragana'] = 0x3054;
  10488. t['gokatakana'] = 0x30B4;
  10489. t['gparen'] = 0x24A2;
  10490. t['gpasquare'] = 0x33AC;
  10491. t['gradient'] = 0x2207;
  10492. t['grave'] = 0x0060;
  10493. t['gravebelowcmb'] = 0x0316;
  10494. t['gravecmb'] = 0x0300;
  10495. t['gravecomb'] = 0x0300;
  10496. t['gravedeva'] = 0x0953;
  10497. t['gravelowmod'] = 0x02CE;
  10498. t['gravemonospace'] = 0xFF40;
  10499. t['gravetonecmb'] = 0x0340;
  10500. t['greater'] = 0x003E;
  10501. t['greaterequal'] = 0x2265;
  10502. t['greaterequalorless'] = 0x22DB;
  10503. t['greatermonospace'] = 0xFF1E;
  10504. t['greaterorequivalent'] = 0x2273;
  10505. t['greaterorless'] = 0x2277;
  10506. t['greateroverequal'] = 0x2267;
  10507. t['greatersmall'] = 0xFE65;
  10508. t['gscript'] = 0x0261;
  10509. t['gstroke'] = 0x01E5;
  10510. t['guhiragana'] = 0x3050;
  10511. t['guillemotleft'] = 0x00AB;
  10512. t['guillemotright'] = 0x00BB;
  10513. t['guilsinglleft'] = 0x2039;
  10514. t['guilsinglright'] = 0x203A;
  10515. t['gukatakana'] = 0x30B0;
  10516. t['guramusquare'] = 0x3318;
  10517. t['gysquare'] = 0x33C9;
  10518. t['h'] = 0x0068;
  10519. t['haabkhasiancyrillic'] = 0x04A9;
  10520. t['haaltonearabic'] = 0x06C1;
  10521. t['habengali'] = 0x09B9;
  10522. t['hadescendercyrillic'] = 0x04B3;
  10523. t['hadeva'] = 0x0939;
  10524. t['hagujarati'] = 0x0AB9;
  10525. t['hagurmukhi'] = 0x0A39;
  10526. t['haharabic'] = 0x062D;
  10527. t['hahfinalarabic'] = 0xFEA2;
  10528. t['hahinitialarabic'] = 0xFEA3;
  10529. t['hahiragana'] = 0x306F;
  10530. t['hahmedialarabic'] = 0xFEA4;
  10531. t['haitusquare'] = 0x332A;
  10532. t['hakatakana'] = 0x30CF;
  10533. t['hakatakanahalfwidth'] = 0xFF8A;
  10534. t['halantgurmukhi'] = 0x0A4D;
  10535. t['hamzaarabic'] = 0x0621;
  10536. t['hamzalowarabic'] = 0x0621;
  10537. t['hangulfiller'] = 0x3164;
  10538. t['hardsigncyrillic'] = 0x044A;
  10539. t['harpoonleftbarbup'] = 0x21BC;
  10540. t['harpoonrightbarbup'] = 0x21C0;
  10541. t['hasquare'] = 0x33CA;
  10542. t['hatafpatah'] = 0x05B2;
  10543. t['hatafpatah16'] = 0x05B2;
  10544. t['hatafpatah23'] = 0x05B2;
  10545. t['hatafpatah2f'] = 0x05B2;
  10546. t['hatafpatahhebrew'] = 0x05B2;
  10547. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10548. t['hatafpatahquarterhebrew'] = 0x05B2;
  10549. t['hatafpatahwidehebrew'] = 0x05B2;
  10550. t['hatafqamats'] = 0x05B3;
  10551. t['hatafqamats1b'] = 0x05B3;
  10552. t['hatafqamats28'] = 0x05B3;
  10553. t['hatafqamats34'] = 0x05B3;
  10554. t['hatafqamatshebrew'] = 0x05B3;
  10555. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10556. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10557. t['hatafqamatswidehebrew'] = 0x05B3;
  10558. t['hatafsegol'] = 0x05B1;
  10559. t['hatafsegol17'] = 0x05B1;
  10560. t['hatafsegol24'] = 0x05B1;
  10561. t['hatafsegol30'] = 0x05B1;
  10562. t['hatafsegolhebrew'] = 0x05B1;
  10563. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10564. t['hatafsegolquarterhebrew'] = 0x05B1;
  10565. t['hatafsegolwidehebrew'] = 0x05B1;
  10566. t['hbar'] = 0x0127;
  10567. t['hbopomofo'] = 0x310F;
  10568. t['hbrevebelow'] = 0x1E2B;
  10569. t['hcedilla'] = 0x1E29;
  10570. t['hcircle'] = 0x24D7;
  10571. t['hcircumflex'] = 0x0125;
  10572. t['hdieresis'] = 0x1E27;
  10573. t['hdotaccent'] = 0x1E23;
  10574. t['hdotbelow'] = 0x1E25;
  10575. t['he'] = 0x05D4;
  10576. t['heart'] = 0x2665;
  10577. t['heartsuitblack'] = 0x2665;
  10578. t['heartsuitwhite'] = 0x2661;
  10579. t['hedagesh'] = 0xFB34;
  10580. t['hedageshhebrew'] = 0xFB34;
  10581. t['hehaltonearabic'] = 0x06C1;
  10582. t['heharabic'] = 0x0647;
  10583. t['hehebrew'] = 0x05D4;
  10584. t['hehfinalaltonearabic'] = 0xFBA7;
  10585. t['hehfinalalttwoarabic'] = 0xFEEA;
  10586. t['hehfinalarabic'] = 0xFEEA;
  10587. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10588. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10589. t['hehinitialaltonearabic'] = 0xFBA8;
  10590. t['hehinitialarabic'] = 0xFEEB;
  10591. t['hehiragana'] = 0x3078;
  10592. t['hehmedialaltonearabic'] = 0xFBA9;
  10593. t['hehmedialarabic'] = 0xFEEC;
  10594. t['heiseierasquare'] = 0x337B;
  10595. t['hekatakana'] = 0x30D8;
  10596. t['hekatakanahalfwidth'] = 0xFF8D;
  10597. t['hekutaarusquare'] = 0x3336;
  10598. t['henghook'] = 0x0267;
  10599. t['herutusquare'] = 0x3339;
  10600. t['het'] = 0x05D7;
  10601. t['hethebrew'] = 0x05D7;
  10602. t['hhook'] = 0x0266;
  10603. t['hhooksuperior'] = 0x02B1;
  10604. t['hieuhacirclekorean'] = 0x327B;
  10605. t['hieuhaparenkorean'] = 0x321B;
  10606. t['hieuhcirclekorean'] = 0x326D;
  10607. t['hieuhkorean'] = 0x314E;
  10608. t['hieuhparenkorean'] = 0x320D;
  10609. t['hihiragana'] = 0x3072;
  10610. t['hikatakana'] = 0x30D2;
  10611. t['hikatakanahalfwidth'] = 0xFF8B;
  10612. t['hiriq'] = 0x05B4;
  10613. t['hiriq14'] = 0x05B4;
  10614. t['hiriq21'] = 0x05B4;
  10615. t['hiriq2d'] = 0x05B4;
  10616. t['hiriqhebrew'] = 0x05B4;
  10617. t['hiriqnarrowhebrew'] = 0x05B4;
  10618. t['hiriqquarterhebrew'] = 0x05B4;
  10619. t['hiriqwidehebrew'] = 0x05B4;
  10620. t['hlinebelow'] = 0x1E96;
  10621. t['hmonospace'] = 0xFF48;
  10622. t['hoarmenian'] = 0x0570;
  10623. t['hohipthai'] = 0x0E2B;
  10624. t['hohiragana'] = 0x307B;
  10625. t['hokatakana'] = 0x30DB;
  10626. t['hokatakanahalfwidth'] = 0xFF8E;
  10627. t['holam'] = 0x05B9;
  10628. t['holam19'] = 0x05B9;
  10629. t['holam26'] = 0x05B9;
  10630. t['holam32'] = 0x05B9;
  10631. t['holamhebrew'] = 0x05B9;
  10632. t['holamnarrowhebrew'] = 0x05B9;
  10633. t['holamquarterhebrew'] = 0x05B9;
  10634. t['holamwidehebrew'] = 0x05B9;
  10635. t['honokhukthai'] = 0x0E2E;
  10636. t['hookabovecomb'] = 0x0309;
  10637. t['hookcmb'] = 0x0309;
  10638. t['hookpalatalizedbelowcmb'] = 0x0321;
  10639. t['hookretroflexbelowcmb'] = 0x0322;
  10640. t['hoonsquare'] = 0x3342;
  10641. t['horicoptic'] = 0x03E9;
  10642. t['horizontalbar'] = 0x2015;
  10643. t['horncmb'] = 0x031B;
  10644. t['hotsprings'] = 0x2668;
  10645. t['house'] = 0x2302;
  10646. t['hparen'] = 0x24A3;
  10647. t['hsuperior'] = 0x02B0;
  10648. t['hturned'] = 0x0265;
  10649. t['huhiragana'] = 0x3075;
  10650. t['huiitosquare'] = 0x3333;
  10651. t['hukatakana'] = 0x30D5;
  10652. t['hukatakanahalfwidth'] = 0xFF8C;
  10653. t['hungarumlaut'] = 0x02DD;
  10654. t['hungarumlautcmb'] = 0x030B;
  10655. t['hv'] = 0x0195;
  10656. t['hyphen'] = 0x002D;
  10657. t['hypheninferior'] = 0xF6E5;
  10658. t['hyphenmonospace'] = 0xFF0D;
  10659. t['hyphensmall'] = 0xFE63;
  10660. t['hyphensuperior'] = 0xF6E6;
  10661. t['hyphentwo'] = 0x2010;
  10662. t['i'] = 0x0069;
  10663. t['iacute'] = 0x00ED;
  10664. t['iacyrillic'] = 0x044F;
  10665. t['ibengali'] = 0x0987;
  10666. t['ibopomofo'] = 0x3127;
  10667. t['ibreve'] = 0x012D;
  10668. t['icaron'] = 0x01D0;
  10669. t['icircle'] = 0x24D8;
  10670. t['icircumflex'] = 0x00EE;
  10671. t['icyrillic'] = 0x0456;
  10672. t['idblgrave'] = 0x0209;
  10673. t['ideographearthcircle'] = 0x328F;
  10674. t['ideographfirecircle'] = 0x328B;
  10675. t['ideographicallianceparen'] = 0x323F;
  10676. t['ideographiccallparen'] = 0x323A;
  10677. t['ideographiccentrecircle'] = 0x32A5;
  10678. t['ideographicclose'] = 0x3006;
  10679. t['ideographiccomma'] = 0x3001;
  10680. t['ideographiccommaleft'] = 0xFF64;
  10681. t['ideographiccongratulationparen'] = 0x3237;
  10682. t['ideographiccorrectcircle'] = 0x32A3;
  10683. t['ideographicearthparen'] = 0x322F;
  10684. t['ideographicenterpriseparen'] = 0x323D;
  10685. t['ideographicexcellentcircle'] = 0x329D;
  10686. t['ideographicfestivalparen'] = 0x3240;
  10687. t['ideographicfinancialcircle'] = 0x3296;
  10688. t['ideographicfinancialparen'] = 0x3236;
  10689. t['ideographicfireparen'] = 0x322B;
  10690. t['ideographichaveparen'] = 0x3232;
  10691. t['ideographichighcircle'] = 0x32A4;
  10692. t['ideographiciterationmark'] = 0x3005;
  10693. t['ideographiclaborcircle'] = 0x3298;
  10694. t['ideographiclaborparen'] = 0x3238;
  10695. t['ideographicleftcircle'] = 0x32A7;
  10696. t['ideographiclowcircle'] = 0x32A6;
  10697. t['ideographicmedicinecircle'] = 0x32A9;
  10698. t['ideographicmetalparen'] = 0x322E;
  10699. t['ideographicmoonparen'] = 0x322A;
  10700. t['ideographicnameparen'] = 0x3234;
  10701. t['ideographicperiod'] = 0x3002;
  10702. t['ideographicprintcircle'] = 0x329E;
  10703. t['ideographicreachparen'] = 0x3243;
  10704. t['ideographicrepresentparen'] = 0x3239;
  10705. t['ideographicresourceparen'] = 0x323E;
  10706. t['ideographicrightcircle'] = 0x32A8;
  10707. t['ideographicsecretcircle'] = 0x3299;
  10708. t['ideographicselfparen'] = 0x3242;
  10709. t['ideographicsocietyparen'] = 0x3233;
  10710. t['ideographicspace'] = 0x3000;
  10711. t['ideographicspecialparen'] = 0x3235;
  10712. t['ideographicstockparen'] = 0x3231;
  10713. t['ideographicstudyparen'] = 0x323B;
  10714. t['ideographicsunparen'] = 0x3230;
  10715. t['ideographicsuperviseparen'] = 0x323C;
  10716. t['ideographicwaterparen'] = 0x322C;
  10717. t['ideographicwoodparen'] = 0x322D;
  10718. t['ideographiczero'] = 0x3007;
  10719. t['ideographmetalcircle'] = 0x328E;
  10720. t['ideographmooncircle'] = 0x328A;
  10721. t['ideographnamecircle'] = 0x3294;
  10722. t['ideographsuncircle'] = 0x3290;
  10723. t['ideographwatercircle'] = 0x328C;
  10724. t['ideographwoodcircle'] = 0x328D;
  10725. t['ideva'] = 0x0907;
  10726. t['idieresis'] = 0x00EF;
  10727. t['idieresisacute'] = 0x1E2F;
  10728. t['idieresiscyrillic'] = 0x04E5;
  10729. t['idotbelow'] = 0x1ECB;
  10730. t['iebrevecyrillic'] = 0x04D7;
  10731. t['iecyrillic'] = 0x0435;
  10732. t['ieungacirclekorean'] = 0x3275;
  10733. t['ieungaparenkorean'] = 0x3215;
  10734. t['ieungcirclekorean'] = 0x3267;
  10735. t['ieungkorean'] = 0x3147;
  10736. t['ieungparenkorean'] = 0x3207;
  10737. t['igrave'] = 0x00EC;
  10738. t['igujarati'] = 0x0A87;
  10739. t['igurmukhi'] = 0x0A07;
  10740. t['ihiragana'] = 0x3044;
  10741. t['ihookabove'] = 0x1EC9;
  10742. t['iibengali'] = 0x0988;
  10743. t['iicyrillic'] = 0x0438;
  10744. t['iideva'] = 0x0908;
  10745. t['iigujarati'] = 0x0A88;
  10746. t['iigurmukhi'] = 0x0A08;
  10747. t['iimatragurmukhi'] = 0x0A40;
  10748. t['iinvertedbreve'] = 0x020B;
  10749. t['iishortcyrillic'] = 0x0439;
  10750. t['iivowelsignbengali'] = 0x09C0;
  10751. t['iivowelsigndeva'] = 0x0940;
  10752. t['iivowelsigngujarati'] = 0x0AC0;
  10753. t['ij'] = 0x0133;
  10754. t['ikatakana'] = 0x30A4;
  10755. t['ikatakanahalfwidth'] = 0xFF72;
  10756. t['ikorean'] = 0x3163;
  10757. t['ilde'] = 0x02DC;
  10758. t['iluyhebrew'] = 0x05AC;
  10759. t['imacron'] = 0x012B;
  10760. t['imacroncyrillic'] = 0x04E3;
  10761. t['imageorapproximatelyequal'] = 0x2253;
  10762. t['imatragurmukhi'] = 0x0A3F;
  10763. t['imonospace'] = 0xFF49;
  10764. t['increment'] = 0x2206;
  10765. t['infinity'] = 0x221E;
  10766. t['iniarmenian'] = 0x056B;
  10767. t['integral'] = 0x222B;
  10768. t['integralbottom'] = 0x2321;
  10769. t['integralbt'] = 0x2321;
  10770. t['integralex'] = 0xF8F5;
  10771. t['integraltop'] = 0x2320;
  10772. t['integraltp'] = 0x2320;
  10773. t['intersection'] = 0x2229;
  10774. t['intisquare'] = 0x3305;
  10775. t['invbullet'] = 0x25D8;
  10776. t['invcircle'] = 0x25D9;
  10777. t['invsmileface'] = 0x263B;
  10778. t['iocyrillic'] = 0x0451;
  10779. t['iogonek'] = 0x012F;
  10780. t['iota'] = 0x03B9;
  10781. t['iotadieresis'] = 0x03CA;
  10782. t['iotadieresistonos'] = 0x0390;
  10783. t['iotalatin'] = 0x0269;
  10784. t['iotatonos'] = 0x03AF;
  10785. t['iparen'] = 0x24A4;
  10786. t['irigurmukhi'] = 0x0A72;
  10787. t['ismallhiragana'] = 0x3043;
  10788. t['ismallkatakana'] = 0x30A3;
  10789. t['ismallkatakanahalfwidth'] = 0xFF68;
  10790. t['issharbengali'] = 0x09FA;
  10791. t['istroke'] = 0x0268;
  10792. t['isuperior'] = 0xF6ED;
  10793. t['iterationhiragana'] = 0x309D;
  10794. t['iterationkatakana'] = 0x30FD;
  10795. t['itilde'] = 0x0129;
  10796. t['itildebelow'] = 0x1E2D;
  10797. t['iubopomofo'] = 0x3129;
  10798. t['iucyrillic'] = 0x044E;
  10799. t['ivowelsignbengali'] = 0x09BF;
  10800. t['ivowelsigndeva'] = 0x093F;
  10801. t['ivowelsigngujarati'] = 0x0ABF;
  10802. t['izhitsacyrillic'] = 0x0475;
  10803. t['izhitsadblgravecyrillic'] = 0x0477;
  10804. t['j'] = 0x006A;
  10805. t['jaarmenian'] = 0x0571;
  10806. t['jabengali'] = 0x099C;
  10807. t['jadeva'] = 0x091C;
  10808. t['jagujarati'] = 0x0A9C;
  10809. t['jagurmukhi'] = 0x0A1C;
  10810. t['jbopomofo'] = 0x3110;
  10811. t['jcaron'] = 0x01F0;
  10812. t['jcircle'] = 0x24D9;
  10813. t['jcircumflex'] = 0x0135;
  10814. t['jcrossedtail'] = 0x029D;
  10815. t['jdotlessstroke'] = 0x025F;
  10816. t['jecyrillic'] = 0x0458;
  10817. t['jeemarabic'] = 0x062C;
  10818. t['jeemfinalarabic'] = 0xFE9E;
  10819. t['jeeminitialarabic'] = 0xFE9F;
  10820. t['jeemmedialarabic'] = 0xFEA0;
  10821. t['jeharabic'] = 0x0698;
  10822. t['jehfinalarabic'] = 0xFB8B;
  10823. t['jhabengali'] = 0x099D;
  10824. t['jhadeva'] = 0x091D;
  10825. t['jhagujarati'] = 0x0A9D;
  10826. t['jhagurmukhi'] = 0x0A1D;
  10827. t['jheharmenian'] = 0x057B;
  10828. t['jis'] = 0x3004;
  10829. t['jmonospace'] = 0xFF4A;
  10830. t['jparen'] = 0x24A5;
  10831. t['jsuperior'] = 0x02B2;
  10832. t['k'] = 0x006B;
  10833. t['kabashkircyrillic'] = 0x04A1;
  10834. t['kabengali'] = 0x0995;
  10835. t['kacute'] = 0x1E31;
  10836. t['kacyrillic'] = 0x043A;
  10837. t['kadescendercyrillic'] = 0x049B;
  10838. t['kadeva'] = 0x0915;
  10839. t['kaf'] = 0x05DB;
  10840. t['kafarabic'] = 0x0643;
  10841. t['kafdagesh'] = 0xFB3B;
  10842. t['kafdageshhebrew'] = 0xFB3B;
  10843. t['kaffinalarabic'] = 0xFEDA;
  10844. t['kafhebrew'] = 0x05DB;
  10845. t['kafinitialarabic'] = 0xFEDB;
  10846. t['kafmedialarabic'] = 0xFEDC;
  10847. t['kafrafehebrew'] = 0xFB4D;
  10848. t['kagujarati'] = 0x0A95;
  10849. t['kagurmukhi'] = 0x0A15;
  10850. t['kahiragana'] = 0x304B;
  10851. t['kahookcyrillic'] = 0x04C4;
  10852. t['kakatakana'] = 0x30AB;
  10853. t['kakatakanahalfwidth'] = 0xFF76;
  10854. t['kappa'] = 0x03BA;
  10855. t['kappasymbolgreek'] = 0x03F0;
  10856. t['kapyeounmieumkorean'] = 0x3171;
  10857. t['kapyeounphieuphkorean'] = 0x3184;
  10858. t['kapyeounpieupkorean'] = 0x3178;
  10859. t['kapyeounssangpieupkorean'] = 0x3179;
  10860. t['karoriisquare'] = 0x330D;
  10861. t['kashidaautoarabic'] = 0x0640;
  10862. t['kashidaautonosidebearingarabic'] = 0x0640;
  10863. t['kasmallkatakana'] = 0x30F5;
  10864. t['kasquare'] = 0x3384;
  10865. t['kasraarabic'] = 0x0650;
  10866. t['kasratanarabic'] = 0x064D;
  10867. t['kastrokecyrillic'] = 0x049F;
  10868. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10869. t['kaverticalstrokecyrillic'] = 0x049D;
  10870. t['kbopomofo'] = 0x310E;
  10871. t['kcalsquare'] = 0x3389;
  10872. t['kcaron'] = 0x01E9;
  10873. t['kcedilla'] = 0x0137;
  10874. t['kcircle'] = 0x24DA;
  10875. t['kcommaaccent'] = 0x0137;
  10876. t['kdotbelow'] = 0x1E33;
  10877. t['keharmenian'] = 0x0584;
  10878. t['kehiragana'] = 0x3051;
  10879. t['kekatakana'] = 0x30B1;
  10880. t['kekatakanahalfwidth'] = 0xFF79;
  10881. t['kenarmenian'] = 0x056F;
  10882. t['kesmallkatakana'] = 0x30F6;
  10883. t['kgreenlandic'] = 0x0138;
  10884. t['khabengali'] = 0x0996;
  10885. t['khacyrillic'] = 0x0445;
  10886. t['khadeva'] = 0x0916;
  10887. t['khagujarati'] = 0x0A96;
  10888. t['khagurmukhi'] = 0x0A16;
  10889. t['khaharabic'] = 0x062E;
  10890. t['khahfinalarabic'] = 0xFEA6;
  10891. t['khahinitialarabic'] = 0xFEA7;
  10892. t['khahmedialarabic'] = 0xFEA8;
  10893. t['kheicoptic'] = 0x03E7;
  10894. t['khhadeva'] = 0x0959;
  10895. t['khhagurmukhi'] = 0x0A59;
  10896. t['khieukhacirclekorean'] = 0x3278;
  10897. t['khieukhaparenkorean'] = 0x3218;
  10898. t['khieukhcirclekorean'] = 0x326A;
  10899. t['khieukhkorean'] = 0x314B;
  10900. t['khieukhparenkorean'] = 0x320A;
  10901. t['khokhaithai'] = 0x0E02;
  10902. t['khokhonthai'] = 0x0E05;
  10903. t['khokhuatthai'] = 0x0E03;
  10904. t['khokhwaithai'] = 0x0E04;
  10905. t['khomutthai'] = 0x0E5B;
  10906. t['khook'] = 0x0199;
  10907. t['khorakhangthai'] = 0x0E06;
  10908. t['khzsquare'] = 0x3391;
  10909. t['kihiragana'] = 0x304D;
  10910. t['kikatakana'] = 0x30AD;
  10911. t['kikatakanahalfwidth'] = 0xFF77;
  10912. t['kiroguramusquare'] = 0x3315;
  10913. t['kiromeetorusquare'] = 0x3316;
  10914. t['kirosquare'] = 0x3314;
  10915. t['kiyeokacirclekorean'] = 0x326E;
  10916. t['kiyeokaparenkorean'] = 0x320E;
  10917. t['kiyeokcirclekorean'] = 0x3260;
  10918. t['kiyeokkorean'] = 0x3131;
  10919. t['kiyeokparenkorean'] = 0x3200;
  10920. t['kiyeoksioskorean'] = 0x3133;
  10921. t['kjecyrillic'] = 0x045C;
  10922. t['klinebelow'] = 0x1E35;
  10923. t['klsquare'] = 0x3398;
  10924. t['kmcubedsquare'] = 0x33A6;
  10925. t['kmonospace'] = 0xFF4B;
  10926. t['kmsquaredsquare'] = 0x33A2;
  10927. t['kohiragana'] = 0x3053;
  10928. t['kohmsquare'] = 0x33C0;
  10929. t['kokaithai'] = 0x0E01;
  10930. t['kokatakana'] = 0x30B3;
  10931. t['kokatakanahalfwidth'] = 0xFF7A;
  10932. t['kooposquare'] = 0x331E;
  10933. t['koppacyrillic'] = 0x0481;
  10934. t['koreanstandardsymbol'] = 0x327F;
  10935. t['koroniscmb'] = 0x0343;
  10936. t['kparen'] = 0x24A6;
  10937. t['kpasquare'] = 0x33AA;
  10938. t['ksicyrillic'] = 0x046F;
  10939. t['ktsquare'] = 0x33CF;
  10940. t['kturned'] = 0x029E;
  10941. t['kuhiragana'] = 0x304F;
  10942. t['kukatakana'] = 0x30AF;
  10943. t['kukatakanahalfwidth'] = 0xFF78;
  10944. t['kvsquare'] = 0x33B8;
  10945. t['kwsquare'] = 0x33BE;
  10946. t['l'] = 0x006C;
  10947. t['labengali'] = 0x09B2;
  10948. t['lacute'] = 0x013A;
  10949. t['ladeva'] = 0x0932;
  10950. t['lagujarati'] = 0x0AB2;
  10951. t['lagurmukhi'] = 0x0A32;
  10952. t['lakkhangyaothai'] = 0x0E45;
  10953. t['lamaleffinalarabic'] = 0xFEFC;
  10954. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10955. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10956. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10957. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10958. t['lamalefisolatedarabic'] = 0xFEFB;
  10959. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10960. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10961. t['lamarabic'] = 0x0644;
  10962. t['lambda'] = 0x03BB;
  10963. t['lambdastroke'] = 0x019B;
  10964. t['lamed'] = 0x05DC;
  10965. t['lameddagesh'] = 0xFB3C;
  10966. t['lameddageshhebrew'] = 0xFB3C;
  10967. t['lamedhebrew'] = 0x05DC;
  10968. t['lamfinalarabic'] = 0xFEDE;
  10969. t['lamhahinitialarabic'] = 0xFCCA;
  10970. t['laminitialarabic'] = 0xFEDF;
  10971. t['lamjeeminitialarabic'] = 0xFCC9;
  10972. t['lamkhahinitialarabic'] = 0xFCCB;
  10973. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10974. t['lammedialarabic'] = 0xFEE0;
  10975. t['lammeemhahinitialarabic'] = 0xFD88;
  10976. t['lammeeminitialarabic'] = 0xFCCC;
  10977. t['largecircle'] = 0x25EF;
  10978. t['lbar'] = 0x019A;
  10979. t['lbelt'] = 0x026C;
  10980. t['lbopomofo'] = 0x310C;
  10981. t['lcaron'] = 0x013E;
  10982. t['lcedilla'] = 0x013C;
  10983. t['lcircle'] = 0x24DB;
  10984. t['lcircumflexbelow'] = 0x1E3D;
  10985. t['lcommaaccent'] = 0x013C;
  10986. t['ldot'] = 0x0140;
  10987. t['ldotaccent'] = 0x0140;
  10988. t['ldotbelow'] = 0x1E37;
  10989. t['ldotbelowmacron'] = 0x1E39;
  10990. t['leftangleabovecmb'] = 0x031A;
  10991. t['lefttackbelowcmb'] = 0x0318;
  10992. t['less'] = 0x003C;
  10993. t['lessequal'] = 0x2264;
  10994. t['lessequalorgreater'] = 0x22DA;
  10995. t['lessmonospace'] = 0xFF1C;
  10996. t['lessorequivalent'] = 0x2272;
  10997. t['lessorgreater'] = 0x2276;
  10998. t['lessoverequal'] = 0x2266;
  10999. t['lesssmall'] = 0xFE64;
  11000. t['lezh'] = 0x026E;
  11001. t['lfblock'] = 0x258C;
  11002. t['lhookretroflex'] = 0x026D;
  11003. t['lira'] = 0x20A4;
  11004. t['liwnarmenian'] = 0x056C;
  11005. t['lj'] = 0x01C9;
  11006. t['ljecyrillic'] = 0x0459;
  11007. t['ll'] = 0xF6C0;
  11008. t['lladeva'] = 0x0933;
  11009. t['llagujarati'] = 0x0AB3;
  11010. t['llinebelow'] = 0x1E3B;
  11011. t['llladeva'] = 0x0934;
  11012. t['llvocalicbengali'] = 0x09E1;
  11013. t['llvocalicdeva'] = 0x0961;
  11014. t['llvocalicvowelsignbengali'] = 0x09E3;
  11015. t['llvocalicvowelsigndeva'] = 0x0963;
  11016. t['lmiddletilde'] = 0x026B;
  11017. t['lmonospace'] = 0xFF4C;
  11018. t['lmsquare'] = 0x33D0;
  11019. t['lochulathai'] = 0x0E2C;
  11020. t['logicaland'] = 0x2227;
  11021. t['logicalnot'] = 0x00AC;
  11022. t['logicalnotreversed'] = 0x2310;
  11023. t['logicalor'] = 0x2228;
  11024. t['lolingthai'] = 0x0E25;
  11025. t['longs'] = 0x017F;
  11026. t['lowlinecenterline'] = 0xFE4E;
  11027. t['lowlinecmb'] = 0x0332;
  11028. t['lowlinedashed'] = 0xFE4D;
  11029. t['lozenge'] = 0x25CA;
  11030. t['lparen'] = 0x24A7;
  11031. t['lslash'] = 0x0142;
  11032. t['lsquare'] = 0x2113;
  11033. t['lsuperior'] = 0xF6EE;
  11034. t['ltshade'] = 0x2591;
  11035. t['luthai'] = 0x0E26;
  11036. t['lvocalicbengali'] = 0x098C;
  11037. t['lvocalicdeva'] = 0x090C;
  11038. t['lvocalicvowelsignbengali'] = 0x09E2;
  11039. t['lvocalicvowelsigndeva'] = 0x0962;
  11040. t['lxsquare'] = 0x33D3;
  11041. t['m'] = 0x006D;
  11042. t['mabengali'] = 0x09AE;
  11043. t['macron'] = 0x00AF;
  11044. t['macronbelowcmb'] = 0x0331;
  11045. t['macroncmb'] = 0x0304;
  11046. t['macronlowmod'] = 0x02CD;
  11047. t['macronmonospace'] = 0xFFE3;
  11048. t['macute'] = 0x1E3F;
  11049. t['madeva'] = 0x092E;
  11050. t['magujarati'] = 0x0AAE;
  11051. t['magurmukhi'] = 0x0A2E;
  11052. t['mahapakhhebrew'] = 0x05A4;
  11053. t['mahapakhlefthebrew'] = 0x05A4;
  11054. t['mahiragana'] = 0x307E;
  11055. t['maichattawalowleftthai'] = 0xF895;
  11056. t['maichattawalowrightthai'] = 0xF894;
  11057. t['maichattawathai'] = 0x0E4B;
  11058. t['maichattawaupperleftthai'] = 0xF893;
  11059. t['maieklowleftthai'] = 0xF88C;
  11060. t['maieklowrightthai'] = 0xF88B;
  11061. t['maiekthai'] = 0x0E48;
  11062. t['maiekupperleftthai'] = 0xF88A;
  11063. t['maihanakatleftthai'] = 0xF884;
  11064. t['maihanakatthai'] = 0x0E31;
  11065. t['maitaikhuleftthai'] = 0xF889;
  11066. t['maitaikhuthai'] = 0x0E47;
  11067. t['maitholowleftthai'] = 0xF88F;
  11068. t['maitholowrightthai'] = 0xF88E;
  11069. t['maithothai'] = 0x0E49;
  11070. t['maithoupperleftthai'] = 0xF88D;
  11071. t['maitrilowleftthai'] = 0xF892;
  11072. t['maitrilowrightthai'] = 0xF891;
  11073. t['maitrithai'] = 0x0E4A;
  11074. t['maitriupperleftthai'] = 0xF890;
  11075. t['maiyamokthai'] = 0x0E46;
  11076. t['makatakana'] = 0x30DE;
  11077. t['makatakanahalfwidth'] = 0xFF8F;
  11078. t['male'] = 0x2642;
  11079. t['mansyonsquare'] = 0x3347;
  11080. t['maqafhebrew'] = 0x05BE;
  11081. t['mars'] = 0x2642;
  11082. t['masoracirclehebrew'] = 0x05AF;
  11083. t['masquare'] = 0x3383;
  11084. t['mbopomofo'] = 0x3107;
  11085. t['mbsquare'] = 0x33D4;
  11086. t['mcircle'] = 0x24DC;
  11087. t['mcubedsquare'] = 0x33A5;
  11088. t['mdotaccent'] = 0x1E41;
  11089. t['mdotbelow'] = 0x1E43;
  11090. t['meemarabic'] = 0x0645;
  11091. t['meemfinalarabic'] = 0xFEE2;
  11092. t['meeminitialarabic'] = 0xFEE3;
  11093. t['meemmedialarabic'] = 0xFEE4;
  11094. t['meemmeeminitialarabic'] = 0xFCD1;
  11095. t['meemmeemisolatedarabic'] = 0xFC48;
  11096. t['meetorusquare'] = 0x334D;
  11097. t['mehiragana'] = 0x3081;
  11098. t['meizierasquare'] = 0x337E;
  11099. t['mekatakana'] = 0x30E1;
  11100. t['mekatakanahalfwidth'] = 0xFF92;
  11101. t['mem'] = 0x05DE;
  11102. t['memdagesh'] = 0xFB3E;
  11103. t['memdageshhebrew'] = 0xFB3E;
  11104. t['memhebrew'] = 0x05DE;
  11105. t['menarmenian'] = 0x0574;
  11106. t['merkhahebrew'] = 0x05A5;
  11107. t['merkhakefulahebrew'] = 0x05A6;
  11108. t['merkhakefulalefthebrew'] = 0x05A6;
  11109. t['merkhalefthebrew'] = 0x05A5;
  11110. t['mhook'] = 0x0271;
  11111. t['mhzsquare'] = 0x3392;
  11112. t['middledotkatakanahalfwidth'] = 0xFF65;
  11113. t['middot'] = 0x00B7;
  11114. t['mieumacirclekorean'] = 0x3272;
  11115. t['mieumaparenkorean'] = 0x3212;
  11116. t['mieumcirclekorean'] = 0x3264;
  11117. t['mieumkorean'] = 0x3141;
  11118. t['mieumpansioskorean'] = 0x3170;
  11119. t['mieumparenkorean'] = 0x3204;
  11120. t['mieumpieupkorean'] = 0x316E;
  11121. t['mieumsioskorean'] = 0x316F;
  11122. t['mihiragana'] = 0x307F;
  11123. t['mikatakana'] = 0x30DF;
  11124. t['mikatakanahalfwidth'] = 0xFF90;
  11125. t['minus'] = 0x2212;
  11126. t['minusbelowcmb'] = 0x0320;
  11127. t['minuscircle'] = 0x2296;
  11128. t['minusmod'] = 0x02D7;
  11129. t['minusplus'] = 0x2213;
  11130. t['minute'] = 0x2032;
  11131. t['miribaarusquare'] = 0x334A;
  11132. t['mirisquare'] = 0x3349;
  11133. t['mlonglegturned'] = 0x0270;
  11134. t['mlsquare'] = 0x3396;
  11135. t['mmcubedsquare'] = 0x33A3;
  11136. t['mmonospace'] = 0xFF4D;
  11137. t['mmsquaredsquare'] = 0x339F;
  11138. t['mohiragana'] = 0x3082;
  11139. t['mohmsquare'] = 0x33C1;
  11140. t['mokatakana'] = 0x30E2;
  11141. t['mokatakanahalfwidth'] = 0xFF93;
  11142. t['molsquare'] = 0x33D6;
  11143. t['momathai'] = 0x0E21;
  11144. t['moverssquare'] = 0x33A7;
  11145. t['moverssquaredsquare'] = 0x33A8;
  11146. t['mparen'] = 0x24A8;
  11147. t['mpasquare'] = 0x33AB;
  11148. t['mssquare'] = 0x33B3;
  11149. t['msuperior'] = 0xF6EF;
  11150. t['mturned'] = 0x026F;
  11151. t['mu'] = 0x00B5;
  11152. t['mu1'] = 0x00B5;
  11153. t['muasquare'] = 0x3382;
  11154. t['muchgreater'] = 0x226B;
  11155. t['muchless'] = 0x226A;
  11156. t['mufsquare'] = 0x338C;
  11157. t['mugreek'] = 0x03BC;
  11158. t['mugsquare'] = 0x338D;
  11159. t['muhiragana'] = 0x3080;
  11160. t['mukatakana'] = 0x30E0;
  11161. t['mukatakanahalfwidth'] = 0xFF91;
  11162. t['mulsquare'] = 0x3395;
  11163. t['multiply'] = 0x00D7;
  11164. t['mumsquare'] = 0x339B;
  11165. t['munahhebrew'] = 0x05A3;
  11166. t['munahlefthebrew'] = 0x05A3;
  11167. t['musicalnote'] = 0x266A;
  11168. t['musicalnotedbl'] = 0x266B;
  11169. t['musicflatsign'] = 0x266D;
  11170. t['musicsharpsign'] = 0x266F;
  11171. t['mussquare'] = 0x33B2;
  11172. t['muvsquare'] = 0x33B6;
  11173. t['muwsquare'] = 0x33BC;
  11174. t['mvmegasquare'] = 0x33B9;
  11175. t['mvsquare'] = 0x33B7;
  11176. t['mwmegasquare'] = 0x33BF;
  11177. t['mwsquare'] = 0x33BD;
  11178. t['n'] = 0x006E;
  11179. t['nabengali'] = 0x09A8;
  11180. t['nabla'] = 0x2207;
  11181. t['nacute'] = 0x0144;
  11182. t['nadeva'] = 0x0928;
  11183. t['nagujarati'] = 0x0AA8;
  11184. t['nagurmukhi'] = 0x0A28;
  11185. t['nahiragana'] = 0x306A;
  11186. t['nakatakana'] = 0x30CA;
  11187. t['nakatakanahalfwidth'] = 0xFF85;
  11188. t['napostrophe'] = 0x0149;
  11189. t['nasquare'] = 0x3381;
  11190. t['nbopomofo'] = 0x310B;
  11191. t['nbspace'] = 0x00A0;
  11192. t['ncaron'] = 0x0148;
  11193. t['ncedilla'] = 0x0146;
  11194. t['ncircle'] = 0x24DD;
  11195. t['ncircumflexbelow'] = 0x1E4B;
  11196. t['ncommaaccent'] = 0x0146;
  11197. t['ndotaccent'] = 0x1E45;
  11198. t['ndotbelow'] = 0x1E47;
  11199. t['nehiragana'] = 0x306D;
  11200. t['nekatakana'] = 0x30CD;
  11201. t['nekatakanahalfwidth'] = 0xFF88;
  11202. t['newsheqelsign'] = 0x20AA;
  11203. t['nfsquare'] = 0x338B;
  11204. t['ngabengali'] = 0x0999;
  11205. t['ngadeva'] = 0x0919;
  11206. t['ngagujarati'] = 0x0A99;
  11207. t['ngagurmukhi'] = 0x0A19;
  11208. t['ngonguthai'] = 0x0E07;
  11209. t['nhiragana'] = 0x3093;
  11210. t['nhookleft'] = 0x0272;
  11211. t['nhookretroflex'] = 0x0273;
  11212. t['nieunacirclekorean'] = 0x326F;
  11213. t['nieunaparenkorean'] = 0x320F;
  11214. t['nieuncieuckorean'] = 0x3135;
  11215. t['nieuncirclekorean'] = 0x3261;
  11216. t['nieunhieuhkorean'] = 0x3136;
  11217. t['nieunkorean'] = 0x3134;
  11218. t['nieunpansioskorean'] = 0x3168;
  11219. t['nieunparenkorean'] = 0x3201;
  11220. t['nieunsioskorean'] = 0x3167;
  11221. t['nieuntikeutkorean'] = 0x3166;
  11222. t['nihiragana'] = 0x306B;
  11223. t['nikatakana'] = 0x30CB;
  11224. t['nikatakanahalfwidth'] = 0xFF86;
  11225. t['nikhahitleftthai'] = 0xF899;
  11226. t['nikhahitthai'] = 0x0E4D;
  11227. t['nine'] = 0x0039;
  11228. t['ninearabic'] = 0x0669;
  11229. t['ninebengali'] = 0x09EF;
  11230. t['ninecircle'] = 0x2468;
  11231. t['ninecircleinversesansserif'] = 0x2792;
  11232. t['ninedeva'] = 0x096F;
  11233. t['ninegujarati'] = 0x0AEF;
  11234. t['ninegurmukhi'] = 0x0A6F;
  11235. t['ninehackarabic'] = 0x0669;
  11236. t['ninehangzhou'] = 0x3029;
  11237. t['nineideographicparen'] = 0x3228;
  11238. t['nineinferior'] = 0x2089;
  11239. t['ninemonospace'] = 0xFF19;
  11240. t['nineoldstyle'] = 0xF739;
  11241. t['nineparen'] = 0x247C;
  11242. t['nineperiod'] = 0x2490;
  11243. t['ninepersian'] = 0x06F9;
  11244. t['nineroman'] = 0x2178;
  11245. t['ninesuperior'] = 0x2079;
  11246. t['nineteencircle'] = 0x2472;
  11247. t['nineteenparen'] = 0x2486;
  11248. t['nineteenperiod'] = 0x249A;
  11249. t['ninethai'] = 0x0E59;
  11250. t['nj'] = 0x01CC;
  11251. t['njecyrillic'] = 0x045A;
  11252. t['nkatakana'] = 0x30F3;
  11253. t['nkatakanahalfwidth'] = 0xFF9D;
  11254. t['nlegrightlong'] = 0x019E;
  11255. t['nlinebelow'] = 0x1E49;
  11256. t['nmonospace'] = 0xFF4E;
  11257. t['nmsquare'] = 0x339A;
  11258. t['nnabengali'] = 0x09A3;
  11259. t['nnadeva'] = 0x0923;
  11260. t['nnagujarati'] = 0x0AA3;
  11261. t['nnagurmukhi'] = 0x0A23;
  11262. t['nnnadeva'] = 0x0929;
  11263. t['nohiragana'] = 0x306E;
  11264. t['nokatakana'] = 0x30CE;
  11265. t['nokatakanahalfwidth'] = 0xFF89;
  11266. t['nonbreakingspace'] = 0x00A0;
  11267. t['nonenthai'] = 0x0E13;
  11268. t['nonuthai'] = 0x0E19;
  11269. t['noonarabic'] = 0x0646;
  11270. t['noonfinalarabic'] = 0xFEE6;
  11271. t['noonghunnaarabic'] = 0x06BA;
  11272. t['noonghunnafinalarabic'] = 0xFB9F;
  11273. t['nooninitialarabic'] = 0xFEE7;
  11274. t['noonjeeminitialarabic'] = 0xFCD2;
  11275. t['noonjeemisolatedarabic'] = 0xFC4B;
  11276. t['noonmedialarabic'] = 0xFEE8;
  11277. t['noonmeeminitialarabic'] = 0xFCD5;
  11278. t['noonmeemisolatedarabic'] = 0xFC4E;
  11279. t['noonnoonfinalarabic'] = 0xFC8D;
  11280. t['notcontains'] = 0x220C;
  11281. t['notelement'] = 0x2209;
  11282. t['notelementof'] = 0x2209;
  11283. t['notequal'] = 0x2260;
  11284. t['notgreater'] = 0x226F;
  11285. t['notgreaternorequal'] = 0x2271;
  11286. t['notgreaternorless'] = 0x2279;
  11287. t['notidentical'] = 0x2262;
  11288. t['notless'] = 0x226E;
  11289. t['notlessnorequal'] = 0x2270;
  11290. t['notparallel'] = 0x2226;
  11291. t['notprecedes'] = 0x2280;
  11292. t['notsubset'] = 0x2284;
  11293. t['notsucceeds'] = 0x2281;
  11294. t['notsuperset'] = 0x2285;
  11295. t['nowarmenian'] = 0x0576;
  11296. t['nparen'] = 0x24A9;
  11297. t['nssquare'] = 0x33B1;
  11298. t['nsuperior'] = 0x207F;
  11299. t['ntilde'] = 0x00F1;
  11300. t['nu'] = 0x03BD;
  11301. t['nuhiragana'] = 0x306C;
  11302. t['nukatakana'] = 0x30CC;
  11303. t['nukatakanahalfwidth'] = 0xFF87;
  11304. t['nuktabengali'] = 0x09BC;
  11305. t['nuktadeva'] = 0x093C;
  11306. t['nuktagujarati'] = 0x0ABC;
  11307. t['nuktagurmukhi'] = 0x0A3C;
  11308. t['numbersign'] = 0x0023;
  11309. t['numbersignmonospace'] = 0xFF03;
  11310. t['numbersignsmall'] = 0xFE5F;
  11311. t['numeralsigngreek'] = 0x0374;
  11312. t['numeralsignlowergreek'] = 0x0375;
  11313. t['numero'] = 0x2116;
  11314. t['nun'] = 0x05E0;
  11315. t['nundagesh'] = 0xFB40;
  11316. t['nundageshhebrew'] = 0xFB40;
  11317. t['nunhebrew'] = 0x05E0;
  11318. t['nvsquare'] = 0x33B5;
  11319. t['nwsquare'] = 0x33BB;
  11320. t['nyabengali'] = 0x099E;
  11321. t['nyadeva'] = 0x091E;
  11322. t['nyagujarati'] = 0x0A9E;
  11323. t['nyagurmukhi'] = 0x0A1E;
  11324. t['o'] = 0x006F;
  11325. t['oacute'] = 0x00F3;
  11326. t['oangthai'] = 0x0E2D;
  11327. t['obarred'] = 0x0275;
  11328. t['obarredcyrillic'] = 0x04E9;
  11329. t['obarreddieresiscyrillic'] = 0x04EB;
  11330. t['obengali'] = 0x0993;
  11331. t['obopomofo'] = 0x311B;
  11332. t['obreve'] = 0x014F;
  11333. t['ocandradeva'] = 0x0911;
  11334. t['ocandragujarati'] = 0x0A91;
  11335. t['ocandravowelsigndeva'] = 0x0949;
  11336. t['ocandravowelsigngujarati'] = 0x0AC9;
  11337. t['ocaron'] = 0x01D2;
  11338. t['ocircle'] = 0x24DE;
  11339. t['ocircumflex'] = 0x00F4;
  11340. t['ocircumflexacute'] = 0x1ED1;
  11341. t['ocircumflexdotbelow'] = 0x1ED9;
  11342. t['ocircumflexgrave'] = 0x1ED3;
  11343. t['ocircumflexhookabove'] = 0x1ED5;
  11344. t['ocircumflextilde'] = 0x1ED7;
  11345. t['ocyrillic'] = 0x043E;
  11346. t['odblacute'] = 0x0151;
  11347. t['odblgrave'] = 0x020D;
  11348. t['odeva'] = 0x0913;
  11349. t['odieresis'] = 0x00F6;
  11350. t['odieresiscyrillic'] = 0x04E7;
  11351. t['odotbelow'] = 0x1ECD;
  11352. t['oe'] = 0x0153;
  11353. t['oekorean'] = 0x315A;
  11354. t['ogonek'] = 0x02DB;
  11355. t['ogonekcmb'] = 0x0328;
  11356. t['ograve'] = 0x00F2;
  11357. t['ogujarati'] = 0x0A93;
  11358. t['oharmenian'] = 0x0585;
  11359. t['ohiragana'] = 0x304A;
  11360. t['ohookabove'] = 0x1ECF;
  11361. t['ohorn'] = 0x01A1;
  11362. t['ohornacute'] = 0x1EDB;
  11363. t['ohorndotbelow'] = 0x1EE3;
  11364. t['ohorngrave'] = 0x1EDD;
  11365. t['ohornhookabove'] = 0x1EDF;
  11366. t['ohorntilde'] = 0x1EE1;
  11367. t['ohungarumlaut'] = 0x0151;
  11368. t['oi'] = 0x01A3;
  11369. t['oinvertedbreve'] = 0x020F;
  11370. t['okatakana'] = 0x30AA;
  11371. t['okatakanahalfwidth'] = 0xFF75;
  11372. t['okorean'] = 0x3157;
  11373. t['olehebrew'] = 0x05AB;
  11374. t['omacron'] = 0x014D;
  11375. t['omacronacute'] = 0x1E53;
  11376. t['omacrongrave'] = 0x1E51;
  11377. t['omdeva'] = 0x0950;
  11378. t['omega'] = 0x03C9;
  11379. t['omega1'] = 0x03D6;
  11380. t['omegacyrillic'] = 0x0461;
  11381. t['omegalatinclosed'] = 0x0277;
  11382. t['omegaroundcyrillic'] = 0x047B;
  11383. t['omegatitlocyrillic'] = 0x047D;
  11384. t['omegatonos'] = 0x03CE;
  11385. t['omgujarati'] = 0x0AD0;
  11386. t['omicron'] = 0x03BF;
  11387. t['omicrontonos'] = 0x03CC;
  11388. t['omonospace'] = 0xFF4F;
  11389. t['one'] = 0x0031;
  11390. t['onearabic'] = 0x0661;
  11391. t['onebengali'] = 0x09E7;
  11392. t['onecircle'] = 0x2460;
  11393. t['onecircleinversesansserif'] = 0x278A;
  11394. t['onedeva'] = 0x0967;
  11395. t['onedotenleader'] = 0x2024;
  11396. t['oneeighth'] = 0x215B;
  11397. t['onefitted'] = 0xF6DC;
  11398. t['onegujarati'] = 0x0AE7;
  11399. t['onegurmukhi'] = 0x0A67;
  11400. t['onehackarabic'] = 0x0661;
  11401. t['onehalf'] = 0x00BD;
  11402. t['onehangzhou'] = 0x3021;
  11403. t['oneideographicparen'] = 0x3220;
  11404. t['oneinferior'] = 0x2081;
  11405. t['onemonospace'] = 0xFF11;
  11406. t['onenumeratorbengali'] = 0x09F4;
  11407. t['oneoldstyle'] = 0xF731;
  11408. t['oneparen'] = 0x2474;
  11409. t['oneperiod'] = 0x2488;
  11410. t['onepersian'] = 0x06F1;
  11411. t['onequarter'] = 0x00BC;
  11412. t['oneroman'] = 0x2170;
  11413. t['onesuperior'] = 0x00B9;
  11414. t['onethai'] = 0x0E51;
  11415. t['onethird'] = 0x2153;
  11416. t['oogonek'] = 0x01EB;
  11417. t['oogonekmacron'] = 0x01ED;
  11418. t['oogurmukhi'] = 0x0A13;
  11419. t['oomatragurmukhi'] = 0x0A4B;
  11420. t['oopen'] = 0x0254;
  11421. t['oparen'] = 0x24AA;
  11422. t['openbullet'] = 0x25E6;
  11423. t['option'] = 0x2325;
  11424. t['ordfeminine'] = 0x00AA;
  11425. t['ordmasculine'] = 0x00BA;
  11426. t['orthogonal'] = 0x221F;
  11427. t['oshortdeva'] = 0x0912;
  11428. t['oshortvowelsigndeva'] = 0x094A;
  11429. t['oslash'] = 0x00F8;
  11430. t['oslashacute'] = 0x01FF;
  11431. t['osmallhiragana'] = 0x3049;
  11432. t['osmallkatakana'] = 0x30A9;
  11433. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11434. t['ostrokeacute'] = 0x01FF;
  11435. t['osuperior'] = 0xF6F0;
  11436. t['otcyrillic'] = 0x047F;
  11437. t['otilde'] = 0x00F5;
  11438. t['otildeacute'] = 0x1E4D;
  11439. t['otildedieresis'] = 0x1E4F;
  11440. t['oubopomofo'] = 0x3121;
  11441. t['overline'] = 0x203E;
  11442. t['overlinecenterline'] = 0xFE4A;
  11443. t['overlinecmb'] = 0x0305;
  11444. t['overlinedashed'] = 0xFE49;
  11445. t['overlinedblwavy'] = 0xFE4C;
  11446. t['overlinewavy'] = 0xFE4B;
  11447. t['overscore'] = 0x00AF;
  11448. t['ovowelsignbengali'] = 0x09CB;
  11449. t['ovowelsigndeva'] = 0x094B;
  11450. t['ovowelsigngujarati'] = 0x0ACB;
  11451. t['p'] = 0x0070;
  11452. t['paampssquare'] = 0x3380;
  11453. t['paasentosquare'] = 0x332B;
  11454. t['pabengali'] = 0x09AA;
  11455. t['pacute'] = 0x1E55;
  11456. t['padeva'] = 0x092A;
  11457. t['pagedown'] = 0x21DF;
  11458. t['pageup'] = 0x21DE;
  11459. t['pagujarati'] = 0x0AAA;
  11460. t['pagurmukhi'] = 0x0A2A;
  11461. t['pahiragana'] = 0x3071;
  11462. t['paiyannoithai'] = 0x0E2F;
  11463. t['pakatakana'] = 0x30D1;
  11464. t['palatalizationcyrilliccmb'] = 0x0484;
  11465. t['palochkacyrillic'] = 0x04C0;
  11466. t['pansioskorean'] = 0x317F;
  11467. t['paragraph'] = 0x00B6;
  11468. t['parallel'] = 0x2225;
  11469. t['parenleft'] = 0x0028;
  11470. t['parenleftaltonearabic'] = 0xFD3E;
  11471. t['parenleftbt'] = 0xF8ED;
  11472. t['parenleftex'] = 0xF8EC;
  11473. t['parenleftinferior'] = 0x208D;
  11474. t['parenleftmonospace'] = 0xFF08;
  11475. t['parenleftsmall'] = 0xFE59;
  11476. t['parenleftsuperior'] = 0x207D;
  11477. t['parenlefttp'] = 0xF8EB;
  11478. t['parenleftvertical'] = 0xFE35;
  11479. t['parenright'] = 0x0029;
  11480. t['parenrightaltonearabic'] = 0xFD3F;
  11481. t['parenrightbt'] = 0xF8F8;
  11482. t['parenrightex'] = 0xF8F7;
  11483. t['parenrightinferior'] = 0x208E;
  11484. t['parenrightmonospace'] = 0xFF09;
  11485. t['parenrightsmall'] = 0xFE5A;
  11486. t['parenrightsuperior'] = 0x207E;
  11487. t['parenrighttp'] = 0xF8F6;
  11488. t['parenrightvertical'] = 0xFE36;
  11489. t['partialdiff'] = 0x2202;
  11490. t['paseqhebrew'] = 0x05C0;
  11491. t['pashtahebrew'] = 0x0599;
  11492. t['pasquare'] = 0x33A9;
  11493. t['patah'] = 0x05B7;
  11494. t['patah11'] = 0x05B7;
  11495. t['patah1d'] = 0x05B7;
  11496. t['patah2a'] = 0x05B7;
  11497. t['patahhebrew'] = 0x05B7;
  11498. t['patahnarrowhebrew'] = 0x05B7;
  11499. t['patahquarterhebrew'] = 0x05B7;
  11500. t['patahwidehebrew'] = 0x05B7;
  11501. t['pazerhebrew'] = 0x05A1;
  11502. t['pbopomofo'] = 0x3106;
  11503. t['pcircle'] = 0x24DF;
  11504. t['pdotaccent'] = 0x1E57;
  11505. t['pe'] = 0x05E4;
  11506. t['pecyrillic'] = 0x043F;
  11507. t['pedagesh'] = 0xFB44;
  11508. t['pedageshhebrew'] = 0xFB44;
  11509. t['peezisquare'] = 0x333B;
  11510. t['pefinaldageshhebrew'] = 0xFB43;
  11511. t['peharabic'] = 0x067E;
  11512. t['peharmenian'] = 0x057A;
  11513. t['pehebrew'] = 0x05E4;
  11514. t['pehfinalarabic'] = 0xFB57;
  11515. t['pehinitialarabic'] = 0xFB58;
  11516. t['pehiragana'] = 0x307A;
  11517. t['pehmedialarabic'] = 0xFB59;
  11518. t['pekatakana'] = 0x30DA;
  11519. t['pemiddlehookcyrillic'] = 0x04A7;
  11520. t['perafehebrew'] = 0xFB4E;
  11521. t['percent'] = 0x0025;
  11522. t['percentarabic'] = 0x066A;
  11523. t['percentmonospace'] = 0xFF05;
  11524. t['percentsmall'] = 0xFE6A;
  11525. t['period'] = 0x002E;
  11526. t['periodarmenian'] = 0x0589;
  11527. t['periodcentered'] = 0x00B7;
  11528. t['periodhalfwidth'] = 0xFF61;
  11529. t['periodinferior'] = 0xF6E7;
  11530. t['periodmonospace'] = 0xFF0E;
  11531. t['periodsmall'] = 0xFE52;
  11532. t['periodsuperior'] = 0xF6E8;
  11533. t['perispomenigreekcmb'] = 0x0342;
  11534. t['perpendicular'] = 0x22A5;
  11535. t['perthousand'] = 0x2030;
  11536. t['peseta'] = 0x20A7;
  11537. t['pfsquare'] = 0x338A;
  11538. t['phabengali'] = 0x09AB;
  11539. t['phadeva'] = 0x092B;
  11540. t['phagujarati'] = 0x0AAB;
  11541. t['phagurmukhi'] = 0x0A2B;
  11542. t['phi'] = 0x03C6;
  11543. t['phi1'] = 0x03D5;
  11544. t['phieuphacirclekorean'] = 0x327A;
  11545. t['phieuphaparenkorean'] = 0x321A;
  11546. t['phieuphcirclekorean'] = 0x326C;
  11547. t['phieuphkorean'] = 0x314D;
  11548. t['phieuphparenkorean'] = 0x320C;
  11549. t['philatin'] = 0x0278;
  11550. t['phinthuthai'] = 0x0E3A;
  11551. t['phisymbolgreek'] = 0x03D5;
  11552. t['phook'] = 0x01A5;
  11553. t['phophanthai'] = 0x0E1E;
  11554. t['phophungthai'] = 0x0E1C;
  11555. t['phosamphaothai'] = 0x0E20;
  11556. t['pi'] = 0x03C0;
  11557. t['pieupacirclekorean'] = 0x3273;
  11558. t['pieupaparenkorean'] = 0x3213;
  11559. t['pieupcieuckorean'] = 0x3176;
  11560. t['pieupcirclekorean'] = 0x3265;
  11561. t['pieupkiyeokkorean'] = 0x3172;
  11562. t['pieupkorean'] = 0x3142;
  11563. t['pieupparenkorean'] = 0x3205;
  11564. t['pieupsioskiyeokkorean'] = 0x3174;
  11565. t['pieupsioskorean'] = 0x3144;
  11566. t['pieupsiostikeutkorean'] = 0x3175;
  11567. t['pieupthieuthkorean'] = 0x3177;
  11568. t['pieuptikeutkorean'] = 0x3173;
  11569. t['pihiragana'] = 0x3074;
  11570. t['pikatakana'] = 0x30D4;
  11571. t['pisymbolgreek'] = 0x03D6;
  11572. t['piwrarmenian'] = 0x0583;
  11573. t['plus'] = 0x002B;
  11574. t['plusbelowcmb'] = 0x031F;
  11575. t['pluscircle'] = 0x2295;
  11576. t['plusminus'] = 0x00B1;
  11577. t['plusmod'] = 0x02D6;
  11578. t['plusmonospace'] = 0xFF0B;
  11579. t['plussmall'] = 0xFE62;
  11580. t['plussuperior'] = 0x207A;
  11581. t['pmonospace'] = 0xFF50;
  11582. t['pmsquare'] = 0x33D8;
  11583. t['pohiragana'] = 0x307D;
  11584. t['pointingindexdownwhite'] = 0x261F;
  11585. t['pointingindexleftwhite'] = 0x261C;
  11586. t['pointingindexrightwhite'] = 0x261E;
  11587. t['pointingindexupwhite'] = 0x261D;
  11588. t['pokatakana'] = 0x30DD;
  11589. t['poplathai'] = 0x0E1B;
  11590. t['postalmark'] = 0x3012;
  11591. t['postalmarkface'] = 0x3020;
  11592. t['pparen'] = 0x24AB;
  11593. t['precedes'] = 0x227A;
  11594. t['prescription'] = 0x211E;
  11595. t['primemod'] = 0x02B9;
  11596. t['primereversed'] = 0x2035;
  11597. t['product'] = 0x220F;
  11598. t['projective'] = 0x2305;
  11599. t['prolongedkana'] = 0x30FC;
  11600. t['propellor'] = 0x2318;
  11601. t['propersubset'] = 0x2282;
  11602. t['propersuperset'] = 0x2283;
  11603. t['proportion'] = 0x2237;
  11604. t['proportional'] = 0x221D;
  11605. t['psi'] = 0x03C8;
  11606. t['psicyrillic'] = 0x0471;
  11607. t['psilipneumatacyrilliccmb'] = 0x0486;
  11608. t['pssquare'] = 0x33B0;
  11609. t['puhiragana'] = 0x3077;
  11610. t['pukatakana'] = 0x30D7;
  11611. t['pvsquare'] = 0x33B4;
  11612. t['pwsquare'] = 0x33BA;
  11613. t['q'] = 0x0071;
  11614. t['qadeva'] = 0x0958;
  11615. t['qadmahebrew'] = 0x05A8;
  11616. t['qafarabic'] = 0x0642;
  11617. t['qaffinalarabic'] = 0xFED6;
  11618. t['qafinitialarabic'] = 0xFED7;
  11619. t['qafmedialarabic'] = 0xFED8;
  11620. t['qamats'] = 0x05B8;
  11621. t['qamats10'] = 0x05B8;
  11622. t['qamats1a'] = 0x05B8;
  11623. t['qamats1c'] = 0x05B8;
  11624. t['qamats27'] = 0x05B8;
  11625. t['qamats29'] = 0x05B8;
  11626. t['qamats33'] = 0x05B8;
  11627. t['qamatsde'] = 0x05B8;
  11628. t['qamatshebrew'] = 0x05B8;
  11629. t['qamatsnarrowhebrew'] = 0x05B8;
  11630. t['qamatsqatanhebrew'] = 0x05B8;
  11631. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11632. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11633. t['qamatsqatanwidehebrew'] = 0x05B8;
  11634. t['qamatsquarterhebrew'] = 0x05B8;
  11635. t['qamatswidehebrew'] = 0x05B8;
  11636. t['qarneyparahebrew'] = 0x059F;
  11637. t['qbopomofo'] = 0x3111;
  11638. t['qcircle'] = 0x24E0;
  11639. t['qhook'] = 0x02A0;
  11640. t['qmonospace'] = 0xFF51;
  11641. t['qof'] = 0x05E7;
  11642. t['qofdagesh'] = 0xFB47;
  11643. t['qofdageshhebrew'] = 0xFB47;
  11644. t['qofhebrew'] = 0x05E7;
  11645. t['qparen'] = 0x24AC;
  11646. t['quarternote'] = 0x2669;
  11647. t['qubuts'] = 0x05BB;
  11648. t['qubuts18'] = 0x05BB;
  11649. t['qubuts25'] = 0x05BB;
  11650. t['qubuts31'] = 0x05BB;
  11651. t['qubutshebrew'] = 0x05BB;
  11652. t['qubutsnarrowhebrew'] = 0x05BB;
  11653. t['qubutsquarterhebrew'] = 0x05BB;
  11654. t['qubutswidehebrew'] = 0x05BB;
  11655. t['question'] = 0x003F;
  11656. t['questionarabic'] = 0x061F;
  11657. t['questionarmenian'] = 0x055E;
  11658. t['questiondown'] = 0x00BF;
  11659. t['questiondownsmall'] = 0xF7BF;
  11660. t['questiongreek'] = 0x037E;
  11661. t['questionmonospace'] = 0xFF1F;
  11662. t['questionsmall'] = 0xF73F;
  11663. t['quotedbl'] = 0x0022;
  11664. t['quotedblbase'] = 0x201E;
  11665. t['quotedblleft'] = 0x201C;
  11666. t['quotedblmonospace'] = 0xFF02;
  11667. t['quotedblprime'] = 0x301E;
  11668. t['quotedblprimereversed'] = 0x301D;
  11669. t['quotedblright'] = 0x201D;
  11670. t['quoteleft'] = 0x2018;
  11671. t['quoteleftreversed'] = 0x201B;
  11672. t['quotereversed'] = 0x201B;
  11673. t['quoteright'] = 0x2019;
  11674. t['quoterightn'] = 0x0149;
  11675. t['quotesinglbase'] = 0x201A;
  11676. t['quotesingle'] = 0x0027;
  11677. t['quotesinglemonospace'] = 0xFF07;
  11678. t['r'] = 0x0072;
  11679. t['raarmenian'] = 0x057C;
  11680. t['rabengali'] = 0x09B0;
  11681. t['racute'] = 0x0155;
  11682. t['radeva'] = 0x0930;
  11683. t['radical'] = 0x221A;
  11684. t['radicalex'] = 0xF8E5;
  11685. t['radoverssquare'] = 0x33AE;
  11686. t['radoverssquaredsquare'] = 0x33AF;
  11687. t['radsquare'] = 0x33AD;
  11688. t['rafe'] = 0x05BF;
  11689. t['rafehebrew'] = 0x05BF;
  11690. t['ragujarati'] = 0x0AB0;
  11691. t['ragurmukhi'] = 0x0A30;
  11692. t['rahiragana'] = 0x3089;
  11693. t['rakatakana'] = 0x30E9;
  11694. t['rakatakanahalfwidth'] = 0xFF97;
  11695. t['ralowerdiagonalbengali'] = 0x09F1;
  11696. t['ramiddlediagonalbengali'] = 0x09F0;
  11697. t['ramshorn'] = 0x0264;
  11698. t['ratio'] = 0x2236;
  11699. t['rbopomofo'] = 0x3116;
  11700. t['rcaron'] = 0x0159;
  11701. t['rcedilla'] = 0x0157;
  11702. t['rcircle'] = 0x24E1;
  11703. t['rcommaaccent'] = 0x0157;
  11704. t['rdblgrave'] = 0x0211;
  11705. t['rdotaccent'] = 0x1E59;
  11706. t['rdotbelow'] = 0x1E5B;
  11707. t['rdotbelowmacron'] = 0x1E5D;
  11708. t['referencemark'] = 0x203B;
  11709. t['reflexsubset'] = 0x2286;
  11710. t['reflexsuperset'] = 0x2287;
  11711. t['registered'] = 0x00AE;
  11712. t['registersans'] = 0xF8E8;
  11713. t['registerserif'] = 0xF6DA;
  11714. t['reharabic'] = 0x0631;
  11715. t['reharmenian'] = 0x0580;
  11716. t['rehfinalarabic'] = 0xFEAE;
  11717. t['rehiragana'] = 0x308C;
  11718. t['rekatakana'] = 0x30EC;
  11719. t['rekatakanahalfwidth'] = 0xFF9A;
  11720. t['resh'] = 0x05E8;
  11721. t['reshdageshhebrew'] = 0xFB48;
  11722. t['reshhebrew'] = 0x05E8;
  11723. t['reversedtilde'] = 0x223D;
  11724. t['reviahebrew'] = 0x0597;
  11725. t['reviamugrashhebrew'] = 0x0597;
  11726. t['revlogicalnot'] = 0x2310;
  11727. t['rfishhook'] = 0x027E;
  11728. t['rfishhookreversed'] = 0x027F;
  11729. t['rhabengali'] = 0x09DD;
  11730. t['rhadeva'] = 0x095D;
  11731. t['rho'] = 0x03C1;
  11732. t['rhook'] = 0x027D;
  11733. t['rhookturned'] = 0x027B;
  11734. t['rhookturnedsuperior'] = 0x02B5;
  11735. t['rhosymbolgreek'] = 0x03F1;
  11736. t['rhotichookmod'] = 0x02DE;
  11737. t['rieulacirclekorean'] = 0x3271;
  11738. t['rieulaparenkorean'] = 0x3211;
  11739. t['rieulcirclekorean'] = 0x3263;
  11740. t['rieulhieuhkorean'] = 0x3140;
  11741. t['rieulkiyeokkorean'] = 0x313A;
  11742. t['rieulkiyeoksioskorean'] = 0x3169;
  11743. t['rieulkorean'] = 0x3139;
  11744. t['rieulmieumkorean'] = 0x313B;
  11745. t['rieulpansioskorean'] = 0x316C;
  11746. t['rieulparenkorean'] = 0x3203;
  11747. t['rieulphieuphkorean'] = 0x313F;
  11748. t['rieulpieupkorean'] = 0x313C;
  11749. t['rieulpieupsioskorean'] = 0x316B;
  11750. t['rieulsioskorean'] = 0x313D;
  11751. t['rieulthieuthkorean'] = 0x313E;
  11752. t['rieultikeutkorean'] = 0x316A;
  11753. t['rieulyeorinhieuhkorean'] = 0x316D;
  11754. t['rightangle'] = 0x221F;
  11755. t['righttackbelowcmb'] = 0x0319;
  11756. t['righttriangle'] = 0x22BF;
  11757. t['rihiragana'] = 0x308A;
  11758. t['rikatakana'] = 0x30EA;
  11759. t['rikatakanahalfwidth'] = 0xFF98;
  11760. t['ring'] = 0x02DA;
  11761. t['ringbelowcmb'] = 0x0325;
  11762. t['ringcmb'] = 0x030A;
  11763. t['ringhalfleft'] = 0x02BF;
  11764. t['ringhalfleftarmenian'] = 0x0559;
  11765. t['ringhalfleftbelowcmb'] = 0x031C;
  11766. t['ringhalfleftcentered'] = 0x02D3;
  11767. t['ringhalfright'] = 0x02BE;
  11768. t['ringhalfrightbelowcmb'] = 0x0339;
  11769. t['ringhalfrightcentered'] = 0x02D2;
  11770. t['rinvertedbreve'] = 0x0213;
  11771. t['rittorusquare'] = 0x3351;
  11772. t['rlinebelow'] = 0x1E5F;
  11773. t['rlongleg'] = 0x027C;
  11774. t['rlonglegturned'] = 0x027A;
  11775. t['rmonospace'] = 0xFF52;
  11776. t['rohiragana'] = 0x308D;
  11777. t['rokatakana'] = 0x30ED;
  11778. t['rokatakanahalfwidth'] = 0xFF9B;
  11779. t['roruathai'] = 0x0E23;
  11780. t['rparen'] = 0x24AD;
  11781. t['rrabengali'] = 0x09DC;
  11782. t['rradeva'] = 0x0931;
  11783. t['rragurmukhi'] = 0x0A5C;
  11784. t['rreharabic'] = 0x0691;
  11785. t['rrehfinalarabic'] = 0xFB8D;
  11786. t['rrvocalicbengali'] = 0x09E0;
  11787. t['rrvocalicdeva'] = 0x0960;
  11788. t['rrvocalicgujarati'] = 0x0AE0;
  11789. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11790. t['rrvocalicvowelsigndeva'] = 0x0944;
  11791. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11792. t['rsuperior'] = 0xF6F1;
  11793. t['rtblock'] = 0x2590;
  11794. t['rturned'] = 0x0279;
  11795. t['rturnedsuperior'] = 0x02B4;
  11796. t['ruhiragana'] = 0x308B;
  11797. t['rukatakana'] = 0x30EB;
  11798. t['rukatakanahalfwidth'] = 0xFF99;
  11799. t['rupeemarkbengali'] = 0x09F2;
  11800. t['rupeesignbengali'] = 0x09F3;
  11801. t['rupiah'] = 0xF6DD;
  11802. t['ruthai'] = 0x0E24;
  11803. t['rvocalicbengali'] = 0x098B;
  11804. t['rvocalicdeva'] = 0x090B;
  11805. t['rvocalicgujarati'] = 0x0A8B;
  11806. t['rvocalicvowelsignbengali'] = 0x09C3;
  11807. t['rvocalicvowelsigndeva'] = 0x0943;
  11808. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11809. t['s'] = 0x0073;
  11810. t['sabengali'] = 0x09B8;
  11811. t['sacute'] = 0x015B;
  11812. t['sacutedotaccent'] = 0x1E65;
  11813. t['sadarabic'] = 0x0635;
  11814. t['sadeva'] = 0x0938;
  11815. t['sadfinalarabic'] = 0xFEBA;
  11816. t['sadinitialarabic'] = 0xFEBB;
  11817. t['sadmedialarabic'] = 0xFEBC;
  11818. t['sagujarati'] = 0x0AB8;
  11819. t['sagurmukhi'] = 0x0A38;
  11820. t['sahiragana'] = 0x3055;
  11821. t['sakatakana'] = 0x30B5;
  11822. t['sakatakanahalfwidth'] = 0xFF7B;
  11823. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11824. t['samekh'] = 0x05E1;
  11825. t['samekhdagesh'] = 0xFB41;
  11826. t['samekhdageshhebrew'] = 0xFB41;
  11827. t['samekhhebrew'] = 0x05E1;
  11828. t['saraaathai'] = 0x0E32;
  11829. t['saraaethai'] = 0x0E41;
  11830. t['saraaimaimalaithai'] = 0x0E44;
  11831. t['saraaimaimuanthai'] = 0x0E43;
  11832. t['saraamthai'] = 0x0E33;
  11833. t['saraathai'] = 0x0E30;
  11834. t['saraethai'] = 0x0E40;
  11835. t['saraiileftthai'] = 0xF886;
  11836. t['saraiithai'] = 0x0E35;
  11837. t['saraileftthai'] = 0xF885;
  11838. t['saraithai'] = 0x0E34;
  11839. t['saraothai'] = 0x0E42;
  11840. t['saraueeleftthai'] = 0xF888;
  11841. t['saraueethai'] = 0x0E37;
  11842. t['saraueleftthai'] = 0xF887;
  11843. t['sarauethai'] = 0x0E36;
  11844. t['sarauthai'] = 0x0E38;
  11845. t['sarauuthai'] = 0x0E39;
  11846. t['sbopomofo'] = 0x3119;
  11847. t['scaron'] = 0x0161;
  11848. t['scarondotaccent'] = 0x1E67;
  11849. t['scedilla'] = 0x015F;
  11850. t['schwa'] = 0x0259;
  11851. t['schwacyrillic'] = 0x04D9;
  11852. t['schwadieresiscyrillic'] = 0x04DB;
  11853. t['schwahook'] = 0x025A;
  11854. t['scircle'] = 0x24E2;
  11855. t['scircumflex'] = 0x015D;
  11856. t['scommaaccent'] = 0x0219;
  11857. t['sdotaccent'] = 0x1E61;
  11858. t['sdotbelow'] = 0x1E63;
  11859. t['sdotbelowdotaccent'] = 0x1E69;
  11860. t['seagullbelowcmb'] = 0x033C;
  11861. t['second'] = 0x2033;
  11862. t['secondtonechinese'] = 0x02CA;
  11863. t['section'] = 0x00A7;
  11864. t['seenarabic'] = 0x0633;
  11865. t['seenfinalarabic'] = 0xFEB2;
  11866. t['seeninitialarabic'] = 0xFEB3;
  11867. t['seenmedialarabic'] = 0xFEB4;
  11868. t['segol'] = 0x05B6;
  11869. t['segol13'] = 0x05B6;
  11870. t['segol1f'] = 0x05B6;
  11871. t['segol2c'] = 0x05B6;
  11872. t['segolhebrew'] = 0x05B6;
  11873. t['segolnarrowhebrew'] = 0x05B6;
  11874. t['segolquarterhebrew'] = 0x05B6;
  11875. t['segoltahebrew'] = 0x0592;
  11876. t['segolwidehebrew'] = 0x05B6;
  11877. t['seharmenian'] = 0x057D;
  11878. t['sehiragana'] = 0x305B;
  11879. t['sekatakana'] = 0x30BB;
  11880. t['sekatakanahalfwidth'] = 0xFF7E;
  11881. t['semicolon'] = 0x003B;
  11882. t['semicolonarabic'] = 0x061B;
  11883. t['semicolonmonospace'] = 0xFF1B;
  11884. t['semicolonsmall'] = 0xFE54;
  11885. t['semivoicedmarkkana'] = 0x309C;
  11886. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11887. t['sentisquare'] = 0x3322;
  11888. t['sentosquare'] = 0x3323;
  11889. t['seven'] = 0x0037;
  11890. t['sevenarabic'] = 0x0667;
  11891. t['sevenbengali'] = 0x09ED;
  11892. t['sevencircle'] = 0x2466;
  11893. t['sevencircleinversesansserif'] = 0x2790;
  11894. t['sevendeva'] = 0x096D;
  11895. t['seveneighths'] = 0x215E;
  11896. t['sevengujarati'] = 0x0AED;
  11897. t['sevengurmukhi'] = 0x0A6D;
  11898. t['sevenhackarabic'] = 0x0667;
  11899. t['sevenhangzhou'] = 0x3027;
  11900. t['sevenideographicparen'] = 0x3226;
  11901. t['seveninferior'] = 0x2087;
  11902. t['sevenmonospace'] = 0xFF17;
  11903. t['sevenoldstyle'] = 0xF737;
  11904. t['sevenparen'] = 0x247A;
  11905. t['sevenperiod'] = 0x248E;
  11906. t['sevenpersian'] = 0x06F7;
  11907. t['sevenroman'] = 0x2176;
  11908. t['sevensuperior'] = 0x2077;
  11909. t['seventeencircle'] = 0x2470;
  11910. t['seventeenparen'] = 0x2484;
  11911. t['seventeenperiod'] = 0x2498;
  11912. t['seventhai'] = 0x0E57;
  11913. t['sfthyphen'] = 0x00AD;
  11914. t['shaarmenian'] = 0x0577;
  11915. t['shabengali'] = 0x09B6;
  11916. t['shacyrillic'] = 0x0448;
  11917. t['shaddaarabic'] = 0x0651;
  11918. t['shaddadammaarabic'] = 0xFC61;
  11919. t['shaddadammatanarabic'] = 0xFC5E;
  11920. t['shaddafathaarabic'] = 0xFC60;
  11921. t['shaddakasraarabic'] = 0xFC62;
  11922. t['shaddakasratanarabic'] = 0xFC5F;
  11923. t['shade'] = 0x2592;
  11924. t['shadedark'] = 0x2593;
  11925. t['shadelight'] = 0x2591;
  11926. t['shademedium'] = 0x2592;
  11927. t['shadeva'] = 0x0936;
  11928. t['shagujarati'] = 0x0AB6;
  11929. t['shagurmukhi'] = 0x0A36;
  11930. t['shalshelethebrew'] = 0x0593;
  11931. t['shbopomofo'] = 0x3115;
  11932. t['shchacyrillic'] = 0x0449;
  11933. t['sheenarabic'] = 0x0634;
  11934. t['sheenfinalarabic'] = 0xFEB6;
  11935. t['sheeninitialarabic'] = 0xFEB7;
  11936. t['sheenmedialarabic'] = 0xFEB8;
  11937. t['sheicoptic'] = 0x03E3;
  11938. t['sheqel'] = 0x20AA;
  11939. t['sheqelhebrew'] = 0x20AA;
  11940. t['sheva'] = 0x05B0;
  11941. t['sheva115'] = 0x05B0;
  11942. t['sheva15'] = 0x05B0;
  11943. t['sheva22'] = 0x05B0;
  11944. t['sheva2e'] = 0x05B0;
  11945. t['shevahebrew'] = 0x05B0;
  11946. t['shevanarrowhebrew'] = 0x05B0;
  11947. t['shevaquarterhebrew'] = 0x05B0;
  11948. t['shevawidehebrew'] = 0x05B0;
  11949. t['shhacyrillic'] = 0x04BB;
  11950. t['shimacoptic'] = 0x03ED;
  11951. t['shin'] = 0x05E9;
  11952. t['shindagesh'] = 0xFB49;
  11953. t['shindageshhebrew'] = 0xFB49;
  11954. t['shindageshshindot'] = 0xFB2C;
  11955. t['shindageshshindothebrew'] = 0xFB2C;
  11956. t['shindageshsindot'] = 0xFB2D;
  11957. t['shindageshsindothebrew'] = 0xFB2D;
  11958. t['shindothebrew'] = 0x05C1;
  11959. t['shinhebrew'] = 0x05E9;
  11960. t['shinshindot'] = 0xFB2A;
  11961. t['shinshindothebrew'] = 0xFB2A;
  11962. t['shinsindot'] = 0xFB2B;
  11963. t['shinsindothebrew'] = 0xFB2B;
  11964. t['shook'] = 0x0282;
  11965. t['sigma'] = 0x03C3;
  11966. t['sigma1'] = 0x03C2;
  11967. t['sigmafinal'] = 0x03C2;
  11968. t['sigmalunatesymbolgreek'] = 0x03F2;
  11969. t['sihiragana'] = 0x3057;
  11970. t['sikatakana'] = 0x30B7;
  11971. t['sikatakanahalfwidth'] = 0xFF7C;
  11972. t['siluqhebrew'] = 0x05BD;
  11973. t['siluqlefthebrew'] = 0x05BD;
  11974. t['similar'] = 0x223C;
  11975. t['sindothebrew'] = 0x05C2;
  11976. t['siosacirclekorean'] = 0x3274;
  11977. t['siosaparenkorean'] = 0x3214;
  11978. t['sioscieuckorean'] = 0x317E;
  11979. t['sioscirclekorean'] = 0x3266;
  11980. t['sioskiyeokkorean'] = 0x317A;
  11981. t['sioskorean'] = 0x3145;
  11982. t['siosnieunkorean'] = 0x317B;
  11983. t['siosparenkorean'] = 0x3206;
  11984. t['siospieupkorean'] = 0x317D;
  11985. t['siostikeutkorean'] = 0x317C;
  11986. t['six'] = 0x0036;
  11987. t['sixarabic'] = 0x0666;
  11988. t['sixbengali'] = 0x09EC;
  11989. t['sixcircle'] = 0x2465;
  11990. t['sixcircleinversesansserif'] = 0x278F;
  11991. t['sixdeva'] = 0x096C;
  11992. t['sixgujarati'] = 0x0AEC;
  11993. t['sixgurmukhi'] = 0x0A6C;
  11994. t['sixhackarabic'] = 0x0666;
  11995. t['sixhangzhou'] = 0x3026;
  11996. t['sixideographicparen'] = 0x3225;
  11997. t['sixinferior'] = 0x2086;
  11998. t['sixmonospace'] = 0xFF16;
  11999. t['sixoldstyle'] = 0xF736;
  12000. t['sixparen'] = 0x2479;
  12001. t['sixperiod'] = 0x248D;
  12002. t['sixpersian'] = 0x06F6;
  12003. t['sixroman'] = 0x2175;
  12004. t['sixsuperior'] = 0x2076;
  12005. t['sixteencircle'] = 0x246F;
  12006. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12007. t['sixteenparen'] = 0x2483;
  12008. t['sixteenperiod'] = 0x2497;
  12009. t['sixthai'] = 0x0E56;
  12010. t['slash'] = 0x002F;
  12011. t['slashmonospace'] = 0xFF0F;
  12012. t['slong'] = 0x017F;
  12013. t['slongdotaccent'] = 0x1E9B;
  12014. t['smileface'] = 0x263A;
  12015. t['smonospace'] = 0xFF53;
  12016. t['sofpasuqhebrew'] = 0x05C3;
  12017. t['softhyphen'] = 0x00AD;
  12018. t['softsigncyrillic'] = 0x044C;
  12019. t['sohiragana'] = 0x305D;
  12020. t['sokatakana'] = 0x30BD;
  12021. t['sokatakanahalfwidth'] = 0xFF7F;
  12022. t['soliduslongoverlaycmb'] = 0x0338;
  12023. t['solidusshortoverlaycmb'] = 0x0337;
  12024. t['sorusithai'] = 0x0E29;
  12025. t['sosalathai'] = 0x0E28;
  12026. t['sosothai'] = 0x0E0B;
  12027. t['sosuathai'] = 0x0E2A;
  12028. t['space'] = 0x0020;
  12029. t['spacehackarabic'] = 0x0020;
  12030. t['spade'] = 0x2660;
  12031. t['spadesuitblack'] = 0x2660;
  12032. t['spadesuitwhite'] = 0x2664;
  12033. t['sparen'] = 0x24AE;
  12034. t['squarebelowcmb'] = 0x033B;
  12035. t['squarecc'] = 0x33C4;
  12036. t['squarecm'] = 0x339D;
  12037. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12038. t['squarehorizontalfill'] = 0x25A4;
  12039. t['squarekg'] = 0x338F;
  12040. t['squarekm'] = 0x339E;
  12041. t['squarekmcapital'] = 0x33CE;
  12042. t['squareln'] = 0x33D1;
  12043. t['squarelog'] = 0x33D2;
  12044. t['squaremg'] = 0x338E;
  12045. t['squaremil'] = 0x33D5;
  12046. t['squaremm'] = 0x339C;
  12047. t['squaremsquared'] = 0x33A1;
  12048. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12049. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12050. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12051. t['squareverticalfill'] = 0x25A5;
  12052. t['squarewhitewithsmallblack'] = 0x25A3;
  12053. t['srsquare'] = 0x33DB;
  12054. t['ssabengali'] = 0x09B7;
  12055. t['ssadeva'] = 0x0937;
  12056. t['ssagujarati'] = 0x0AB7;
  12057. t['ssangcieuckorean'] = 0x3149;
  12058. t['ssanghieuhkorean'] = 0x3185;
  12059. t['ssangieungkorean'] = 0x3180;
  12060. t['ssangkiyeokkorean'] = 0x3132;
  12061. t['ssangnieunkorean'] = 0x3165;
  12062. t['ssangpieupkorean'] = 0x3143;
  12063. t['ssangsioskorean'] = 0x3146;
  12064. t['ssangtikeutkorean'] = 0x3138;
  12065. t['ssuperior'] = 0xF6F2;
  12066. t['sterling'] = 0x00A3;
  12067. t['sterlingmonospace'] = 0xFFE1;
  12068. t['strokelongoverlaycmb'] = 0x0336;
  12069. t['strokeshortoverlaycmb'] = 0x0335;
  12070. t['subset'] = 0x2282;
  12071. t['subsetnotequal'] = 0x228A;
  12072. t['subsetorequal'] = 0x2286;
  12073. t['succeeds'] = 0x227B;
  12074. t['suchthat'] = 0x220B;
  12075. t['suhiragana'] = 0x3059;
  12076. t['sukatakana'] = 0x30B9;
  12077. t['sukatakanahalfwidth'] = 0xFF7D;
  12078. t['sukunarabic'] = 0x0652;
  12079. t['summation'] = 0x2211;
  12080. t['sun'] = 0x263C;
  12081. t['superset'] = 0x2283;
  12082. t['supersetnotequal'] = 0x228B;
  12083. t['supersetorequal'] = 0x2287;
  12084. t['svsquare'] = 0x33DC;
  12085. t['syouwaerasquare'] = 0x337C;
  12086. t['t'] = 0x0074;
  12087. t['tabengali'] = 0x09A4;
  12088. t['tackdown'] = 0x22A4;
  12089. t['tackleft'] = 0x22A3;
  12090. t['tadeva'] = 0x0924;
  12091. t['tagujarati'] = 0x0AA4;
  12092. t['tagurmukhi'] = 0x0A24;
  12093. t['taharabic'] = 0x0637;
  12094. t['tahfinalarabic'] = 0xFEC2;
  12095. t['tahinitialarabic'] = 0xFEC3;
  12096. t['tahiragana'] = 0x305F;
  12097. t['tahmedialarabic'] = 0xFEC4;
  12098. t['taisyouerasquare'] = 0x337D;
  12099. t['takatakana'] = 0x30BF;
  12100. t['takatakanahalfwidth'] = 0xFF80;
  12101. t['tatweelarabic'] = 0x0640;
  12102. t['tau'] = 0x03C4;
  12103. t['tav'] = 0x05EA;
  12104. t['tavdages'] = 0xFB4A;
  12105. t['tavdagesh'] = 0xFB4A;
  12106. t['tavdageshhebrew'] = 0xFB4A;
  12107. t['tavhebrew'] = 0x05EA;
  12108. t['tbar'] = 0x0167;
  12109. t['tbopomofo'] = 0x310A;
  12110. t['tcaron'] = 0x0165;
  12111. t['tccurl'] = 0x02A8;
  12112. t['tcedilla'] = 0x0163;
  12113. t['tcheharabic'] = 0x0686;
  12114. t['tchehfinalarabic'] = 0xFB7B;
  12115. t['tchehinitialarabic'] = 0xFB7C;
  12116. t['tchehmedialarabic'] = 0xFB7D;
  12117. t['tcircle'] = 0x24E3;
  12118. t['tcircumflexbelow'] = 0x1E71;
  12119. t['tcommaaccent'] = 0x0163;
  12120. t['tdieresis'] = 0x1E97;
  12121. t['tdotaccent'] = 0x1E6B;
  12122. t['tdotbelow'] = 0x1E6D;
  12123. t['tecyrillic'] = 0x0442;
  12124. t['tedescendercyrillic'] = 0x04AD;
  12125. t['teharabic'] = 0x062A;
  12126. t['tehfinalarabic'] = 0xFE96;
  12127. t['tehhahinitialarabic'] = 0xFCA2;
  12128. t['tehhahisolatedarabic'] = 0xFC0C;
  12129. t['tehinitialarabic'] = 0xFE97;
  12130. t['tehiragana'] = 0x3066;
  12131. t['tehjeeminitialarabic'] = 0xFCA1;
  12132. t['tehjeemisolatedarabic'] = 0xFC0B;
  12133. t['tehmarbutaarabic'] = 0x0629;
  12134. t['tehmarbutafinalarabic'] = 0xFE94;
  12135. t['tehmedialarabic'] = 0xFE98;
  12136. t['tehmeeminitialarabic'] = 0xFCA4;
  12137. t['tehmeemisolatedarabic'] = 0xFC0E;
  12138. t['tehnoonfinalarabic'] = 0xFC73;
  12139. t['tekatakana'] = 0x30C6;
  12140. t['tekatakanahalfwidth'] = 0xFF83;
  12141. t['telephone'] = 0x2121;
  12142. t['telephoneblack'] = 0x260E;
  12143. t['telishagedolahebrew'] = 0x05A0;
  12144. t['telishaqetanahebrew'] = 0x05A9;
  12145. t['tencircle'] = 0x2469;
  12146. t['tenideographicparen'] = 0x3229;
  12147. t['tenparen'] = 0x247D;
  12148. t['tenperiod'] = 0x2491;
  12149. t['tenroman'] = 0x2179;
  12150. t['tesh'] = 0x02A7;
  12151. t['tet'] = 0x05D8;
  12152. t['tetdagesh'] = 0xFB38;
  12153. t['tetdageshhebrew'] = 0xFB38;
  12154. t['tethebrew'] = 0x05D8;
  12155. t['tetsecyrillic'] = 0x04B5;
  12156. t['tevirhebrew'] = 0x059B;
  12157. t['tevirlefthebrew'] = 0x059B;
  12158. t['thabengali'] = 0x09A5;
  12159. t['thadeva'] = 0x0925;
  12160. t['thagujarati'] = 0x0AA5;
  12161. t['thagurmukhi'] = 0x0A25;
  12162. t['thalarabic'] = 0x0630;
  12163. t['thalfinalarabic'] = 0xFEAC;
  12164. t['thanthakhatlowleftthai'] = 0xF898;
  12165. t['thanthakhatlowrightthai'] = 0xF897;
  12166. t['thanthakhatthai'] = 0x0E4C;
  12167. t['thanthakhatupperleftthai'] = 0xF896;
  12168. t['theharabic'] = 0x062B;
  12169. t['thehfinalarabic'] = 0xFE9A;
  12170. t['thehinitialarabic'] = 0xFE9B;
  12171. t['thehmedialarabic'] = 0xFE9C;
  12172. t['thereexists'] = 0x2203;
  12173. t['therefore'] = 0x2234;
  12174. t['theta'] = 0x03B8;
  12175. t['theta1'] = 0x03D1;
  12176. t['thetasymbolgreek'] = 0x03D1;
  12177. t['thieuthacirclekorean'] = 0x3279;
  12178. t['thieuthaparenkorean'] = 0x3219;
  12179. t['thieuthcirclekorean'] = 0x326B;
  12180. t['thieuthkorean'] = 0x314C;
  12181. t['thieuthparenkorean'] = 0x320B;
  12182. t['thirteencircle'] = 0x246C;
  12183. t['thirteenparen'] = 0x2480;
  12184. t['thirteenperiod'] = 0x2494;
  12185. t['thonangmonthothai'] = 0x0E11;
  12186. t['thook'] = 0x01AD;
  12187. t['thophuthaothai'] = 0x0E12;
  12188. t['thorn'] = 0x00FE;
  12189. t['thothahanthai'] = 0x0E17;
  12190. t['thothanthai'] = 0x0E10;
  12191. t['thothongthai'] = 0x0E18;
  12192. t['thothungthai'] = 0x0E16;
  12193. t['thousandcyrillic'] = 0x0482;
  12194. t['thousandsseparatorarabic'] = 0x066C;
  12195. t['thousandsseparatorpersian'] = 0x066C;
  12196. t['three'] = 0x0033;
  12197. t['threearabic'] = 0x0663;
  12198. t['threebengali'] = 0x09E9;
  12199. t['threecircle'] = 0x2462;
  12200. t['threecircleinversesansserif'] = 0x278C;
  12201. t['threedeva'] = 0x0969;
  12202. t['threeeighths'] = 0x215C;
  12203. t['threegujarati'] = 0x0AE9;
  12204. t['threegurmukhi'] = 0x0A69;
  12205. t['threehackarabic'] = 0x0663;
  12206. t['threehangzhou'] = 0x3023;
  12207. t['threeideographicparen'] = 0x3222;
  12208. t['threeinferior'] = 0x2083;
  12209. t['threemonospace'] = 0xFF13;
  12210. t['threenumeratorbengali'] = 0x09F6;
  12211. t['threeoldstyle'] = 0xF733;
  12212. t['threeparen'] = 0x2476;
  12213. t['threeperiod'] = 0x248A;
  12214. t['threepersian'] = 0x06F3;
  12215. t['threequarters'] = 0x00BE;
  12216. t['threequartersemdash'] = 0xF6DE;
  12217. t['threeroman'] = 0x2172;
  12218. t['threesuperior'] = 0x00B3;
  12219. t['threethai'] = 0x0E53;
  12220. t['thzsquare'] = 0x3394;
  12221. t['tihiragana'] = 0x3061;
  12222. t['tikatakana'] = 0x30C1;
  12223. t['tikatakanahalfwidth'] = 0xFF81;
  12224. t['tikeutacirclekorean'] = 0x3270;
  12225. t['tikeutaparenkorean'] = 0x3210;
  12226. t['tikeutcirclekorean'] = 0x3262;
  12227. t['tikeutkorean'] = 0x3137;
  12228. t['tikeutparenkorean'] = 0x3202;
  12229. t['tilde'] = 0x02DC;
  12230. t['tildebelowcmb'] = 0x0330;
  12231. t['tildecmb'] = 0x0303;
  12232. t['tildecomb'] = 0x0303;
  12233. t['tildedoublecmb'] = 0x0360;
  12234. t['tildeoperator'] = 0x223C;
  12235. t['tildeoverlaycmb'] = 0x0334;
  12236. t['tildeverticalcmb'] = 0x033E;
  12237. t['timescircle'] = 0x2297;
  12238. t['tipehahebrew'] = 0x0596;
  12239. t['tipehalefthebrew'] = 0x0596;
  12240. t['tippigurmukhi'] = 0x0A70;
  12241. t['titlocyrilliccmb'] = 0x0483;
  12242. t['tiwnarmenian'] = 0x057F;
  12243. t['tlinebelow'] = 0x1E6F;
  12244. t['tmonospace'] = 0xFF54;
  12245. t['toarmenian'] = 0x0569;
  12246. t['tohiragana'] = 0x3068;
  12247. t['tokatakana'] = 0x30C8;
  12248. t['tokatakanahalfwidth'] = 0xFF84;
  12249. t['tonebarextrahighmod'] = 0x02E5;
  12250. t['tonebarextralowmod'] = 0x02E9;
  12251. t['tonebarhighmod'] = 0x02E6;
  12252. t['tonebarlowmod'] = 0x02E8;
  12253. t['tonebarmidmod'] = 0x02E7;
  12254. t['tonefive'] = 0x01BD;
  12255. t['tonesix'] = 0x0185;
  12256. t['tonetwo'] = 0x01A8;
  12257. t['tonos'] = 0x0384;
  12258. t['tonsquare'] = 0x3327;
  12259. t['topatakthai'] = 0x0E0F;
  12260. t['tortoiseshellbracketleft'] = 0x3014;
  12261. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12262. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12263. t['tortoiseshellbracketright'] = 0x3015;
  12264. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12265. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12266. t['totaothai'] = 0x0E15;
  12267. t['tpalatalhook'] = 0x01AB;
  12268. t['tparen'] = 0x24AF;
  12269. t['trademark'] = 0x2122;
  12270. t['trademarksans'] = 0xF8EA;
  12271. t['trademarkserif'] = 0xF6DB;
  12272. t['tretroflexhook'] = 0x0288;
  12273. t['triagdn'] = 0x25BC;
  12274. t['triaglf'] = 0x25C4;
  12275. t['triagrt'] = 0x25BA;
  12276. t['triagup'] = 0x25B2;
  12277. t['ts'] = 0x02A6;
  12278. t['tsadi'] = 0x05E6;
  12279. t['tsadidagesh'] = 0xFB46;
  12280. t['tsadidageshhebrew'] = 0xFB46;
  12281. t['tsadihebrew'] = 0x05E6;
  12282. t['tsecyrillic'] = 0x0446;
  12283. t['tsere'] = 0x05B5;
  12284. t['tsere12'] = 0x05B5;
  12285. t['tsere1e'] = 0x05B5;
  12286. t['tsere2b'] = 0x05B5;
  12287. t['tserehebrew'] = 0x05B5;
  12288. t['tserenarrowhebrew'] = 0x05B5;
  12289. t['tserequarterhebrew'] = 0x05B5;
  12290. t['tserewidehebrew'] = 0x05B5;
  12291. t['tshecyrillic'] = 0x045B;
  12292. t['tsuperior'] = 0xF6F3;
  12293. t['ttabengali'] = 0x099F;
  12294. t['ttadeva'] = 0x091F;
  12295. t['ttagujarati'] = 0x0A9F;
  12296. t['ttagurmukhi'] = 0x0A1F;
  12297. t['tteharabic'] = 0x0679;
  12298. t['ttehfinalarabic'] = 0xFB67;
  12299. t['ttehinitialarabic'] = 0xFB68;
  12300. t['ttehmedialarabic'] = 0xFB69;
  12301. t['tthabengali'] = 0x09A0;
  12302. t['tthadeva'] = 0x0920;
  12303. t['tthagujarati'] = 0x0AA0;
  12304. t['tthagurmukhi'] = 0x0A20;
  12305. t['tturned'] = 0x0287;
  12306. t['tuhiragana'] = 0x3064;
  12307. t['tukatakana'] = 0x30C4;
  12308. t['tukatakanahalfwidth'] = 0xFF82;
  12309. t['tusmallhiragana'] = 0x3063;
  12310. t['tusmallkatakana'] = 0x30C3;
  12311. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12312. t['twelvecircle'] = 0x246B;
  12313. t['twelveparen'] = 0x247F;
  12314. t['twelveperiod'] = 0x2493;
  12315. t['twelveroman'] = 0x217B;
  12316. t['twentycircle'] = 0x2473;
  12317. t['twentyhangzhou'] = 0x5344;
  12318. t['twentyparen'] = 0x2487;
  12319. t['twentyperiod'] = 0x249B;
  12320. t['two'] = 0x0032;
  12321. t['twoarabic'] = 0x0662;
  12322. t['twobengali'] = 0x09E8;
  12323. t['twocircle'] = 0x2461;
  12324. t['twocircleinversesansserif'] = 0x278B;
  12325. t['twodeva'] = 0x0968;
  12326. t['twodotenleader'] = 0x2025;
  12327. t['twodotleader'] = 0x2025;
  12328. t['twodotleadervertical'] = 0xFE30;
  12329. t['twogujarati'] = 0x0AE8;
  12330. t['twogurmukhi'] = 0x0A68;
  12331. t['twohackarabic'] = 0x0662;
  12332. t['twohangzhou'] = 0x3022;
  12333. t['twoideographicparen'] = 0x3221;
  12334. t['twoinferior'] = 0x2082;
  12335. t['twomonospace'] = 0xFF12;
  12336. t['twonumeratorbengali'] = 0x09F5;
  12337. t['twooldstyle'] = 0xF732;
  12338. t['twoparen'] = 0x2475;
  12339. t['twoperiod'] = 0x2489;
  12340. t['twopersian'] = 0x06F2;
  12341. t['tworoman'] = 0x2171;
  12342. t['twostroke'] = 0x01BB;
  12343. t['twosuperior'] = 0x00B2;
  12344. t['twothai'] = 0x0E52;
  12345. t['twothirds'] = 0x2154;
  12346. t['u'] = 0x0075;
  12347. t['uacute'] = 0x00FA;
  12348. t['ubar'] = 0x0289;
  12349. t['ubengali'] = 0x0989;
  12350. t['ubopomofo'] = 0x3128;
  12351. t['ubreve'] = 0x016D;
  12352. t['ucaron'] = 0x01D4;
  12353. t['ucircle'] = 0x24E4;
  12354. t['ucircumflex'] = 0x00FB;
  12355. t['ucircumflexbelow'] = 0x1E77;
  12356. t['ucyrillic'] = 0x0443;
  12357. t['udattadeva'] = 0x0951;
  12358. t['udblacute'] = 0x0171;
  12359. t['udblgrave'] = 0x0215;
  12360. t['udeva'] = 0x0909;
  12361. t['udieresis'] = 0x00FC;
  12362. t['udieresisacute'] = 0x01D8;
  12363. t['udieresisbelow'] = 0x1E73;
  12364. t['udieresiscaron'] = 0x01DA;
  12365. t['udieresiscyrillic'] = 0x04F1;
  12366. t['udieresisgrave'] = 0x01DC;
  12367. t['udieresismacron'] = 0x01D6;
  12368. t['udotbelow'] = 0x1EE5;
  12369. t['ugrave'] = 0x00F9;
  12370. t['ugujarati'] = 0x0A89;
  12371. t['ugurmukhi'] = 0x0A09;
  12372. t['uhiragana'] = 0x3046;
  12373. t['uhookabove'] = 0x1EE7;
  12374. t['uhorn'] = 0x01B0;
  12375. t['uhornacute'] = 0x1EE9;
  12376. t['uhorndotbelow'] = 0x1EF1;
  12377. t['uhorngrave'] = 0x1EEB;
  12378. t['uhornhookabove'] = 0x1EED;
  12379. t['uhorntilde'] = 0x1EEF;
  12380. t['uhungarumlaut'] = 0x0171;
  12381. t['uhungarumlautcyrillic'] = 0x04F3;
  12382. t['uinvertedbreve'] = 0x0217;
  12383. t['ukatakana'] = 0x30A6;
  12384. t['ukatakanahalfwidth'] = 0xFF73;
  12385. t['ukcyrillic'] = 0x0479;
  12386. t['ukorean'] = 0x315C;
  12387. t['umacron'] = 0x016B;
  12388. t['umacroncyrillic'] = 0x04EF;
  12389. t['umacrondieresis'] = 0x1E7B;
  12390. t['umatragurmukhi'] = 0x0A41;
  12391. t['umonospace'] = 0xFF55;
  12392. t['underscore'] = 0x005F;
  12393. t['underscoredbl'] = 0x2017;
  12394. t['underscoremonospace'] = 0xFF3F;
  12395. t['underscorevertical'] = 0xFE33;
  12396. t['underscorewavy'] = 0xFE4F;
  12397. t['union'] = 0x222A;
  12398. t['universal'] = 0x2200;
  12399. t['uogonek'] = 0x0173;
  12400. t['uparen'] = 0x24B0;
  12401. t['upblock'] = 0x2580;
  12402. t['upperdothebrew'] = 0x05C4;
  12403. t['upsilon'] = 0x03C5;
  12404. t['upsilondieresis'] = 0x03CB;
  12405. t['upsilondieresistonos'] = 0x03B0;
  12406. t['upsilonlatin'] = 0x028A;
  12407. t['upsilontonos'] = 0x03CD;
  12408. t['uptackbelowcmb'] = 0x031D;
  12409. t['uptackmod'] = 0x02D4;
  12410. t['uragurmukhi'] = 0x0A73;
  12411. t['uring'] = 0x016F;
  12412. t['ushortcyrillic'] = 0x045E;
  12413. t['usmallhiragana'] = 0x3045;
  12414. t['usmallkatakana'] = 0x30A5;
  12415. t['usmallkatakanahalfwidth'] = 0xFF69;
  12416. t['ustraightcyrillic'] = 0x04AF;
  12417. t['ustraightstrokecyrillic'] = 0x04B1;
  12418. t['utilde'] = 0x0169;
  12419. t['utildeacute'] = 0x1E79;
  12420. t['utildebelow'] = 0x1E75;
  12421. t['uubengali'] = 0x098A;
  12422. t['uudeva'] = 0x090A;
  12423. t['uugujarati'] = 0x0A8A;
  12424. t['uugurmukhi'] = 0x0A0A;
  12425. t['uumatragurmukhi'] = 0x0A42;
  12426. t['uuvowelsignbengali'] = 0x09C2;
  12427. t['uuvowelsigndeva'] = 0x0942;
  12428. t['uuvowelsigngujarati'] = 0x0AC2;
  12429. t['uvowelsignbengali'] = 0x09C1;
  12430. t['uvowelsigndeva'] = 0x0941;
  12431. t['uvowelsigngujarati'] = 0x0AC1;
  12432. t['v'] = 0x0076;
  12433. t['vadeva'] = 0x0935;
  12434. t['vagujarati'] = 0x0AB5;
  12435. t['vagurmukhi'] = 0x0A35;
  12436. t['vakatakana'] = 0x30F7;
  12437. t['vav'] = 0x05D5;
  12438. t['vavdagesh'] = 0xFB35;
  12439. t['vavdagesh65'] = 0xFB35;
  12440. t['vavdageshhebrew'] = 0xFB35;
  12441. t['vavhebrew'] = 0x05D5;
  12442. t['vavholam'] = 0xFB4B;
  12443. t['vavholamhebrew'] = 0xFB4B;
  12444. t['vavvavhebrew'] = 0x05F0;
  12445. t['vavyodhebrew'] = 0x05F1;
  12446. t['vcircle'] = 0x24E5;
  12447. t['vdotbelow'] = 0x1E7F;
  12448. t['vecyrillic'] = 0x0432;
  12449. t['veharabic'] = 0x06A4;
  12450. t['vehfinalarabic'] = 0xFB6B;
  12451. t['vehinitialarabic'] = 0xFB6C;
  12452. t['vehmedialarabic'] = 0xFB6D;
  12453. t['vekatakana'] = 0x30F9;
  12454. t['venus'] = 0x2640;
  12455. t['verticalbar'] = 0x007C;
  12456. t['verticallineabovecmb'] = 0x030D;
  12457. t['verticallinebelowcmb'] = 0x0329;
  12458. t['verticallinelowmod'] = 0x02CC;
  12459. t['verticallinemod'] = 0x02C8;
  12460. t['vewarmenian'] = 0x057E;
  12461. t['vhook'] = 0x028B;
  12462. t['vikatakana'] = 0x30F8;
  12463. t['viramabengali'] = 0x09CD;
  12464. t['viramadeva'] = 0x094D;
  12465. t['viramagujarati'] = 0x0ACD;
  12466. t['visargabengali'] = 0x0983;
  12467. t['visargadeva'] = 0x0903;
  12468. t['visargagujarati'] = 0x0A83;
  12469. t['vmonospace'] = 0xFF56;
  12470. t['voarmenian'] = 0x0578;
  12471. t['voicediterationhiragana'] = 0x309E;
  12472. t['voicediterationkatakana'] = 0x30FE;
  12473. t['voicedmarkkana'] = 0x309B;
  12474. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12475. t['vokatakana'] = 0x30FA;
  12476. t['vparen'] = 0x24B1;
  12477. t['vtilde'] = 0x1E7D;
  12478. t['vturned'] = 0x028C;
  12479. t['vuhiragana'] = 0x3094;
  12480. t['vukatakana'] = 0x30F4;
  12481. t['w'] = 0x0077;
  12482. t['wacute'] = 0x1E83;
  12483. t['waekorean'] = 0x3159;
  12484. t['wahiragana'] = 0x308F;
  12485. t['wakatakana'] = 0x30EF;
  12486. t['wakatakanahalfwidth'] = 0xFF9C;
  12487. t['wakorean'] = 0x3158;
  12488. t['wasmallhiragana'] = 0x308E;
  12489. t['wasmallkatakana'] = 0x30EE;
  12490. t['wattosquare'] = 0x3357;
  12491. t['wavedash'] = 0x301C;
  12492. t['wavyunderscorevertical'] = 0xFE34;
  12493. t['wawarabic'] = 0x0648;
  12494. t['wawfinalarabic'] = 0xFEEE;
  12495. t['wawhamzaabovearabic'] = 0x0624;
  12496. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12497. t['wbsquare'] = 0x33DD;
  12498. t['wcircle'] = 0x24E6;
  12499. t['wcircumflex'] = 0x0175;
  12500. t['wdieresis'] = 0x1E85;
  12501. t['wdotaccent'] = 0x1E87;
  12502. t['wdotbelow'] = 0x1E89;
  12503. t['wehiragana'] = 0x3091;
  12504. t['weierstrass'] = 0x2118;
  12505. t['wekatakana'] = 0x30F1;
  12506. t['wekorean'] = 0x315E;
  12507. t['weokorean'] = 0x315D;
  12508. t['wgrave'] = 0x1E81;
  12509. t['whitebullet'] = 0x25E6;
  12510. t['whitecircle'] = 0x25CB;
  12511. t['whitecircleinverse'] = 0x25D9;
  12512. t['whitecornerbracketleft'] = 0x300E;
  12513. t['whitecornerbracketleftvertical'] = 0xFE43;
  12514. t['whitecornerbracketright'] = 0x300F;
  12515. t['whitecornerbracketrightvertical'] = 0xFE44;
  12516. t['whitediamond'] = 0x25C7;
  12517. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12518. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12519. t['whitedownpointingtriangle'] = 0x25BD;
  12520. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12521. t['whiteleftpointingtriangle'] = 0x25C1;
  12522. t['whitelenticularbracketleft'] = 0x3016;
  12523. t['whitelenticularbracketright'] = 0x3017;
  12524. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12525. t['whiterightpointingtriangle'] = 0x25B7;
  12526. t['whitesmallsquare'] = 0x25AB;
  12527. t['whitesmilingface'] = 0x263A;
  12528. t['whitesquare'] = 0x25A1;
  12529. t['whitestar'] = 0x2606;
  12530. t['whitetelephone'] = 0x260F;
  12531. t['whitetortoiseshellbracketleft'] = 0x3018;
  12532. t['whitetortoiseshellbracketright'] = 0x3019;
  12533. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12534. t['whiteuppointingtriangle'] = 0x25B3;
  12535. t['wihiragana'] = 0x3090;
  12536. t['wikatakana'] = 0x30F0;
  12537. t['wikorean'] = 0x315F;
  12538. t['wmonospace'] = 0xFF57;
  12539. t['wohiragana'] = 0x3092;
  12540. t['wokatakana'] = 0x30F2;
  12541. t['wokatakanahalfwidth'] = 0xFF66;
  12542. t['won'] = 0x20A9;
  12543. t['wonmonospace'] = 0xFFE6;
  12544. t['wowaenthai'] = 0x0E27;
  12545. t['wparen'] = 0x24B2;
  12546. t['wring'] = 0x1E98;
  12547. t['wsuperior'] = 0x02B7;
  12548. t['wturned'] = 0x028D;
  12549. t['wynn'] = 0x01BF;
  12550. t['x'] = 0x0078;
  12551. t['xabovecmb'] = 0x033D;
  12552. t['xbopomofo'] = 0x3112;
  12553. t['xcircle'] = 0x24E7;
  12554. t['xdieresis'] = 0x1E8D;
  12555. t['xdotaccent'] = 0x1E8B;
  12556. t['xeharmenian'] = 0x056D;
  12557. t['xi'] = 0x03BE;
  12558. t['xmonospace'] = 0xFF58;
  12559. t['xparen'] = 0x24B3;
  12560. t['xsuperior'] = 0x02E3;
  12561. t['y'] = 0x0079;
  12562. t['yaadosquare'] = 0x334E;
  12563. t['yabengali'] = 0x09AF;
  12564. t['yacute'] = 0x00FD;
  12565. t['yadeva'] = 0x092F;
  12566. t['yaekorean'] = 0x3152;
  12567. t['yagujarati'] = 0x0AAF;
  12568. t['yagurmukhi'] = 0x0A2F;
  12569. t['yahiragana'] = 0x3084;
  12570. t['yakatakana'] = 0x30E4;
  12571. t['yakatakanahalfwidth'] = 0xFF94;
  12572. t['yakorean'] = 0x3151;
  12573. t['yamakkanthai'] = 0x0E4E;
  12574. t['yasmallhiragana'] = 0x3083;
  12575. t['yasmallkatakana'] = 0x30E3;
  12576. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12577. t['yatcyrillic'] = 0x0463;
  12578. t['ycircle'] = 0x24E8;
  12579. t['ycircumflex'] = 0x0177;
  12580. t['ydieresis'] = 0x00FF;
  12581. t['ydotaccent'] = 0x1E8F;
  12582. t['ydotbelow'] = 0x1EF5;
  12583. t['yeharabic'] = 0x064A;
  12584. t['yehbarreearabic'] = 0x06D2;
  12585. t['yehbarreefinalarabic'] = 0xFBAF;
  12586. t['yehfinalarabic'] = 0xFEF2;
  12587. t['yehhamzaabovearabic'] = 0x0626;
  12588. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12589. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12590. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12591. t['yehinitialarabic'] = 0xFEF3;
  12592. t['yehmedialarabic'] = 0xFEF4;
  12593. t['yehmeeminitialarabic'] = 0xFCDD;
  12594. t['yehmeemisolatedarabic'] = 0xFC58;
  12595. t['yehnoonfinalarabic'] = 0xFC94;
  12596. t['yehthreedotsbelowarabic'] = 0x06D1;
  12597. t['yekorean'] = 0x3156;
  12598. t['yen'] = 0x00A5;
  12599. t['yenmonospace'] = 0xFFE5;
  12600. t['yeokorean'] = 0x3155;
  12601. t['yeorinhieuhkorean'] = 0x3186;
  12602. t['yerahbenyomohebrew'] = 0x05AA;
  12603. t['yerahbenyomolefthebrew'] = 0x05AA;
  12604. t['yericyrillic'] = 0x044B;
  12605. t['yerudieresiscyrillic'] = 0x04F9;
  12606. t['yesieungkorean'] = 0x3181;
  12607. t['yesieungpansioskorean'] = 0x3183;
  12608. t['yesieungsioskorean'] = 0x3182;
  12609. t['yetivhebrew'] = 0x059A;
  12610. t['ygrave'] = 0x1EF3;
  12611. t['yhook'] = 0x01B4;
  12612. t['yhookabove'] = 0x1EF7;
  12613. t['yiarmenian'] = 0x0575;
  12614. t['yicyrillic'] = 0x0457;
  12615. t['yikorean'] = 0x3162;
  12616. t['yinyang'] = 0x262F;
  12617. t['yiwnarmenian'] = 0x0582;
  12618. t['ymonospace'] = 0xFF59;
  12619. t['yod'] = 0x05D9;
  12620. t['yoddagesh'] = 0xFB39;
  12621. t['yoddageshhebrew'] = 0xFB39;
  12622. t['yodhebrew'] = 0x05D9;
  12623. t['yodyodhebrew'] = 0x05F2;
  12624. t['yodyodpatahhebrew'] = 0xFB1F;
  12625. t['yohiragana'] = 0x3088;
  12626. t['yoikorean'] = 0x3189;
  12627. t['yokatakana'] = 0x30E8;
  12628. t['yokatakanahalfwidth'] = 0xFF96;
  12629. t['yokorean'] = 0x315B;
  12630. t['yosmallhiragana'] = 0x3087;
  12631. t['yosmallkatakana'] = 0x30E7;
  12632. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12633. t['yotgreek'] = 0x03F3;
  12634. t['yoyaekorean'] = 0x3188;
  12635. t['yoyakorean'] = 0x3187;
  12636. t['yoyakthai'] = 0x0E22;
  12637. t['yoyingthai'] = 0x0E0D;
  12638. t['yparen'] = 0x24B4;
  12639. t['ypogegrammeni'] = 0x037A;
  12640. t['ypogegrammenigreekcmb'] = 0x0345;
  12641. t['yr'] = 0x01A6;
  12642. t['yring'] = 0x1E99;
  12643. t['ysuperior'] = 0x02B8;
  12644. t['ytilde'] = 0x1EF9;
  12645. t['yturned'] = 0x028E;
  12646. t['yuhiragana'] = 0x3086;
  12647. t['yuikorean'] = 0x318C;
  12648. t['yukatakana'] = 0x30E6;
  12649. t['yukatakanahalfwidth'] = 0xFF95;
  12650. t['yukorean'] = 0x3160;
  12651. t['yusbigcyrillic'] = 0x046B;
  12652. t['yusbigiotifiedcyrillic'] = 0x046D;
  12653. t['yuslittlecyrillic'] = 0x0467;
  12654. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12655. t['yusmallhiragana'] = 0x3085;
  12656. t['yusmallkatakana'] = 0x30E5;
  12657. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12658. t['yuyekorean'] = 0x318B;
  12659. t['yuyeokorean'] = 0x318A;
  12660. t['yyabengali'] = 0x09DF;
  12661. t['yyadeva'] = 0x095F;
  12662. t['z'] = 0x007A;
  12663. t['zaarmenian'] = 0x0566;
  12664. t['zacute'] = 0x017A;
  12665. t['zadeva'] = 0x095B;
  12666. t['zagurmukhi'] = 0x0A5B;
  12667. t['zaharabic'] = 0x0638;
  12668. t['zahfinalarabic'] = 0xFEC6;
  12669. t['zahinitialarabic'] = 0xFEC7;
  12670. t['zahiragana'] = 0x3056;
  12671. t['zahmedialarabic'] = 0xFEC8;
  12672. t['zainarabic'] = 0x0632;
  12673. t['zainfinalarabic'] = 0xFEB0;
  12674. t['zakatakana'] = 0x30B6;
  12675. t['zaqefgadolhebrew'] = 0x0595;
  12676. t['zaqefqatanhebrew'] = 0x0594;
  12677. t['zarqahebrew'] = 0x0598;
  12678. t['zayin'] = 0x05D6;
  12679. t['zayindagesh'] = 0xFB36;
  12680. t['zayindageshhebrew'] = 0xFB36;
  12681. t['zayinhebrew'] = 0x05D6;
  12682. t['zbopomofo'] = 0x3117;
  12683. t['zcaron'] = 0x017E;
  12684. t['zcircle'] = 0x24E9;
  12685. t['zcircumflex'] = 0x1E91;
  12686. t['zcurl'] = 0x0291;
  12687. t['zdot'] = 0x017C;
  12688. t['zdotaccent'] = 0x017C;
  12689. t['zdotbelow'] = 0x1E93;
  12690. t['zecyrillic'] = 0x0437;
  12691. t['zedescendercyrillic'] = 0x0499;
  12692. t['zedieresiscyrillic'] = 0x04DF;
  12693. t['zehiragana'] = 0x305C;
  12694. t['zekatakana'] = 0x30BC;
  12695. t['zero'] = 0x0030;
  12696. t['zeroarabic'] = 0x0660;
  12697. t['zerobengali'] = 0x09E6;
  12698. t['zerodeva'] = 0x0966;
  12699. t['zerogujarati'] = 0x0AE6;
  12700. t['zerogurmukhi'] = 0x0A66;
  12701. t['zerohackarabic'] = 0x0660;
  12702. t['zeroinferior'] = 0x2080;
  12703. t['zeromonospace'] = 0xFF10;
  12704. t['zerooldstyle'] = 0xF730;
  12705. t['zeropersian'] = 0x06F0;
  12706. t['zerosuperior'] = 0x2070;
  12707. t['zerothai'] = 0x0E50;
  12708. t['zerowidthjoiner'] = 0xFEFF;
  12709. t['zerowidthnonjoiner'] = 0x200C;
  12710. t['zerowidthspace'] = 0x200B;
  12711. t['zeta'] = 0x03B6;
  12712. t['zhbopomofo'] = 0x3113;
  12713. t['zhearmenian'] = 0x056A;
  12714. t['zhebrevecyrillic'] = 0x04C2;
  12715. t['zhecyrillic'] = 0x0436;
  12716. t['zhedescendercyrillic'] = 0x0497;
  12717. t['zhedieresiscyrillic'] = 0x04DD;
  12718. t['zihiragana'] = 0x3058;
  12719. t['zikatakana'] = 0x30B8;
  12720. t['zinorhebrew'] = 0x05AE;
  12721. t['zlinebelow'] = 0x1E95;
  12722. t['zmonospace'] = 0xFF5A;
  12723. t['zohiragana'] = 0x305E;
  12724. t['zokatakana'] = 0x30BE;
  12725. t['zparen'] = 0x24B5;
  12726. t['zretroflexhook'] = 0x0290;
  12727. t['zstroke'] = 0x01B6;
  12728. t['zuhiragana'] = 0x305A;
  12729. t['zukatakana'] = 0x30BA;
  12730. t['.notdef'] = 0x0000;
  12731. });
  12732. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12733. t['space'] = 0x0020;
  12734. t['a1'] = 0x2701;
  12735. t['a2'] = 0x2702;
  12736. t['a202'] = 0x2703;
  12737. t['a3'] = 0x2704;
  12738. t['a4'] = 0x260E;
  12739. t['a5'] = 0x2706;
  12740. t['a119'] = 0x2707;
  12741. t['a118'] = 0x2708;
  12742. t['a117'] = 0x2709;
  12743. t['a11'] = 0x261B;
  12744. t['a12'] = 0x261E;
  12745. t['a13'] = 0x270C;
  12746. t['a14'] = 0x270D;
  12747. t['a15'] = 0x270E;
  12748. t['a16'] = 0x270F;
  12749. t['a105'] = 0x2710;
  12750. t['a17'] = 0x2711;
  12751. t['a18'] = 0x2712;
  12752. t['a19'] = 0x2713;
  12753. t['a20'] = 0x2714;
  12754. t['a21'] = 0x2715;
  12755. t['a22'] = 0x2716;
  12756. t['a23'] = 0x2717;
  12757. t['a24'] = 0x2718;
  12758. t['a25'] = 0x2719;
  12759. t['a26'] = 0x271A;
  12760. t['a27'] = 0x271B;
  12761. t['a28'] = 0x271C;
  12762. t['a6'] = 0x271D;
  12763. t['a7'] = 0x271E;
  12764. t['a8'] = 0x271F;
  12765. t['a9'] = 0x2720;
  12766. t['a10'] = 0x2721;
  12767. t['a29'] = 0x2722;
  12768. t['a30'] = 0x2723;
  12769. t['a31'] = 0x2724;
  12770. t['a32'] = 0x2725;
  12771. t['a33'] = 0x2726;
  12772. t['a34'] = 0x2727;
  12773. t['a35'] = 0x2605;
  12774. t['a36'] = 0x2729;
  12775. t['a37'] = 0x272A;
  12776. t['a38'] = 0x272B;
  12777. t['a39'] = 0x272C;
  12778. t['a40'] = 0x272D;
  12779. t['a41'] = 0x272E;
  12780. t['a42'] = 0x272F;
  12781. t['a43'] = 0x2730;
  12782. t['a44'] = 0x2731;
  12783. t['a45'] = 0x2732;
  12784. t['a46'] = 0x2733;
  12785. t['a47'] = 0x2734;
  12786. t['a48'] = 0x2735;
  12787. t['a49'] = 0x2736;
  12788. t['a50'] = 0x2737;
  12789. t['a51'] = 0x2738;
  12790. t['a52'] = 0x2739;
  12791. t['a53'] = 0x273A;
  12792. t['a54'] = 0x273B;
  12793. t['a55'] = 0x273C;
  12794. t['a56'] = 0x273D;
  12795. t['a57'] = 0x273E;
  12796. t['a58'] = 0x273F;
  12797. t['a59'] = 0x2740;
  12798. t['a60'] = 0x2741;
  12799. t['a61'] = 0x2742;
  12800. t['a62'] = 0x2743;
  12801. t['a63'] = 0x2744;
  12802. t['a64'] = 0x2745;
  12803. t['a65'] = 0x2746;
  12804. t['a66'] = 0x2747;
  12805. t['a67'] = 0x2748;
  12806. t['a68'] = 0x2749;
  12807. t['a69'] = 0x274A;
  12808. t['a70'] = 0x274B;
  12809. t['a71'] = 0x25CF;
  12810. t['a72'] = 0x274D;
  12811. t['a73'] = 0x25A0;
  12812. t['a74'] = 0x274F;
  12813. t['a203'] = 0x2750;
  12814. t['a75'] = 0x2751;
  12815. t['a204'] = 0x2752;
  12816. t['a76'] = 0x25B2;
  12817. t['a77'] = 0x25BC;
  12818. t['a78'] = 0x25C6;
  12819. t['a79'] = 0x2756;
  12820. t['a81'] = 0x25D7;
  12821. t['a82'] = 0x2758;
  12822. t['a83'] = 0x2759;
  12823. t['a84'] = 0x275A;
  12824. t['a97'] = 0x275B;
  12825. t['a98'] = 0x275C;
  12826. t['a99'] = 0x275D;
  12827. t['a100'] = 0x275E;
  12828. t['a101'] = 0x2761;
  12829. t['a102'] = 0x2762;
  12830. t['a103'] = 0x2763;
  12831. t['a104'] = 0x2764;
  12832. t['a106'] = 0x2765;
  12833. t['a107'] = 0x2766;
  12834. t['a108'] = 0x2767;
  12835. t['a112'] = 0x2663;
  12836. t['a111'] = 0x2666;
  12837. t['a110'] = 0x2665;
  12838. t['a109'] = 0x2660;
  12839. t['a120'] = 0x2460;
  12840. t['a121'] = 0x2461;
  12841. t['a122'] = 0x2462;
  12842. t['a123'] = 0x2463;
  12843. t['a124'] = 0x2464;
  12844. t['a125'] = 0x2465;
  12845. t['a126'] = 0x2466;
  12846. t['a127'] = 0x2467;
  12847. t['a128'] = 0x2468;
  12848. t['a129'] = 0x2469;
  12849. t['a130'] = 0x2776;
  12850. t['a131'] = 0x2777;
  12851. t['a132'] = 0x2778;
  12852. t['a133'] = 0x2779;
  12853. t['a134'] = 0x277A;
  12854. t['a135'] = 0x277B;
  12855. t['a136'] = 0x277C;
  12856. t['a137'] = 0x277D;
  12857. t['a138'] = 0x277E;
  12858. t['a139'] = 0x277F;
  12859. t['a140'] = 0x2780;
  12860. t['a141'] = 0x2781;
  12861. t['a142'] = 0x2782;
  12862. t['a143'] = 0x2783;
  12863. t['a144'] = 0x2784;
  12864. t['a145'] = 0x2785;
  12865. t['a146'] = 0x2786;
  12866. t['a147'] = 0x2787;
  12867. t['a148'] = 0x2788;
  12868. t['a149'] = 0x2789;
  12869. t['a150'] = 0x278A;
  12870. t['a151'] = 0x278B;
  12871. t['a152'] = 0x278C;
  12872. t['a153'] = 0x278D;
  12873. t['a154'] = 0x278E;
  12874. t['a155'] = 0x278F;
  12875. t['a156'] = 0x2790;
  12876. t['a157'] = 0x2791;
  12877. t['a158'] = 0x2792;
  12878. t['a159'] = 0x2793;
  12879. t['a160'] = 0x2794;
  12880. t['a161'] = 0x2192;
  12881. t['a163'] = 0x2194;
  12882. t['a164'] = 0x2195;
  12883. t['a196'] = 0x2798;
  12884. t['a165'] = 0x2799;
  12885. t['a192'] = 0x279A;
  12886. t['a166'] = 0x279B;
  12887. t['a167'] = 0x279C;
  12888. t['a168'] = 0x279D;
  12889. t['a169'] = 0x279E;
  12890. t['a170'] = 0x279F;
  12891. t['a171'] = 0x27A0;
  12892. t['a172'] = 0x27A1;
  12893. t['a173'] = 0x27A2;
  12894. t['a162'] = 0x27A3;
  12895. t['a174'] = 0x27A4;
  12896. t['a175'] = 0x27A5;
  12897. t['a176'] = 0x27A6;
  12898. t['a177'] = 0x27A7;
  12899. t['a178'] = 0x27A8;
  12900. t['a179'] = 0x27A9;
  12901. t['a193'] = 0x27AA;
  12902. t['a180'] = 0x27AB;
  12903. t['a199'] = 0x27AC;
  12904. t['a181'] = 0x27AD;
  12905. t['a200'] = 0x27AE;
  12906. t['a182'] = 0x27AF;
  12907. t['a201'] = 0x27B1;
  12908. t['a183'] = 0x27B2;
  12909. t['a184'] = 0x27B3;
  12910. t['a197'] = 0x27B4;
  12911. t['a185'] = 0x27B5;
  12912. t['a194'] = 0x27B6;
  12913. t['a198'] = 0x27B7;
  12914. t['a186'] = 0x27B8;
  12915. t['a195'] = 0x27B9;
  12916. t['a187'] = 0x27BA;
  12917. t['a188'] = 0x27BB;
  12918. t['a189'] = 0x27BC;
  12919. t['a190'] = 0x27BD;
  12920. t['a191'] = 0x27BE;
  12921. t['a89'] = 0x2768;
  12922. t['a90'] = 0x2769;
  12923. t['a93'] = 0x276A;
  12924. t['a94'] = 0x276B;
  12925. t['a91'] = 0x276C;
  12926. t['a92'] = 0x276D;
  12927. t['a205'] = 0x276E;
  12928. t['a85'] = 0x276F;
  12929. t['a206'] = 0x2770;
  12930. t['a86'] = 0x2771;
  12931. t['a87'] = 0x2772;
  12932. t['a88'] = 0x2773;
  12933. t['a95'] = 0x2774;
  12934. t['a96'] = 0x2775;
  12935. t['.notdef'] = 0x0000;
  12936. });
  12937. exports.getGlyphsUnicode = getGlyphsUnicode;
  12938. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  12939. }));
  12940. (function (root, factory) {
  12941. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  12942. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  12943. var error = sharedUtil.error;
  12944. var log2 = sharedUtil.log2;
  12945. var readInt8 = sharedUtil.readInt8;
  12946. var readUint16 = sharedUtil.readUint16;
  12947. var readUint32 = sharedUtil.readUint32;
  12948. var shadow = sharedUtil.shadow;
  12949. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  12950. var Jbig2Image = function Jbig2ImageClosure() {
  12951. function ContextCache() {
  12952. }
  12953. ContextCache.prototype = {
  12954. getContexts: function (id) {
  12955. if (id in this) {
  12956. return this[id];
  12957. }
  12958. return this[id] = new Int8Array(1 << 16);
  12959. }
  12960. };
  12961. function DecodingContext(data, start, end) {
  12962. this.data = data;
  12963. this.start = start;
  12964. this.end = end;
  12965. }
  12966. DecodingContext.prototype = {
  12967. get decoder() {
  12968. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  12969. return shadow(this, 'decoder', decoder);
  12970. },
  12971. get contextCache() {
  12972. var cache = new ContextCache();
  12973. return shadow(this, 'contextCache', cache);
  12974. }
  12975. };
  12976. function decodeInteger(contextCache, procedure, decoder) {
  12977. var contexts = contextCache.getContexts(procedure);
  12978. var prev = 1;
  12979. function readBits(length) {
  12980. var v = 0;
  12981. for (var i = 0; i < length; i++) {
  12982. var bit = decoder.readBit(contexts, prev);
  12983. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  12984. v = v << 1 | bit;
  12985. }
  12986. return v >>> 0;
  12987. }
  12988. var sign = readBits(1);
  12989. 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);
  12990. return sign === 0 ? value : value > 0 ? -value : null;
  12991. }
  12992. function decodeIAID(contextCache, decoder, codeLength) {
  12993. var contexts = contextCache.getContexts('IAID');
  12994. var prev = 1;
  12995. for (var i = 0; i < codeLength; i++) {
  12996. var bit = decoder.readBit(contexts, prev);
  12997. prev = prev << 1 | bit;
  12998. }
  12999. if (codeLength < 31) {
  13000. return prev & (1 << codeLength) - 1;
  13001. }
  13002. return prev & 0x7FFFFFFF;
  13003. }
  13004. var SegmentTypes = [
  13005. 'SymbolDictionary',
  13006. null,
  13007. null,
  13008. null,
  13009. 'IntermediateTextRegion',
  13010. null,
  13011. 'ImmediateTextRegion',
  13012. 'ImmediateLosslessTextRegion',
  13013. null,
  13014. null,
  13015. null,
  13016. null,
  13017. null,
  13018. null,
  13019. null,
  13020. null,
  13021. 'patternDictionary',
  13022. null,
  13023. null,
  13024. null,
  13025. 'IntermediateHalftoneRegion',
  13026. null,
  13027. 'ImmediateHalftoneRegion',
  13028. 'ImmediateLosslessHalftoneRegion',
  13029. null,
  13030. null,
  13031. null,
  13032. null,
  13033. null,
  13034. null,
  13035. null,
  13036. null,
  13037. null,
  13038. null,
  13039. null,
  13040. null,
  13041. 'IntermediateGenericRegion',
  13042. null,
  13043. 'ImmediateGenericRegion',
  13044. 'ImmediateLosslessGenericRegion',
  13045. 'IntermediateGenericRefinementRegion',
  13046. null,
  13047. 'ImmediateGenericRefinementRegion',
  13048. 'ImmediateLosslessGenericRefinementRegion',
  13049. null,
  13050. null,
  13051. null,
  13052. null,
  13053. 'PageInformation',
  13054. 'EndOfPage',
  13055. 'EndOfStripe',
  13056. 'EndOfFile',
  13057. 'Profiles',
  13058. 'Tables',
  13059. null,
  13060. null,
  13061. null,
  13062. null,
  13063. null,
  13064. null,
  13065. null,
  13066. null,
  13067. 'Extension'
  13068. ];
  13069. var CodingTemplates = [
  13070. [
  13071. {
  13072. x: -1,
  13073. y: -2
  13074. },
  13075. {
  13076. x: 0,
  13077. y: -2
  13078. },
  13079. {
  13080. x: 1,
  13081. y: -2
  13082. },
  13083. {
  13084. x: -2,
  13085. y: -1
  13086. },
  13087. {
  13088. x: -1,
  13089. y: -1
  13090. },
  13091. {
  13092. x: 0,
  13093. y: -1
  13094. },
  13095. {
  13096. x: 1,
  13097. y: -1
  13098. },
  13099. {
  13100. x: 2,
  13101. y: -1
  13102. },
  13103. {
  13104. x: -4,
  13105. y: 0
  13106. },
  13107. {
  13108. x: -3,
  13109. y: 0
  13110. },
  13111. {
  13112. x: -2,
  13113. y: 0
  13114. },
  13115. {
  13116. x: -1,
  13117. y: 0
  13118. }
  13119. ],
  13120. [
  13121. {
  13122. x: -1,
  13123. y: -2
  13124. },
  13125. {
  13126. x: 0,
  13127. y: -2
  13128. },
  13129. {
  13130. x: 1,
  13131. y: -2
  13132. },
  13133. {
  13134. x: 2,
  13135. y: -2
  13136. },
  13137. {
  13138. x: -2,
  13139. y: -1
  13140. },
  13141. {
  13142. x: -1,
  13143. y: -1
  13144. },
  13145. {
  13146. x: 0,
  13147. y: -1
  13148. },
  13149. {
  13150. x: 1,
  13151. y: -1
  13152. },
  13153. {
  13154. x: 2,
  13155. y: -1
  13156. },
  13157. {
  13158. x: -3,
  13159. y: 0
  13160. },
  13161. {
  13162. x: -2,
  13163. y: 0
  13164. },
  13165. {
  13166. x: -1,
  13167. y: 0
  13168. }
  13169. ],
  13170. [
  13171. {
  13172. x: -1,
  13173. y: -2
  13174. },
  13175. {
  13176. x: 0,
  13177. y: -2
  13178. },
  13179. {
  13180. x: 1,
  13181. y: -2
  13182. },
  13183. {
  13184. x: -2,
  13185. y: -1
  13186. },
  13187. {
  13188. x: -1,
  13189. y: -1
  13190. },
  13191. {
  13192. x: 0,
  13193. y: -1
  13194. },
  13195. {
  13196. x: 1,
  13197. y: -1
  13198. },
  13199. {
  13200. x: -2,
  13201. y: 0
  13202. },
  13203. {
  13204. x: -1,
  13205. y: 0
  13206. }
  13207. ],
  13208. [
  13209. {
  13210. x: -3,
  13211. y: -1
  13212. },
  13213. {
  13214. x: -2,
  13215. y: -1
  13216. },
  13217. {
  13218. x: -1,
  13219. y: -1
  13220. },
  13221. {
  13222. x: 0,
  13223. y: -1
  13224. },
  13225. {
  13226. x: 1,
  13227. y: -1
  13228. },
  13229. {
  13230. x: -4,
  13231. y: 0
  13232. },
  13233. {
  13234. x: -3,
  13235. y: 0
  13236. },
  13237. {
  13238. x: -2,
  13239. y: 0
  13240. },
  13241. {
  13242. x: -1,
  13243. y: 0
  13244. }
  13245. ]
  13246. ];
  13247. var RefinementTemplates = [
  13248. {
  13249. coding: [
  13250. {
  13251. x: 0,
  13252. y: -1
  13253. },
  13254. {
  13255. x: 1,
  13256. y: -1
  13257. },
  13258. {
  13259. x: -1,
  13260. y: 0
  13261. }
  13262. ],
  13263. reference: [
  13264. {
  13265. x: 0,
  13266. y: -1
  13267. },
  13268. {
  13269. x: 1,
  13270. y: -1
  13271. },
  13272. {
  13273. x: -1,
  13274. y: 0
  13275. },
  13276. {
  13277. x: 0,
  13278. y: 0
  13279. },
  13280. {
  13281. x: 1,
  13282. y: 0
  13283. },
  13284. {
  13285. x: -1,
  13286. y: 1
  13287. },
  13288. {
  13289. x: 0,
  13290. y: 1
  13291. },
  13292. {
  13293. x: 1,
  13294. y: 1
  13295. }
  13296. ]
  13297. },
  13298. {
  13299. coding: [
  13300. {
  13301. x: -1,
  13302. y: -1
  13303. },
  13304. {
  13305. x: 0,
  13306. y: -1
  13307. },
  13308. {
  13309. x: 1,
  13310. y: -1
  13311. },
  13312. {
  13313. x: -1,
  13314. y: 0
  13315. }
  13316. ],
  13317. reference: [
  13318. {
  13319. x: 0,
  13320. y: -1
  13321. },
  13322. {
  13323. x: -1,
  13324. y: 0
  13325. },
  13326. {
  13327. x: 0,
  13328. y: 0
  13329. },
  13330. {
  13331. x: 1,
  13332. y: 0
  13333. },
  13334. {
  13335. x: 0,
  13336. y: 1
  13337. },
  13338. {
  13339. x: 1,
  13340. y: 1
  13341. }
  13342. ]
  13343. }
  13344. ];
  13345. var ReusedContexts = [
  13346. 0x9B25,
  13347. 0x0795,
  13348. 0x00E5,
  13349. 0x0195
  13350. ];
  13351. var RefinementReusedContexts = [
  13352. 0x0020,
  13353. 0x0008
  13354. ];
  13355. function decodeBitmapTemplate0(width, height, decodingContext) {
  13356. var decoder = decodingContext.decoder;
  13357. var contexts = decodingContext.contextCache.getContexts('GB');
  13358. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13359. var OLD_PIXEL_MASK = 0x7BF7;
  13360. for (i = 0; i < height; i++) {
  13361. row = bitmap[i] = new Uint8Array(width);
  13362. row1 = i < 1 ? row : bitmap[i - 1];
  13363. row2 = i < 2 ? row : bitmap[i - 2];
  13364. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13365. for (j = 0; j < width; j++) {
  13366. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13367. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13368. }
  13369. }
  13370. return bitmap;
  13371. }
  13372. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13373. if (mmr) {
  13374. error('JBIG2 error: MMR encoding is not supported');
  13375. }
  13376. 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) {
  13377. return decodeBitmapTemplate0(width, height, decodingContext);
  13378. }
  13379. var useskip = !!skip;
  13380. var template = CodingTemplates[templateIndex].concat(at);
  13381. template.sort(function (a, b) {
  13382. return a.y - b.y || a.x - b.x;
  13383. });
  13384. var templateLength = template.length;
  13385. var templateX = new Int8Array(templateLength);
  13386. var templateY = new Int8Array(templateLength);
  13387. var changingTemplateEntries = [];
  13388. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13389. var c, k;
  13390. for (k = 0; k < templateLength; k++) {
  13391. templateX[k] = template[k].x;
  13392. templateY[k] = template[k].y;
  13393. minX = Math.min(minX, template[k].x);
  13394. maxX = Math.max(maxX, template[k].x);
  13395. minY = Math.min(minY, template[k].y);
  13396. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13397. reuseMask |= 1 << templateLength - 1 - k;
  13398. } else {
  13399. changingTemplateEntries.push(k);
  13400. }
  13401. }
  13402. var changingEntriesLength = changingTemplateEntries.length;
  13403. var changingTemplateX = new Int8Array(changingEntriesLength);
  13404. var changingTemplateY = new Int8Array(changingEntriesLength);
  13405. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13406. for (c = 0; c < changingEntriesLength; c++) {
  13407. k = changingTemplateEntries[c];
  13408. changingTemplateX[c] = template[k].x;
  13409. changingTemplateY[c] = template[k].y;
  13410. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13411. }
  13412. var sbb_left = -minX;
  13413. var sbb_top = -minY;
  13414. var sbb_right = width - maxX;
  13415. var pseudoPixelContext = ReusedContexts[templateIndex];
  13416. var row = new Uint8Array(width);
  13417. var bitmap = [];
  13418. var decoder = decodingContext.decoder;
  13419. var contexts = decodingContext.contextCache.getContexts('GB');
  13420. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13421. for (var i = 0; i < height; i++) {
  13422. if (prediction) {
  13423. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13424. ltp ^= sltp;
  13425. if (ltp) {
  13426. bitmap.push(row);
  13427. continue;
  13428. }
  13429. }
  13430. row = new Uint8Array(row);
  13431. bitmap.push(row);
  13432. for (j = 0; j < width; j++) {
  13433. if (useskip && skip[i][j]) {
  13434. row[j] = 0;
  13435. continue;
  13436. }
  13437. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13438. contextLabel = contextLabel << 1 & reuseMask;
  13439. for (k = 0; k < changingEntriesLength; k++) {
  13440. i0 = i + changingTemplateY[k];
  13441. j0 = j + changingTemplateX[k];
  13442. bit = bitmap[i0][j0];
  13443. if (bit) {
  13444. bit = changingTemplateBit[k];
  13445. contextLabel |= bit;
  13446. }
  13447. }
  13448. } else {
  13449. contextLabel = 0;
  13450. shift = templateLength - 1;
  13451. for (k = 0; k < templateLength; k++, shift--) {
  13452. j0 = j + templateX[k];
  13453. if (j0 >= 0 && j0 < width) {
  13454. i0 = i + templateY[k];
  13455. if (i0 >= 0) {
  13456. bit = bitmap[i0][j0];
  13457. if (bit) {
  13458. contextLabel |= bit << shift;
  13459. }
  13460. }
  13461. }
  13462. }
  13463. }
  13464. var pixel = decoder.readBit(contexts, contextLabel);
  13465. row[j] = pixel;
  13466. }
  13467. }
  13468. return bitmap;
  13469. }
  13470. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13471. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13472. if (templateIndex === 0) {
  13473. codingTemplate = codingTemplate.concat([at[0]]);
  13474. }
  13475. var codingTemplateLength = codingTemplate.length;
  13476. var codingTemplateX = new Int32Array(codingTemplateLength);
  13477. var codingTemplateY = new Int32Array(codingTemplateLength);
  13478. var k;
  13479. for (k = 0; k < codingTemplateLength; k++) {
  13480. codingTemplateX[k] = codingTemplate[k].x;
  13481. codingTemplateY[k] = codingTemplate[k].y;
  13482. }
  13483. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13484. if (templateIndex === 0) {
  13485. referenceTemplate = referenceTemplate.concat([at[1]]);
  13486. }
  13487. var referenceTemplateLength = referenceTemplate.length;
  13488. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13489. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13490. for (k = 0; k < referenceTemplateLength; k++) {
  13491. referenceTemplateX[k] = referenceTemplate[k].x;
  13492. referenceTemplateY[k] = referenceTemplate[k].y;
  13493. }
  13494. var referenceWidth = referenceBitmap[0].length;
  13495. var referenceHeight = referenceBitmap.length;
  13496. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13497. var bitmap = [];
  13498. var decoder = decodingContext.decoder;
  13499. var contexts = decodingContext.contextCache.getContexts('GR');
  13500. var ltp = 0;
  13501. for (var i = 0; i < height; i++) {
  13502. if (prediction) {
  13503. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13504. ltp ^= sltp;
  13505. if (ltp) {
  13506. error('JBIG2 error: prediction is not supported');
  13507. }
  13508. }
  13509. var row = new Uint8Array(width);
  13510. bitmap.push(row);
  13511. for (var j = 0; j < width; j++) {
  13512. var i0, j0;
  13513. var contextLabel = 0;
  13514. for (k = 0; k < codingTemplateLength; k++) {
  13515. i0 = i + codingTemplateY[k];
  13516. j0 = j + codingTemplateX[k];
  13517. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13518. contextLabel <<= 1;
  13519. } else
  13520. {
  13521. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13522. }
  13523. }
  13524. for (k = 0; k < referenceTemplateLength; k++) {
  13525. i0 = i + referenceTemplateY[k] + offsetY;
  13526. j0 = j + referenceTemplateX[k] + offsetX;
  13527. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13528. contextLabel <<= 1;
  13529. } else
  13530. {
  13531. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13532. }
  13533. }
  13534. var pixel = decoder.readBit(contexts, contextLabel);
  13535. row[j] = pixel;
  13536. }
  13537. }
  13538. return bitmap;
  13539. }
  13540. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13541. if (huffman) {
  13542. error('JBIG2 error: huffman is not supported');
  13543. }
  13544. var newSymbols = [];
  13545. var currentHeight = 0;
  13546. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13547. var decoder = decodingContext.decoder;
  13548. var contextCache = decodingContext.contextCache;
  13549. while (newSymbols.length < numberOfNewSymbols) {
  13550. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13551. currentHeight += deltaHeight;
  13552. var currentWidth = 0;
  13553. var totalWidth = 0;
  13554. while (true) {
  13555. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13556. if (deltaWidth === null) {
  13557. break;
  13558. }
  13559. currentWidth += deltaWidth;
  13560. totalWidth += currentWidth;
  13561. var bitmap;
  13562. if (refinement) {
  13563. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13564. if (numberOfInstances > 1) {
  13565. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13566. } else {
  13567. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13568. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13569. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13570. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13571. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13572. }
  13573. } else {
  13574. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13575. }
  13576. newSymbols.push(bitmap);
  13577. }
  13578. }
  13579. var exportedSymbols = [];
  13580. var flags = [], currentFlag = false;
  13581. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13582. while (flags.length < totalSymbolsLength) {
  13583. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13584. while (runLength--) {
  13585. flags.push(currentFlag);
  13586. }
  13587. currentFlag = !currentFlag;
  13588. }
  13589. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13590. if (flags[i]) {
  13591. exportedSymbols.push(symbols[i]);
  13592. }
  13593. }
  13594. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13595. if (flags[i]) {
  13596. exportedSymbols.push(newSymbols[j]);
  13597. }
  13598. }
  13599. return exportedSymbols;
  13600. }
  13601. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13602. if (huffman) {
  13603. error('JBIG2 error: huffman is not supported');
  13604. }
  13605. var bitmap = [];
  13606. var i, row;
  13607. for (i = 0; i < height; i++) {
  13608. row = new Uint8Array(width);
  13609. if (defaultPixelValue) {
  13610. for (var j = 0; j < width; j++) {
  13611. row[j] = defaultPixelValue;
  13612. }
  13613. }
  13614. bitmap.push(row);
  13615. }
  13616. var decoder = decodingContext.decoder;
  13617. var contextCache = decodingContext.contextCache;
  13618. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13619. var firstS = 0;
  13620. i = 0;
  13621. while (i < numberOfSymbolInstances) {
  13622. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13623. stripT += deltaT;
  13624. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13625. firstS += deltaFirstS;
  13626. var currentS = firstS;
  13627. do {
  13628. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13629. var t = stripSize * stripT + currentT;
  13630. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13631. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13632. var symbolBitmap = inputSymbols[symbolId];
  13633. var symbolWidth = symbolBitmap[0].length;
  13634. var symbolHeight = symbolBitmap.length;
  13635. if (applyRefinement) {
  13636. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13637. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13638. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13639. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13640. symbolWidth += rdw;
  13641. symbolHeight += rdh;
  13642. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13643. }
  13644. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13645. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13646. var s2, t2, symbolRow;
  13647. if (transposed) {
  13648. for (s2 = 0; s2 < symbolHeight; s2++) {
  13649. row = bitmap[offsetS + s2];
  13650. if (!row) {
  13651. continue;
  13652. }
  13653. symbolRow = symbolBitmap[s2];
  13654. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13655. switch (combinationOperator) {
  13656. case 0:
  13657. for (t2 = 0; t2 < maxWidth; t2++) {
  13658. row[offsetT + t2] |= symbolRow[t2];
  13659. }
  13660. break;
  13661. case 2:
  13662. for (t2 = 0; t2 < maxWidth; t2++) {
  13663. row[offsetT + t2] ^= symbolRow[t2];
  13664. }
  13665. break;
  13666. default:
  13667. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13668. }
  13669. }
  13670. currentS += symbolHeight - 1;
  13671. } else {
  13672. for (t2 = 0; t2 < symbolHeight; t2++) {
  13673. row = bitmap[offsetT + t2];
  13674. if (!row) {
  13675. continue;
  13676. }
  13677. symbolRow = symbolBitmap[t2];
  13678. switch (combinationOperator) {
  13679. case 0:
  13680. for (s2 = 0; s2 < symbolWidth; s2++) {
  13681. row[offsetS + s2] |= symbolRow[s2];
  13682. }
  13683. break;
  13684. case 2:
  13685. for (s2 = 0; s2 < symbolWidth; s2++) {
  13686. row[offsetS + s2] ^= symbolRow[s2];
  13687. }
  13688. break;
  13689. default:
  13690. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13691. }
  13692. }
  13693. currentS += symbolWidth - 1;
  13694. }
  13695. i++;
  13696. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13697. if (deltaS === null) {
  13698. break;
  13699. }
  13700. currentS += deltaS + dsOffset;
  13701. } while (true);
  13702. }
  13703. return bitmap;
  13704. }
  13705. function readSegmentHeader(data, start) {
  13706. var segmentHeader = {};
  13707. segmentHeader.number = readUint32(data, start);
  13708. var flags = data[start + 4];
  13709. var segmentType = flags & 0x3F;
  13710. if (!SegmentTypes[segmentType]) {
  13711. error('JBIG2 error: invalid segment type: ' + segmentType);
  13712. }
  13713. segmentHeader.type = segmentType;
  13714. segmentHeader.typeName = SegmentTypes[segmentType];
  13715. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13716. var pageAssociationFieldSize = !!(flags & 0x40);
  13717. var referredFlags = data[start + 5];
  13718. var referredToCount = referredFlags >> 5 & 7;
  13719. var retainBits = [referredFlags & 31];
  13720. var position = start + 6;
  13721. if (referredFlags === 7) {
  13722. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13723. position += 3;
  13724. var bytes = referredToCount + 7 >> 3;
  13725. retainBits[0] = data[position++];
  13726. while (--bytes > 0) {
  13727. retainBits.push(data[position++]);
  13728. }
  13729. } else if (referredFlags === 5 || referredFlags === 6) {
  13730. error('JBIG2 error: invalid referred-to flags');
  13731. }
  13732. segmentHeader.retainBits = retainBits;
  13733. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13734. var referredTo = [];
  13735. var i, ii;
  13736. for (i = 0; i < referredToCount; i++) {
  13737. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13738. referredTo.push(number);
  13739. position += referredToSegmentNumberSize;
  13740. }
  13741. segmentHeader.referredTo = referredTo;
  13742. if (!pageAssociationFieldSize) {
  13743. segmentHeader.pageAssociation = data[position++];
  13744. } else {
  13745. segmentHeader.pageAssociation = readUint32(data, position);
  13746. position += 4;
  13747. }
  13748. segmentHeader.length = readUint32(data, position);
  13749. position += 4;
  13750. if (segmentHeader.length === 0xFFFFFFFF) {
  13751. if (segmentType === 38) {
  13752. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13753. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13754. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13755. var searchPatternLength = 6;
  13756. var searchPattern = new Uint8Array(searchPatternLength);
  13757. if (!genericRegionMmr) {
  13758. searchPattern[0] = 0xFF;
  13759. searchPattern[1] = 0xAC;
  13760. }
  13761. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13762. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13763. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13764. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13765. for (i = position, ii = data.length; i < ii; i++) {
  13766. var j = 0;
  13767. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13768. j++;
  13769. }
  13770. if (j === searchPatternLength) {
  13771. segmentHeader.length = i + searchPatternLength;
  13772. break;
  13773. }
  13774. }
  13775. if (segmentHeader.length === 0xFFFFFFFF) {
  13776. error('JBIG2 error: segment end was not found');
  13777. }
  13778. } else {
  13779. error('JBIG2 error: invalid unknown segment length');
  13780. }
  13781. }
  13782. segmentHeader.headerEnd = position;
  13783. return segmentHeader;
  13784. }
  13785. function readSegments(header, data, start, end) {
  13786. var segments = [];
  13787. var position = start;
  13788. while (position < end) {
  13789. var segmentHeader = readSegmentHeader(data, position);
  13790. position = segmentHeader.headerEnd;
  13791. var segment = {
  13792. header: segmentHeader,
  13793. data: data
  13794. };
  13795. if (!header.randomAccess) {
  13796. segment.start = position;
  13797. position += segmentHeader.length;
  13798. segment.end = position;
  13799. }
  13800. segments.push(segment);
  13801. if (segmentHeader.type === 51) {
  13802. break;
  13803. }
  13804. }
  13805. if (header.randomAccess) {
  13806. for (var i = 0, ii = segments.length; i < ii; i++) {
  13807. segments[i].start = position;
  13808. position += segments[i].header.length;
  13809. segments[i].end = position;
  13810. }
  13811. }
  13812. return segments;
  13813. }
  13814. function readRegionSegmentInformation(data, start) {
  13815. return {
  13816. width: readUint32(data, start),
  13817. height: readUint32(data, start + 4),
  13818. x: readUint32(data, start + 8),
  13819. y: readUint32(data, start + 12),
  13820. combinationOperator: data[start + 16] & 7
  13821. };
  13822. }
  13823. var RegionSegmentInformationFieldLength = 17;
  13824. function processSegment(segment, visitor) {
  13825. var header = segment.header;
  13826. var data = segment.data, position = segment.start, end = segment.end;
  13827. var args, at, i, atLength;
  13828. switch (header.type) {
  13829. case 0:
  13830. var dictionary = {};
  13831. var dictionaryFlags = readUint16(data, position);
  13832. dictionary.huffman = !!(dictionaryFlags & 1);
  13833. dictionary.refinement = !!(dictionaryFlags & 2);
  13834. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13835. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13836. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13837. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13838. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13839. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13840. dictionary.template = dictionaryFlags >> 10 & 3;
  13841. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13842. position += 2;
  13843. if (!dictionary.huffman) {
  13844. atLength = dictionary.template === 0 ? 4 : 1;
  13845. at = [];
  13846. for (i = 0; i < atLength; i++) {
  13847. at.push({
  13848. x: readInt8(data, position),
  13849. y: readInt8(data, position + 1)
  13850. });
  13851. position += 2;
  13852. }
  13853. dictionary.at = at;
  13854. }
  13855. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13856. at = [];
  13857. for (i = 0; i < 2; i++) {
  13858. at.push({
  13859. x: readInt8(data, position),
  13860. y: readInt8(data, position + 1)
  13861. });
  13862. position += 2;
  13863. }
  13864. dictionary.refinementAt = at;
  13865. }
  13866. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13867. position += 4;
  13868. dictionary.numberOfNewSymbols = readUint32(data, position);
  13869. position += 4;
  13870. args = [
  13871. dictionary,
  13872. header.number,
  13873. header.referredTo,
  13874. data,
  13875. position,
  13876. end
  13877. ];
  13878. break;
  13879. case 6:
  13880. case 7:
  13881. var textRegion = {};
  13882. textRegion.info = readRegionSegmentInformation(data, position);
  13883. position += RegionSegmentInformationFieldLength;
  13884. var textRegionSegmentFlags = readUint16(data, position);
  13885. position += 2;
  13886. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  13887. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  13888. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  13889. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  13890. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  13891. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  13892. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  13893. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  13894. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  13895. if (textRegion.huffman) {
  13896. var textRegionHuffmanFlags = readUint16(data, position);
  13897. position += 2;
  13898. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  13899. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  13900. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  13901. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  13902. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  13903. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  13904. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  13905. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  13906. }
  13907. if (textRegion.refinement && !textRegion.refinementTemplate) {
  13908. at = [];
  13909. for (i = 0; i < 2; i++) {
  13910. at.push({
  13911. x: readInt8(data, position),
  13912. y: readInt8(data, position + 1)
  13913. });
  13914. position += 2;
  13915. }
  13916. textRegion.refinementAt = at;
  13917. }
  13918. textRegion.numberOfSymbolInstances = readUint32(data, position);
  13919. position += 4;
  13920. if (textRegion.huffman) {
  13921. error('JBIG2 error: huffman is not supported');
  13922. }
  13923. args = [
  13924. textRegion,
  13925. header.referredTo,
  13926. data,
  13927. position,
  13928. end
  13929. ];
  13930. break;
  13931. case 38:
  13932. case 39:
  13933. var genericRegion = {};
  13934. genericRegion.info = readRegionSegmentInformation(data, position);
  13935. position += RegionSegmentInformationFieldLength;
  13936. var genericRegionSegmentFlags = data[position++];
  13937. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  13938. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  13939. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  13940. if (!genericRegion.mmr) {
  13941. atLength = genericRegion.template === 0 ? 4 : 1;
  13942. at = [];
  13943. for (i = 0; i < atLength; i++) {
  13944. at.push({
  13945. x: readInt8(data, position),
  13946. y: readInt8(data, position + 1)
  13947. });
  13948. position += 2;
  13949. }
  13950. genericRegion.at = at;
  13951. }
  13952. args = [
  13953. genericRegion,
  13954. data,
  13955. position,
  13956. end
  13957. ];
  13958. break;
  13959. case 48:
  13960. var pageInfo = {
  13961. width: readUint32(data, position),
  13962. height: readUint32(data, position + 4),
  13963. resolutionX: readUint32(data, position + 8),
  13964. resolutionY: readUint32(data, position + 12)
  13965. };
  13966. if (pageInfo.height === 0xFFFFFFFF) {
  13967. delete pageInfo.height;
  13968. }
  13969. var pageSegmentFlags = data[position + 16];
  13970. var pageStripingInformation = readUint16(data, position + 17);
  13971. pageInfo.lossless = !!(pageSegmentFlags & 1);
  13972. pageInfo.refinement = !!(pageSegmentFlags & 2);
  13973. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  13974. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  13975. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  13976. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  13977. args = [pageInfo];
  13978. break;
  13979. case 49:
  13980. break;
  13981. case 50:
  13982. break;
  13983. case 51:
  13984. break;
  13985. case 62:
  13986. break;
  13987. default:
  13988. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  13989. }
  13990. var callbackName = 'on' + header.typeName;
  13991. if (callbackName in visitor) {
  13992. visitor[callbackName].apply(visitor, args);
  13993. }
  13994. }
  13995. function processSegments(segments, visitor) {
  13996. for (var i = 0, ii = segments.length; i < ii; i++) {
  13997. processSegment(segments[i], visitor);
  13998. }
  13999. }
  14000. function parseJbig2(data, start, end) {
  14001. var position = start;
  14002. 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) {
  14003. error('JBIG2 error: invalid header');
  14004. }
  14005. var header = {};
  14006. position += 8;
  14007. var flags = data[position++];
  14008. header.randomAccess = !(flags & 1);
  14009. if (!(flags & 2)) {
  14010. header.numberOfPages = readUint32(data, position);
  14011. position += 4;
  14012. }
  14013. var segments = readSegments(header, data, position, end);
  14014. error('Not implemented');
  14015. }
  14016. function parseJbig2Chunks(chunks) {
  14017. var visitor = new SimpleSegmentVisitor();
  14018. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14019. var chunk = chunks[i];
  14020. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14021. processSegments(segments, visitor);
  14022. }
  14023. return visitor.buffer;
  14024. }
  14025. function SimpleSegmentVisitor() {
  14026. }
  14027. SimpleSegmentVisitor.prototype = {
  14028. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14029. this.currentPageInfo = info;
  14030. var rowSize = info.width + 7 >> 3;
  14031. var buffer = new Uint8Array(rowSize * info.height);
  14032. if (info.defaultPixelValue) {
  14033. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14034. buffer[i] = 0xFF;
  14035. }
  14036. }
  14037. this.buffer = buffer;
  14038. },
  14039. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14040. var pageInfo = this.currentPageInfo;
  14041. var width = regionInfo.width, height = regionInfo.height;
  14042. var rowSize = pageInfo.width + 7 >> 3;
  14043. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14044. var buffer = this.buffer;
  14045. var mask0 = 128 >> (regionInfo.x & 7);
  14046. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14047. var i, j, mask, offset;
  14048. switch (combinationOperator) {
  14049. case 0:
  14050. for (i = 0; i < height; i++) {
  14051. mask = mask0;
  14052. offset = offset0;
  14053. for (j = 0; j < width; j++) {
  14054. if (bitmap[i][j]) {
  14055. buffer[offset] |= mask;
  14056. }
  14057. mask >>= 1;
  14058. if (!mask) {
  14059. mask = 128;
  14060. offset++;
  14061. }
  14062. }
  14063. offset0 += rowSize;
  14064. }
  14065. break;
  14066. case 2:
  14067. for (i = 0; i < height; i++) {
  14068. mask = mask0;
  14069. offset = offset0;
  14070. for (j = 0; j < width; j++) {
  14071. if (bitmap[i][j]) {
  14072. buffer[offset] ^= mask;
  14073. }
  14074. mask >>= 1;
  14075. if (!mask) {
  14076. mask = 128;
  14077. offset++;
  14078. }
  14079. }
  14080. offset0 += rowSize;
  14081. }
  14082. break;
  14083. default:
  14084. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14085. }
  14086. },
  14087. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14088. var regionInfo = region.info;
  14089. var decodingContext = new DecodingContext(data, start, end);
  14090. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14091. this.drawBitmap(regionInfo, bitmap);
  14092. },
  14093. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14094. this.onImmediateGenericRegion.apply(this, arguments);
  14095. },
  14096. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14097. var huffmanTables;
  14098. if (dictionary.huffman) {
  14099. error('JBIG2 error: huffman is not supported');
  14100. }
  14101. var symbols = this.symbols;
  14102. if (!symbols) {
  14103. this.symbols = symbols = {};
  14104. }
  14105. var inputSymbols = [];
  14106. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14107. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14108. }
  14109. var decodingContext = new DecodingContext(data, start, end);
  14110. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14111. },
  14112. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14113. var regionInfo = region.info;
  14114. var huffmanTables;
  14115. var symbols = this.symbols;
  14116. var inputSymbols = [];
  14117. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14118. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14119. }
  14120. var symbolCodeLength = log2(inputSymbols.length);
  14121. var decodingContext = new DecodingContext(data, start, end);
  14122. 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);
  14123. this.drawBitmap(regionInfo, bitmap);
  14124. },
  14125. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14126. this.onImmediateTextRegion.apply(this, arguments);
  14127. }
  14128. };
  14129. function Jbig2Image() {
  14130. }
  14131. Jbig2Image.prototype = {
  14132. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14133. return parseJbig2Chunks(chunks);
  14134. }
  14135. };
  14136. return Jbig2Image;
  14137. }();
  14138. exports.Jbig2Image = Jbig2Image;
  14139. }));
  14140. (function (root, factory) {
  14141. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14142. }(this, function (exports, sharedUtil) {
  14143. var error = sharedUtil.error;
  14144. var JpegImage = function JpegImageClosure() {
  14145. var dctZigZag = new Uint8Array([
  14146. 0,
  14147. 1,
  14148. 8,
  14149. 16,
  14150. 9,
  14151. 2,
  14152. 3,
  14153. 10,
  14154. 17,
  14155. 24,
  14156. 32,
  14157. 25,
  14158. 18,
  14159. 11,
  14160. 4,
  14161. 5,
  14162. 12,
  14163. 19,
  14164. 26,
  14165. 33,
  14166. 40,
  14167. 48,
  14168. 41,
  14169. 34,
  14170. 27,
  14171. 20,
  14172. 13,
  14173. 6,
  14174. 7,
  14175. 14,
  14176. 21,
  14177. 28,
  14178. 35,
  14179. 42,
  14180. 49,
  14181. 56,
  14182. 57,
  14183. 50,
  14184. 43,
  14185. 36,
  14186. 29,
  14187. 22,
  14188. 15,
  14189. 23,
  14190. 30,
  14191. 37,
  14192. 44,
  14193. 51,
  14194. 58,
  14195. 59,
  14196. 52,
  14197. 45,
  14198. 38,
  14199. 31,
  14200. 39,
  14201. 46,
  14202. 53,
  14203. 60,
  14204. 61,
  14205. 54,
  14206. 47,
  14207. 55,
  14208. 62,
  14209. 63
  14210. ]);
  14211. var dctCos1 = 4017;
  14212. var dctSin1 = 799;
  14213. var dctCos3 = 3406;
  14214. var dctSin3 = 2276;
  14215. var dctCos6 = 1567;
  14216. var dctSin6 = 3784;
  14217. var dctSqrt2 = 5793;
  14218. var dctSqrt1d2 = 2896;
  14219. function JpegImage() {
  14220. this.decodeTransform = null;
  14221. this.colorTransform = -1;
  14222. }
  14223. function buildHuffmanTable(codeLengths, values) {
  14224. var k = 0, code = [], i, j, length = 16;
  14225. while (length > 0 && !codeLengths[length - 1]) {
  14226. length--;
  14227. }
  14228. code.push({
  14229. children: [],
  14230. index: 0
  14231. });
  14232. var p = code[0], q;
  14233. for (i = 0; i < length; i++) {
  14234. for (j = 0; j < codeLengths[i]; j++) {
  14235. p = code.pop();
  14236. p.children[p.index] = values[k];
  14237. while (p.index > 0) {
  14238. p = code.pop();
  14239. }
  14240. p.index++;
  14241. code.push(p);
  14242. while (code.length <= i) {
  14243. code.push(q = {
  14244. children: [],
  14245. index: 0
  14246. });
  14247. p.children[p.index] = q.children;
  14248. p = q;
  14249. }
  14250. k++;
  14251. }
  14252. if (i + 1 < length) {
  14253. code.push(q = {
  14254. children: [],
  14255. index: 0
  14256. });
  14257. p.children[p.index] = q.children;
  14258. p = q;
  14259. }
  14260. }
  14261. return code[0].children;
  14262. }
  14263. function getBlockBufferOffset(component, row, col) {
  14264. return 64 * ((component.blocksPerLine + 1) * row + col);
  14265. }
  14266. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14267. var mcusPerLine = frame.mcusPerLine;
  14268. var progressive = frame.progressive;
  14269. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14270. function readBit() {
  14271. if (bitsCount > 0) {
  14272. bitsCount--;
  14273. return bitsData >> bitsCount & 1;
  14274. }
  14275. bitsData = data[offset++];
  14276. if (bitsData === 0xFF) {
  14277. var nextByte = data[offset++];
  14278. if (nextByte) {
  14279. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14280. }
  14281. }
  14282. bitsCount = 7;
  14283. return bitsData >>> 7;
  14284. }
  14285. function decodeHuffman(tree) {
  14286. var node = tree;
  14287. while (true) {
  14288. node = node[readBit()];
  14289. if (typeof node === 'number') {
  14290. return node;
  14291. }
  14292. if (typeof node !== 'object') {
  14293. error('JPEG error: invalid huffman sequence');
  14294. }
  14295. }
  14296. }
  14297. function receive(length) {
  14298. var n = 0;
  14299. while (length > 0) {
  14300. n = n << 1 | readBit();
  14301. length--;
  14302. }
  14303. return n;
  14304. }
  14305. function receiveAndExtend(length) {
  14306. if (length === 1) {
  14307. return readBit() === 1 ? 1 : -1;
  14308. }
  14309. var n = receive(length);
  14310. if (n >= 1 << length - 1) {
  14311. return n;
  14312. }
  14313. return n + (-1 << length) + 1;
  14314. }
  14315. function decodeBaseline(component, offset) {
  14316. var t = decodeHuffman(component.huffmanTableDC);
  14317. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14318. component.blockData[offset] = component.pred += diff;
  14319. var k = 1;
  14320. while (k < 64) {
  14321. var rs = decodeHuffman(component.huffmanTableAC);
  14322. var s = rs & 15, r = rs >> 4;
  14323. if (s === 0) {
  14324. if (r < 15) {
  14325. break;
  14326. }
  14327. k += 16;
  14328. continue;
  14329. }
  14330. k += r;
  14331. var z = dctZigZag[k];
  14332. component.blockData[offset + z] = receiveAndExtend(s);
  14333. k++;
  14334. }
  14335. }
  14336. function decodeDCFirst(component, offset) {
  14337. var t = decodeHuffman(component.huffmanTableDC);
  14338. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14339. component.blockData[offset] = component.pred += diff;
  14340. }
  14341. function decodeDCSuccessive(component, offset) {
  14342. component.blockData[offset] |= readBit() << successive;
  14343. }
  14344. var eobrun = 0;
  14345. function decodeACFirst(component, offset) {
  14346. if (eobrun > 0) {
  14347. eobrun--;
  14348. return;
  14349. }
  14350. var k = spectralStart, e = spectralEnd;
  14351. while (k <= e) {
  14352. var rs = decodeHuffman(component.huffmanTableAC);
  14353. var s = rs & 15, r = rs >> 4;
  14354. if (s === 0) {
  14355. if (r < 15) {
  14356. eobrun = receive(r) + (1 << r) - 1;
  14357. break;
  14358. }
  14359. k += 16;
  14360. continue;
  14361. }
  14362. k += r;
  14363. var z = dctZigZag[k];
  14364. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14365. k++;
  14366. }
  14367. }
  14368. var successiveACState = 0, successiveACNextValue;
  14369. function decodeACSuccessive(component, offset) {
  14370. var k = spectralStart;
  14371. var e = spectralEnd;
  14372. var r = 0;
  14373. var s;
  14374. var rs;
  14375. while (k <= e) {
  14376. var z = dctZigZag[k];
  14377. switch (successiveACState) {
  14378. case 0:
  14379. rs = decodeHuffman(component.huffmanTableAC);
  14380. s = rs & 15;
  14381. r = rs >> 4;
  14382. if (s === 0) {
  14383. if (r < 15) {
  14384. eobrun = receive(r) + (1 << r);
  14385. successiveACState = 4;
  14386. } else {
  14387. r = 16;
  14388. successiveACState = 1;
  14389. }
  14390. } else {
  14391. if (s !== 1) {
  14392. error('JPEG error: invalid ACn encoding');
  14393. }
  14394. successiveACNextValue = receiveAndExtend(s);
  14395. successiveACState = r ? 2 : 3;
  14396. }
  14397. continue;
  14398. case 1:
  14399. case 2:
  14400. if (component.blockData[offset + z]) {
  14401. component.blockData[offset + z] += readBit() << successive;
  14402. } else {
  14403. r--;
  14404. if (r === 0) {
  14405. successiveACState = successiveACState === 2 ? 3 : 0;
  14406. }
  14407. }
  14408. break;
  14409. case 3:
  14410. if (component.blockData[offset + z]) {
  14411. component.blockData[offset + z] += readBit() << successive;
  14412. } else {
  14413. component.blockData[offset + z] = successiveACNextValue << successive;
  14414. successiveACState = 0;
  14415. }
  14416. break;
  14417. case 4:
  14418. if (component.blockData[offset + z]) {
  14419. component.blockData[offset + z] += readBit() << successive;
  14420. }
  14421. break;
  14422. }
  14423. k++;
  14424. }
  14425. if (successiveACState === 4) {
  14426. eobrun--;
  14427. if (eobrun === 0) {
  14428. successiveACState = 0;
  14429. }
  14430. }
  14431. }
  14432. function decodeMcu(component, decode, mcu, row, col) {
  14433. var mcuRow = mcu / mcusPerLine | 0;
  14434. var mcuCol = mcu % mcusPerLine;
  14435. var blockRow = mcuRow * component.v + row;
  14436. var blockCol = mcuCol * component.h + col;
  14437. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14438. decode(component, offset);
  14439. }
  14440. function decodeBlock(component, decode, mcu) {
  14441. var blockRow = mcu / component.blocksPerLine | 0;
  14442. var blockCol = mcu % component.blocksPerLine;
  14443. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14444. decode(component, offset);
  14445. }
  14446. var componentsLength = components.length;
  14447. var component, i, j, k, n;
  14448. var decodeFn;
  14449. if (progressive) {
  14450. if (spectralStart === 0) {
  14451. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14452. } else {
  14453. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14454. }
  14455. } else {
  14456. decodeFn = decodeBaseline;
  14457. }
  14458. var mcu = 0, marker;
  14459. var mcuExpected;
  14460. if (componentsLength === 1) {
  14461. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14462. } else {
  14463. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14464. }
  14465. if (!resetInterval) {
  14466. resetInterval = mcuExpected;
  14467. }
  14468. var h, v;
  14469. while (mcu < mcuExpected) {
  14470. for (i = 0; i < componentsLength; i++) {
  14471. components[i].pred = 0;
  14472. }
  14473. eobrun = 0;
  14474. if (componentsLength === 1) {
  14475. component = components[0];
  14476. for (n = 0; n < resetInterval; n++) {
  14477. decodeBlock(component, decodeFn, mcu);
  14478. mcu++;
  14479. }
  14480. } else {
  14481. for (n = 0; n < resetInterval; n++) {
  14482. for (i = 0; i < componentsLength; i++) {
  14483. component = components[i];
  14484. h = component.h;
  14485. v = component.v;
  14486. for (j = 0; j < v; j++) {
  14487. for (k = 0; k < h; k++) {
  14488. decodeMcu(component, decodeFn, mcu, j, k);
  14489. }
  14490. }
  14491. }
  14492. mcu++;
  14493. }
  14494. }
  14495. bitsCount = 0;
  14496. marker = data[offset] << 8 | data[offset + 1];
  14497. while (data[offset] === 0x00 && offset < data.length - 1) {
  14498. offset++;
  14499. marker = data[offset] << 8 | data[offset + 1];
  14500. }
  14501. if (marker <= 0xFF00) {
  14502. error('JPEG error: marker was not found');
  14503. }
  14504. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14505. offset += 2;
  14506. } else {
  14507. break;
  14508. }
  14509. }
  14510. return offset - startOffset;
  14511. }
  14512. function quantizeAndInverse(component, blockBufferOffset, p) {
  14513. var qt = component.quantizationTable, blockData = component.blockData;
  14514. var v0, v1, v2, v3, v4, v5, v6, v7;
  14515. var p0, p1, p2, p3, p4, p5, p6, p7;
  14516. var t;
  14517. if (!qt) {
  14518. error('JPEG error: missing required Quantization Table.');
  14519. }
  14520. for (var row = 0; row < 64; row += 8) {
  14521. p0 = blockData[blockBufferOffset + row];
  14522. p1 = blockData[blockBufferOffset + row + 1];
  14523. p2 = blockData[blockBufferOffset + row + 2];
  14524. p3 = blockData[blockBufferOffset + row + 3];
  14525. p4 = blockData[blockBufferOffset + row + 4];
  14526. p5 = blockData[blockBufferOffset + row + 5];
  14527. p6 = blockData[blockBufferOffset + row + 6];
  14528. p7 = blockData[blockBufferOffset + row + 7];
  14529. p0 *= qt[row];
  14530. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14531. t = dctSqrt2 * p0 + 512 >> 10;
  14532. p[row] = t;
  14533. p[row + 1] = t;
  14534. p[row + 2] = t;
  14535. p[row + 3] = t;
  14536. p[row + 4] = t;
  14537. p[row + 5] = t;
  14538. p[row + 6] = t;
  14539. p[row + 7] = t;
  14540. continue;
  14541. }
  14542. p1 *= qt[row + 1];
  14543. p2 *= qt[row + 2];
  14544. p3 *= qt[row + 3];
  14545. p4 *= qt[row + 4];
  14546. p5 *= qt[row + 5];
  14547. p6 *= qt[row + 6];
  14548. p7 *= qt[row + 7];
  14549. v0 = dctSqrt2 * p0 + 128 >> 8;
  14550. v1 = dctSqrt2 * p4 + 128 >> 8;
  14551. v2 = p2;
  14552. v3 = p6;
  14553. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14554. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14555. v5 = p3 << 4;
  14556. v6 = p5 << 4;
  14557. v0 = v0 + v1 + 1 >> 1;
  14558. v1 = v0 - v1;
  14559. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14560. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14561. v3 = t;
  14562. v4 = v4 + v6 + 1 >> 1;
  14563. v6 = v4 - v6;
  14564. v7 = v7 + v5 + 1 >> 1;
  14565. v5 = v7 - v5;
  14566. v0 = v0 + v3 + 1 >> 1;
  14567. v3 = v0 - v3;
  14568. v1 = v1 + v2 + 1 >> 1;
  14569. v2 = v1 - v2;
  14570. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14571. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14572. v7 = t;
  14573. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14574. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14575. v6 = t;
  14576. p[row] = v0 + v7;
  14577. p[row + 7] = v0 - v7;
  14578. p[row + 1] = v1 + v6;
  14579. p[row + 6] = v1 - v6;
  14580. p[row + 2] = v2 + v5;
  14581. p[row + 5] = v2 - v5;
  14582. p[row + 3] = v3 + v4;
  14583. p[row + 4] = v3 - v4;
  14584. }
  14585. for (var col = 0; col < 8; ++col) {
  14586. p0 = p[col];
  14587. p1 = p[col + 8];
  14588. p2 = p[col + 16];
  14589. p3 = p[col + 24];
  14590. p4 = p[col + 32];
  14591. p5 = p[col + 40];
  14592. p6 = p[col + 48];
  14593. p7 = p[col + 56];
  14594. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14595. t = dctSqrt2 * p0 + 8192 >> 14;
  14596. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14597. blockData[blockBufferOffset + col] = t;
  14598. blockData[blockBufferOffset + col + 8] = t;
  14599. blockData[blockBufferOffset + col + 16] = t;
  14600. blockData[blockBufferOffset + col + 24] = t;
  14601. blockData[blockBufferOffset + col + 32] = t;
  14602. blockData[blockBufferOffset + col + 40] = t;
  14603. blockData[blockBufferOffset + col + 48] = t;
  14604. blockData[blockBufferOffset + col + 56] = t;
  14605. continue;
  14606. }
  14607. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14608. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14609. v2 = p2;
  14610. v3 = p6;
  14611. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14612. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14613. v5 = p3;
  14614. v6 = p5;
  14615. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14616. v1 = v0 - v1;
  14617. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14618. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14619. v3 = t;
  14620. v4 = v4 + v6 + 1 >> 1;
  14621. v6 = v4 - v6;
  14622. v7 = v7 + v5 + 1 >> 1;
  14623. v5 = v7 - v5;
  14624. v0 = v0 + v3 + 1 >> 1;
  14625. v3 = v0 - v3;
  14626. v1 = v1 + v2 + 1 >> 1;
  14627. v2 = v1 - v2;
  14628. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14629. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14630. v7 = t;
  14631. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14632. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14633. v6 = t;
  14634. p0 = v0 + v7;
  14635. p7 = v0 - v7;
  14636. p1 = v1 + v6;
  14637. p6 = v1 - v6;
  14638. p2 = v2 + v5;
  14639. p5 = v2 - v5;
  14640. p3 = v3 + v4;
  14641. p4 = v3 - v4;
  14642. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14643. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14644. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14645. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14646. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14647. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14648. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14649. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14650. blockData[blockBufferOffset + col] = p0;
  14651. blockData[blockBufferOffset + col + 8] = p1;
  14652. blockData[blockBufferOffset + col + 16] = p2;
  14653. blockData[blockBufferOffset + col + 24] = p3;
  14654. blockData[blockBufferOffset + col + 32] = p4;
  14655. blockData[blockBufferOffset + col + 40] = p5;
  14656. blockData[blockBufferOffset + col + 48] = p6;
  14657. blockData[blockBufferOffset + col + 56] = p7;
  14658. }
  14659. }
  14660. function buildComponentData(frame, component) {
  14661. var blocksPerLine = component.blocksPerLine;
  14662. var blocksPerColumn = component.blocksPerColumn;
  14663. var computationBuffer = new Int16Array(64);
  14664. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14665. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14666. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14667. quantizeAndInverse(component, offset, computationBuffer);
  14668. }
  14669. }
  14670. return component.blockData;
  14671. }
  14672. function clamp0to255(a) {
  14673. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14674. }
  14675. JpegImage.prototype = {
  14676. parse: function parse(data) {
  14677. function readUint16() {
  14678. var value = data[offset] << 8 | data[offset + 1];
  14679. offset += 2;
  14680. return value;
  14681. }
  14682. function readDataBlock() {
  14683. var length = readUint16();
  14684. var array = data.subarray(offset, offset + length - 2);
  14685. offset += array.length;
  14686. return array;
  14687. }
  14688. function prepareComponents(frame) {
  14689. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14690. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14691. for (var i = 0; i < frame.components.length; i++) {
  14692. component = frame.components[i];
  14693. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14694. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14695. var blocksPerLineForMcu = mcusPerLine * component.h;
  14696. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14697. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14698. component.blockData = new Int16Array(blocksBufferSize);
  14699. component.blocksPerLine = blocksPerLine;
  14700. component.blocksPerColumn = blocksPerColumn;
  14701. }
  14702. frame.mcusPerLine = mcusPerLine;
  14703. frame.mcusPerColumn = mcusPerColumn;
  14704. }
  14705. var offset = 0;
  14706. var jfif = null;
  14707. var adobe = null;
  14708. var frame, resetInterval;
  14709. var quantizationTables = [];
  14710. var huffmanTablesAC = [], huffmanTablesDC = [];
  14711. var fileMarker = readUint16();
  14712. if (fileMarker !== 0xFFD8) {
  14713. error('JPEG error: SOI not found');
  14714. }
  14715. fileMarker = readUint16();
  14716. while (fileMarker !== 0xFFD9) {
  14717. var i, j, l;
  14718. switch (fileMarker) {
  14719. case 0xFFE0:
  14720. case 0xFFE1:
  14721. case 0xFFE2:
  14722. case 0xFFE3:
  14723. case 0xFFE4:
  14724. case 0xFFE5:
  14725. case 0xFFE6:
  14726. case 0xFFE7:
  14727. case 0xFFE8:
  14728. case 0xFFE9:
  14729. case 0xFFEA:
  14730. case 0xFFEB:
  14731. case 0xFFEC:
  14732. case 0xFFED:
  14733. case 0xFFEE:
  14734. case 0xFFEF:
  14735. case 0xFFFE:
  14736. var appData = readDataBlock();
  14737. if (fileMarker === 0xFFE0) {
  14738. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14739. jfif = {
  14740. version: {
  14741. major: appData[5],
  14742. minor: appData[6]
  14743. },
  14744. densityUnits: appData[7],
  14745. xDensity: appData[8] << 8 | appData[9],
  14746. yDensity: appData[10] << 8 | appData[11],
  14747. thumbWidth: appData[12],
  14748. thumbHeight: appData[13],
  14749. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14750. };
  14751. }
  14752. }
  14753. if (fileMarker === 0xFFEE) {
  14754. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14755. adobe = {
  14756. version: appData[5] << 8 | appData[6],
  14757. flags0: appData[7] << 8 | appData[8],
  14758. flags1: appData[9] << 8 | appData[10],
  14759. transformCode: appData[11]
  14760. };
  14761. }
  14762. }
  14763. break;
  14764. case 0xFFDB:
  14765. var quantizationTablesLength = readUint16();
  14766. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14767. var z;
  14768. while (offset < quantizationTablesEnd) {
  14769. var quantizationTableSpec = data[offset++];
  14770. var tableData = new Uint16Array(64);
  14771. if (quantizationTableSpec >> 4 === 0) {
  14772. for (j = 0; j < 64; j++) {
  14773. z = dctZigZag[j];
  14774. tableData[z] = data[offset++];
  14775. }
  14776. } else if (quantizationTableSpec >> 4 === 1) {
  14777. for (j = 0; j < 64; j++) {
  14778. z = dctZigZag[j];
  14779. tableData[z] = readUint16();
  14780. }
  14781. } else {
  14782. error('JPEG error: DQT - invalid table spec');
  14783. }
  14784. quantizationTables[quantizationTableSpec & 15] = tableData;
  14785. }
  14786. break;
  14787. case 0xFFC0:
  14788. case 0xFFC1:
  14789. case 0xFFC2:
  14790. if (frame) {
  14791. error('JPEG error: Only single frame JPEGs supported');
  14792. }
  14793. readUint16();
  14794. frame = {};
  14795. frame.extended = fileMarker === 0xFFC1;
  14796. frame.progressive = fileMarker === 0xFFC2;
  14797. frame.precision = data[offset++];
  14798. frame.scanLines = readUint16();
  14799. frame.samplesPerLine = readUint16();
  14800. frame.components = [];
  14801. frame.componentIds = {};
  14802. var componentsCount = data[offset++], componentId;
  14803. var maxH = 0, maxV = 0;
  14804. for (i = 0; i < componentsCount; i++) {
  14805. componentId = data[offset];
  14806. var h = data[offset + 1] >> 4;
  14807. var v = data[offset + 1] & 15;
  14808. if (maxH < h) {
  14809. maxH = h;
  14810. }
  14811. if (maxV < v) {
  14812. maxV = v;
  14813. }
  14814. var qId = data[offset + 2];
  14815. l = frame.components.push({
  14816. h: h,
  14817. v: v,
  14818. quantizationId: qId,
  14819. quantizationTable: null
  14820. });
  14821. frame.componentIds[componentId] = l - 1;
  14822. offset += 3;
  14823. }
  14824. frame.maxH = maxH;
  14825. frame.maxV = maxV;
  14826. prepareComponents(frame);
  14827. break;
  14828. case 0xFFC4:
  14829. var huffmanLength = readUint16();
  14830. for (i = 2; i < huffmanLength;) {
  14831. var huffmanTableSpec = data[offset++];
  14832. var codeLengths = new Uint8Array(16);
  14833. var codeLengthSum = 0;
  14834. for (j = 0; j < 16; j++, offset++) {
  14835. codeLengthSum += codeLengths[j] = data[offset];
  14836. }
  14837. var huffmanValues = new Uint8Array(codeLengthSum);
  14838. for (j = 0; j < codeLengthSum; j++, offset++) {
  14839. huffmanValues[j] = data[offset];
  14840. }
  14841. i += 17 + codeLengthSum;
  14842. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14843. }
  14844. break;
  14845. case 0xFFDD:
  14846. readUint16();
  14847. resetInterval = readUint16();
  14848. break;
  14849. case 0xFFDA:
  14850. var scanLength = readUint16();
  14851. var selectorsCount = data[offset++];
  14852. var components = [], component;
  14853. for (i = 0; i < selectorsCount; i++) {
  14854. var componentIndex = frame.componentIds[data[offset++]];
  14855. component = frame.components[componentIndex];
  14856. var tableSpec = data[offset++];
  14857. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14858. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14859. components.push(component);
  14860. }
  14861. var spectralStart = data[offset++];
  14862. var spectralEnd = data[offset++];
  14863. var successiveApproximation = data[offset++];
  14864. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14865. offset += processed;
  14866. break;
  14867. case 0xFFFF:
  14868. if (data[offset] !== 0xFF) {
  14869. offset--;
  14870. }
  14871. break;
  14872. default:
  14873. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14874. offset -= 3;
  14875. break;
  14876. }
  14877. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14878. }
  14879. fileMarker = readUint16();
  14880. }
  14881. this.width = frame.samplesPerLine;
  14882. this.height = frame.scanLines;
  14883. this.jfif = jfif;
  14884. this.adobe = adobe;
  14885. this.components = [];
  14886. for (i = 0; i < frame.components.length; i++) {
  14887. component = frame.components[i];
  14888. var quantizationTable = quantizationTables[component.quantizationId];
  14889. if (quantizationTable) {
  14890. component.quantizationTable = quantizationTable;
  14891. }
  14892. this.components.push({
  14893. output: buildComponentData(frame, component),
  14894. scaleX: component.h / frame.maxH,
  14895. scaleY: component.v / frame.maxV,
  14896. blocksPerLine: component.blocksPerLine,
  14897. blocksPerColumn: component.blocksPerColumn
  14898. });
  14899. }
  14900. this.numComponents = this.components.length;
  14901. },
  14902. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  14903. var scaleX = this.width / width, scaleY = this.height / height;
  14904. var component, componentScaleX, componentScaleY, blocksPerScanline;
  14905. var x, y, i, j, k;
  14906. var index;
  14907. var offset = 0;
  14908. var output;
  14909. var numComponents = this.components.length;
  14910. var dataLength = width * height * numComponents;
  14911. var data = new Uint8Array(dataLength);
  14912. var xScaleBlockOffset = new Uint32Array(width);
  14913. var mask3LSB = 0xfffffff8;
  14914. for (i = 0; i < numComponents; i++) {
  14915. component = this.components[i];
  14916. componentScaleX = component.scaleX * scaleX;
  14917. componentScaleY = component.scaleY * scaleY;
  14918. offset = i;
  14919. output = component.output;
  14920. blocksPerScanline = component.blocksPerLine + 1 << 3;
  14921. for (x = 0; x < width; x++) {
  14922. j = 0 | x * componentScaleX;
  14923. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  14924. }
  14925. for (y = 0; y < height; y++) {
  14926. j = 0 | y * componentScaleY;
  14927. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  14928. for (x = 0; x < width; x++) {
  14929. data[offset] = output[index + xScaleBlockOffset[x]];
  14930. offset += numComponents;
  14931. }
  14932. }
  14933. }
  14934. var transform = this.decodeTransform;
  14935. if (transform) {
  14936. for (i = 0; i < dataLength;) {
  14937. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  14938. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  14939. }
  14940. }
  14941. }
  14942. return data;
  14943. },
  14944. _isColorConversionNeeded: function isColorConversionNeeded() {
  14945. if (this.adobe && this.adobe.transformCode) {
  14946. return true;
  14947. } else if (this.numComponents === 3) {
  14948. if (!this.adobe && this.colorTransform === 0) {
  14949. return false;
  14950. }
  14951. return true;
  14952. } else {
  14953. if (!this.adobe && this.colorTransform === 1) {
  14954. return true;
  14955. }
  14956. return false;
  14957. }
  14958. },
  14959. _convertYccToRgb: function convertYccToRgb(data) {
  14960. var Y, Cb, Cr;
  14961. for (var i = 0, length = data.length; i < length; i += 3) {
  14962. Y = data[i];
  14963. Cb = data[i + 1];
  14964. Cr = data[i + 2];
  14965. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  14966. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  14967. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  14968. }
  14969. return data;
  14970. },
  14971. _convertYcckToRgb: function convertYcckToRgb(data) {
  14972. var Y, Cb, Cr, k;
  14973. var offset = 0;
  14974. for (var i = 0, length = data.length; i < length; i += 4) {
  14975. Y = data[i];
  14976. Cb = data[i + 1];
  14977. Cr = data[i + 2];
  14978. k = data[i + 3];
  14979. 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);
  14980. 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);
  14981. 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);
  14982. data[offset++] = clamp0to255(r);
  14983. data[offset++] = clamp0to255(g);
  14984. data[offset++] = clamp0to255(b);
  14985. }
  14986. return data;
  14987. },
  14988. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  14989. var Y, Cb, Cr;
  14990. for (var i = 0, length = data.length; i < length; i += 4) {
  14991. Y = data[i];
  14992. Cb = data[i + 1];
  14993. Cr = data[i + 2];
  14994. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  14995. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  14996. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  14997. }
  14998. return data;
  14999. },
  15000. _convertCmykToRgb: function convertCmykToRgb(data) {
  15001. var c, m, y, k;
  15002. var offset = 0;
  15003. var min = -255 * 255 * 255;
  15004. var scale = 1 / 255 / 255;
  15005. for (var i = 0, length = data.length; i < length; i += 4) {
  15006. c = data[i];
  15007. m = data[i + 1];
  15008. y = data[i + 2];
  15009. k = data[i + 3];
  15010. 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);
  15011. 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);
  15012. 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);
  15013. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15014. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15015. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15016. }
  15017. return data;
  15018. },
  15019. getData: function getData(width, height, forceRGBoutput) {
  15020. if (this.numComponents > 4) {
  15021. error('JPEG error: Unsupported color mode');
  15022. }
  15023. var data = this._getLinearizedBlockData(width, height);
  15024. if (this.numComponents === 1 && forceRGBoutput) {
  15025. var dataLength = data.length;
  15026. var rgbData = new Uint8Array(dataLength * 3);
  15027. var offset = 0;
  15028. for (var i = 0; i < dataLength; i++) {
  15029. var grayColor = data[i];
  15030. rgbData[offset++] = grayColor;
  15031. rgbData[offset++] = grayColor;
  15032. rgbData[offset++] = grayColor;
  15033. }
  15034. return rgbData;
  15035. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15036. return this._convertYccToRgb(data);
  15037. } else if (this.numComponents === 4) {
  15038. if (this._isColorConversionNeeded()) {
  15039. if (forceRGBoutput) {
  15040. return this._convertYcckToRgb(data);
  15041. } else {
  15042. return this._convertYcckToCmyk(data);
  15043. }
  15044. } else if (forceRGBoutput) {
  15045. return this._convertCmykToRgb(data);
  15046. }
  15047. }
  15048. return data;
  15049. }
  15050. };
  15051. return JpegImage;
  15052. }();
  15053. exports.JpegImage = JpegImage;
  15054. }));
  15055. (function (root, factory) {
  15056. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15057. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15058. var info = sharedUtil.info;
  15059. var warn = sharedUtil.warn;
  15060. var error = sharedUtil.error;
  15061. var log2 = sharedUtil.log2;
  15062. var readUint16 = sharedUtil.readUint16;
  15063. var readUint32 = sharedUtil.readUint32;
  15064. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15065. var JpxImage = function JpxImageClosure() {
  15066. var SubbandsGainLog2 = {
  15067. 'LL': 0,
  15068. 'LH': 1,
  15069. 'HL': 1,
  15070. 'HH': 2
  15071. };
  15072. function JpxImage() {
  15073. this.failOnCorruptedImage = false;
  15074. }
  15075. JpxImage.prototype = {
  15076. parse: function JpxImage_parse(data) {
  15077. var head = readUint16(data, 0);
  15078. if (head === 0xFF4F) {
  15079. this.parseCodestream(data, 0, data.length);
  15080. return;
  15081. }
  15082. var position = 0, length = data.length;
  15083. while (position < length) {
  15084. var headerSize = 8;
  15085. var lbox = readUint32(data, position);
  15086. var tbox = readUint32(data, position + 4);
  15087. position += headerSize;
  15088. if (lbox === 1) {
  15089. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15090. position += 8;
  15091. headerSize += 8;
  15092. }
  15093. if (lbox === 0) {
  15094. lbox = length - position + headerSize;
  15095. }
  15096. if (lbox < headerSize) {
  15097. error('JPX Error: Invalid box field size');
  15098. }
  15099. var dataLength = lbox - headerSize;
  15100. var jumpDataLength = true;
  15101. switch (tbox) {
  15102. case 0x6A703268:
  15103. jumpDataLength = false;
  15104. break;
  15105. case 0x636F6C72:
  15106. var method = data[position];
  15107. if (method === 1) {
  15108. var colorspace = readUint32(data, position + 3);
  15109. switch (colorspace) {
  15110. case 16:
  15111. case 17:
  15112. case 18:
  15113. break;
  15114. default:
  15115. warn('Unknown colorspace ' + colorspace);
  15116. break;
  15117. }
  15118. } else if (method === 2) {
  15119. info('ICC profile not supported');
  15120. }
  15121. break;
  15122. case 0x6A703263:
  15123. this.parseCodestream(data, position, position + dataLength);
  15124. break;
  15125. case 0x6A502020:
  15126. if (0x0d0a870a !== readUint32(data, position)) {
  15127. warn('Invalid JP2 signature');
  15128. }
  15129. break;
  15130. case 0x6A501A1A:
  15131. case 0x66747970:
  15132. case 0x72726571:
  15133. case 0x72657320:
  15134. case 0x69686472:
  15135. break;
  15136. default:
  15137. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15138. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15139. break;
  15140. }
  15141. if (jumpDataLength) {
  15142. position += dataLength;
  15143. }
  15144. }
  15145. },
  15146. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15147. var newByte = stream.getByte();
  15148. while (newByte >= 0) {
  15149. var oldByte = newByte;
  15150. newByte = stream.getByte();
  15151. var code = oldByte << 8 | newByte;
  15152. if (code === 0xFF51) {
  15153. stream.skip(4);
  15154. var Xsiz = stream.getInt32() >>> 0;
  15155. var Ysiz = stream.getInt32() >>> 0;
  15156. var XOsiz = stream.getInt32() >>> 0;
  15157. var YOsiz = stream.getInt32() >>> 0;
  15158. stream.skip(16);
  15159. var Csiz = stream.getUint16();
  15160. this.width = Xsiz - XOsiz;
  15161. this.height = Ysiz - YOsiz;
  15162. this.componentsCount = Csiz;
  15163. this.bitsPerComponent = 8;
  15164. return;
  15165. }
  15166. }
  15167. error('JPX Error: No size marker found in JPX stream');
  15168. },
  15169. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15170. var context = {};
  15171. var doNotRecover = false;
  15172. try {
  15173. var position = start;
  15174. while (position + 1 < end) {
  15175. var code = readUint16(data, position);
  15176. position += 2;
  15177. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15178. switch (code) {
  15179. case 0xFF4F:
  15180. context.mainHeader = true;
  15181. break;
  15182. case 0xFFD9:
  15183. break;
  15184. case 0xFF51:
  15185. length = readUint16(data, position);
  15186. var siz = {};
  15187. siz.Xsiz = readUint32(data, position + 4);
  15188. siz.Ysiz = readUint32(data, position + 8);
  15189. siz.XOsiz = readUint32(data, position + 12);
  15190. siz.YOsiz = readUint32(data, position + 16);
  15191. siz.XTsiz = readUint32(data, position + 20);
  15192. siz.YTsiz = readUint32(data, position + 24);
  15193. siz.XTOsiz = readUint32(data, position + 28);
  15194. siz.YTOsiz = readUint32(data, position + 32);
  15195. var componentsCount = readUint16(data, position + 36);
  15196. siz.Csiz = componentsCount;
  15197. var components = [];
  15198. j = position + 38;
  15199. for (var i = 0; i < componentsCount; i++) {
  15200. var component = {
  15201. precision: (data[j] & 0x7F) + 1,
  15202. isSigned: !!(data[j] & 0x80),
  15203. XRsiz: data[j + 1],
  15204. YRsiz: data[j + 1]
  15205. };
  15206. calculateComponentDimensions(component, siz);
  15207. components.push(component);
  15208. }
  15209. context.SIZ = siz;
  15210. context.components = components;
  15211. calculateTileGrids(context, components);
  15212. context.QCC = [];
  15213. context.COC = [];
  15214. break;
  15215. case 0xFF5C:
  15216. length = readUint16(data, position);
  15217. var qcd = {};
  15218. j = position + 2;
  15219. sqcd = data[j++];
  15220. switch (sqcd & 0x1F) {
  15221. case 0:
  15222. spqcdSize = 8;
  15223. scalarExpounded = true;
  15224. break;
  15225. case 1:
  15226. spqcdSize = 16;
  15227. scalarExpounded = false;
  15228. break;
  15229. case 2:
  15230. spqcdSize = 16;
  15231. scalarExpounded = true;
  15232. break;
  15233. default:
  15234. throw new Error('Invalid SQcd value ' + sqcd);
  15235. }
  15236. qcd.noQuantization = spqcdSize === 8;
  15237. qcd.scalarExpounded = scalarExpounded;
  15238. qcd.guardBits = sqcd >> 5;
  15239. spqcds = [];
  15240. while (j < length + position) {
  15241. var spqcd = {};
  15242. if (spqcdSize === 8) {
  15243. spqcd.epsilon = data[j++] >> 3;
  15244. spqcd.mu = 0;
  15245. } else {
  15246. spqcd.epsilon = data[j] >> 3;
  15247. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15248. j += 2;
  15249. }
  15250. spqcds.push(spqcd);
  15251. }
  15252. qcd.SPqcds = spqcds;
  15253. if (context.mainHeader) {
  15254. context.QCD = qcd;
  15255. } else {
  15256. context.currentTile.QCD = qcd;
  15257. context.currentTile.QCC = [];
  15258. }
  15259. break;
  15260. case 0xFF5D:
  15261. length = readUint16(data, position);
  15262. var qcc = {};
  15263. j = position + 2;
  15264. var cqcc;
  15265. if (context.SIZ.Csiz < 257) {
  15266. cqcc = data[j++];
  15267. } else {
  15268. cqcc = readUint16(data, j);
  15269. j += 2;
  15270. }
  15271. sqcd = data[j++];
  15272. switch (sqcd & 0x1F) {
  15273. case 0:
  15274. spqcdSize = 8;
  15275. scalarExpounded = true;
  15276. break;
  15277. case 1:
  15278. spqcdSize = 16;
  15279. scalarExpounded = false;
  15280. break;
  15281. case 2:
  15282. spqcdSize = 16;
  15283. scalarExpounded = true;
  15284. break;
  15285. default:
  15286. throw new Error('Invalid SQcd value ' + sqcd);
  15287. }
  15288. qcc.noQuantization = spqcdSize === 8;
  15289. qcc.scalarExpounded = scalarExpounded;
  15290. qcc.guardBits = sqcd >> 5;
  15291. spqcds = [];
  15292. while (j < length + position) {
  15293. spqcd = {};
  15294. if (spqcdSize === 8) {
  15295. spqcd.epsilon = data[j++] >> 3;
  15296. spqcd.mu = 0;
  15297. } else {
  15298. spqcd.epsilon = data[j] >> 3;
  15299. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15300. j += 2;
  15301. }
  15302. spqcds.push(spqcd);
  15303. }
  15304. qcc.SPqcds = spqcds;
  15305. if (context.mainHeader) {
  15306. context.QCC[cqcc] = qcc;
  15307. } else {
  15308. context.currentTile.QCC[cqcc] = qcc;
  15309. }
  15310. break;
  15311. case 0xFF52:
  15312. length = readUint16(data, position);
  15313. var cod = {};
  15314. j = position + 2;
  15315. var scod = data[j++];
  15316. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15317. cod.sopMarkerUsed = !!(scod & 2);
  15318. cod.ephMarkerUsed = !!(scod & 4);
  15319. cod.progressionOrder = data[j++];
  15320. cod.layersCount = readUint16(data, j);
  15321. j += 2;
  15322. cod.multipleComponentTransform = data[j++];
  15323. cod.decompositionLevelsCount = data[j++];
  15324. cod.xcb = (data[j++] & 0xF) + 2;
  15325. cod.ycb = (data[j++] & 0xF) + 2;
  15326. var blockStyle = data[j++];
  15327. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15328. cod.resetContextProbabilities = !!(blockStyle & 2);
  15329. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15330. cod.verticalyStripe = !!(blockStyle & 8);
  15331. cod.predictableTermination = !!(blockStyle & 16);
  15332. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15333. cod.reversibleTransformation = data[j++];
  15334. if (cod.entropyCoderWithCustomPrecincts) {
  15335. var precinctsSizes = [];
  15336. while (j < length + position) {
  15337. var precinctsSize = data[j++];
  15338. precinctsSizes.push({
  15339. PPx: precinctsSize & 0xF,
  15340. PPy: precinctsSize >> 4
  15341. });
  15342. }
  15343. cod.precinctsSizes = precinctsSizes;
  15344. }
  15345. var unsupported = [];
  15346. if (cod.selectiveArithmeticCodingBypass) {
  15347. unsupported.push('selectiveArithmeticCodingBypass');
  15348. }
  15349. if (cod.resetContextProbabilities) {
  15350. unsupported.push('resetContextProbabilities');
  15351. }
  15352. if (cod.terminationOnEachCodingPass) {
  15353. unsupported.push('terminationOnEachCodingPass');
  15354. }
  15355. if (cod.verticalyStripe) {
  15356. unsupported.push('verticalyStripe');
  15357. }
  15358. if (cod.predictableTermination) {
  15359. unsupported.push('predictableTermination');
  15360. }
  15361. if (unsupported.length > 0) {
  15362. doNotRecover = true;
  15363. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15364. }
  15365. if (context.mainHeader) {
  15366. context.COD = cod;
  15367. } else {
  15368. context.currentTile.COD = cod;
  15369. context.currentTile.COC = [];
  15370. }
  15371. break;
  15372. case 0xFF90:
  15373. length = readUint16(data, position);
  15374. tile = {};
  15375. tile.index = readUint16(data, position + 2);
  15376. tile.length = readUint32(data, position + 4);
  15377. tile.dataEnd = tile.length + position - 2;
  15378. tile.partIndex = data[position + 8];
  15379. tile.partsCount = data[position + 9];
  15380. context.mainHeader = false;
  15381. if (tile.partIndex === 0) {
  15382. tile.COD = context.COD;
  15383. tile.COC = context.COC.slice(0);
  15384. tile.QCD = context.QCD;
  15385. tile.QCC = context.QCC.slice(0);
  15386. }
  15387. context.currentTile = tile;
  15388. break;
  15389. case 0xFF93:
  15390. tile = context.currentTile;
  15391. if (tile.partIndex === 0) {
  15392. initializeTile(context, tile.index);
  15393. buildPackets(context);
  15394. }
  15395. length = tile.dataEnd - position;
  15396. parseTilePackets(context, data, position, length);
  15397. break;
  15398. case 0xFF55:
  15399. case 0xFF57:
  15400. case 0xFF58:
  15401. case 0xFF64:
  15402. length = readUint16(data, position);
  15403. break;
  15404. case 0xFF53:
  15405. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15406. default:
  15407. throw new Error('Unknown codestream code: ' + code.toString(16));
  15408. }
  15409. position += length;
  15410. }
  15411. } catch (e) {
  15412. if (doNotRecover || this.failOnCorruptedImage) {
  15413. error('JPX Error: ' + e.message);
  15414. } else {
  15415. warn('JPX: Trying to recover from: ' + e.message);
  15416. }
  15417. }
  15418. this.tiles = transformComponents(context);
  15419. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15420. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15421. this.componentsCount = context.SIZ.Csiz;
  15422. }
  15423. };
  15424. function calculateComponentDimensions(component, siz) {
  15425. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15426. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15427. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15428. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15429. component.width = component.x1 - component.x0;
  15430. component.height = component.y1 - component.y0;
  15431. }
  15432. function calculateTileGrids(context, components) {
  15433. var siz = context.SIZ;
  15434. var tile, tiles = [];
  15435. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15436. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15437. for (var q = 0; q < numYtiles; q++) {
  15438. for (var p = 0; p < numXtiles; p++) {
  15439. tile = {};
  15440. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15441. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15442. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15443. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15444. tile.width = tile.tx1 - tile.tx0;
  15445. tile.height = tile.ty1 - tile.ty0;
  15446. tile.components = [];
  15447. tiles.push(tile);
  15448. }
  15449. }
  15450. context.tiles = tiles;
  15451. var componentsCount = siz.Csiz;
  15452. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15453. var component = components[i];
  15454. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15455. var tileComponent = {};
  15456. tile = tiles[j];
  15457. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15458. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15459. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15460. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15461. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15462. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15463. tile.components[i] = tileComponent;
  15464. }
  15465. }
  15466. }
  15467. function getBlocksDimensions(context, component, r) {
  15468. var codOrCoc = component.codingStyleParameters;
  15469. var result = {};
  15470. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15471. result.PPx = 15;
  15472. result.PPy = 15;
  15473. } else {
  15474. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15475. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15476. }
  15477. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15478. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15479. return result;
  15480. }
  15481. function buildPrecincts(context, resolution, dimensions) {
  15482. var precinctWidth = 1 << dimensions.PPx;
  15483. var precinctHeight = 1 << dimensions.PPy;
  15484. var isZeroRes = resolution.resLevel === 0;
  15485. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15486. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15487. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15488. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15489. var numprecincts = numprecinctswide * numprecinctshigh;
  15490. resolution.precinctParameters = {
  15491. precinctWidth: precinctWidth,
  15492. precinctHeight: precinctHeight,
  15493. numprecinctswide: numprecinctswide,
  15494. numprecinctshigh: numprecinctshigh,
  15495. numprecincts: numprecincts,
  15496. precinctWidthInSubband: precinctWidthInSubband,
  15497. precinctHeightInSubband: precinctHeightInSubband
  15498. };
  15499. }
  15500. function buildCodeblocks(context, subband, dimensions) {
  15501. var xcb_ = dimensions.xcb_;
  15502. var ycb_ = dimensions.ycb_;
  15503. var codeblockWidth = 1 << xcb_;
  15504. var codeblockHeight = 1 << ycb_;
  15505. var cbx0 = subband.tbx0 >> xcb_;
  15506. var cby0 = subband.tby0 >> ycb_;
  15507. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15508. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15509. var precinctParameters = subband.resolution.precinctParameters;
  15510. var codeblocks = [];
  15511. var precincts = [];
  15512. var i, j, codeblock, precinctNumber;
  15513. for (j = cby0; j < cby1; j++) {
  15514. for (i = cbx0; i < cbx1; i++) {
  15515. codeblock = {
  15516. cbx: i,
  15517. cby: j,
  15518. tbx0: codeblockWidth * i,
  15519. tby0: codeblockHeight * j,
  15520. tbx1: codeblockWidth * (i + 1),
  15521. tby1: codeblockHeight * (j + 1)
  15522. };
  15523. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15524. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15525. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15526. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15527. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15528. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15529. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15530. codeblock.precinctNumber = precinctNumber;
  15531. codeblock.subbandType = subband.type;
  15532. codeblock.Lblock = 3;
  15533. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15534. continue;
  15535. }
  15536. codeblocks.push(codeblock);
  15537. var precinct = precincts[precinctNumber];
  15538. if (precinct !== undefined) {
  15539. if (i < precinct.cbxMin) {
  15540. precinct.cbxMin = i;
  15541. } else if (i > precinct.cbxMax) {
  15542. precinct.cbxMax = i;
  15543. }
  15544. if (j < precinct.cbyMin) {
  15545. precinct.cbxMin = j;
  15546. } else if (j > precinct.cbyMax) {
  15547. precinct.cbyMax = j;
  15548. }
  15549. } else {
  15550. precincts[precinctNumber] = precinct = {
  15551. cbxMin: i,
  15552. cbyMin: j,
  15553. cbxMax: i,
  15554. cbyMax: j
  15555. };
  15556. }
  15557. codeblock.precinct = precinct;
  15558. }
  15559. }
  15560. subband.codeblockParameters = {
  15561. codeblockWidth: xcb_,
  15562. codeblockHeight: ycb_,
  15563. numcodeblockwide: cbx1 - cbx0 + 1,
  15564. numcodeblockhigh: cby1 - cby0 + 1
  15565. };
  15566. subband.codeblocks = codeblocks;
  15567. subband.precincts = precincts;
  15568. }
  15569. function createPacket(resolution, precinctNumber, layerNumber) {
  15570. var precinctCodeblocks = [];
  15571. var subbands = resolution.subbands;
  15572. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15573. var subband = subbands[i];
  15574. var codeblocks = subband.codeblocks;
  15575. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15576. var codeblock = codeblocks[j];
  15577. if (codeblock.precinctNumber !== precinctNumber) {
  15578. continue;
  15579. }
  15580. precinctCodeblocks.push(codeblock);
  15581. }
  15582. }
  15583. return {
  15584. layerNumber: layerNumber,
  15585. codeblocks: precinctCodeblocks
  15586. };
  15587. }
  15588. function LayerResolutionComponentPositionIterator(context) {
  15589. var siz = context.SIZ;
  15590. var tileIndex = context.currentTile.index;
  15591. var tile = context.tiles[tileIndex];
  15592. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15593. var componentsCount = siz.Csiz;
  15594. var maxDecompositionLevelsCount = 0;
  15595. for (var q = 0; q < componentsCount; q++) {
  15596. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15597. }
  15598. var l = 0, r = 0, i = 0, k = 0;
  15599. this.nextPacket = function JpxImage_nextPacket() {
  15600. for (; l < layersCount; l++) {
  15601. for (; r <= maxDecompositionLevelsCount; r++) {
  15602. for (; i < componentsCount; i++) {
  15603. var component = tile.components[i];
  15604. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15605. continue;
  15606. }
  15607. var resolution = component.resolutions[r];
  15608. var numprecincts = resolution.precinctParameters.numprecincts;
  15609. for (; k < numprecincts;) {
  15610. var packet = createPacket(resolution, k, l);
  15611. k++;
  15612. return packet;
  15613. }
  15614. k = 0;
  15615. }
  15616. i = 0;
  15617. }
  15618. r = 0;
  15619. }
  15620. error('JPX Error: Out of packets');
  15621. };
  15622. }
  15623. function ResolutionLayerComponentPositionIterator(context) {
  15624. var siz = context.SIZ;
  15625. var tileIndex = context.currentTile.index;
  15626. var tile = context.tiles[tileIndex];
  15627. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15628. var componentsCount = siz.Csiz;
  15629. var maxDecompositionLevelsCount = 0;
  15630. for (var q = 0; q < componentsCount; q++) {
  15631. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15632. }
  15633. var r = 0, l = 0, i = 0, k = 0;
  15634. this.nextPacket = function JpxImage_nextPacket() {
  15635. for (; r <= maxDecompositionLevelsCount; r++) {
  15636. for (; l < layersCount; l++) {
  15637. for (; i < componentsCount; i++) {
  15638. var component = tile.components[i];
  15639. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15640. continue;
  15641. }
  15642. var resolution = component.resolutions[r];
  15643. var numprecincts = resolution.precinctParameters.numprecincts;
  15644. for (; k < numprecincts;) {
  15645. var packet = createPacket(resolution, k, l);
  15646. k++;
  15647. return packet;
  15648. }
  15649. k = 0;
  15650. }
  15651. i = 0;
  15652. }
  15653. l = 0;
  15654. }
  15655. error('JPX Error: Out of packets');
  15656. };
  15657. }
  15658. function ResolutionPositionComponentLayerIterator(context) {
  15659. var siz = context.SIZ;
  15660. var tileIndex = context.currentTile.index;
  15661. var tile = context.tiles[tileIndex];
  15662. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15663. var componentsCount = siz.Csiz;
  15664. var l, r, c, p;
  15665. var maxDecompositionLevelsCount = 0;
  15666. for (c = 0; c < componentsCount; c++) {
  15667. var component = tile.components[c];
  15668. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15669. }
  15670. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15671. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15672. var maxNumPrecincts = 0;
  15673. for (c = 0; c < componentsCount; ++c) {
  15674. var resolutions = tile.components[c].resolutions;
  15675. if (r < resolutions.length) {
  15676. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15677. }
  15678. }
  15679. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15680. }
  15681. l = 0;
  15682. r = 0;
  15683. c = 0;
  15684. p = 0;
  15685. this.nextPacket = function JpxImage_nextPacket() {
  15686. for (; r <= maxDecompositionLevelsCount; r++) {
  15687. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15688. for (; c < componentsCount; c++) {
  15689. var component = tile.components[c];
  15690. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15691. continue;
  15692. }
  15693. var resolution = component.resolutions[r];
  15694. var numprecincts = resolution.precinctParameters.numprecincts;
  15695. if (p >= numprecincts) {
  15696. continue;
  15697. }
  15698. for (; l < layersCount;) {
  15699. var packet = createPacket(resolution, p, l);
  15700. l++;
  15701. return packet;
  15702. }
  15703. l = 0;
  15704. }
  15705. c = 0;
  15706. }
  15707. p = 0;
  15708. }
  15709. error('JPX Error: Out of packets');
  15710. };
  15711. }
  15712. function PositionComponentResolutionLayerIterator(context) {
  15713. var siz = context.SIZ;
  15714. var tileIndex = context.currentTile.index;
  15715. var tile = context.tiles[tileIndex];
  15716. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15717. var componentsCount = siz.Csiz;
  15718. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15719. var precinctsIterationSizes = precinctsSizes;
  15720. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15721. this.nextPacket = function JpxImage_nextPacket() {
  15722. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15723. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15724. for (; c < componentsCount; c++) {
  15725. var component = tile.components[c];
  15726. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15727. for (; r <= decompositionLevelsCount; r++) {
  15728. var resolution = component.resolutions[r];
  15729. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15730. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15731. if (k === null) {
  15732. continue;
  15733. }
  15734. for (; l < layersCount;) {
  15735. var packet = createPacket(resolution, k, l);
  15736. l++;
  15737. return packet;
  15738. }
  15739. l = 0;
  15740. }
  15741. r = 0;
  15742. }
  15743. c = 0;
  15744. }
  15745. px = 0;
  15746. }
  15747. error('JPX Error: Out of packets');
  15748. };
  15749. }
  15750. function ComponentPositionResolutionLayerIterator(context) {
  15751. var siz = context.SIZ;
  15752. var tileIndex = context.currentTile.index;
  15753. var tile = context.tiles[tileIndex];
  15754. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15755. var componentsCount = siz.Csiz;
  15756. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15757. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15758. this.nextPacket = function JpxImage_nextPacket() {
  15759. for (; c < componentsCount; ++c) {
  15760. var component = tile.components[c];
  15761. var precinctsIterationSizes = precinctsSizes.components[c];
  15762. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15763. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15764. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15765. for (; r <= decompositionLevelsCount; r++) {
  15766. var resolution = component.resolutions[r];
  15767. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15768. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15769. if (k === null) {
  15770. continue;
  15771. }
  15772. for (; l < layersCount;) {
  15773. var packet = createPacket(resolution, k, l);
  15774. l++;
  15775. return packet;
  15776. }
  15777. l = 0;
  15778. }
  15779. r = 0;
  15780. }
  15781. px = 0;
  15782. }
  15783. py = 0;
  15784. }
  15785. error('JPX Error: Out of packets');
  15786. };
  15787. }
  15788. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15789. var posX = pxIndex * precinctIterationSizes.minWidth;
  15790. var posY = pyIndex * precinctIterationSizes.minHeight;
  15791. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15792. return null;
  15793. }
  15794. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15795. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15796. }
  15797. function getPrecinctSizesInImageScale(tile) {
  15798. var componentsCount = tile.components.length;
  15799. var minWidth = Number.MAX_VALUE;
  15800. var minHeight = Number.MAX_VALUE;
  15801. var maxNumWide = 0;
  15802. var maxNumHigh = 0;
  15803. var sizePerComponent = new Array(componentsCount);
  15804. for (var c = 0; c < componentsCount; c++) {
  15805. var component = tile.components[c];
  15806. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15807. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15808. var minWidthCurrentComponent = Number.MAX_VALUE;
  15809. var minHeightCurrentComponent = Number.MAX_VALUE;
  15810. var maxNumWideCurrentComponent = 0;
  15811. var maxNumHighCurrentComponent = 0;
  15812. var scale = 1;
  15813. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15814. var resolution = component.resolutions[r];
  15815. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15816. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15817. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15818. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15819. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15820. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15821. sizePerResolution[r] = {
  15822. width: widthCurrentResolution,
  15823. height: heightCurrentResolution
  15824. };
  15825. scale <<= 1;
  15826. }
  15827. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15828. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15829. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15830. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15831. sizePerComponent[c] = {
  15832. resolutions: sizePerResolution,
  15833. minWidth: minWidthCurrentComponent,
  15834. minHeight: minHeightCurrentComponent,
  15835. maxNumWide: maxNumWideCurrentComponent,
  15836. maxNumHigh: maxNumHighCurrentComponent
  15837. };
  15838. }
  15839. return {
  15840. components: sizePerComponent,
  15841. minWidth: minWidth,
  15842. minHeight: minHeight,
  15843. maxNumWide: maxNumWide,
  15844. maxNumHigh: maxNumHigh
  15845. };
  15846. }
  15847. function buildPackets(context) {
  15848. var siz = context.SIZ;
  15849. var tileIndex = context.currentTile.index;
  15850. var tile = context.tiles[tileIndex];
  15851. var componentsCount = siz.Csiz;
  15852. for (var c = 0; c < componentsCount; c++) {
  15853. var component = tile.components[c];
  15854. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15855. var resolutions = [];
  15856. var subbands = [];
  15857. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15858. var blocksDimensions = getBlocksDimensions(context, component, r);
  15859. var resolution = {};
  15860. var scale = 1 << decompositionLevelsCount - r;
  15861. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15862. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15863. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15864. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15865. resolution.resLevel = r;
  15866. buildPrecincts(context, resolution, blocksDimensions);
  15867. resolutions.push(resolution);
  15868. var subband;
  15869. if (r === 0) {
  15870. subband = {};
  15871. subband.type = 'LL';
  15872. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15873. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15874. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15875. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15876. subband.resolution = resolution;
  15877. buildCodeblocks(context, subband, blocksDimensions);
  15878. subbands.push(subband);
  15879. resolution.subbands = [subband];
  15880. } else {
  15881. var bscale = 1 << decompositionLevelsCount - r + 1;
  15882. var resolutionSubbands = [];
  15883. subband = {};
  15884. subband.type = 'HL';
  15885. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15886. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  15887. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15888. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  15889. subband.resolution = resolution;
  15890. buildCodeblocks(context, subband, blocksDimensions);
  15891. subbands.push(subband);
  15892. resolutionSubbands.push(subband);
  15893. subband = {};
  15894. subband.type = 'LH';
  15895. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  15896. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15897. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  15898. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15899. subband.resolution = resolution;
  15900. buildCodeblocks(context, subband, blocksDimensions);
  15901. subbands.push(subband);
  15902. resolutionSubbands.push(subband);
  15903. subband = {};
  15904. subband.type = 'HH';
  15905. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15906. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15907. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15908. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15909. subband.resolution = resolution;
  15910. buildCodeblocks(context, subband, blocksDimensions);
  15911. subbands.push(subband);
  15912. resolutionSubbands.push(subband);
  15913. resolution.subbands = resolutionSubbands;
  15914. }
  15915. }
  15916. component.resolutions = resolutions;
  15917. component.subbands = subbands;
  15918. }
  15919. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  15920. switch (progressionOrder) {
  15921. case 0:
  15922. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  15923. break;
  15924. case 1:
  15925. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  15926. break;
  15927. case 2:
  15928. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  15929. break;
  15930. case 3:
  15931. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  15932. break;
  15933. case 4:
  15934. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  15935. break;
  15936. default:
  15937. error('JPX Error: Unsupported progression order ' + progressionOrder);
  15938. }
  15939. }
  15940. function parseTilePackets(context, data, offset, dataLength) {
  15941. var position = 0;
  15942. var buffer, bufferSize = 0, skipNextBit = false;
  15943. function readBits(count) {
  15944. while (bufferSize < count) {
  15945. var b = data[offset + position];
  15946. position++;
  15947. if (skipNextBit) {
  15948. buffer = buffer << 7 | b;
  15949. bufferSize += 7;
  15950. skipNextBit = false;
  15951. } else {
  15952. buffer = buffer << 8 | b;
  15953. bufferSize += 8;
  15954. }
  15955. if (b === 0xFF) {
  15956. skipNextBit = true;
  15957. }
  15958. }
  15959. bufferSize -= count;
  15960. return buffer >>> bufferSize & (1 << count) - 1;
  15961. }
  15962. function skipMarkerIfEqual(value) {
  15963. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  15964. skipBytes(1);
  15965. return true;
  15966. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  15967. skipBytes(2);
  15968. return true;
  15969. }
  15970. return false;
  15971. }
  15972. function skipBytes(count) {
  15973. position += count;
  15974. }
  15975. function alignToByte() {
  15976. bufferSize = 0;
  15977. if (skipNextBit) {
  15978. position++;
  15979. skipNextBit = false;
  15980. }
  15981. }
  15982. function readCodingpasses() {
  15983. if (readBits(1) === 0) {
  15984. return 1;
  15985. }
  15986. if (readBits(1) === 0) {
  15987. return 2;
  15988. }
  15989. var value = readBits(2);
  15990. if (value < 3) {
  15991. return value + 3;
  15992. }
  15993. value = readBits(5);
  15994. if (value < 31) {
  15995. return value + 6;
  15996. }
  15997. value = readBits(7);
  15998. return value + 37;
  15999. }
  16000. var tileIndex = context.currentTile.index;
  16001. var tile = context.tiles[tileIndex];
  16002. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16003. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16004. var packetsIterator = tile.packetsIterator;
  16005. while (position < dataLength) {
  16006. alignToByte();
  16007. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16008. skipBytes(4);
  16009. }
  16010. var packet = packetsIterator.nextPacket();
  16011. if (!readBits(1)) {
  16012. continue;
  16013. }
  16014. var layerNumber = packet.layerNumber;
  16015. var queue = [], codeblock;
  16016. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16017. codeblock = packet.codeblocks[i];
  16018. var precinct = codeblock.precinct;
  16019. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16020. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16021. var codeblockIncluded = false;
  16022. var firstTimeInclusion = false;
  16023. var valueReady;
  16024. if (codeblock['included'] !== undefined) {
  16025. codeblockIncluded = !!readBits(1);
  16026. } else {
  16027. precinct = codeblock.precinct;
  16028. var inclusionTree, zeroBitPlanesTree;
  16029. if (precinct['inclusionTree'] !== undefined) {
  16030. inclusionTree = precinct.inclusionTree;
  16031. } else {
  16032. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16033. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16034. inclusionTree = new InclusionTree(width, height, layerNumber);
  16035. zeroBitPlanesTree = new TagTree(width, height);
  16036. precinct.inclusionTree = inclusionTree;
  16037. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16038. }
  16039. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16040. while (true) {
  16041. if (readBits(1)) {
  16042. valueReady = !inclusionTree.nextLevel();
  16043. if (valueReady) {
  16044. codeblock.included = true;
  16045. codeblockIncluded = firstTimeInclusion = true;
  16046. break;
  16047. }
  16048. } else {
  16049. inclusionTree.incrementValue(layerNumber);
  16050. break;
  16051. }
  16052. }
  16053. }
  16054. }
  16055. if (!codeblockIncluded) {
  16056. continue;
  16057. }
  16058. if (firstTimeInclusion) {
  16059. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16060. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16061. while (true) {
  16062. if (readBits(1)) {
  16063. valueReady = !zeroBitPlanesTree.nextLevel();
  16064. if (valueReady) {
  16065. break;
  16066. }
  16067. } else {
  16068. zeroBitPlanesTree.incrementValue();
  16069. }
  16070. }
  16071. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16072. }
  16073. var codingpasses = readCodingpasses();
  16074. while (readBits(1)) {
  16075. codeblock.Lblock++;
  16076. }
  16077. var codingpassesLog2 = log2(codingpasses);
  16078. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16079. var codedDataLength = readBits(bits);
  16080. queue.push({
  16081. codeblock: codeblock,
  16082. codingpasses: codingpasses,
  16083. dataLength: codedDataLength
  16084. });
  16085. }
  16086. alignToByte();
  16087. if (ephMarkerUsed) {
  16088. skipMarkerIfEqual(0x92);
  16089. }
  16090. while (queue.length > 0) {
  16091. var packetItem = queue.shift();
  16092. codeblock = packetItem.codeblock;
  16093. if (codeblock['data'] === undefined) {
  16094. codeblock.data = [];
  16095. }
  16096. codeblock.data.push({
  16097. data: data,
  16098. start: offset + position,
  16099. end: offset + position + packetItem.dataLength,
  16100. codingpasses: packetItem.codingpasses
  16101. });
  16102. position += packetItem.dataLength;
  16103. }
  16104. }
  16105. return position;
  16106. }
  16107. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16108. var x0 = subband.tbx0;
  16109. var y0 = subband.tby0;
  16110. var width = subband.tbx1 - subband.tbx0;
  16111. var codeblocks = subband.codeblocks;
  16112. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16113. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16114. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16115. var codeblock = codeblocks[i];
  16116. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16117. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16118. if (blockWidth === 0 || blockHeight === 0) {
  16119. continue;
  16120. }
  16121. if (codeblock['data'] === undefined) {
  16122. continue;
  16123. }
  16124. var bitModel, currentCodingpassType;
  16125. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16126. currentCodingpassType = 2;
  16127. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16128. var j, jj, dataItem;
  16129. for (j = 0, jj = data.length; j < jj; j++) {
  16130. dataItem = data[j];
  16131. totalLength += dataItem.end - dataItem.start;
  16132. codingpasses += dataItem.codingpasses;
  16133. }
  16134. var encodedData = new Uint8Array(totalLength);
  16135. var position = 0;
  16136. for (j = 0, jj = data.length; j < jj; j++) {
  16137. dataItem = data[j];
  16138. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16139. encodedData.set(chunk, position);
  16140. position += chunk.length;
  16141. }
  16142. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16143. bitModel.setDecoder(decoder);
  16144. for (j = 0; j < codingpasses; j++) {
  16145. switch (currentCodingpassType) {
  16146. case 0:
  16147. bitModel.runSignificancePropagationPass();
  16148. break;
  16149. case 1:
  16150. bitModel.runMagnitudeRefinementPass();
  16151. break;
  16152. case 2:
  16153. bitModel.runCleanupPass();
  16154. if (segmentationSymbolUsed) {
  16155. bitModel.checkSegmentationSymbol();
  16156. }
  16157. break;
  16158. }
  16159. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16160. }
  16161. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16162. var sign = bitModel.coefficentsSign;
  16163. var magnitude = bitModel.coefficentsMagnitude;
  16164. var bitsDecoded = bitModel.bitsDecoded;
  16165. var magnitudeCorrection = reversible ? 0 : 0.5;
  16166. var k, n, nb;
  16167. position = 0;
  16168. var interleave = subband.type !== 'LL';
  16169. for (j = 0; j < blockHeight; j++) {
  16170. var row = offset / width | 0;
  16171. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16172. for (k = 0; k < blockWidth; k++) {
  16173. n = magnitude[position];
  16174. if (n !== 0) {
  16175. n = (n + magnitudeCorrection) * delta;
  16176. if (sign[position] !== 0) {
  16177. n = -n;
  16178. }
  16179. nb = bitsDecoded[position];
  16180. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16181. if (reversible && nb >= mb) {
  16182. coefficients[pos] = n;
  16183. } else {
  16184. coefficients[pos] = n * (1 << mb - nb);
  16185. }
  16186. }
  16187. offset++;
  16188. position++;
  16189. }
  16190. offset += width - blockWidth;
  16191. }
  16192. }
  16193. }
  16194. function transformTile(context, tile, c) {
  16195. var component = tile.components[c];
  16196. var codingStyleParameters = component.codingStyleParameters;
  16197. var quantizationParameters = component.quantizationParameters;
  16198. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16199. var spqcds = quantizationParameters.SPqcds;
  16200. var scalarExpounded = quantizationParameters.scalarExpounded;
  16201. var guardBits = quantizationParameters.guardBits;
  16202. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16203. var precision = context.components[c].precision;
  16204. var reversible = codingStyleParameters.reversibleTransformation;
  16205. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16206. var subbandCoefficients = [];
  16207. var b = 0;
  16208. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16209. var resolution = component.resolutions[i];
  16210. var width = resolution.trx1 - resolution.trx0;
  16211. var height = resolution.try1 - resolution.try0;
  16212. var coefficients = new Float32Array(width * height);
  16213. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16214. var mu, epsilon;
  16215. if (!scalarExpounded) {
  16216. mu = spqcds[0].mu;
  16217. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16218. } else {
  16219. mu = spqcds[b].mu;
  16220. epsilon = spqcds[b].epsilon;
  16221. b++;
  16222. }
  16223. var subband = resolution.subbands[j];
  16224. var gainLog2 = SubbandsGainLog2[subband.type];
  16225. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16226. var mb = guardBits + epsilon - 1;
  16227. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16228. }
  16229. subbandCoefficients.push({
  16230. width: width,
  16231. height: height,
  16232. items: coefficients
  16233. });
  16234. }
  16235. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16236. return {
  16237. left: component.tcx0,
  16238. top: component.tcy0,
  16239. width: result.width,
  16240. height: result.height,
  16241. items: result.items
  16242. };
  16243. }
  16244. function transformComponents(context) {
  16245. var siz = context.SIZ;
  16246. var components = context.components;
  16247. var componentsCount = siz.Csiz;
  16248. var resultImages = [];
  16249. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16250. var tile = context.tiles[i];
  16251. var transformedTiles = [];
  16252. var c;
  16253. for (c = 0; c < componentsCount; c++) {
  16254. transformedTiles[c] = transformTile(context, tile, c);
  16255. }
  16256. var tile0 = transformedTiles[0];
  16257. var out = new Uint8Array(tile0.items.length * componentsCount);
  16258. var result = {
  16259. left: tile0.left,
  16260. top: tile0.top,
  16261. width: tile0.width,
  16262. height: tile0.height,
  16263. items: out
  16264. };
  16265. var shift, offset, max, min, maxK;
  16266. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16267. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16268. var fourComponents = componentsCount === 4;
  16269. var y0items = transformedTiles[0].items;
  16270. var y1items = transformedTiles[1].items;
  16271. var y2items = transformedTiles[2].items;
  16272. var y3items = fourComponents ? transformedTiles[3].items : null;
  16273. shift = components[0].precision - 8;
  16274. offset = (128 << shift) + 0.5;
  16275. max = 255 * (1 << shift);
  16276. maxK = max * 0.5;
  16277. min = -maxK;
  16278. var component0 = tile.components[0];
  16279. var alpha01 = componentsCount - 3;
  16280. jj = y0items.length;
  16281. if (!component0.codingStyleParameters.reversibleTransformation) {
  16282. for (j = 0; j < jj; j++, pos += alpha01) {
  16283. y0 = y0items[j] + offset;
  16284. y1 = y1items[j];
  16285. y2 = y2items[j];
  16286. r = y0 + 1.402 * y2;
  16287. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16288. b = y0 + 1.772 * y1;
  16289. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16290. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16291. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16292. }
  16293. } else {
  16294. for (j = 0; j < jj; j++, pos += alpha01) {
  16295. y0 = y0items[j] + offset;
  16296. y1 = y1items[j];
  16297. y2 = y2items[j];
  16298. g = y0 - (y2 + y1 >> 2);
  16299. r = g + y2;
  16300. b = g + y1;
  16301. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16302. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16303. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16304. }
  16305. }
  16306. if (fourComponents) {
  16307. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16308. k = y3items[j];
  16309. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16310. }
  16311. }
  16312. } else {
  16313. for (c = 0; c < componentsCount; c++) {
  16314. var items = transformedTiles[c].items;
  16315. shift = components[c].precision - 8;
  16316. offset = (128 << shift) + 0.5;
  16317. max = 127.5 * (1 << shift);
  16318. min = -max;
  16319. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16320. val = items[j];
  16321. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16322. pos += componentsCount;
  16323. }
  16324. }
  16325. }
  16326. resultImages.push(result);
  16327. }
  16328. return resultImages;
  16329. }
  16330. function initializeTile(context, tileIndex) {
  16331. var siz = context.SIZ;
  16332. var componentsCount = siz.Csiz;
  16333. var tile = context.tiles[tileIndex];
  16334. for (var c = 0; c < componentsCount; c++) {
  16335. var component = tile.components[c];
  16336. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16337. component.quantizationParameters = qcdOrQcc;
  16338. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16339. component.codingStyleParameters = codOrCoc;
  16340. }
  16341. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16342. }
  16343. var TagTree = function TagTreeClosure() {
  16344. function TagTree(width, height) {
  16345. var levelsLength = log2(Math.max(width, height)) + 1;
  16346. this.levels = [];
  16347. for (var i = 0; i < levelsLength; i++) {
  16348. var level = {
  16349. width: width,
  16350. height: height,
  16351. items: []
  16352. };
  16353. this.levels.push(level);
  16354. width = Math.ceil(width / 2);
  16355. height = Math.ceil(height / 2);
  16356. }
  16357. }
  16358. TagTree.prototype = {
  16359. reset: function TagTree_reset(i, j) {
  16360. var currentLevel = 0, value = 0, level;
  16361. while (currentLevel < this.levels.length) {
  16362. level = this.levels[currentLevel];
  16363. var index = i + j * level.width;
  16364. if (level.items[index] !== undefined) {
  16365. value = level.items[index];
  16366. break;
  16367. }
  16368. level.index = index;
  16369. i >>= 1;
  16370. j >>= 1;
  16371. currentLevel++;
  16372. }
  16373. currentLevel--;
  16374. level = this.levels[currentLevel];
  16375. level.items[level.index] = value;
  16376. this.currentLevel = currentLevel;
  16377. delete this.value;
  16378. },
  16379. incrementValue: function TagTree_incrementValue() {
  16380. var level = this.levels[this.currentLevel];
  16381. level.items[level.index]++;
  16382. },
  16383. nextLevel: function TagTree_nextLevel() {
  16384. var currentLevel = this.currentLevel;
  16385. var level = this.levels[currentLevel];
  16386. var value = level.items[level.index];
  16387. currentLevel--;
  16388. if (currentLevel < 0) {
  16389. this.value = value;
  16390. return false;
  16391. }
  16392. this.currentLevel = currentLevel;
  16393. level = this.levels[currentLevel];
  16394. level.items[level.index] = value;
  16395. return true;
  16396. }
  16397. };
  16398. return TagTree;
  16399. }();
  16400. var InclusionTree = function InclusionTreeClosure() {
  16401. function InclusionTree(width, height, defaultValue) {
  16402. var levelsLength = log2(Math.max(width, height)) + 1;
  16403. this.levels = [];
  16404. for (var i = 0; i < levelsLength; i++) {
  16405. var items = new Uint8Array(width * height);
  16406. for (var j = 0, jj = items.length; j < jj; j++) {
  16407. items[j] = defaultValue;
  16408. }
  16409. var level = {
  16410. width: width,
  16411. height: height,
  16412. items: items
  16413. };
  16414. this.levels.push(level);
  16415. width = Math.ceil(width / 2);
  16416. height = Math.ceil(height / 2);
  16417. }
  16418. }
  16419. InclusionTree.prototype = {
  16420. reset: function InclusionTree_reset(i, j, stopValue) {
  16421. var currentLevel = 0;
  16422. while (currentLevel < this.levels.length) {
  16423. var level = this.levels[currentLevel];
  16424. var index = i + j * level.width;
  16425. level.index = index;
  16426. var value = level.items[index];
  16427. if (value === 0xFF) {
  16428. break;
  16429. }
  16430. if (value > stopValue) {
  16431. this.currentLevel = currentLevel;
  16432. this.propagateValues();
  16433. return false;
  16434. }
  16435. i >>= 1;
  16436. j >>= 1;
  16437. currentLevel++;
  16438. }
  16439. this.currentLevel = currentLevel - 1;
  16440. return true;
  16441. },
  16442. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16443. var level = this.levels[this.currentLevel];
  16444. level.items[level.index] = stopValue + 1;
  16445. this.propagateValues();
  16446. },
  16447. propagateValues: function InclusionTree_propagateValues() {
  16448. var levelIndex = this.currentLevel;
  16449. var level = this.levels[levelIndex];
  16450. var currentValue = level.items[level.index];
  16451. while (--levelIndex >= 0) {
  16452. level = this.levels[levelIndex];
  16453. level.items[level.index] = currentValue;
  16454. }
  16455. },
  16456. nextLevel: function InclusionTree_nextLevel() {
  16457. var currentLevel = this.currentLevel;
  16458. var level = this.levels[currentLevel];
  16459. var value = level.items[level.index];
  16460. level.items[level.index] = 0xFF;
  16461. currentLevel--;
  16462. if (currentLevel < 0) {
  16463. return false;
  16464. }
  16465. this.currentLevel = currentLevel;
  16466. level = this.levels[currentLevel];
  16467. level.items[level.index] = value;
  16468. return true;
  16469. }
  16470. };
  16471. return InclusionTree;
  16472. }();
  16473. var BitModel = function BitModelClosure() {
  16474. var UNIFORM_CONTEXT = 17;
  16475. var RUNLENGTH_CONTEXT = 18;
  16476. var LLAndLHContextsLabel = new Uint8Array([
  16477. 0,
  16478. 5,
  16479. 8,
  16480. 0,
  16481. 3,
  16482. 7,
  16483. 8,
  16484. 0,
  16485. 4,
  16486. 7,
  16487. 8,
  16488. 0,
  16489. 0,
  16490. 0,
  16491. 0,
  16492. 0,
  16493. 1,
  16494. 6,
  16495. 8,
  16496. 0,
  16497. 3,
  16498. 7,
  16499. 8,
  16500. 0,
  16501. 4,
  16502. 7,
  16503. 8,
  16504. 0,
  16505. 0,
  16506. 0,
  16507. 0,
  16508. 0,
  16509. 2,
  16510. 6,
  16511. 8,
  16512. 0,
  16513. 3,
  16514. 7,
  16515. 8,
  16516. 0,
  16517. 4,
  16518. 7,
  16519. 8,
  16520. 0,
  16521. 0,
  16522. 0,
  16523. 0,
  16524. 0,
  16525. 2,
  16526. 6,
  16527. 8,
  16528. 0,
  16529. 3,
  16530. 7,
  16531. 8,
  16532. 0,
  16533. 4,
  16534. 7,
  16535. 8,
  16536. 0,
  16537. 0,
  16538. 0,
  16539. 0,
  16540. 0,
  16541. 2,
  16542. 6,
  16543. 8,
  16544. 0,
  16545. 3,
  16546. 7,
  16547. 8,
  16548. 0,
  16549. 4,
  16550. 7,
  16551. 8
  16552. ]);
  16553. var HLContextLabel = new Uint8Array([
  16554. 0,
  16555. 3,
  16556. 4,
  16557. 0,
  16558. 5,
  16559. 7,
  16560. 7,
  16561. 0,
  16562. 8,
  16563. 8,
  16564. 8,
  16565. 0,
  16566. 0,
  16567. 0,
  16568. 0,
  16569. 0,
  16570. 1,
  16571. 3,
  16572. 4,
  16573. 0,
  16574. 6,
  16575. 7,
  16576. 7,
  16577. 0,
  16578. 8,
  16579. 8,
  16580. 8,
  16581. 0,
  16582. 0,
  16583. 0,
  16584. 0,
  16585. 0,
  16586. 2,
  16587. 3,
  16588. 4,
  16589. 0,
  16590. 6,
  16591. 7,
  16592. 7,
  16593. 0,
  16594. 8,
  16595. 8,
  16596. 8,
  16597. 0,
  16598. 0,
  16599. 0,
  16600. 0,
  16601. 0,
  16602. 2,
  16603. 3,
  16604. 4,
  16605. 0,
  16606. 6,
  16607. 7,
  16608. 7,
  16609. 0,
  16610. 8,
  16611. 8,
  16612. 8,
  16613. 0,
  16614. 0,
  16615. 0,
  16616. 0,
  16617. 0,
  16618. 2,
  16619. 3,
  16620. 4,
  16621. 0,
  16622. 6,
  16623. 7,
  16624. 7,
  16625. 0,
  16626. 8,
  16627. 8,
  16628. 8
  16629. ]);
  16630. var HHContextLabel = new Uint8Array([
  16631. 0,
  16632. 1,
  16633. 2,
  16634. 0,
  16635. 1,
  16636. 2,
  16637. 2,
  16638. 0,
  16639. 2,
  16640. 2,
  16641. 2,
  16642. 0,
  16643. 0,
  16644. 0,
  16645. 0,
  16646. 0,
  16647. 3,
  16648. 4,
  16649. 5,
  16650. 0,
  16651. 4,
  16652. 5,
  16653. 5,
  16654. 0,
  16655. 5,
  16656. 5,
  16657. 5,
  16658. 0,
  16659. 0,
  16660. 0,
  16661. 0,
  16662. 0,
  16663. 6,
  16664. 7,
  16665. 7,
  16666. 0,
  16667. 7,
  16668. 7,
  16669. 7,
  16670. 0,
  16671. 7,
  16672. 7,
  16673. 7,
  16674. 0,
  16675. 0,
  16676. 0,
  16677. 0,
  16678. 0,
  16679. 8,
  16680. 8,
  16681. 8,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 8,
  16688. 8,
  16689. 8,
  16690. 0,
  16691. 0,
  16692. 0,
  16693. 0,
  16694. 0,
  16695. 8,
  16696. 8,
  16697. 8,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 8,
  16704. 8,
  16705. 8
  16706. ]);
  16707. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16708. this.width = width;
  16709. this.height = height;
  16710. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16711. var coefficientCount = width * height;
  16712. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16713. this.coefficentsSign = new Uint8Array(coefficientCount);
  16714. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16715. this.processingFlags = new Uint8Array(coefficientCount);
  16716. var bitsDecoded = new Uint8Array(coefficientCount);
  16717. if (zeroBitPlanes !== 0) {
  16718. for (var i = 0; i < coefficientCount; i++) {
  16719. bitsDecoded[i] = zeroBitPlanes;
  16720. }
  16721. }
  16722. this.bitsDecoded = bitsDecoded;
  16723. this.reset();
  16724. }
  16725. BitModel.prototype = {
  16726. setDecoder: function BitModel_setDecoder(decoder) {
  16727. this.decoder = decoder;
  16728. },
  16729. reset: function BitModel_reset() {
  16730. this.contexts = new Int8Array(19);
  16731. this.contexts[0] = 4 << 1 | 0;
  16732. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16733. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16734. },
  16735. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16736. var neighborsSignificance = this.neighborsSignificance;
  16737. var width = this.width, height = this.height;
  16738. var left = column > 0;
  16739. var right = column + 1 < width;
  16740. var i;
  16741. if (row > 0) {
  16742. i = index - width;
  16743. if (left) {
  16744. neighborsSignificance[i - 1] += 0x10;
  16745. }
  16746. if (right) {
  16747. neighborsSignificance[i + 1] += 0x10;
  16748. }
  16749. neighborsSignificance[i] += 0x04;
  16750. }
  16751. if (row + 1 < height) {
  16752. i = index + width;
  16753. if (left) {
  16754. neighborsSignificance[i - 1] += 0x10;
  16755. }
  16756. if (right) {
  16757. neighborsSignificance[i + 1] += 0x10;
  16758. }
  16759. neighborsSignificance[i] += 0x04;
  16760. }
  16761. if (left) {
  16762. neighborsSignificance[index - 1] += 0x01;
  16763. }
  16764. if (right) {
  16765. neighborsSignificance[index + 1] += 0x01;
  16766. }
  16767. neighborsSignificance[index] |= 0x80;
  16768. },
  16769. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16770. var decoder = this.decoder;
  16771. var width = this.width, height = this.height;
  16772. var coefficentsMagnitude = this.coefficentsMagnitude;
  16773. var coefficentsSign = this.coefficentsSign;
  16774. var neighborsSignificance = this.neighborsSignificance;
  16775. var processingFlags = this.processingFlags;
  16776. var contexts = this.contexts;
  16777. var labels = this.contextLabelTable;
  16778. var bitsDecoded = this.bitsDecoded;
  16779. var processedInverseMask = ~1;
  16780. var processedMask = 1;
  16781. var firstMagnitudeBitMask = 2;
  16782. for (var i0 = 0; i0 < height; i0 += 4) {
  16783. for (var j = 0; j < width; j++) {
  16784. var index = i0 * width + j;
  16785. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16786. var i = i0 + i1;
  16787. if (i >= height) {
  16788. break;
  16789. }
  16790. processingFlags[index] &= processedInverseMask;
  16791. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16792. continue;
  16793. }
  16794. var contextLabel = labels[neighborsSignificance[index]];
  16795. var decision = decoder.readBit(contexts, contextLabel);
  16796. if (decision) {
  16797. var sign = this.decodeSignBit(i, j, index);
  16798. coefficentsSign[index] = sign;
  16799. coefficentsMagnitude[index] = 1;
  16800. this.setNeighborsSignificance(i, j, index);
  16801. processingFlags[index] |= firstMagnitudeBitMask;
  16802. }
  16803. bitsDecoded[index]++;
  16804. processingFlags[index] |= processedMask;
  16805. }
  16806. }
  16807. }
  16808. },
  16809. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16810. var width = this.width, height = this.height;
  16811. var coefficentsMagnitude = this.coefficentsMagnitude;
  16812. var coefficentsSign = this.coefficentsSign;
  16813. var contribution, sign0, sign1, significance1;
  16814. var contextLabel, decoded;
  16815. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16816. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16817. sign1 = coefficentsSign[index + 1];
  16818. if (significance1) {
  16819. sign0 = coefficentsSign[index - 1];
  16820. contribution = 1 - sign1 - sign0;
  16821. } else {
  16822. contribution = 1 - sign1 - sign1;
  16823. }
  16824. } else if (significance1) {
  16825. sign0 = coefficentsSign[index - 1];
  16826. contribution = 1 - sign0 - sign0;
  16827. } else {
  16828. contribution = 0;
  16829. }
  16830. var horizontalContribution = 3 * contribution;
  16831. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16832. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16833. sign1 = coefficentsSign[index + width];
  16834. if (significance1) {
  16835. sign0 = coefficentsSign[index - width];
  16836. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16837. } else {
  16838. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16839. }
  16840. } else if (significance1) {
  16841. sign0 = coefficentsSign[index - width];
  16842. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16843. } else {
  16844. contribution = horizontalContribution;
  16845. }
  16846. if (contribution >= 0) {
  16847. contextLabel = 9 + contribution;
  16848. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16849. } else {
  16850. contextLabel = 9 - contribution;
  16851. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16852. }
  16853. return decoded;
  16854. },
  16855. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16856. var decoder = this.decoder;
  16857. var width = this.width, height = this.height;
  16858. var coefficentsMagnitude = this.coefficentsMagnitude;
  16859. var neighborsSignificance = this.neighborsSignificance;
  16860. var contexts = this.contexts;
  16861. var bitsDecoded = this.bitsDecoded;
  16862. var processingFlags = this.processingFlags;
  16863. var processedMask = 1;
  16864. var firstMagnitudeBitMask = 2;
  16865. var length = width * height;
  16866. var width4 = width * 4;
  16867. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16868. indexNext = Math.min(length, index0 + width4);
  16869. for (var j = 0; j < width; j++) {
  16870. for (var index = index0 + j; index < indexNext; index += width) {
  16871. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16872. continue;
  16873. }
  16874. var contextLabel = 16;
  16875. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16876. processingFlags[index] ^= firstMagnitudeBitMask;
  16877. var significance = neighborsSignificance[index] & 127;
  16878. contextLabel = significance === 0 ? 15 : 14;
  16879. }
  16880. var bit = decoder.readBit(contexts, contextLabel);
  16881. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16882. bitsDecoded[index]++;
  16883. processingFlags[index] |= processedMask;
  16884. }
  16885. }
  16886. }
  16887. },
  16888. runCleanupPass: function BitModel_runCleanupPass() {
  16889. var decoder = this.decoder;
  16890. var width = this.width, height = this.height;
  16891. var neighborsSignificance = this.neighborsSignificance;
  16892. var coefficentsMagnitude = this.coefficentsMagnitude;
  16893. var coefficentsSign = this.coefficentsSign;
  16894. var contexts = this.contexts;
  16895. var labels = this.contextLabelTable;
  16896. var bitsDecoded = this.bitsDecoded;
  16897. var processingFlags = this.processingFlags;
  16898. var processedMask = 1;
  16899. var firstMagnitudeBitMask = 2;
  16900. var oneRowDown = width;
  16901. var twoRowsDown = width * 2;
  16902. var threeRowsDown = width * 3;
  16903. var iNext;
  16904. for (var i0 = 0; i0 < height; i0 = iNext) {
  16905. iNext = Math.min(i0 + 4, height);
  16906. var indexBase = i0 * width;
  16907. var checkAllEmpty = i0 + 3 < height;
  16908. for (var j = 0; j < width; j++) {
  16909. var index0 = indexBase + j;
  16910. 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;
  16911. var i1 = 0, index = index0;
  16912. var i = i0, sign;
  16913. if (allEmpty) {
  16914. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  16915. if (!hasSignificantCoefficent) {
  16916. bitsDecoded[index0]++;
  16917. bitsDecoded[index0 + oneRowDown]++;
  16918. bitsDecoded[index0 + twoRowsDown]++;
  16919. bitsDecoded[index0 + threeRowsDown]++;
  16920. continue;
  16921. }
  16922. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  16923. if (i1 !== 0) {
  16924. i = i0 + i1;
  16925. index += i1 * width;
  16926. }
  16927. sign = this.decodeSignBit(i, j, index);
  16928. coefficentsSign[index] = sign;
  16929. coefficentsMagnitude[index] = 1;
  16930. this.setNeighborsSignificance(i, j, index);
  16931. processingFlags[index] |= firstMagnitudeBitMask;
  16932. index = index0;
  16933. for (var i2 = i0; i2 <= i; i2++, index += width) {
  16934. bitsDecoded[index]++;
  16935. }
  16936. i1++;
  16937. }
  16938. for (i = i0 + i1; i < iNext; i++, index += width) {
  16939. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16940. continue;
  16941. }
  16942. var contextLabel = labels[neighborsSignificance[index]];
  16943. var decision = decoder.readBit(contexts, contextLabel);
  16944. if (decision === 1) {
  16945. sign = this.decodeSignBit(i, j, index);
  16946. coefficentsSign[index] = sign;
  16947. coefficentsMagnitude[index] = 1;
  16948. this.setNeighborsSignificance(i, j, index);
  16949. processingFlags[index] |= firstMagnitudeBitMask;
  16950. }
  16951. bitsDecoded[index]++;
  16952. }
  16953. }
  16954. }
  16955. },
  16956. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  16957. var decoder = this.decoder;
  16958. var contexts = this.contexts;
  16959. 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);
  16960. if (symbol !== 0xA) {
  16961. error('JPX Error: Invalid segmentation symbol');
  16962. }
  16963. }
  16964. };
  16965. return BitModel;
  16966. }();
  16967. var Transform = function TransformClosure() {
  16968. function Transform() {
  16969. }
  16970. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  16971. var ll = subbands[0];
  16972. for (var i = 1, ii = subbands.length; i < ii; i++) {
  16973. ll = this.iterate(ll, subbands[i], u0, v0);
  16974. }
  16975. return ll;
  16976. };
  16977. Transform.prototype.extend = function extend(buffer, offset, size) {
  16978. var i1 = offset - 1, j1 = offset + 1;
  16979. var i2 = offset + size - 2, j2 = offset + size;
  16980. buffer[i1--] = buffer[j1++];
  16981. buffer[j2++] = buffer[i2--];
  16982. buffer[i1--] = buffer[j1++];
  16983. buffer[j2++] = buffer[i2--];
  16984. buffer[i1--] = buffer[j1++];
  16985. buffer[j2++] = buffer[i2--];
  16986. buffer[i1] = buffer[j1];
  16987. buffer[j2] = buffer[i2];
  16988. };
  16989. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  16990. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  16991. var width = hl_lh_hh.width;
  16992. var height = hl_lh_hh.height;
  16993. var items = hl_lh_hh.items;
  16994. var i, j, k, l, u, v;
  16995. for (k = 0, i = 0; i < llHeight; i++) {
  16996. l = i * 2 * width;
  16997. for (j = 0; j < llWidth; j++, k++, l += 2) {
  16998. items[l] = llItems[k];
  16999. }
  17000. }
  17001. llItems = ll.items = null;
  17002. var bufferPadding = 4;
  17003. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17004. if (width === 1) {
  17005. if ((u0 & 1) !== 0) {
  17006. for (v = 0, k = 0; v < height; v++, k += width) {
  17007. items[k] *= 0.5;
  17008. }
  17009. }
  17010. } else {
  17011. for (v = 0, k = 0; v < height; v++, k += width) {
  17012. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17013. this.extend(rowBuffer, bufferPadding, width);
  17014. this.filter(rowBuffer, bufferPadding, width);
  17015. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17016. }
  17017. }
  17018. var numBuffers = 16;
  17019. var colBuffers = [];
  17020. for (i = 0; i < numBuffers; i++) {
  17021. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17022. }
  17023. var b, currentBuffer = 0;
  17024. ll = bufferPadding + height;
  17025. if (height === 1) {
  17026. if ((v0 & 1) !== 0) {
  17027. for (u = 0; u < width; u++) {
  17028. items[u] *= 0.5;
  17029. }
  17030. }
  17031. } else {
  17032. for (u = 0; u < width; u++) {
  17033. if (currentBuffer === 0) {
  17034. numBuffers = Math.min(width - u, numBuffers);
  17035. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17036. for (b = 0; b < numBuffers; b++) {
  17037. colBuffers[b][l] = items[k + b];
  17038. }
  17039. }
  17040. currentBuffer = numBuffers;
  17041. }
  17042. currentBuffer--;
  17043. var buffer = colBuffers[currentBuffer];
  17044. this.extend(buffer, bufferPadding, height);
  17045. this.filter(buffer, bufferPadding, height);
  17046. if (currentBuffer === 0) {
  17047. k = u - numBuffers + 1;
  17048. for (l = bufferPadding; l < ll; k += width, l++) {
  17049. for (b = 0; b < numBuffers; b++) {
  17050. items[k + b] = colBuffers[b][l];
  17051. }
  17052. }
  17053. }
  17054. }
  17055. }
  17056. return {
  17057. width: width,
  17058. height: height,
  17059. items: items
  17060. };
  17061. };
  17062. return Transform;
  17063. }();
  17064. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17065. function IrreversibleTransform() {
  17066. Transform.call(this);
  17067. }
  17068. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17069. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17070. var len = length >> 1;
  17071. offset = offset | 0;
  17072. var j, n, current, next;
  17073. var alpha = -1.586134342059924;
  17074. var beta = -0.052980118572961;
  17075. var gamma = 0.882911075530934;
  17076. var delta = 0.443506852043971;
  17077. var K = 1.230174104914001;
  17078. var K_ = 1 / K;
  17079. j = offset - 3;
  17080. for (n = len + 4; n--; j += 2) {
  17081. x[j] *= K_;
  17082. }
  17083. j = offset - 2;
  17084. current = delta * x[j - 1];
  17085. for (n = len + 3; n--; j += 2) {
  17086. next = delta * x[j + 1];
  17087. x[j] = K * x[j] - current - next;
  17088. if (n--) {
  17089. j += 2;
  17090. current = delta * x[j + 1];
  17091. x[j] = K * x[j] - current - next;
  17092. } else {
  17093. break;
  17094. }
  17095. }
  17096. j = offset - 1;
  17097. current = gamma * x[j - 1];
  17098. for (n = len + 2; n--; j += 2) {
  17099. next = gamma * x[j + 1];
  17100. x[j] -= current + next;
  17101. if (n--) {
  17102. j += 2;
  17103. current = gamma * x[j + 1];
  17104. x[j] -= current + next;
  17105. } else {
  17106. break;
  17107. }
  17108. }
  17109. j = offset;
  17110. current = beta * x[j - 1];
  17111. for (n = len + 1; n--; j += 2) {
  17112. next = beta * x[j + 1];
  17113. x[j] -= current + next;
  17114. if (n--) {
  17115. j += 2;
  17116. current = beta * x[j + 1];
  17117. x[j] -= current + next;
  17118. } else {
  17119. break;
  17120. }
  17121. }
  17122. if (len !== 0) {
  17123. j = offset + 1;
  17124. current = alpha * x[j - 1];
  17125. for (n = len; n--; j += 2) {
  17126. next = alpha * x[j + 1];
  17127. x[j] -= current + next;
  17128. if (n--) {
  17129. j += 2;
  17130. current = alpha * x[j + 1];
  17131. x[j] -= current + next;
  17132. } else {
  17133. break;
  17134. }
  17135. }
  17136. }
  17137. };
  17138. return IrreversibleTransform;
  17139. }();
  17140. var ReversibleTransform = function ReversibleTransformClosure() {
  17141. function ReversibleTransform() {
  17142. Transform.call(this);
  17143. }
  17144. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17145. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17146. var len = length >> 1;
  17147. offset = offset | 0;
  17148. var j, n;
  17149. for (j = offset, n = len + 1; n--; j += 2) {
  17150. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17151. }
  17152. for (j = offset + 1, n = len; n--; j += 2) {
  17153. x[j] += x[j - 1] + x[j + 1] >> 1;
  17154. }
  17155. };
  17156. return ReversibleTransform;
  17157. }();
  17158. return JpxImage;
  17159. }();
  17160. exports.JpxImage = JpxImage;
  17161. }));
  17162. (function (root, factory) {
  17163. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17164. }(this, function (exports, sharedUtil) {
  17165. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17166. var getMetrics = getLookupTableFactory(function (t) {
  17167. t['Courier'] = 600;
  17168. t['Courier-Bold'] = 600;
  17169. t['Courier-BoldOblique'] = 600;
  17170. t['Courier-Oblique'] = 600;
  17171. t['Helvetica'] = getLookupTableFactory(function (t) {
  17172. t['space'] = 278;
  17173. t['exclam'] = 278;
  17174. t['quotedbl'] = 355;
  17175. t['numbersign'] = 556;
  17176. t['dollar'] = 556;
  17177. t['percent'] = 889;
  17178. t['ampersand'] = 667;
  17179. t['quoteright'] = 222;
  17180. t['parenleft'] = 333;
  17181. t['parenright'] = 333;
  17182. t['asterisk'] = 389;
  17183. t['plus'] = 584;
  17184. t['comma'] = 278;
  17185. t['hyphen'] = 333;
  17186. t['period'] = 278;
  17187. t['slash'] = 278;
  17188. t['zero'] = 556;
  17189. t['one'] = 556;
  17190. t['two'] = 556;
  17191. t['three'] = 556;
  17192. t['four'] = 556;
  17193. t['five'] = 556;
  17194. t['six'] = 556;
  17195. t['seven'] = 556;
  17196. t['eight'] = 556;
  17197. t['nine'] = 556;
  17198. t['colon'] = 278;
  17199. t['semicolon'] = 278;
  17200. t['less'] = 584;
  17201. t['equal'] = 584;
  17202. t['greater'] = 584;
  17203. t['question'] = 556;
  17204. t['at'] = 1015;
  17205. t['A'] = 667;
  17206. t['B'] = 667;
  17207. t['C'] = 722;
  17208. t['D'] = 722;
  17209. t['E'] = 667;
  17210. t['F'] = 611;
  17211. t['G'] = 778;
  17212. t['H'] = 722;
  17213. t['I'] = 278;
  17214. t['J'] = 500;
  17215. t['K'] = 667;
  17216. t['L'] = 556;
  17217. t['M'] = 833;
  17218. t['N'] = 722;
  17219. t['O'] = 778;
  17220. t['P'] = 667;
  17221. t['Q'] = 778;
  17222. t['R'] = 722;
  17223. t['S'] = 667;
  17224. t['T'] = 611;
  17225. t['U'] = 722;
  17226. t['V'] = 667;
  17227. t['W'] = 944;
  17228. t['X'] = 667;
  17229. t['Y'] = 667;
  17230. t['Z'] = 611;
  17231. t['bracketleft'] = 278;
  17232. t['backslash'] = 278;
  17233. t['bracketright'] = 278;
  17234. t['asciicircum'] = 469;
  17235. t['underscore'] = 556;
  17236. t['quoteleft'] = 222;
  17237. t['a'] = 556;
  17238. t['b'] = 556;
  17239. t['c'] = 500;
  17240. t['d'] = 556;
  17241. t['e'] = 556;
  17242. t['f'] = 278;
  17243. t['g'] = 556;
  17244. t['h'] = 556;
  17245. t['i'] = 222;
  17246. t['j'] = 222;
  17247. t['k'] = 500;
  17248. t['l'] = 222;
  17249. t['m'] = 833;
  17250. t['n'] = 556;
  17251. t['o'] = 556;
  17252. t['p'] = 556;
  17253. t['q'] = 556;
  17254. t['r'] = 333;
  17255. t['s'] = 500;
  17256. t['t'] = 278;
  17257. t['u'] = 556;
  17258. t['v'] = 500;
  17259. t['w'] = 722;
  17260. t['x'] = 500;
  17261. t['y'] = 500;
  17262. t['z'] = 500;
  17263. t['braceleft'] = 334;
  17264. t['bar'] = 260;
  17265. t['braceright'] = 334;
  17266. t['asciitilde'] = 584;
  17267. t['exclamdown'] = 333;
  17268. t['cent'] = 556;
  17269. t['sterling'] = 556;
  17270. t['fraction'] = 167;
  17271. t['yen'] = 556;
  17272. t['florin'] = 556;
  17273. t['section'] = 556;
  17274. t['currency'] = 556;
  17275. t['quotesingle'] = 191;
  17276. t['quotedblleft'] = 333;
  17277. t['guillemotleft'] = 556;
  17278. t['guilsinglleft'] = 333;
  17279. t['guilsinglright'] = 333;
  17280. t['fi'] = 500;
  17281. t['fl'] = 500;
  17282. t['endash'] = 556;
  17283. t['dagger'] = 556;
  17284. t['daggerdbl'] = 556;
  17285. t['periodcentered'] = 278;
  17286. t['paragraph'] = 537;
  17287. t['bullet'] = 350;
  17288. t['quotesinglbase'] = 222;
  17289. t['quotedblbase'] = 333;
  17290. t['quotedblright'] = 333;
  17291. t['guillemotright'] = 556;
  17292. t['ellipsis'] = 1000;
  17293. t['perthousand'] = 1000;
  17294. t['questiondown'] = 611;
  17295. t['grave'] = 333;
  17296. t['acute'] = 333;
  17297. t['circumflex'] = 333;
  17298. t['tilde'] = 333;
  17299. t['macron'] = 333;
  17300. t['breve'] = 333;
  17301. t['dotaccent'] = 333;
  17302. t['dieresis'] = 333;
  17303. t['ring'] = 333;
  17304. t['cedilla'] = 333;
  17305. t['hungarumlaut'] = 333;
  17306. t['ogonek'] = 333;
  17307. t['caron'] = 333;
  17308. t['emdash'] = 1000;
  17309. t['AE'] = 1000;
  17310. t['ordfeminine'] = 370;
  17311. t['Lslash'] = 556;
  17312. t['Oslash'] = 778;
  17313. t['OE'] = 1000;
  17314. t['ordmasculine'] = 365;
  17315. t['ae'] = 889;
  17316. t['dotlessi'] = 278;
  17317. t['lslash'] = 222;
  17318. t['oslash'] = 611;
  17319. t['oe'] = 944;
  17320. t['germandbls'] = 611;
  17321. t['Idieresis'] = 278;
  17322. t['eacute'] = 556;
  17323. t['abreve'] = 556;
  17324. t['uhungarumlaut'] = 556;
  17325. t['ecaron'] = 556;
  17326. t['Ydieresis'] = 667;
  17327. t['divide'] = 584;
  17328. t['Yacute'] = 667;
  17329. t['Acircumflex'] = 667;
  17330. t['aacute'] = 556;
  17331. t['Ucircumflex'] = 722;
  17332. t['yacute'] = 500;
  17333. t['scommaaccent'] = 500;
  17334. t['ecircumflex'] = 556;
  17335. t['Uring'] = 722;
  17336. t['Udieresis'] = 722;
  17337. t['aogonek'] = 556;
  17338. t['Uacute'] = 722;
  17339. t['uogonek'] = 556;
  17340. t['Edieresis'] = 667;
  17341. t['Dcroat'] = 722;
  17342. t['commaaccent'] = 250;
  17343. t['copyright'] = 737;
  17344. t['Emacron'] = 667;
  17345. t['ccaron'] = 500;
  17346. t['aring'] = 556;
  17347. t['Ncommaaccent'] = 722;
  17348. t['lacute'] = 222;
  17349. t['agrave'] = 556;
  17350. t['Tcommaaccent'] = 611;
  17351. t['Cacute'] = 722;
  17352. t['atilde'] = 556;
  17353. t['Edotaccent'] = 667;
  17354. t['scaron'] = 500;
  17355. t['scedilla'] = 500;
  17356. t['iacute'] = 278;
  17357. t['lozenge'] = 471;
  17358. t['Rcaron'] = 722;
  17359. t['Gcommaaccent'] = 778;
  17360. t['ucircumflex'] = 556;
  17361. t['acircumflex'] = 556;
  17362. t['Amacron'] = 667;
  17363. t['rcaron'] = 333;
  17364. t['ccedilla'] = 500;
  17365. t['Zdotaccent'] = 611;
  17366. t['Thorn'] = 667;
  17367. t['Omacron'] = 778;
  17368. t['Racute'] = 722;
  17369. t['Sacute'] = 667;
  17370. t['dcaron'] = 643;
  17371. t['Umacron'] = 722;
  17372. t['uring'] = 556;
  17373. t['threesuperior'] = 333;
  17374. t['Ograve'] = 778;
  17375. t['Agrave'] = 667;
  17376. t['Abreve'] = 667;
  17377. t['multiply'] = 584;
  17378. t['uacute'] = 556;
  17379. t['Tcaron'] = 611;
  17380. t['partialdiff'] = 476;
  17381. t['ydieresis'] = 500;
  17382. t['Nacute'] = 722;
  17383. t['icircumflex'] = 278;
  17384. t['Ecircumflex'] = 667;
  17385. t['adieresis'] = 556;
  17386. t['edieresis'] = 556;
  17387. t['cacute'] = 500;
  17388. t['nacute'] = 556;
  17389. t['umacron'] = 556;
  17390. t['Ncaron'] = 722;
  17391. t['Iacute'] = 278;
  17392. t['plusminus'] = 584;
  17393. t['brokenbar'] = 260;
  17394. t['registered'] = 737;
  17395. t['Gbreve'] = 778;
  17396. t['Idotaccent'] = 278;
  17397. t['summation'] = 600;
  17398. t['Egrave'] = 667;
  17399. t['racute'] = 333;
  17400. t['omacron'] = 556;
  17401. t['Zacute'] = 611;
  17402. t['Zcaron'] = 611;
  17403. t['greaterequal'] = 549;
  17404. t['Eth'] = 722;
  17405. t['Ccedilla'] = 722;
  17406. t['lcommaaccent'] = 222;
  17407. t['tcaron'] = 317;
  17408. t['eogonek'] = 556;
  17409. t['Uogonek'] = 722;
  17410. t['Aacute'] = 667;
  17411. t['Adieresis'] = 667;
  17412. t['egrave'] = 556;
  17413. t['zacute'] = 500;
  17414. t['iogonek'] = 222;
  17415. t['Oacute'] = 778;
  17416. t['oacute'] = 556;
  17417. t['amacron'] = 556;
  17418. t['sacute'] = 500;
  17419. t['idieresis'] = 278;
  17420. t['Ocircumflex'] = 778;
  17421. t['Ugrave'] = 722;
  17422. t['Delta'] = 612;
  17423. t['thorn'] = 556;
  17424. t['twosuperior'] = 333;
  17425. t['Odieresis'] = 778;
  17426. t['mu'] = 556;
  17427. t['igrave'] = 278;
  17428. t['ohungarumlaut'] = 556;
  17429. t['Eogonek'] = 667;
  17430. t['dcroat'] = 556;
  17431. t['threequarters'] = 834;
  17432. t['Scedilla'] = 667;
  17433. t['lcaron'] = 299;
  17434. t['Kcommaaccent'] = 667;
  17435. t['Lacute'] = 556;
  17436. t['trademark'] = 1000;
  17437. t['edotaccent'] = 556;
  17438. t['Igrave'] = 278;
  17439. t['Imacron'] = 278;
  17440. t['Lcaron'] = 556;
  17441. t['onehalf'] = 834;
  17442. t['lessequal'] = 549;
  17443. t['ocircumflex'] = 556;
  17444. t['ntilde'] = 556;
  17445. t['Uhungarumlaut'] = 722;
  17446. t['Eacute'] = 667;
  17447. t['emacron'] = 556;
  17448. t['gbreve'] = 556;
  17449. t['onequarter'] = 834;
  17450. t['Scaron'] = 667;
  17451. t['Scommaaccent'] = 667;
  17452. t['Ohungarumlaut'] = 778;
  17453. t['degree'] = 400;
  17454. t['ograve'] = 556;
  17455. t['Ccaron'] = 722;
  17456. t['ugrave'] = 556;
  17457. t['radical'] = 453;
  17458. t['Dcaron'] = 722;
  17459. t['rcommaaccent'] = 333;
  17460. t['Ntilde'] = 722;
  17461. t['otilde'] = 556;
  17462. t['Rcommaaccent'] = 722;
  17463. t['Lcommaaccent'] = 556;
  17464. t['Atilde'] = 667;
  17465. t['Aogonek'] = 667;
  17466. t['Aring'] = 667;
  17467. t['Otilde'] = 778;
  17468. t['zdotaccent'] = 500;
  17469. t['Ecaron'] = 667;
  17470. t['Iogonek'] = 278;
  17471. t['kcommaaccent'] = 500;
  17472. t['minus'] = 584;
  17473. t['Icircumflex'] = 278;
  17474. t['ncaron'] = 556;
  17475. t['tcommaaccent'] = 278;
  17476. t['logicalnot'] = 584;
  17477. t['odieresis'] = 556;
  17478. t['udieresis'] = 556;
  17479. t['notequal'] = 549;
  17480. t['gcommaaccent'] = 556;
  17481. t['eth'] = 556;
  17482. t['zcaron'] = 500;
  17483. t['ncommaaccent'] = 556;
  17484. t['onesuperior'] = 333;
  17485. t['imacron'] = 278;
  17486. t['Euro'] = 556;
  17487. });
  17488. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17489. t['space'] = 278;
  17490. t['exclam'] = 333;
  17491. t['quotedbl'] = 474;
  17492. t['numbersign'] = 556;
  17493. t['dollar'] = 556;
  17494. t['percent'] = 889;
  17495. t['ampersand'] = 722;
  17496. t['quoteright'] = 278;
  17497. t['parenleft'] = 333;
  17498. t['parenright'] = 333;
  17499. t['asterisk'] = 389;
  17500. t['plus'] = 584;
  17501. t['comma'] = 278;
  17502. t['hyphen'] = 333;
  17503. t['period'] = 278;
  17504. t['slash'] = 278;
  17505. t['zero'] = 556;
  17506. t['one'] = 556;
  17507. t['two'] = 556;
  17508. t['three'] = 556;
  17509. t['four'] = 556;
  17510. t['five'] = 556;
  17511. t['six'] = 556;
  17512. t['seven'] = 556;
  17513. t['eight'] = 556;
  17514. t['nine'] = 556;
  17515. t['colon'] = 333;
  17516. t['semicolon'] = 333;
  17517. t['less'] = 584;
  17518. t['equal'] = 584;
  17519. t['greater'] = 584;
  17520. t['question'] = 611;
  17521. t['at'] = 975;
  17522. t['A'] = 722;
  17523. t['B'] = 722;
  17524. t['C'] = 722;
  17525. t['D'] = 722;
  17526. t['E'] = 667;
  17527. t['F'] = 611;
  17528. t['G'] = 778;
  17529. t['H'] = 722;
  17530. t['I'] = 278;
  17531. t['J'] = 556;
  17532. t['K'] = 722;
  17533. t['L'] = 611;
  17534. t['M'] = 833;
  17535. t['N'] = 722;
  17536. t['O'] = 778;
  17537. t['P'] = 667;
  17538. t['Q'] = 778;
  17539. t['R'] = 722;
  17540. t['S'] = 667;
  17541. t['T'] = 611;
  17542. t['U'] = 722;
  17543. t['V'] = 667;
  17544. t['W'] = 944;
  17545. t['X'] = 667;
  17546. t['Y'] = 667;
  17547. t['Z'] = 611;
  17548. t['bracketleft'] = 333;
  17549. t['backslash'] = 278;
  17550. t['bracketright'] = 333;
  17551. t['asciicircum'] = 584;
  17552. t['underscore'] = 556;
  17553. t['quoteleft'] = 278;
  17554. t['a'] = 556;
  17555. t['b'] = 611;
  17556. t['c'] = 556;
  17557. t['d'] = 611;
  17558. t['e'] = 556;
  17559. t['f'] = 333;
  17560. t['g'] = 611;
  17561. t['h'] = 611;
  17562. t['i'] = 278;
  17563. t['j'] = 278;
  17564. t['k'] = 556;
  17565. t['l'] = 278;
  17566. t['m'] = 889;
  17567. t['n'] = 611;
  17568. t['o'] = 611;
  17569. t['p'] = 611;
  17570. t['q'] = 611;
  17571. t['r'] = 389;
  17572. t['s'] = 556;
  17573. t['t'] = 333;
  17574. t['u'] = 611;
  17575. t['v'] = 556;
  17576. t['w'] = 778;
  17577. t['x'] = 556;
  17578. t['y'] = 556;
  17579. t['z'] = 500;
  17580. t['braceleft'] = 389;
  17581. t['bar'] = 280;
  17582. t['braceright'] = 389;
  17583. t['asciitilde'] = 584;
  17584. t['exclamdown'] = 333;
  17585. t['cent'] = 556;
  17586. t['sterling'] = 556;
  17587. t['fraction'] = 167;
  17588. t['yen'] = 556;
  17589. t['florin'] = 556;
  17590. t['section'] = 556;
  17591. t['currency'] = 556;
  17592. t['quotesingle'] = 238;
  17593. t['quotedblleft'] = 500;
  17594. t['guillemotleft'] = 556;
  17595. t['guilsinglleft'] = 333;
  17596. t['guilsinglright'] = 333;
  17597. t['fi'] = 611;
  17598. t['fl'] = 611;
  17599. t['endash'] = 556;
  17600. t['dagger'] = 556;
  17601. t['daggerdbl'] = 556;
  17602. t['periodcentered'] = 278;
  17603. t['paragraph'] = 556;
  17604. t['bullet'] = 350;
  17605. t['quotesinglbase'] = 278;
  17606. t['quotedblbase'] = 500;
  17607. t['quotedblright'] = 500;
  17608. t['guillemotright'] = 556;
  17609. t['ellipsis'] = 1000;
  17610. t['perthousand'] = 1000;
  17611. t['questiondown'] = 611;
  17612. t['grave'] = 333;
  17613. t['acute'] = 333;
  17614. t['circumflex'] = 333;
  17615. t['tilde'] = 333;
  17616. t['macron'] = 333;
  17617. t['breve'] = 333;
  17618. t['dotaccent'] = 333;
  17619. t['dieresis'] = 333;
  17620. t['ring'] = 333;
  17621. t['cedilla'] = 333;
  17622. t['hungarumlaut'] = 333;
  17623. t['ogonek'] = 333;
  17624. t['caron'] = 333;
  17625. t['emdash'] = 1000;
  17626. t['AE'] = 1000;
  17627. t['ordfeminine'] = 370;
  17628. t['Lslash'] = 611;
  17629. t['Oslash'] = 778;
  17630. t['OE'] = 1000;
  17631. t['ordmasculine'] = 365;
  17632. t['ae'] = 889;
  17633. t['dotlessi'] = 278;
  17634. t['lslash'] = 278;
  17635. t['oslash'] = 611;
  17636. t['oe'] = 944;
  17637. t['germandbls'] = 611;
  17638. t['Idieresis'] = 278;
  17639. t['eacute'] = 556;
  17640. t['abreve'] = 556;
  17641. t['uhungarumlaut'] = 611;
  17642. t['ecaron'] = 556;
  17643. t['Ydieresis'] = 667;
  17644. t['divide'] = 584;
  17645. t['Yacute'] = 667;
  17646. t['Acircumflex'] = 722;
  17647. t['aacute'] = 556;
  17648. t['Ucircumflex'] = 722;
  17649. t['yacute'] = 556;
  17650. t['scommaaccent'] = 556;
  17651. t['ecircumflex'] = 556;
  17652. t['Uring'] = 722;
  17653. t['Udieresis'] = 722;
  17654. t['aogonek'] = 556;
  17655. t['Uacute'] = 722;
  17656. t['uogonek'] = 611;
  17657. t['Edieresis'] = 667;
  17658. t['Dcroat'] = 722;
  17659. t['commaaccent'] = 250;
  17660. t['copyright'] = 737;
  17661. t['Emacron'] = 667;
  17662. t['ccaron'] = 556;
  17663. t['aring'] = 556;
  17664. t['Ncommaaccent'] = 722;
  17665. t['lacute'] = 278;
  17666. t['agrave'] = 556;
  17667. t['Tcommaaccent'] = 611;
  17668. t['Cacute'] = 722;
  17669. t['atilde'] = 556;
  17670. t['Edotaccent'] = 667;
  17671. t['scaron'] = 556;
  17672. t['scedilla'] = 556;
  17673. t['iacute'] = 278;
  17674. t['lozenge'] = 494;
  17675. t['Rcaron'] = 722;
  17676. t['Gcommaaccent'] = 778;
  17677. t['ucircumflex'] = 611;
  17678. t['acircumflex'] = 556;
  17679. t['Amacron'] = 722;
  17680. t['rcaron'] = 389;
  17681. t['ccedilla'] = 556;
  17682. t['Zdotaccent'] = 611;
  17683. t['Thorn'] = 667;
  17684. t['Omacron'] = 778;
  17685. t['Racute'] = 722;
  17686. t['Sacute'] = 667;
  17687. t['dcaron'] = 743;
  17688. t['Umacron'] = 722;
  17689. t['uring'] = 611;
  17690. t['threesuperior'] = 333;
  17691. t['Ograve'] = 778;
  17692. t['Agrave'] = 722;
  17693. t['Abreve'] = 722;
  17694. t['multiply'] = 584;
  17695. t['uacute'] = 611;
  17696. t['Tcaron'] = 611;
  17697. t['partialdiff'] = 494;
  17698. t['ydieresis'] = 556;
  17699. t['Nacute'] = 722;
  17700. t['icircumflex'] = 278;
  17701. t['Ecircumflex'] = 667;
  17702. t['adieresis'] = 556;
  17703. t['edieresis'] = 556;
  17704. t['cacute'] = 556;
  17705. t['nacute'] = 611;
  17706. t['umacron'] = 611;
  17707. t['Ncaron'] = 722;
  17708. t['Iacute'] = 278;
  17709. t['plusminus'] = 584;
  17710. t['brokenbar'] = 280;
  17711. t['registered'] = 737;
  17712. t['Gbreve'] = 778;
  17713. t['Idotaccent'] = 278;
  17714. t['summation'] = 600;
  17715. t['Egrave'] = 667;
  17716. t['racute'] = 389;
  17717. t['omacron'] = 611;
  17718. t['Zacute'] = 611;
  17719. t['Zcaron'] = 611;
  17720. t['greaterequal'] = 549;
  17721. t['Eth'] = 722;
  17722. t['Ccedilla'] = 722;
  17723. t['lcommaaccent'] = 278;
  17724. t['tcaron'] = 389;
  17725. t['eogonek'] = 556;
  17726. t['Uogonek'] = 722;
  17727. t['Aacute'] = 722;
  17728. t['Adieresis'] = 722;
  17729. t['egrave'] = 556;
  17730. t['zacute'] = 500;
  17731. t['iogonek'] = 278;
  17732. t['Oacute'] = 778;
  17733. t['oacute'] = 611;
  17734. t['amacron'] = 556;
  17735. t['sacute'] = 556;
  17736. t['idieresis'] = 278;
  17737. t['Ocircumflex'] = 778;
  17738. t['Ugrave'] = 722;
  17739. t['Delta'] = 612;
  17740. t['thorn'] = 611;
  17741. t['twosuperior'] = 333;
  17742. t['Odieresis'] = 778;
  17743. t['mu'] = 611;
  17744. t['igrave'] = 278;
  17745. t['ohungarumlaut'] = 611;
  17746. t['Eogonek'] = 667;
  17747. t['dcroat'] = 611;
  17748. t['threequarters'] = 834;
  17749. t['Scedilla'] = 667;
  17750. t['lcaron'] = 400;
  17751. t['Kcommaaccent'] = 722;
  17752. t['Lacute'] = 611;
  17753. t['trademark'] = 1000;
  17754. t['edotaccent'] = 556;
  17755. t['Igrave'] = 278;
  17756. t['Imacron'] = 278;
  17757. t['Lcaron'] = 611;
  17758. t['onehalf'] = 834;
  17759. t['lessequal'] = 549;
  17760. t['ocircumflex'] = 611;
  17761. t['ntilde'] = 611;
  17762. t['Uhungarumlaut'] = 722;
  17763. t['Eacute'] = 667;
  17764. t['emacron'] = 556;
  17765. t['gbreve'] = 611;
  17766. t['onequarter'] = 834;
  17767. t['Scaron'] = 667;
  17768. t['Scommaaccent'] = 667;
  17769. t['Ohungarumlaut'] = 778;
  17770. t['degree'] = 400;
  17771. t['ograve'] = 611;
  17772. t['Ccaron'] = 722;
  17773. t['ugrave'] = 611;
  17774. t['radical'] = 549;
  17775. t['Dcaron'] = 722;
  17776. t['rcommaaccent'] = 389;
  17777. t['Ntilde'] = 722;
  17778. t['otilde'] = 611;
  17779. t['Rcommaaccent'] = 722;
  17780. t['Lcommaaccent'] = 611;
  17781. t['Atilde'] = 722;
  17782. t['Aogonek'] = 722;
  17783. t['Aring'] = 722;
  17784. t['Otilde'] = 778;
  17785. t['zdotaccent'] = 500;
  17786. t['Ecaron'] = 667;
  17787. t['Iogonek'] = 278;
  17788. t['kcommaaccent'] = 556;
  17789. t['minus'] = 584;
  17790. t['Icircumflex'] = 278;
  17791. t['ncaron'] = 611;
  17792. t['tcommaaccent'] = 333;
  17793. t['logicalnot'] = 584;
  17794. t['odieresis'] = 611;
  17795. t['udieresis'] = 611;
  17796. t['notequal'] = 549;
  17797. t['gcommaaccent'] = 611;
  17798. t['eth'] = 611;
  17799. t['zcaron'] = 500;
  17800. t['ncommaaccent'] = 611;
  17801. t['onesuperior'] = 333;
  17802. t['imacron'] = 278;
  17803. t['Euro'] = 556;
  17804. });
  17805. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17806. t['space'] = 278;
  17807. t['exclam'] = 333;
  17808. t['quotedbl'] = 474;
  17809. t['numbersign'] = 556;
  17810. t['dollar'] = 556;
  17811. t['percent'] = 889;
  17812. t['ampersand'] = 722;
  17813. t['quoteright'] = 278;
  17814. t['parenleft'] = 333;
  17815. t['parenright'] = 333;
  17816. t['asterisk'] = 389;
  17817. t['plus'] = 584;
  17818. t['comma'] = 278;
  17819. t['hyphen'] = 333;
  17820. t['period'] = 278;
  17821. t['slash'] = 278;
  17822. t['zero'] = 556;
  17823. t['one'] = 556;
  17824. t['two'] = 556;
  17825. t['three'] = 556;
  17826. t['four'] = 556;
  17827. t['five'] = 556;
  17828. t['six'] = 556;
  17829. t['seven'] = 556;
  17830. t['eight'] = 556;
  17831. t['nine'] = 556;
  17832. t['colon'] = 333;
  17833. t['semicolon'] = 333;
  17834. t['less'] = 584;
  17835. t['equal'] = 584;
  17836. t['greater'] = 584;
  17837. t['question'] = 611;
  17838. t['at'] = 975;
  17839. t['A'] = 722;
  17840. t['B'] = 722;
  17841. t['C'] = 722;
  17842. t['D'] = 722;
  17843. t['E'] = 667;
  17844. t['F'] = 611;
  17845. t['G'] = 778;
  17846. t['H'] = 722;
  17847. t['I'] = 278;
  17848. t['J'] = 556;
  17849. t['K'] = 722;
  17850. t['L'] = 611;
  17851. t['M'] = 833;
  17852. t['N'] = 722;
  17853. t['O'] = 778;
  17854. t['P'] = 667;
  17855. t['Q'] = 778;
  17856. t['R'] = 722;
  17857. t['S'] = 667;
  17858. t['T'] = 611;
  17859. t['U'] = 722;
  17860. t['V'] = 667;
  17861. t['W'] = 944;
  17862. t['X'] = 667;
  17863. t['Y'] = 667;
  17864. t['Z'] = 611;
  17865. t['bracketleft'] = 333;
  17866. t['backslash'] = 278;
  17867. t['bracketright'] = 333;
  17868. t['asciicircum'] = 584;
  17869. t['underscore'] = 556;
  17870. t['quoteleft'] = 278;
  17871. t['a'] = 556;
  17872. t['b'] = 611;
  17873. t['c'] = 556;
  17874. t['d'] = 611;
  17875. t['e'] = 556;
  17876. t['f'] = 333;
  17877. t['g'] = 611;
  17878. t['h'] = 611;
  17879. t['i'] = 278;
  17880. t['j'] = 278;
  17881. t['k'] = 556;
  17882. t['l'] = 278;
  17883. t['m'] = 889;
  17884. t['n'] = 611;
  17885. t['o'] = 611;
  17886. t['p'] = 611;
  17887. t['q'] = 611;
  17888. t['r'] = 389;
  17889. t['s'] = 556;
  17890. t['t'] = 333;
  17891. t['u'] = 611;
  17892. t['v'] = 556;
  17893. t['w'] = 778;
  17894. t['x'] = 556;
  17895. t['y'] = 556;
  17896. t['z'] = 500;
  17897. t['braceleft'] = 389;
  17898. t['bar'] = 280;
  17899. t['braceright'] = 389;
  17900. t['asciitilde'] = 584;
  17901. t['exclamdown'] = 333;
  17902. t['cent'] = 556;
  17903. t['sterling'] = 556;
  17904. t['fraction'] = 167;
  17905. t['yen'] = 556;
  17906. t['florin'] = 556;
  17907. t['section'] = 556;
  17908. t['currency'] = 556;
  17909. t['quotesingle'] = 238;
  17910. t['quotedblleft'] = 500;
  17911. t['guillemotleft'] = 556;
  17912. t['guilsinglleft'] = 333;
  17913. t['guilsinglright'] = 333;
  17914. t['fi'] = 611;
  17915. t['fl'] = 611;
  17916. t['endash'] = 556;
  17917. t['dagger'] = 556;
  17918. t['daggerdbl'] = 556;
  17919. t['periodcentered'] = 278;
  17920. t['paragraph'] = 556;
  17921. t['bullet'] = 350;
  17922. t['quotesinglbase'] = 278;
  17923. t['quotedblbase'] = 500;
  17924. t['quotedblright'] = 500;
  17925. t['guillemotright'] = 556;
  17926. t['ellipsis'] = 1000;
  17927. t['perthousand'] = 1000;
  17928. t['questiondown'] = 611;
  17929. t['grave'] = 333;
  17930. t['acute'] = 333;
  17931. t['circumflex'] = 333;
  17932. t['tilde'] = 333;
  17933. t['macron'] = 333;
  17934. t['breve'] = 333;
  17935. t['dotaccent'] = 333;
  17936. t['dieresis'] = 333;
  17937. t['ring'] = 333;
  17938. t['cedilla'] = 333;
  17939. t['hungarumlaut'] = 333;
  17940. t['ogonek'] = 333;
  17941. t['caron'] = 333;
  17942. t['emdash'] = 1000;
  17943. t['AE'] = 1000;
  17944. t['ordfeminine'] = 370;
  17945. t['Lslash'] = 611;
  17946. t['Oslash'] = 778;
  17947. t['OE'] = 1000;
  17948. t['ordmasculine'] = 365;
  17949. t['ae'] = 889;
  17950. t['dotlessi'] = 278;
  17951. t['lslash'] = 278;
  17952. t['oslash'] = 611;
  17953. t['oe'] = 944;
  17954. t['germandbls'] = 611;
  17955. t['Idieresis'] = 278;
  17956. t['eacute'] = 556;
  17957. t['abreve'] = 556;
  17958. t['uhungarumlaut'] = 611;
  17959. t['ecaron'] = 556;
  17960. t['Ydieresis'] = 667;
  17961. t['divide'] = 584;
  17962. t['Yacute'] = 667;
  17963. t['Acircumflex'] = 722;
  17964. t['aacute'] = 556;
  17965. t['Ucircumflex'] = 722;
  17966. t['yacute'] = 556;
  17967. t['scommaaccent'] = 556;
  17968. t['ecircumflex'] = 556;
  17969. t['Uring'] = 722;
  17970. t['Udieresis'] = 722;
  17971. t['aogonek'] = 556;
  17972. t['Uacute'] = 722;
  17973. t['uogonek'] = 611;
  17974. t['Edieresis'] = 667;
  17975. t['Dcroat'] = 722;
  17976. t['commaaccent'] = 250;
  17977. t['copyright'] = 737;
  17978. t['Emacron'] = 667;
  17979. t['ccaron'] = 556;
  17980. t['aring'] = 556;
  17981. t['Ncommaaccent'] = 722;
  17982. t['lacute'] = 278;
  17983. t['agrave'] = 556;
  17984. t['Tcommaaccent'] = 611;
  17985. t['Cacute'] = 722;
  17986. t['atilde'] = 556;
  17987. t['Edotaccent'] = 667;
  17988. t['scaron'] = 556;
  17989. t['scedilla'] = 556;
  17990. t['iacute'] = 278;
  17991. t['lozenge'] = 494;
  17992. t['Rcaron'] = 722;
  17993. t['Gcommaaccent'] = 778;
  17994. t['ucircumflex'] = 611;
  17995. t['acircumflex'] = 556;
  17996. t['Amacron'] = 722;
  17997. t['rcaron'] = 389;
  17998. t['ccedilla'] = 556;
  17999. t['Zdotaccent'] = 611;
  18000. t['Thorn'] = 667;
  18001. t['Omacron'] = 778;
  18002. t['Racute'] = 722;
  18003. t['Sacute'] = 667;
  18004. t['dcaron'] = 743;
  18005. t['Umacron'] = 722;
  18006. t['uring'] = 611;
  18007. t['threesuperior'] = 333;
  18008. t['Ograve'] = 778;
  18009. t['Agrave'] = 722;
  18010. t['Abreve'] = 722;
  18011. t['multiply'] = 584;
  18012. t['uacute'] = 611;
  18013. t['Tcaron'] = 611;
  18014. t['partialdiff'] = 494;
  18015. t['ydieresis'] = 556;
  18016. t['Nacute'] = 722;
  18017. t['icircumflex'] = 278;
  18018. t['Ecircumflex'] = 667;
  18019. t['adieresis'] = 556;
  18020. t['edieresis'] = 556;
  18021. t['cacute'] = 556;
  18022. t['nacute'] = 611;
  18023. t['umacron'] = 611;
  18024. t['Ncaron'] = 722;
  18025. t['Iacute'] = 278;
  18026. t['plusminus'] = 584;
  18027. t['brokenbar'] = 280;
  18028. t['registered'] = 737;
  18029. t['Gbreve'] = 778;
  18030. t['Idotaccent'] = 278;
  18031. t['summation'] = 600;
  18032. t['Egrave'] = 667;
  18033. t['racute'] = 389;
  18034. t['omacron'] = 611;
  18035. t['Zacute'] = 611;
  18036. t['Zcaron'] = 611;
  18037. t['greaterequal'] = 549;
  18038. t['Eth'] = 722;
  18039. t['Ccedilla'] = 722;
  18040. t['lcommaaccent'] = 278;
  18041. t['tcaron'] = 389;
  18042. t['eogonek'] = 556;
  18043. t['Uogonek'] = 722;
  18044. t['Aacute'] = 722;
  18045. t['Adieresis'] = 722;
  18046. t['egrave'] = 556;
  18047. t['zacute'] = 500;
  18048. t['iogonek'] = 278;
  18049. t['Oacute'] = 778;
  18050. t['oacute'] = 611;
  18051. t['amacron'] = 556;
  18052. t['sacute'] = 556;
  18053. t['idieresis'] = 278;
  18054. t['Ocircumflex'] = 778;
  18055. t['Ugrave'] = 722;
  18056. t['Delta'] = 612;
  18057. t['thorn'] = 611;
  18058. t['twosuperior'] = 333;
  18059. t['Odieresis'] = 778;
  18060. t['mu'] = 611;
  18061. t['igrave'] = 278;
  18062. t['ohungarumlaut'] = 611;
  18063. t['Eogonek'] = 667;
  18064. t['dcroat'] = 611;
  18065. t['threequarters'] = 834;
  18066. t['Scedilla'] = 667;
  18067. t['lcaron'] = 400;
  18068. t['Kcommaaccent'] = 722;
  18069. t['Lacute'] = 611;
  18070. t['trademark'] = 1000;
  18071. t['edotaccent'] = 556;
  18072. t['Igrave'] = 278;
  18073. t['Imacron'] = 278;
  18074. t['Lcaron'] = 611;
  18075. t['onehalf'] = 834;
  18076. t['lessequal'] = 549;
  18077. t['ocircumflex'] = 611;
  18078. t['ntilde'] = 611;
  18079. t['Uhungarumlaut'] = 722;
  18080. t['Eacute'] = 667;
  18081. t['emacron'] = 556;
  18082. t['gbreve'] = 611;
  18083. t['onequarter'] = 834;
  18084. t['Scaron'] = 667;
  18085. t['Scommaaccent'] = 667;
  18086. t['Ohungarumlaut'] = 778;
  18087. t['degree'] = 400;
  18088. t['ograve'] = 611;
  18089. t['Ccaron'] = 722;
  18090. t['ugrave'] = 611;
  18091. t['radical'] = 549;
  18092. t['Dcaron'] = 722;
  18093. t['rcommaaccent'] = 389;
  18094. t['Ntilde'] = 722;
  18095. t['otilde'] = 611;
  18096. t['Rcommaaccent'] = 722;
  18097. t['Lcommaaccent'] = 611;
  18098. t['Atilde'] = 722;
  18099. t['Aogonek'] = 722;
  18100. t['Aring'] = 722;
  18101. t['Otilde'] = 778;
  18102. t['zdotaccent'] = 500;
  18103. t['Ecaron'] = 667;
  18104. t['Iogonek'] = 278;
  18105. t['kcommaaccent'] = 556;
  18106. t['minus'] = 584;
  18107. t['Icircumflex'] = 278;
  18108. t['ncaron'] = 611;
  18109. t['tcommaaccent'] = 333;
  18110. t['logicalnot'] = 584;
  18111. t['odieresis'] = 611;
  18112. t['udieresis'] = 611;
  18113. t['notequal'] = 549;
  18114. t['gcommaaccent'] = 611;
  18115. t['eth'] = 611;
  18116. t['zcaron'] = 500;
  18117. t['ncommaaccent'] = 611;
  18118. t['onesuperior'] = 333;
  18119. t['imacron'] = 278;
  18120. t['Euro'] = 556;
  18121. });
  18122. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18123. t['space'] = 278;
  18124. t['exclam'] = 278;
  18125. t['quotedbl'] = 355;
  18126. t['numbersign'] = 556;
  18127. t['dollar'] = 556;
  18128. t['percent'] = 889;
  18129. t['ampersand'] = 667;
  18130. t['quoteright'] = 222;
  18131. t['parenleft'] = 333;
  18132. t['parenright'] = 333;
  18133. t['asterisk'] = 389;
  18134. t['plus'] = 584;
  18135. t['comma'] = 278;
  18136. t['hyphen'] = 333;
  18137. t['period'] = 278;
  18138. t['slash'] = 278;
  18139. t['zero'] = 556;
  18140. t['one'] = 556;
  18141. t['two'] = 556;
  18142. t['three'] = 556;
  18143. t['four'] = 556;
  18144. t['five'] = 556;
  18145. t['six'] = 556;
  18146. t['seven'] = 556;
  18147. t['eight'] = 556;
  18148. t['nine'] = 556;
  18149. t['colon'] = 278;
  18150. t['semicolon'] = 278;
  18151. t['less'] = 584;
  18152. t['equal'] = 584;
  18153. t['greater'] = 584;
  18154. t['question'] = 556;
  18155. t['at'] = 1015;
  18156. t['A'] = 667;
  18157. t['B'] = 667;
  18158. t['C'] = 722;
  18159. t['D'] = 722;
  18160. t['E'] = 667;
  18161. t['F'] = 611;
  18162. t['G'] = 778;
  18163. t['H'] = 722;
  18164. t['I'] = 278;
  18165. t['J'] = 500;
  18166. t['K'] = 667;
  18167. t['L'] = 556;
  18168. t['M'] = 833;
  18169. t['N'] = 722;
  18170. t['O'] = 778;
  18171. t['P'] = 667;
  18172. t['Q'] = 778;
  18173. t['R'] = 722;
  18174. t['S'] = 667;
  18175. t['T'] = 611;
  18176. t['U'] = 722;
  18177. t['V'] = 667;
  18178. t['W'] = 944;
  18179. t['X'] = 667;
  18180. t['Y'] = 667;
  18181. t['Z'] = 611;
  18182. t['bracketleft'] = 278;
  18183. t['backslash'] = 278;
  18184. t['bracketright'] = 278;
  18185. t['asciicircum'] = 469;
  18186. t['underscore'] = 556;
  18187. t['quoteleft'] = 222;
  18188. t['a'] = 556;
  18189. t['b'] = 556;
  18190. t['c'] = 500;
  18191. t['d'] = 556;
  18192. t['e'] = 556;
  18193. t['f'] = 278;
  18194. t['g'] = 556;
  18195. t['h'] = 556;
  18196. t['i'] = 222;
  18197. t['j'] = 222;
  18198. t['k'] = 500;
  18199. t['l'] = 222;
  18200. t['m'] = 833;
  18201. t['n'] = 556;
  18202. t['o'] = 556;
  18203. t['p'] = 556;
  18204. t['q'] = 556;
  18205. t['r'] = 333;
  18206. t['s'] = 500;
  18207. t['t'] = 278;
  18208. t['u'] = 556;
  18209. t['v'] = 500;
  18210. t['w'] = 722;
  18211. t['x'] = 500;
  18212. t['y'] = 500;
  18213. t['z'] = 500;
  18214. t['braceleft'] = 334;
  18215. t['bar'] = 260;
  18216. t['braceright'] = 334;
  18217. t['asciitilde'] = 584;
  18218. t['exclamdown'] = 333;
  18219. t['cent'] = 556;
  18220. t['sterling'] = 556;
  18221. t['fraction'] = 167;
  18222. t['yen'] = 556;
  18223. t['florin'] = 556;
  18224. t['section'] = 556;
  18225. t['currency'] = 556;
  18226. t['quotesingle'] = 191;
  18227. t['quotedblleft'] = 333;
  18228. t['guillemotleft'] = 556;
  18229. t['guilsinglleft'] = 333;
  18230. t['guilsinglright'] = 333;
  18231. t['fi'] = 500;
  18232. t['fl'] = 500;
  18233. t['endash'] = 556;
  18234. t['dagger'] = 556;
  18235. t['daggerdbl'] = 556;
  18236. t['periodcentered'] = 278;
  18237. t['paragraph'] = 537;
  18238. t['bullet'] = 350;
  18239. t['quotesinglbase'] = 222;
  18240. t['quotedblbase'] = 333;
  18241. t['quotedblright'] = 333;
  18242. t['guillemotright'] = 556;
  18243. t['ellipsis'] = 1000;
  18244. t['perthousand'] = 1000;
  18245. t['questiondown'] = 611;
  18246. t['grave'] = 333;
  18247. t['acute'] = 333;
  18248. t['circumflex'] = 333;
  18249. t['tilde'] = 333;
  18250. t['macron'] = 333;
  18251. t['breve'] = 333;
  18252. t['dotaccent'] = 333;
  18253. t['dieresis'] = 333;
  18254. t['ring'] = 333;
  18255. t['cedilla'] = 333;
  18256. t['hungarumlaut'] = 333;
  18257. t['ogonek'] = 333;
  18258. t['caron'] = 333;
  18259. t['emdash'] = 1000;
  18260. t['AE'] = 1000;
  18261. t['ordfeminine'] = 370;
  18262. t['Lslash'] = 556;
  18263. t['Oslash'] = 778;
  18264. t['OE'] = 1000;
  18265. t['ordmasculine'] = 365;
  18266. t['ae'] = 889;
  18267. t['dotlessi'] = 278;
  18268. t['lslash'] = 222;
  18269. t['oslash'] = 611;
  18270. t['oe'] = 944;
  18271. t['germandbls'] = 611;
  18272. t['Idieresis'] = 278;
  18273. t['eacute'] = 556;
  18274. t['abreve'] = 556;
  18275. t['uhungarumlaut'] = 556;
  18276. t['ecaron'] = 556;
  18277. t['Ydieresis'] = 667;
  18278. t['divide'] = 584;
  18279. t['Yacute'] = 667;
  18280. t['Acircumflex'] = 667;
  18281. t['aacute'] = 556;
  18282. t['Ucircumflex'] = 722;
  18283. t['yacute'] = 500;
  18284. t['scommaaccent'] = 500;
  18285. t['ecircumflex'] = 556;
  18286. t['Uring'] = 722;
  18287. t['Udieresis'] = 722;
  18288. t['aogonek'] = 556;
  18289. t['Uacute'] = 722;
  18290. t['uogonek'] = 556;
  18291. t['Edieresis'] = 667;
  18292. t['Dcroat'] = 722;
  18293. t['commaaccent'] = 250;
  18294. t['copyright'] = 737;
  18295. t['Emacron'] = 667;
  18296. t['ccaron'] = 500;
  18297. t['aring'] = 556;
  18298. t['Ncommaaccent'] = 722;
  18299. t['lacute'] = 222;
  18300. t['agrave'] = 556;
  18301. t['Tcommaaccent'] = 611;
  18302. t['Cacute'] = 722;
  18303. t['atilde'] = 556;
  18304. t['Edotaccent'] = 667;
  18305. t['scaron'] = 500;
  18306. t['scedilla'] = 500;
  18307. t['iacute'] = 278;
  18308. t['lozenge'] = 471;
  18309. t['Rcaron'] = 722;
  18310. t['Gcommaaccent'] = 778;
  18311. t['ucircumflex'] = 556;
  18312. t['acircumflex'] = 556;
  18313. t['Amacron'] = 667;
  18314. t['rcaron'] = 333;
  18315. t['ccedilla'] = 500;
  18316. t['Zdotaccent'] = 611;
  18317. t['Thorn'] = 667;
  18318. t['Omacron'] = 778;
  18319. t['Racute'] = 722;
  18320. t['Sacute'] = 667;
  18321. t['dcaron'] = 643;
  18322. t['Umacron'] = 722;
  18323. t['uring'] = 556;
  18324. t['threesuperior'] = 333;
  18325. t['Ograve'] = 778;
  18326. t['Agrave'] = 667;
  18327. t['Abreve'] = 667;
  18328. t['multiply'] = 584;
  18329. t['uacute'] = 556;
  18330. t['Tcaron'] = 611;
  18331. t['partialdiff'] = 476;
  18332. t['ydieresis'] = 500;
  18333. t['Nacute'] = 722;
  18334. t['icircumflex'] = 278;
  18335. t['Ecircumflex'] = 667;
  18336. t['adieresis'] = 556;
  18337. t['edieresis'] = 556;
  18338. t['cacute'] = 500;
  18339. t['nacute'] = 556;
  18340. t['umacron'] = 556;
  18341. t['Ncaron'] = 722;
  18342. t['Iacute'] = 278;
  18343. t['plusminus'] = 584;
  18344. t['brokenbar'] = 260;
  18345. t['registered'] = 737;
  18346. t['Gbreve'] = 778;
  18347. t['Idotaccent'] = 278;
  18348. t['summation'] = 600;
  18349. t['Egrave'] = 667;
  18350. t['racute'] = 333;
  18351. t['omacron'] = 556;
  18352. t['Zacute'] = 611;
  18353. t['Zcaron'] = 611;
  18354. t['greaterequal'] = 549;
  18355. t['Eth'] = 722;
  18356. t['Ccedilla'] = 722;
  18357. t['lcommaaccent'] = 222;
  18358. t['tcaron'] = 317;
  18359. t['eogonek'] = 556;
  18360. t['Uogonek'] = 722;
  18361. t['Aacute'] = 667;
  18362. t['Adieresis'] = 667;
  18363. t['egrave'] = 556;
  18364. t['zacute'] = 500;
  18365. t['iogonek'] = 222;
  18366. t['Oacute'] = 778;
  18367. t['oacute'] = 556;
  18368. t['amacron'] = 556;
  18369. t['sacute'] = 500;
  18370. t['idieresis'] = 278;
  18371. t['Ocircumflex'] = 778;
  18372. t['Ugrave'] = 722;
  18373. t['Delta'] = 612;
  18374. t['thorn'] = 556;
  18375. t['twosuperior'] = 333;
  18376. t['Odieresis'] = 778;
  18377. t['mu'] = 556;
  18378. t['igrave'] = 278;
  18379. t['ohungarumlaut'] = 556;
  18380. t['Eogonek'] = 667;
  18381. t['dcroat'] = 556;
  18382. t['threequarters'] = 834;
  18383. t['Scedilla'] = 667;
  18384. t['lcaron'] = 299;
  18385. t['Kcommaaccent'] = 667;
  18386. t['Lacute'] = 556;
  18387. t['trademark'] = 1000;
  18388. t['edotaccent'] = 556;
  18389. t['Igrave'] = 278;
  18390. t['Imacron'] = 278;
  18391. t['Lcaron'] = 556;
  18392. t['onehalf'] = 834;
  18393. t['lessequal'] = 549;
  18394. t['ocircumflex'] = 556;
  18395. t['ntilde'] = 556;
  18396. t['Uhungarumlaut'] = 722;
  18397. t['Eacute'] = 667;
  18398. t['emacron'] = 556;
  18399. t['gbreve'] = 556;
  18400. t['onequarter'] = 834;
  18401. t['Scaron'] = 667;
  18402. t['Scommaaccent'] = 667;
  18403. t['Ohungarumlaut'] = 778;
  18404. t['degree'] = 400;
  18405. t['ograve'] = 556;
  18406. t['Ccaron'] = 722;
  18407. t['ugrave'] = 556;
  18408. t['radical'] = 453;
  18409. t['Dcaron'] = 722;
  18410. t['rcommaaccent'] = 333;
  18411. t['Ntilde'] = 722;
  18412. t['otilde'] = 556;
  18413. t['Rcommaaccent'] = 722;
  18414. t['Lcommaaccent'] = 556;
  18415. t['Atilde'] = 667;
  18416. t['Aogonek'] = 667;
  18417. t['Aring'] = 667;
  18418. t['Otilde'] = 778;
  18419. t['zdotaccent'] = 500;
  18420. t['Ecaron'] = 667;
  18421. t['Iogonek'] = 278;
  18422. t['kcommaaccent'] = 500;
  18423. t['minus'] = 584;
  18424. t['Icircumflex'] = 278;
  18425. t['ncaron'] = 556;
  18426. t['tcommaaccent'] = 278;
  18427. t['logicalnot'] = 584;
  18428. t['odieresis'] = 556;
  18429. t['udieresis'] = 556;
  18430. t['notequal'] = 549;
  18431. t['gcommaaccent'] = 556;
  18432. t['eth'] = 556;
  18433. t['zcaron'] = 500;
  18434. t['ncommaaccent'] = 556;
  18435. t['onesuperior'] = 333;
  18436. t['imacron'] = 278;
  18437. t['Euro'] = 556;
  18438. });
  18439. t['Symbol'] = getLookupTableFactory(function (t) {
  18440. t['space'] = 250;
  18441. t['exclam'] = 333;
  18442. t['universal'] = 713;
  18443. t['numbersign'] = 500;
  18444. t['existential'] = 549;
  18445. t['percent'] = 833;
  18446. t['ampersand'] = 778;
  18447. t['suchthat'] = 439;
  18448. t['parenleft'] = 333;
  18449. t['parenright'] = 333;
  18450. t['asteriskmath'] = 500;
  18451. t['plus'] = 549;
  18452. t['comma'] = 250;
  18453. t['minus'] = 549;
  18454. t['period'] = 250;
  18455. t['slash'] = 278;
  18456. t['zero'] = 500;
  18457. t['one'] = 500;
  18458. t['two'] = 500;
  18459. t['three'] = 500;
  18460. t['four'] = 500;
  18461. t['five'] = 500;
  18462. t['six'] = 500;
  18463. t['seven'] = 500;
  18464. t['eight'] = 500;
  18465. t['nine'] = 500;
  18466. t['colon'] = 278;
  18467. t['semicolon'] = 278;
  18468. t['less'] = 549;
  18469. t['equal'] = 549;
  18470. t['greater'] = 549;
  18471. t['question'] = 444;
  18472. t['congruent'] = 549;
  18473. t['Alpha'] = 722;
  18474. t['Beta'] = 667;
  18475. t['Chi'] = 722;
  18476. t['Delta'] = 612;
  18477. t['Epsilon'] = 611;
  18478. t['Phi'] = 763;
  18479. t['Gamma'] = 603;
  18480. t['Eta'] = 722;
  18481. t['Iota'] = 333;
  18482. t['theta1'] = 631;
  18483. t['Kappa'] = 722;
  18484. t['Lambda'] = 686;
  18485. t['Mu'] = 889;
  18486. t['Nu'] = 722;
  18487. t['Omicron'] = 722;
  18488. t['Pi'] = 768;
  18489. t['Theta'] = 741;
  18490. t['Rho'] = 556;
  18491. t['Sigma'] = 592;
  18492. t['Tau'] = 611;
  18493. t['Upsilon'] = 690;
  18494. t['sigma1'] = 439;
  18495. t['Omega'] = 768;
  18496. t['Xi'] = 645;
  18497. t['Psi'] = 795;
  18498. t['Zeta'] = 611;
  18499. t['bracketleft'] = 333;
  18500. t['therefore'] = 863;
  18501. t['bracketright'] = 333;
  18502. t['perpendicular'] = 658;
  18503. t['underscore'] = 500;
  18504. t['radicalex'] = 500;
  18505. t['alpha'] = 631;
  18506. t['beta'] = 549;
  18507. t['chi'] = 549;
  18508. t['delta'] = 494;
  18509. t['epsilon'] = 439;
  18510. t['phi'] = 521;
  18511. t['gamma'] = 411;
  18512. t['eta'] = 603;
  18513. t['iota'] = 329;
  18514. t['phi1'] = 603;
  18515. t['kappa'] = 549;
  18516. t['lambda'] = 549;
  18517. t['mu'] = 576;
  18518. t['nu'] = 521;
  18519. t['omicron'] = 549;
  18520. t['pi'] = 549;
  18521. t['theta'] = 521;
  18522. t['rho'] = 549;
  18523. t['sigma'] = 603;
  18524. t['tau'] = 439;
  18525. t['upsilon'] = 576;
  18526. t['omega1'] = 713;
  18527. t['omega'] = 686;
  18528. t['xi'] = 493;
  18529. t['psi'] = 686;
  18530. t['zeta'] = 494;
  18531. t['braceleft'] = 480;
  18532. t['bar'] = 200;
  18533. t['braceright'] = 480;
  18534. t['similar'] = 549;
  18535. t['Euro'] = 750;
  18536. t['Upsilon1'] = 620;
  18537. t['minute'] = 247;
  18538. t['lessequal'] = 549;
  18539. t['fraction'] = 167;
  18540. t['infinity'] = 713;
  18541. t['florin'] = 500;
  18542. t['club'] = 753;
  18543. t['diamond'] = 753;
  18544. t['heart'] = 753;
  18545. t['spade'] = 753;
  18546. t['arrowboth'] = 1042;
  18547. t['arrowleft'] = 987;
  18548. t['arrowup'] = 603;
  18549. t['arrowright'] = 987;
  18550. t['arrowdown'] = 603;
  18551. t['degree'] = 400;
  18552. t['plusminus'] = 549;
  18553. t['second'] = 411;
  18554. t['greaterequal'] = 549;
  18555. t['multiply'] = 549;
  18556. t['proportional'] = 713;
  18557. t['partialdiff'] = 494;
  18558. t['bullet'] = 460;
  18559. t['divide'] = 549;
  18560. t['notequal'] = 549;
  18561. t['equivalence'] = 549;
  18562. t['approxequal'] = 549;
  18563. t['ellipsis'] = 1000;
  18564. t['arrowvertex'] = 603;
  18565. t['arrowhorizex'] = 1000;
  18566. t['carriagereturn'] = 658;
  18567. t['aleph'] = 823;
  18568. t['Ifraktur'] = 686;
  18569. t['Rfraktur'] = 795;
  18570. t['weierstrass'] = 987;
  18571. t['circlemultiply'] = 768;
  18572. t['circleplus'] = 768;
  18573. t['emptyset'] = 823;
  18574. t['intersection'] = 768;
  18575. t['union'] = 768;
  18576. t['propersuperset'] = 713;
  18577. t['reflexsuperset'] = 713;
  18578. t['notsubset'] = 713;
  18579. t['propersubset'] = 713;
  18580. t['reflexsubset'] = 713;
  18581. t['element'] = 713;
  18582. t['notelement'] = 713;
  18583. t['angle'] = 768;
  18584. t['gradient'] = 713;
  18585. t['registerserif'] = 790;
  18586. t['copyrightserif'] = 790;
  18587. t['trademarkserif'] = 890;
  18588. t['product'] = 823;
  18589. t['radical'] = 549;
  18590. t['dotmath'] = 250;
  18591. t['logicalnot'] = 713;
  18592. t['logicaland'] = 603;
  18593. t['logicalor'] = 603;
  18594. t['arrowdblboth'] = 1042;
  18595. t['arrowdblleft'] = 987;
  18596. t['arrowdblup'] = 603;
  18597. t['arrowdblright'] = 987;
  18598. t['arrowdbldown'] = 603;
  18599. t['lozenge'] = 494;
  18600. t['angleleft'] = 329;
  18601. t['registersans'] = 790;
  18602. t['copyrightsans'] = 790;
  18603. t['trademarksans'] = 786;
  18604. t['summation'] = 713;
  18605. t['parenlefttp'] = 384;
  18606. t['parenleftex'] = 384;
  18607. t['parenleftbt'] = 384;
  18608. t['bracketlefttp'] = 384;
  18609. t['bracketleftex'] = 384;
  18610. t['bracketleftbt'] = 384;
  18611. t['bracelefttp'] = 494;
  18612. t['braceleftmid'] = 494;
  18613. t['braceleftbt'] = 494;
  18614. t['braceex'] = 494;
  18615. t['angleright'] = 329;
  18616. t['integral'] = 274;
  18617. t['integraltp'] = 686;
  18618. t['integralex'] = 686;
  18619. t['integralbt'] = 686;
  18620. t['parenrighttp'] = 384;
  18621. t['parenrightex'] = 384;
  18622. t['parenrightbt'] = 384;
  18623. t['bracketrighttp'] = 384;
  18624. t['bracketrightex'] = 384;
  18625. t['bracketrightbt'] = 384;
  18626. t['bracerighttp'] = 494;
  18627. t['bracerightmid'] = 494;
  18628. t['bracerightbt'] = 494;
  18629. t['apple'] = 790;
  18630. });
  18631. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18632. t['space'] = 250;
  18633. t['exclam'] = 333;
  18634. t['quotedbl'] = 408;
  18635. t['numbersign'] = 500;
  18636. t['dollar'] = 500;
  18637. t['percent'] = 833;
  18638. t['ampersand'] = 778;
  18639. t['quoteright'] = 333;
  18640. t['parenleft'] = 333;
  18641. t['parenright'] = 333;
  18642. t['asterisk'] = 500;
  18643. t['plus'] = 564;
  18644. t['comma'] = 250;
  18645. t['hyphen'] = 333;
  18646. t['period'] = 250;
  18647. t['slash'] = 278;
  18648. t['zero'] = 500;
  18649. t['one'] = 500;
  18650. t['two'] = 500;
  18651. t['three'] = 500;
  18652. t['four'] = 500;
  18653. t['five'] = 500;
  18654. t['six'] = 500;
  18655. t['seven'] = 500;
  18656. t['eight'] = 500;
  18657. t['nine'] = 500;
  18658. t['colon'] = 278;
  18659. t['semicolon'] = 278;
  18660. t['less'] = 564;
  18661. t['equal'] = 564;
  18662. t['greater'] = 564;
  18663. t['question'] = 444;
  18664. t['at'] = 921;
  18665. t['A'] = 722;
  18666. t['B'] = 667;
  18667. t['C'] = 667;
  18668. t['D'] = 722;
  18669. t['E'] = 611;
  18670. t['F'] = 556;
  18671. t['G'] = 722;
  18672. t['H'] = 722;
  18673. t['I'] = 333;
  18674. t['J'] = 389;
  18675. t['K'] = 722;
  18676. t['L'] = 611;
  18677. t['M'] = 889;
  18678. t['N'] = 722;
  18679. t['O'] = 722;
  18680. t['P'] = 556;
  18681. t['Q'] = 722;
  18682. t['R'] = 667;
  18683. t['S'] = 556;
  18684. t['T'] = 611;
  18685. t['U'] = 722;
  18686. t['V'] = 722;
  18687. t['W'] = 944;
  18688. t['X'] = 722;
  18689. t['Y'] = 722;
  18690. t['Z'] = 611;
  18691. t['bracketleft'] = 333;
  18692. t['backslash'] = 278;
  18693. t['bracketright'] = 333;
  18694. t['asciicircum'] = 469;
  18695. t['underscore'] = 500;
  18696. t['quoteleft'] = 333;
  18697. t['a'] = 444;
  18698. t['b'] = 500;
  18699. t['c'] = 444;
  18700. t['d'] = 500;
  18701. t['e'] = 444;
  18702. t['f'] = 333;
  18703. t['g'] = 500;
  18704. t['h'] = 500;
  18705. t['i'] = 278;
  18706. t['j'] = 278;
  18707. t['k'] = 500;
  18708. t['l'] = 278;
  18709. t['m'] = 778;
  18710. t['n'] = 500;
  18711. t['o'] = 500;
  18712. t['p'] = 500;
  18713. t['q'] = 500;
  18714. t['r'] = 333;
  18715. t['s'] = 389;
  18716. t['t'] = 278;
  18717. t['u'] = 500;
  18718. t['v'] = 500;
  18719. t['w'] = 722;
  18720. t['x'] = 500;
  18721. t['y'] = 500;
  18722. t['z'] = 444;
  18723. t['braceleft'] = 480;
  18724. t['bar'] = 200;
  18725. t['braceright'] = 480;
  18726. t['asciitilde'] = 541;
  18727. t['exclamdown'] = 333;
  18728. t['cent'] = 500;
  18729. t['sterling'] = 500;
  18730. t['fraction'] = 167;
  18731. t['yen'] = 500;
  18732. t['florin'] = 500;
  18733. t['section'] = 500;
  18734. t['currency'] = 500;
  18735. t['quotesingle'] = 180;
  18736. t['quotedblleft'] = 444;
  18737. t['guillemotleft'] = 500;
  18738. t['guilsinglleft'] = 333;
  18739. t['guilsinglright'] = 333;
  18740. t['fi'] = 556;
  18741. t['fl'] = 556;
  18742. t['endash'] = 500;
  18743. t['dagger'] = 500;
  18744. t['daggerdbl'] = 500;
  18745. t['periodcentered'] = 250;
  18746. t['paragraph'] = 453;
  18747. t['bullet'] = 350;
  18748. t['quotesinglbase'] = 333;
  18749. t['quotedblbase'] = 444;
  18750. t['quotedblright'] = 444;
  18751. t['guillemotright'] = 500;
  18752. t['ellipsis'] = 1000;
  18753. t['perthousand'] = 1000;
  18754. t['questiondown'] = 444;
  18755. t['grave'] = 333;
  18756. t['acute'] = 333;
  18757. t['circumflex'] = 333;
  18758. t['tilde'] = 333;
  18759. t['macron'] = 333;
  18760. t['breve'] = 333;
  18761. t['dotaccent'] = 333;
  18762. t['dieresis'] = 333;
  18763. t['ring'] = 333;
  18764. t['cedilla'] = 333;
  18765. t['hungarumlaut'] = 333;
  18766. t['ogonek'] = 333;
  18767. t['caron'] = 333;
  18768. t['emdash'] = 1000;
  18769. t['AE'] = 889;
  18770. t['ordfeminine'] = 276;
  18771. t['Lslash'] = 611;
  18772. t['Oslash'] = 722;
  18773. t['OE'] = 889;
  18774. t['ordmasculine'] = 310;
  18775. t['ae'] = 667;
  18776. t['dotlessi'] = 278;
  18777. t['lslash'] = 278;
  18778. t['oslash'] = 500;
  18779. t['oe'] = 722;
  18780. t['germandbls'] = 500;
  18781. t['Idieresis'] = 333;
  18782. t['eacute'] = 444;
  18783. t['abreve'] = 444;
  18784. t['uhungarumlaut'] = 500;
  18785. t['ecaron'] = 444;
  18786. t['Ydieresis'] = 722;
  18787. t['divide'] = 564;
  18788. t['Yacute'] = 722;
  18789. t['Acircumflex'] = 722;
  18790. t['aacute'] = 444;
  18791. t['Ucircumflex'] = 722;
  18792. t['yacute'] = 500;
  18793. t['scommaaccent'] = 389;
  18794. t['ecircumflex'] = 444;
  18795. t['Uring'] = 722;
  18796. t['Udieresis'] = 722;
  18797. t['aogonek'] = 444;
  18798. t['Uacute'] = 722;
  18799. t['uogonek'] = 500;
  18800. t['Edieresis'] = 611;
  18801. t['Dcroat'] = 722;
  18802. t['commaaccent'] = 250;
  18803. t['copyright'] = 760;
  18804. t['Emacron'] = 611;
  18805. t['ccaron'] = 444;
  18806. t['aring'] = 444;
  18807. t['Ncommaaccent'] = 722;
  18808. t['lacute'] = 278;
  18809. t['agrave'] = 444;
  18810. t['Tcommaaccent'] = 611;
  18811. t['Cacute'] = 667;
  18812. t['atilde'] = 444;
  18813. t['Edotaccent'] = 611;
  18814. t['scaron'] = 389;
  18815. t['scedilla'] = 389;
  18816. t['iacute'] = 278;
  18817. t['lozenge'] = 471;
  18818. t['Rcaron'] = 667;
  18819. t['Gcommaaccent'] = 722;
  18820. t['ucircumflex'] = 500;
  18821. t['acircumflex'] = 444;
  18822. t['Amacron'] = 722;
  18823. t['rcaron'] = 333;
  18824. t['ccedilla'] = 444;
  18825. t['Zdotaccent'] = 611;
  18826. t['Thorn'] = 556;
  18827. t['Omacron'] = 722;
  18828. t['Racute'] = 667;
  18829. t['Sacute'] = 556;
  18830. t['dcaron'] = 588;
  18831. t['Umacron'] = 722;
  18832. t['uring'] = 500;
  18833. t['threesuperior'] = 300;
  18834. t['Ograve'] = 722;
  18835. t['Agrave'] = 722;
  18836. t['Abreve'] = 722;
  18837. t['multiply'] = 564;
  18838. t['uacute'] = 500;
  18839. t['Tcaron'] = 611;
  18840. t['partialdiff'] = 476;
  18841. t['ydieresis'] = 500;
  18842. t['Nacute'] = 722;
  18843. t['icircumflex'] = 278;
  18844. t['Ecircumflex'] = 611;
  18845. t['adieresis'] = 444;
  18846. t['edieresis'] = 444;
  18847. t['cacute'] = 444;
  18848. t['nacute'] = 500;
  18849. t['umacron'] = 500;
  18850. t['Ncaron'] = 722;
  18851. t['Iacute'] = 333;
  18852. t['plusminus'] = 564;
  18853. t['brokenbar'] = 200;
  18854. t['registered'] = 760;
  18855. t['Gbreve'] = 722;
  18856. t['Idotaccent'] = 333;
  18857. t['summation'] = 600;
  18858. t['Egrave'] = 611;
  18859. t['racute'] = 333;
  18860. t['omacron'] = 500;
  18861. t['Zacute'] = 611;
  18862. t['Zcaron'] = 611;
  18863. t['greaterequal'] = 549;
  18864. t['Eth'] = 722;
  18865. t['Ccedilla'] = 667;
  18866. t['lcommaaccent'] = 278;
  18867. t['tcaron'] = 326;
  18868. t['eogonek'] = 444;
  18869. t['Uogonek'] = 722;
  18870. t['Aacute'] = 722;
  18871. t['Adieresis'] = 722;
  18872. t['egrave'] = 444;
  18873. t['zacute'] = 444;
  18874. t['iogonek'] = 278;
  18875. t['Oacute'] = 722;
  18876. t['oacute'] = 500;
  18877. t['amacron'] = 444;
  18878. t['sacute'] = 389;
  18879. t['idieresis'] = 278;
  18880. t['Ocircumflex'] = 722;
  18881. t['Ugrave'] = 722;
  18882. t['Delta'] = 612;
  18883. t['thorn'] = 500;
  18884. t['twosuperior'] = 300;
  18885. t['Odieresis'] = 722;
  18886. t['mu'] = 500;
  18887. t['igrave'] = 278;
  18888. t['ohungarumlaut'] = 500;
  18889. t['Eogonek'] = 611;
  18890. t['dcroat'] = 500;
  18891. t['threequarters'] = 750;
  18892. t['Scedilla'] = 556;
  18893. t['lcaron'] = 344;
  18894. t['Kcommaaccent'] = 722;
  18895. t['Lacute'] = 611;
  18896. t['trademark'] = 980;
  18897. t['edotaccent'] = 444;
  18898. t['Igrave'] = 333;
  18899. t['Imacron'] = 333;
  18900. t['Lcaron'] = 611;
  18901. t['onehalf'] = 750;
  18902. t['lessequal'] = 549;
  18903. t['ocircumflex'] = 500;
  18904. t['ntilde'] = 500;
  18905. t['Uhungarumlaut'] = 722;
  18906. t['Eacute'] = 611;
  18907. t['emacron'] = 444;
  18908. t['gbreve'] = 500;
  18909. t['onequarter'] = 750;
  18910. t['Scaron'] = 556;
  18911. t['Scommaaccent'] = 556;
  18912. t['Ohungarumlaut'] = 722;
  18913. t['degree'] = 400;
  18914. t['ograve'] = 500;
  18915. t['Ccaron'] = 667;
  18916. t['ugrave'] = 500;
  18917. t['radical'] = 453;
  18918. t['Dcaron'] = 722;
  18919. t['rcommaaccent'] = 333;
  18920. t['Ntilde'] = 722;
  18921. t['otilde'] = 500;
  18922. t['Rcommaaccent'] = 667;
  18923. t['Lcommaaccent'] = 611;
  18924. t['Atilde'] = 722;
  18925. t['Aogonek'] = 722;
  18926. t['Aring'] = 722;
  18927. t['Otilde'] = 722;
  18928. t['zdotaccent'] = 444;
  18929. t['Ecaron'] = 611;
  18930. t['Iogonek'] = 333;
  18931. t['kcommaaccent'] = 500;
  18932. t['minus'] = 564;
  18933. t['Icircumflex'] = 333;
  18934. t['ncaron'] = 500;
  18935. t['tcommaaccent'] = 278;
  18936. t['logicalnot'] = 564;
  18937. t['odieresis'] = 500;
  18938. t['udieresis'] = 500;
  18939. t['notequal'] = 549;
  18940. t['gcommaaccent'] = 500;
  18941. t['eth'] = 500;
  18942. t['zcaron'] = 444;
  18943. t['ncommaaccent'] = 500;
  18944. t['onesuperior'] = 300;
  18945. t['imacron'] = 278;
  18946. t['Euro'] = 500;
  18947. });
  18948. t['Times-Bold'] = getLookupTableFactory(function (t) {
  18949. t['space'] = 250;
  18950. t['exclam'] = 333;
  18951. t['quotedbl'] = 555;
  18952. t['numbersign'] = 500;
  18953. t['dollar'] = 500;
  18954. t['percent'] = 1000;
  18955. t['ampersand'] = 833;
  18956. t['quoteright'] = 333;
  18957. t['parenleft'] = 333;
  18958. t['parenright'] = 333;
  18959. t['asterisk'] = 500;
  18960. t['plus'] = 570;
  18961. t['comma'] = 250;
  18962. t['hyphen'] = 333;
  18963. t['period'] = 250;
  18964. t['slash'] = 278;
  18965. t['zero'] = 500;
  18966. t['one'] = 500;
  18967. t['two'] = 500;
  18968. t['three'] = 500;
  18969. t['four'] = 500;
  18970. t['five'] = 500;
  18971. t['six'] = 500;
  18972. t['seven'] = 500;
  18973. t['eight'] = 500;
  18974. t['nine'] = 500;
  18975. t['colon'] = 333;
  18976. t['semicolon'] = 333;
  18977. t['less'] = 570;
  18978. t['equal'] = 570;
  18979. t['greater'] = 570;
  18980. t['question'] = 500;
  18981. t['at'] = 930;
  18982. t['A'] = 722;
  18983. t['B'] = 667;
  18984. t['C'] = 722;
  18985. t['D'] = 722;
  18986. t['E'] = 667;
  18987. t['F'] = 611;
  18988. t['G'] = 778;
  18989. t['H'] = 778;
  18990. t['I'] = 389;
  18991. t['J'] = 500;
  18992. t['K'] = 778;
  18993. t['L'] = 667;
  18994. t['M'] = 944;
  18995. t['N'] = 722;
  18996. t['O'] = 778;
  18997. t['P'] = 611;
  18998. t['Q'] = 778;
  18999. t['R'] = 722;
  19000. t['S'] = 556;
  19001. t['T'] = 667;
  19002. t['U'] = 722;
  19003. t['V'] = 722;
  19004. t['W'] = 1000;
  19005. t['X'] = 722;
  19006. t['Y'] = 722;
  19007. t['Z'] = 667;
  19008. t['bracketleft'] = 333;
  19009. t['backslash'] = 278;
  19010. t['bracketright'] = 333;
  19011. t['asciicircum'] = 581;
  19012. t['underscore'] = 500;
  19013. t['quoteleft'] = 333;
  19014. t['a'] = 500;
  19015. t['b'] = 556;
  19016. t['c'] = 444;
  19017. t['d'] = 556;
  19018. t['e'] = 444;
  19019. t['f'] = 333;
  19020. t['g'] = 500;
  19021. t['h'] = 556;
  19022. t['i'] = 278;
  19023. t['j'] = 333;
  19024. t['k'] = 556;
  19025. t['l'] = 278;
  19026. t['m'] = 833;
  19027. t['n'] = 556;
  19028. t['o'] = 500;
  19029. t['p'] = 556;
  19030. t['q'] = 556;
  19031. t['r'] = 444;
  19032. t['s'] = 389;
  19033. t['t'] = 333;
  19034. t['u'] = 556;
  19035. t['v'] = 500;
  19036. t['w'] = 722;
  19037. t['x'] = 500;
  19038. t['y'] = 500;
  19039. t['z'] = 444;
  19040. t['braceleft'] = 394;
  19041. t['bar'] = 220;
  19042. t['braceright'] = 394;
  19043. t['asciitilde'] = 520;
  19044. t['exclamdown'] = 333;
  19045. t['cent'] = 500;
  19046. t['sterling'] = 500;
  19047. t['fraction'] = 167;
  19048. t['yen'] = 500;
  19049. t['florin'] = 500;
  19050. t['section'] = 500;
  19051. t['currency'] = 500;
  19052. t['quotesingle'] = 278;
  19053. t['quotedblleft'] = 500;
  19054. t['guillemotleft'] = 500;
  19055. t['guilsinglleft'] = 333;
  19056. t['guilsinglright'] = 333;
  19057. t['fi'] = 556;
  19058. t['fl'] = 556;
  19059. t['endash'] = 500;
  19060. t['dagger'] = 500;
  19061. t['daggerdbl'] = 500;
  19062. t['periodcentered'] = 250;
  19063. t['paragraph'] = 540;
  19064. t['bullet'] = 350;
  19065. t['quotesinglbase'] = 333;
  19066. t['quotedblbase'] = 500;
  19067. t['quotedblright'] = 500;
  19068. t['guillemotright'] = 500;
  19069. t['ellipsis'] = 1000;
  19070. t['perthousand'] = 1000;
  19071. t['questiondown'] = 500;
  19072. t['grave'] = 333;
  19073. t['acute'] = 333;
  19074. t['circumflex'] = 333;
  19075. t['tilde'] = 333;
  19076. t['macron'] = 333;
  19077. t['breve'] = 333;
  19078. t['dotaccent'] = 333;
  19079. t['dieresis'] = 333;
  19080. t['ring'] = 333;
  19081. t['cedilla'] = 333;
  19082. t['hungarumlaut'] = 333;
  19083. t['ogonek'] = 333;
  19084. t['caron'] = 333;
  19085. t['emdash'] = 1000;
  19086. t['AE'] = 1000;
  19087. t['ordfeminine'] = 300;
  19088. t['Lslash'] = 667;
  19089. t['Oslash'] = 778;
  19090. t['OE'] = 1000;
  19091. t['ordmasculine'] = 330;
  19092. t['ae'] = 722;
  19093. t['dotlessi'] = 278;
  19094. t['lslash'] = 278;
  19095. t['oslash'] = 500;
  19096. t['oe'] = 722;
  19097. t['germandbls'] = 556;
  19098. t['Idieresis'] = 389;
  19099. t['eacute'] = 444;
  19100. t['abreve'] = 500;
  19101. t['uhungarumlaut'] = 556;
  19102. t['ecaron'] = 444;
  19103. t['Ydieresis'] = 722;
  19104. t['divide'] = 570;
  19105. t['Yacute'] = 722;
  19106. t['Acircumflex'] = 722;
  19107. t['aacute'] = 500;
  19108. t['Ucircumflex'] = 722;
  19109. t['yacute'] = 500;
  19110. t['scommaaccent'] = 389;
  19111. t['ecircumflex'] = 444;
  19112. t['Uring'] = 722;
  19113. t['Udieresis'] = 722;
  19114. t['aogonek'] = 500;
  19115. t['Uacute'] = 722;
  19116. t['uogonek'] = 556;
  19117. t['Edieresis'] = 667;
  19118. t['Dcroat'] = 722;
  19119. t['commaaccent'] = 250;
  19120. t['copyright'] = 747;
  19121. t['Emacron'] = 667;
  19122. t['ccaron'] = 444;
  19123. t['aring'] = 500;
  19124. t['Ncommaaccent'] = 722;
  19125. t['lacute'] = 278;
  19126. t['agrave'] = 500;
  19127. t['Tcommaaccent'] = 667;
  19128. t['Cacute'] = 722;
  19129. t['atilde'] = 500;
  19130. t['Edotaccent'] = 667;
  19131. t['scaron'] = 389;
  19132. t['scedilla'] = 389;
  19133. t['iacute'] = 278;
  19134. t['lozenge'] = 494;
  19135. t['Rcaron'] = 722;
  19136. t['Gcommaaccent'] = 778;
  19137. t['ucircumflex'] = 556;
  19138. t['acircumflex'] = 500;
  19139. t['Amacron'] = 722;
  19140. t['rcaron'] = 444;
  19141. t['ccedilla'] = 444;
  19142. t['Zdotaccent'] = 667;
  19143. t['Thorn'] = 611;
  19144. t['Omacron'] = 778;
  19145. t['Racute'] = 722;
  19146. t['Sacute'] = 556;
  19147. t['dcaron'] = 672;
  19148. t['Umacron'] = 722;
  19149. t['uring'] = 556;
  19150. t['threesuperior'] = 300;
  19151. t['Ograve'] = 778;
  19152. t['Agrave'] = 722;
  19153. t['Abreve'] = 722;
  19154. t['multiply'] = 570;
  19155. t['uacute'] = 556;
  19156. t['Tcaron'] = 667;
  19157. t['partialdiff'] = 494;
  19158. t['ydieresis'] = 500;
  19159. t['Nacute'] = 722;
  19160. t['icircumflex'] = 278;
  19161. t['Ecircumflex'] = 667;
  19162. t['adieresis'] = 500;
  19163. t['edieresis'] = 444;
  19164. t['cacute'] = 444;
  19165. t['nacute'] = 556;
  19166. t['umacron'] = 556;
  19167. t['Ncaron'] = 722;
  19168. t['Iacute'] = 389;
  19169. t['plusminus'] = 570;
  19170. t['brokenbar'] = 220;
  19171. t['registered'] = 747;
  19172. t['Gbreve'] = 778;
  19173. t['Idotaccent'] = 389;
  19174. t['summation'] = 600;
  19175. t['Egrave'] = 667;
  19176. t['racute'] = 444;
  19177. t['omacron'] = 500;
  19178. t['Zacute'] = 667;
  19179. t['Zcaron'] = 667;
  19180. t['greaterequal'] = 549;
  19181. t['Eth'] = 722;
  19182. t['Ccedilla'] = 722;
  19183. t['lcommaaccent'] = 278;
  19184. t['tcaron'] = 416;
  19185. t['eogonek'] = 444;
  19186. t['Uogonek'] = 722;
  19187. t['Aacute'] = 722;
  19188. t['Adieresis'] = 722;
  19189. t['egrave'] = 444;
  19190. t['zacute'] = 444;
  19191. t['iogonek'] = 278;
  19192. t['Oacute'] = 778;
  19193. t['oacute'] = 500;
  19194. t['amacron'] = 500;
  19195. t['sacute'] = 389;
  19196. t['idieresis'] = 278;
  19197. t['Ocircumflex'] = 778;
  19198. t['Ugrave'] = 722;
  19199. t['Delta'] = 612;
  19200. t['thorn'] = 556;
  19201. t['twosuperior'] = 300;
  19202. t['Odieresis'] = 778;
  19203. t['mu'] = 556;
  19204. t['igrave'] = 278;
  19205. t['ohungarumlaut'] = 500;
  19206. t['Eogonek'] = 667;
  19207. t['dcroat'] = 556;
  19208. t['threequarters'] = 750;
  19209. t['Scedilla'] = 556;
  19210. t['lcaron'] = 394;
  19211. t['Kcommaaccent'] = 778;
  19212. t['Lacute'] = 667;
  19213. t['trademark'] = 1000;
  19214. t['edotaccent'] = 444;
  19215. t['Igrave'] = 389;
  19216. t['Imacron'] = 389;
  19217. t['Lcaron'] = 667;
  19218. t['onehalf'] = 750;
  19219. t['lessequal'] = 549;
  19220. t['ocircumflex'] = 500;
  19221. t['ntilde'] = 556;
  19222. t['Uhungarumlaut'] = 722;
  19223. t['Eacute'] = 667;
  19224. t['emacron'] = 444;
  19225. t['gbreve'] = 500;
  19226. t['onequarter'] = 750;
  19227. t['Scaron'] = 556;
  19228. t['Scommaaccent'] = 556;
  19229. t['Ohungarumlaut'] = 778;
  19230. t['degree'] = 400;
  19231. t['ograve'] = 500;
  19232. t['Ccaron'] = 722;
  19233. t['ugrave'] = 556;
  19234. t['radical'] = 549;
  19235. t['Dcaron'] = 722;
  19236. t['rcommaaccent'] = 444;
  19237. t['Ntilde'] = 722;
  19238. t['otilde'] = 500;
  19239. t['Rcommaaccent'] = 722;
  19240. t['Lcommaaccent'] = 667;
  19241. t['Atilde'] = 722;
  19242. t['Aogonek'] = 722;
  19243. t['Aring'] = 722;
  19244. t['Otilde'] = 778;
  19245. t['zdotaccent'] = 444;
  19246. t['Ecaron'] = 667;
  19247. t['Iogonek'] = 389;
  19248. t['kcommaaccent'] = 556;
  19249. t['minus'] = 570;
  19250. t['Icircumflex'] = 389;
  19251. t['ncaron'] = 556;
  19252. t['tcommaaccent'] = 333;
  19253. t['logicalnot'] = 570;
  19254. t['odieresis'] = 500;
  19255. t['udieresis'] = 556;
  19256. t['notequal'] = 549;
  19257. t['gcommaaccent'] = 500;
  19258. t['eth'] = 500;
  19259. t['zcaron'] = 444;
  19260. t['ncommaaccent'] = 556;
  19261. t['onesuperior'] = 300;
  19262. t['imacron'] = 278;
  19263. t['Euro'] = 500;
  19264. });
  19265. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19266. t['space'] = 250;
  19267. t['exclam'] = 389;
  19268. t['quotedbl'] = 555;
  19269. t['numbersign'] = 500;
  19270. t['dollar'] = 500;
  19271. t['percent'] = 833;
  19272. t['ampersand'] = 778;
  19273. t['quoteright'] = 333;
  19274. t['parenleft'] = 333;
  19275. t['parenright'] = 333;
  19276. t['asterisk'] = 500;
  19277. t['plus'] = 570;
  19278. t['comma'] = 250;
  19279. t['hyphen'] = 333;
  19280. t['period'] = 250;
  19281. t['slash'] = 278;
  19282. t['zero'] = 500;
  19283. t['one'] = 500;
  19284. t['two'] = 500;
  19285. t['three'] = 500;
  19286. t['four'] = 500;
  19287. t['five'] = 500;
  19288. t['six'] = 500;
  19289. t['seven'] = 500;
  19290. t['eight'] = 500;
  19291. t['nine'] = 500;
  19292. t['colon'] = 333;
  19293. t['semicolon'] = 333;
  19294. t['less'] = 570;
  19295. t['equal'] = 570;
  19296. t['greater'] = 570;
  19297. t['question'] = 500;
  19298. t['at'] = 832;
  19299. t['A'] = 667;
  19300. t['B'] = 667;
  19301. t['C'] = 667;
  19302. t['D'] = 722;
  19303. t['E'] = 667;
  19304. t['F'] = 667;
  19305. t['G'] = 722;
  19306. t['H'] = 778;
  19307. t['I'] = 389;
  19308. t['J'] = 500;
  19309. t['K'] = 667;
  19310. t['L'] = 611;
  19311. t['M'] = 889;
  19312. t['N'] = 722;
  19313. t['O'] = 722;
  19314. t['P'] = 611;
  19315. t['Q'] = 722;
  19316. t['R'] = 667;
  19317. t['S'] = 556;
  19318. t['T'] = 611;
  19319. t['U'] = 722;
  19320. t['V'] = 667;
  19321. t['W'] = 889;
  19322. t['X'] = 667;
  19323. t['Y'] = 611;
  19324. t['Z'] = 611;
  19325. t['bracketleft'] = 333;
  19326. t['backslash'] = 278;
  19327. t['bracketright'] = 333;
  19328. t['asciicircum'] = 570;
  19329. t['underscore'] = 500;
  19330. t['quoteleft'] = 333;
  19331. t['a'] = 500;
  19332. t['b'] = 500;
  19333. t['c'] = 444;
  19334. t['d'] = 500;
  19335. t['e'] = 444;
  19336. t['f'] = 333;
  19337. t['g'] = 500;
  19338. t['h'] = 556;
  19339. t['i'] = 278;
  19340. t['j'] = 278;
  19341. t['k'] = 500;
  19342. t['l'] = 278;
  19343. t['m'] = 778;
  19344. t['n'] = 556;
  19345. t['o'] = 500;
  19346. t['p'] = 500;
  19347. t['q'] = 500;
  19348. t['r'] = 389;
  19349. t['s'] = 389;
  19350. t['t'] = 278;
  19351. t['u'] = 556;
  19352. t['v'] = 444;
  19353. t['w'] = 667;
  19354. t['x'] = 500;
  19355. t['y'] = 444;
  19356. t['z'] = 389;
  19357. t['braceleft'] = 348;
  19358. t['bar'] = 220;
  19359. t['braceright'] = 348;
  19360. t['asciitilde'] = 570;
  19361. t['exclamdown'] = 389;
  19362. t['cent'] = 500;
  19363. t['sterling'] = 500;
  19364. t['fraction'] = 167;
  19365. t['yen'] = 500;
  19366. t['florin'] = 500;
  19367. t['section'] = 500;
  19368. t['currency'] = 500;
  19369. t['quotesingle'] = 278;
  19370. t['quotedblleft'] = 500;
  19371. t['guillemotleft'] = 500;
  19372. t['guilsinglleft'] = 333;
  19373. t['guilsinglright'] = 333;
  19374. t['fi'] = 556;
  19375. t['fl'] = 556;
  19376. t['endash'] = 500;
  19377. t['dagger'] = 500;
  19378. t['daggerdbl'] = 500;
  19379. t['periodcentered'] = 250;
  19380. t['paragraph'] = 500;
  19381. t['bullet'] = 350;
  19382. t['quotesinglbase'] = 333;
  19383. t['quotedblbase'] = 500;
  19384. t['quotedblright'] = 500;
  19385. t['guillemotright'] = 500;
  19386. t['ellipsis'] = 1000;
  19387. t['perthousand'] = 1000;
  19388. t['questiondown'] = 500;
  19389. t['grave'] = 333;
  19390. t['acute'] = 333;
  19391. t['circumflex'] = 333;
  19392. t['tilde'] = 333;
  19393. t['macron'] = 333;
  19394. t['breve'] = 333;
  19395. t['dotaccent'] = 333;
  19396. t['dieresis'] = 333;
  19397. t['ring'] = 333;
  19398. t['cedilla'] = 333;
  19399. t['hungarumlaut'] = 333;
  19400. t['ogonek'] = 333;
  19401. t['caron'] = 333;
  19402. t['emdash'] = 1000;
  19403. t['AE'] = 944;
  19404. t['ordfeminine'] = 266;
  19405. t['Lslash'] = 611;
  19406. t['Oslash'] = 722;
  19407. t['OE'] = 944;
  19408. t['ordmasculine'] = 300;
  19409. t['ae'] = 722;
  19410. t['dotlessi'] = 278;
  19411. t['lslash'] = 278;
  19412. t['oslash'] = 500;
  19413. t['oe'] = 722;
  19414. t['germandbls'] = 500;
  19415. t['Idieresis'] = 389;
  19416. t['eacute'] = 444;
  19417. t['abreve'] = 500;
  19418. t['uhungarumlaut'] = 556;
  19419. t['ecaron'] = 444;
  19420. t['Ydieresis'] = 611;
  19421. t['divide'] = 570;
  19422. t['Yacute'] = 611;
  19423. t['Acircumflex'] = 667;
  19424. t['aacute'] = 500;
  19425. t['Ucircumflex'] = 722;
  19426. t['yacute'] = 444;
  19427. t['scommaaccent'] = 389;
  19428. t['ecircumflex'] = 444;
  19429. t['Uring'] = 722;
  19430. t['Udieresis'] = 722;
  19431. t['aogonek'] = 500;
  19432. t['Uacute'] = 722;
  19433. t['uogonek'] = 556;
  19434. t['Edieresis'] = 667;
  19435. t['Dcroat'] = 722;
  19436. t['commaaccent'] = 250;
  19437. t['copyright'] = 747;
  19438. t['Emacron'] = 667;
  19439. t['ccaron'] = 444;
  19440. t['aring'] = 500;
  19441. t['Ncommaaccent'] = 722;
  19442. t['lacute'] = 278;
  19443. t['agrave'] = 500;
  19444. t['Tcommaaccent'] = 611;
  19445. t['Cacute'] = 667;
  19446. t['atilde'] = 500;
  19447. t['Edotaccent'] = 667;
  19448. t['scaron'] = 389;
  19449. t['scedilla'] = 389;
  19450. t['iacute'] = 278;
  19451. t['lozenge'] = 494;
  19452. t['Rcaron'] = 667;
  19453. t['Gcommaaccent'] = 722;
  19454. t['ucircumflex'] = 556;
  19455. t['acircumflex'] = 500;
  19456. t['Amacron'] = 667;
  19457. t['rcaron'] = 389;
  19458. t['ccedilla'] = 444;
  19459. t['Zdotaccent'] = 611;
  19460. t['Thorn'] = 611;
  19461. t['Omacron'] = 722;
  19462. t['Racute'] = 667;
  19463. t['Sacute'] = 556;
  19464. t['dcaron'] = 608;
  19465. t['Umacron'] = 722;
  19466. t['uring'] = 556;
  19467. t['threesuperior'] = 300;
  19468. t['Ograve'] = 722;
  19469. t['Agrave'] = 667;
  19470. t['Abreve'] = 667;
  19471. t['multiply'] = 570;
  19472. t['uacute'] = 556;
  19473. t['Tcaron'] = 611;
  19474. t['partialdiff'] = 494;
  19475. t['ydieresis'] = 444;
  19476. t['Nacute'] = 722;
  19477. t['icircumflex'] = 278;
  19478. t['Ecircumflex'] = 667;
  19479. t['adieresis'] = 500;
  19480. t['edieresis'] = 444;
  19481. t['cacute'] = 444;
  19482. t['nacute'] = 556;
  19483. t['umacron'] = 556;
  19484. t['Ncaron'] = 722;
  19485. t['Iacute'] = 389;
  19486. t['plusminus'] = 570;
  19487. t['brokenbar'] = 220;
  19488. t['registered'] = 747;
  19489. t['Gbreve'] = 722;
  19490. t['Idotaccent'] = 389;
  19491. t['summation'] = 600;
  19492. t['Egrave'] = 667;
  19493. t['racute'] = 389;
  19494. t['omacron'] = 500;
  19495. t['Zacute'] = 611;
  19496. t['Zcaron'] = 611;
  19497. t['greaterequal'] = 549;
  19498. t['Eth'] = 722;
  19499. t['Ccedilla'] = 667;
  19500. t['lcommaaccent'] = 278;
  19501. t['tcaron'] = 366;
  19502. t['eogonek'] = 444;
  19503. t['Uogonek'] = 722;
  19504. t['Aacute'] = 667;
  19505. t['Adieresis'] = 667;
  19506. t['egrave'] = 444;
  19507. t['zacute'] = 389;
  19508. t['iogonek'] = 278;
  19509. t['Oacute'] = 722;
  19510. t['oacute'] = 500;
  19511. t['amacron'] = 500;
  19512. t['sacute'] = 389;
  19513. t['idieresis'] = 278;
  19514. t['Ocircumflex'] = 722;
  19515. t['Ugrave'] = 722;
  19516. t['Delta'] = 612;
  19517. t['thorn'] = 500;
  19518. t['twosuperior'] = 300;
  19519. t['Odieresis'] = 722;
  19520. t['mu'] = 576;
  19521. t['igrave'] = 278;
  19522. t['ohungarumlaut'] = 500;
  19523. t['Eogonek'] = 667;
  19524. t['dcroat'] = 500;
  19525. t['threequarters'] = 750;
  19526. t['Scedilla'] = 556;
  19527. t['lcaron'] = 382;
  19528. t['Kcommaaccent'] = 667;
  19529. t['Lacute'] = 611;
  19530. t['trademark'] = 1000;
  19531. t['edotaccent'] = 444;
  19532. t['Igrave'] = 389;
  19533. t['Imacron'] = 389;
  19534. t['Lcaron'] = 611;
  19535. t['onehalf'] = 750;
  19536. t['lessequal'] = 549;
  19537. t['ocircumflex'] = 500;
  19538. t['ntilde'] = 556;
  19539. t['Uhungarumlaut'] = 722;
  19540. t['Eacute'] = 667;
  19541. t['emacron'] = 444;
  19542. t['gbreve'] = 500;
  19543. t['onequarter'] = 750;
  19544. t['Scaron'] = 556;
  19545. t['Scommaaccent'] = 556;
  19546. t['Ohungarumlaut'] = 722;
  19547. t['degree'] = 400;
  19548. t['ograve'] = 500;
  19549. t['Ccaron'] = 667;
  19550. t['ugrave'] = 556;
  19551. t['radical'] = 549;
  19552. t['Dcaron'] = 722;
  19553. t['rcommaaccent'] = 389;
  19554. t['Ntilde'] = 722;
  19555. t['otilde'] = 500;
  19556. t['Rcommaaccent'] = 667;
  19557. t['Lcommaaccent'] = 611;
  19558. t['Atilde'] = 667;
  19559. t['Aogonek'] = 667;
  19560. t['Aring'] = 667;
  19561. t['Otilde'] = 722;
  19562. t['zdotaccent'] = 389;
  19563. t['Ecaron'] = 667;
  19564. t['Iogonek'] = 389;
  19565. t['kcommaaccent'] = 500;
  19566. t['minus'] = 606;
  19567. t['Icircumflex'] = 389;
  19568. t['ncaron'] = 556;
  19569. t['tcommaaccent'] = 278;
  19570. t['logicalnot'] = 606;
  19571. t['odieresis'] = 500;
  19572. t['udieresis'] = 556;
  19573. t['notequal'] = 549;
  19574. t['gcommaaccent'] = 500;
  19575. t['eth'] = 500;
  19576. t['zcaron'] = 389;
  19577. t['ncommaaccent'] = 556;
  19578. t['onesuperior'] = 300;
  19579. t['imacron'] = 278;
  19580. t['Euro'] = 500;
  19581. });
  19582. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19583. t['space'] = 250;
  19584. t['exclam'] = 333;
  19585. t['quotedbl'] = 420;
  19586. t['numbersign'] = 500;
  19587. t['dollar'] = 500;
  19588. t['percent'] = 833;
  19589. t['ampersand'] = 778;
  19590. t['quoteright'] = 333;
  19591. t['parenleft'] = 333;
  19592. t['parenright'] = 333;
  19593. t['asterisk'] = 500;
  19594. t['plus'] = 675;
  19595. t['comma'] = 250;
  19596. t['hyphen'] = 333;
  19597. t['period'] = 250;
  19598. t['slash'] = 278;
  19599. t['zero'] = 500;
  19600. t['one'] = 500;
  19601. t['two'] = 500;
  19602. t['three'] = 500;
  19603. t['four'] = 500;
  19604. t['five'] = 500;
  19605. t['six'] = 500;
  19606. t['seven'] = 500;
  19607. t['eight'] = 500;
  19608. t['nine'] = 500;
  19609. t['colon'] = 333;
  19610. t['semicolon'] = 333;
  19611. t['less'] = 675;
  19612. t['equal'] = 675;
  19613. t['greater'] = 675;
  19614. t['question'] = 500;
  19615. t['at'] = 920;
  19616. t['A'] = 611;
  19617. t['B'] = 611;
  19618. t['C'] = 667;
  19619. t['D'] = 722;
  19620. t['E'] = 611;
  19621. t['F'] = 611;
  19622. t['G'] = 722;
  19623. t['H'] = 722;
  19624. t['I'] = 333;
  19625. t['J'] = 444;
  19626. t['K'] = 667;
  19627. t['L'] = 556;
  19628. t['M'] = 833;
  19629. t['N'] = 667;
  19630. t['O'] = 722;
  19631. t['P'] = 611;
  19632. t['Q'] = 722;
  19633. t['R'] = 611;
  19634. t['S'] = 500;
  19635. t['T'] = 556;
  19636. t['U'] = 722;
  19637. t['V'] = 611;
  19638. t['W'] = 833;
  19639. t['X'] = 611;
  19640. t['Y'] = 556;
  19641. t['Z'] = 556;
  19642. t['bracketleft'] = 389;
  19643. t['backslash'] = 278;
  19644. t['bracketright'] = 389;
  19645. t['asciicircum'] = 422;
  19646. t['underscore'] = 500;
  19647. t['quoteleft'] = 333;
  19648. t['a'] = 500;
  19649. t['b'] = 500;
  19650. t['c'] = 444;
  19651. t['d'] = 500;
  19652. t['e'] = 444;
  19653. t['f'] = 278;
  19654. t['g'] = 500;
  19655. t['h'] = 500;
  19656. t['i'] = 278;
  19657. t['j'] = 278;
  19658. t['k'] = 444;
  19659. t['l'] = 278;
  19660. t['m'] = 722;
  19661. t['n'] = 500;
  19662. t['o'] = 500;
  19663. t['p'] = 500;
  19664. t['q'] = 500;
  19665. t['r'] = 389;
  19666. t['s'] = 389;
  19667. t['t'] = 278;
  19668. t['u'] = 500;
  19669. t['v'] = 444;
  19670. t['w'] = 667;
  19671. t['x'] = 444;
  19672. t['y'] = 444;
  19673. t['z'] = 389;
  19674. t['braceleft'] = 400;
  19675. t['bar'] = 275;
  19676. t['braceright'] = 400;
  19677. t['asciitilde'] = 541;
  19678. t['exclamdown'] = 389;
  19679. t['cent'] = 500;
  19680. t['sterling'] = 500;
  19681. t['fraction'] = 167;
  19682. t['yen'] = 500;
  19683. t['florin'] = 500;
  19684. t['section'] = 500;
  19685. t['currency'] = 500;
  19686. t['quotesingle'] = 214;
  19687. t['quotedblleft'] = 556;
  19688. t['guillemotleft'] = 500;
  19689. t['guilsinglleft'] = 333;
  19690. t['guilsinglright'] = 333;
  19691. t['fi'] = 500;
  19692. t['fl'] = 500;
  19693. t['endash'] = 500;
  19694. t['dagger'] = 500;
  19695. t['daggerdbl'] = 500;
  19696. t['periodcentered'] = 250;
  19697. t['paragraph'] = 523;
  19698. t['bullet'] = 350;
  19699. t['quotesinglbase'] = 333;
  19700. t['quotedblbase'] = 556;
  19701. t['quotedblright'] = 556;
  19702. t['guillemotright'] = 500;
  19703. t['ellipsis'] = 889;
  19704. t['perthousand'] = 1000;
  19705. t['questiondown'] = 500;
  19706. t['grave'] = 333;
  19707. t['acute'] = 333;
  19708. t['circumflex'] = 333;
  19709. t['tilde'] = 333;
  19710. t['macron'] = 333;
  19711. t['breve'] = 333;
  19712. t['dotaccent'] = 333;
  19713. t['dieresis'] = 333;
  19714. t['ring'] = 333;
  19715. t['cedilla'] = 333;
  19716. t['hungarumlaut'] = 333;
  19717. t['ogonek'] = 333;
  19718. t['caron'] = 333;
  19719. t['emdash'] = 889;
  19720. t['AE'] = 889;
  19721. t['ordfeminine'] = 276;
  19722. t['Lslash'] = 556;
  19723. t['Oslash'] = 722;
  19724. t['OE'] = 944;
  19725. t['ordmasculine'] = 310;
  19726. t['ae'] = 667;
  19727. t['dotlessi'] = 278;
  19728. t['lslash'] = 278;
  19729. t['oslash'] = 500;
  19730. t['oe'] = 667;
  19731. t['germandbls'] = 500;
  19732. t['Idieresis'] = 333;
  19733. t['eacute'] = 444;
  19734. t['abreve'] = 500;
  19735. t['uhungarumlaut'] = 500;
  19736. t['ecaron'] = 444;
  19737. t['Ydieresis'] = 556;
  19738. t['divide'] = 675;
  19739. t['Yacute'] = 556;
  19740. t['Acircumflex'] = 611;
  19741. t['aacute'] = 500;
  19742. t['Ucircumflex'] = 722;
  19743. t['yacute'] = 444;
  19744. t['scommaaccent'] = 389;
  19745. t['ecircumflex'] = 444;
  19746. t['Uring'] = 722;
  19747. t['Udieresis'] = 722;
  19748. t['aogonek'] = 500;
  19749. t['Uacute'] = 722;
  19750. t['uogonek'] = 500;
  19751. t['Edieresis'] = 611;
  19752. t['Dcroat'] = 722;
  19753. t['commaaccent'] = 250;
  19754. t['copyright'] = 760;
  19755. t['Emacron'] = 611;
  19756. t['ccaron'] = 444;
  19757. t['aring'] = 500;
  19758. t['Ncommaaccent'] = 667;
  19759. t['lacute'] = 278;
  19760. t['agrave'] = 500;
  19761. t['Tcommaaccent'] = 556;
  19762. t['Cacute'] = 667;
  19763. t['atilde'] = 500;
  19764. t['Edotaccent'] = 611;
  19765. t['scaron'] = 389;
  19766. t['scedilla'] = 389;
  19767. t['iacute'] = 278;
  19768. t['lozenge'] = 471;
  19769. t['Rcaron'] = 611;
  19770. t['Gcommaaccent'] = 722;
  19771. t['ucircumflex'] = 500;
  19772. t['acircumflex'] = 500;
  19773. t['Amacron'] = 611;
  19774. t['rcaron'] = 389;
  19775. t['ccedilla'] = 444;
  19776. t['Zdotaccent'] = 556;
  19777. t['Thorn'] = 611;
  19778. t['Omacron'] = 722;
  19779. t['Racute'] = 611;
  19780. t['Sacute'] = 500;
  19781. t['dcaron'] = 544;
  19782. t['Umacron'] = 722;
  19783. t['uring'] = 500;
  19784. t['threesuperior'] = 300;
  19785. t['Ograve'] = 722;
  19786. t['Agrave'] = 611;
  19787. t['Abreve'] = 611;
  19788. t['multiply'] = 675;
  19789. t['uacute'] = 500;
  19790. t['Tcaron'] = 556;
  19791. t['partialdiff'] = 476;
  19792. t['ydieresis'] = 444;
  19793. t['Nacute'] = 667;
  19794. t['icircumflex'] = 278;
  19795. t['Ecircumflex'] = 611;
  19796. t['adieresis'] = 500;
  19797. t['edieresis'] = 444;
  19798. t['cacute'] = 444;
  19799. t['nacute'] = 500;
  19800. t['umacron'] = 500;
  19801. t['Ncaron'] = 667;
  19802. t['Iacute'] = 333;
  19803. t['plusminus'] = 675;
  19804. t['brokenbar'] = 275;
  19805. t['registered'] = 760;
  19806. t['Gbreve'] = 722;
  19807. t['Idotaccent'] = 333;
  19808. t['summation'] = 600;
  19809. t['Egrave'] = 611;
  19810. t['racute'] = 389;
  19811. t['omacron'] = 500;
  19812. t['Zacute'] = 556;
  19813. t['Zcaron'] = 556;
  19814. t['greaterequal'] = 549;
  19815. t['Eth'] = 722;
  19816. t['Ccedilla'] = 667;
  19817. t['lcommaaccent'] = 278;
  19818. t['tcaron'] = 300;
  19819. t['eogonek'] = 444;
  19820. t['Uogonek'] = 722;
  19821. t['Aacute'] = 611;
  19822. t['Adieresis'] = 611;
  19823. t['egrave'] = 444;
  19824. t['zacute'] = 389;
  19825. t['iogonek'] = 278;
  19826. t['Oacute'] = 722;
  19827. t['oacute'] = 500;
  19828. t['amacron'] = 500;
  19829. t['sacute'] = 389;
  19830. t['idieresis'] = 278;
  19831. t['Ocircumflex'] = 722;
  19832. t['Ugrave'] = 722;
  19833. t['Delta'] = 612;
  19834. t['thorn'] = 500;
  19835. t['twosuperior'] = 300;
  19836. t['Odieresis'] = 722;
  19837. t['mu'] = 500;
  19838. t['igrave'] = 278;
  19839. t['ohungarumlaut'] = 500;
  19840. t['Eogonek'] = 611;
  19841. t['dcroat'] = 500;
  19842. t['threequarters'] = 750;
  19843. t['Scedilla'] = 500;
  19844. t['lcaron'] = 300;
  19845. t['Kcommaaccent'] = 667;
  19846. t['Lacute'] = 556;
  19847. t['trademark'] = 980;
  19848. t['edotaccent'] = 444;
  19849. t['Igrave'] = 333;
  19850. t['Imacron'] = 333;
  19851. t['Lcaron'] = 611;
  19852. t['onehalf'] = 750;
  19853. t['lessequal'] = 549;
  19854. t['ocircumflex'] = 500;
  19855. t['ntilde'] = 500;
  19856. t['Uhungarumlaut'] = 722;
  19857. t['Eacute'] = 611;
  19858. t['emacron'] = 444;
  19859. t['gbreve'] = 500;
  19860. t['onequarter'] = 750;
  19861. t['Scaron'] = 500;
  19862. t['Scommaaccent'] = 500;
  19863. t['Ohungarumlaut'] = 722;
  19864. t['degree'] = 400;
  19865. t['ograve'] = 500;
  19866. t['Ccaron'] = 667;
  19867. t['ugrave'] = 500;
  19868. t['radical'] = 453;
  19869. t['Dcaron'] = 722;
  19870. t['rcommaaccent'] = 389;
  19871. t['Ntilde'] = 667;
  19872. t['otilde'] = 500;
  19873. t['Rcommaaccent'] = 611;
  19874. t['Lcommaaccent'] = 556;
  19875. t['Atilde'] = 611;
  19876. t['Aogonek'] = 611;
  19877. t['Aring'] = 611;
  19878. t['Otilde'] = 722;
  19879. t['zdotaccent'] = 389;
  19880. t['Ecaron'] = 611;
  19881. t['Iogonek'] = 333;
  19882. t['kcommaaccent'] = 444;
  19883. t['minus'] = 675;
  19884. t['Icircumflex'] = 333;
  19885. t['ncaron'] = 500;
  19886. t['tcommaaccent'] = 278;
  19887. t['logicalnot'] = 675;
  19888. t['odieresis'] = 500;
  19889. t['udieresis'] = 500;
  19890. t['notequal'] = 549;
  19891. t['gcommaaccent'] = 500;
  19892. t['eth'] = 500;
  19893. t['zcaron'] = 389;
  19894. t['ncommaaccent'] = 500;
  19895. t['onesuperior'] = 300;
  19896. t['imacron'] = 278;
  19897. t['Euro'] = 500;
  19898. });
  19899. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  19900. t['space'] = 278;
  19901. t['a1'] = 974;
  19902. t['a2'] = 961;
  19903. t['a202'] = 974;
  19904. t['a3'] = 980;
  19905. t['a4'] = 719;
  19906. t['a5'] = 789;
  19907. t['a119'] = 790;
  19908. t['a118'] = 791;
  19909. t['a117'] = 690;
  19910. t['a11'] = 960;
  19911. t['a12'] = 939;
  19912. t['a13'] = 549;
  19913. t['a14'] = 855;
  19914. t['a15'] = 911;
  19915. t['a16'] = 933;
  19916. t['a105'] = 911;
  19917. t['a17'] = 945;
  19918. t['a18'] = 974;
  19919. t['a19'] = 755;
  19920. t['a20'] = 846;
  19921. t['a21'] = 762;
  19922. t['a22'] = 761;
  19923. t['a23'] = 571;
  19924. t['a24'] = 677;
  19925. t['a25'] = 763;
  19926. t['a26'] = 760;
  19927. t['a27'] = 759;
  19928. t['a28'] = 754;
  19929. t['a6'] = 494;
  19930. t['a7'] = 552;
  19931. t['a8'] = 537;
  19932. t['a9'] = 577;
  19933. t['a10'] = 692;
  19934. t['a29'] = 786;
  19935. t['a30'] = 788;
  19936. t['a31'] = 788;
  19937. t['a32'] = 790;
  19938. t['a33'] = 793;
  19939. t['a34'] = 794;
  19940. t['a35'] = 816;
  19941. t['a36'] = 823;
  19942. t['a37'] = 789;
  19943. t['a38'] = 841;
  19944. t['a39'] = 823;
  19945. t['a40'] = 833;
  19946. t['a41'] = 816;
  19947. t['a42'] = 831;
  19948. t['a43'] = 923;
  19949. t['a44'] = 744;
  19950. t['a45'] = 723;
  19951. t['a46'] = 749;
  19952. t['a47'] = 790;
  19953. t['a48'] = 792;
  19954. t['a49'] = 695;
  19955. t['a50'] = 776;
  19956. t['a51'] = 768;
  19957. t['a52'] = 792;
  19958. t['a53'] = 759;
  19959. t['a54'] = 707;
  19960. t['a55'] = 708;
  19961. t['a56'] = 682;
  19962. t['a57'] = 701;
  19963. t['a58'] = 826;
  19964. t['a59'] = 815;
  19965. t['a60'] = 789;
  19966. t['a61'] = 789;
  19967. t['a62'] = 707;
  19968. t['a63'] = 687;
  19969. t['a64'] = 696;
  19970. t['a65'] = 689;
  19971. t['a66'] = 786;
  19972. t['a67'] = 787;
  19973. t['a68'] = 713;
  19974. t['a69'] = 791;
  19975. t['a70'] = 785;
  19976. t['a71'] = 791;
  19977. t['a72'] = 873;
  19978. t['a73'] = 761;
  19979. t['a74'] = 762;
  19980. t['a203'] = 762;
  19981. t['a75'] = 759;
  19982. t['a204'] = 759;
  19983. t['a76'] = 892;
  19984. t['a77'] = 892;
  19985. t['a78'] = 788;
  19986. t['a79'] = 784;
  19987. t['a81'] = 438;
  19988. t['a82'] = 138;
  19989. t['a83'] = 277;
  19990. t['a84'] = 415;
  19991. t['a97'] = 392;
  19992. t['a98'] = 392;
  19993. t['a99'] = 668;
  19994. t['a100'] = 668;
  19995. t['a89'] = 390;
  19996. t['a90'] = 390;
  19997. t['a93'] = 317;
  19998. t['a94'] = 317;
  19999. t['a91'] = 276;
  20000. t['a92'] = 276;
  20001. t['a205'] = 509;
  20002. t['a85'] = 509;
  20003. t['a206'] = 410;
  20004. t['a86'] = 410;
  20005. t['a87'] = 234;
  20006. t['a88'] = 234;
  20007. t['a95'] = 334;
  20008. t['a96'] = 334;
  20009. t['a101'] = 732;
  20010. t['a102'] = 544;
  20011. t['a103'] = 544;
  20012. t['a104'] = 910;
  20013. t['a106'] = 667;
  20014. t['a107'] = 760;
  20015. t['a108'] = 760;
  20016. t['a112'] = 776;
  20017. t['a111'] = 595;
  20018. t['a110'] = 694;
  20019. t['a109'] = 626;
  20020. t['a120'] = 788;
  20021. t['a121'] = 788;
  20022. t['a122'] = 788;
  20023. t['a123'] = 788;
  20024. t['a124'] = 788;
  20025. t['a125'] = 788;
  20026. t['a126'] = 788;
  20027. t['a127'] = 788;
  20028. t['a128'] = 788;
  20029. t['a129'] = 788;
  20030. t['a130'] = 788;
  20031. t['a131'] = 788;
  20032. t['a132'] = 788;
  20033. t['a133'] = 788;
  20034. t['a134'] = 788;
  20035. t['a135'] = 788;
  20036. t['a136'] = 788;
  20037. t['a137'] = 788;
  20038. t['a138'] = 788;
  20039. t['a139'] = 788;
  20040. t['a140'] = 788;
  20041. t['a141'] = 788;
  20042. t['a142'] = 788;
  20043. t['a143'] = 788;
  20044. t['a144'] = 788;
  20045. t['a145'] = 788;
  20046. t['a146'] = 788;
  20047. t['a147'] = 788;
  20048. t['a148'] = 788;
  20049. t['a149'] = 788;
  20050. t['a150'] = 788;
  20051. t['a151'] = 788;
  20052. t['a152'] = 788;
  20053. t['a153'] = 788;
  20054. t['a154'] = 788;
  20055. t['a155'] = 788;
  20056. t['a156'] = 788;
  20057. t['a157'] = 788;
  20058. t['a158'] = 788;
  20059. t['a159'] = 788;
  20060. t['a160'] = 894;
  20061. t['a161'] = 838;
  20062. t['a163'] = 1016;
  20063. t['a164'] = 458;
  20064. t['a196'] = 748;
  20065. t['a165'] = 924;
  20066. t['a192'] = 748;
  20067. t['a166'] = 918;
  20068. t['a167'] = 927;
  20069. t['a168'] = 928;
  20070. t['a169'] = 928;
  20071. t['a170'] = 834;
  20072. t['a171'] = 873;
  20073. t['a172'] = 828;
  20074. t['a173'] = 924;
  20075. t['a162'] = 924;
  20076. t['a174'] = 917;
  20077. t['a175'] = 930;
  20078. t['a176'] = 931;
  20079. t['a177'] = 463;
  20080. t['a178'] = 883;
  20081. t['a179'] = 836;
  20082. t['a193'] = 836;
  20083. t['a180'] = 867;
  20084. t['a199'] = 867;
  20085. t['a181'] = 696;
  20086. t['a200'] = 696;
  20087. t['a182'] = 874;
  20088. t['a201'] = 874;
  20089. t['a183'] = 760;
  20090. t['a184'] = 946;
  20091. t['a197'] = 771;
  20092. t['a185'] = 865;
  20093. t['a194'] = 771;
  20094. t['a198'] = 888;
  20095. t['a186'] = 967;
  20096. t['a195'] = 888;
  20097. t['a187'] = 831;
  20098. t['a188'] = 873;
  20099. t['a189'] = 927;
  20100. t['a190'] = 970;
  20101. t['a191'] = 918;
  20102. });
  20103. });
  20104. exports.getMetrics = getMetrics;
  20105. }));
  20106. (function (root, factory) {
  20107. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20108. }(this, function (exports, sharedUtil) {
  20109. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20110. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20111. var MASK_HIGH = 0xffff0000;
  20112. var MASK_LOW = 0xffff;
  20113. function MurmurHash3_64(seed) {
  20114. var SEED = 0xc3d2e1f0;
  20115. this.h1 = seed ? seed & 0xffffffff : SEED;
  20116. this.h2 = seed ? seed & 0xffffffff : SEED;
  20117. }
  20118. var alwaysUseUint32ArrayView = false;
  20119. try {
  20120. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20121. } catch (e) {
  20122. alwaysUseUint32ArrayView = true;
  20123. }
  20124. MurmurHash3_64.prototype = {
  20125. update: function MurmurHash3_64_update(input) {
  20126. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20127. var i;
  20128. if (typeof input === 'string') {
  20129. var data = new Uint8Array(input.length * 2);
  20130. var length = 0;
  20131. for (i = 0; i < input.length; i++) {
  20132. var code = input.charCodeAt(i);
  20133. if (code <= 0xff) {
  20134. data[length++] = code;
  20135. } else {
  20136. data[length++] = code >>> 8;
  20137. data[length++] = code & 0xff;
  20138. }
  20139. }
  20140. } else if (input instanceof Uint8Array) {
  20141. data = input;
  20142. length = data.length;
  20143. } else if (typeof input === 'object' && 'length' in input) {
  20144. data = input;
  20145. length = data.length;
  20146. useUint32ArrayView = true;
  20147. } else {
  20148. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20149. }
  20150. var blockCounts = length >> 2;
  20151. var tailLength = length - blockCounts * 4;
  20152. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20153. var k1 = 0;
  20154. var k2 = 0;
  20155. var h1 = this.h1;
  20156. var h2 = this.h2;
  20157. var C1 = 0xcc9e2d51;
  20158. var C2 = 0x1b873593;
  20159. var C1_LOW = C1 & MASK_LOW;
  20160. var C2_LOW = C2 & MASK_LOW;
  20161. for (i = 0; i < blockCounts; i++) {
  20162. if (i & 1) {
  20163. k1 = dataUint32[i];
  20164. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20165. k1 = k1 << 15 | k1 >>> 17;
  20166. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20167. h1 ^= k1;
  20168. h1 = h1 << 13 | h1 >>> 19;
  20169. h1 = h1 * 5 + 0xe6546b64;
  20170. } else {
  20171. k2 = dataUint32[i];
  20172. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20173. k2 = k2 << 15 | k2 >>> 17;
  20174. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20175. h2 ^= k2;
  20176. h2 = h2 << 13 | h2 >>> 19;
  20177. h2 = h2 * 5 + 0xe6546b64;
  20178. }
  20179. }
  20180. k1 = 0;
  20181. switch (tailLength) {
  20182. case 3:
  20183. k1 ^= data[blockCounts * 4 + 2] << 16;
  20184. case 2:
  20185. k1 ^= data[blockCounts * 4 + 1] << 8;
  20186. case 1:
  20187. k1 ^= data[blockCounts * 4];
  20188. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20189. k1 = k1 << 15 | k1 >>> 17;
  20190. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20191. if (blockCounts & 1) {
  20192. h1 ^= k1;
  20193. } else {
  20194. h2 ^= k1;
  20195. }
  20196. }
  20197. this.h1 = h1;
  20198. this.h2 = h2;
  20199. return this;
  20200. },
  20201. hexdigest: function MurmurHash3_64_hexdigest() {
  20202. var h1 = this.h1;
  20203. var h2 = this.h2;
  20204. h1 ^= h2 >>> 1;
  20205. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20206. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20207. h1 ^= h2 >>> 1;
  20208. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20209. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20210. h1 ^= h2 >>> 1;
  20211. for (var i = 0, arr = [
  20212. h1,
  20213. h2
  20214. ], str = ''; i < arr.length; i++) {
  20215. var hex = (arr[i] >>> 0).toString(16);
  20216. while (hex.length < 8) {
  20217. hex = '0' + hex;
  20218. }
  20219. str += hex;
  20220. }
  20221. return str;
  20222. }
  20223. };
  20224. return MurmurHash3_64;
  20225. }();
  20226. exports.MurmurHash3_64 = MurmurHash3_64;
  20227. }));
  20228. (function (root, factory) {
  20229. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20230. }(this, function (exports, sharedUtil) {
  20231. var isArray = sharedUtil.isArray;
  20232. var Name = function NameClosure() {
  20233. function Name(name) {
  20234. this.name = name;
  20235. }
  20236. Name.prototype = {};
  20237. var nameCache = Object.create(null);
  20238. Name.get = function Name_get(name) {
  20239. var nameValue = nameCache[name];
  20240. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20241. };
  20242. return Name;
  20243. }();
  20244. var Cmd = function CmdClosure() {
  20245. function Cmd(cmd) {
  20246. this.cmd = cmd;
  20247. }
  20248. Cmd.prototype = {};
  20249. var cmdCache = Object.create(null);
  20250. Cmd.get = function Cmd_get(cmd) {
  20251. var cmdValue = cmdCache[cmd];
  20252. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20253. };
  20254. return Cmd;
  20255. }();
  20256. var Dict = function DictClosure() {
  20257. var nonSerializable = function nonSerializableClosure() {
  20258. return nonSerializable;
  20259. };
  20260. function Dict(xref) {
  20261. this.map = Object.create(null);
  20262. this.xref = xref;
  20263. this.objId = null;
  20264. this.suppressEncryption = false;
  20265. this.__nonSerializable__ = nonSerializable;
  20266. }
  20267. Dict.prototype = {
  20268. assignXref: function Dict_assignXref(newXref) {
  20269. this.xref = newXref;
  20270. },
  20271. get: function Dict_get(key1, key2, key3) {
  20272. var value;
  20273. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20274. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20275. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20276. }
  20277. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20278. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20279. }
  20280. value = this.map[key3] || null;
  20281. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20282. },
  20283. getAsync: function Dict_getAsync(key1, key2, key3) {
  20284. var value;
  20285. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20286. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20287. if (xref) {
  20288. return xref.fetchIfRefAsync(value, suppressEncryption);
  20289. }
  20290. return Promise.resolve(value);
  20291. }
  20292. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20293. if (xref) {
  20294. return xref.fetchIfRefAsync(value, suppressEncryption);
  20295. }
  20296. return Promise.resolve(value);
  20297. }
  20298. value = this.map[key3] || null;
  20299. if (xref) {
  20300. return xref.fetchIfRefAsync(value, suppressEncryption);
  20301. }
  20302. return Promise.resolve(value);
  20303. },
  20304. getArray: function Dict_getArray(key1, key2, key3) {
  20305. var value = this.get(key1, key2, key3);
  20306. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20307. if (!isArray(value) || !xref) {
  20308. return value;
  20309. }
  20310. value = value.slice();
  20311. for (var i = 0, ii = value.length; i < ii; i++) {
  20312. if (!isRef(value[i])) {
  20313. continue;
  20314. }
  20315. value[i] = xref.fetch(value[i], suppressEncryption);
  20316. }
  20317. return value;
  20318. },
  20319. getRaw: function Dict_getRaw(key) {
  20320. return this.map[key];
  20321. },
  20322. getKeys: function Dict_getKeys() {
  20323. return Object.keys(this.map);
  20324. },
  20325. set: function Dict_set(key, value) {
  20326. this.map[key] = value;
  20327. },
  20328. has: function Dict_has(key) {
  20329. return key in this.map;
  20330. },
  20331. forEach: function Dict_forEach(callback) {
  20332. for (var key in this.map) {
  20333. callback(key, this.get(key));
  20334. }
  20335. }
  20336. };
  20337. Dict.empty = new Dict(null);
  20338. Dict.merge = function Dict_merge(xref, dictArray) {
  20339. var mergedDict = new Dict(xref);
  20340. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20341. var dict = dictArray[i];
  20342. if (!isDict(dict)) {
  20343. continue;
  20344. }
  20345. for (var keyName in dict.map) {
  20346. if (mergedDict.map[keyName]) {
  20347. continue;
  20348. }
  20349. mergedDict.map[keyName] = dict.map[keyName];
  20350. }
  20351. }
  20352. return mergedDict;
  20353. };
  20354. return Dict;
  20355. }();
  20356. var Ref = function RefClosure() {
  20357. function Ref(num, gen) {
  20358. this.num = num;
  20359. this.gen = gen;
  20360. }
  20361. Ref.prototype = {
  20362. toString: function Ref_toString() {
  20363. var str = this.num + 'R';
  20364. if (this.gen !== 0) {
  20365. str += this.gen;
  20366. }
  20367. return str;
  20368. }
  20369. };
  20370. return Ref;
  20371. }();
  20372. var RefSet = function RefSetClosure() {
  20373. function RefSet() {
  20374. this.dict = Object.create(null);
  20375. }
  20376. RefSet.prototype = {
  20377. has: function RefSet_has(ref) {
  20378. return ref.toString() in this.dict;
  20379. },
  20380. put: function RefSet_put(ref) {
  20381. this.dict[ref.toString()] = true;
  20382. },
  20383. remove: function RefSet_remove(ref) {
  20384. delete this.dict[ref.toString()];
  20385. }
  20386. };
  20387. return RefSet;
  20388. }();
  20389. var RefSetCache = function RefSetCacheClosure() {
  20390. function RefSetCache() {
  20391. this.dict = Object.create(null);
  20392. }
  20393. RefSetCache.prototype = {
  20394. get: function RefSetCache_get(ref) {
  20395. return this.dict[ref.toString()];
  20396. },
  20397. has: function RefSetCache_has(ref) {
  20398. return ref.toString() in this.dict;
  20399. },
  20400. put: function RefSetCache_put(ref, obj) {
  20401. this.dict[ref.toString()] = obj;
  20402. },
  20403. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20404. this.dict[ref.toString()] = this.get(aliasRef);
  20405. },
  20406. forEach: function RefSetCache_forEach(fn, thisArg) {
  20407. for (var i in this.dict) {
  20408. fn.call(thisArg, this.dict[i]);
  20409. }
  20410. },
  20411. clear: function RefSetCache_clear() {
  20412. this.dict = Object.create(null);
  20413. }
  20414. };
  20415. return RefSetCache;
  20416. }();
  20417. function isName(v, name) {
  20418. return v instanceof Name && (name === undefined || v.name === name);
  20419. }
  20420. function isCmd(v, cmd) {
  20421. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20422. }
  20423. function isDict(v, type) {
  20424. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20425. }
  20426. function isRef(v) {
  20427. return v instanceof Ref;
  20428. }
  20429. function isRefsEqual(v1, v2) {
  20430. return v1.num === v2.num && v1.gen === v2.gen;
  20431. }
  20432. function isStream(v) {
  20433. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20434. }
  20435. exports.Cmd = Cmd;
  20436. exports.Dict = Dict;
  20437. exports.Name = Name;
  20438. exports.Ref = Ref;
  20439. exports.RefSet = RefSet;
  20440. exports.RefSetCache = RefSetCache;
  20441. exports.isCmd = isCmd;
  20442. exports.isDict = isDict;
  20443. exports.isName = isName;
  20444. exports.isRef = isRef;
  20445. exports.isRefsEqual = isRefsEqual;
  20446. exports.isStream = isStream;
  20447. }));
  20448. (function (root, factory) {
  20449. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20450. }(this, function (exports, sharedUtil) {
  20451. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20452. var getStdFontMap = getLookupTableFactory(function (t) {
  20453. t['ArialNarrow'] = 'Helvetica';
  20454. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20455. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20456. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20457. t['ArialBlack'] = 'Helvetica';
  20458. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20459. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20460. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20461. t['Arial-Black'] = 'Helvetica';
  20462. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20463. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20464. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20465. t['Arial'] = 'Helvetica';
  20466. t['Arial-Bold'] = 'Helvetica-Bold';
  20467. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20468. t['Arial-Italic'] = 'Helvetica-Oblique';
  20469. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20470. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20471. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20472. t['ArialMT'] = 'Helvetica';
  20473. t['Courier-Bold'] = 'Courier-Bold';
  20474. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20475. t['Courier-Italic'] = 'Courier-Oblique';
  20476. t['CourierNew'] = 'Courier';
  20477. t['CourierNew-Bold'] = 'Courier-Bold';
  20478. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20479. t['CourierNew-Italic'] = 'Courier-Oblique';
  20480. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20481. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20482. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20483. t['CourierNewPSMT'] = 'Courier';
  20484. t['Helvetica'] = 'Helvetica';
  20485. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20486. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20487. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20488. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20489. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20490. t['Symbol-Bold'] = 'Symbol';
  20491. t['Symbol-BoldItalic'] = 'Symbol';
  20492. t['Symbol-Italic'] = 'Symbol';
  20493. t['TimesNewRoman'] = 'Times-Roman';
  20494. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20495. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20496. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20497. t['TimesNewRomanPS'] = 'Times-Roman';
  20498. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20499. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20500. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20501. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20502. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20503. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20504. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20505. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20506. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20507. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20508. });
  20509. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20510. t['CenturyGothic'] = 'Helvetica';
  20511. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20512. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20513. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20514. t['ComicSansMS'] = 'Comic Sans MS';
  20515. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20516. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20517. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20518. t['LucidaConsole'] = 'Courier';
  20519. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20520. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20521. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20522. t['MS-Gothic'] = 'MS Gothic';
  20523. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20524. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20525. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20526. t['MS-Mincho'] = 'MS Mincho';
  20527. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20528. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20529. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20530. t['MS-PGothic'] = 'MS PGothic';
  20531. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20532. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20533. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20534. t['MS-PMincho'] = 'MS PMincho';
  20535. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20536. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20537. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20538. t['Wingdings'] = 'ZapfDingbats';
  20539. });
  20540. var getSerifFonts = getLookupTableFactory(function (t) {
  20541. t['Adobe Jenson'] = true;
  20542. t['Adobe Text'] = true;
  20543. t['Albertus'] = true;
  20544. t['Aldus'] = true;
  20545. t['Alexandria'] = true;
  20546. t['Algerian'] = true;
  20547. t['American Typewriter'] = true;
  20548. t['Antiqua'] = true;
  20549. t['Apex'] = true;
  20550. t['Arno'] = true;
  20551. t['Aster'] = true;
  20552. t['Aurora'] = true;
  20553. t['Baskerville'] = true;
  20554. t['Bell'] = true;
  20555. t['Bembo'] = true;
  20556. t['Bembo Schoolbook'] = true;
  20557. t['Benguiat'] = true;
  20558. t['Berkeley Old Style'] = true;
  20559. t['Bernhard Modern'] = true;
  20560. t['Berthold City'] = true;
  20561. t['Bodoni'] = true;
  20562. t['Bauer Bodoni'] = true;
  20563. t['Book Antiqua'] = true;
  20564. t['Bookman'] = true;
  20565. t['Bordeaux Roman'] = true;
  20566. t['Californian FB'] = true;
  20567. t['Calisto'] = true;
  20568. t['Calvert'] = true;
  20569. t['Capitals'] = true;
  20570. t['Cambria'] = true;
  20571. t['Cartier'] = true;
  20572. t['Caslon'] = true;
  20573. t['Catull'] = true;
  20574. t['Centaur'] = true;
  20575. t['Century Old Style'] = true;
  20576. t['Century Schoolbook'] = true;
  20577. t['Chaparral'] = true;
  20578. t['Charis SIL'] = true;
  20579. t['Cheltenham'] = true;
  20580. t['Cholla Slab'] = true;
  20581. t['Clarendon'] = true;
  20582. t['Clearface'] = true;
  20583. t['Cochin'] = true;
  20584. t['Colonna'] = true;
  20585. t['Computer Modern'] = true;
  20586. t['Concrete Roman'] = true;
  20587. t['Constantia'] = true;
  20588. t['Cooper Black'] = true;
  20589. t['Corona'] = true;
  20590. t['Ecotype'] = true;
  20591. t['Egyptienne'] = true;
  20592. t['Elephant'] = true;
  20593. t['Excelsior'] = true;
  20594. t['Fairfield'] = true;
  20595. t['FF Scala'] = true;
  20596. t['Folkard'] = true;
  20597. t['Footlight'] = true;
  20598. t['FreeSerif'] = true;
  20599. t['Friz Quadrata'] = true;
  20600. t['Garamond'] = true;
  20601. t['Gentium'] = true;
  20602. t['Georgia'] = true;
  20603. t['Gloucester'] = true;
  20604. t['Goudy Old Style'] = true;
  20605. t['Goudy Schoolbook'] = true;
  20606. t['Goudy Pro Font'] = true;
  20607. t['Granjon'] = true;
  20608. t['Guardian Egyptian'] = true;
  20609. t['Heather'] = true;
  20610. t['Hercules'] = true;
  20611. t['High Tower Text'] = true;
  20612. t['Hiroshige'] = true;
  20613. t['Hoefler Text'] = true;
  20614. t['Humana Serif'] = true;
  20615. t['Imprint'] = true;
  20616. t['Ionic No. 5'] = true;
  20617. t['Janson'] = true;
  20618. t['Joanna'] = true;
  20619. t['Korinna'] = true;
  20620. t['Lexicon'] = true;
  20621. t['Liberation Serif'] = true;
  20622. t['Linux Libertine'] = true;
  20623. t['Literaturnaya'] = true;
  20624. t['Lucida'] = true;
  20625. t['Lucida Bright'] = true;
  20626. t['Melior'] = true;
  20627. t['Memphis'] = true;
  20628. t['Miller'] = true;
  20629. t['Minion'] = true;
  20630. t['Modern'] = true;
  20631. t['Mona Lisa'] = true;
  20632. t['Mrs Eaves'] = true;
  20633. t['MS Serif'] = true;
  20634. t['Museo Slab'] = true;
  20635. t['New York'] = true;
  20636. t['Nimbus Roman'] = true;
  20637. t['NPS Rawlinson Roadway'] = true;
  20638. t['Palatino'] = true;
  20639. t['Perpetua'] = true;
  20640. t['Plantin'] = true;
  20641. t['Plantin Schoolbook'] = true;
  20642. t['Playbill'] = true;
  20643. t['Poor Richard'] = true;
  20644. t['Rawlinson Roadway'] = true;
  20645. t['Renault'] = true;
  20646. t['Requiem'] = true;
  20647. t['Rockwell'] = true;
  20648. t['Roman'] = true;
  20649. t['Rotis Serif'] = true;
  20650. t['Sabon'] = true;
  20651. t['Scala'] = true;
  20652. t['Seagull'] = true;
  20653. t['Sistina'] = true;
  20654. t['Souvenir'] = true;
  20655. t['STIX'] = true;
  20656. t['Stone Informal'] = true;
  20657. t['Stone Serif'] = true;
  20658. t['Sylfaen'] = true;
  20659. t['Times'] = true;
  20660. t['Trajan'] = true;
  20661. t['Trinité'] = true;
  20662. t['Trump Mediaeval'] = true;
  20663. t['Utopia'] = true;
  20664. t['Vale Type'] = true;
  20665. t['Bitstream Vera'] = true;
  20666. t['Vera Serif'] = true;
  20667. t['Versailles'] = true;
  20668. t['Wanted'] = true;
  20669. t['Weiss'] = true;
  20670. t['Wide Latin'] = true;
  20671. t['Windsor'] = true;
  20672. t['XITS'] = true;
  20673. });
  20674. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20675. t['Dingbats'] = true;
  20676. t['Symbol'] = true;
  20677. t['ZapfDingbats'] = true;
  20678. });
  20679. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20680. t[2] = 10;
  20681. t[3] = 32;
  20682. t[4] = 33;
  20683. t[5] = 34;
  20684. t[6] = 35;
  20685. t[7] = 36;
  20686. t[8] = 37;
  20687. t[9] = 38;
  20688. t[10] = 39;
  20689. t[11] = 40;
  20690. t[12] = 41;
  20691. t[13] = 42;
  20692. t[14] = 43;
  20693. t[15] = 44;
  20694. t[16] = 45;
  20695. t[17] = 46;
  20696. t[18] = 47;
  20697. t[19] = 48;
  20698. t[20] = 49;
  20699. t[21] = 50;
  20700. t[22] = 51;
  20701. t[23] = 52;
  20702. t[24] = 53;
  20703. t[25] = 54;
  20704. t[26] = 55;
  20705. t[27] = 56;
  20706. t[28] = 57;
  20707. t[29] = 58;
  20708. t[30] = 894;
  20709. t[31] = 60;
  20710. t[32] = 61;
  20711. t[33] = 62;
  20712. t[34] = 63;
  20713. t[35] = 64;
  20714. t[36] = 65;
  20715. t[37] = 66;
  20716. t[38] = 67;
  20717. t[39] = 68;
  20718. t[40] = 69;
  20719. t[41] = 70;
  20720. t[42] = 71;
  20721. t[43] = 72;
  20722. t[44] = 73;
  20723. t[45] = 74;
  20724. t[46] = 75;
  20725. t[47] = 76;
  20726. t[48] = 77;
  20727. t[49] = 78;
  20728. t[50] = 79;
  20729. t[51] = 80;
  20730. t[52] = 81;
  20731. t[53] = 82;
  20732. t[54] = 83;
  20733. t[55] = 84;
  20734. t[56] = 85;
  20735. t[57] = 86;
  20736. t[58] = 87;
  20737. t[59] = 88;
  20738. t[60] = 89;
  20739. t[61] = 90;
  20740. t[62] = 91;
  20741. t[63] = 92;
  20742. t[64] = 93;
  20743. t[65] = 94;
  20744. t[66] = 95;
  20745. t[67] = 96;
  20746. t[68] = 97;
  20747. t[69] = 98;
  20748. t[70] = 99;
  20749. t[71] = 100;
  20750. t[72] = 101;
  20751. t[73] = 102;
  20752. t[74] = 103;
  20753. t[75] = 104;
  20754. t[76] = 105;
  20755. t[77] = 106;
  20756. t[78] = 107;
  20757. t[79] = 108;
  20758. t[80] = 109;
  20759. t[81] = 110;
  20760. t[82] = 111;
  20761. t[83] = 112;
  20762. t[84] = 113;
  20763. t[85] = 114;
  20764. t[86] = 115;
  20765. t[87] = 116;
  20766. t[88] = 117;
  20767. t[89] = 118;
  20768. t[90] = 119;
  20769. t[91] = 120;
  20770. t[92] = 121;
  20771. t[93] = 122;
  20772. t[94] = 123;
  20773. t[95] = 124;
  20774. t[96] = 125;
  20775. t[97] = 126;
  20776. t[98] = 196;
  20777. t[99] = 197;
  20778. t[100] = 199;
  20779. t[101] = 201;
  20780. t[102] = 209;
  20781. t[103] = 214;
  20782. t[104] = 220;
  20783. t[105] = 225;
  20784. t[106] = 224;
  20785. t[107] = 226;
  20786. t[108] = 228;
  20787. t[109] = 227;
  20788. t[110] = 229;
  20789. t[111] = 231;
  20790. t[112] = 233;
  20791. t[113] = 232;
  20792. t[114] = 234;
  20793. t[115] = 235;
  20794. t[116] = 237;
  20795. t[117] = 236;
  20796. t[118] = 238;
  20797. t[119] = 239;
  20798. t[120] = 241;
  20799. t[121] = 243;
  20800. t[122] = 242;
  20801. t[123] = 244;
  20802. t[124] = 246;
  20803. t[125] = 245;
  20804. t[126] = 250;
  20805. t[127] = 249;
  20806. t[128] = 251;
  20807. t[129] = 252;
  20808. t[130] = 8224;
  20809. t[131] = 176;
  20810. t[132] = 162;
  20811. t[133] = 163;
  20812. t[134] = 167;
  20813. t[135] = 8226;
  20814. t[136] = 182;
  20815. t[137] = 223;
  20816. t[138] = 174;
  20817. t[139] = 169;
  20818. t[140] = 8482;
  20819. t[141] = 180;
  20820. t[142] = 168;
  20821. t[143] = 8800;
  20822. t[144] = 198;
  20823. t[145] = 216;
  20824. t[146] = 8734;
  20825. t[147] = 177;
  20826. t[148] = 8804;
  20827. t[149] = 8805;
  20828. t[150] = 165;
  20829. t[151] = 181;
  20830. t[152] = 8706;
  20831. t[153] = 8721;
  20832. t[154] = 8719;
  20833. t[156] = 8747;
  20834. t[157] = 170;
  20835. t[158] = 186;
  20836. t[159] = 8486;
  20837. t[160] = 230;
  20838. t[161] = 248;
  20839. t[162] = 191;
  20840. t[163] = 161;
  20841. t[164] = 172;
  20842. t[165] = 8730;
  20843. t[166] = 402;
  20844. t[167] = 8776;
  20845. t[168] = 8710;
  20846. t[169] = 171;
  20847. t[170] = 187;
  20848. t[171] = 8230;
  20849. t[210] = 218;
  20850. t[223] = 711;
  20851. t[224] = 321;
  20852. t[225] = 322;
  20853. t[227] = 353;
  20854. t[229] = 382;
  20855. t[234] = 253;
  20856. t[252] = 263;
  20857. t[253] = 268;
  20858. t[254] = 269;
  20859. t[258] = 258;
  20860. t[260] = 260;
  20861. t[261] = 261;
  20862. t[265] = 280;
  20863. t[266] = 281;
  20864. t[268] = 283;
  20865. t[269] = 313;
  20866. t[275] = 323;
  20867. t[276] = 324;
  20868. t[278] = 328;
  20869. t[284] = 345;
  20870. t[285] = 346;
  20871. t[286] = 347;
  20872. t[292] = 367;
  20873. t[295] = 377;
  20874. t[296] = 378;
  20875. t[298] = 380;
  20876. t[305] = 963;
  20877. t[306] = 964;
  20878. t[307] = 966;
  20879. t[308] = 8215;
  20880. t[309] = 8252;
  20881. t[310] = 8319;
  20882. t[311] = 8359;
  20883. t[312] = 8592;
  20884. t[313] = 8593;
  20885. t[337] = 9552;
  20886. t[493] = 1039;
  20887. t[494] = 1040;
  20888. t[705] = 1524;
  20889. t[706] = 8362;
  20890. t[710] = 64288;
  20891. t[711] = 64298;
  20892. t[759] = 1617;
  20893. t[761] = 1776;
  20894. t[763] = 1778;
  20895. t[775] = 1652;
  20896. t[777] = 1764;
  20897. t[778] = 1780;
  20898. t[779] = 1781;
  20899. t[780] = 1782;
  20900. t[782] = 771;
  20901. t[783] = 64726;
  20902. t[786] = 8363;
  20903. t[788] = 8532;
  20904. t[790] = 768;
  20905. t[791] = 769;
  20906. t[792] = 768;
  20907. t[795] = 803;
  20908. t[797] = 64336;
  20909. t[798] = 64337;
  20910. t[799] = 64342;
  20911. t[800] = 64343;
  20912. t[801] = 64344;
  20913. t[802] = 64345;
  20914. t[803] = 64362;
  20915. t[804] = 64363;
  20916. t[805] = 64364;
  20917. t[2424] = 7821;
  20918. t[2425] = 7822;
  20919. t[2426] = 7823;
  20920. t[2427] = 7824;
  20921. t[2428] = 7825;
  20922. t[2429] = 7826;
  20923. t[2430] = 7827;
  20924. t[2433] = 7682;
  20925. t[2678] = 8045;
  20926. t[2679] = 8046;
  20927. t[2830] = 1552;
  20928. t[2838] = 686;
  20929. t[2840] = 751;
  20930. t[2842] = 753;
  20931. t[2843] = 754;
  20932. t[2844] = 755;
  20933. t[2846] = 757;
  20934. t[2856] = 767;
  20935. t[2857] = 848;
  20936. t[2858] = 849;
  20937. t[2862] = 853;
  20938. t[2863] = 854;
  20939. t[2864] = 855;
  20940. t[2865] = 861;
  20941. t[2866] = 862;
  20942. t[2906] = 7460;
  20943. t[2908] = 7462;
  20944. t[2909] = 7463;
  20945. t[2910] = 7464;
  20946. t[2912] = 7466;
  20947. t[2913] = 7467;
  20948. t[2914] = 7468;
  20949. t[2916] = 7470;
  20950. t[2917] = 7471;
  20951. t[2918] = 7472;
  20952. t[2920] = 7474;
  20953. t[2921] = 7475;
  20954. t[2922] = 7476;
  20955. t[2924] = 7478;
  20956. t[2925] = 7479;
  20957. t[2926] = 7480;
  20958. t[2928] = 7482;
  20959. t[2929] = 7483;
  20960. t[2930] = 7484;
  20961. t[2932] = 7486;
  20962. t[2933] = 7487;
  20963. t[2934] = 7488;
  20964. t[2936] = 7490;
  20965. t[2937] = 7491;
  20966. t[2938] = 7492;
  20967. t[2940] = 7494;
  20968. t[2941] = 7495;
  20969. t[2942] = 7496;
  20970. t[2944] = 7498;
  20971. t[2946] = 7500;
  20972. t[2948] = 7502;
  20973. t[2950] = 7504;
  20974. t[2951] = 7505;
  20975. t[2952] = 7506;
  20976. t[2954] = 7508;
  20977. t[2955] = 7509;
  20978. t[2956] = 7510;
  20979. t[2958] = 7512;
  20980. t[2959] = 7513;
  20981. t[2960] = 7514;
  20982. t[2962] = 7516;
  20983. t[2963] = 7517;
  20984. t[2964] = 7518;
  20985. t[2966] = 7520;
  20986. t[2967] = 7521;
  20987. t[2968] = 7522;
  20988. t[2970] = 7524;
  20989. t[2971] = 7525;
  20990. t[2972] = 7526;
  20991. t[2974] = 7528;
  20992. t[2975] = 7529;
  20993. t[2976] = 7530;
  20994. t[2978] = 1537;
  20995. t[2979] = 1538;
  20996. t[2980] = 1539;
  20997. t[2982] = 1549;
  20998. t[2983] = 1551;
  20999. t[2984] = 1552;
  21000. t[2986] = 1554;
  21001. t[2987] = 1555;
  21002. t[2988] = 1556;
  21003. t[2990] = 1623;
  21004. t[2991] = 1624;
  21005. t[2995] = 1775;
  21006. t[2999] = 1791;
  21007. t[3002] = 64290;
  21008. t[3003] = 64291;
  21009. t[3004] = 64292;
  21010. t[3006] = 64294;
  21011. t[3007] = 64295;
  21012. t[3008] = 64296;
  21013. t[3011] = 1900;
  21014. t[3014] = 8223;
  21015. t[3015] = 8244;
  21016. t[3017] = 7532;
  21017. t[3018] = 7533;
  21018. t[3019] = 7534;
  21019. t[3075] = 7590;
  21020. t[3076] = 7591;
  21021. t[3079] = 7594;
  21022. t[3080] = 7595;
  21023. t[3083] = 7598;
  21024. t[3084] = 7599;
  21025. t[3087] = 7602;
  21026. t[3088] = 7603;
  21027. t[3091] = 7606;
  21028. t[3092] = 7607;
  21029. t[3095] = 7610;
  21030. t[3096] = 7611;
  21031. t[3099] = 7614;
  21032. t[3100] = 7615;
  21033. t[3103] = 7618;
  21034. t[3104] = 7619;
  21035. t[3107] = 8337;
  21036. t[3108] = 8338;
  21037. t[3116] = 1884;
  21038. t[3119] = 1885;
  21039. t[3120] = 1885;
  21040. t[3123] = 1886;
  21041. t[3124] = 1886;
  21042. t[3127] = 1887;
  21043. t[3128] = 1887;
  21044. t[3131] = 1888;
  21045. t[3132] = 1888;
  21046. t[3135] = 1889;
  21047. t[3136] = 1889;
  21048. t[3139] = 1890;
  21049. t[3140] = 1890;
  21050. t[3143] = 1891;
  21051. t[3144] = 1891;
  21052. t[3147] = 1892;
  21053. t[3148] = 1892;
  21054. t[3153] = 580;
  21055. t[3154] = 581;
  21056. t[3157] = 584;
  21057. t[3158] = 585;
  21058. t[3161] = 588;
  21059. t[3162] = 589;
  21060. t[3165] = 891;
  21061. t[3166] = 892;
  21062. t[3169] = 1274;
  21063. t[3170] = 1275;
  21064. t[3173] = 1278;
  21065. t[3174] = 1279;
  21066. t[3181] = 7622;
  21067. t[3182] = 7623;
  21068. t[3282] = 11799;
  21069. t[3316] = 578;
  21070. t[3379] = 42785;
  21071. t[3393] = 1159;
  21072. t[3416] = 8377;
  21073. });
  21074. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21075. t[227] = 322;
  21076. t[264] = 261;
  21077. t[291] = 346;
  21078. });
  21079. exports.getStdFontMap = getStdFontMap;
  21080. exports.getNonStdFontMap = getNonStdFontMap;
  21081. exports.getSerifFonts = getSerifFonts;
  21082. exports.getSymbolsFonts = getSymbolsFonts;
  21083. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21084. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21085. }));
  21086. (function (root, factory) {
  21087. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21088. }(this, function (exports, sharedUtil) {
  21089. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21090. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21091. t[63721] = 0x00A9;
  21092. t[63193] = 0x00A9;
  21093. t[63720] = 0x00AE;
  21094. t[63194] = 0x00AE;
  21095. t[63722] = 0x2122;
  21096. t[63195] = 0x2122;
  21097. t[63729] = 0x23A7;
  21098. t[63730] = 0x23A8;
  21099. t[63731] = 0x23A9;
  21100. t[63740] = 0x23AB;
  21101. t[63741] = 0x23AC;
  21102. t[63742] = 0x23AD;
  21103. t[63726] = 0x23A1;
  21104. t[63727] = 0x23A2;
  21105. t[63728] = 0x23A3;
  21106. t[63737] = 0x23A4;
  21107. t[63738] = 0x23A5;
  21108. t[63739] = 0x23A6;
  21109. t[63723] = 0x239B;
  21110. t[63724] = 0x239C;
  21111. t[63725] = 0x239D;
  21112. t[63734] = 0x239E;
  21113. t[63735] = 0x239F;
  21114. t[63736] = 0x23A0;
  21115. });
  21116. function mapSpecialUnicodeValues(code) {
  21117. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21118. return 0;
  21119. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21120. return getSpecialPUASymbols()[code] || code;
  21121. }
  21122. return code;
  21123. }
  21124. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21125. var unicode = glyphsUnicodeMap[name];
  21126. if (unicode !== undefined) {
  21127. return unicode;
  21128. }
  21129. if (!name) {
  21130. return -1;
  21131. }
  21132. if (name[0] === 'u') {
  21133. var nameLen = name.length, hexStr;
  21134. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21135. hexStr = name.substr(3);
  21136. } else if (nameLen >= 5 && nameLen <= 7) {
  21137. hexStr = name.substr(1);
  21138. } else {
  21139. return -1;
  21140. }
  21141. if (hexStr === hexStr.toUpperCase()) {
  21142. unicode = parseInt(hexStr, 16);
  21143. if (unicode >= 0) {
  21144. return unicode;
  21145. }
  21146. }
  21147. }
  21148. return -1;
  21149. }
  21150. var UnicodeRanges = [
  21151. {
  21152. 'begin': 0x0000,
  21153. 'end': 0x007F
  21154. },
  21155. {
  21156. 'begin': 0x0080,
  21157. 'end': 0x00FF
  21158. },
  21159. {
  21160. 'begin': 0x0100,
  21161. 'end': 0x017F
  21162. },
  21163. {
  21164. 'begin': 0x0180,
  21165. 'end': 0x024F
  21166. },
  21167. {
  21168. 'begin': 0x0250,
  21169. 'end': 0x02AF
  21170. },
  21171. {
  21172. 'begin': 0x02B0,
  21173. 'end': 0x02FF
  21174. },
  21175. {
  21176. 'begin': 0x0300,
  21177. 'end': 0x036F
  21178. },
  21179. {
  21180. 'begin': 0x0370,
  21181. 'end': 0x03FF
  21182. },
  21183. {
  21184. 'begin': 0x2C80,
  21185. 'end': 0x2CFF
  21186. },
  21187. {
  21188. 'begin': 0x0400,
  21189. 'end': 0x04FF
  21190. },
  21191. {
  21192. 'begin': 0x0530,
  21193. 'end': 0x058F
  21194. },
  21195. {
  21196. 'begin': 0x0590,
  21197. 'end': 0x05FF
  21198. },
  21199. {
  21200. 'begin': 0xA500,
  21201. 'end': 0xA63F
  21202. },
  21203. {
  21204. 'begin': 0x0600,
  21205. 'end': 0x06FF
  21206. },
  21207. {
  21208. 'begin': 0x07C0,
  21209. 'end': 0x07FF
  21210. },
  21211. {
  21212. 'begin': 0x0900,
  21213. 'end': 0x097F
  21214. },
  21215. {
  21216. 'begin': 0x0980,
  21217. 'end': 0x09FF
  21218. },
  21219. {
  21220. 'begin': 0x0A00,
  21221. 'end': 0x0A7F
  21222. },
  21223. {
  21224. 'begin': 0x0A80,
  21225. 'end': 0x0AFF
  21226. },
  21227. {
  21228. 'begin': 0x0B00,
  21229. 'end': 0x0B7F
  21230. },
  21231. {
  21232. 'begin': 0x0B80,
  21233. 'end': 0x0BFF
  21234. },
  21235. {
  21236. 'begin': 0x0C00,
  21237. 'end': 0x0C7F
  21238. },
  21239. {
  21240. 'begin': 0x0C80,
  21241. 'end': 0x0CFF
  21242. },
  21243. {
  21244. 'begin': 0x0D00,
  21245. 'end': 0x0D7F
  21246. },
  21247. {
  21248. 'begin': 0x0E00,
  21249. 'end': 0x0E7F
  21250. },
  21251. {
  21252. 'begin': 0x0E80,
  21253. 'end': 0x0EFF
  21254. },
  21255. {
  21256. 'begin': 0x10A0,
  21257. 'end': 0x10FF
  21258. },
  21259. {
  21260. 'begin': 0x1B00,
  21261. 'end': 0x1B7F
  21262. },
  21263. {
  21264. 'begin': 0x1100,
  21265. 'end': 0x11FF
  21266. },
  21267. {
  21268. 'begin': 0x1E00,
  21269. 'end': 0x1EFF
  21270. },
  21271. {
  21272. 'begin': 0x1F00,
  21273. 'end': 0x1FFF
  21274. },
  21275. {
  21276. 'begin': 0x2000,
  21277. 'end': 0x206F
  21278. },
  21279. {
  21280. 'begin': 0x2070,
  21281. 'end': 0x209F
  21282. },
  21283. {
  21284. 'begin': 0x20A0,
  21285. 'end': 0x20CF
  21286. },
  21287. {
  21288. 'begin': 0x20D0,
  21289. 'end': 0x20FF
  21290. },
  21291. {
  21292. 'begin': 0x2100,
  21293. 'end': 0x214F
  21294. },
  21295. {
  21296. 'begin': 0x2150,
  21297. 'end': 0x218F
  21298. },
  21299. {
  21300. 'begin': 0x2190,
  21301. 'end': 0x21FF
  21302. },
  21303. {
  21304. 'begin': 0x2200,
  21305. 'end': 0x22FF
  21306. },
  21307. {
  21308. 'begin': 0x2300,
  21309. 'end': 0x23FF
  21310. },
  21311. {
  21312. 'begin': 0x2400,
  21313. 'end': 0x243F
  21314. },
  21315. {
  21316. 'begin': 0x2440,
  21317. 'end': 0x245F
  21318. },
  21319. {
  21320. 'begin': 0x2460,
  21321. 'end': 0x24FF
  21322. },
  21323. {
  21324. 'begin': 0x2500,
  21325. 'end': 0x257F
  21326. },
  21327. {
  21328. 'begin': 0x2580,
  21329. 'end': 0x259F
  21330. },
  21331. {
  21332. 'begin': 0x25A0,
  21333. 'end': 0x25FF
  21334. },
  21335. {
  21336. 'begin': 0x2600,
  21337. 'end': 0x26FF
  21338. },
  21339. {
  21340. 'begin': 0x2700,
  21341. 'end': 0x27BF
  21342. },
  21343. {
  21344. 'begin': 0x3000,
  21345. 'end': 0x303F
  21346. },
  21347. {
  21348. 'begin': 0x3040,
  21349. 'end': 0x309F
  21350. },
  21351. {
  21352. 'begin': 0x30A0,
  21353. 'end': 0x30FF
  21354. },
  21355. {
  21356. 'begin': 0x3100,
  21357. 'end': 0x312F
  21358. },
  21359. {
  21360. 'begin': 0x3130,
  21361. 'end': 0x318F
  21362. },
  21363. {
  21364. 'begin': 0xA840,
  21365. 'end': 0xA87F
  21366. },
  21367. {
  21368. 'begin': 0x3200,
  21369. 'end': 0x32FF
  21370. },
  21371. {
  21372. 'begin': 0x3300,
  21373. 'end': 0x33FF
  21374. },
  21375. {
  21376. 'begin': 0xAC00,
  21377. 'end': 0xD7AF
  21378. },
  21379. {
  21380. 'begin': 0xD800,
  21381. 'end': 0xDFFF
  21382. },
  21383. {
  21384. 'begin': 0x10900,
  21385. 'end': 0x1091F
  21386. },
  21387. {
  21388. 'begin': 0x4E00,
  21389. 'end': 0x9FFF
  21390. },
  21391. {
  21392. 'begin': 0xE000,
  21393. 'end': 0xF8FF
  21394. },
  21395. {
  21396. 'begin': 0x31C0,
  21397. 'end': 0x31EF
  21398. },
  21399. {
  21400. 'begin': 0xFB00,
  21401. 'end': 0xFB4F
  21402. },
  21403. {
  21404. 'begin': 0xFB50,
  21405. 'end': 0xFDFF
  21406. },
  21407. {
  21408. 'begin': 0xFE20,
  21409. 'end': 0xFE2F
  21410. },
  21411. {
  21412. 'begin': 0xFE10,
  21413. 'end': 0xFE1F
  21414. },
  21415. {
  21416. 'begin': 0xFE50,
  21417. 'end': 0xFE6F
  21418. },
  21419. {
  21420. 'begin': 0xFE70,
  21421. 'end': 0xFEFF
  21422. },
  21423. {
  21424. 'begin': 0xFF00,
  21425. 'end': 0xFFEF
  21426. },
  21427. {
  21428. 'begin': 0xFFF0,
  21429. 'end': 0xFFFF
  21430. },
  21431. {
  21432. 'begin': 0x0F00,
  21433. 'end': 0x0FFF
  21434. },
  21435. {
  21436. 'begin': 0x0700,
  21437. 'end': 0x074F
  21438. },
  21439. {
  21440. 'begin': 0x0780,
  21441. 'end': 0x07BF
  21442. },
  21443. {
  21444. 'begin': 0x0D80,
  21445. 'end': 0x0DFF
  21446. },
  21447. {
  21448. 'begin': 0x1000,
  21449. 'end': 0x109F
  21450. },
  21451. {
  21452. 'begin': 0x1200,
  21453. 'end': 0x137F
  21454. },
  21455. {
  21456. 'begin': 0x13A0,
  21457. 'end': 0x13FF
  21458. },
  21459. {
  21460. 'begin': 0x1400,
  21461. 'end': 0x167F
  21462. },
  21463. {
  21464. 'begin': 0x1680,
  21465. 'end': 0x169F
  21466. },
  21467. {
  21468. 'begin': 0x16A0,
  21469. 'end': 0x16FF
  21470. },
  21471. {
  21472. 'begin': 0x1780,
  21473. 'end': 0x17FF
  21474. },
  21475. {
  21476. 'begin': 0x1800,
  21477. 'end': 0x18AF
  21478. },
  21479. {
  21480. 'begin': 0x2800,
  21481. 'end': 0x28FF
  21482. },
  21483. {
  21484. 'begin': 0xA000,
  21485. 'end': 0xA48F
  21486. },
  21487. {
  21488. 'begin': 0x1700,
  21489. 'end': 0x171F
  21490. },
  21491. {
  21492. 'begin': 0x10300,
  21493. 'end': 0x1032F
  21494. },
  21495. {
  21496. 'begin': 0x10330,
  21497. 'end': 0x1034F
  21498. },
  21499. {
  21500. 'begin': 0x10400,
  21501. 'end': 0x1044F
  21502. },
  21503. {
  21504. 'begin': 0x1D000,
  21505. 'end': 0x1D0FF
  21506. },
  21507. {
  21508. 'begin': 0x1D400,
  21509. 'end': 0x1D7FF
  21510. },
  21511. {
  21512. 'begin': 0xFF000,
  21513. 'end': 0xFFFFD
  21514. },
  21515. {
  21516. 'begin': 0xFE00,
  21517. 'end': 0xFE0F
  21518. },
  21519. {
  21520. 'begin': 0xE0000,
  21521. 'end': 0xE007F
  21522. },
  21523. {
  21524. 'begin': 0x1900,
  21525. 'end': 0x194F
  21526. },
  21527. {
  21528. 'begin': 0x1950,
  21529. 'end': 0x197F
  21530. },
  21531. {
  21532. 'begin': 0x1980,
  21533. 'end': 0x19DF
  21534. },
  21535. {
  21536. 'begin': 0x1A00,
  21537. 'end': 0x1A1F
  21538. },
  21539. {
  21540. 'begin': 0x2C00,
  21541. 'end': 0x2C5F
  21542. },
  21543. {
  21544. 'begin': 0x2D30,
  21545. 'end': 0x2D7F
  21546. },
  21547. {
  21548. 'begin': 0x4DC0,
  21549. 'end': 0x4DFF
  21550. },
  21551. {
  21552. 'begin': 0xA800,
  21553. 'end': 0xA82F
  21554. },
  21555. {
  21556. 'begin': 0x10000,
  21557. 'end': 0x1007F
  21558. },
  21559. {
  21560. 'begin': 0x10140,
  21561. 'end': 0x1018F
  21562. },
  21563. {
  21564. 'begin': 0x10380,
  21565. 'end': 0x1039F
  21566. },
  21567. {
  21568. 'begin': 0x103A0,
  21569. 'end': 0x103DF
  21570. },
  21571. {
  21572. 'begin': 0x10450,
  21573. 'end': 0x1047F
  21574. },
  21575. {
  21576. 'begin': 0x10480,
  21577. 'end': 0x104AF
  21578. },
  21579. {
  21580. 'begin': 0x10800,
  21581. 'end': 0x1083F
  21582. },
  21583. {
  21584. 'begin': 0x10A00,
  21585. 'end': 0x10A5F
  21586. },
  21587. {
  21588. 'begin': 0x1D300,
  21589. 'end': 0x1D35F
  21590. },
  21591. {
  21592. 'begin': 0x12000,
  21593. 'end': 0x123FF
  21594. },
  21595. {
  21596. 'begin': 0x1D360,
  21597. 'end': 0x1D37F
  21598. },
  21599. {
  21600. 'begin': 0x1B80,
  21601. 'end': 0x1BBF
  21602. },
  21603. {
  21604. 'begin': 0x1C00,
  21605. 'end': 0x1C4F
  21606. },
  21607. {
  21608. 'begin': 0x1C50,
  21609. 'end': 0x1C7F
  21610. },
  21611. {
  21612. 'begin': 0xA880,
  21613. 'end': 0xA8DF
  21614. },
  21615. {
  21616. 'begin': 0xA900,
  21617. 'end': 0xA92F
  21618. },
  21619. {
  21620. 'begin': 0xA930,
  21621. 'end': 0xA95F
  21622. },
  21623. {
  21624. 'begin': 0xAA00,
  21625. 'end': 0xAA5F
  21626. },
  21627. {
  21628. 'begin': 0x10190,
  21629. 'end': 0x101CF
  21630. },
  21631. {
  21632. 'begin': 0x101D0,
  21633. 'end': 0x101FF
  21634. },
  21635. {
  21636. 'begin': 0x102A0,
  21637. 'end': 0x102DF
  21638. },
  21639. {
  21640. 'begin': 0x1F030,
  21641. 'end': 0x1F09F
  21642. }
  21643. ];
  21644. function getUnicodeRangeFor(value) {
  21645. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21646. var range = UnicodeRanges[i];
  21647. if (value >= range.begin && value < range.end) {
  21648. return i;
  21649. }
  21650. }
  21651. return -1;
  21652. }
  21653. function isRTLRangeFor(value) {
  21654. var range = UnicodeRanges[13];
  21655. if (value >= range.begin && value < range.end) {
  21656. return true;
  21657. }
  21658. range = UnicodeRanges[11];
  21659. if (value >= range.begin && value < range.end) {
  21660. return true;
  21661. }
  21662. return false;
  21663. }
  21664. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21665. t['\u00A8'] = '\u0020\u0308';
  21666. t['\u00AF'] = '\u0020\u0304';
  21667. t['\u00B4'] = '\u0020\u0301';
  21668. t['\u00B5'] = '\u03BC';
  21669. t['\u00B8'] = '\u0020\u0327';
  21670. t['\u0132'] = '\u0049\u004A';
  21671. t['\u0133'] = '\u0069\u006A';
  21672. t['\u013F'] = '\u004C\u00B7';
  21673. t['\u0140'] = '\u006C\u00B7';
  21674. t['\u0149'] = '\u02BC\u006E';
  21675. t['\u017F'] = '\u0073';
  21676. t['\u01C4'] = '\u0044\u017D';
  21677. t['\u01C5'] = '\u0044\u017E';
  21678. t['\u01C6'] = '\u0064\u017E';
  21679. t['\u01C7'] = '\u004C\u004A';
  21680. t['\u01C8'] = '\u004C\u006A';
  21681. t['\u01C9'] = '\u006C\u006A';
  21682. t['\u01CA'] = '\u004E\u004A';
  21683. t['\u01CB'] = '\u004E\u006A';
  21684. t['\u01CC'] = '\u006E\u006A';
  21685. t['\u01F1'] = '\u0044\u005A';
  21686. t['\u01F2'] = '\u0044\u007A';
  21687. t['\u01F3'] = '\u0064\u007A';
  21688. t['\u02D8'] = '\u0020\u0306';
  21689. t['\u02D9'] = '\u0020\u0307';
  21690. t['\u02DA'] = '\u0020\u030A';
  21691. t['\u02DB'] = '\u0020\u0328';
  21692. t['\u02DC'] = '\u0020\u0303';
  21693. t['\u02DD'] = '\u0020\u030B';
  21694. t['\u037A'] = '\u0020\u0345';
  21695. t['\u0384'] = '\u0020\u0301';
  21696. t['\u03D0'] = '\u03B2';
  21697. t['\u03D1'] = '\u03B8';
  21698. t['\u03D2'] = '\u03A5';
  21699. t['\u03D5'] = '\u03C6';
  21700. t['\u03D6'] = '\u03C0';
  21701. t['\u03F0'] = '\u03BA';
  21702. t['\u03F1'] = '\u03C1';
  21703. t['\u03F2'] = '\u03C2';
  21704. t['\u03F4'] = '\u0398';
  21705. t['\u03F5'] = '\u03B5';
  21706. t['\u03F9'] = '\u03A3';
  21707. t['\u0587'] = '\u0565\u0582';
  21708. t['\u0675'] = '\u0627\u0674';
  21709. t['\u0676'] = '\u0648\u0674';
  21710. t['\u0677'] = '\u06C7\u0674';
  21711. t['\u0678'] = '\u064A\u0674';
  21712. t['\u0E33'] = '\u0E4D\u0E32';
  21713. t['\u0EB3'] = '\u0ECD\u0EB2';
  21714. t['\u0EDC'] = '\u0EAB\u0E99';
  21715. t['\u0EDD'] = '\u0EAB\u0EA1';
  21716. t['\u0F77'] = '\u0FB2\u0F81';
  21717. t['\u0F79'] = '\u0FB3\u0F81';
  21718. t['\u1E9A'] = '\u0061\u02BE';
  21719. t['\u1FBD'] = '\u0020\u0313';
  21720. t['\u1FBF'] = '\u0020\u0313';
  21721. t['\u1FC0'] = '\u0020\u0342';
  21722. t['\u1FFE'] = '\u0020\u0314';
  21723. t['\u2002'] = '\u0020';
  21724. t['\u2003'] = '\u0020';
  21725. t['\u2004'] = '\u0020';
  21726. t['\u2005'] = '\u0020';
  21727. t['\u2006'] = '\u0020';
  21728. t['\u2008'] = '\u0020';
  21729. t['\u2009'] = '\u0020';
  21730. t['\u200A'] = '\u0020';
  21731. t['\u2017'] = '\u0020\u0333';
  21732. t['\u2024'] = '\u002E';
  21733. t['\u2025'] = '\u002E\u002E';
  21734. t['\u2026'] = '\u002E\u002E\u002E';
  21735. t['\u2033'] = '\u2032\u2032';
  21736. t['\u2034'] = '\u2032\u2032\u2032';
  21737. t['\u2036'] = '\u2035\u2035';
  21738. t['\u2037'] = '\u2035\u2035\u2035';
  21739. t['\u203C'] = '\u0021\u0021';
  21740. t['\u203E'] = '\u0020\u0305';
  21741. t['\u2047'] = '\u003F\u003F';
  21742. t['\u2048'] = '\u003F\u0021';
  21743. t['\u2049'] = '\u0021\u003F';
  21744. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21745. t['\u205F'] = '\u0020';
  21746. t['\u20A8'] = '\u0052\u0073';
  21747. t['\u2100'] = '\u0061\u002F\u0063';
  21748. t['\u2101'] = '\u0061\u002F\u0073';
  21749. t['\u2103'] = '\u00B0\u0043';
  21750. t['\u2105'] = '\u0063\u002F\u006F';
  21751. t['\u2106'] = '\u0063\u002F\u0075';
  21752. t['\u2107'] = '\u0190';
  21753. t['\u2109'] = '\u00B0\u0046';
  21754. t['\u2116'] = '\u004E\u006F';
  21755. t['\u2121'] = '\u0054\u0045\u004C';
  21756. t['\u2135'] = '\u05D0';
  21757. t['\u2136'] = '\u05D1';
  21758. t['\u2137'] = '\u05D2';
  21759. t['\u2138'] = '\u05D3';
  21760. t['\u213B'] = '\u0046\u0041\u0058';
  21761. t['\u2160'] = '\u0049';
  21762. t['\u2161'] = '\u0049\u0049';
  21763. t['\u2162'] = '\u0049\u0049\u0049';
  21764. t['\u2163'] = '\u0049\u0056';
  21765. t['\u2164'] = '\u0056';
  21766. t['\u2165'] = '\u0056\u0049';
  21767. t['\u2166'] = '\u0056\u0049\u0049';
  21768. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21769. t['\u2168'] = '\u0049\u0058';
  21770. t['\u2169'] = '\u0058';
  21771. t['\u216A'] = '\u0058\u0049';
  21772. t['\u216B'] = '\u0058\u0049\u0049';
  21773. t['\u216C'] = '\u004C';
  21774. t['\u216D'] = '\u0043';
  21775. t['\u216E'] = '\u0044';
  21776. t['\u216F'] = '\u004D';
  21777. t['\u2170'] = '\u0069';
  21778. t['\u2171'] = '\u0069\u0069';
  21779. t['\u2172'] = '\u0069\u0069\u0069';
  21780. t['\u2173'] = '\u0069\u0076';
  21781. t['\u2174'] = '\u0076';
  21782. t['\u2175'] = '\u0076\u0069';
  21783. t['\u2176'] = '\u0076\u0069\u0069';
  21784. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21785. t['\u2178'] = '\u0069\u0078';
  21786. t['\u2179'] = '\u0078';
  21787. t['\u217A'] = '\u0078\u0069';
  21788. t['\u217B'] = '\u0078\u0069\u0069';
  21789. t['\u217C'] = '\u006C';
  21790. t['\u217D'] = '\u0063';
  21791. t['\u217E'] = '\u0064';
  21792. t['\u217F'] = '\u006D';
  21793. t['\u222C'] = '\u222B\u222B';
  21794. t['\u222D'] = '\u222B\u222B\u222B';
  21795. t['\u222F'] = '\u222E\u222E';
  21796. t['\u2230'] = '\u222E\u222E\u222E';
  21797. t['\u2474'] = '\u0028\u0031\u0029';
  21798. t['\u2475'] = '\u0028\u0032\u0029';
  21799. t['\u2476'] = '\u0028\u0033\u0029';
  21800. t['\u2477'] = '\u0028\u0034\u0029';
  21801. t['\u2478'] = '\u0028\u0035\u0029';
  21802. t['\u2479'] = '\u0028\u0036\u0029';
  21803. t['\u247A'] = '\u0028\u0037\u0029';
  21804. t['\u247B'] = '\u0028\u0038\u0029';
  21805. t['\u247C'] = '\u0028\u0039\u0029';
  21806. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21807. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21808. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21809. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21810. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21811. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21812. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21813. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21814. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21815. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21816. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21817. t['\u2488'] = '\u0031\u002E';
  21818. t['\u2489'] = '\u0032\u002E';
  21819. t['\u248A'] = '\u0033\u002E';
  21820. t['\u248B'] = '\u0034\u002E';
  21821. t['\u248C'] = '\u0035\u002E';
  21822. t['\u248D'] = '\u0036\u002E';
  21823. t['\u248E'] = '\u0037\u002E';
  21824. t['\u248F'] = '\u0038\u002E';
  21825. t['\u2490'] = '\u0039\u002E';
  21826. t['\u2491'] = '\u0031\u0030\u002E';
  21827. t['\u2492'] = '\u0031\u0031\u002E';
  21828. t['\u2493'] = '\u0031\u0032\u002E';
  21829. t['\u2494'] = '\u0031\u0033\u002E';
  21830. t['\u2495'] = '\u0031\u0034\u002E';
  21831. t['\u2496'] = '\u0031\u0035\u002E';
  21832. t['\u2497'] = '\u0031\u0036\u002E';
  21833. t['\u2498'] = '\u0031\u0037\u002E';
  21834. t['\u2499'] = '\u0031\u0038\u002E';
  21835. t['\u249A'] = '\u0031\u0039\u002E';
  21836. t['\u249B'] = '\u0032\u0030\u002E';
  21837. t['\u249C'] = '\u0028\u0061\u0029';
  21838. t['\u249D'] = '\u0028\u0062\u0029';
  21839. t['\u249E'] = '\u0028\u0063\u0029';
  21840. t['\u249F'] = '\u0028\u0064\u0029';
  21841. t['\u24A0'] = '\u0028\u0065\u0029';
  21842. t['\u24A1'] = '\u0028\u0066\u0029';
  21843. t['\u24A2'] = '\u0028\u0067\u0029';
  21844. t['\u24A3'] = '\u0028\u0068\u0029';
  21845. t['\u24A4'] = '\u0028\u0069\u0029';
  21846. t['\u24A5'] = '\u0028\u006A\u0029';
  21847. t['\u24A6'] = '\u0028\u006B\u0029';
  21848. t['\u24A7'] = '\u0028\u006C\u0029';
  21849. t['\u24A8'] = '\u0028\u006D\u0029';
  21850. t['\u24A9'] = '\u0028\u006E\u0029';
  21851. t['\u24AA'] = '\u0028\u006F\u0029';
  21852. t['\u24AB'] = '\u0028\u0070\u0029';
  21853. t['\u24AC'] = '\u0028\u0071\u0029';
  21854. t['\u24AD'] = '\u0028\u0072\u0029';
  21855. t['\u24AE'] = '\u0028\u0073\u0029';
  21856. t['\u24AF'] = '\u0028\u0074\u0029';
  21857. t['\u24B0'] = '\u0028\u0075\u0029';
  21858. t['\u24B1'] = '\u0028\u0076\u0029';
  21859. t['\u24B2'] = '\u0028\u0077\u0029';
  21860. t['\u24B3'] = '\u0028\u0078\u0029';
  21861. t['\u24B4'] = '\u0028\u0079\u0029';
  21862. t['\u24B5'] = '\u0028\u007A\u0029';
  21863. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21864. t['\u2A74'] = '\u003A\u003A\u003D';
  21865. t['\u2A75'] = '\u003D\u003D';
  21866. t['\u2A76'] = '\u003D\u003D\u003D';
  21867. t['\u2E9F'] = '\u6BCD';
  21868. t['\u2EF3'] = '\u9F9F';
  21869. t['\u2F00'] = '\u4E00';
  21870. t['\u2F01'] = '\u4E28';
  21871. t['\u2F02'] = '\u4E36';
  21872. t['\u2F03'] = '\u4E3F';
  21873. t['\u2F04'] = '\u4E59';
  21874. t['\u2F05'] = '\u4E85';
  21875. t['\u2F06'] = '\u4E8C';
  21876. t['\u2F07'] = '\u4EA0';
  21877. t['\u2F08'] = '\u4EBA';
  21878. t['\u2F09'] = '\u513F';
  21879. t['\u2F0A'] = '\u5165';
  21880. t['\u2F0B'] = '\u516B';
  21881. t['\u2F0C'] = '\u5182';
  21882. t['\u2F0D'] = '\u5196';
  21883. t['\u2F0E'] = '\u51AB';
  21884. t['\u2F0F'] = '\u51E0';
  21885. t['\u2F10'] = '\u51F5';
  21886. t['\u2F11'] = '\u5200';
  21887. t['\u2F12'] = '\u529B';
  21888. t['\u2F13'] = '\u52F9';
  21889. t['\u2F14'] = '\u5315';
  21890. t['\u2F15'] = '\u531A';
  21891. t['\u2F16'] = '\u5338';
  21892. t['\u2F17'] = '\u5341';
  21893. t['\u2F18'] = '\u535C';
  21894. t['\u2F19'] = '\u5369';
  21895. t['\u2F1A'] = '\u5382';
  21896. t['\u2F1B'] = '\u53B6';
  21897. t['\u2F1C'] = '\u53C8';
  21898. t['\u2F1D'] = '\u53E3';
  21899. t['\u2F1E'] = '\u56D7';
  21900. t['\u2F1F'] = '\u571F';
  21901. t['\u2F20'] = '\u58EB';
  21902. t['\u2F21'] = '\u5902';
  21903. t['\u2F22'] = '\u590A';
  21904. t['\u2F23'] = '\u5915';
  21905. t['\u2F24'] = '\u5927';
  21906. t['\u2F25'] = '\u5973';
  21907. t['\u2F26'] = '\u5B50';
  21908. t['\u2F27'] = '\u5B80';
  21909. t['\u2F28'] = '\u5BF8';
  21910. t['\u2F29'] = '\u5C0F';
  21911. t['\u2F2A'] = '\u5C22';
  21912. t['\u2F2B'] = '\u5C38';
  21913. t['\u2F2C'] = '\u5C6E';
  21914. t['\u2F2D'] = '\u5C71';
  21915. t['\u2F2E'] = '\u5DDB';
  21916. t['\u2F2F'] = '\u5DE5';
  21917. t['\u2F30'] = '\u5DF1';
  21918. t['\u2F31'] = '\u5DFE';
  21919. t['\u2F32'] = '\u5E72';
  21920. t['\u2F33'] = '\u5E7A';
  21921. t['\u2F34'] = '\u5E7F';
  21922. t['\u2F35'] = '\u5EF4';
  21923. t['\u2F36'] = '\u5EFE';
  21924. t['\u2F37'] = '\u5F0B';
  21925. t['\u2F38'] = '\u5F13';
  21926. t['\u2F39'] = '\u5F50';
  21927. t['\u2F3A'] = '\u5F61';
  21928. t['\u2F3B'] = '\u5F73';
  21929. t['\u2F3C'] = '\u5FC3';
  21930. t['\u2F3D'] = '\u6208';
  21931. t['\u2F3E'] = '\u6236';
  21932. t['\u2F3F'] = '\u624B';
  21933. t['\u2F40'] = '\u652F';
  21934. t['\u2F41'] = '\u6534';
  21935. t['\u2F42'] = '\u6587';
  21936. t['\u2F43'] = '\u6597';
  21937. t['\u2F44'] = '\u65A4';
  21938. t['\u2F45'] = '\u65B9';
  21939. t['\u2F46'] = '\u65E0';
  21940. t['\u2F47'] = '\u65E5';
  21941. t['\u2F48'] = '\u66F0';
  21942. t['\u2F49'] = '\u6708';
  21943. t['\u2F4A'] = '\u6728';
  21944. t['\u2F4B'] = '\u6B20';
  21945. t['\u2F4C'] = '\u6B62';
  21946. t['\u2F4D'] = '\u6B79';
  21947. t['\u2F4E'] = '\u6BB3';
  21948. t['\u2F4F'] = '\u6BCB';
  21949. t['\u2F50'] = '\u6BD4';
  21950. t['\u2F51'] = '\u6BDB';
  21951. t['\u2F52'] = '\u6C0F';
  21952. t['\u2F53'] = '\u6C14';
  21953. t['\u2F54'] = '\u6C34';
  21954. t['\u2F55'] = '\u706B';
  21955. t['\u2F56'] = '\u722A';
  21956. t['\u2F57'] = '\u7236';
  21957. t['\u2F58'] = '\u723B';
  21958. t['\u2F59'] = '\u723F';
  21959. t['\u2F5A'] = '\u7247';
  21960. t['\u2F5B'] = '\u7259';
  21961. t['\u2F5C'] = '\u725B';
  21962. t['\u2F5D'] = '\u72AC';
  21963. t['\u2F5E'] = '\u7384';
  21964. t['\u2F5F'] = '\u7389';
  21965. t['\u2F60'] = '\u74DC';
  21966. t['\u2F61'] = '\u74E6';
  21967. t['\u2F62'] = '\u7518';
  21968. t['\u2F63'] = '\u751F';
  21969. t['\u2F64'] = '\u7528';
  21970. t['\u2F65'] = '\u7530';
  21971. t['\u2F66'] = '\u758B';
  21972. t['\u2F67'] = '\u7592';
  21973. t['\u2F68'] = '\u7676';
  21974. t['\u2F69'] = '\u767D';
  21975. t['\u2F6A'] = '\u76AE';
  21976. t['\u2F6B'] = '\u76BF';
  21977. t['\u2F6C'] = '\u76EE';
  21978. t['\u2F6D'] = '\u77DB';
  21979. t['\u2F6E'] = '\u77E2';
  21980. t['\u2F6F'] = '\u77F3';
  21981. t['\u2F70'] = '\u793A';
  21982. t['\u2F71'] = '\u79B8';
  21983. t['\u2F72'] = '\u79BE';
  21984. t['\u2F73'] = '\u7A74';
  21985. t['\u2F74'] = '\u7ACB';
  21986. t['\u2F75'] = '\u7AF9';
  21987. t['\u2F76'] = '\u7C73';
  21988. t['\u2F77'] = '\u7CF8';
  21989. t['\u2F78'] = '\u7F36';
  21990. t['\u2F79'] = '\u7F51';
  21991. t['\u2F7A'] = '\u7F8A';
  21992. t['\u2F7B'] = '\u7FBD';
  21993. t['\u2F7C'] = '\u8001';
  21994. t['\u2F7D'] = '\u800C';
  21995. t['\u2F7E'] = '\u8012';
  21996. t['\u2F7F'] = '\u8033';
  21997. t['\u2F80'] = '\u807F';
  21998. t['\u2F81'] = '\u8089';
  21999. t['\u2F82'] = '\u81E3';
  22000. t['\u2F83'] = '\u81EA';
  22001. t['\u2F84'] = '\u81F3';
  22002. t['\u2F85'] = '\u81FC';
  22003. t['\u2F86'] = '\u820C';
  22004. t['\u2F87'] = '\u821B';
  22005. t['\u2F88'] = '\u821F';
  22006. t['\u2F89'] = '\u826E';
  22007. t['\u2F8A'] = '\u8272';
  22008. t['\u2F8B'] = '\u8278';
  22009. t['\u2F8C'] = '\u864D';
  22010. t['\u2F8D'] = '\u866B';
  22011. t['\u2F8E'] = '\u8840';
  22012. t['\u2F8F'] = '\u884C';
  22013. t['\u2F90'] = '\u8863';
  22014. t['\u2F91'] = '\u897E';
  22015. t['\u2F92'] = '\u898B';
  22016. t['\u2F93'] = '\u89D2';
  22017. t['\u2F94'] = '\u8A00';
  22018. t['\u2F95'] = '\u8C37';
  22019. t['\u2F96'] = '\u8C46';
  22020. t['\u2F97'] = '\u8C55';
  22021. t['\u2F98'] = '\u8C78';
  22022. t['\u2F99'] = '\u8C9D';
  22023. t['\u2F9A'] = '\u8D64';
  22024. t['\u2F9B'] = '\u8D70';
  22025. t['\u2F9C'] = '\u8DB3';
  22026. t['\u2F9D'] = '\u8EAB';
  22027. t['\u2F9E'] = '\u8ECA';
  22028. t['\u2F9F'] = '\u8F9B';
  22029. t['\u2FA0'] = '\u8FB0';
  22030. t['\u2FA1'] = '\u8FB5';
  22031. t['\u2FA2'] = '\u9091';
  22032. t['\u2FA3'] = '\u9149';
  22033. t['\u2FA4'] = '\u91C6';
  22034. t['\u2FA5'] = '\u91CC';
  22035. t['\u2FA6'] = '\u91D1';
  22036. t['\u2FA7'] = '\u9577';
  22037. t['\u2FA8'] = '\u9580';
  22038. t['\u2FA9'] = '\u961C';
  22039. t['\u2FAA'] = '\u96B6';
  22040. t['\u2FAB'] = '\u96B9';
  22041. t['\u2FAC'] = '\u96E8';
  22042. t['\u2FAD'] = '\u9751';
  22043. t['\u2FAE'] = '\u975E';
  22044. t['\u2FAF'] = '\u9762';
  22045. t['\u2FB0'] = '\u9769';
  22046. t['\u2FB1'] = '\u97CB';
  22047. t['\u2FB2'] = '\u97ED';
  22048. t['\u2FB3'] = '\u97F3';
  22049. t['\u2FB4'] = '\u9801';
  22050. t['\u2FB5'] = '\u98A8';
  22051. t['\u2FB6'] = '\u98DB';
  22052. t['\u2FB7'] = '\u98DF';
  22053. t['\u2FB8'] = '\u9996';
  22054. t['\u2FB9'] = '\u9999';
  22055. t['\u2FBA'] = '\u99AC';
  22056. t['\u2FBB'] = '\u9AA8';
  22057. t['\u2FBC'] = '\u9AD8';
  22058. t['\u2FBD'] = '\u9ADF';
  22059. t['\u2FBE'] = '\u9B25';
  22060. t['\u2FBF'] = '\u9B2F';
  22061. t['\u2FC0'] = '\u9B32';
  22062. t['\u2FC1'] = '\u9B3C';
  22063. t['\u2FC2'] = '\u9B5A';
  22064. t['\u2FC3'] = '\u9CE5';
  22065. t['\u2FC4'] = '\u9E75';
  22066. t['\u2FC5'] = '\u9E7F';
  22067. t['\u2FC6'] = '\u9EA5';
  22068. t['\u2FC7'] = '\u9EBB';
  22069. t['\u2FC8'] = '\u9EC3';
  22070. t['\u2FC9'] = '\u9ECD';
  22071. t['\u2FCA'] = '\u9ED1';
  22072. t['\u2FCB'] = '\u9EF9';
  22073. t['\u2FCC'] = '\u9EFD';
  22074. t['\u2FCD'] = '\u9F0E';
  22075. t['\u2FCE'] = '\u9F13';
  22076. t['\u2FCF'] = '\u9F20';
  22077. t['\u2FD0'] = '\u9F3B';
  22078. t['\u2FD1'] = '\u9F4A';
  22079. t['\u2FD2'] = '\u9F52';
  22080. t['\u2FD3'] = '\u9F8D';
  22081. t['\u2FD4'] = '\u9F9C';
  22082. t['\u2FD5'] = '\u9FA0';
  22083. t['\u3036'] = '\u3012';
  22084. t['\u3038'] = '\u5341';
  22085. t['\u3039'] = '\u5344';
  22086. t['\u303A'] = '\u5345';
  22087. t['\u309B'] = '\u0020\u3099';
  22088. t['\u309C'] = '\u0020\u309A';
  22089. t['\u3131'] = '\u1100';
  22090. t['\u3132'] = '\u1101';
  22091. t['\u3133'] = '\u11AA';
  22092. t['\u3134'] = '\u1102';
  22093. t['\u3135'] = '\u11AC';
  22094. t['\u3136'] = '\u11AD';
  22095. t['\u3137'] = '\u1103';
  22096. t['\u3138'] = '\u1104';
  22097. t['\u3139'] = '\u1105';
  22098. t['\u313A'] = '\u11B0';
  22099. t['\u313B'] = '\u11B1';
  22100. t['\u313C'] = '\u11B2';
  22101. t['\u313D'] = '\u11B3';
  22102. t['\u313E'] = '\u11B4';
  22103. t['\u313F'] = '\u11B5';
  22104. t['\u3140'] = '\u111A';
  22105. t['\u3141'] = '\u1106';
  22106. t['\u3142'] = '\u1107';
  22107. t['\u3143'] = '\u1108';
  22108. t['\u3144'] = '\u1121';
  22109. t['\u3145'] = '\u1109';
  22110. t['\u3146'] = '\u110A';
  22111. t['\u3147'] = '\u110B';
  22112. t['\u3148'] = '\u110C';
  22113. t['\u3149'] = '\u110D';
  22114. t['\u314A'] = '\u110E';
  22115. t['\u314B'] = '\u110F';
  22116. t['\u314C'] = '\u1110';
  22117. t['\u314D'] = '\u1111';
  22118. t['\u314E'] = '\u1112';
  22119. t['\u314F'] = '\u1161';
  22120. t['\u3150'] = '\u1162';
  22121. t['\u3151'] = '\u1163';
  22122. t['\u3152'] = '\u1164';
  22123. t['\u3153'] = '\u1165';
  22124. t['\u3154'] = '\u1166';
  22125. t['\u3155'] = '\u1167';
  22126. t['\u3156'] = '\u1168';
  22127. t['\u3157'] = '\u1169';
  22128. t['\u3158'] = '\u116A';
  22129. t['\u3159'] = '\u116B';
  22130. t['\u315A'] = '\u116C';
  22131. t['\u315B'] = '\u116D';
  22132. t['\u315C'] = '\u116E';
  22133. t['\u315D'] = '\u116F';
  22134. t['\u315E'] = '\u1170';
  22135. t['\u315F'] = '\u1171';
  22136. t['\u3160'] = '\u1172';
  22137. t['\u3161'] = '\u1173';
  22138. t['\u3162'] = '\u1174';
  22139. t['\u3163'] = '\u1175';
  22140. t['\u3164'] = '\u1160';
  22141. t['\u3165'] = '\u1114';
  22142. t['\u3166'] = '\u1115';
  22143. t['\u3167'] = '\u11C7';
  22144. t['\u3168'] = '\u11C8';
  22145. t['\u3169'] = '\u11CC';
  22146. t['\u316A'] = '\u11CE';
  22147. t['\u316B'] = '\u11D3';
  22148. t['\u316C'] = '\u11D7';
  22149. t['\u316D'] = '\u11D9';
  22150. t['\u316E'] = '\u111C';
  22151. t['\u316F'] = '\u11DD';
  22152. t['\u3170'] = '\u11DF';
  22153. t['\u3171'] = '\u111D';
  22154. t['\u3172'] = '\u111E';
  22155. t['\u3173'] = '\u1120';
  22156. t['\u3174'] = '\u1122';
  22157. t['\u3175'] = '\u1123';
  22158. t['\u3176'] = '\u1127';
  22159. t['\u3177'] = '\u1129';
  22160. t['\u3178'] = '\u112B';
  22161. t['\u3179'] = '\u112C';
  22162. t['\u317A'] = '\u112D';
  22163. t['\u317B'] = '\u112E';
  22164. t['\u317C'] = '\u112F';
  22165. t['\u317D'] = '\u1132';
  22166. t['\u317E'] = '\u1136';
  22167. t['\u317F'] = '\u1140';
  22168. t['\u3180'] = '\u1147';
  22169. t['\u3181'] = '\u114C';
  22170. t['\u3182'] = '\u11F1';
  22171. t['\u3183'] = '\u11F2';
  22172. t['\u3184'] = '\u1157';
  22173. t['\u3185'] = '\u1158';
  22174. t['\u3186'] = '\u1159';
  22175. t['\u3187'] = '\u1184';
  22176. t['\u3188'] = '\u1185';
  22177. t['\u3189'] = '\u1188';
  22178. t['\u318A'] = '\u1191';
  22179. t['\u318B'] = '\u1192';
  22180. t['\u318C'] = '\u1194';
  22181. t['\u318D'] = '\u119E';
  22182. t['\u318E'] = '\u11A1';
  22183. t['\u3200'] = '\u0028\u1100\u0029';
  22184. t['\u3201'] = '\u0028\u1102\u0029';
  22185. t['\u3202'] = '\u0028\u1103\u0029';
  22186. t['\u3203'] = '\u0028\u1105\u0029';
  22187. t['\u3204'] = '\u0028\u1106\u0029';
  22188. t['\u3205'] = '\u0028\u1107\u0029';
  22189. t['\u3206'] = '\u0028\u1109\u0029';
  22190. t['\u3207'] = '\u0028\u110B\u0029';
  22191. t['\u3208'] = '\u0028\u110C\u0029';
  22192. t['\u3209'] = '\u0028\u110E\u0029';
  22193. t['\u320A'] = '\u0028\u110F\u0029';
  22194. t['\u320B'] = '\u0028\u1110\u0029';
  22195. t['\u320C'] = '\u0028\u1111\u0029';
  22196. t['\u320D'] = '\u0028\u1112\u0029';
  22197. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22198. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22199. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22200. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22201. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22202. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22203. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22204. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22205. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22206. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22207. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22208. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22209. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22210. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22211. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22212. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22213. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22214. t['\u3220'] = '\u0028\u4E00\u0029';
  22215. t['\u3221'] = '\u0028\u4E8C\u0029';
  22216. t['\u3222'] = '\u0028\u4E09\u0029';
  22217. t['\u3223'] = '\u0028\u56DB\u0029';
  22218. t['\u3224'] = '\u0028\u4E94\u0029';
  22219. t['\u3225'] = '\u0028\u516D\u0029';
  22220. t['\u3226'] = '\u0028\u4E03\u0029';
  22221. t['\u3227'] = '\u0028\u516B\u0029';
  22222. t['\u3228'] = '\u0028\u4E5D\u0029';
  22223. t['\u3229'] = '\u0028\u5341\u0029';
  22224. t['\u322A'] = '\u0028\u6708\u0029';
  22225. t['\u322B'] = '\u0028\u706B\u0029';
  22226. t['\u322C'] = '\u0028\u6C34\u0029';
  22227. t['\u322D'] = '\u0028\u6728\u0029';
  22228. t['\u322E'] = '\u0028\u91D1\u0029';
  22229. t['\u322F'] = '\u0028\u571F\u0029';
  22230. t['\u3230'] = '\u0028\u65E5\u0029';
  22231. t['\u3231'] = '\u0028\u682A\u0029';
  22232. t['\u3232'] = '\u0028\u6709\u0029';
  22233. t['\u3233'] = '\u0028\u793E\u0029';
  22234. t['\u3234'] = '\u0028\u540D\u0029';
  22235. t['\u3235'] = '\u0028\u7279\u0029';
  22236. t['\u3236'] = '\u0028\u8CA1\u0029';
  22237. t['\u3237'] = '\u0028\u795D\u0029';
  22238. t['\u3238'] = '\u0028\u52B4\u0029';
  22239. t['\u3239'] = '\u0028\u4EE3\u0029';
  22240. t['\u323A'] = '\u0028\u547C\u0029';
  22241. t['\u323B'] = '\u0028\u5B66\u0029';
  22242. t['\u323C'] = '\u0028\u76E3\u0029';
  22243. t['\u323D'] = '\u0028\u4F01\u0029';
  22244. t['\u323E'] = '\u0028\u8CC7\u0029';
  22245. t['\u323F'] = '\u0028\u5354\u0029';
  22246. t['\u3240'] = '\u0028\u796D\u0029';
  22247. t['\u3241'] = '\u0028\u4F11\u0029';
  22248. t['\u3242'] = '\u0028\u81EA\u0029';
  22249. t['\u3243'] = '\u0028\u81F3\u0029';
  22250. t['\u32C0'] = '\u0031\u6708';
  22251. t['\u32C1'] = '\u0032\u6708';
  22252. t['\u32C2'] = '\u0033\u6708';
  22253. t['\u32C3'] = '\u0034\u6708';
  22254. t['\u32C4'] = '\u0035\u6708';
  22255. t['\u32C5'] = '\u0036\u6708';
  22256. t['\u32C6'] = '\u0037\u6708';
  22257. t['\u32C7'] = '\u0038\u6708';
  22258. t['\u32C8'] = '\u0039\u6708';
  22259. t['\u32C9'] = '\u0031\u0030\u6708';
  22260. t['\u32CA'] = '\u0031\u0031\u6708';
  22261. t['\u32CB'] = '\u0031\u0032\u6708';
  22262. t['\u3358'] = '\u0030\u70B9';
  22263. t['\u3359'] = '\u0031\u70B9';
  22264. t['\u335A'] = '\u0032\u70B9';
  22265. t['\u335B'] = '\u0033\u70B9';
  22266. t['\u335C'] = '\u0034\u70B9';
  22267. t['\u335D'] = '\u0035\u70B9';
  22268. t['\u335E'] = '\u0036\u70B9';
  22269. t['\u335F'] = '\u0037\u70B9';
  22270. t['\u3360'] = '\u0038\u70B9';
  22271. t['\u3361'] = '\u0039\u70B9';
  22272. t['\u3362'] = '\u0031\u0030\u70B9';
  22273. t['\u3363'] = '\u0031\u0031\u70B9';
  22274. t['\u3364'] = '\u0031\u0032\u70B9';
  22275. t['\u3365'] = '\u0031\u0033\u70B9';
  22276. t['\u3366'] = '\u0031\u0034\u70B9';
  22277. t['\u3367'] = '\u0031\u0035\u70B9';
  22278. t['\u3368'] = '\u0031\u0036\u70B9';
  22279. t['\u3369'] = '\u0031\u0037\u70B9';
  22280. t['\u336A'] = '\u0031\u0038\u70B9';
  22281. t['\u336B'] = '\u0031\u0039\u70B9';
  22282. t['\u336C'] = '\u0032\u0030\u70B9';
  22283. t['\u336D'] = '\u0032\u0031\u70B9';
  22284. t['\u336E'] = '\u0032\u0032\u70B9';
  22285. t['\u336F'] = '\u0032\u0033\u70B9';
  22286. t['\u3370'] = '\u0032\u0034\u70B9';
  22287. t['\u33E0'] = '\u0031\u65E5';
  22288. t['\u33E1'] = '\u0032\u65E5';
  22289. t['\u33E2'] = '\u0033\u65E5';
  22290. t['\u33E3'] = '\u0034\u65E5';
  22291. t['\u33E4'] = '\u0035\u65E5';
  22292. t['\u33E5'] = '\u0036\u65E5';
  22293. t['\u33E6'] = '\u0037\u65E5';
  22294. t['\u33E7'] = '\u0038\u65E5';
  22295. t['\u33E8'] = '\u0039\u65E5';
  22296. t['\u33E9'] = '\u0031\u0030\u65E5';
  22297. t['\u33EA'] = '\u0031\u0031\u65E5';
  22298. t['\u33EB'] = '\u0031\u0032\u65E5';
  22299. t['\u33EC'] = '\u0031\u0033\u65E5';
  22300. t['\u33ED'] = '\u0031\u0034\u65E5';
  22301. t['\u33EE'] = '\u0031\u0035\u65E5';
  22302. t['\u33EF'] = '\u0031\u0036\u65E5';
  22303. t['\u33F0'] = '\u0031\u0037\u65E5';
  22304. t['\u33F1'] = '\u0031\u0038\u65E5';
  22305. t['\u33F2'] = '\u0031\u0039\u65E5';
  22306. t['\u33F3'] = '\u0032\u0030\u65E5';
  22307. t['\u33F4'] = '\u0032\u0031\u65E5';
  22308. t['\u33F5'] = '\u0032\u0032\u65E5';
  22309. t['\u33F6'] = '\u0032\u0033\u65E5';
  22310. t['\u33F7'] = '\u0032\u0034\u65E5';
  22311. t['\u33F8'] = '\u0032\u0035\u65E5';
  22312. t['\u33F9'] = '\u0032\u0036\u65E5';
  22313. t['\u33FA'] = '\u0032\u0037\u65E5';
  22314. t['\u33FB'] = '\u0032\u0038\u65E5';
  22315. t['\u33FC'] = '\u0032\u0039\u65E5';
  22316. t['\u33FD'] = '\u0033\u0030\u65E5';
  22317. t['\u33FE'] = '\u0033\u0031\u65E5';
  22318. t['\uFB00'] = '\u0066\u0066';
  22319. t['\uFB01'] = '\u0066\u0069';
  22320. t['\uFB02'] = '\u0066\u006C';
  22321. t['\uFB03'] = '\u0066\u0066\u0069';
  22322. t['\uFB04'] = '\u0066\u0066\u006C';
  22323. t['\uFB05'] = '\u017F\u0074';
  22324. t['\uFB06'] = '\u0073\u0074';
  22325. t['\uFB13'] = '\u0574\u0576';
  22326. t['\uFB14'] = '\u0574\u0565';
  22327. t['\uFB15'] = '\u0574\u056B';
  22328. t['\uFB16'] = '\u057E\u0576';
  22329. t['\uFB17'] = '\u0574\u056D';
  22330. t['\uFB4F'] = '\u05D0\u05DC';
  22331. t['\uFB50'] = '\u0671';
  22332. t['\uFB51'] = '\u0671';
  22333. t['\uFB52'] = '\u067B';
  22334. t['\uFB53'] = '\u067B';
  22335. t['\uFB54'] = '\u067B';
  22336. t['\uFB55'] = '\u067B';
  22337. t['\uFB56'] = '\u067E';
  22338. t['\uFB57'] = '\u067E';
  22339. t['\uFB58'] = '\u067E';
  22340. t['\uFB59'] = '\u067E';
  22341. t['\uFB5A'] = '\u0680';
  22342. t['\uFB5B'] = '\u0680';
  22343. t['\uFB5C'] = '\u0680';
  22344. t['\uFB5D'] = '\u0680';
  22345. t['\uFB5E'] = '\u067A';
  22346. t['\uFB5F'] = '\u067A';
  22347. t['\uFB60'] = '\u067A';
  22348. t['\uFB61'] = '\u067A';
  22349. t['\uFB62'] = '\u067F';
  22350. t['\uFB63'] = '\u067F';
  22351. t['\uFB64'] = '\u067F';
  22352. t['\uFB65'] = '\u067F';
  22353. t['\uFB66'] = '\u0679';
  22354. t['\uFB67'] = '\u0679';
  22355. t['\uFB68'] = '\u0679';
  22356. t['\uFB69'] = '\u0679';
  22357. t['\uFB6A'] = '\u06A4';
  22358. t['\uFB6B'] = '\u06A4';
  22359. t['\uFB6C'] = '\u06A4';
  22360. t['\uFB6D'] = '\u06A4';
  22361. t['\uFB6E'] = '\u06A6';
  22362. t['\uFB6F'] = '\u06A6';
  22363. t['\uFB70'] = '\u06A6';
  22364. t['\uFB71'] = '\u06A6';
  22365. t['\uFB72'] = '\u0684';
  22366. t['\uFB73'] = '\u0684';
  22367. t['\uFB74'] = '\u0684';
  22368. t['\uFB75'] = '\u0684';
  22369. t['\uFB76'] = '\u0683';
  22370. t['\uFB77'] = '\u0683';
  22371. t['\uFB78'] = '\u0683';
  22372. t['\uFB79'] = '\u0683';
  22373. t['\uFB7A'] = '\u0686';
  22374. t['\uFB7B'] = '\u0686';
  22375. t['\uFB7C'] = '\u0686';
  22376. t['\uFB7D'] = '\u0686';
  22377. t['\uFB7E'] = '\u0687';
  22378. t['\uFB7F'] = '\u0687';
  22379. t['\uFB80'] = '\u0687';
  22380. t['\uFB81'] = '\u0687';
  22381. t['\uFB82'] = '\u068D';
  22382. t['\uFB83'] = '\u068D';
  22383. t['\uFB84'] = '\u068C';
  22384. t['\uFB85'] = '\u068C';
  22385. t['\uFB86'] = '\u068E';
  22386. t['\uFB87'] = '\u068E';
  22387. t['\uFB88'] = '\u0688';
  22388. t['\uFB89'] = '\u0688';
  22389. t['\uFB8A'] = '\u0698';
  22390. t['\uFB8B'] = '\u0698';
  22391. t['\uFB8C'] = '\u0691';
  22392. t['\uFB8D'] = '\u0691';
  22393. t['\uFB8E'] = '\u06A9';
  22394. t['\uFB8F'] = '\u06A9';
  22395. t['\uFB90'] = '\u06A9';
  22396. t['\uFB91'] = '\u06A9';
  22397. t['\uFB92'] = '\u06AF';
  22398. t['\uFB93'] = '\u06AF';
  22399. t['\uFB94'] = '\u06AF';
  22400. t['\uFB95'] = '\u06AF';
  22401. t['\uFB96'] = '\u06B3';
  22402. t['\uFB97'] = '\u06B3';
  22403. t['\uFB98'] = '\u06B3';
  22404. t['\uFB99'] = '\u06B3';
  22405. t['\uFB9A'] = '\u06B1';
  22406. t['\uFB9B'] = '\u06B1';
  22407. t['\uFB9C'] = '\u06B1';
  22408. t['\uFB9D'] = '\u06B1';
  22409. t['\uFB9E'] = '\u06BA';
  22410. t['\uFB9F'] = '\u06BA';
  22411. t['\uFBA0'] = '\u06BB';
  22412. t['\uFBA1'] = '\u06BB';
  22413. t['\uFBA2'] = '\u06BB';
  22414. t['\uFBA3'] = '\u06BB';
  22415. t['\uFBA4'] = '\u06C0';
  22416. t['\uFBA5'] = '\u06C0';
  22417. t['\uFBA6'] = '\u06C1';
  22418. t['\uFBA7'] = '\u06C1';
  22419. t['\uFBA8'] = '\u06C1';
  22420. t['\uFBA9'] = '\u06C1';
  22421. t['\uFBAA'] = '\u06BE';
  22422. t['\uFBAB'] = '\u06BE';
  22423. t['\uFBAC'] = '\u06BE';
  22424. t['\uFBAD'] = '\u06BE';
  22425. t['\uFBAE'] = '\u06D2';
  22426. t['\uFBAF'] = '\u06D2';
  22427. t['\uFBB0'] = '\u06D3';
  22428. t['\uFBB1'] = '\u06D3';
  22429. t['\uFBD3'] = '\u06AD';
  22430. t['\uFBD4'] = '\u06AD';
  22431. t['\uFBD5'] = '\u06AD';
  22432. t['\uFBD6'] = '\u06AD';
  22433. t['\uFBD7'] = '\u06C7';
  22434. t['\uFBD8'] = '\u06C7';
  22435. t['\uFBD9'] = '\u06C6';
  22436. t['\uFBDA'] = '\u06C6';
  22437. t['\uFBDB'] = '\u06C8';
  22438. t['\uFBDC'] = '\u06C8';
  22439. t['\uFBDD'] = '\u0677';
  22440. t['\uFBDE'] = '\u06CB';
  22441. t['\uFBDF'] = '\u06CB';
  22442. t['\uFBE0'] = '\u06C5';
  22443. t['\uFBE1'] = '\u06C5';
  22444. t['\uFBE2'] = '\u06C9';
  22445. t['\uFBE3'] = '\u06C9';
  22446. t['\uFBE4'] = '\u06D0';
  22447. t['\uFBE5'] = '\u06D0';
  22448. t['\uFBE6'] = '\u06D0';
  22449. t['\uFBE7'] = '\u06D0';
  22450. t['\uFBE8'] = '\u0649';
  22451. t['\uFBE9'] = '\u0649';
  22452. t['\uFBEA'] = '\u0626\u0627';
  22453. t['\uFBEB'] = '\u0626\u0627';
  22454. t['\uFBEC'] = '\u0626\u06D5';
  22455. t['\uFBED'] = '\u0626\u06D5';
  22456. t['\uFBEE'] = '\u0626\u0648';
  22457. t['\uFBEF'] = '\u0626\u0648';
  22458. t['\uFBF0'] = '\u0626\u06C7';
  22459. t['\uFBF1'] = '\u0626\u06C7';
  22460. t['\uFBF2'] = '\u0626\u06C6';
  22461. t['\uFBF3'] = '\u0626\u06C6';
  22462. t['\uFBF4'] = '\u0626\u06C8';
  22463. t['\uFBF5'] = '\u0626\u06C8';
  22464. t['\uFBF6'] = '\u0626\u06D0';
  22465. t['\uFBF7'] = '\u0626\u06D0';
  22466. t['\uFBF8'] = '\u0626\u06D0';
  22467. t['\uFBF9'] = '\u0626\u0649';
  22468. t['\uFBFA'] = '\u0626\u0649';
  22469. t['\uFBFB'] = '\u0626\u0649';
  22470. t['\uFBFC'] = '\u06CC';
  22471. t['\uFBFD'] = '\u06CC';
  22472. t['\uFBFE'] = '\u06CC';
  22473. t['\uFBFF'] = '\u06CC';
  22474. t['\uFC00'] = '\u0626\u062C';
  22475. t['\uFC01'] = '\u0626\u062D';
  22476. t['\uFC02'] = '\u0626\u0645';
  22477. t['\uFC03'] = '\u0626\u0649';
  22478. t['\uFC04'] = '\u0626\u064A';
  22479. t['\uFC05'] = '\u0628\u062C';
  22480. t['\uFC06'] = '\u0628\u062D';
  22481. t['\uFC07'] = '\u0628\u062E';
  22482. t['\uFC08'] = '\u0628\u0645';
  22483. t['\uFC09'] = '\u0628\u0649';
  22484. t['\uFC0A'] = '\u0628\u064A';
  22485. t['\uFC0B'] = '\u062A\u062C';
  22486. t['\uFC0C'] = '\u062A\u062D';
  22487. t['\uFC0D'] = '\u062A\u062E';
  22488. t['\uFC0E'] = '\u062A\u0645';
  22489. t['\uFC0F'] = '\u062A\u0649';
  22490. t['\uFC10'] = '\u062A\u064A';
  22491. t['\uFC11'] = '\u062B\u062C';
  22492. t['\uFC12'] = '\u062B\u0645';
  22493. t['\uFC13'] = '\u062B\u0649';
  22494. t['\uFC14'] = '\u062B\u064A';
  22495. t['\uFC15'] = '\u062C\u062D';
  22496. t['\uFC16'] = '\u062C\u0645';
  22497. t['\uFC17'] = '\u062D\u062C';
  22498. t['\uFC18'] = '\u062D\u0645';
  22499. t['\uFC19'] = '\u062E\u062C';
  22500. t['\uFC1A'] = '\u062E\u062D';
  22501. t['\uFC1B'] = '\u062E\u0645';
  22502. t['\uFC1C'] = '\u0633\u062C';
  22503. t['\uFC1D'] = '\u0633\u062D';
  22504. t['\uFC1E'] = '\u0633\u062E';
  22505. t['\uFC1F'] = '\u0633\u0645';
  22506. t['\uFC20'] = '\u0635\u062D';
  22507. t['\uFC21'] = '\u0635\u0645';
  22508. t['\uFC22'] = '\u0636\u062C';
  22509. t['\uFC23'] = '\u0636\u062D';
  22510. t['\uFC24'] = '\u0636\u062E';
  22511. t['\uFC25'] = '\u0636\u0645';
  22512. t['\uFC26'] = '\u0637\u062D';
  22513. t['\uFC27'] = '\u0637\u0645';
  22514. t['\uFC28'] = '\u0638\u0645';
  22515. t['\uFC29'] = '\u0639\u062C';
  22516. t['\uFC2A'] = '\u0639\u0645';
  22517. t['\uFC2B'] = '\u063A\u062C';
  22518. t['\uFC2C'] = '\u063A\u0645';
  22519. t['\uFC2D'] = '\u0641\u062C';
  22520. t['\uFC2E'] = '\u0641\u062D';
  22521. t['\uFC2F'] = '\u0641\u062E';
  22522. t['\uFC30'] = '\u0641\u0645';
  22523. t['\uFC31'] = '\u0641\u0649';
  22524. t['\uFC32'] = '\u0641\u064A';
  22525. t['\uFC33'] = '\u0642\u062D';
  22526. t['\uFC34'] = '\u0642\u0645';
  22527. t['\uFC35'] = '\u0642\u0649';
  22528. t['\uFC36'] = '\u0642\u064A';
  22529. t['\uFC37'] = '\u0643\u0627';
  22530. t['\uFC38'] = '\u0643\u062C';
  22531. t['\uFC39'] = '\u0643\u062D';
  22532. t['\uFC3A'] = '\u0643\u062E';
  22533. t['\uFC3B'] = '\u0643\u0644';
  22534. t['\uFC3C'] = '\u0643\u0645';
  22535. t['\uFC3D'] = '\u0643\u0649';
  22536. t['\uFC3E'] = '\u0643\u064A';
  22537. t['\uFC3F'] = '\u0644\u062C';
  22538. t['\uFC40'] = '\u0644\u062D';
  22539. t['\uFC41'] = '\u0644\u062E';
  22540. t['\uFC42'] = '\u0644\u0645';
  22541. t['\uFC43'] = '\u0644\u0649';
  22542. t['\uFC44'] = '\u0644\u064A';
  22543. t['\uFC45'] = '\u0645\u062C';
  22544. t['\uFC46'] = '\u0645\u062D';
  22545. t['\uFC47'] = '\u0645\u062E';
  22546. t['\uFC48'] = '\u0645\u0645';
  22547. t['\uFC49'] = '\u0645\u0649';
  22548. t['\uFC4A'] = '\u0645\u064A';
  22549. t['\uFC4B'] = '\u0646\u062C';
  22550. t['\uFC4C'] = '\u0646\u062D';
  22551. t['\uFC4D'] = '\u0646\u062E';
  22552. t['\uFC4E'] = '\u0646\u0645';
  22553. t['\uFC4F'] = '\u0646\u0649';
  22554. t['\uFC50'] = '\u0646\u064A';
  22555. t['\uFC51'] = '\u0647\u062C';
  22556. t['\uFC52'] = '\u0647\u0645';
  22557. t['\uFC53'] = '\u0647\u0649';
  22558. t['\uFC54'] = '\u0647\u064A';
  22559. t['\uFC55'] = '\u064A\u062C';
  22560. t['\uFC56'] = '\u064A\u062D';
  22561. t['\uFC57'] = '\u064A\u062E';
  22562. t['\uFC58'] = '\u064A\u0645';
  22563. t['\uFC59'] = '\u064A\u0649';
  22564. t['\uFC5A'] = '\u064A\u064A';
  22565. t['\uFC5B'] = '\u0630\u0670';
  22566. t['\uFC5C'] = '\u0631\u0670';
  22567. t['\uFC5D'] = '\u0649\u0670';
  22568. t['\uFC5E'] = '\u0020\u064C\u0651';
  22569. t['\uFC5F'] = '\u0020\u064D\u0651';
  22570. t['\uFC60'] = '\u0020\u064E\u0651';
  22571. t['\uFC61'] = '\u0020\u064F\u0651';
  22572. t['\uFC62'] = '\u0020\u0650\u0651';
  22573. t['\uFC63'] = '\u0020\u0651\u0670';
  22574. t['\uFC64'] = '\u0626\u0631';
  22575. t['\uFC65'] = '\u0626\u0632';
  22576. t['\uFC66'] = '\u0626\u0645';
  22577. t['\uFC67'] = '\u0626\u0646';
  22578. t['\uFC68'] = '\u0626\u0649';
  22579. t['\uFC69'] = '\u0626\u064A';
  22580. t['\uFC6A'] = '\u0628\u0631';
  22581. t['\uFC6B'] = '\u0628\u0632';
  22582. t['\uFC6C'] = '\u0628\u0645';
  22583. t['\uFC6D'] = '\u0628\u0646';
  22584. t['\uFC6E'] = '\u0628\u0649';
  22585. t['\uFC6F'] = '\u0628\u064A';
  22586. t['\uFC70'] = '\u062A\u0631';
  22587. t['\uFC71'] = '\u062A\u0632';
  22588. t['\uFC72'] = '\u062A\u0645';
  22589. t['\uFC73'] = '\u062A\u0646';
  22590. t['\uFC74'] = '\u062A\u0649';
  22591. t['\uFC75'] = '\u062A\u064A';
  22592. t['\uFC76'] = '\u062B\u0631';
  22593. t['\uFC77'] = '\u062B\u0632';
  22594. t['\uFC78'] = '\u062B\u0645';
  22595. t['\uFC79'] = '\u062B\u0646';
  22596. t['\uFC7A'] = '\u062B\u0649';
  22597. t['\uFC7B'] = '\u062B\u064A';
  22598. t['\uFC7C'] = '\u0641\u0649';
  22599. t['\uFC7D'] = '\u0641\u064A';
  22600. t['\uFC7E'] = '\u0642\u0649';
  22601. t['\uFC7F'] = '\u0642\u064A';
  22602. t['\uFC80'] = '\u0643\u0627';
  22603. t['\uFC81'] = '\u0643\u0644';
  22604. t['\uFC82'] = '\u0643\u0645';
  22605. t['\uFC83'] = '\u0643\u0649';
  22606. t['\uFC84'] = '\u0643\u064A';
  22607. t['\uFC85'] = '\u0644\u0645';
  22608. t['\uFC86'] = '\u0644\u0649';
  22609. t['\uFC87'] = '\u0644\u064A';
  22610. t['\uFC88'] = '\u0645\u0627';
  22611. t['\uFC89'] = '\u0645\u0645';
  22612. t['\uFC8A'] = '\u0646\u0631';
  22613. t['\uFC8B'] = '\u0646\u0632';
  22614. t['\uFC8C'] = '\u0646\u0645';
  22615. t['\uFC8D'] = '\u0646\u0646';
  22616. t['\uFC8E'] = '\u0646\u0649';
  22617. t['\uFC8F'] = '\u0646\u064A';
  22618. t['\uFC90'] = '\u0649\u0670';
  22619. t['\uFC91'] = '\u064A\u0631';
  22620. t['\uFC92'] = '\u064A\u0632';
  22621. t['\uFC93'] = '\u064A\u0645';
  22622. t['\uFC94'] = '\u064A\u0646';
  22623. t['\uFC95'] = '\u064A\u0649';
  22624. t['\uFC96'] = '\u064A\u064A';
  22625. t['\uFC97'] = '\u0626\u062C';
  22626. t['\uFC98'] = '\u0626\u062D';
  22627. t['\uFC99'] = '\u0626\u062E';
  22628. t['\uFC9A'] = '\u0626\u0645';
  22629. t['\uFC9B'] = '\u0626\u0647';
  22630. t['\uFC9C'] = '\u0628\u062C';
  22631. t['\uFC9D'] = '\u0628\u062D';
  22632. t['\uFC9E'] = '\u0628\u062E';
  22633. t['\uFC9F'] = '\u0628\u0645';
  22634. t['\uFCA0'] = '\u0628\u0647';
  22635. t['\uFCA1'] = '\u062A\u062C';
  22636. t['\uFCA2'] = '\u062A\u062D';
  22637. t['\uFCA3'] = '\u062A\u062E';
  22638. t['\uFCA4'] = '\u062A\u0645';
  22639. t['\uFCA5'] = '\u062A\u0647';
  22640. t['\uFCA6'] = '\u062B\u0645';
  22641. t['\uFCA7'] = '\u062C\u062D';
  22642. t['\uFCA8'] = '\u062C\u0645';
  22643. t['\uFCA9'] = '\u062D\u062C';
  22644. t['\uFCAA'] = '\u062D\u0645';
  22645. t['\uFCAB'] = '\u062E\u062C';
  22646. t['\uFCAC'] = '\u062E\u0645';
  22647. t['\uFCAD'] = '\u0633\u062C';
  22648. t['\uFCAE'] = '\u0633\u062D';
  22649. t['\uFCAF'] = '\u0633\u062E';
  22650. t['\uFCB0'] = '\u0633\u0645';
  22651. t['\uFCB1'] = '\u0635\u062D';
  22652. t['\uFCB2'] = '\u0635\u062E';
  22653. t['\uFCB3'] = '\u0635\u0645';
  22654. t['\uFCB4'] = '\u0636\u062C';
  22655. t['\uFCB5'] = '\u0636\u062D';
  22656. t['\uFCB6'] = '\u0636\u062E';
  22657. t['\uFCB7'] = '\u0636\u0645';
  22658. t['\uFCB8'] = '\u0637\u062D';
  22659. t['\uFCB9'] = '\u0638\u0645';
  22660. t['\uFCBA'] = '\u0639\u062C';
  22661. t['\uFCBB'] = '\u0639\u0645';
  22662. t['\uFCBC'] = '\u063A\u062C';
  22663. t['\uFCBD'] = '\u063A\u0645';
  22664. t['\uFCBE'] = '\u0641\u062C';
  22665. t['\uFCBF'] = '\u0641\u062D';
  22666. t['\uFCC0'] = '\u0641\u062E';
  22667. t['\uFCC1'] = '\u0641\u0645';
  22668. t['\uFCC2'] = '\u0642\u062D';
  22669. t['\uFCC3'] = '\u0642\u0645';
  22670. t['\uFCC4'] = '\u0643\u062C';
  22671. t['\uFCC5'] = '\u0643\u062D';
  22672. t['\uFCC6'] = '\u0643\u062E';
  22673. t['\uFCC7'] = '\u0643\u0644';
  22674. t['\uFCC8'] = '\u0643\u0645';
  22675. t['\uFCC9'] = '\u0644\u062C';
  22676. t['\uFCCA'] = '\u0644\u062D';
  22677. t['\uFCCB'] = '\u0644\u062E';
  22678. t['\uFCCC'] = '\u0644\u0645';
  22679. t['\uFCCD'] = '\u0644\u0647';
  22680. t['\uFCCE'] = '\u0645\u062C';
  22681. t['\uFCCF'] = '\u0645\u062D';
  22682. t['\uFCD0'] = '\u0645\u062E';
  22683. t['\uFCD1'] = '\u0645\u0645';
  22684. t['\uFCD2'] = '\u0646\u062C';
  22685. t['\uFCD3'] = '\u0646\u062D';
  22686. t['\uFCD4'] = '\u0646\u062E';
  22687. t['\uFCD5'] = '\u0646\u0645';
  22688. t['\uFCD6'] = '\u0646\u0647';
  22689. t['\uFCD7'] = '\u0647\u062C';
  22690. t['\uFCD8'] = '\u0647\u0645';
  22691. t['\uFCD9'] = '\u0647\u0670';
  22692. t['\uFCDA'] = '\u064A\u062C';
  22693. t['\uFCDB'] = '\u064A\u062D';
  22694. t['\uFCDC'] = '\u064A\u062E';
  22695. t['\uFCDD'] = '\u064A\u0645';
  22696. t['\uFCDE'] = '\u064A\u0647';
  22697. t['\uFCDF'] = '\u0626\u0645';
  22698. t['\uFCE0'] = '\u0626\u0647';
  22699. t['\uFCE1'] = '\u0628\u0645';
  22700. t['\uFCE2'] = '\u0628\u0647';
  22701. t['\uFCE3'] = '\u062A\u0645';
  22702. t['\uFCE4'] = '\u062A\u0647';
  22703. t['\uFCE5'] = '\u062B\u0645';
  22704. t['\uFCE6'] = '\u062B\u0647';
  22705. t['\uFCE7'] = '\u0633\u0645';
  22706. t['\uFCE8'] = '\u0633\u0647';
  22707. t['\uFCE9'] = '\u0634\u0645';
  22708. t['\uFCEA'] = '\u0634\u0647';
  22709. t['\uFCEB'] = '\u0643\u0644';
  22710. t['\uFCEC'] = '\u0643\u0645';
  22711. t['\uFCED'] = '\u0644\u0645';
  22712. t['\uFCEE'] = '\u0646\u0645';
  22713. t['\uFCEF'] = '\u0646\u0647';
  22714. t['\uFCF0'] = '\u064A\u0645';
  22715. t['\uFCF1'] = '\u064A\u0647';
  22716. t['\uFCF2'] = '\u0640\u064E\u0651';
  22717. t['\uFCF3'] = '\u0640\u064F\u0651';
  22718. t['\uFCF4'] = '\u0640\u0650\u0651';
  22719. t['\uFCF5'] = '\u0637\u0649';
  22720. t['\uFCF6'] = '\u0637\u064A';
  22721. t['\uFCF7'] = '\u0639\u0649';
  22722. t['\uFCF8'] = '\u0639\u064A';
  22723. t['\uFCF9'] = '\u063A\u0649';
  22724. t['\uFCFA'] = '\u063A\u064A';
  22725. t['\uFCFB'] = '\u0633\u0649';
  22726. t['\uFCFC'] = '\u0633\u064A';
  22727. t['\uFCFD'] = '\u0634\u0649';
  22728. t['\uFCFE'] = '\u0634\u064A';
  22729. t['\uFCFF'] = '\u062D\u0649';
  22730. t['\uFD00'] = '\u062D\u064A';
  22731. t['\uFD01'] = '\u062C\u0649';
  22732. t['\uFD02'] = '\u062C\u064A';
  22733. t['\uFD03'] = '\u062E\u0649';
  22734. t['\uFD04'] = '\u062E\u064A';
  22735. t['\uFD05'] = '\u0635\u0649';
  22736. t['\uFD06'] = '\u0635\u064A';
  22737. t['\uFD07'] = '\u0636\u0649';
  22738. t['\uFD08'] = '\u0636\u064A';
  22739. t['\uFD09'] = '\u0634\u062C';
  22740. t['\uFD0A'] = '\u0634\u062D';
  22741. t['\uFD0B'] = '\u0634\u062E';
  22742. t['\uFD0C'] = '\u0634\u0645';
  22743. t['\uFD0D'] = '\u0634\u0631';
  22744. t['\uFD0E'] = '\u0633\u0631';
  22745. t['\uFD0F'] = '\u0635\u0631';
  22746. t['\uFD10'] = '\u0636\u0631';
  22747. t['\uFD11'] = '\u0637\u0649';
  22748. t['\uFD12'] = '\u0637\u064A';
  22749. t['\uFD13'] = '\u0639\u0649';
  22750. t['\uFD14'] = '\u0639\u064A';
  22751. t['\uFD15'] = '\u063A\u0649';
  22752. t['\uFD16'] = '\u063A\u064A';
  22753. t['\uFD17'] = '\u0633\u0649';
  22754. t['\uFD18'] = '\u0633\u064A';
  22755. t['\uFD19'] = '\u0634\u0649';
  22756. t['\uFD1A'] = '\u0634\u064A';
  22757. t['\uFD1B'] = '\u062D\u0649';
  22758. t['\uFD1C'] = '\u062D\u064A';
  22759. t['\uFD1D'] = '\u062C\u0649';
  22760. t['\uFD1E'] = '\u062C\u064A';
  22761. t['\uFD1F'] = '\u062E\u0649';
  22762. t['\uFD20'] = '\u062E\u064A';
  22763. t['\uFD21'] = '\u0635\u0649';
  22764. t['\uFD22'] = '\u0635\u064A';
  22765. t['\uFD23'] = '\u0636\u0649';
  22766. t['\uFD24'] = '\u0636\u064A';
  22767. t['\uFD25'] = '\u0634\u062C';
  22768. t['\uFD26'] = '\u0634\u062D';
  22769. t['\uFD27'] = '\u0634\u062E';
  22770. t['\uFD28'] = '\u0634\u0645';
  22771. t['\uFD29'] = '\u0634\u0631';
  22772. t['\uFD2A'] = '\u0633\u0631';
  22773. t['\uFD2B'] = '\u0635\u0631';
  22774. t['\uFD2C'] = '\u0636\u0631';
  22775. t['\uFD2D'] = '\u0634\u062C';
  22776. t['\uFD2E'] = '\u0634\u062D';
  22777. t['\uFD2F'] = '\u0634\u062E';
  22778. t['\uFD30'] = '\u0634\u0645';
  22779. t['\uFD31'] = '\u0633\u0647';
  22780. t['\uFD32'] = '\u0634\u0647';
  22781. t['\uFD33'] = '\u0637\u0645';
  22782. t['\uFD34'] = '\u0633\u062C';
  22783. t['\uFD35'] = '\u0633\u062D';
  22784. t['\uFD36'] = '\u0633\u062E';
  22785. t['\uFD37'] = '\u0634\u062C';
  22786. t['\uFD38'] = '\u0634\u062D';
  22787. t['\uFD39'] = '\u0634\u062E';
  22788. t['\uFD3A'] = '\u0637\u0645';
  22789. t['\uFD3B'] = '\u0638\u0645';
  22790. t['\uFD3C'] = '\u0627\u064B';
  22791. t['\uFD3D'] = '\u0627\u064B';
  22792. t['\uFD50'] = '\u062A\u062C\u0645';
  22793. t['\uFD51'] = '\u062A\u062D\u062C';
  22794. t['\uFD52'] = '\u062A\u062D\u062C';
  22795. t['\uFD53'] = '\u062A\u062D\u0645';
  22796. t['\uFD54'] = '\u062A\u062E\u0645';
  22797. t['\uFD55'] = '\u062A\u0645\u062C';
  22798. t['\uFD56'] = '\u062A\u0645\u062D';
  22799. t['\uFD57'] = '\u062A\u0645\u062E';
  22800. t['\uFD58'] = '\u062C\u0645\u062D';
  22801. t['\uFD59'] = '\u062C\u0645\u062D';
  22802. t['\uFD5A'] = '\u062D\u0645\u064A';
  22803. t['\uFD5B'] = '\u062D\u0645\u0649';
  22804. t['\uFD5C'] = '\u0633\u062D\u062C';
  22805. t['\uFD5D'] = '\u0633\u062C\u062D';
  22806. t['\uFD5E'] = '\u0633\u062C\u0649';
  22807. t['\uFD5F'] = '\u0633\u0645\u062D';
  22808. t['\uFD60'] = '\u0633\u0645\u062D';
  22809. t['\uFD61'] = '\u0633\u0645\u062C';
  22810. t['\uFD62'] = '\u0633\u0645\u0645';
  22811. t['\uFD63'] = '\u0633\u0645\u0645';
  22812. t['\uFD64'] = '\u0635\u062D\u062D';
  22813. t['\uFD65'] = '\u0635\u062D\u062D';
  22814. t['\uFD66'] = '\u0635\u0645\u0645';
  22815. t['\uFD67'] = '\u0634\u062D\u0645';
  22816. t['\uFD68'] = '\u0634\u062D\u0645';
  22817. t['\uFD69'] = '\u0634\u062C\u064A';
  22818. t['\uFD6A'] = '\u0634\u0645\u062E';
  22819. t['\uFD6B'] = '\u0634\u0645\u062E';
  22820. t['\uFD6C'] = '\u0634\u0645\u0645';
  22821. t['\uFD6D'] = '\u0634\u0645\u0645';
  22822. t['\uFD6E'] = '\u0636\u062D\u0649';
  22823. t['\uFD6F'] = '\u0636\u062E\u0645';
  22824. t['\uFD70'] = '\u0636\u062E\u0645';
  22825. t['\uFD71'] = '\u0637\u0645\u062D';
  22826. t['\uFD72'] = '\u0637\u0645\u062D';
  22827. t['\uFD73'] = '\u0637\u0645\u0645';
  22828. t['\uFD74'] = '\u0637\u0645\u064A';
  22829. t['\uFD75'] = '\u0639\u062C\u0645';
  22830. t['\uFD76'] = '\u0639\u0645\u0645';
  22831. t['\uFD77'] = '\u0639\u0645\u0645';
  22832. t['\uFD78'] = '\u0639\u0645\u0649';
  22833. t['\uFD79'] = '\u063A\u0645\u0645';
  22834. t['\uFD7A'] = '\u063A\u0645\u064A';
  22835. t['\uFD7B'] = '\u063A\u0645\u0649';
  22836. t['\uFD7C'] = '\u0641\u062E\u0645';
  22837. t['\uFD7D'] = '\u0641\u062E\u0645';
  22838. t['\uFD7E'] = '\u0642\u0645\u062D';
  22839. t['\uFD7F'] = '\u0642\u0645\u0645';
  22840. t['\uFD80'] = '\u0644\u062D\u0645';
  22841. t['\uFD81'] = '\u0644\u062D\u064A';
  22842. t['\uFD82'] = '\u0644\u062D\u0649';
  22843. t['\uFD83'] = '\u0644\u062C\u062C';
  22844. t['\uFD84'] = '\u0644\u062C\u062C';
  22845. t['\uFD85'] = '\u0644\u062E\u0645';
  22846. t['\uFD86'] = '\u0644\u062E\u0645';
  22847. t['\uFD87'] = '\u0644\u0645\u062D';
  22848. t['\uFD88'] = '\u0644\u0645\u062D';
  22849. t['\uFD89'] = '\u0645\u062D\u062C';
  22850. t['\uFD8A'] = '\u0645\u062D\u0645';
  22851. t['\uFD8B'] = '\u0645\u062D\u064A';
  22852. t['\uFD8C'] = '\u0645\u062C\u062D';
  22853. t['\uFD8D'] = '\u0645\u062C\u0645';
  22854. t['\uFD8E'] = '\u0645\u062E\u062C';
  22855. t['\uFD8F'] = '\u0645\u062E\u0645';
  22856. t['\uFD92'] = '\u0645\u062C\u062E';
  22857. t['\uFD93'] = '\u0647\u0645\u062C';
  22858. t['\uFD94'] = '\u0647\u0645\u0645';
  22859. t['\uFD95'] = '\u0646\u062D\u0645';
  22860. t['\uFD96'] = '\u0646\u062D\u0649';
  22861. t['\uFD97'] = '\u0646\u062C\u0645';
  22862. t['\uFD98'] = '\u0646\u062C\u0645';
  22863. t['\uFD99'] = '\u0646\u062C\u0649';
  22864. t['\uFD9A'] = '\u0646\u0645\u064A';
  22865. t['\uFD9B'] = '\u0646\u0645\u0649';
  22866. t['\uFD9C'] = '\u064A\u0645\u0645';
  22867. t['\uFD9D'] = '\u064A\u0645\u0645';
  22868. t['\uFD9E'] = '\u0628\u062E\u064A';
  22869. t['\uFD9F'] = '\u062A\u062C\u064A';
  22870. t['\uFDA0'] = '\u062A\u062C\u0649';
  22871. t['\uFDA1'] = '\u062A\u062E\u064A';
  22872. t['\uFDA2'] = '\u062A\u062E\u0649';
  22873. t['\uFDA3'] = '\u062A\u0645\u064A';
  22874. t['\uFDA4'] = '\u062A\u0645\u0649';
  22875. t['\uFDA5'] = '\u062C\u0645\u064A';
  22876. t['\uFDA6'] = '\u062C\u062D\u0649';
  22877. t['\uFDA7'] = '\u062C\u0645\u0649';
  22878. t['\uFDA8'] = '\u0633\u062E\u0649';
  22879. t['\uFDA9'] = '\u0635\u062D\u064A';
  22880. t['\uFDAA'] = '\u0634\u062D\u064A';
  22881. t['\uFDAB'] = '\u0636\u062D\u064A';
  22882. t['\uFDAC'] = '\u0644\u062C\u064A';
  22883. t['\uFDAD'] = '\u0644\u0645\u064A';
  22884. t['\uFDAE'] = '\u064A\u062D\u064A';
  22885. t['\uFDAF'] = '\u064A\u062C\u064A';
  22886. t['\uFDB0'] = '\u064A\u0645\u064A';
  22887. t['\uFDB1'] = '\u0645\u0645\u064A';
  22888. t['\uFDB2'] = '\u0642\u0645\u064A';
  22889. t['\uFDB3'] = '\u0646\u062D\u064A';
  22890. t['\uFDB4'] = '\u0642\u0645\u062D';
  22891. t['\uFDB5'] = '\u0644\u062D\u0645';
  22892. t['\uFDB6'] = '\u0639\u0645\u064A';
  22893. t['\uFDB7'] = '\u0643\u0645\u064A';
  22894. t['\uFDB8'] = '\u0646\u062C\u062D';
  22895. t['\uFDB9'] = '\u0645\u062E\u064A';
  22896. t['\uFDBA'] = '\u0644\u062C\u0645';
  22897. t['\uFDBB'] = '\u0643\u0645\u0645';
  22898. t['\uFDBC'] = '\u0644\u062C\u0645';
  22899. t['\uFDBD'] = '\u0646\u062C\u062D';
  22900. t['\uFDBE'] = '\u062C\u062D\u064A';
  22901. t['\uFDBF'] = '\u062D\u062C\u064A';
  22902. t['\uFDC0'] = '\u0645\u062C\u064A';
  22903. t['\uFDC1'] = '\u0641\u0645\u064A';
  22904. t['\uFDC2'] = '\u0628\u062D\u064A';
  22905. t['\uFDC3'] = '\u0643\u0645\u0645';
  22906. t['\uFDC4'] = '\u0639\u062C\u0645';
  22907. t['\uFDC5'] = '\u0635\u0645\u0645';
  22908. t['\uFDC6'] = '\u0633\u062E\u064A';
  22909. t['\uFDC7'] = '\u0646\u062C\u064A';
  22910. t['\uFE49'] = '\u203E';
  22911. t['\uFE4A'] = '\u203E';
  22912. t['\uFE4B'] = '\u203E';
  22913. t['\uFE4C'] = '\u203E';
  22914. t['\uFE4D'] = '\u005F';
  22915. t['\uFE4E'] = '\u005F';
  22916. t['\uFE4F'] = '\u005F';
  22917. t['\uFE80'] = '\u0621';
  22918. t['\uFE81'] = '\u0622';
  22919. t['\uFE82'] = '\u0622';
  22920. t['\uFE83'] = '\u0623';
  22921. t['\uFE84'] = '\u0623';
  22922. t['\uFE85'] = '\u0624';
  22923. t['\uFE86'] = '\u0624';
  22924. t['\uFE87'] = '\u0625';
  22925. t['\uFE88'] = '\u0625';
  22926. t['\uFE89'] = '\u0626';
  22927. t['\uFE8A'] = '\u0626';
  22928. t['\uFE8B'] = '\u0626';
  22929. t['\uFE8C'] = '\u0626';
  22930. t['\uFE8D'] = '\u0627';
  22931. t['\uFE8E'] = '\u0627';
  22932. t['\uFE8F'] = '\u0628';
  22933. t['\uFE90'] = '\u0628';
  22934. t['\uFE91'] = '\u0628';
  22935. t['\uFE92'] = '\u0628';
  22936. t['\uFE93'] = '\u0629';
  22937. t['\uFE94'] = '\u0629';
  22938. t['\uFE95'] = '\u062A';
  22939. t['\uFE96'] = '\u062A';
  22940. t['\uFE97'] = '\u062A';
  22941. t['\uFE98'] = '\u062A';
  22942. t['\uFE99'] = '\u062B';
  22943. t['\uFE9A'] = '\u062B';
  22944. t['\uFE9B'] = '\u062B';
  22945. t['\uFE9C'] = '\u062B';
  22946. t['\uFE9D'] = '\u062C';
  22947. t['\uFE9E'] = '\u062C';
  22948. t['\uFE9F'] = '\u062C';
  22949. t['\uFEA0'] = '\u062C';
  22950. t['\uFEA1'] = '\u062D';
  22951. t['\uFEA2'] = '\u062D';
  22952. t['\uFEA3'] = '\u062D';
  22953. t['\uFEA4'] = '\u062D';
  22954. t['\uFEA5'] = '\u062E';
  22955. t['\uFEA6'] = '\u062E';
  22956. t['\uFEA7'] = '\u062E';
  22957. t['\uFEA8'] = '\u062E';
  22958. t['\uFEA9'] = '\u062F';
  22959. t['\uFEAA'] = '\u062F';
  22960. t['\uFEAB'] = '\u0630';
  22961. t['\uFEAC'] = '\u0630';
  22962. t['\uFEAD'] = '\u0631';
  22963. t['\uFEAE'] = '\u0631';
  22964. t['\uFEAF'] = '\u0632';
  22965. t['\uFEB0'] = '\u0632';
  22966. t['\uFEB1'] = '\u0633';
  22967. t['\uFEB2'] = '\u0633';
  22968. t['\uFEB3'] = '\u0633';
  22969. t['\uFEB4'] = '\u0633';
  22970. t['\uFEB5'] = '\u0634';
  22971. t['\uFEB6'] = '\u0634';
  22972. t['\uFEB7'] = '\u0634';
  22973. t['\uFEB8'] = '\u0634';
  22974. t['\uFEB9'] = '\u0635';
  22975. t['\uFEBA'] = '\u0635';
  22976. t['\uFEBB'] = '\u0635';
  22977. t['\uFEBC'] = '\u0635';
  22978. t['\uFEBD'] = '\u0636';
  22979. t['\uFEBE'] = '\u0636';
  22980. t['\uFEBF'] = '\u0636';
  22981. t['\uFEC0'] = '\u0636';
  22982. t['\uFEC1'] = '\u0637';
  22983. t['\uFEC2'] = '\u0637';
  22984. t['\uFEC3'] = '\u0637';
  22985. t['\uFEC4'] = '\u0637';
  22986. t['\uFEC5'] = '\u0638';
  22987. t['\uFEC6'] = '\u0638';
  22988. t['\uFEC7'] = '\u0638';
  22989. t['\uFEC8'] = '\u0638';
  22990. t['\uFEC9'] = '\u0639';
  22991. t['\uFECA'] = '\u0639';
  22992. t['\uFECB'] = '\u0639';
  22993. t['\uFECC'] = '\u0639';
  22994. t['\uFECD'] = '\u063A';
  22995. t['\uFECE'] = '\u063A';
  22996. t['\uFECF'] = '\u063A';
  22997. t['\uFED0'] = '\u063A';
  22998. t['\uFED1'] = '\u0641';
  22999. t['\uFED2'] = '\u0641';
  23000. t['\uFED3'] = '\u0641';
  23001. t['\uFED4'] = '\u0641';
  23002. t['\uFED5'] = '\u0642';
  23003. t['\uFED6'] = '\u0642';
  23004. t['\uFED7'] = '\u0642';
  23005. t['\uFED8'] = '\u0642';
  23006. t['\uFED9'] = '\u0643';
  23007. t['\uFEDA'] = '\u0643';
  23008. t['\uFEDB'] = '\u0643';
  23009. t['\uFEDC'] = '\u0643';
  23010. t['\uFEDD'] = '\u0644';
  23011. t['\uFEDE'] = '\u0644';
  23012. t['\uFEDF'] = '\u0644';
  23013. t['\uFEE0'] = '\u0644';
  23014. t['\uFEE1'] = '\u0645';
  23015. t['\uFEE2'] = '\u0645';
  23016. t['\uFEE3'] = '\u0645';
  23017. t['\uFEE4'] = '\u0645';
  23018. t['\uFEE5'] = '\u0646';
  23019. t['\uFEE6'] = '\u0646';
  23020. t['\uFEE7'] = '\u0646';
  23021. t['\uFEE8'] = '\u0646';
  23022. t['\uFEE9'] = '\u0647';
  23023. t['\uFEEA'] = '\u0647';
  23024. t['\uFEEB'] = '\u0647';
  23025. t['\uFEEC'] = '\u0647';
  23026. t['\uFEED'] = '\u0648';
  23027. t['\uFEEE'] = '\u0648';
  23028. t['\uFEEF'] = '\u0649';
  23029. t['\uFEF0'] = '\u0649';
  23030. t['\uFEF1'] = '\u064A';
  23031. t['\uFEF2'] = '\u064A';
  23032. t['\uFEF3'] = '\u064A';
  23033. t['\uFEF4'] = '\u064A';
  23034. t['\uFEF5'] = '\u0644\u0622';
  23035. t['\uFEF6'] = '\u0644\u0622';
  23036. t['\uFEF7'] = '\u0644\u0623';
  23037. t['\uFEF8'] = '\u0644\u0623';
  23038. t['\uFEF9'] = '\u0644\u0625';
  23039. t['\uFEFA'] = '\u0644\u0625';
  23040. t['\uFEFB'] = '\u0644\u0627';
  23041. t['\uFEFC'] = '\u0644\u0627';
  23042. });
  23043. function reverseIfRtl(chars) {
  23044. var charsLength = chars.length;
  23045. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23046. return chars;
  23047. }
  23048. var s = '';
  23049. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23050. s += chars[ii];
  23051. }
  23052. return s;
  23053. }
  23054. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23055. exports.reverseIfRtl = reverseIfRtl;
  23056. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23057. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23058. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23059. }));
  23060. (function (root, factory) {
  23061. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23062. }(this, function (exports, sharedUtil) {
  23063. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23064. var warn = sharedUtil.warn;
  23065. var deprecated = sharedUtil.deprecated;
  23066. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23067. var CustomStyle = function CustomStyleClosure() {
  23068. var prefixes = [
  23069. 'ms',
  23070. 'Moz',
  23071. 'Webkit',
  23072. 'O'
  23073. ];
  23074. var _cache = Object.create(null);
  23075. function CustomStyle() {
  23076. }
  23077. CustomStyle.getProp = function get(propName, element) {
  23078. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23079. return _cache[propName];
  23080. }
  23081. element = element || document.documentElement;
  23082. var style = element.style, prefixed, uPropName;
  23083. if (typeof style[propName] === 'string') {
  23084. return _cache[propName] = propName;
  23085. }
  23086. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23087. for (var i = 0, l = prefixes.length; i < l; i++) {
  23088. prefixed = prefixes[i] + uPropName;
  23089. if (typeof style[prefixed] === 'string') {
  23090. return _cache[propName] = prefixed;
  23091. }
  23092. }
  23093. return _cache[propName] = 'undefined';
  23094. };
  23095. CustomStyle.setProp = function set(propName, element, str) {
  23096. var prop = this.getProp(propName);
  23097. if (prop !== 'undefined') {
  23098. element.style[prop] = str;
  23099. }
  23100. };
  23101. return CustomStyle;
  23102. }();
  23103. var hasCanvasTypedArrays;
  23104. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23105. var canvas = document.createElement('canvas');
  23106. canvas.width = canvas.height = 1;
  23107. var ctx = canvas.getContext('2d');
  23108. var imageData = ctx.createImageData(1, 1);
  23109. return typeof imageData.data.buffer !== 'undefined';
  23110. };
  23111. var LinkTarget = {
  23112. NONE: 0,
  23113. SELF: 1,
  23114. BLANK: 2,
  23115. PARENT: 3,
  23116. TOP: 4
  23117. };
  23118. var LinkTargetStringMap = [
  23119. '',
  23120. '_self',
  23121. '_blank',
  23122. '_parent',
  23123. '_top'
  23124. ];
  23125. function addLinkAttributes(link, params) {
  23126. var url = params && params.url;
  23127. link.href = link.title = url ? removeNullCharacters(url) : '';
  23128. if (url) {
  23129. var target = params.target;
  23130. if (typeof target === 'undefined') {
  23131. target = getDefaultSetting('externalLinkTarget');
  23132. }
  23133. link.target = LinkTargetStringMap[target];
  23134. var rel = params.rel;
  23135. if (typeof rel === 'undefined') {
  23136. rel = getDefaultSetting('externalLinkRel');
  23137. }
  23138. link.rel = rel;
  23139. }
  23140. }
  23141. function getFilenameFromUrl(url) {
  23142. var anchor = url.indexOf('#');
  23143. var query = url.indexOf('?');
  23144. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23145. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23146. }
  23147. function getDefaultSetting(id) {
  23148. var globalSettings = sharedUtil.globalScope.PDFJS;
  23149. switch (id) {
  23150. case 'pdfBug':
  23151. return globalSettings ? globalSettings.pdfBug : false;
  23152. case 'disableAutoFetch':
  23153. return globalSettings ? globalSettings.disableAutoFetch : false;
  23154. case 'disableStream':
  23155. return globalSettings ? globalSettings.disableStream : false;
  23156. case 'disableRange':
  23157. return globalSettings ? globalSettings.disableRange : false;
  23158. case 'disableFontFace':
  23159. return globalSettings ? globalSettings.disableFontFace : false;
  23160. case 'disableCreateObjectURL':
  23161. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23162. case 'disableWebGL':
  23163. return globalSettings ? globalSettings.disableWebGL : true;
  23164. case 'cMapUrl':
  23165. return globalSettings ? globalSettings.cMapUrl : null;
  23166. case 'cMapPacked':
  23167. return globalSettings ? globalSettings.cMapPacked : false;
  23168. case 'postMessageTransfers':
  23169. return globalSettings ? globalSettings.postMessageTransfers : true;
  23170. case 'workerSrc':
  23171. return globalSettings ? globalSettings.workerSrc : null;
  23172. case 'disableWorker':
  23173. return globalSettings ? globalSettings.disableWorker : false;
  23174. case 'maxImageSize':
  23175. return globalSettings ? globalSettings.maxImageSize : -1;
  23176. case 'imageResourcesPath':
  23177. return globalSettings ? globalSettings.imageResourcesPath : '';
  23178. case 'isEvalSupported':
  23179. return globalSettings ? globalSettings.isEvalSupported : true;
  23180. case 'externalLinkTarget':
  23181. if (!globalSettings) {
  23182. return LinkTarget.NONE;
  23183. }
  23184. switch (globalSettings.externalLinkTarget) {
  23185. case LinkTarget.NONE:
  23186. case LinkTarget.SELF:
  23187. case LinkTarget.BLANK:
  23188. case LinkTarget.PARENT:
  23189. case LinkTarget.TOP:
  23190. return globalSettings.externalLinkTarget;
  23191. }
  23192. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23193. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23194. return LinkTarget.NONE;
  23195. case 'externalLinkRel':
  23196. return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
  23197. case 'enableStats':
  23198. return !!(globalSettings && globalSettings.enableStats);
  23199. default:
  23200. throw new Error('Unknown default setting: ' + id);
  23201. }
  23202. }
  23203. function isExternalLinkTargetSet() {
  23204. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23205. switch (externalLinkTarget) {
  23206. case LinkTarget.NONE:
  23207. return false;
  23208. case LinkTarget.SELF:
  23209. case LinkTarget.BLANK:
  23210. case LinkTarget.PARENT:
  23211. case LinkTarget.TOP:
  23212. return true;
  23213. }
  23214. }
  23215. function isValidUrl(url, allowRelative) {
  23216. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23217. var baseUrl = allowRelative ? 'http://example.com' : null;
  23218. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23219. }
  23220. exports.CustomStyle = CustomStyle;
  23221. exports.addLinkAttributes = addLinkAttributes;
  23222. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23223. exports.isValidUrl = isValidUrl;
  23224. exports.getFilenameFromUrl = getFilenameFromUrl;
  23225. exports.LinkTarget = LinkTarget;
  23226. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23227. exports.getDefaultSetting = getDefaultSetting;
  23228. }));
  23229. (function (root, factory) {
  23230. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23231. }(this, function (exports, sharedUtil) {
  23232. var assert = sharedUtil.assert;
  23233. var bytesToString = sharedUtil.bytesToString;
  23234. var string32 = sharedUtil.string32;
  23235. var shadow = sharedUtil.shadow;
  23236. var warn = sharedUtil.warn;
  23237. function FontLoader(docId) {
  23238. this.docId = docId;
  23239. this.styleElement = null;
  23240. this.nativeFontFaces = [];
  23241. this.loadTestFontId = 0;
  23242. this.loadingContext = {
  23243. requests: [],
  23244. nextRequestId: 0
  23245. };
  23246. }
  23247. FontLoader.prototype = {
  23248. insertRule: function fontLoaderInsertRule(rule) {
  23249. var styleElement = this.styleElement;
  23250. if (!styleElement) {
  23251. styleElement = this.styleElement = document.createElement('style');
  23252. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23253. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23254. }
  23255. var styleSheet = styleElement.sheet;
  23256. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23257. },
  23258. clear: function fontLoaderClear() {
  23259. var styleElement = this.styleElement;
  23260. if (styleElement) {
  23261. styleElement.parentNode.removeChild(styleElement);
  23262. styleElement = this.styleElement = null;
  23263. }
  23264. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23265. document.fonts.delete(nativeFontFace);
  23266. });
  23267. this.nativeFontFaces.length = 0;
  23268. }
  23269. };
  23270. var getLoadTestFont = function () {
  23271. 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==');
  23272. };
  23273. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23274. get: function () {
  23275. return shadow(this, 'loadTestFont', getLoadTestFont());
  23276. },
  23277. configurable: true
  23278. });
  23279. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23280. this.nativeFontFaces.push(nativeFontFace);
  23281. document.fonts.add(nativeFontFace);
  23282. };
  23283. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23284. var rules = [];
  23285. var fontsToLoad = [];
  23286. var fontLoadPromises = [];
  23287. var getNativeFontPromise = function (nativeFontFace) {
  23288. return nativeFontFace.loaded.catch(function (e) {
  23289. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23290. });
  23291. };
  23292. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23293. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23294. var font = fonts[i];
  23295. if (font.attached || font.loading === false) {
  23296. continue;
  23297. }
  23298. font.attached = true;
  23299. if (isFontLoadingAPISupported) {
  23300. var nativeFontFace = font.createNativeFontFace();
  23301. if (nativeFontFace) {
  23302. this.addNativeFontFace(nativeFontFace);
  23303. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23304. }
  23305. } else {
  23306. var rule = font.createFontFaceRule();
  23307. if (rule) {
  23308. this.insertRule(rule);
  23309. rules.push(rule);
  23310. fontsToLoad.push(font);
  23311. }
  23312. }
  23313. }
  23314. var request = this.queueLoadingCallback(callback);
  23315. if (isFontLoadingAPISupported) {
  23316. Promise.all(fontLoadPromises).then(function () {
  23317. request.complete();
  23318. });
  23319. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23320. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23321. } else {
  23322. request.complete();
  23323. }
  23324. };
  23325. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23326. function LoadLoader_completeRequest() {
  23327. assert(!request.end, 'completeRequest() cannot be called twice');
  23328. request.end = Date.now();
  23329. while (context.requests.length > 0 && context.requests[0].end) {
  23330. var otherRequest = context.requests.shift();
  23331. setTimeout(otherRequest.callback, 0);
  23332. }
  23333. }
  23334. var context = this.loadingContext;
  23335. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23336. var request = {
  23337. id: requestId,
  23338. complete: LoadLoader_completeRequest,
  23339. callback: callback,
  23340. started: Date.now()
  23341. };
  23342. context.requests.push(request);
  23343. return request;
  23344. };
  23345. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23346. function int32(data, offset) {
  23347. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23348. }
  23349. function spliceString(s, offset, remove, insert) {
  23350. var chunk1 = s.substr(0, offset);
  23351. var chunk2 = s.substr(offset + remove);
  23352. return chunk1 + insert + chunk2;
  23353. }
  23354. var i, ii;
  23355. var canvas = document.createElement('canvas');
  23356. canvas.width = 1;
  23357. canvas.height = 1;
  23358. var ctx = canvas.getContext('2d');
  23359. var called = 0;
  23360. function isFontReady(name, callback) {
  23361. called++;
  23362. if (called > 30) {
  23363. warn('Load test font never loaded.');
  23364. callback();
  23365. return;
  23366. }
  23367. ctx.font = '30px ' + name;
  23368. ctx.fillText('.', 0, 20);
  23369. var imageData = ctx.getImageData(0, 0, 1, 1);
  23370. if (imageData.data[3] > 0) {
  23371. callback();
  23372. return;
  23373. }
  23374. setTimeout(isFontReady.bind(null, name, callback));
  23375. }
  23376. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23377. var data = this.loadTestFont;
  23378. var COMMENT_OFFSET = 976;
  23379. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23380. var CFF_CHECKSUM_OFFSET = 16;
  23381. var XXXX_VALUE = 0x58585858;
  23382. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23383. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23384. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23385. }
  23386. if (i < loadTestFontId.length) {
  23387. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23388. }
  23389. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23390. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23391. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23392. this.insertRule(rule);
  23393. var names = [];
  23394. for (i = 0, ii = fonts.length; i < ii; i++) {
  23395. names.push(fonts[i].loadedName);
  23396. }
  23397. names.push(loadTestFontId);
  23398. var div = document.createElement('div');
  23399. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23400. for (i = 0, ii = names.length; i < ii; ++i) {
  23401. var span = document.createElement('span');
  23402. span.textContent = 'Hi';
  23403. span.style.fontFamily = names[i];
  23404. div.appendChild(span);
  23405. }
  23406. document.body.appendChild(div);
  23407. isFontReady(loadTestFontId, function () {
  23408. document.body.removeChild(div);
  23409. request.complete();
  23410. });
  23411. };
  23412. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23413. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23414. if (typeof navigator === 'undefined') {
  23415. return true;
  23416. }
  23417. var supported = false;
  23418. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23419. if (m && m[1] >= 14) {
  23420. supported = true;
  23421. }
  23422. return supported;
  23423. };
  23424. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23425. get: function () {
  23426. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23427. },
  23428. enumerable: true,
  23429. configurable: true
  23430. });
  23431. var IsEvalSupportedCached = {
  23432. get value() {
  23433. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23434. }
  23435. };
  23436. var FontFaceObject = function FontFaceObjectClosure() {
  23437. function FontFaceObject(translatedData, options) {
  23438. this.compiledGlyphs = Object.create(null);
  23439. for (var i in translatedData) {
  23440. this[i] = translatedData[i];
  23441. }
  23442. this.options = options;
  23443. }
  23444. FontFaceObject.prototype = {
  23445. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23446. if (!this.data) {
  23447. return null;
  23448. }
  23449. if (this.options.disableFontFace) {
  23450. this.disableFontFace = true;
  23451. return null;
  23452. }
  23453. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23454. if (this.options.fontRegistry) {
  23455. this.options.fontRegistry.registerFont(this);
  23456. }
  23457. return nativeFontFace;
  23458. },
  23459. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23460. if (!this.data) {
  23461. return null;
  23462. }
  23463. if (this.options.disableFontFace) {
  23464. this.disableFontFace = true;
  23465. return null;
  23466. }
  23467. var data = bytesToString(new Uint8Array(this.data));
  23468. var fontName = this.loadedName;
  23469. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23470. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23471. if (this.options.fontRegistry) {
  23472. this.options.fontRegistry.registerFont(this, url);
  23473. }
  23474. return rule;
  23475. },
  23476. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23477. if (!(character in this.compiledGlyphs)) {
  23478. var cmds = objs.get(this.loadedName + '_path_' + character);
  23479. var current, i, len;
  23480. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23481. var args, js = '';
  23482. for (i = 0, len = cmds.length; i < len; i++) {
  23483. current = cmds[i];
  23484. if (current.args !== undefined) {
  23485. args = current.args.join(',');
  23486. } else {
  23487. args = '';
  23488. }
  23489. js += 'c.' + current.cmd + '(' + args + ');\n';
  23490. }
  23491. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23492. } else {
  23493. this.compiledGlyphs[character] = function (c, size) {
  23494. for (i = 0, len = cmds.length; i < len; i++) {
  23495. current = cmds[i];
  23496. if (current.cmd === 'scale') {
  23497. current.args = [
  23498. size,
  23499. -size
  23500. ];
  23501. }
  23502. c[current.cmd].apply(c, current.args);
  23503. }
  23504. };
  23505. }
  23506. }
  23507. return this.compiledGlyphs[character];
  23508. }
  23509. };
  23510. return FontFaceObject;
  23511. }();
  23512. exports.FontFaceObject = FontFaceObject;
  23513. exports.FontLoader = FontLoader;
  23514. }));
  23515. (function (root, factory) {
  23516. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23517. }(this, function (exports, sharedUtil) {
  23518. var error = sharedUtil.error;
  23519. function fixMetadata(meta) {
  23520. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23521. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23522. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23523. });
  23524. var chars = '';
  23525. for (var i = 0; i < bytes.length; i += 2) {
  23526. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23527. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 && false ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23528. }
  23529. return '>' + chars;
  23530. });
  23531. }
  23532. function Metadata(meta) {
  23533. if (typeof meta === 'string') {
  23534. meta = fixMetadata(meta);
  23535. var parser = new DOMParser();
  23536. meta = parser.parseFromString(meta, 'application/xml');
  23537. } else if (!(meta instanceof Document)) {
  23538. error('Metadata: Invalid metadata object');
  23539. }
  23540. this.metaDocument = meta;
  23541. this.metadata = Object.create(null);
  23542. this.parse();
  23543. }
  23544. Metadata.prototype = {
  23545. parse: function Metadata_parse() {
  23546. var doc = this.metaDocument;
  23547. var rdf = doc.documentElement;
  23548. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23549. rdf = rdf.firstChild;
  23550. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23551. rdf = rdf.nextSibling;
  23552. }
  23553. }
  23554. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23555. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23556. return;
  23557. }
  23558. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23559. for (i = 0, length = children.length; i < length; i++) {
  23560. desc = children[i];
  23561. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23562. continue;
  23563. }
  23564. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23565. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23566. entry = desc.childNodes[ii];
  23567. name = entry.nodeName.toLowerCase();
  23568. this.metadata[name] = entry.textContent.trim();
  23569. }
  23570. }
  23571. }
  23572. },
  23573. get: function Metadata_get(name) {
  23574. return this.metadata[name] || null;
  23575. },
  23576. has: function Metadata_has(name) {
  23577. return typeof this.metadata[name] !== 'undefined';
  23578. }
  23579. };
  23580. exports.Metadata = Metadata;
  23581. }));
  23582. (function (root, factory) {
  23583. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23584. }(this, function (exports, sharedUtil) {
  23585. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23586. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23587. var ImageKind = sharedUtil.ImageKind;
  23588. var OPS = sharedUtil.OPS;
  23589. var Util = sharedUtil.Util;
  23590. var isNum = sharedUtil.isNum;
  23591. var isArray = sharedUtil.isArray;
  23592. var warn = sharedUtil.warn;
  23593. var createObjectURL = sharedUtil.createObjectURL;
  23594. var SVG_DEFAULTS = {
  23595. fontStyle: 'normal',
  23596. fontWeight: 'normal',
  23597. fillColor: '#000000'
  23598. };
  23599. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23600. var PNG_HEADER = new Uint8Array([
  23601. 0x89,
  23602. 0x50,
  23603. 0x4e,
  23604. 0x47,
  23605. 0x0d,
  23606. 0x0a,
  23607. 0x1a,
  23608. 0x0a
  23609. ]);
  23610. var CHUNK_WRAPPER_SIZE = 12;
  23611. var crcTable = new Int32Array(256);
  23612. for (var i = 0; i < 256; i++) {
  23613. var c = i;
  23614. for (var h = 0; h < 8; h++) {
  23615. if (c & 1) {
  23616. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23617. } else {
  23618. c = c >> 1 & 0x7fffffff;
  23619. }
  23620. }
  23621. crcTable[i] = c;
  23622. }
  23623. function crc32(data, start, end) {
  23624. var crc = -1;
  23625. for (var i = start; i < end; i++) {
  23626. var a = (crc ^ data[i]) & 0xff;
  23627. var b = crcTable[a];
  23628. crc = crc >>> 8 ^ b;
  23629. }
  23630. return crc ^ -1;
  23631. }
  23632. function writePngChunk(type, body, data, offset) {
  23633. var p = offset;
  23634. var len = body.length;
  23635. data[p] = len >> 24 & 0xff;
  23636. data[p + 1] = len >> 16 & 0xff;
  23637. data[p + 2] = len >> 8 & 0xff;
  23638. data[p + 3] = len & 0xff;
  23639. p += 4;
  23640. data[p] = type.charCodeAt(0) & 0xff;
  23641. data[p + 1] = type.charCodeAt(1) & 0xff;
  23642. data[p + 2] = type.charCodeAt(2) & 0xff;
  23643. data[p + 3] = type.charCodeAt(3) & 0xff;
  23644. p += 4;
  23645. data.set(body, p);
  23646. p += body.length;
  23647. var crc = crc32(data, offset + 4, p);
  23648. data[p] = crc >> 24 & 0xff;
  23649. data[p + 1] = crc >> 16 & 0xff;
  23650. data[p + 2] = crc >> 8 & 0xff;
  23651. data[p + 3] = crc & 0xff;
  23652. }
  23653. function adler32(data, start, end) {
  23654. var a = 1;
  23655. var b = 0;
  23656. for (var i = start; i < end; ++i) {
  23657. a = (a + (data[i] & 0xff)) % 65521;
  23658. b = (b + a) % 65521;
  23659. }
  23660. return b << 16 | a;
  23661. }
  23662. function encode(imgData, kind, forceDataSchema) {
  23663. var width = imgData.width;
  23664. var height = imgData.height;
  23665. var bitDepth, colorType, lineSize;
  23666. var bytes = imgData.data;
  23667. switch (kind) {
  23668. case ImageKind.GRAYSCALE_1BPP:
  23669. colorType = 0;
  23670. bitDepth = 1;
  23671. lineSize = width + 7 >> 3;
  23672. break;
  23673. case ImageKind.RGB_24BPP:
  23674. colorType = 2;
  23675. bitDepth = 8;
  23676. lineSize = width * 3;
  23677. break;
  23678. case ImageKind.RGBA_32BPP:
  23679. colorType = 6;
  23680. bitDepth = 8;
  23681. lineSize = width * 4;
  23682. break;
  23683. default:
  23684. throw new Error('invalid format');
  23685. }
  23686. var literals = new Uint8Array((1 + lineSize) * height);
  23687. var offsetLiterals = 0, offsetBytes = 0;
  23688. var y, i;
  23689. for (y = 0; y < height; ++y) {
  23690. literals[offsetLiterals++] = 0;
  23691. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23692. offsetBytes += lineSize;
  23693. offsetLiterals += lineSize;
  23694. }
  23695. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23696. offsetLiterals = 0;
  23697. for (y = 0; y < height; y++) {
  23698. offsetLiterals++;
  23699. for (i = 0; i < lineSize; i++) {
  23700. literals[offsetLiterals++] ^= 0xFF;
  23701. }
  23702. }
  23703. }
  23704. var ihdr = new Uint8Array([
  23705. width >> 24 & 0xff,
  23706. width >> 16 & 0xff,
  23707. width >> 8 & 0xff,
  23708. width & 0xff,
  23709. height >> 24 & 0xff,
  23710. height >> 16 & 0xff,
  23711. height >> 8 & 0xff,
  23712. height & 0xff,
  23713. bitDepth,
  23714. colorType,
  23715. 0x00,
  23716. 0x00,
  23717. 0x00
  23718. ]);
  23719. var len = literals.length;
  23720. var maxBlockLength = 0xFFFF;
  23721. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23722. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23723. var pi = 0;
  23724. idat[pi++] = 0x78;
  23725. idat[pi++] = 0x9c;
  23726. var pos = 0;
  23727. while (len > maxBlockLength) {
  23728. idat[pi++] = 0x00;
  23729. idat[pi++] = 0xff;
  23730. idat[pi++] = 0xff;
  23731. idat[pi++] = 0x00;
  23732. idat[pi++] = 0x00;
  23733. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23734. pi += maxBlockLength;
  23735. pos += maxBlockLength;
  23736. len -= maxBlockLength;
  23737. }
  23738. idat[pi++] = 0x01;
  23739. idat[pi++] = len & 0xff;
  23740. idat[pi++] = len >> 8 & 0xff;
  23741. idat[pi++] = ~len & 0xffff & 0xff;
  23742. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23743. idat.set(literals.subarray(pos), pi);
  23744. pi += literals.length - pos;
  23745. var adler = adler32(literals, 0, literals.length);
  23746. idat[pi++] = adler >> 24 & 0xff;
  23747. idat[pi++] = adler >> 16 & 0xff;
  23748. idat[pi++] = adler >> 8 & 0xff;
  23749. idat[pi++] = adler & 0xff;
  23750. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23751. var data = new Uint8Array(pngLength);
  23752. var offset = 0;
  23753. data.set(PNG_HEADER, offset);
  23754. offset += PNG_HEADER.length;
  23755. writePngChunk('IHDR', ihdr, data, offset);
  23756. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23757. writePngChunk('IDATA', idat, data, offset);
  23758. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23759. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23760. return createObjectURL(data, 'image/png', forceDataSchema);
  23761. }
  23762. return function convertImgDataToPng(imgData, forceDataSchema) {
  23763. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23764. return encode(imgData, kind, forceDataSchema);
  23765. };
  23766. }();
  23767. var SVGExtraState = function SVGExtraStateClosure() {
  23768. function SVGExtraState() {
  23769. this.fontSizeScale = 1;
  23770. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23771. this.fontSize = 0;
  23772. this.textMatrix = IDENTITY_MATRIX;
  23773. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23774. this.leading = 0;
  23775. this.x = 0;
  23776. this.y = 0;
  23777. this.lineX = 0;
  23778. this.lineY = 0;
  23779. this.charSpacing = 0;
  23780. this.wordSpacing = 0;
  23781. this.textHScale = 1;
  23782. this.textRise = 0;
  23783. this.fillColor = SVG_DEFAULTS.fillColor;
  23784. this.strokeColor = '#000000';
  23785. this.fillAlpha = 1;
  23786. this.strokeAlpha = 1;
  23787. this.lineWidth = 1;
  23788. this.lineJoin = '';
  23789. this.lineCap = '';
  23790. this.miterLimit = 0;
  23791. this.dashArray = [];
  23792. this.dashPhase = 0;
  23793. this.dependencies = [];
  23794. this.activeClipUrl = null;
  23795. this.clipGroup = null;
  23796. this.maskId = '';
  23797. }
  23798. SVGExtraState.prototype = {
  23799. clone: function SVGExtraState_clone() {
  23800. return Object.create(this);
  23801. },
  23802. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23803. this.x = x;
  23804. this.y = y;
  23805. }
  23806. };
  23807. return SVGExtraState;
  23808. }();
  23809. var SVGGraphics = function SVGGraphicsClosure() {
  23810. function opListToTree(opList) {
  23811. var opTree = [];
  23812. var tmp = [];
  23813. var opListLen = opList.length;
  23814. for (var x = 0; x < opListLen; x++) {
  23815. if (opList[x].fn === 'save') {
  23816. opTree.push({
  23817. 'fnId': 92,
  23818. 'fn': 'group',
  23819. 'items': []
  23820. });
  23821. tmp.push(opTree);
  23822. opTree = opTree[opTree.length - 1].items;
  23823. continue;
  23824. }
  23825. if (opList[x].fn === 'restore') {
  23826. opTree = tmp.pop();
  23827. } else {
  23828. opTree.push(opList[x]);
  23829. }
  23830. }
  23831. return opTree;
  23832. }
  23833. function pf(value) {
  23834. if (value === (value | 0)) {
  23835. return value.toString();
  23836. }
  23837. var s = value.toFixed(10);
  23838. var i = s.length - 1;
  23839. if (s[i] !== '0') {
  23840. return s;
  23841. }
  23842. do {
  23843. i--;
  23844. } while (s[i] === '0');
  23845. return s.substr(0, s[i] === '.' ? i : i + 1);
  23846. }
  23847. function pm(m) {
  23848. if (m[4] === 0 && m[5] === 0) {
  23849. if (m[1] === 0 && m[2] === 0) {
  23850. if (m[0] === 1 && m[3] === 1) {
  23851. return '';
  23852. }
  23853. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  23854. }
  23855. if (m[0] === m[3] && m[1] === -m[2]) {
  23856. var a = Math.acos(m[0]) * 180 / Math.PI;
  23857. return 'rotate(' + pf(a) + ')';
  23858. }
  23859. } else {
  23860. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  23861. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23862. }
  23863. }
  23864. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23865. }
  23866. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  23867. this.current = new SVGExtraState();
  23868. this.transformMatrix = IDENTITY_MATRIX;
  23869. this.transformStack = [];
  23870. this.extraStack = [];
  23871. this.commonObjs = commonObjs;
  23872. this.objs = objs;
  23873. this.pendingEOFill = false;
  23874. this.embedFonts = false;
  23875. this.embeddedFonts = Object.create(null);
  23876. this.cssStyle = null;
  23877. this.forceDataSchema = !!forceDataSchema;
  23878. }
  23879. var NS = 'http://www.w3.org/2000/svg';
  23880. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  23881. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  23882. var LINE_CAP_STYLES = [
  23883. 'butt',
  23884. 'round',
  23885. 'square'
  23886. ];
  23887. var LINE_JOIN_STYLES = [
  23888. 'miter',
  23889. 'round',
  23890. 'bevel'
  23891. ];
  23892. var clipCount = 0;
  23893. var maskCount = 0;
  23894. SVGGraphics.prototype = {
  23895. save: function SVGGraphics_save() {
  23896. this.transformStack.push(this.transformMatrix);
  23897. var old = this.current;
  23898. this.extraStack.push(old);
  23899. this.current = old.clone();
  23900. },
  23901. restore: function SVGGraphics_restore() {
  23902. this.transformMatrix = this.transformStack.pop();
  23903. this.current = this.extraStack.pop();
  23904. this.tgrp = null;
  23905. },
  23906. group: function SVGGraphics_group(items) {
  23907. this.save();
  23908. this.executeOpTree(items);
  23909. this.restore();
  23910. },
  23911. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  23912. var fnArray = operatorList.fnArray;
  23913. var fnArrayLen = fnArray.length;
  23914. var argsArray = operatorList.argsArray;
  23915. var self = this;
  23916. for (var i = 0; i < fnArrayLen; i++) {
  23917. if (OPS.dependency === fnArray[i]) {
  23918. var deps = argsArray[i];
  23919. for (var n = 0, nn = deps.length; n < nn; n++) {
  23920. var obj = deps[n];
  23921. var common = obj.substring(0, 2) === 'g_';
  23922. var promise;
  23923. if (common) {
  23924. promise = new Promise(function (resolve) {
  23925. self.commonObjs.get(obj, resolve);
  23926. });
  23927. } else {
  23928. promise = new Promise(function (resolve) {
  23929. self.objs.get(obj, resolve);
  23930. });
  23931. }
  23932. this.current.dependencies.push(promise);
  23933. }
  23934. }
  23935. }
  23936. return Promise.all(this.current.dependencies);
  23937. },
  23938. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  23939. var transformMatrix = [
  23940. a,
  23941. b,
  23942. c,
  23943. d,
  23944. e,
  23945. f
  23946. ];
  23947. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  23948. this.tgrp = null;
  23949. },
  23950. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  23951. this.viewport = viewport;
  23952. var svgElement = this._initialize(viewport);
  23953. return this.loadDependencies(operatorList).then(function () {
  23954. this.transformMatrix = IDENTITY_MATRIX;
  23955. var opTree = this.convertOpList(operatorList);
  23956. this.executeOpTree(opTree);
  23957. return svgElement;
  23958. }.bind(this));
  23959. },
  23960. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  23961. var argsArray = operatorList.argsArray;
  23962. var fnArray = operatorList.fnArray;
  23963. var fnArrayLen = fnArray.length;
  23964. var REVOPS = [];
  23965. var opList = [];
  23966. for (var op in OPS) {
  23967. REVOPS[OPS[op]] = op;
  23968. }
  23969. for (var x = 0; x < fnArrayLen; x++) {
  23970. var fnId = fnArray[x];
  23971. opList.push({
  23972. 'fnId': fnId,
  23973. 'fn': REVOPS[fnId],
  23974. 'args': argsArray[x]
  23975. });
  23976. }
  23977. return opListToTree(opList);
  23978. },
  23979. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  23980. var opTreeLen = opTree.length;
  23981. for (var x = 0; x < opTreeLen; x++) {
  23982. var fn = opTree[x].fn;
  23983. var fnId = opTree[x].fnId;
  23984. var args = opTree[x].args;
  23985. switch (fnId | 0) {
  23986. case OPS.beginText:
  23987. this.beginText();
  23988. break;
  23989. case OPS.setLeading:
  23990. this.setLeading(args);
  23991. break;
  23992. case OPS.setLeadingMoveText:
  23993. this.setLeadingMoveText(args[0], args[1]);
  23994. break;
  23995. case OPS.setFont:
  23996. this.setFont(args);
  23997. break;
  23998. case OPS.showText:
  23999. this.showText(args[0]);
  24000. break;
  24001. case OPS.showSpacedText:
  24002. this.showText(args[0]);
  24003. break;
  24004. case OPS.endText:
  24005. this.endText();
  24006. break;
  24007. case OPS.moveText:
  24008. this.moveText(args[0], args[1]);
  24009. break;
  24010. case OPS.setCharSpacing:
  24011. this.setCharSpacing(args[0]);
  24012. break;
  24013. case OPS.setWordSpacing:
  24014. this.setWordSpacing(args[0]);
  24015. break;
  24016. case OPS.setHScale:
  24017. this.setHScale(args[0]);
  24018. break;
  24019. case OPS.setTextMatrix:
  24020. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24021. break;
  24022. case OPS.setLineWidth:
  24023. this.setLineWidth(args[0]);
  24024. break;
  24025. case OPS.setLineJoin:
  24026. this.setLineJoin(args[0]);
  24027. break;
  24028. case OPS.setLineCap:
  24029. this.setLineCap(args[0]);
  24030. break;
  24031. case OPS.setMiterLimit:
  24032. this.setMiterLimit(args[0]);
  24033. break;
  24034. case OPS.setFillRGBColor:
  24035. this.setFillRGBColor(args[0], args[1], args[2]);
  24036. break;
  24037. case OPS.setStrokeRGBColor:
  24038. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24039. break;
  24040. case OPS.setDash:
  24041. this.setDash(args[0], args[1]);
  24042. break;
  24043. case OPS.setGState:
  24044. this.setGState(args[0]);
  24045. break;
  24046. case OPS.fill:
  24047. this.fill();
  24048. break;
  24049. case OPS.eoFill:
  24050. this.eoFill();
  24051. break;
  24052. case OPS.stroke:
  24053. this.stroke();
  24054. break;
  24055. case OPS.fillStroke:
  24056. this.fillStroke();
  24057. break;
  24058. case OPS.eoFillStroke:
  24059. this.eoFillStroke();
  24060. break;
  24061. case OPS.clip:
  24062. this.clip('nonzero');
  24063. break;
  24064. case OPS.eoClip:
  24065. this.clip('evenodd');
  24066. break;
  24067. case OPS.paintSolidColorImageMask:
  24068. this.paintSolidColorImageMask();
  24069. break;
  24070. case OPS.paintJpegXObject:
  24071. this.paintJpegXObject(args[0], args[1], args[2]);
  24072. break;
  24073. case OPS.paintImageXObject:
  24074. this.paintImageXObject(args[0]);
  24075. break;
  24076. case OPS.paintInlineImageXObject:
  24077. this.paintInlineImageXObject(args[0]);
  24078. break;
  24079. case OPS.paintImageMaskXObject:
  24080. this.paintImageMaskXObject(args[0]);
  24081. break;
  24082. case OPS.paintFormXObjectBegin:
  24083. this.paintFormXObjectBegin(args[0], args[1]);
  24084. break;
  24085. case OPS.paintFormXObjectEnd:
  24086. this.paintFormXObjectEnd();
  24087. break;
  24088. case OPS.closePath:
  24089. this.closePath();
  24090. break;
  24091. case OPS.closeStroke:
  24092. this.closeStroke();
  24093. break;
  24094. case OPS.closeFillStroke:
  24095. this.closeFillStroke();
  24096. break;
  24097. case OPS.nextLine:
  24098. this.nextLine();
  24099. break;
  24100. case OPS.transform:
  24101. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24102. break;
  24103. case OPS.constructPath:
  24104. this.constructPath(args[0], args[1]);
  24105. break;
  24106. case OPS.endPath:
  24107. this.endPath();
  24108. break;
  24109. case 92:
  24110. this.group(opTree[x].items);
  24111. break;
  24112. default:
  24113. warn('Unimplemented operator ' + fn);
  24114. break;
  24115. }
  24116. }
  24117. },
  24118. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24119. this.current.wordSpacing = wordSpacing;
  24120. },
  24121. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24122. this.current.charSpacing = charSpacing;
  24123. },
  24124. nextLine: function SVGGraphics_nextLine() {
  24125. this.moveText(0, this.current.leading);
  24126. },
  24127. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24128. var current = this.current;
  24129. this.current.textMatrix = this.current.lineMatrix = [
  24130. a,
  24131. b,
  24132. c,
  24133. d,
  24134. e,
  24135. f
  24136. ];
  24137. this.current.x = this.current.lineX = 0;
  24138. this.current.y = this.current.lineY = 0;
  24139. current.xcoords = [];
  24140. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24141. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24142. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24143. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24144. current.txtElement = document.createElementNS(NS, 'svg:text');
  24145. current.txtElement.appendChild(current.tspan);
  24146. },
  24147. beginText: function SVGGraphics_beginText() {
  24148. this.current.x = this.current.lineX = 0;
  24149. this.current.y = this.current.lineY = 0;
  24150. this.current.textMatrix = IDENTITY_MATRIX;
  24151. this.current.lineMatrix = IDENTITY_MATRIX;
  24152. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24153. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24154. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24155. this.current.xcoords = [];
  24156. },
  24157. moveText: function SVGGraphics_moveText(x, y) {
  24158. var current = this.current;
  24159. this.current.x = this.current.lineX += x;
  24160. this.current.y = this.current.lineY += y;
  24161. current.xcoords = [];
  24162. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24163. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24164. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24165. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24166. },
  24167. showText: function SVGGraphics_showText(glyphs) {
  24168. var current = this.current;
  24169. var font = current.font;
  24170. var fontSize = current.fontSize;
  24171. if (fontSize === 0) {
  24172. return;
  24173. }
  24174. var charSpacing = current.charSpacing;
  24175. var wordSpacing = current.wordSpacing;
  24176. var fontDirection = current.fontDirection;
  24177. var textHScale = current.textHScale * fontDirection;
  24178. var glyphsLength = glyphs.length;
  24179. var vertical = font.vertical;
  24180. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24181. var x = 0, i;
  24182. for (i = 0; i < glyphsLength; ++i) {
  24183. var glyph = glyphs[i];
  24184. if (glyph === null) {
  24185. x += fontDirection * wordSpacing;
  24186. continue;
  24187. } else if (isNum(glyph)) {
  24188. x += -glyph * fontSize * 0.001;
  24189. continue;
  24190. }
  24191. current.xcoords.push(current.x + x * textHScale);
  24192. var width = glyph.width;
  24193. var character = glyph.fontChar;
  24194. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24195. x += charWidth;
  24196. current.tspan.textContent += character;
  24197. }
  24198. if (vertical) {
  24199. current.y -= x * textHScale;
  24200. } else {
  24201. current.x += x * textHScale;
  24202. }
  24203. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24204. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24205. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24206. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24207. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24208. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24209. }
  24210. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24211. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24212. }
  24213. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24214. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24215. }
  24216. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24217. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24218. current.txtElement.appendChild(current.tspan);
  24219. current.txtgrp.appendChild(current.txtElement);
  24220. this._ensureTransformGroup().appendChild(current.txtElement);
  24221. },
  24222. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24223. this.setLeading(-y);
  24224. this.moveText(x, y);
  24225. },
  24226. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24227. if (!this.cssStyle) {
  24228. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24229. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24230. this.defs.appendChild(this.cssStyle);
  24231. }
  24232. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24233. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24234. },
  24235. setFont: function SVGGraphics_setFont(details) {
  24236. var current = this.current;
  24237. var fontObj = this.commonObjs.get(details[0]);
  24238. var size = details[1];
  24239. this.current.font = fontObj;
  24240. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24241. this.addFontStyle(fontObj);
  24242. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24243. }
  24244. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24245. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24246. var italic = fontObj.italic ? 'italic' : 'normal';
  24247. if (size < 0) {
  24248. size = -size;
  24249. current.fontDirection = -1;
  24250. } else {
  24251. current.fontDirection = 1;
  24252. }
  24253. current.fontSize = size;
  24254. current.fontFamily = fontObj.loadedName;
  24255. current.fontWeight = bold;
  24256. current.fontStyle = italic;
  24257. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24258. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24259. current.xcoords = [];
  24260. },
  24261. endText: function SVGGraphics_endText() {
  24262. },
  24263. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24264. this.current.lineWidth = width;
  24265. },
  24266. setLineCap: function SVGGraphics_setLineCap(style) {
  24267. this.current.lineCap = LINE_CAP_STYLES[style];
  24268. },
  24269. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24270. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24271. },
  24272. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24273. this.current.miterLimit = limit;
  24274. },
  24275. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24276. var color = Util.makeCssRgb(r, g, b);
  24277. this.current.strokeColor = color;
  24278. },
  24279. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24280. var color = Util.makeCssRgb(r, g, b);
  24281. this.current.fillColor = color;
  24282. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24283. this.current.xcoords = [];
  24284. },
  24285. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24286. this.current.dashArray = dashArray;
  24287. this.current.dashPhase = dashPhase;
  24288. },
  24289. constructPath: function SVGGraphics_constructPath(ops, args) {
  24290. var current = this.current;
  24291. var x = current.x, y = current.y;
  24292. current.path = document.createElementNS(NS, 'svg:path');
  24293. var d = [];
  24294. var opLength = ops.length;
  24295. for (var i = 0, j = 0; i < opLength; i++) {
  24296. switch (ops[i] | 0) {
  24297. case OPS.rectangle:
  24298. x = args[j++];
  24299. y = args[j++];
  24300. var width = args[j++];
  24301. var height = args[j++];
  24302. var xw = x + width;
  24303. var yh = y + height;
  24304. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24305. break;
  24306. case OPS.moveTo:
  24307. x = args[j++];
  24308. y = args[j++];
  24309. d.push('M', pf(x), pf(y));
  24310. break;
  24311. case OPS.lineTo:
  24312. x = args[j++];
  24313. y = args[j++];
  24314. d.push('L', pf(x), pf(y));
  24315. break;
  24316. case OPS.curveTo:
  24317. x = args[j + 4];
  24318. y = args[j + 5];
  24319. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24320. j += 6;
  24321. break;
  24322. case OPS.curveTo2:
  24323. x = args[j + 2];
  24324. y = args[j + 3];
  24325. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24326. j += 4;
  24327. break;
  24328. case OPS.curveTo3:
  24329. x = args[j + 2];
  24330. y = args[j + 3];
  24331. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24332. j += 4;
  24333. break;
  24334. case OPS.closePath:
  24335. d.push('Z');
  24336. break;
  24337. }
  24338. }
  24339. current.path.setAttributeNS(null, 'd', d.join(' '));
  24340. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24341. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24342. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24343. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24344. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24345. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24346. current.path.setAttributeNS(null, 'fill', 'none');
  24347. this._ensureTransformGroup().appendChild(current.path);
  24348. current.element = current.path;
  24349. current.setCurrentPoint(x, y);
  24350. },
  24351. endPath: function SVGGraphics_endPath() {
  24352. },
  24353. clip: function SVGGraphics_clip(type) {
  24354. var current = this.current;
  24355. var clipId = 'clippath' + clipCount;
  24356. clipCount++;
  24357. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24358. clipPath.setAttributeNS(null, 'id', clipId);
  24359. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24360. var clipElement = current.element.cloneNode();
  24361. if (type === 'evenodd') {
  24362. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24363. } else {
  24364. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24365. }
  24366. clipPath.appendChild(clipElement);
  24367. this.defs.appendChild(clipPath);
  24368. if (current.activeClipUrl) {
  24369. current.clipGroup = null;
  24370. this.extraStack.forEach(function (prev) {
  24371. prev.clipGroup = null;
  24372. });
  24373. }
  24374. current.activeClipUrl = 'url(#' + clipId + ')';
  24375. this.tgrp = null;
  24376. },
  24377. closePath: function SVGGraphics_closePath() {
  24378. var current = this.current;
  24379. var d = current.path.getAttributeNS(null, 'd');
  24380. d += 'Z';
  24381. current.path.setAttributeNS(null, 'd', d);
  24382. },
  24383. setLeading: function SVGGraphics_setLeading(leading) {
  24384. this.current.leading = -leading;
  24385. },
  24386. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24387. this.current.textRise = textRise;
  24388. },
  24389. setHScale: function SVGGraphics_setHScale(scale) {
  24390. this.current.textHScale = scale / 100;
  24391. },
  24392. setGState: function SVGGraphics_setGState(states) {
  24393. for (var i = 0, ii = states.length; i < ii; i++) {
  24394. var state = states[i];
  24395. var key = state[0];
  24396. var value = state[1];
  24397. switch (key) {
  24398. case 'LW':
  24399. this.setLineWidth(value);
  24400. break;
  24401. case 'LC':
  24402. this.setLineCap(value);
  24403. break;
  24404. case 'LJ':
  24405. this.setLineJoin(value);
  24406. break;
  24407. case 'ML':
  24408. this.setMiterLimit(value);
  24409. break;
  24410. case 'D':
  24411. this.setDash(value[0], value[1]);
  24412. break;
  24413. case 'Font':
  24414. this.setFont(value);
  24415. break;
  24416. default:
  24417. warn('Unimplemented graphic state ' + key);
  24418. break;
  24419. }
  24420. }
  24421. },
  24422. fill: function SVGGraphics_fill() {
  24423. var current = this.current;
  24424. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24425. },
  24426. stroke: function SVGGraphics_stroke() {
  24427. var current = this.current;
  24428. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24429. current.element.setAttributeNS(null, 'fill', 'none');
  24430. },
  24431. eoFill: function SVGGraphics_eoFill() {
  24432. var current = this.current;
  24433. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24434. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24435. },
  24436. fillStroke: function SVGGraphics_fillStroke() {
  24437. this.stroke();
  24438. this.fill();
  24439. },
  24440. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24441. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24442. this.fillStroke();
  24443. },
  24444. closeStroke: function SVGGraphics_closeStroke() {
  24445. this.closePath();
  24446. this.stroke();
  24447. },
  24448. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24449. this.closePath();
  24450. this.fillStroke();
  24451. },
  24452. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24453. var current = this.current;
  24454. var rect = document.createElementNS(NS, 'svg:rect');
  24455. rect.setAttributeNS(null, 'x', '0');
  24456. rect.setAttributeNS(null, 'y', '0');
  24457. rect.setAttributeNS(null, 'width', '1px');
  24458. rect.setAttributeNS(null, 'height', '1px');
  24459. rect.setAttributeNS(null, 'fill', current.fillColor);
  24460. this._ensureTransformGroup().appendChild(rect);
  24461. },
  24462. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24463. var imgObj = this.objs.get(objId);
  24464. var imgEl = document.createElementNS(NS, 'svg:image');
  24465. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24466. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24467. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24468. imgEl.setAttributeNS(null, 'x', '0');
  24469. imgEl.setAttributeNS(null, 'y', pf(-h));
  24470. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24471. this._ensureTransformGroup().appendChild(imgEl);
  24472. },
  24473. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24474. var imgData = this.objs.get(objId);
  24475. if (!imgData) {
  24476. warn('Dependent image isn\'t ready yet');
  24477. return;
  24478. }
  24479. this.paintInlineImageXObject(imgData);
  24480. },
  24481. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24482. var width = imgData.width;
  24483. var height = imgData.height;
  24484. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24485. var cliprect = document.createElementNS(NS, 'svg:rect');
  24486. cliprect.setAttributeNS(null, 'x', '0');
  24487. cliprect.setAttributeNS(null, 'y', '0');
  24488. cliprect.setAttributeNS(null, 'width', pf(width));
  24489. cliprect.setAttributeNS(null, 'height', pf(height));
  24490. this.current.element = cliprect;
  24491. this.clip('nonzero');
  24492. var imgEl = document.createElementNS(NS, 'svg:image');
  24493. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24494. imgEl.setAttributeNS(null, 'x', '0');
  24495. imgEl.setAttributeNS(null, 'y', pf(-height));
  24496. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24497. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24498. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24499. if (mask) {
  24500. mask.appendChild(imgEl);
  24501. } else {
  24502. this._ensureTransformGroup().appendChild(imgEl);
  24503. }
  24504. },
  24505. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24506. var current = this.current;
  24507. var width = imgData.width;
  24508. var height = imgData.height;
  24509. var fillColor = current.fillColor;
  24510. current.maskId = 'mask' + maskCount++;
  24511. var mask = document.createElementNS(NS, 'svg:mask');
  24512. mask.setAttributeNS(null, 'id', current.maskId);
  24513. var rect = document.createElementNS(NS, 'svg:rect');
  24514. rect.setAttributeNS(null, 'x', '0');
  24515. rect.setAttributeNS(null, 'y', '0');
  24516. rect.setAttributeNS(null, 'width', pf(width));
  24517. rect.setAttributeNS(null, 'height', pf(height));
  24518. rect.setAttributeNS(null, 'fill', fillColor);
  24519. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24520. this.defs.appendChild(mask);
  24521. this._ensureTransformGroup().appendChild(rect);
  24522. this.paintInlineImageXObject(imgData, mask);
  24523. },
  24524. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24525. if (isArray(matrix) && matrix.length === 6) {
  24526. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24527. }
  24528. if (isArray(bbox) && bbox.length === 4) {
  24529. var width = bbox[2] - bbox[0];
  24530. var height = bbox[3] - bbox[1];
  24531. var cliprect = document.createElementNS(NS, 'svg:rect');
  24532. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24533. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24534. cliprect.setAttributeNS(null, 'width', pf(width));
  24535. cliprect.setAttributeNS(null, 'height', pf(height));
  24536. this.current.element = cliprect;
  24537. this.clip('nonzero');
  24538. this.endPath();
  24539. }
  24540. },
  24541. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24542. },
  24543. _initialize: function SVGGraphics_initialize(viewport) {
  24544. var svg = document.createElementNS(NS, 'svg:svg');
  24545. svg.setAttributeNS(null, 'version', '1.1');
  24546. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24547. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24548. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24549. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24550. var definitions = document.createElementNS(NS, 'svg:defs');
  24551. svg.appendChild(definitions);
  24552. this.defs = definitions;
  24553. var rootGroup = document.createElementNS(NS, 'svg:g');
  24554. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24555. svg.appendChild(rootGroup);
  24556. this.svg = rootGroup;
  24557. return svg;
  24558. },
  24559. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24560. if (!this.current.clipGroup) {
  24561. var clipGroup = document.createElementNS(NS, 'svg:g');
  24562. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24563. this.svg.appendChild(clipGroup);
  24564. this.current.clipGroup = clipGroup;
  24565. }
  24566. return this.current.clipGroup;
  24567. },
  24568. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24569. if (!this.tgrp) {
  24570. this.tgrp = document.createElementNS(NS, 'svg:g');
  24571. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24572. if (this.current.activeClipUrl) {
  24573. this._ensureClipGroup().appendChild(this.tgrp);
  24574. } else {
  24575. this.svg.appendChild(this.tgrp);
  24576. }
  24577. }
  24578. return this.tgrp;
  24579. }
  24580. };
  24581. return SVGGraphics;
  24582. }();
  24583. exports.SVGGraphics = SVGGraphics;
  24584. }));
  24585. (function (root, factory) {
  24586. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24587. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24588. var Util = sharedUtil.Util;
  24589. var error = sharedUtil.error;
  24590. var info = sharedUtil.info;
  24591. var isInt = sharedUtil.isInt;
  24592. var isArray = sharedUtil.isArray;
  24593. var createObjectURL = sharedUtil.createObjectURL;
  24594. var shadow = sharedUtil.shadow;
  24595. var warn = sharedUtil.warn;
  24596. var isSpace = sharedUtil.isSpace;
  24597. var Dict = corePrimitives.Dict;
  24598. var isDict = corePrimitives.isDict;
  24599. var isStream = corePrimitives.isStream;
  24600. var Jbig2Image = coreJbig2.Jbig2Image;
  24601. var JpegImage = coreJpg.JpegImage;
  24602. var JpxImage = coreJpx.JpxImage;
  24603. var Stream = function StreamClosure() {
  24604. function Stream(arrayBuffer, start, length, dict) {
  24605. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24606. this.start = start || 0;
  24607. this.pos = this.start;
  24608. this.end = start + length || this.bytes.length;
  24609. this.dict = dict;
  24610. }
  24611. Stream.prototype = {
  24612. get length() {
  24613. return this.end - this.start;
  24614. },
  24615. get isEmpty() {
  24616. return this.length === 0;
  24617. },
  24618. getByte: function Stream_getByte() {
  24619. if (this.pos >= this.end) {
  24620. return -1;
  24621. }
  24622. return this.bytes[this.pos++];
  24623. },
  24624. getUint16: function Stream_getUint16() {
  24625. var b0 = this.getByte();
  24626. var b1 = this.getByte();
  24627. if (b0 === -1 || b1 === -1) {
  24628. return -1;
  24629. }
  24630. return (b0 << 8) + b1;
  24631. },
  24632. getInt32: function Stream_getInt32() {
  24633. var b0 = this.getByte();
  24634. var b1 = this.getByte();
  24635. var b2 = this.getByte();
  24636. var b3 = this.getByte();
  24637. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24638. },
  24639. getBytes: function Stream_getBytes(length) {
  24640. var bytes = this.bytes;
  24641. var pos = this.pos;
  24642. var strEnd = this.end;
  24643. if (!length) {
  24644. return bytes.subarray(pos, strEnd);
  24645. }
  24646. var end = pos + length;
  24647. if (end > strEnd) {
  24648. end = strEnd;
  24649. }
  24650. this.pos = end;
  24651. return bytes.subarray(pos, end);
  24652. },
  24653. peekByte: function Stream_peekByte() {
  24654. var peekedByte = this.getByte();
  24655. this.pos--;
  24656. return peekedByte;
  24657. },
  24658. peekBytes: function Stream_peekBytes(length) {
  24659. var bytes = this.getBytes(length);
  24660. this.pos -= bytes.length;
  24661. return bytes;
  24662. },
  24663. skip: function Stream_skip(n) {
  24664. if (!n) {
  24665. n = 1;
  24666. }
  24667. this.pos += n;
  24668. },
  24669. reset: function Stream_reset() {
  24670. this.pos = this.start;
  24671. },
  24672. moveStart: function Stream_moveStart() {
  24673. this.start = this.pos;
  24674. },
  24675. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24676. return new Stream(this.bytes.buffer, start, length, dict);
  24677. },
  24678. isStream: true
  24679. };
  24680. return Stream;
  24681. }();
  24682. var StringStream = function StringStreamClosure() {
  24683. function StringStream(str) {
  24684. var length = str.length;
  24685. var bytes = new Uint8Array(length);
  24686. for (var n = 0; n < length; ++n) {
  24687. bytes[n] = str.charCodeAt(n);
  24688. }
  24689. Stream.call(this, bytes);
  24690. }
  24691. StringStream.prototype = Stream.prototype;
  24692. return StringStream;
  24693. }();
  24694. var DecodeStream = function DecodeStreamClosure() {
  24695. var emptyBuffer = new Uint8Array(0);
  24696. function DecodeStream(maybeMinBufferLength) {
  24697. this.pos = 0;
  24698. this.bufferLength = 0;
  24699. this.eof = false;
  24700. this.buffer = emptyBuffer;
  24701. this.minBufferLength = 512;
  24702. if (maybeMinBufferLength) {
  24703. while (this.minBufferLength < maybeMinBufferLength) {
  24704. this.minBufferLength *= 2;
  24705. }
  24706. }
  24707. }
  24708. DecodeStream.prototype = {
  24709. get isEmpty() {
  24710. while (!this.eof && this.bufferLength === 0) {
  24711. this.readBlock();
  24712. }
  24713. return this.bufferLength === 0;
  24714. },
  24715. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24716. var buffer = this.buffer;
  24717. if (requested <= buffer.byteLength) {
  24718. return buffer;
  24719. }
  24720. var size = this.minBufferLength;
  24721. while (size < requested) {
  24722. size *= 2;
  24723. }
  24724. var buffer2 = new Uint8Array(size);
  24725. buffer2.set(buffer);
  24726. return this.buffer = buffer2;
  24727. },
  24728. getByte: function DecodeStream_getByte() {
  24729. var pos = this.pos;
  24730. while (this.bufferLength <= pos) {
  24731. if (this.eof) {
  24732. return -1;
  24733. }
  24734. this.readBlock();
  24735. }
  24736. return this.buffer[this.pos++];
  24737. },
  24738. getUint16: function DecodeStream_getUint16() {
  24739. var b0 = this.getByte();
  24740. var b1 = this.getByte();
  24741. if (b0 === -1 || b1 === -1) {
  24742. return -1;
  24743. }
  24744. return (b0 << 8) + b1;
  24745. },
  24746. getInt32: function DecodeStream_getInt32() {
  24747. var b0 = this.getByte();
  24748. var b1 = this.getByte();
  24749. var b2 = this.getByte();
  24750. var b3 = this.getByte();
  24751. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24752. },
  24753. getBytes: function DecodeStream_getBytes(length) {
  24754. var end, pos = this.pos;
  24755. if (length) {
  24756. this.ensureBuffer(pos + length);
  24757. end = pos + length;
  24758. while (!this.eof && this.bufferLength < end) {
  24759. this.readBlock();
  24760. }
  24761. var bufEnd = this.bufferLength;
  24762. if (end > bufEnd) {
  24763. end = bufEnd;
  24764. }
  24765. } else {
  24766. while (!this.eof) {
  24767. this.readBlock();
  24768. }
  24769. end = this.bufferLength;
  24770. }
  24771. this.pos = end;
  24772. return this.buffer.subarray(pos, end);
  24773. },
  24774. peekByte: function DecodeStream_peekByte() {
  24775. var peekedByte = this.getByte();
  24776. this.pos--;
  24777. return peekedByte;
  24778. },
  24779. peekBytes: function DecodeStream_peekBytes(length) {
  24780. var bytes = this.getBytes(length);
  24781. this.pos -= bytes.length;
  24782. return bytes;
  24783. },
  24784. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24785. var end = start + length;
  24786. while (this.bufferLength <= end && !this.eof) {
  24787. this.readBlock();
  24788. }
  24789. return new Stream(this.buffer, start, length, dict);
  24790. },
  24791. skip: function DecodeStream_skip(n) {
  24792. if (!n) {
  24793. n = 1;
  24794. }
  24795. this.pos += n;
  24796. },
  24797. reset: function DecodeStream_reset() {
  24798. this.pos = 0;
  24799. },
  24800. getBaseStreams: function DecodeStream_getBaseStreams() {
  24801. if (this.str && this.str.getBaseStreams) {
  24802. return this.str.getBaseStreams();
  24803. }
  24804. return [];
  24805. }
  24806. };
  24807. return DecodeStream;
  24808. }();
  24809. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24810. function StreamsSequenceStream(streams) {
  24811. this.streams = streams;
  24812. DecodeStream.call(this, null);
  24813. }
  24814. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24815. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24816. var streams = this.streams;
  24817. if (streams.length === 0) {
  24818. this.eof = true;
  24819. return;
  24820. }
  24821. var stream = streams.shift();
  24822. var chunk = stream.getBytes();
  24823. var bufferLength = this.bufferLength;
  24824. var newLength = bufferLength + chunk.length;
  24825. var buffer = this.ensureBuffer(newLength);
  24826. buffer.set(chunk, bufferLength);
  24827. this.bufferLength = newLength;
  24828. };
  24829. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24830. var baseStreams = [];
  24831. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24832. var stream = this.streams[i];
  24833. if (stream.getBaseStreams) {
  24834. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24835. }
  24836. }
  24837. return baseStreams;
  24838. };
  24839. return StreamsSequenceStream;
  24840. }();
  24841. var FlateStream = function FlateStreamClosure() {
  24842. var codeLenCodeMap = new Int32Array([
  24843. 16,
  24844. 17,
  24845. 18,
  24846. 0,
  24847. 8,
  24848. 7,
  24849. 9,
  24850. 6,
  24851. 10,
  24852. 5,
  24853. 11,
  24854. 4,
  24855. 12,
  24856. 3,
  24857. 13,
  24858. 2,
  24859. 14,
  24860. 1,
  24861. 15
  24862. ]);
  24863. var lengthDecode = new Int32Array([
  24864. 0x00003,
  24865. 0x00004,
  24866. 0x00005,
  24867. 0x00006,
  24868. 0x00007,
  24869. 0x00008,
  24870. 0x00009,
  24871. 0x0000a,
  24872. 0x1000b,
  24873. 0x1000d,
  24874. 0x1000f,
  24875. 0x10011,
  24876. 0x20013,
  24877. 0x20017,
  24878. 0x2001b,
  24879. 0x2001f,
  24880. 0x30023,
  24881. 0x3002b,
  24882. 0x30033,
  24883. 0x3003b,
  24884. 0x40043,
  24885. 0x40053,
  24886. 0x40063,
  24887. 0x40073,
  24888. 0x50083,
  24889. 0x500a3,
  24890. 0x500c3,
  24891. 0x500e3,
  24892. 0x00102,
  24893. 0x00102,
  24894. 0x00102
  24895. ]);
  24896. var distDecode = new Int32Array([
  24897. 0x00001,
  24898. 0x00002,
  24899. 0x00003,
  24900. 0x00004,
  24901. 0x10005,
  24902. 0x10007,
  24903. 0x20009,
  24904. 0x2000d,
  24905. 0x30011,
  24906. 0x30019,
  24907. 0x40021,
  24908. 0x40031,
  24909. 0x50041,
  24910. 0x50061,
  24911. 0x60081,
  24912. 0x600c1,
  24913. 0x70101,
  24914. 0x70181,
  24915. 0x80201,
  24916. 0x80301,
  24917. 0x90401,
  24918. 0x90601,
  24919. 0xa0801,
  24920. 0xa0c01,
  24921. 0xb1001,
  24922. 0xb1801,
  24923. 0xc2001,
  24924. 0xc3001,
  24925. 0xd4001,
  24926. 0xd6001
  24927. ]);
  24928. var fixedLitCodeTab = [
  24929. new Int32Array([
  24930. 0x70100,
  24931. 0x80050,
  24932. 0x80010,
  24933. 0x80118,
  24934. 0x70110,
  24935. 0x80070,
  24936. 0x80030,
  24937. 0x900c0,
  24938. 0x70108,
  24939. 0x80060,
  24940. 0x80020,
  24941. 0x900a0,
  24942. 0x80000,
  24943. 0x80080,
  24944. 0x80040,
  24945. 0x900e0,
  24946. 0x70104,
  24947. 0x80058,
  24948. 0x80018,
  24949. 0x90090,
  24950. 0x70114,
  24951. 0x80078,
  24952. 0x80038,
  24953. 0x900d0,
  24954. 0x7010c,
  24955. 0x80068,
  24956. 0x80028,
  24957. 0x900b0,
  24958. 0x80008,
  24959. 0x80088,
  24960. 0x80048,
  24961. 0x900f0,
  24962. 0x70102,
  24963. 0x80054,
  24964. 0x80014,
  24965. 0x8011c,
  24966. 0x70112,
  24967. 0x80074,
  24968. 0x80034,
  24969. 0x900c8,
  24970. 0x7010a,
  24971. 0x80064,
  24972. 0x80024,
  24973. 0x900a8,
  24974. 0x80004,
  24975. 0x80084,
  24976. 0x80044,
  24977. 0x900e8,
  24978. 0x70106,
  24979. 0x8005c,
  24980. 0x8001c,
  24981. 0x90098,
  24982. 0x70116,
  24983. 0x8007c,
  24984. 0x8003c,
  24985. 0x900d8,
  24986. 0x7010e,
  24987. 0x8006c,
  24988. 0x8002c,
  24989. 0x900b8,
  24990. 0x8000c,
  24991. 0x8008c,
  24992. 0x8004c,
  24993. 0x900f8,
  24994. 0x70101,
  24995. 0x80052,
  24996. 0x80012,
  24997. 0x8011a,
  24998. 0x70111,
  24999. 0x80072,
  25000. 0x80032,
  25001. 0x900c4,
  25002. 0x70109,
  25003. 0x80062,
  25004. 0x80022,
  25005. 0x900a4,
  25006. 0x80002,
  25007. 0x80082,
  25008. 0x80042,
  25009. 0x900e4,
  25010. 0x70105,
  25011. 0x8005a,
  25012. 0x8001a,
  25013. 0x90094,
  25014. 0x70115,
  25015. 0x8007a,
  25016. 0x8003a,
  25017. 0x900d4,
  25018. 0x7010d,
  25019. 0x8006a,
  25020. 0x8002a,
  25021. 0x900b4,
  25022. 0x8000a,
  25023. 0x8008a,
  25024. 0x8004a,
  25025. 0x900f4,
  25026. 0x70103,
  25027. 0x80056,
  25028. 0x80016,
  25029. 0x8011e,
  25030. 0x70113,
  25031. 0x80076,
  25032. 0x80036,
  25033. 0x900cc,
  25034. 0x7010b,
  25035. 0x80066,
  25036. 0x80026,
  25037. 0x900ac,
  25038. 0x80006,
  25039. 0x80086,
  25040. 0x80046,
  25041. 0x900ec,
  25042. 0x70107,
  25043. 0x8005e,
  25044. 0x8001e,
  25045. 0x9009c,
  25046. 0x70117,
  25047. 0x8007e,
  25048. 0x8003e,
  25049. 0x900dc,
  25050. 0x7010f,
  25051. 0x8006e,
  25052. 0x8002e,
  25053. 0x900bc,
  25054. 0x8000e,
  25055. 0x8008e,
  25056. 0x8004e,
  25057. 0x900fc,
  25058. 0x70100,
  25059. 0x80051,
  25060. 0x80011,
  25061. 0x80119,
  25062. 0x70110,
  25063. 0x80071,
  25064. 0x80031,
  25065. 0x900c2,
  25066. 0x70108,
  25067. 0x80061,
  25068. 0x80021,
  25069. 0x900a2,
  25070. 0x80001,
  25071. 0x80081,
  25072. 0x80041,
  25073. 0x900e2,
  25074. 0x70104,
  25075. 0x80059,
  25076. 0x80019,
  25077. 0x90092,
  25078. 0x70114,
  25079. 0x80079,
  25080. 0x80039,
  25081. 0x900d2,
  25082. 0x7010c,
  25083. 0x80069,
  25084. 0x80029,
  25085. 0x900b2,
  25086. 0x80009,
  25087. 0x80089,
  25088. 0x80049,
  25089. 0x900f2,
  25090. 0x70102,
  25091. 0x80055,
  25092. 0x80015,
  25093. 0x8011d,
  25094. 0x70112,
  25095. 0x80075,
  25096. 0x80035,
  25097. 0x900ca,
  25098. 0x7010a,
  25099. 0x80065,
  25100. 0x80025,
  25101. 0x900aa,
  25102. 0x80005,
  25103. 0x80085,
  25104. 0x80045,
  25105. 0x900ea,
  25106. 0x70106,
  25107. 0x8005d,
  25108. 0x8001d,
  25109. 0x9009a,
  25110. 0x70116,
  25111. 0x8007d,
  25112. 0x8003d,
  25113. 0x900da,
  25114. 0x7010e,
  25115. 0x8006d,
  25116. 0x8002d,
  25117. 0x900ba,
  25118. 0x8000d,
  25119. 0x8008d,
  25120. 0x8004d,
  25121. 0x900fa,
  25122. 0x70101,
  25123. 0x80053,
  25124. 0x80013,
  25125. 0x8011b,
  25126. 0x70111,
  25127. 0x80073,
  25128. 0x80033,
  25129. 0x900c6,
  25130. 0x70109,
  25131. 0x80063,
  25132. 0x80023,
  25133. 0x900a6,
  25134. 0x80003,
  25135. 0x80083,
  25136. 0x80043,
  25137. 0x900e6,
  25138. 0x70105,
  25139. 0x8005b,
  25140. 0x8001b,
  25141. 0x90096,
  25142. 0x70115,
  25143. 0x8007b,
  25144. 0x8003b,
  25145. 0x900d6,
  25146. 0x7010d,
  25147. 0x8006b,
  25148. 0x8002b,
  25149. 0x900b6,
  25150. 0x8000b,
  25151. 0x8008b,
  25152. 0x8004b,
  25153. 0x900f6,
  25154. 0x70103,
  25155. 0x80057,
  25156. 0x80017,
  25157. 0x8011f,
  25158. 0x70113,
  25159. 0x80077,
  25160. 0x80037,
  25161. 0x900ce,
  25162. 0x7010b,
  25163. 0x80067,
  25164. 0x80027,
  25165. 0x900ae,
  25166. 0x80007,
  25167. 0x80087,
  25168. 0x80047,
  25169. 0x900ee,
  25170. 0x70107,
  25171. 0x8005f,
  25172. 0x8001f,
  25173. 0x9009e,
  25174. 0x70117,
  25175. 0x8007f,
  25176. 0x8003f,
  25177. 0x900de,
  25178. 0x7010f,
  25179. 0x8006f,
  25180. 0x8002f,
  25181. 0x900be,
  25182. 0x8000f,
  25183. 0x8008f,
  25184. 0x8004f,
  25185. 0x900fe,
  25186. 0x70100,
  25187. 0x80050,
  25188. 0x80010,
  25189. 0x80118,
  25190. 0x70110,
  25191. 0x80070,
  25192. 0x80030,
  25193. 0x900c1,
  25194. 0x70108,
  25195. 0x80060,
  25196. 0x80020,
  25197. 0x900a1,
  25198. 0x80000,
  25199. 0x80080,
  25200. 0x80040,
  25201. 0x900e1,
  25202. 0x70104,
  25203. 0x80058,
  25204. 0x80018,
  25205. 0x90091,
  25206. 0x70114,
  25207. 0x80078,
  25208. 0x80038,
  25209. 0x900d1,
  25210. 0x7010c,
  25211. 0x80068,
  25212. 0x80028,
  25213. 0x900b1,
  25214. 0x80008,
  25215. 0x80088,
  25216. 0x80048,
  25217. 0x900f1,
  25218. 0x70102,
  25219. 0x80054,
  25220. 0x80014,
  25221. 0x8011c,
  25222. 0x70112,
  25223. 0x80074,
  25224. 0x80034,
  25225. 0x900c9,
  25226. 0x7010a,
  25227. 0x80064,
  25228. 0x80024,
  25229. 0x900a9,
  25230. 0x80004,
  25231. 0x80084,
  25232. 0x80044,
  25233. 0x900e9,
  25234. 0x70106,
  25235. 0x8005c,
  25236. 0x8001c,
  25237. 0x90099,
  25238. 0x70116,
  25239. 0x8007c,
  25240. 0x8003c,
  25241. 0x900d9,
  25242. 0x7010e,
  25243. 0x8006c,
  25244. 0x8002c,
  25245. 0x900b9,
  25246. 0x8000c,
  25247. 0x8008c,
  25248. 0x8004c,
  25249. 0x900f9,
  25250. 0x70101,
  25251. 0x80052,
  25252. 0x80012,
  25253. 0x8011a,
  25254. 0x70111,
  25255. 0x80072,
  25256. 0x80032,
  25257. 0x900c5,
  25258. 0x70109,
  25259. 0x80062,
  25260. 0x80022,
  25261. 0x900a5,
  25262. 0x80002,
  25263. 0x80082,
  25264. 0x80042,
  25265. 0x900e5,
  25266. 0x70105,
  25267. 0x8005a,
  25268. 0x8001a,
  25269. 0x90095,
  25270. 0x70115,
  25271. 0x8007a,
  25272. 0x8003a,
  25273. 0x900d5,
  25274. 0x7010d,
  25275. 0x8006a,
  25276. 0x8002a,
  25277. 0x900b5,
  25278. 0x8000a,
  25279. 0x8008a,
  25280. 0x8004a,
  25281. 0x900f5,
  25282. 0x70103,
  25283. 0x80056,
  25284. 0x80016,
  25285. 0x8011e,
  25286. 0x70113,
  25287. 0x80076,
  25288. 0x80036,
  25289. 0x900cd,
  25290. 0x7010b,
  25291. 0x80066,
  25292. 0x80026,
  25293. 0x900ad,
  25294. 0x80006,
  25295. 0x80086,
  25296. 0x80046,
  25297. 0x900ed,
  25298. 0x70107,
  25299. 0x8005e,
  25300. 0x8001e,
  25301. 0x9009d,
  25302. 0x70117,
  25303. 0x8007e,
  25304. 0x8003e,
  25305. 0x900dd,
  25306. 0x7010f,
  25307. 0x8006e,
  25308. 0x8002e,
  25309. 0x900bd,
  25310. 0x8000e,
  25311. 0x8008e,
  25312. 0x8004e,
  25313. 0x900fd,
  25314. 0x70100,
  25315. 0x80051,
  25316. 0x80011,
  25317. 0x80119,
  25318. 0x70110,
  25319. 0x80071,
  25320. 0x80031,
  25321. 0x900c3,
  25322. 0x70108,
  25323. 0x80061,
  25324. 0x80021,
  25325. 0x900a3,
  25326. 0x80001,
  25327. 0x80081,
  25328. 0x80041,
  25329. 0x900e3,
  25330. 0x70104,
  25331. 0x80059,
  25332. 0x80019,
  25333. 0x90093,
  25334. 0x70114,
  25335. 0x80079,
  25336. 0x80039,
  25337. 0x900d3,
  25338. 0x7010c,
  25339. 0x80069,
  25340. 0x80029,
  25341. 0x900b3,
  25342. 0x80009,
  25343. 0x80089,
  25344. 0x80049,
  25345. 0x900f3,
  25346. 0x70102,
  25347. 0x80055,
  25348. 0x80015,
  25349. 0x8011d,
  25350. 0x70112,
  25351. 0x80075,
  25352. 0x80035,
  25353. 0x900cb,
  25354. 0x7010a,
  25355. 0x80065,
  25356. 0x80025,
  25357. 0x900ab,
  25358. 0x80005,
  25359. 0x80085,
  25360. 0x80045,
  25361. 0x900eb,
  25362. 0x70106,
  25363. 0x8005d,
  25364. 0x8001d,
  25365. 0x9009b,
  25366. 0x70116,
  25367. 0x8007d,
  25368. 0x8003d,
  25369. 0x900db,
  25370. 0x7010e,
  25371. 0x8006d,
  25372. 0x8002d,
  25373. 0x900bb,
  25374. 0x8000d,
  25375. 0x8008d,
  25376. 0x8004d,
  25377. 0x900fb,
  25378. 0x70101,
  25379. 0x80053,
  25380. 0x80013,
  25381. 0x8011b,
  25382. 0x70111,
  25383. 0x80073,
  25384. 0x80033,
  25385. 0x900c7,
  25386. 0x70109,
  25387. 0x80063,
  25388. 0x80023,
  25389. 0x900a7,
  25390. 0x80003,
  25391. 0x80083,
  25392. 0x80043,
  25393. 0x900e7,
  25394. 0x70105,
  25395. 0x8005b,
  25396. 0x8001b,
  25397. 0x90097,
  25398. 0x70115,
  25399. 0x8007b,
  25400. 0x8003b,
  25401. 0x900d7,
  25402. 0x7010d,
  25403. 0x8006b,
  25404. 0x8002b,
  25405. 0x900b7,
  25406. 0x8000b,
  25407. 0x8008b,
  25408. 0x8004b,
  25409. 0x900f7,
  25410. 0x70103,
  25411. 0x80057,
  25412. 0x80017,
  25413. 0x8011f,
  25414. 0x70113,
  25415. 0x80077,
  25416. 0x80037,
  25417. 0x900cf,
  25418. 0x7010b,
  25419. 0x80067,
  25420. 0x80027,
  25421. 0x900af,
  25422. 0x80007,
  25423. 0x80087,
  25424. 0x80047,
  25425. 0x900ef,
  25426. 0x70107,
  25427. 0x8005f,
  25428. 0x8001f,
  25429. 0x9009f,
  25430. 0x70117,
  25431. 0x8007f,
  25432. 0x8003f,
  25433. 0x900df,
  25434. 0x7010f,
  25435. 0x8006f,
  25436. 0x8002f,
  25437. 0x900bf,
  25438. 0x8000f,
  25439. 0x8008f,
  25440. 0x8004f,
  25441. 0x900ff
  25442. ]),
  25443. 9
  25444. ];
  25445. var fixedDistCodeTab = [
  25446. new Int32Array([
  25447. 0x50000,
  25448. 0x50010,
  25449. 0x50008,
  25450. 0x50018,
  25451. 0x50004,
  25452. 0x50014,
  25453. 0x5000c,
  25454. 0x5001c,
  25455. 0x50002,
  25456. 0x50012,
  25457. 0x5000a,
  25458. 0x5001a,
  25459. 0x50006,
  25460. 0x50016,
  25461. 0x5000e,
  25462. 0x00000,
  25463. 0x50001,
  25464. 0x50011,
  25465. 0x50009,
  25466. 0x50019,
  25467. 0x50005,
  25468. 0x50015,
  25469. 0x5000d,
  25470. 0x5001d,
  25471. 0x50003,
  25472. 0x50013,
  25473. 0x5000b,
  25474. 0x5001b,
  25475. 0x50007,
  25476. 0x50017,
  25477. 0x5000f,
  25478. 0x00000
  25479. ]),
  25480. 5
  25481. ];
  25482. function FlateStream(str, maybeLength) {
  25483. this.str = str;
  25484. this.dict = str.dict;
  25485. var cmf = str.getByte();
  25486. var flg = str.getByte();
  25487. if (cmf === -1 || flg === -1) {
  25488. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25489. }
  25490. if ((cmf & 0x0f) !== 0x08) {
  25491. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25492. }
  25493. if (((cmf << 8) + flg) % 31 !== 0) {
  25494. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25495. }
  25496. if (flg & 0x20) {
  25497. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25498. }
  25499. this.codeSize = 0;
  25500. this.codeBuf = 0;
  25501. DecodeStream.call(this, maybeLength);
  25502. }
  25503. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25504. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25505. var str = this.str;
  25506. var codeSize = this.codeSize;
  25507. var codeBuf = this.codeBuf;
  25508. var b;
  25509. while (codeSize < bits) {
  25510. if ((b = str.getByte()) === -1) {
  25511. error('Bad encoding in flate stream');
  25512. }
  25513. codeBuf |= b << codeSize;
  25514. codeSize += 8;
  25515. }
  25516. b = codeBuf & (1 << bits) - 1;
  25517. this.codeBuf = codeBuf >> bits;
  25518. this.codeSize = codeSize -= bits;
  25519. return b;
  25520. };
  25521. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25522. var str = this.str;
  25523. var codes = table[0];
  25524. var maxLen = table[1];
  25525. var codeSize = this.codeSize;
  25526. var codeBuf = this.codeBuf;
  25527. var b;
  25528. while (codeSize < maxLen) {
  25529. if ((b = str.getByte()) === -1) {
  25530. break;
  25531. }
  25532. codeBuf |= b << codeSize;
  25533. codeSize += 8;
  25534. }
  25535. var code = codes[codeBuf & (1 << maxLen) - 1];
  25536. var codeLen = code >> 16;
  25537. var codeVal = code & 0xffff;
  25538. if (codeLen < 1 || codeSize < codeLen) {
  25539. error('Bad encoding in flate stream');
  25540. }
  25541. this.codeBuf = codeBuf >> codeLen;
  25542. this.codeSize = codeSize - codeLen;
  25543. return codeVal;
  25544. };
  25545. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25546. var n = lengths.length;
  25547. var maxLen = 0;
  25548. var i;
  25549. for (i = 0; i < n; ++i) {
  25550. if (lengths[i] > maxLen) {
  25551. maxLen = lengths[i];
  25552. }
  25553. }
  25554. var size = 1 << maxLen;
  25555. var codes = new Int32Array(size);
  25556. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25557. for (var val = 0; val < n; ++val) {
  25558. if (lengths[val] === len) {
  25559. var code2 = 0;
  25560. var t = code;
  25561. for (i = 0; i < len; ++i) {
  25562. code2 = code2 << 1 | t & 1;
  25563. t >>= 1;
  25564. }
  25565. for (i = code2; i < size; i += skip) {
  25566. codes[i] = len << 16 | val;
  25567. }
  25568. ++code;
  25569. }
  25570. }
  25571. }
  25572. return [
  25573. codes,
  25574. maxLen
  25575. ];
  25576. };
  25577. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25578. var buffer, len;
  25579. var str = this.str;
  25580. var hdr = this.getBits(3);
  25581. if (hdr & 1) {
  25582. this.eof = true;
  25583. }
  25584. hdr >>= 1;
  25585. if (hdr === 0) {
  25586. var b;
  25587. if ((b = str.getByte()) === -1) {
  25588. error('Bad block header in flate stream');
  25589. }
  25590. var blockLen = b;
  25591. if ((b = str.getByte()) === -1) {
  25592. error('Bad block header in flate stream');
  25593. }
  25594. blockLen |= b << 8;
  25595. if ((b = str.getByte()) === -1) {
  25596. error('Bad block header in flate stream');
  25597. }
  25598. var check = b;
  25599. if ((b = str.getByte()) === -1) {
  25600. error('Bad block header in flate stream');
  25601. }
  25602. check |= b << 8;
  25603. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25604. error('Bad uncompressed block length in flate stream');
  25605. }
  25606. this.codeBuf = 0;
  25607. this.codeSize = 0;
  25608. var bufferLength = this.bufferLength;
  25609. buffer = this.ensureBuffer(bufferLength + blockLen);
  25610. var end = bufferLength + blockLen;
  25611. this.bufferLength = end;
  25612. if (blockLen === 0) {
  25613. if (str.peekByte() === -1) {
  25614. this.eof = true;
  25615. }
  25616. } else {
  25617. for (var n = bufferLength; n < end; ++n) {
  25618. if ((b = str.getByte()) === -1) {
  25619. this.eof = true;
  25620. break;
  25621. }
  25622. buffer[n] = b;
  25623. }
  25624. }
  25625. return;
  25626. }
  25627. var litCodeTable;
  25628. var distCodeTable;
  25629. if (hdr === 1) {
  25630. litCodeTable = fixedLitCodeTab;
  25631. distCodeTable = fixedDistCodeTab;
  25632. } else if (hdr === 2) {
  25633. var numLitCodes = this.getBits(5) + 257;
  25634. var numDistCodes = this.getBits(5) + 1;
  25635. var numCodeLenCodes = this.getBits(4) + 4;
  25636. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25637. var i;
  25638. for (i = 0; i < numCodeLenCodes; ++i) {
  25639. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25640. }
  25641. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25642. len = 0;
  25643. i = 0;
  25644. var codes = numLitCodes + numDistCodes;
  25645. var codeLengths = new Uint8Array(codes);
  25646. var bitsLength, bitsOffset, what;
  25647. while (i < codes) {
  25648. var code = this.getCode(codeLenCodeTab);
  25649. if (code === 16) {
  25650. bitsLength = 2;
  25651. bitsOffset = 3;
  25652. what = len;
  25653. } else if (code === 17) {
  25654. bitsLength = 3;
  25655. bitsOffset = 3;
  25656. what = len = 0;
  25657. } else if (code === 18) {
  25658. bitsLength = 7;
  25659. bitsOffset = 11;
  25660. what = len = 0;
  25661. } else {
  25662. codeLengths[i++] = len = code;
  25663. continue;
  25664. }
  25665. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25666. while (repeatLength-- > 0) {
  25667. codeLengths[i++] = what;
  25668. }
  25669. }
  25670. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25671. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25672. } else {
  25673. error('Unknown block type in flate stream');
  25674. }
  25675. buffer = this.buffer;
  25676. var limit = buffer ? buffer.length : 0;
  25677. var pos = this.bufferLength;
  25678. while (true) {
  25679. var code1 = this.getCode(litCodeTable);
  25680. if (code1 < 256) {
  25681. if (pos + 1 >= limit) {
  25682. buffer = this.ensureBuffer(pos + 1);
  25683. limit = buffer.length;
  25684. }
  25685. buffer[pos++] = code1;
  25686. continue;
  25687. }
  25688. if (code1 === 256) {
  25689. this.bufferLength = pos;
  25690. return;
  25691. }
  25692. code1 -= 257;
  25693. code1 = lengthDecode[code1];
  25694. var code2 = code1 >> 16;
  25695. if (code2 > 0) {
  25696. code2 = this.getBits(code2);
  25697. }
  25698. len = (code1 & 0xffff) + code2;
  25699. code1 = this.getCode(distCodeTable);
  25700. code1 = distDecode[code1];
  25701. code2 = code1 >> 16;
  25702. if (code2 > 0) {
  25703. code2 = this.getBits(code2);
  25704. }
  25705. var dist = (code1 & 0xffff) + code2;
  25706. if (pos + len >= limit) {
  25707. buffer = this.ensureBuffer(pos + len);
  25708. limit = buffer.length;
  25709. }
  25710. for (var k = 0; k < len; ++k, ++pos) {
  25711. buffer[pos] = buffer[pos - dist];
  25712. }
  25713. }
  25714. };
  25715. return FlateStream;
  25716. }();
  25717. var PredictorStream = function PredictorStreamClosure() {
  25718. function PredictorStream(str, maybeLength, params) {
  25719. if (!isDict(params)) {
  25720. return str;
  25721. }
  25722. var predictor = this.predictor = params.get('Predictor') || 1;
  25723. if (predictor <= 1) {
  25724. return str;
  25725. }
  25726. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25727. error('Unsupported predictor: ' + predictor);
  25728. }
  25729. if (predictor === 2) {
  25730. this.readBlock = this.readBlockTiff;
  25731. } else {
  25732. this.readBlock = this.readBlockPng;
  25733. }
  25734. this.str = str;
  25735. this.dict = str.dict;
  25736. var colors = this.colors = params.get('Colors') || 1;
  25737. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25738. var columns = this.columns = params.get('Columns') || 1;
  25739. this.pixBytes = colors * bits + 7 >> 3;
  25740. this.rowBytes = columns * colors * bits + 7 >> 3;
  25741. DecodeStream.call(this, maybeLength);
  25742. return this;
  25743. }
  25744. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25745. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25746. var rowBytes = this.rowBytes;
  25747. var bufferLength = this.bufferLength;
  25748. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25749. var bits = this.bits;
  25750. var colors = this.colors;
  25751. var rawBytes = this.str.getBytes(rowBytes);
  25752. this.eof = !rawBytes.length;
  25753. if (this.eof) {
  25754. return;
  25755. }
  25756. var inbuf = 0, outbuf = 0;
  25757. var inbits = 0, outbits = 0;
  25758. var pos = bufferLength;
  25759. var i;
  25760. if (bits === 1) {
  25761. for (i = 0; i < rowBytes; ++i) {
  25762. var c = rawBytes[i];
  25763. inbuf = inbuf << 8 | c;
  25764. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  25765. inbuf &= 0xFFFF;
  25766. }
  25767. } else if (bits === 8) {
  25768. for (i = 0; i < colors; ++i) {
  25769. buffer[pos++] = rawBytes[i];
  25770. }
  25771. for (; i < rowBytes; ++i) {
  25772. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  25773. pos++;
  25774. }
  25775. } else {
  25776. var compArray = new Uint8Array(colors + 1);
  25777. var bitMask = (1 << bits) - 1;
  25778. var j = 0, k = bufferLength;
  25779. var columns = this.columns;
  25780. for (i = 0; i < columns; ++i) {
  25781. for (var kk = 0; kk < colors; ++kk) {
  25782. if (inbits < bits) {
  25783. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  25784. inbits += 8;
  25785. }
  25786. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  25787. inbits -= bits;
  25788. outbuf = outbuf << bits | compArray[kk];
  25789. outbits += bits;
  25790. if (outbits >= 8) {
  25791. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  25792. outbits -= 8;
  25793. }
  25794. }
  25795. }
  25796. if (outbits > 0) {
  25797. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  25798. }
  25799. }
  25800. this.bufferLength += rowBytes;
  25801. };
  25802. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  25803. var rowBytes = this.rowBytes;
  25804. var pixBytes = this.pixBytes;
  25805. var predictor = this.str.getByte();
  25806. var rawBytes = this.str.getBytes(rowBytes);
  25807. this.eof = !rawBytes.length;
  25808. if (this.eof) {
  25809. return;
  25810. }
  25811. var bufferLength = this.bufferLength;
  25812. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25813. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  25814. if (prevRow.length === 0) {
  25815. prevRow = new Uint8Array(rowBytes);
  25816. }
  25817. var i, j = bufferLength, up, c;
  25818. switch (predictor) {
  25819. case 0:
  25820. for (i = 0; i < rowBytes; ++i) {
  25821. buffer[j++] = rawBytes[i];
  25822. }
  25823. break;
  25824. case 1:
  25825. for (i = 0; i < pixBytes; ++i) {
  25826. buffer[j++] = rawBytes[i];
  25827. }
  25828. for (; i < rowBytes; ++i) {
  25829. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  25830. j++;
  25831. }
  25832. break;
  25833. case 2:
  25834. for (i = 0; i < rowBytes; ++i) {
  25835. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  25836. }
  25837. break;
  25838. case 3:
  25839. for (i = 0; i < pixBytes; ++i) {
  25840. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  25841. }
  25842. for (; i < rowBytes; ++i) {
  25843. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  25844. j++;
  25845. }
  25846. break;
  25847. case 4:
  25848. for (i = 0; i < pixBytes; ++i) {
  25849. up = prevRow[i];
  25850. c = rawBytes[i];
  25851. buffer[j++] = up + c;
  25852. }
  25853. for (; i < rowBytes; ++i) {
  25854. up = prevRow[i];
  25855. var upLeft = prevRow[i - pixBytes];
  25856. var left = buffer[j - pixBytes];
  25857. var p = left + up - upLeft;
  25858. var pa = p - left;
  25859. if (pa < 0) {
  25860. pa = -pa;
  25861. }
  25862. var pb = p - up;
  25863. if (pb < 0) {
  25864. pb = -pb;
  25865. }
  25866. var pc = p - upLeft;
  25867. if (pc < 0) {
  25868. pc = -pc;
  25869. }
  25870. c = rawBytes[i];
  25871. if (pa <= pb && pa <= pc) {
  25872. buffer[j++] = left + c;
  25873. } else if (pb <= pc) {
  25874. buffer[j++] = up + c;
  25875. } else {
  25876. buffer[j++] = upLeft + c;
  25877. }
  25878. }
  25879. break;
  25880. default:
  25881. error('Unsupported predictor: ' + predictor);
  25882. }
  25883. this.bufferLength += rowBytes;
  25884. };
  25885. return PredictorStream;
  25886. }();
  25887. var JpegStream = function JpegStreamClosure() {
  25888. function JpegStream(stream, maybeLength, dict, params) {
  25889. var ch;
  25890. while ((ch = stream.getByte()) !== -1) {
  25891. if (ch === 0xFF) {
  25892. stream.skip(-1);
  25893. break;
  25894. }
  25895. }
  25896. this.stream = stream;
  25897. this.maybeLength = maybeLength;
  25898. this.dict = dict;
  25899. this.params = params;
  25900. DecodeStream.call(this, maybeLength);
  25901. }
  25902. JpegStream.prototype = Object.create(DecodeStream.prototype);
  25903. Object.defineProperty(JpegStream.prototype, 'bytes', {
  25904. get: function JpegStream_bytes() {
  25905. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25906. },
  25907. configurable: true
  25908. });
  25909. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  25910. if (this.bufferLength) {
  25911. return;
  25912. }
  25913. var jpegImage = new JpegImage();
  25914. var decodeArr = this.dict.getArray('Decode', 'D');
  25915. if (this.forceRGB && isArray(decodeArr)) {
  25916. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  25917. var decodeArrLength = decodeArr.length;
  25918. var transform = new Int32Array(decodeArrLength);
  25919. var transformNeeded = false;
  25920. var maxValue = (1 << bitsPerComponent) - 1;
  25921. for (var i = 0; i < decodeArrLength; i += 2) {
  25922. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  25923. transform[i + 1] = decodeArr[i] * maxValue | 0;
  25924. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  25925. transformNeeded = true;
  25926. }
  25927. }
  25928. if (transformNeeded) {
  25929. jpegImage.decodeTransform = transform;
  25930. }
  25931. }
  25932. if (isDict(this.params)) {
  25933. var colorTransform = this.params.get('ColorTransform');
  25934. if (isInt(colorTransform)) {
  25935. jpegImage.colorTransform = colorTransform;
  25936. }
  25937. }
  25938. jpegImage.parse(this.bytes);
  25939. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  25940. this.buffer = data;
  25941. this.bufferLength = data.length;
  25942. this.eof = true;
  25943. };
  25944. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  25945. this.ensureBuffer();
  25946. return this.buffer;
  25947. };
  25948. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  25949. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  25950. };
  25951. return JpegStream;
  25952. }();
  25953. var JpxStream = function JpxStreamClosure() {
  25954. function JpxStream(stream, maybeLength, dict, params) {
  25955. this.stream = stream;
  25956. this.maybeLength = maybeLength;
  25957. this.dict = dict;
  25958. this.params = params;
  25959. DecodeStream.call(this, maybeLength);
  25960. }
  25961. JpxStream.prototype = Object.create(DecodeStream.prototype);
  25962. Object.defineProperty(JpxStream.prototype, 'bytes', {
  25963. get: function JpxStream_bytes() {
  25964. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25965. },
  25966. configurable: true
  25967. });
  25968. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  25969. if (this.bufferLength) {
  25970. return;
  25971. }
  25972. var jpxImage = new JpxImage();
  25973. jpxImage.parse(this.bytes);
  25974. var width = jpxImage.width;
  25975. var height = jpxImage.height;
  25976. var componentsCount = jpxImage.componentsCount;
  25977. var tileCount = jpxImage.tiles.length;
  25978. if (tileCount === 1) {
  25979. this.buffer = jpxImage.tiles[0].items;
  25980. } else {
  25981. var data = new Uint8Array(width * height * componentsCount);
  25982. for (var k = 0; k < tileCount; k++) {
  25983. var tileComponents = jpxImage.tiles[k];
  25984. var tileWidth = tileComponents.width;
  25985. var tileHeight = tileComponents.height;
  25986. var tileLeft = tileComponents.left;
  25987. var tileTop = tileComponents.top;
  25988. var src = tileComponents.items;
  25989. var srcPosition = 0;
  25990. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  25991. var imgRowSize = width * componentsCount;
  25992. var tileRowSize = tileWidth * componentsCount;
  25993. for (var j = 0; j < tileHeight; j++) {
  25994. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  25995. data.set(rowBytes, dataPosition);
  25996. srcPosition += tileRowSize;
  25997. dataPosition += imgRowSize;
  25998. }
  25999. }
  26000. this.buffer = data;
  26001. }
  26002. this.bufferLength = this.buffer.length;
  26003. this.eof = true;
  26004. };
  26005. return JpxStream;
  26006. }();
  26007. var Jbig2Stream = function Jbig2StreamClosure() {
  26008. function Jbig2Stream(stream, maybeLength, dict, params) {
  26009. this.stream = stream;
  26010. this.maybeLength = maybeLength;
  26011. this.dict = dict;
  26012. this.params = params;
  26013. DecodeStream.call(this, maybeLength);
  26014. }
  26015. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26016. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26017. get: function Jbig2Stream_bytes() {
  26018. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26019. },
  26020. configurable: true
  26021. });
  26022. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26023. if (this.bufferLength) {
  26024. return;
  26025. }
  26026. var jbig2Image = new Jbig2Image();
  26027. var chunks = [];
  26028. if (isDict(this.params)) {
  26029. var globalsStream = this.params.get('JBIG2Globals');
  26030. if (isStream(globalsStream)) {
  26031. var globals = globalsStream.getBytes();
  26032. chunks.push({
  26033. data: globals,
  26034. start: 0,
  26035. end: globals.length
  26036. });
  26037. }
  26038. }
  26039. chunks.push({
  26040. data: this.bytes,
  26041. start: 0,
  26042. end: this.bytes.length
  26043. });
  26044. var data = jbig2Image.parseChunks(chunks);
  26045. var dataLength = data.length;
  26046. for (var i = 0; i < dataLength; i++) {
  26047. data[i] ^= 0xFF;
  26048. }
  26049. this.buffer = data;
  26050. this.bufferLength = dataLength;
  26051. this.eof = true;
  26052. };
  26053. return Jbig2Stream;
  26054. }();
  26055. var DecryptStream = function DecryptStreamClosure() {
  26056. function DecryptStream(str, maybeLength, decrypt) {
  26057. this.str = str;
  26058. this.dict = str.dict;
  26059. this.decrypt = decrypt;
  26060. this.nextChunk = null;
  26061. this.initialized = false;
  26062. DecodeStream.call(this, maybeLength);
  26063. }
  26064. var chunkSize = 512;
  26065. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26066. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26067. var chunk;
  26068. if (this.initialized) {
  26069. chunk = this.nextChunk;
  26070. } else {
  26071. chunk = this.str.getBytes(chunkSize);
  26072. this.initialized = true;
  26073. }
  26074. if (!chunk || chunk.length === 0) {
  26075. this.eof = true;
  26076. return;
  26077. }
  26078. this.nextChunk = this.str.getBytes(chunkSize);
  26079. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26080. var decrypt = this.decrypt;
  26081. chunk = decrypt(chunk, !hasMoreData);
  26082. var bufferLength = this.bufferLength;
  26083. var i, n = chunk.length;
  26084. var buffer = this.ensureBuffer(bufferLength + n);
  26085. for (i = 0; i < n; i++) {
  26086. buffer[bufferLength++] = chunk[i];
  26087. }
  26088. this.bufferLength = bufferLength;
  26089. };
  26090. return DecryptStream;
  26091. }();
  26092. var Ascii85Stream = function Ascii85StreamClosure() {
  26093. function Ascii85Stream(str, maybeLength) {
  26094. this.str = str;
  26095. this.dict = str.dict;
  26096. this.input = new Uint8Array(5);
  26097. if (maybeLength) {
  26098. maybeLength = 0.8 * maybeLength;
  26099. }
  26100. DecodeStream.call(this, maybeLength);
  26101. }
  26102. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26103. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26104. var TILDA_CHAR = 0x7E;
  26105. var Z_LOWER_CHAR = 0x7A;
  26106. var EOF = -1;
  26107. var str = this.str;
  26108. var c = str.getByte();
  26109. while (isSpace(c)) {
  26110. c = str.getByte();
  26111. }
  26112. if (c === EOF || c === TILDA_CHAR) {
  26113. this.eof = true;
  26114. return;
  26115. }
  26116. var bufferLength = this.bufferLength, buffer;
  26117. var i;
  26118. if (c === Z_LOWER_CHAR) {
  26119. buffer = this.ensureBuffer(bufferLength + 4);
  26120. for (i = 0; i < 4; ++i) {
  26121. buffer[bufferLength + i] = 0;
  26122. }
  26123. this.bufferLength += 4;
  26124. } else {
  26125. var input = this.input;
  26126. input[0] = c;
  26127. for (i = 1; i < 5; ++i) {
  26128. c = str.getByte();
  26129. while (isSpace(c)) {
  26130. c = str.getByte();
  26131. }
  26132. input[i] = c;
  26133. if (c === EOF || c === TILDA_CHAR) {
  26134. break;
  26135. }
  26136. }
  26137. buffer = this.ensureBuffer(bufferLength + i - 1);
  26138. this.bufferLength += i - 1;
  26139. if (i < 5) {
  26140. for (; i < 5; ++i) {
  26141. input[i] = 0x21 + 84;
  26142. }
  26143. this.eof = true;
  26144. }
  26145. var t = 0;
  26146. for (i = 0; i < 5; ++i) {
  26147. t = t * 85 + (input[i] - 0x21);
  26148. }
  26149. for (i = 3; i >= 0; --i) {
  26150. buffer[bufferLength + i] = t & 0xFF;
  26151. t >>= 8;
  26152. }
  26153. }
  26154. };
  26155. return Ascii85Stream;
  26156. }();
  26157. var AsciiHexStream = function AsciiHexStreamClosure() {
  26158. function AsciiHexStream(str, maybeLength) {
  26159. this.str = str;
  26160. this.dict = str.dict;
  26161. this.firstDigit = -1;
  26162. if (maybeLength) {
  26163. maybeLength = 0.5 * maybeLength;
  26164. }
  26165. DecodeStream.call(this, maybeLength);
  26166. }
  26167. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26168. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26169. var UPSTREAM_BLOCK_SIZE = 8000;
  26170. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26171. if (!bytes.length) {
  26172. this.eof = true;
  26173. return;
  26174. }
  26175. var maxDecodeLength = bytes.length + 1 >> 1;
  26176. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26177. var bufferLength = this.bufferLength;
  26178. var firstDigit = this.firstDigit;
  26179. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26180. var ch = bytes[i], digit;
  26181. if (ch >= 0x30 && ch <= 0x39) {
  26182. digit = ch & 0x0F;
  26183. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26184. digit = (ch & 0x0F) + 9;
  26185. } else if (ch === 0x3E) {
  26186. this.eof = true;
  26187. break;
  26188. } else {
  26189. continue;
  26190. }
  26191. if (firstDigit < 0) {
  26192. firstDigit = digit;
  26193. } else {
  26194. buffer[bufferLength++] = firstDigit << 4 | digit;
  26195. firstDigit = -1;
  26196. }
  26197. }
  26198. if (firstDigit >= 0 && this.eof) {
  26199. buffer[bufferLength++] = firstDigit << 4;
  26200. firstDigit = -1;
  26201. }
  26202. this.firstDigit = firstDigit;
  26203. this.bufferLength = bufferLength;
  26204. };
  26205. return AsciiHexStream;
  26206. }();
  26207. var RunLengthStream = function RunLengthStreamClosure() {
  26208. function RunLengthStream(str, maybeLength) {
  26209. this.str = str;
  26210. this.dict = str.dict;
  26211. DecodeStream.call(this, maybeLength);
  26212. }
  26213. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26214. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26215. var repeatHeader = this.str.getBytes(2);
  26216. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26217. this.eof = true;
  26218. return;
  26219. }
  26220. var buffer;
  26221. var bufferLength = this.bufferLength;
  26222. var n = repeatHeader[0];
  26223. if (n < 128) {
  26224. buffer = this.ensureBuffer(bufferLength + n + 1);
  26225. buffer[bufferLength++] = repeatHeader[1];
  26226. if (n > 0) {
  26227. var source = this.str.getBytes(n);
  26228. buffer.set(source, bufferLength);
  26229. bufferLength += n;
  26230. }
  26231. } else {
  26232. n = 257 - n;
  26233. var b = repeatHeader[1];
  26234. buffer = this.ensureBuffer(bufferLength + n + 1);
  26235. for (var i = 0; i < n; i++) {
  26236. buffer[bufferLength++] = b;
  26237. }
  26238. }
  26239. this.bufferLength = bufferLength;
  26240. };
  26241. return RunLengthStream;
  26242. }();
  26243. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26244. var ccittEOL = -2;
  26245. var ccittEOF = -1;
  26246. var twoDimPass = 0;
  26247. var twoDimHoriz = 1;
  26248. var twoDimVert0 = 2;
  26249. var twoDimVertR1 = 3;
  26250. var twoDimVertL1 = 4;
  26251. var twoDimVertR2 = 5;
  26252. var twoDimVertL2 = 6;
  26253. var twoDimVertR3 = 7;
  26254. var twoDimVertL3 = 8;
  26255. var twoDimTable = [
  26256. [
  26257. -1,
  26258. -1
  26259. ],
  26260. [
  26261. -1,
  26262. -1
  26263. ],
  26264. [
  26265. 7,
  26266. twoDimVertL3
  26267. ],
  26268. [
  26269. 7,
  26270. twoDimVertR3
  26271. ],
  26272. [
  26273. 6,
  26274. twoDimVertL2
  26275. ],
  26276. [
  26277. 6,
  26278. twoDimVertL2
  26279. ],
  26280. [
  26281. 6,
  26282. twoDimVertR2
  26283. ],
  26284. [
  26285. 6,
  26286. twoDimVertR2
  26287. ],
  26288. [
  26289. 4,
  26290. twoDimPass
  26291. ],
  26292. [
  26293. 4,
  26294. twoDimPass
  26295. ],
  26296. [
  26297. 4,
  26298. twoDimPass
  26299. ],
  26300. [
  26301. 4,
  26302. twoDimPass
  26303. ],
  26304. [
  26305. 4,
  26306. twoDimPass
  26307. ],
  26308. [
  26309. 4,
  26310. twoDimPass
  26311. ],
  26312. [
  26313. 4,
  26314. twoDimPass
  26315. ],
  26316. [
  26317. 4,
  26318. twoDimPass
  26319. ],
  26320. [
  26321. 3,
  26322. twoDimHoriz
  26323. ],
  26324. [
  26325. 3,
  26326. twoDimHoriz
  26327. ],
  26328. [
  26329. 3,
  26330. twoDimHoriz
  26331. ],
  26332. [
  26333. 3,
  26334. twoDimHoriz
  26335. ],
  26336. [
  26337. 3,
  26338. twoDimHoriz
  26339. ],
  26340. [
  26341. 3,
  26342. twoDimHoriz
  26343. ],
  26344. [
  26345. 3,
  26346. twoDimHoriz
  26347. ],
  26348. [
  26349. 3,
  26350. twoDimHoriz
  26351. ],
  26352. [
  26353. 3,
  26354. twoDimHoriz
  26355. ],
  26356. [
  26357. 3,
  26358. twoDimHoriz
  26359. ],
  26360. [
  26361. 3,
  26362. twoDimHoriz
  26363. ],
  26364. [
  26365. 3,
  26366. twoDimHoriz
  26367. ],
  26368. [
  26369. 3,
  26370. twoDimHoriz
  26371. ],
  26372. [
  26373. 3,
  26374. twoDimHoriz
  26375. ],
  26376. [
  26377. 3,
  26378. twoDimHoriz
  26379. ],
  26380. [
  26381. 3,
  26382. twoDimHoriz
  26383. ],
  26384. [
  26385. 3,
  26386. twoDimVertL1
  26387. ],
  26388. [
  26389. 3,
  26390. twoDimVertL1
  26391. ],
  26392. [
  26393. 3,
  26394. twoDimVertL1
  26395. ],
  26396. [
  26397. 3,
  26398. twoDimVertL1
  26399. ],
  26400. [
  26401. 3,
  26402. twoDimVertL1
  26403. ],
  26404. [
  26405. 3,
  26406. twoDimVertL1
  26407. ],
  26408. [
  26409. 3,
  26410. twoDimVertL1
  26411. ],
  26412. [
  26413. 3,
  26414. twoDimVertL1
  26415. ],
  26416. [
  26417. 3,
  26418. twoDimVertL1
  26419. ],
  26420. [
  26421. 3,
  26422. twoDimVertL1
  26423. ],
  26424. [
  26425. 3,
  26426. twoDimVertL1
  26427. ],
  26428. [
  26429. 3,
  26430. twoDimVertL1
  26431. ],
  26432. [
  26433. 3,
  26434. twoDimVertL1
  26435. ],
  26436. [
  26437. 3,
  26438. twoDimVertL1
  26439. ],
  26440. [
  26441. 3,
  26442. twoDimVertL1
  26443. ],
  26444. [
  26445. 3,
  26446. twoDimVertL1
  26447. ],
  26448. [
  26449. 3,
  26450. twoDimVertR1
  26451. ],
  26452. [
  26453. 3,
  26454. twoDimVertR1
  26455. ],
  26456. [
  26457. 3,
  26458. twoDimVertR1
  26459. ],
  26460. [
  26461. 3,
  26462. twoDimVertR1
  26463. ],
  26464. [
  26465. 3,
  26466. twoDimVertR1
  26467. ],
  26468. [
  26469. 3,
  26470. twoDimVertR1
  26471. ],
  26472. [
  26473. 3,
  26474. twoDimVertR1
  26475. ],
  26476. [
  26477. 3,
  26478. twoDimVertR1
  26479. ],
  26480. [
  26481. 3,
  26482. twoDimVertR1
  26483. ],
  26484. [
  26485. 3,
  26486. twoDimVertR1
  26487. ],
  26488. [
  26489. 3,
  26490. twoDimVertR1
  26491. ],
  26492. [
  26493. 3,
  26494. twoDimVertR1
  26495. ],
  26496. [
  26497. 3,
  26498. twoDimVertR1
  26499. ],
  26500. [
  26501. 3,
  26502. twoDimVertR1
  26503. ],
  26504. [
  26505. 3,
  26506. twoDimVertR1
  26507. ],
  26508. [
  26509. 3,
  26510. twoDimVertR1
  26511. ],
  26512. [
  26513. 1,
  26514. twoDimVert0
  26515. ],
  26516. [
  26517. 1,
  26518. twoDimVert0
  26519. ],
  26520. [
  26521. 1,
  26522. twoDimVert0
  26523. ],
  26524. [
  26525. 1,
  26526. twoDimVert0
  26527. ],
  26528. [
  26529. 1,
  26530. twoDimVert0
  26531. ],
  26532. [
  26533. 1,
  26534. twoDimVert0
  26535. ],
  26536. [
  26537. 1,
  26538. twoDimVert0
  26539. ],
  26540. [
  26541. 1,
  26542. twoDimVert0
  26543. ],
  26544. [
  26545. 1,
  26546. twoDimVert0
  26547. ],
  26548. [
  26549. 1,
  26550. twoDimVert0
  26551. ],
  26552. [
  26553. 1,
  26554. twoDimVert0
  26555. ],
  26556. [
  26557. 1,
  26558. twoDimVert0
  26559. ],
  26560. [
  26561. 1,
  26562. twoDimVert0
  26563. ],
  26564. [
  26565. 1,
  26566. twoDimVert0
  26567. ],
  26568. [
  26569. 1,
  26570. twoDimVert0
  26571. ],
  26572. [
  26573. 1,
  26574. twoDimVert0
  26575. ],
  26576. [
  26577. 1,
  26578. twoDimVert0
  26579. ],
  26580. [
  26581. 1,
  26582. twoDimVert0
  26583. ],
  26584. [
  26585. 1,
  26586. twoDimVert0
  26587. ],
  26588. [
  26589. 1,
  26590. twoDimVert0
  26591. ],
  26592. [
  26593. 1,
  26594. twoDimVert0
  26595. ],
  26596. [
  26597. 1,
  26598. twoDimVert0
  26599. ],
  26600. [
  26601. 1,
  26602. twoDimVert0
  26603. ],
  26604. [
  26605. 1,
  26606. twoDimVert0
  26607. ],
  26608. [
  26609. 1,
  26610. twoDimVert0
  26611. ],
  26612. [
  26613. 1,
  26614. twoDimVert0
  26615. ],
  26616. [
  26617. 1,
  26618. twoDimVert0
  26619. ],
  26620. [
  26621. 1,
  26622. twoDimVert0
  26623. ],
  26624. [
  26625. 1,
  26626. twoDimVert0
  26627. ],
  26628. [
  26629. 1,
  26630. twoDimVert0
  26631. ],
  26632. [
  26633. 1,
  26634. twoDimVert0
  26635. ],
  26636. [
  26637. 1,
  26638. twoDimVert0
  26639. ],
  26640. [
  26641. 1,
  26642. twoDimVert0
  26643. ],
  26644. [
  26645. 1,
  26646. twoDimVert0
  26647. ],
  26648. [
  26649. 1,
  26650. twoDimVert0
  26651. ],
  26652. [
  26653. 1,
  26654. twoDimVert0
  26655. ],
  26656. [
  26657. 1,
  26658. twoDimVert0
  26659. ],
  26660. [
  26661. 1,
  26662. twoDimVert0
  26663. ],
  26664. [
  26665. 1,
  26666. twoDimVert0
  26667. ],
  26668. [
  26669. 1,
  26670. twoDimVert0
  26671. ],
  26672. [
  26673. 1,
  26674. twoDimVert0
  26675. ],
  26676. [
  26677. 1,
  26678. twoDimVert0
  26679. ],
  26680. [
  26681. 1,
  26682. twoDimVert0
  26683. ],
  26684. [
  26685. 1,
  26686. twoDimVert0
  26687. ],
  26688. [
  26689. 1,
  26690. twoDimVert0
  26691. ],
  26692. [
  26693. 1,
  26694. twoDimVert0
  26695. ],
  26696. [
  26697. 1,
  26698. twoDimVert0
  26699. ],
  26700. [
  26701. 1,
  26702. twoDimVert0
  26703. ],
  26704. [
  26705. 1,
  26706. twoDimVert0
  26707. ],
  26708. [
  26709. 1,
  26710. twoDimVert0
  26711. ],
  26712. [
  26713. 1,
  26714. twoDimVert0
  26715. ],
  26716. [
  26717. 1,
  26718. twoDimVert0
  26719. ],
  26720. [
  26721. 1,
  26722. twoDimVert0
  26723. ],
  26724. [
  26725. 1,
  26726. twoDimVert0
  26727. ],
  26728. [
  26729. 1,
  26730. twoDimVert0
  26731. ],
  26732. [
  26733. 1,
  26734. twoDimVert0
  26735. ],
  26736. [
  26737. 1,
  26738. twoDimVert0
  26739. ],
  26740. [
  26741. 1,
  26742. twoDimVert0
  26743. ],
  26744. [
  26745. 1,
  26746. twoDimVert0
  26747. ],
  26748. [
  26749. 1,
  26750. twoDimVert0
  26751. ],
  26752. [
  26753. 1,
  26754. twoDimVert0
  26755. ],
  26756. [
  26757. 1,
  26758. twoDimVert0
  26759. ],
  26760. [
  26761. 1,
  26762. twoDimVert0
  26763. ],
  26764. [
  26765. 1,
  26766. twoDimVert0
  26767. ]
  26768. ];
  26769. var whiteTable1 = [
  26770. [
  26771. -1,
  26772. -1
  26773. ],
  26774. [
  26775. 12,
  26776. ccittEOL
  26777. ],
  26778. [
  26779. -1,
  26780. -1
  26781. ],
  26782. [
  26783. -1,
  26784. -1
  26785. ],
  26786. [
  26787. -1,
  26788. -1
  26789. ],
  26790. [
  26791. -1,
  26792. -1
  26793. ],
  26794. [
  26795. -1,
  26796. -1
  26797. ],
  26798. [
  26799. -1,
  26800. -1
  26801. ],
  26802. [
  26803. -1,
  26804. -1
  26805. ],
  26806. [
  26807. -1,
  26808. -1
  26809. ],
  26810. [
  26811. -1,
  26812. -1
  26813. ],
  26814. [
  26815. -1,
  26816. -1
  26817. ],
  26818. [
  26819. -1,
  26820. -1
  26821. ],
  26822. [
  26823. -1,
  26824. -1
  26825. ],
  26826. [
  26827. -1,
  26828. -1
  26829. ],
  26830. [
  26831. -1,
  26832. -1
  26833. ],
  26834. [
  26835. 11,
  26836. 1792
  26837. ],
  26838. [
  26839. 11,
  26840. 1792
  26841. ],
  26842. [
  26843. 12,
  26844. 1984
  26845. ],
  26846. [
  26847. 12,
  26848. 2048
  26849. ],
  26850. [
  26851. 12,
  26852. 2112
  26853. ],
  26854. [
  26855. 12,
  26856. 2176
  26857. ],
  26858. [
  26859. 12,
  26860. 2240
  26861. ],
  26862. [
  26863. 12,
  26864. 2304
  26865. ],
  26866. [
  26867. 11,
  26868. 1856
  26869. ],
  26870. [
  26871. 11,
  26872. 1856
  26873. ],
  26874. [
  26875. 11,
  26876. 1920
  26877. ],
  26878. [
  26879. 11,
  26880. 1920
  26881. ],
  26882. [
  26883. 12,
  26884. 2368
  26885. ],
  26886. [
  26887. 12,
  26888. 2432
  26889. ],
  26890. [
  26891. 12,
  26892. 2496
  26893. ],
  26894. [
  26895. 12,
  26896. 2560
  26897. ]
  26898. ];
  26899. var whiteTable2 = [
  26900. [
  26901. -1,
  26902. -1
  26903. ],
  26904. [
  26905. -1,
  26906. -1
  26907. ],
  26908. [
  26909. -1,
  26910. -1
  26911. ],
  26912. [
  26913. -1,
  26914. -1
  26915. ],
  26916. [
  26917. 8,
  26918. 29
  26919. ],
  26920. [
  26921. 8,
  26922. 29
  26923. ],
  26924. [
  26925. 8,
  26926. 30
  26927. ],
  26928. [
  26929. 8,
  26930. 30
  26931. ],
  26932. [
  26933. 8,
  26934. 45
  26935. ],
  26936. [
  26937. 8,
  26938. 45
  26939. ],
  26940. [
  26941. 8,
  26942. 46
  26943. ],
  26944. [
  26945. 8,
  26946. 46
  26947. ],
  26948. [
  26949. 7,
  26950. 22
  26951. ],
  26952. [
  26953. 7,
  26954. 22
  26955. ],
  26956. [
  26957. 7,
  26958. 22
  26959. ],
  26960. [
  26961. 7,
  26962. 22
  26963. ],
  26964. [
  26965. 7,
  26966. 23
  26967. ],
  26968. [
  26969. 7,
  26970. 23
  26971. ],
  26972. [
  26973. 7,
  26974. 23
  26975. ],
  26976. [
  26977. 7,
  26978. 23
  26979. ],
  26980. [
  26981. 8,
  26982. 47
  26983. ],
  26984. [
  26985. 8,
  26986. 47
  26987. ],
  26988. [
  26989. 8,
  26990. 48
  26991. ],
  26992. [
  26993. 8,
  26994. 48
  26995. ],
  26996. [
  26997. 6,
  26998. 13
  26999. ],
  27000. [
  27001. 6,
  27002. 13
  27003. ],
  27004. [
  27005. 6,
  27006. 13
  27007. ],
  27008. [
  27009. 6,
  27010. 13
  27011. ],
  27012. [
  27013. 6,
  27014. 13
  27015. ],
  27016. [
  27017. 6,
  27018. 13
  27019. ],
  27020. [
  27021. 6,
  27022. 13
  27023. ],
  27024. [
  27025. 6,
  27026. 13
  27027. ],
  27028. [
  27029. 7,
  27030. 20
  27031. ],
  27032. [
  27033. 7,
  27034. 20
  27035. ],
  27036. [
  27037. 7,
  27038. 20
  27039. ],
  27040. [
  27041. 7,
  27042. 20
  27043. ],
  27044. [
  27045. 8,
  27046. 33
  27047. ],
  27048. [
  27049. 8,
  27050. 33
  27051. ],
  27052. [
  27053. 8,
  27054. 34
  27055. ],
  27056. [
  27057. 8,
  27058. 34
  27059. ],
  27060. [
  27061. 8,
  27062. 35
  27063. ],
  27064. [
  27065. 8,
  27066. 35
  27067. ],
  27068. [
  27069. 8,
  27070. 36
  27071. ],
  27072. [
  27073. 8,
  27074. 36
  27075. ],
  27076. [
  27077. 8,
  27078. 37
  27079. ],
  27080. [
  27081. 8,
  27082. 37
  27083. ],
  27084. [
  27085. 8,
  27086. 38
  27087. ],
  27088. [
  27089. 8,
  27090. 38
  27091. ],
  27092. [
  27093. 7,
  27094. 19
  27095. ],
  27096. [
  27097. 7,
  27098. 19
  27099. ],
  27100. [
  27101. 7,
  27102. 19
  27103. ],
  27104. [
  27105. 7,
  27106. 19
  27107. ],
  27108. [
  27109. 8,
  27110. 31
  27111. ],
  27112. [
  27113. 8,
  27114. 31
  27115. ],
  27116. [
  27117. 8,
  27118. 32
  27119. ],
  27120. [
  27121. 8,
  27122. 32
  27123. ],
  27124. [
  27125. 6,
  27126. 1
  27127. ],
  27128. [
  27129. 6,
  27130. 1
  27131. ],
  27132. [
  27133. 6,
  27134. 1
  27135. ],
  27136. [
  27137. 6,
  27138. 1
  27139. ],
  27140. [
  27141. 6,
  27142. 1
  27143. ],
  27144. [
  27145. 6,
  27146. 1
  27147. ],
  27148. [
  27149. 6,
  27150. 1
  27151. ],
  27152. [
  27153. 6,
  27154. 1
  27155. ],
  27156. [
  27157. 6,
  27158. 12
  27159. ],
  27160. [
  27161. 6,
  27162. 12
  27163. ],
  27164. [
  27165. 6,
  27166. 12
  27167. ],
  27168. [
  27169. 6,
  27170. 12
  27171. ],
  27172. [
  27173. 6,
  27174. 12
  27175. ],
  27176. [
  27177. 6,
  27178. 12
  27179. ],
  27180. [
  27181. 6,
  27182. 12
  27183. ],
  27184. [
  27185. 6,
  27186. 12
  27187. ],
  27188. [
  27189. 8,
  27190. 53
  27191. ],
  27192. [
  27193. 8,
  27194. 53
  27195. ],
  27196. [
  27197. 8,
  27198. 54
  27199. ],
  27200. [
  27201. 8,
  27202. 54
  27203. ],
  27204. [
  27205. 7,
  27206. 26
  27207. ],
  27208. [
  27209. 7,
  27210. 26
  27211. ],
  27212. [
  27213. 7,
  27214. 26
  27215. ],
  27216. [
  27217. 7,
  27218. 26
  27219. ],
  27220. [
  27221. 8,
  27222. 39
  27223. ],
  27224. [
  27225. 8,
  27226. 39
  27227. ],
  27228. [
  27229. 8,
  27230. 40
  27231. ],
  27232. [
  27233. 8,
  27234. 40
  27235. ],
  27236. [
  27237. 8,
  27238. 41
  27239. ],
  27240. [
  27241. 8,
  27242. 41
  27243. ],
  27244. [
  27245. 8,
  27246. 42
  27247. ],
  27248. [
  27249. 8,
  27250. 42
  27251. ],
  27252. [
  27253. 8,
  27254. 43
  27255. ],
  27256. [
  27257. 8,
  27258. 43
  27259. ],
  27260. [
  27261. 8,
  27262. 44
  27263. ],
  27264. [
  27265. 8,
  27266. 44
  27267. ],
  27268. [
  27269. 7,
  27270. 21
  27271. ],
  27272. [
  27273. 7,
  27274. 21
  27275. ],
  27276. [
  27277. 7,
  27278. 21
  27279. ],
  27280. [
  27281. 7,
  27282. 21
  27283. ],
  27284. [
  27285. 7,
  27286. 28
  27287. ],
  27288. [
  27289. 7,
  27290. 28
  27291. ],
  27292. [
  27293. 7,
  27294. 28
  27295. ],
  27296. [
  27297. 7,
  27298. 28
  27299. ],
  27300. [
  27301. 8,
  27302. 61
  27303. ],
  27304. [
  27305. 8,
  27306. 61
  27307. ],
  27308. [
  27309. 8,
  27310. 62
  27311. ],
  27312. [
  27313. 8,
  27314. 62
  27315. ],
  27316. [
  27317. 8,
  27318. 63
  27319. ],
  27320. [
  27321. 8,
  27322. 63
  27323. ],
  27324. [
  27325. 8,
  27326. 0
  27327. ],
  27328. [
  27329. 8,
  27330. 0
  27331. ],
  27332. [
  27333. 8,
  27334. 320
  27335. ],
  27336. [
  27337. 8,
  27338. 320
  27339. ],
  27340. [
  27341. 8,
  27342. 384
  27343. ],
  27344. [
  27345. 8,
  27346. 384
  27347. ],
  27348. [
  27349. 5,
  27350. 10
  27351. ],
  27352. [
  27353. 5,
  27354. 10
  27355. ],
  27356. [
  27357. 5,
  27358. 10
  27359. ],
  27360. [
  27361. 5,
  27362. 10
  27363. ],
  27364. [
  27365. 5,
  27366. 10
  27367. ],
  27368. [
  27369. 5,
  27370. 10
  27371. ],
  27372. [
  27373. 5,
  27374. 10
  27375. ],
  27376. [
  27377. 5,
  27378. 10
  27379. ],
  27380. [
  27381. 5,
  27382. 10
  27383. ],
  27384. [
  27385. 5,
  27386. 10
  27387. ],
  27388. [
  27389. 5,
  27390. 10
  27391. ],
  27392. [
  27393. 5,
  27394. 10
  27395. ],
  27396. [
  27397. 5,
  27398. 10
  27399. ],
  27400. [
  27401. 5,
  27402. 10
  27403. ],
  27404. [
  27405. 5,
  27406. 10
  27407. ],
  27408. [
  27409. 5,
  27410. 10
  27411. ],
  27412. [
  27413. 5,
  27414. 11
  27415. ],
  27416. [
  27417. 5,
  27418. 11
  27419. ],
  27420. [
  27421. 5,
  27422. 11
  27423. ],
  27424. [
  27425. 5,
  27426. 11
  27427. ],
  27428. [
  27429. 5,
  27430. 11
  27431. ],
  27432. [
  27433. 5,
  27434. 11
  27435. ],
  27436. [
  27437. 5,
  27438. 11
  27439. ],
  27440. [
  27441. 5,
  27442. 11
  27443. ],
  27444. [
  27445. 5,
  27446. 11
  27447. ],
  27448. [
  27449. 5,
  27450. 11
  27451. ],
  27452. [
  27453. 5,
  27454. 11
  27455. ],
  27456. [
  27457. 5,
  27458. 11
  27459. ],
  27460. [
  27461. 5,
  27462. 11
  27463. ],
  27464. [
  27465. 5,
  27466. 11
  27467. ],
  27468. [
  27469. 5,
  27470. 11
  27471. ],
  27472. [
  27473. 5,
  27474. 11
  27475. ],
  27476. [
  27477. 7,
  27478. 27
  27479. ],
  27480. [
  27481. 7,
  27482. 27
  27483. ],
  27484. [
  27485. 7,
  27486. 27
  27487. ],
  27488. [
  27489. 7,
  27490. 27
  27491. ],
  27492. [
  27493. 8,
  27494. 59
  27495. ],
  27496. [
  27497. 8,
  27498. 59
  27499. ],
  27500. [
  27501. 8,
  27502. 60
  27503. ],
  27504. [
  27505. 8,
  27506. 60
  27507. ],
  27508. [
  27509. 9,
  27510. 1472
  27511. ],
  27512. [
  27513. 9,
  27514. 1536
  27515. ],
  27516. [
  27517. 9,
  27518. 1600
  27519. ],
  27520. [
  27521. 9,
  27522. 1728
  27523. ],
  27524. [
  27525. 7,
  27526. 18
  27527. ],
  27528. [
  27529. 7,
  27530. 18
  27531. ],
  27532. [
  27533. 7,
  27534. 18
  27535. ],
  27536. [
  27537. 7,
  27538. 18
  27539. ],
  27540. [
  27541. 7,
  27542. 24
  27543. ],
  27544. [
  27545. 7,
  27546. 24
  27547. ],
  27548. [
  27549. 7,
  27550. 24
  27551. ],
  27552. [
  27553. 7,
  27554. 24
  27555. ],
  27556. [
  27557. 8,
  27558. 49
  27559. ],
  27560. [
  27561. 8,
  27562. 49
  27563. ],
  27564. [
  27565. 8,
  27566. 50
  27567. ],
  27568. [
  27569. 8,
  27570. 50
  27571. ],
  27572. [
  27573. 8,
  27574. 51
  27575. ],
  27576. [
  27577. 8,
  27578. 51
  27579. ],
  27580. [
  27581. 8,
  27582. 52
  27583. ],
  27584. [
  27585. 8,
  27586. 52
  27587. ],
  27588. [
  27589. 7,
  27590. 25
  27591. ],
  27592. [
  27593. 7,
  27594. 25
  27595. ],
  27596. [
  27597. 7,
  27598. 25
  27599. ],
  27600. [
  27601. 7,
  27602. 25
  27603. ],
  27604. [
  27605. 8,
  27606. 55
  27607. ],
  27608. [
  27609. 8,
  27610. 55
  27611. ],
  27612. [
  27613. 8,
  27614. 56
  27615. ],
  27616. [
  27617. 8,
  27618. 56
  27619. ],
  27620. [
  27621. 8,
  27622. 57
  27623. ],
  27624. [
  27625. 8,
  27626. 57
  27627. ],
  27628. [
  27629. 8,
  27630. 58
  27631. ],
  27632. [
  27633. 8,
  27634. 58
  27635. ],
  27636. [
  27637. 6,
  27638. 192
  27639. ],
  27640. [
  27641. 6,
  27642. 192
  27643. ],
  27644. [
  27645. 6,
  27646. 192
  27647. ],
  27648. [
  27649. 6,
  27650. 192
  27651. ],
  27652. [
  27653. 6,
  27654. 192
  27655. ],
  27656. [
  27657. 6,
  27658. 192
  27659. ],
  27660. [
  27661. 6,
  27662. 192
  27663. ],
  27664. [
  27665. 6,
  27666. 192
  27667. ],
  27668. [
  27669. 6,
  27670. 1664
  27671. ],
  27672. [
  27673. 6,
  27674. 1664
  27675. ],
  27676. [
  27677. 6,
  27678. 1664
  27679. ],
  27680. [
  27681. 6,
  27682. 1664
  27683. ],
  27684. [
  27685. 6,
  27686. 1664
  27687. ],
  27688. [
  27689. 6,
  27690. 1664
  27691. ],
  27692. [
  27693. 6,
  27694. 1664
  27695. ],
  27696. [
  27697. 6,
  27698. 1664
  27699. ],
  27700. [
  27701. 8,
  27702. 448
  27703. ],
  27704. [
  27705. 8,
  27706. 448
  27707. ],
  27708. [
  27709. 8,
  27710. 512
  27711. ],
  27712. [
  27713. 8,
  27714. 512
  27715. ],
  27716. [
  27717. 9,
  27718. 704
  27719. ],
  27720. [
  27721. 9,
  27722. 768
  27723. ],
  27724. [
  27725. 8,
  27726. 640
  27727. ],
  27728. [
  27729. 8,
  27730. 640
  27731. ],
  27732. [
  27733. 8,
  27734. 576
  27735. ],
  27736. [
  27737. 8,
  27738. 576
  27739. ],
  27740. [
  27741. 9,
  27742. 832
  27743. ],
  27744. [
  27745. 9,
  27746. 896
  27747. ],
  27748. [
  27749. 9,
  27750. 960
  27751. ],
  27752. [
  27753. 9,
  27754. 1024
  27755. ],
  27756. [
  27757. 9,
  27758. 1088
  27759. ],
  27760. [
  27761. 9,
  27762. 1152
  27763. ],
  27764. [
  27765. 9,
  27766. 1216
  27767. ],
  27768. [
  27769. 9,
  27770. 1280
  27771. ],
  27772. [
  27773. 9,
  27774. 1344
  27775. ],
  27776. [
  27777. 9,
  27778. 1408
  27779. ],
  27780. [
  27781. 7,
  27782. 256
  27783. ],
  27784. [
  27785. 7,
  27786. 256
  27787. ],
  27788. [
  27789. 7,
  27790. 256
  27791. ],
  27792. [
  27793. 7,
  27794. 256
  27795. ],
  27796. [
  27797. 4,
  27798. 2
  27799. ],
  27800. [
  27801. 4,
  27802. 2
  27803. ],
  27804. [
  27805. 4,
  27806. 2
  27807. ],
  27808. [
  27809. 4,
  27810. 2
  27811. ],
  27812. [
  27813. 4,
  27814. 2
  27815. ],
  27816. [
  27817. 4,
  27818. 2
  27819. ],
  27820. [
  27821. 4,
  27822. 2
  27823. ],
  27824. [
  27825. 4,
  27826. 2
  27827. ],
  27828. [
  27829. 4,
  27830. 2
  27831. ],
  27832. [
  27833. 4,
  27834. 2
  27835. ],
  27836. [
  27837. 4,
  27838. 2
  27839. ],
  27840. [
  27841. 4,
  27842. 2
  27843. ],
  27844. [
  27845. 4,
  27846. 2
  27847. ],
  27848. [
  27849. 4,
  27850. 2
  27851. ],
  27852. [
  27853. 4,
  27854. 2
  27855. ],
  27856. [
  27857. 4,
  27858. 2
  27859. ],
  27860. [
  27861. 4,
  27862. 2
  27863. ],
  27864. [
  27865. 4,
  27866. 2
  27867. ],
  27868. [
  27869. 4,
  27870. 2
  27871. ],
  27872. [
  27873. 4,
  27874. 2
  27875. ],
  27876. [
  27877. 4,
  27878. 2
  27879. ],
  27880. [
  27881. 4,
  27882. 2
  27883. ],
  27884. [
  27885. 4,
  27886. 2
  27887. ],
  27888. [
  27889. 4,
  27890. 2
  27891. ],
  27892. [
  27893. 4,
  27894. 2
  27895. ],
  27896. [
  27897. 4,
  27898. 2
  27899. ],
  27900. [
  27901. 4,
  27902. 2
  27903. ],
  27904. [
  27905. 4,
  27906. 2
  27907. ],
  27908. [
  27909. 4,
  27910. 2
  27911. ],
  27912. [
  27913. 4,
  27914. 2
  27915. ],
  27916. [
  27917. 4,
  27918. 2
  27919. ],
  27920. [
  27921. 4,
  27922. 2
  27923. ],
  27924. [
  27925. 4,
  27926. 3
  27927. ],
  27928. [
  27929. 4,
  27930. 3
  27931. ],
  27932. [
  27933. 4,
  27934. 3
  27935. ],
  27936. [
  27937. 4,
  27938. 3
  27939. ],
  27940. [
  27941. 4,
  27942. 3
  27943. ],
  27944. [
  27945. 4,
  27946. 3
  27947. ],
  27948. [
  27949. 4,
  27950. 3
  27951. ],
  27952. [
  27953. 4,
  27954. 3
  27955. ],
  27956. [
  27957. 4,
  27958. 3
  27959. ],
  27960. [
  27961. 4,
  27962. 3
  27963. ],
  27964. [
  27965. 4,
  27966. 3
  27967. ],
  27968. [
  27969. 4,
  27970. 3
  27971. ],
  27972. [
  27973. 4,
  27974. 3
  27975. ],
  27976. [
  27977. 4,
  27978. 3
  27979. ],
  27980. [
  27981. 4,
  27982. 3
  27983. ],
  27984. [
  27985. 4,
  27986. 3
  27987. ],
  27988. [
  27989. 4,
  27990. 3
  27991. ],
  27992. [
  27993. 4,
  27994. 3
  27995. ],
  27996. [
  27997. 4,
  27998. 3
  27999. ],
  28000. [
  28001. 4,
  28002. 3
  28003. ],
  28004. [
  28005. 4,
  28006. 3
  28007. ],
  28008. [
  28009. 4,
  28010. 3
  28011. ],
  28012. [
  28013. 4,
  28014. 3
  28015. ],
  28016. [
  28017. 4,
  28018. 3
  28019. ],
  28020. [
  28021. 4,
  28022. 3
  28023. ],
  28024. [
  28025. 4,
  28026. 3
  28027. ],
  28028. [
  28029. 4,
  28030. 3
  28031. ],
  28032. [
  28033. 4,
  28034. 3
  28035. ],
  28036. [
  28037. 4,
  28038. 3
  28039. ],
  28040. [
  28041. 4,
  28042. 3
  28043. ],
  28044. [
  28045. 4,
  28046. 3
  28047. ],
  28048. [
  28049. 4,
  28050. 3
  28051. ],
  28052. [
  28053. 5,
  28054. 128
  28055. ],
  28056. [
  28057. 5,
  28058. 128
  28059. ],
  28060. [
  28061. 5,
  28062. 128
  28063. ],
  28064. [
  28065. 5,
  28066. 128
  28067. ],
  28068. [
  28069. 5,
  28070. 128
  28071. ],
  28072. [
  28073. 5,
  28074. 128
  28075. ],
  28076. [
  28077. 5,
  28078. 128
  28079. ],
  28080. [
  28081. 5,
  28082. 128
  28083. ],
  28084. [
  28085. 5,
  28086. 128
  28087. ],
  28088. [
  28089. 5,
  28090. 128
  28091. ],
  28092. [
  28093. 5,
  28094. 128
  28095. ],
  28096. [
  28097. 5,
  28098. 128
  28099. ],
  28100. [
  28101. 5,
  28102. 128
  28103. ],
  28104. [
  28105. 5,
  28106. 128
  28107. ],
  28108. [
  28109. 5,
  28110. 128
  28111. ],
  28112. [
  28113. 5,
  28114. 128
  28115. ],
  28116. [
  28117. 5,
  28118. 8
  28119. ],
  28120. [
  28121. 5,
  28122. 8
  28123. ],
  28124. [
  28125. 5,
  28126. 8
  28127. ],
  28128. [
  28129. 5,
  28130. 8
  28131. ],
  28132. [
  28133. 5,
  28134. 8
  28135. ],
  28136. [
  28137. 5,
  28138. 8
  28139. ],
  28140. [
  28141. 5,
  28142. 8
  28143. ],
  28144. [
  28145. 5,
  28146. 8
  28147. ],
  28148. [
  28149. 5,
  28150. 8
  28151. ],
  28152. [
  28153. 5,
  28154. 8
  28155. ],
  28156. [
  28157. 5,
  28158. 8
  28159. ],
  28160. [
  28161. 5,
  28162. 8
  28163. ],
  28164. [
  28165. 5,
  28166. 8
  28167. ],
  28168. [
  28169. 5,
  28170. 8
  28171. ],
  28172. [
  28173. 5,
  28174. 8
  28175. ],
  28176. [
  28177. 5,
  28178. 8
  28179. ],
  28180. [
  28181. 5,
  28182. 9
  28183. ],
  28184. [
  28185. 5,
  28186. 9
  28187. ],
  28188. [
  28189. 5,
  28190. 9
  28191. ],
  28192. [
  28193. 5,
  28194. 9
  28195. ],
  28196. [
  28197. 5,
  28198. 9
  28199. ],
  28200. [
  28201. 5,
  28202. 9
  28203. ],
  28204. [
  28205. 5,
  28206. 9
  28207. ],
  28208. [
  28209. 5,
  28210. 9
  28211. ],
  28212. [
  28213. 5,
  28214. 9
  28215. ],
  28216. [
  28217. 5,
  28218. 9
  28219. ],
  28220. [
  28221. 5,
  28222. 9
  28223. ],
  28224. [
  28225. 5,
  28226. 9
  28227. ],
  28228. [
  28229. 5,
  28230. 9
  28231. ],
  28232. [
  28233. 5,
  28234. 9
  28235. ],
  28236. [
  28237. 5,
  28238. 9
  28239. ],
  28240. [
  28241. 5,
  28242. 9
  28243. ],
  28244. [
  28245. 6,
  28246. 16
  28247. ],
  28248. [
  28249. 6,
  28250. 16
  28251. ],
  28252. [
  28253. 6,
  28254. 16
  28255. ],
  28256. [
  28257. 6,
  28258. 16
  28259. ],
  28260. [
  28261. 6,
  28262. 16
  28263. ],
  28264. [
  28265. 6,
  28266. 16
  28267. ],
  28268. [
  28269. 6,
  28270. 16
  28271. ],
  28272. [
  28273. 6,
  28274. 16
  28275. ],
  28276. [
  28277. 6,
  28278. 17
  28279. ],
  28280. [
  28281. 6,
  28282. 17
  28283. ],
  28284. [
  28285. 6,
  28286. 17
  28287. ],
  28288. [
  28289. 6,
  28290. 17
  28291. ],
  28292. [
  28293. 6,
  28294. 17
  28295. ],
  28296. [
  28297. 6,
  28298. 17
  28299. ],
  28300. [
  28301. 6,
  28302. 17
  28303. ],
  28304. [
  28305. 6,
  28306. 17
  28307. ],
  28308. [
  28309. 4,
  28310. 4
  28311. ],
  28312. [
  28313. 4,
  28314. 4
  28315. ],
  28316. [
  28317. 4,
  28318. 4
  28319. ],
  28320. [
  28321. 4,
  28322. 4
  28323. ],
  28324. [
  28325. 4,
  28326. 4
  28327. ],
  28328. [
  28329. 4,
  28330. 4
  28331. ],
  28332. [
  28333. 4,
  28334. 4
  28335. ],
  28336. [
  28337. 4,
  28338. 4
  28339. ],
  28340. [
  28341. 4,
  28342. 4
  28343. ],
  28344. [
  28345. 4,
  28346. 4
  28347. ],
  28348. [
  28349. 4,
  28350. 4
  28351. ],
  28352. [
  28353. 4,
  28354. 4
  28355. ],
  28356. [
  28357. 4,
  28358. 4
  28359. ],
  28360. [
  28361. 4,
  28362. 4
  28363. ],
  28364. [
  28365. 4,
  28366. 4
  28367. ],
  28368. [
  28369. 4,
  28370. 4
  28371. ],
  28372. [
  28373. 4,
  28374. 4
  28375. ],
  28376. [
  28377. 4,
  28378. 4
  28379. ],
  28380. [
  28381. 4,
  28382. 4
  28383. ],
  28384. [
  28385. 4,
  28386. 4
  28387. ],
  28388. [
  28389. 4,
  28390. 4
  28391. ],
  28392. [
  28393. 4,
  28394. 4
  28395. ],
  28396. [
  28397. 4,
  28398. 4
  28399. ],
  28400. [
  28401. 4,
  28402. 4
  28403. ],
  28404. [
  28405. 4,
  28406. 4
  28407. ],
  28408. [
  28409. 4,
  28410. 4
  28411. ],
  28412. [
  28413. 4,
  28414. 4
  28415. ],
  28416. [
  28417. 4,
  28418. 4
  28419. ],
  28420. [
  28421. 4,
  28422. 4
  28423. ],
  28424. [
  28425. 4,
  28426. 4
  28427. ],
  28428. [
  28429. 4,
  28430. 4
  28431. ],
  28432. [
  28433. 4,
  28434. 4
  28435. ],
  28436. [
  28437. 4,
  28438. 5
  28439. ],
  28440. [
  28441. 4,
  28442. 5
  28443. ],
  28444. [
  28445. 4,
  28446. 5
  28447. ],
  28448. [
  28449. 4,
  28450. 5
  28451. ],
  28452. [
  28453. 4,
  28454. 5
  28455. ],
  28456. [
  28457. 4,
  28458. 5
  28459. ],
  28460. [
  28461. 4,
  28462. 5
  28463. ],
  28464. [
  28465. 4,
  28466. 5
  28467. ],
  28468. [
  28469. 4,
  28470. 5
  28471. ],
  28472. [
  28473. 4,
  28474. 5
  28475. ],
  28476. [
  28477. 4,
  28478. 5
  28479. ],
  28480. [
  28481. 4,
  28482. 5
  28483. ],
  28484. [
  28485. 4,
  28486. 5
  28487. ],
  28488. [
  28489. 4,
  28490. 5
  28491. ],
  28492. [
  28493. 4,
  28494. 5
  28495. ],
  28496. [
  28497. 4,
  28498. 5
  28499. ],
  28500. [
  28501. 4,
  28502. 5
  28503. ],
  28504. [
  28505. 4,
  28506. 5
  28507. ],
  28508. [
  28509. 4,
  28510. 5
  28511. ],
  28512. [
  28513. 4,
  28514. 5
  28515. ],
  28516. [
  28517. 4,
  28518. 5
  28519. ],
  28520. [
  28521. 4,
  28522. 5
  28523. ],
  28524. [
  28525. 4,
  28526. 5
  28527. ],
  28528. [
  28529. 4,
  28530. 5
  28531. ],
  28532. [
  28533. 4,
  28534. 5
  28535. ],
  28536. [
  28537. 4,
  28538. 5
  28539. ],
  28540. [
  28541. 4,
  28542. 5
  28543. ],
  28544. [
  28545. 4,
  28546. 5
  28547. ],
  28548. [
  28549. 4,
  28550. 5
  28551. ],
  28552. [
  28553. 4,
  28554. 5
  28555. ],
  28556. [
  28557. 4,
  28558. 5
  28559. ],
  28560. [
  28561. 4,
  28562. 5
  28563. ],
  28564. [
  28565. 6,
  28566. 14
  28567. ],
  28568. [
  28569. 6,
  28570. 14
  28571. ],
  28572. [
  28573. 6,
  28574. 14
  28575. ],
  28576. [
  28577. 6,
  28578. 14
  28579. ],
  28580. [
  28581. 6,
  28582. 14
  28583. ],
  28584. [
  28585. 6,
  28586. 14
  28587. ],
  28588. [
  28589. 6,
  28590. 14
  28591. ],
  28592. [
  28593. 6,
  28594. 14
  28595. ],
  28596. [
  28597. 6,
  28598. 15
  28599. ],
  28600. [
  28601. 6,
  28602. 15
  28603. ],
  28604. [
  28605. 6,
  28606. 15
  28607. ],
  28608. [
  28609. 6,
  28610. 15
  28611. ],
  28612. [
  28613. 6,
  28614. 15
  28615. ],
  28616. [
  28617. 6,
  28618. 15
  28619. ],
  28620. [
  28621. 6,
  28622. 15
  28623. ],
  28624. [
  28625. 6,
  28626. 15
  28627. ],
  28628. [
  28629. 5,
  28630. 64
  28631. ],
  28632. [
  28633. 5,
  28634. 64
  28635. ],
  28636. [
  28637. 5,
  28638. 64
  28639. ],
  28640. [
  28641. 5,
  28642. 64
  28643. ],
  28644. [
  28645. 5,
  28646. 64
  28647. ],
  28648. [
  28649. 5,
  28650. 64
  28651. ],
  28652. [
  28653. 5,
  28654. 64
  28655. ],
  28656. [
  28657. 5,
  28658. 64
  28659. ],
  28660. [
  28661. 5,
  28662. 64
  28663. ],
  28664. [
  28665. 5,
  28666. 64
  28667. ],
  28668. [
  28669. 5,
  28670. 64
  28671. ],
  28672. [
  28673. 5,
  28674. 64
  28675. ],
  28676. [
  28677. 5,
  28678. 64
  28679. ],
  28680. [
  28681. 5,
  28682. 64
  28683. ],
  28684. [
  28685. 5,
  28686. 64
  28687. ],
  28688. [
  28689. 5,
  28690. 64
  28691. ],
  28692. [
  28693. 4,
  28694. 6
  28695. ],
  28696. [
  28697. 4,
  28698. 6
  28699. ],
  28700. [
  28701. 4,
  28702. 6
  28703. ],
  28704. [
  28705. 4,
  28706. 6
  28707. ],
  28708. [
  28709. 4,
  28710. 6
  28711. ],
  28712. [
  28713. 4,
  28714. 6
  28715. ],
  28716. [
  28717. 4,
  28718. 6
  28719. ],
  28720. [
  28721. 4,
  28722. 6
  28723. ],
  28724. [
  28725. 4,
  28726. 6
  28727. ],
  28728. [
  28729. 4,
  28730. 6
  28731. ],
  28732. [
  28733. 4,
  28734. 6
  28735. ],
  28736. [
  28737. 4,
  28738. 6
  28739. ],
  28740. [
  28741. 4,
  28742. 6
  28743. ],
  28744. [
  28745. 4,
  28746. 6
  28747. ],
  28748. [
  28749. 4,
  28750. 6
  28751. ],
  28752. [
  28753. 4,
  28754. 6
  28755. ],
  28756. [
  28757. 4,
  28758. 6
  28759. ],
  28760. [
  28761. 4,
  28762. 6
  28763. ],
  28764. [
  28765. 4,
  28766. 6
  28767. ],
  28768. [
  28769. 4,
  28770. 6
  28771. ],
  28772. [
  28773. 4,
  28774. 6
  28775. ],
  28776. [
  28777. 4,
  28778. 6
  28779. ],
  28780. [
  28781. 4,
  28782. 6
  28783. ],
  28784. [
  28785. 4,
  28786. 6
  28787. ],
  28788. [
  28789. 4,
  28790. 6
  28791. ],
  28792. [
  28793. 4,
  28794. 6
  28795. ],
  28796. [
  28797. 4,
  28798. 6
  28799. ],
  28800. [
  28801. 4,
  28802. 6
  28803. ],
  28804. [
  28805. 4,
  28806. 6
  28807. ],
  28808. [
  28809. 4,
  28810. 6
  28811. ],
  28812. [
  28813. 4,
  28814. 6
  28815. ],
  28816. [
  28817. 4,
  28818. 6
  28819. ],
  28820. [
  28821. 4,
  28822. 7
  28823. ],
  28824. [
  28825. 4,
  28826. 7
  28827. ],
  28828. [
  28829. 4,
  28830. 7
  28831. ],
  28832. [
  28833. 4,
  28834. 7
  28835. ],
  28836. [
  28837. 4,
  28838. 7
  28839. ],
  28840. [
  28841. 4,
  28842. 7
  28843. ],
  28844. [
  28845. 4,
  28846. 7
  28847. ],
  28848. [
  28849. 4,
  28850. 7
  28851. ],
  28852. [
  28853. 4,
  28854. 7
  28855. ],
  28856. [
  28857. 4,
  28858. 7
  28859. ],
  28860. [
  28861. 4,
  28862. 7
  28863. ],
  28864. [
  28865. 4,
  28866. 7
  28867. ],
  28868. [
  28869. 4,
  28870. 7
  28871. ],
  28872. [
  28873. 4,
  28874. 7
  28875. ],
  28876. [
  28877. 4,
  28878. 7
  28879. ],
  28880. [
  28881. 4,
  28882. 7
  28883. ],
  28884. [
  28885. 4,
  28886. 7
  28887. ],
  28888. [
  28889. 4,
  28890. 7
  28891. ],
  28892. [
  28893. 4,
  28894. 7
  28895. ],
  28896. [
  28897. 4,
  28898. 7
  28899. ],
  28900. [
  28901. 4,
  28902. 7
  28903. ],
  28904. [
  28905. 4,
  28906. 7
  28907. ],
  28908. [
  28909. 4,
  28910. 7
  28911. ],
  28912. [
  28913. 4,
  28914. 7
  28915. ],
  28916. [
  28917. 4,
  28918. 7
  28919. ],
  28920. [
  28921. 4,
  28922. 7
  28923. ],
  28924. [
  28925. 4,
  28926. 7
  28927. ],
  28928. [
  28929. 4,
  28930. 7
  28931. ],
  28932. [
  28933. 4,
  28934. 7
  28935. ],
  28936. [
  28937. 4,
  28938. 7
  28939. ],
  28940. [
  28941. 4,
  28942. 7
  28943. ],
  28944. [
  28945. 4,
  28946. 7
  28947. ]
  28948. ];
  28949. var blackTable1 = [
  28950. [
  28951. -1,
  28952. -1
  28953. ],
  28954. [
  28955. -1,
  28956. -1
  28957. ],
  28958. [
  28959. 12,
  28960. ccittEOL
  28961. ],
  28962. [
  28963. 12,
  28964. ccittEOL
  28965. ],
  28966. [
  28967. -1,
  28968. -1
  28969. ],
  28970. [
  28971. -1,
  28972. -1
  28973. ],
  28974. [
  28975. -1,
  28976. -1
  28977. ],
  28978. [
  28979. -1,
  28980. -1
  28981. ],
  28982. [
  28983. -1,
  28984. -1
  28985. ],
  28986. [
  28987. -1,
  28988. -1
  28989. ],
  28990. [
  28991. -1,
  28992. -1
  28993. ],
  28994. [
  28995. -1,
  28996. -1
  28997. ],
  28998. [
  28999. -1,
  29000. -1
  29001. ],
  29002. [
  29003. -1,
  29004. -1
  29005. ],
  29006. [
  29007. -1,
  29008. -1
  29009. ],
  29010. [
  29011. -1,
  29012. -1
  29013. ],
  29014. [
  29015. -1,
  29016. -1
  29017. ],
  29018. [
  29019. -1,
  29020. -1
  29021. ],
  29022. [
  29023. -1,
  29024. -1
  29025. ],
  29026. [
  29027. -1,
  29028. -1
  29029. ],
  29030. [
  29031. -1,
  29032. -1
  29033. ],
  29034. [
  29035. -1,
  29036. -1
  29037. ],
  29038. [
  29039. -1,
  29040. -1
  29041. ],
  29042. [
  29043. -1,
  29044. -1
  29045. ],
  29046. [
  29047. -1,
  29048. -1
  29049. ],
  29050. [
  29051. -1,
  29052. -1
  29053. ],
  29054. [
  29055. -1,
  29056. -1
  29057. ],
  29058. [
  29059. -1,
  29060. -1
  29061. ],
  29062. [
  29063. -1,
  29064. -1
  29065. ],
  29066. [
  29067. -1,
  29068. -1
  29069. ],
  29070. [
  29071. -1,
  29072. -1
  29073. ],
  29074. [
  29075. -1,
  29076. -1
  29077. ],
  29078. [
  29079. 11,
  29080. 1792
  29081. ],
  29082. [
  29083. 11,
  29084. 1792
  29085. ],
  29086. [
  29087. 11,
  29088. 1792
  29089. ],
  29090. [
  29091. 11,
  29092. 1792
  29093. ],
  29094. [
  29095. 12,
  29096. 1984
  29097. ],
  29098. [
  29099. 12,
  29100. 1984
  29101. ],
  29102. [
  29103. 12,
  29104. 2048
  29105. ],
  29106. [
  29107. 12,
  29108. 2048
  29109. ],
  29110. [
  29111. 12,
  29112. 2112
  29113. ],
  29114. [
  29115. 12,
  29116. 2112
  29117. ],
  29118. [
  29119. 12,
  29120. 2176
  29121. ],
  29122. [
  29123. 12,
  29124. 2176
  29125. ],
  29126. [
  29127. 12,
  29128. 2240
  29129. ],
  29130. [
  29131. 12,
  29132. 2240
  29133. ],
  29134. [
  29135. 12,
  29136. 2304
  29137. ],
  29138. [
  29139. 12,
  29140. 2304
  29141. ],
  29142. [
  29143. 11,
  29144. 1856
  29145. ],
  29146. [
  29147. 11,
  29148. 1856
  29149. ],
  29150. [
  29151. 11,
  29152. 1856
  29153. ],
  29154. [
  29155. 11,
  29156. 1856
  29157. ],
  29158. [
  29159. 11,
  29160. 1920
  29161. ],
  29162. [
  29163. 11,
  29164. 1920
  29165. ],
  29166. [
  29167. 11,
  29168. 1920
  29169. ],
  29170. [
  29171. 11,
  29172. 1920
  29173. ],
  29174. [
  29175. 12,
  29176. 2368
  29177. ],
  29178. [
  29179. 12,
  29180. 2368
  29181. ],
  29182. [
  29183. 12,
  29184. 2432
  29185. ],
  29186. [
  29187. 12,
  29188. 2432
  29189. ],
  29190. [
  29191. 12,
  29192. 2496
  29193. ],
  29194. [
  29195. 12,
  29196. 2496
  29197. ],
  29198. [
  29199. 12,
  29200. 2560
  29201. ],
  29202. [
  29203. 12,
  29204. 2560
  29205. ],
  29206. [
  29207. 10,
  29208. 18
  29209. ],
  29210. [
  29211. 10,
  29212. 18
  29213. ],
  29214. [
  29215. 10,
  29216. 18
  29217. ],
  29218. [
  29219. 10,
  29220. 18
  29221. ],
  29222. [
  29223. 10,
  29224. 18
  29225. ],
  29226. [
  29227. 10,
  29228. 18
  29229. ],
  29230. [
  29231. 10,
  29232. 18
  29233. ],
  29234. [
  29235. 10,
  29236. 18
  29237. ],
  29238. [
  29239. 12,
  29240. 52
  29241. ],
  29242. [
  29243. 12,
  29244. 52
  29245. ],
  29246. [
  29247. 13,
  29248. 640
  29249. ],
  29250. [
  29251. 13,
  29252. 704
  29253. ],
  29254. [
  29255. 13,
  29256. 768
  29257. ],
  29258. [
  29259. 13,
  29260. 832
  29261. ],
  29262. [
  29263. 12,
  29264. 55
  29265. ],
  29266. [
  29267. 12,
  29268. 55
  29269. ],
  29270. [
  29271. 12,
  29272. 56
  29273. ],
  29274. [
  29275. 12,
  29276. 56
  29277. ],
  29278. [
  29279. 13,
  29280. 1280
  29281. ],
  29282. [
  29283. 13,
  29284. 1344
  29285. ],
  29286. [
  29287. 13,
  29288. 1408
  29289. ],
  29290. [
  29291. 13,
  29292. 1472
  29293. ],
  29294. [
  29295. 12,
  29296. 59
  29297. ],
  29298. [
  29299. 12,
  29300. 59
  29301. ],
  29302. [
  29303. 12,
  29304. 60
  29305. ],
  29306. [
  29307. 12,
  29308. 60
  29309. ],
  29310. [
  29311. 13,
  29312. 1536
  29313. ],
  29314. [
  29315. 13,
  29316. 1600
  29317. ],
  29318. [
  29319. 11,
  29320. 24
  29321. ],
  29322. [
  29323. 11,
  29324. 24
  29325. ],
  29326. [
  29327. 11,
  29328. 24
  29329. ],
  29330. [
  29331. 11,
  29332. 24
  29333. ],
  29334. [
  29335. 11,
  29336. 25
  29337. ],
  29338. [
  29339. 11,
  29340. 25
  29341. ],
  29342. [
  29343. 11,
  29344. 25
  29345. ],
  29346. [
  29347. 11,
  29348. 25
  29349. ],
  29350. [
  29351. 13,
  29352. 1664
  29353. ],
  29354. [
  29355. 13,
  29356. 1728
  29357. ],
  29358. [
  29359. 12,
  29360. 320
  29361. ],
  29362. [
  29363. 12,
  29364. 320
  29365. ],
  29366. [
  29367. 12,
  29368. 384
  29369. ],
  29370. [
  29371. 12,
  29372. 384
  29373. ],
  29374. [
  29375. 12,
  29376. 448
  29377. ],
  29378. [
  29379. 12,
  29380. 448
  29381. ],
  29382. [
  29383. 13,
  29384. 512
  29385. ],
  29386. [
  29387. 13,
  29388. 576
  29389. ],
  29390. [
  29391. 12,
  29392. 53
  29393. ],
  29394. [
  29395. 12,
  29396. 53
  29397. ],
  29398. [
  29399. 12,
  29400. 54
  29401. ],
  29402. [
  29403. 12,
  29404. 54
  29405. ],
  29406. [
  29407. 13,
  29408. 896
  29409. ],
  29410. [
  29411. 13,
  29412. 960
  29413. ],
  29414. [
  29415. 13,
  29416. 1024
  29417. ],
  29418. [
  29419. 13,
  29420. 1088
  29421. ],
  29422. [
  29423. 13,
  29424. 1152
  29425. ],
  29426. [
  29427. 13,
  29428. 1216
  29429. ],
  29430. [
  29431. 10,
  29432. 64
  29433. ],
  29434. [
  29435. 10,
  29436. 64
  29437. ],
  29438. [
  29439. 10,
  29440. 64
  29441. ],
  29442. [
  29443. 10,
  29444. 64
  29445. ],
  29446. [
  29447. 10,
  29448. 64
  29449. ],
  29450. [
  29451. 10,
  29452. 64
  29453. ],
  29454. [
  29455. 10,
  29456. 64
  29457. ],
  29458. [
  29459. 10,
  29460. 64
  29461. ]
  29462. ];
  29463. var blackTable2 = [
  29464. [
  29465. 8,
  29466. 13
  29467. ],
  29468. [
  29469. 8,
  29470. 13
  29471. ],
  29472. [
  29473. 8,
  29474. 13
  29475. ],
  29476. [
  29477. 8,
  29478. 13
  29479. ],
  29480. [
  29481. 8,
  29482. 13
  29483. ],
  29484. [
  29485. 8,
  29486. 13
  29487. ],
  29488. [
  29489. 8,
  29490. 13
  29491. ],
  29492. [
  29493. 8,
  29494. 13
  29495. ],
  29496. [
  29497. 8,
  29498. 13
  29499. ],
  29500. [
  29501. 8,
  29502. 13
  29503. ],
  29504. [
  29505. 8,
  29506. 13
  29507. ],
  29508. [
  29509. 8,
  29510. 13
  29511. ],
  29512. [
  29513. 8,
  29514. 13
  29515. ],
  29516. [
  29517. 8,
  29518. 13
  29519. ],
  29520. [
  29521. 8,
  29522. 13
  29523. ],
  29524. [
  29525. 8,
  29526. 13
  29527. ],
  29528. [
  29529. 11,
  29530. 23
  29531. ],
  29532. [
  29533. 11,
  29534. 23
  29535. ],
  29536. [
  29537. 12,
  29538. 50
  29539. ],
  29540. [
  29541. 12,
  29542. 51
  29543. ],
  29544. [
  29545. 12,
  29546. 44
  29547. ],
  29548. [
  29549. 12,
  29550. 45
  29551. ],
  29552. [
  29553. 12,
  29554. 46
  29555. ],
  29556. [
  29557. 12,
  29558. 47
  29559. ],
  29560. [
  29561. 12,
  29562. 57
  29563. ],
  29564. [
  29565. 12,
  29566. 58
  29567. ],
  29568. [
  29569. 12,
  29570. 61
  29571. ],
  29572. [
  29573. 12,
  29574. 256
  29575. ],
  29576. [
  29577. 10,
  29578. 16
  29579. ],
  29580. [
  29581. 10,
  29582. 16
  29583. ],
  29584. [
  29585. 10,
  29586. 16
  29587. ],
  29588. [
  29589. 10,
  29590. 16
  29591. ],
  29592. [
  29593. 10,
  29594. 17
  29595. ],
  29596. [
  29597. 10,
  29598. 17
  29599. ],
  29600. [
  29601. 10,
  29602. 17
  29603. ],
  29604. [
  29605. 10,
  29606. 17
  29607. ],
  29608. [
  29609. 12,
  29610. 48
  29611. ],
  29612. [
  29613. 12,
  29614. 49
  29615. ],
  29616. [
  29617. 12,
  29618. 62
  29619. ],
  29620. [
  29621. 12,
  29622. 63
  29623. ],
  29624. [
  29625. 12,
  29626. 30
  29627. ],
  29628. [
  29629. 12,
  29630. 31
  29631. ],
  29632. [
  29633. 12,
  29634. 32
  29635. ],
  29636. [
  29637. 12,
  29638. 33
  29639. ],
  29640. [
  29641. 12,
  29642. 40
  29643. ],
  29644. [
  29645. 12,
  29646. 41
  29647. ],
  29648. [
  29649. 11,
  29650. 22
  29651. ],
  29652. [
  29653. 11,
  29654. 22
  29655. ],
  29656. [
  29657. 8,
  29658. 14
  29659. ],
  29660. [
  29661. 8,
  29662. 14
  29663. ],
  29664. [
  29665. 8,
  29666. 14
  29667. ],
  29668. [
  29669. 8,
  29670. 14
  29671. ],
  29672. [
  29673. 8,
  29674. 14
  29675. ],
  29676. [
  29677. 8,
  29678. 14
  29679. ],
  29680. [
  29681. 8,
  29682. 14
  29683. ],
  29684. [
  29685. 8,
  29686. 14
  29687. ],
  29688. [
  29689. 8,
  29690. 14
  29691. ],
  29692. [
  29693. 8,
  29694. 14
  29695. ],
  29696. [
  29697. 8,
  29698. 14
  29699. ],
  29700. [
  29701. 8,
  29702. 14
  29703. ],
  29704. [
  29705. 8,
  29706. 14
  29707. ],
  29708. [
  29709. 8,
  29710. 14
  29711. ],
  29712. [
  29713. 8,
  29714. 14
  29715. ],
  29716. [
  29717. 8,
  29718. 14
  29719. ],
  29720. [
  29721. 7,
  29722. 10
  29723. ],
  29724. [
  29725. 7,
  29726. 10
  29727. ],
  29728. [
  29729. 7,
  29730. 10
  29731. ],
  29732. [
  29733. 7,
  29734. 10
  29735. ],
  29736. [
  29737. 7,
  29738. 10
  29739. ],
  29740. [
  29741. 7,
  29742. 10
  29743. ],
  29744. [
  29745. 7,
  29746. 10
  29747. ],
  29748. [
  29749. 7,
  29750. 10
  29751. ],
  29752. [
  29753. 7,
  29754. 10
  29755. ],
  29756. [
  29757. 7,
  29758. 10
  29759. ],
  29760. [
  29761. 7,
  29762. 10
  29763. ],
  29764. [
  29765. 7,
  29766. 10
  29767. ],
  29768. [
  29769. 7,
  29770. 10
  29771. ],
  29772. [
  29773. 7,
  29774. 10
  29775. ],
  29776. [
  29777. 7,
  29778. 10
  29779. ],
  29780. [
  29781. 7,
  29782. 10
  29783. ],
  29784. [
  29785. 7,
  29786. 10
  29787. ],
  29788. [
  29789. 7,
  29790. 10
  29791. ],
  29792. [
  29793. 7,
  29794. 10
  29795. ],
  29796. [
  29797. 7,
  29798. 10
  29799. ],
  29800. [
  29801. 7,
  29802. 10
  29803. ],
  29804. [
  29805. 7,
  29806. 10
  29807. ],
  29808. [
  29809. 7,
  29810. 10
  29811. ],
  29812. [
  29813. 7,
  29814. 10
  29815. ],
  29816. [
  29817. 7,
  29818. 10
  29819. ],
  29820. [
  29821. 7,
  29822. 10
  29823. ],
  29824. [
  29825. 7,
  29826. 10
  29827. ],
  29828. [
  29829. 7,
  29830. 10
  29831. ],
  29832. [
  29833. 7,
  29834. 10
  29835. ],
  29836. [
  29837. 7,
  29838. 10
  29839. ],
  29840. [
  29841. 7,
  29842. 10
  29843. ],
  29844. [
  29845. 7,
  29846. 10
  29847. ],
  29848. [
  29849. 7,
  29850. 11
  29851. ],
  29852. [
  29853. 7,
  29854. 11
  29855. ],
  29856. [
  29857. 7,
  29858. 11
  29859. ],
  29860. [
  29861. 7,
  29862. 11
  29863. ],
  29864. [
  29865. 7,
  29866. 11
  29867. ],
  29868. [
  29869. 7,
  29870. 11
  29871. ],
  29872. [
  29873. 7,
  29874. 11
  29875. ],
  29876. [
  29877. 7,
  29878. 11
  29879. ],
  29880. [
  29881. 7,
  29882. 11
  29883. ],
  29884. [
  29885. 7,
  29886. 11
  29887. ],
  29888. [
  29889. 7,
  29890. 11
  29891. ],
  29892. [
  29893. 7,
  29894. 11
  29895. ],
  29896. [
  29897. 7,
  29898. 11
  29899. ],
  29900. [
  29901. 7,
  29902. 11
  29903. ],
  29904. [
  29905. 7,
  29906. 11
  29907. ],
  29908. [
  29909. 7,
  29910. 11
  29911. ],
  29912. [
  29913. 7,
  29914. 11
  29915. ],
  29916. [
  29917. 7,
  29918. 11
  29919. ],
  29920. [
  29921. 7,
  29922. 11
  29923. ],
  29924. [
  29925. 7,
  29926. 11
  29927. ],
  29928. [
  29929. 7,
  29930. 11
  29931. ],
  29932. [
  29933. 7,
  29934. 11
  29935. ],
  29936. [
  29937. 7,
  29938. 11
  29939. ],
  29940. [
  29941. 7,
  29942. 11
  29943. ],
  29944. [
  29945. 7,
  29946. 11
  29947. ],
  29948. [
  29949. 7,
  29950. 11
  29951. ],
  29952. [
  29953. 7,
  29954. 11
  29955. ],
  29956. [
  29957. 7,
  29958. 11
  29959. ],
  29960. [
  29961. 7,
  29962. 11
  29963. ],
  29964. [
  29965. 7,
  29966. 11
  29967. ],
  29968. [
  29969. 7,
  29970. 11
  29971. ],
  29972. [
  29973. 7,
  29974. 11
  29975. ],
  29976. [
  29977. 9,
  29978. 15
  29979. ],
  29980. [
  29981. 9,
  29982. 15
  29983. ],
  29984. [
  29985. 9,
  29986. 15
  29987. ],
  29988. [
  29989. 9,
  29990. 15
  29991. ],
  29992. [
  29993. 9,
  29994. 15
  29995. ],
  29996. [
  29997. 9,
  29998. 15
  29999. ],
  30000. [
  30001. 9,
  30002. 15
  30003. ],
  30004. [
  30005. 9,
  30006. 15
  30007. ],
  30008. [
  30009. 12,
  30010. 128
  30011. ],
  30012. [
  30013. 12,
  30014. 192
  30015. ],
  30016. [
  30017. 12,
  30018. 26
  30019. ],
  30020. [
  30021. 12,
  30022. 27
  30023. ],
  30024. [
  30025. 12,
  30026. 28
  30027. ],
  30028. [
  30029. 12,
  30030. 29
  30031. ],
  30032. [
  30033. 11,
  30034. 19
  30035. ],
  30036. [
  30037. 11,
  30038. 19
  30039. ],
  30040. [
  30041. 11,
  30042. 20
  30043. ],
  30044. [
  30045. 11,
  30046. 20
  30047. ],
  30048. [
  30049. 12,
  30050. 34
  30051. ],
  30052. [
  30053. 12,
  30054. 35
  30055. ],
  30056. [
  30057. 12,
  30058. 36
  30059. ],
  30060. [
  30061. 12,
  30062. 37
  30063. ],
  30064. [
  30065. 12,
  30066. 38
  30067. ],
  30068. [
  30069. 12,
  30070. 39
  30071. ],
  30072. [
  30073. 11,
  30074. 21
  30075. ],
  30076. [
  30077. 11,
  30078. 21
  30079. ],
  30080. [
  30081. 12,
  30082. 42
  30083. ],
  30084. [
  30085. 12,
  30086. 43
  30087. ],
  30088. [
  30089. 10,
  30090. 0
  30091. ],
  30092. [
  30093. 10,
  30094. 0
  30095. ],
  30096. [
  30097. 10,
  30098. 0
  30099. ],
  30100. [
  30101. 10,
  30102. 0
  30103. ],
  30104. [
  30105. 7,
  30106. 12
  30107. ],
  30108. [
  30109. 7,
  30110. 12
  30111. ],
  30112. [
  30113. 7,
  30114. 12
  30115. ],
  30116. [
  30117. 7,
  30118. 12
  30119. ],
  30120. [
  30121. 7,
  30122. 12
  30123. ],
  30124. [
  30125. 7,
  30126. 12
  30127. ],
  30128. [
  30129. 7,
  30130. 12
  30131. ],
  30132. [
  30133. 7,
  30134. 12
  30135. ],
  30136. [
  30137. 7,
  30138. 12
  30139. ],
  30140. [
  30141. 7,
  30142. 12
  30143. ],
  30144. [
  30145. 7,
  30146. 12
  30147. ],
  30148. [
  30149. 7,
  30150. 12
  30151. ],
  30152. [
  30153. 7,
  30154. 12
  30155. ],
  30156. [
  30157. 7,
  30158. 12
  30159. ],
  30160. [
  30161. 7,
  30162. 12
  30163. ],
  30164. [
  30165. 7,
  30166. 12
  30167. ],
  30168. [
  30169. 7,
  30170. 12
  30171. ],
  30172. [
  30173. 7,
  30174. 12
  30175. ],
  30176. [
  30177. 7,
  30178. 12
  30179. ],
  30180. [
  30181. 7,
  30182. 12
  30183. ],
  30184. [
  30185. 7,
  30186. 12
  30187. ],
  30188. [
  30189. 7,
  30190. 12
  30191. ],
  30192. [
  30193. 7,
  30194. 12
  30195. ],
  30196. [
  30197. 7,
  30198. 12
  30199. ],
  30200. [
  30201. 7,
  30202. 12
  30203. ],
  30204. [
  30205. 7,
  30206. 12
  30207. ],
  30208. [
  30209. 7,
  30210. 12
  30211. ],
  30212. [
  30213. 7,
  30214. 12
  30215. ],
  30216. [
  30217. 7,
  30218. 12
  30219. ],
  30220. [
  30221. 7,
  30222. 12
  30223. ],
  30224. [
  30225. 7,
  30226. 12
  30227. ],
  30228. [
  30229. 7,
  30230. 12
  30231. ]
  30232. ];
  30233. var blackTable3 = [
  30234. [
  30235. -1,
  30236. -1
  30237. ],
  30238. [
  30239. -1,
  30240. -1
  30241. ],
  30242. [
  30243. -1,
  30244. -1
  30245. ],
  30246. [
  30247. -1,
  30248. -1
  30249. ],
  30250. [
  30251. 6,
  30252. 9
  30253. ],
  30254. [
  30255. 6,
  30256. 8
  30257. ],
  30258. [
  30259. 5,
  30260. 7
  30261. ],
  30262. [
  30263. 5,
  30264. 7
  30265. ],
  30266. [
  30267. 4,
  30268. 6
  30269. ],
  30270. [
  30271. 4,
  30272. 6
  30273. ],
  30274. [
  30275. 4,
  30276. 6
  30277. ],
  30278. [
  30279. 4,
  30280. 6
  30281. ],
  30282. [
  30283. 4,
  30284. 5
  30285. ],
  30286. [
  30287. 4,
  30288. 5
  30289. ],
  30290. [
  30291. 4,
  30292. 5
  30293. ],
  30294. [
  30295. 4,
  30296. 5
  30297. ],
  30298. [
  30299. 3,
  30300. 1
  30301. ],
  30302. [
  30303. 3,
  30304. 1
  30305. ],
  30306. [
  30307. 3,
  30308. 1
  30309. ],
  30310. [
  30311. 3,
  30312. 1
  30313. ],
  30314. [
  30315. 3,
  30316. 1
  30317. ],
  30318. [
  30319. 3,
  30320. 1
  30321. ],
  30322. [
  30323. 3,
  30324. 1
  30325. ],
  30326. [
  30327. 3,
  30328. 1
  30329. ],
  30330. [
  30331. 3,
  30332. 4
  30333. ],
  30334. [
  30335. 3,
  30336. 4
  30337. ],
  30338. [
  30339. 3,
  30340. 4
  30341. ],
  30342. [
  30343. 3,
  30344. 4
  30345. ],
  30346. [
  30347. 3,
  30348. 4
  30349. ],
  30350. [
  30351. 3,
  30352. 4
  30353. ],
  30354. [
  30355. 3,
  30356. 4
  30357. ],
  30358. [
  30359. 3,
  30360. 4
  30361. ],
  30362. [
  30363. 2,
  30364. 3
  30365. ],
  30366. [
  30367. 2,
  30368. 3
  30369. ],
  30370. [
  30371. 2,
  30372. 3
  30373. ],
  30374. [
  30375. 2,
  30376. 3
  30377. ],
  30378. [
  30379. 2,
  30380. 3
  30381. ],
  30382. [
  30383. 2,
  30384. 3
  30385. ],
  30386. [
  30387. 2,
  30388. 3
  30389. ],
  30390. [
  30391. 2,
  30392. 3
  30393. ],
  30394. [
  30395. 2,
  30396. 3
  30397. ],
  30398. [
  30399. 2,
  30400. 3
  30401. ],
  30402. [
  30403. 2,
  30404. 3
  30405. ],
  30406. [
  30407. 2,
  30408. 3
  30409. ],
  30410. [
  30411. 2,
  30412. 3
  30413. ],
  30414. [
  30415. 2,
  30416. 3
  30417. ],
  30418. [
  30419. 2,
  30420. 3
  30421. ],
  30422. [
  30423. 2,
  30424. 3
  30425. ],
  30426. [
  30427. 2,
  30428. 2
  30429. ],
  30430. [
  30431. 2,
  30432. 2
  30433. ],
  30434. [
  30435. 2,
  30436. 2
  30437. ],
  30438. [
  30439. 2,
  30440. 2
  30441. ],
  30442. [
  30443. 2,
  30444. 2
  30445. ],
  30446. [
  30447. 2,
  30448. 2
  30449. ],
  30450. [
  30451. 2,
  30452. 2
  30453. ],
  30454. [
  30455. 2,
  30456. 2
  30457. ],
  30458. [
  30459. 2,
  30460. 2
  30461. ],
  30462. [
  30463. 2,
  30464. 2
  30465. ],
  30466. [
  30467. 2,
  30468. 2
  30469. ],
  30470. [
  30471. 2,
  30472. 2
  30473. ],
  30474. [
  30475. 2,
  30476. 2
  30477. ],
  30478. [
  30479. 2,
  30480. 2
  30481. ],
  30482. [
  30483. 2,
  30484. 2
  30485. ],
  30486. [
  30487. 2,
  30488. 2
  30489. ]
  30490. ];
  30491. function CCITTFaxStream(str, maybeLength, params) {
  30492. this.str = str;
  30493. this.dict = str.dict;
  30494. params = params || Dict.empty;
  30495. this.encoding = params.get('K') || 0;
  30496. this.eoline = params.get('EndOfLine') || false;
  30497. this.byteAlign = params.get('EncodedByteAlign') || false;
  30498. this.columns = params.get('Columns') || 1728;
  30499. this.rows = params.get('Rows') || 0;
  30500. var eoblock = params.get('EndOfBlock');
  30501. if (eoblock === null || eoblock === undefined) {
  30502. eoblock = true;
  30503. }
  30504. this.eoblock = eoblock;
  30505. this.black = params.get('BlackIs1') || false;
  30506. this.codingLine = new Uint32Array(this.columns + 1);
  30507. this.refLine = new Uint32Array(this.columns + 2);
  30508. this.codingLine[0] = this.columns;
  30509. this.codingPos = 0;
  30510. this.row = 0;
  30511. this.nextLine2D = this.encoding < 0;
  30512. this.inputBits = 0;
  30513. this.inputBuf = 0;
  30514. this.outputBits = 0;
  30515. var code1;
  30516. while ((code1 = this.lookBits(12)) === 0) {
  30517. this.eatBits(1);
  30518. }
  30519. if (code1 === 1) {
  30520. this.eatBits(12);
  30521. }
  30522. if (this.encoding > 0) {
  30523. this.nextLine2D = !this.lookBits(1);
  30524. this.eatBits(1);
  30525. }
  30526. DecodeStream.call(this, maybeLength);
  30527. }
  30528. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30529. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30530. while (!this.eof) {
  30531. var c = this.lookChar();
  30532. this.ensureBuffer(this.bufferLength + 1);
  30533. this.buffer[this.bufferLength++] = c;
  30534. }
  30535. };
  30536. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30537. var codingLine = this.codingLine;
  30538. var codingPos = this.codingPos;
  30539. if (a1 > codingLine[codingPos]) {
  30540. if (a1 > this.columns) {
  30541. info('row is wrong length');
  30542. this.err = true;
  30543. a1 = this.columns;
  30544. }
  30545. if (codingPos & 1 ^ blackPixels) {
  30546. ++codingPos;
  30547. }
  30548. codingLine[codingPos] = a1;
  30549. }
  30550. this.codingPos = codingPos;
  30551. };
  30552. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30553. var codingLine = this.codingLine;
  30554. var codingPos = this.codingPos;
  30555. if (a1 > codingLine[codingPos]) {
  30556. if (a1 > this.columns) {
  30557. info('row is wrong length');
  30558. this.err = true;
  30559. a1 = this.columns;
  30560. }
  30561. if (codingPos & 1 ^ blackPixels) {
  30562. ++codingPos;
  30563. }
  30564. codingLine[codingPos] = a1;
  30565. } else if (a1 < codingLine[codingPos]) {
  30566. if (a1 < 0) {
  30567. info('invalid code');
  30568. this.err = true;
  30569. a1 = 0;
  30570. }
  30571. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30572. --codingPos;
  30573. }
  30574. codingLine[codingPos] = a1;
  30575. }
  30576. this.codingPos = codingPos;
  30577. };
  30578. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30579. var refLine = this.refLine;
  30580. var codingLine = this.codingLine;
  30581. var columns = this.columns;
  30582. var refPos, blackPixels, bits, i;
  30583. if (this.outputBits === 0) {
  30584. if (this.eof) {
  30585. return null;
  30586. }
  30587. this.err = false;
  30588. var code1, code2, code3;
  30589. if (this.nextLine2D) {
  30590. for (i = 0; codingLine[i] < columns; ++i) {
  30591. refLine[i] = codingLine[i];
  30592. }
  30593. refLine[i++] = columns;
  30594. refLine[i] = columns;
  30595. codingLine[0] = 0;
  30596. this.codingPos = 0;
  30597. refPos = 0;
  30598. blackPixels = 0;
  30599. while (codingLine[this.codingPos] < columns) {
  30600. code1 = this.getTwoDimCode();
  30601. switch (code1) {
  30602. case twoDimPass:
  30603. this.addPixels(refLine[refPos + 1], blackPixels);
  30604. if (refLine[refPos + 1] < columns) {
  30605. refPos += 2;
  30606. }
  30607. break;
  30608. case twoDimHoriz:
  30609. code1 = code2 = 0;
  30610. if (blackPixels) {
  30611. do {
  30612. code1 += code3 = this.getBlackCode();
  30613. } while (code3 >= 64);
  30614. do {
  30615. code2 += code3 = this.getWhiteCode();
  30616. } while (code3 >= 64);
  30617. } else {
  30618. do {
  30619. code1 += code3 = this.getWhiteCode();
  30620. } while (code3 >= 64);
  30621. do {
  30622. code2 += code3 = this.getBlackCode();
  30623. } while (code3 >= 64);
  30624. }
  30625. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30626. if (codingLine[this.codingPos] < columns) {
  30627. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30628. }
  30629. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30630. refPos += 2;
  30631. }
  30632. break;
  30633. case twoDimVertR3:
  30634. this.addPixels(refLine[refPos] + 3, blackPixels);
  30635. blackPixels ^= 1;
  30636. if (codingLine[this.codingPos] < columns) {
  30637. ++refPos;
  30638. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30639. refPos += 2;
  30640. }
  30641. }
  30642. break;
  30643. case twoDimVertR2:
  30644. this.addPixels(refLine[refPos] + 2, blackPixels);
  30645. blackPixels ^= 1;
  30646. if (codingLine[this.codingPos] < columns) {
  30647. ++refPos;
  30648. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30649. refPos += 2;
  30650. }
  30651. }
  30652. break;
  30653. case twoDimVertR1:
  30654. this.addPixels(refLine[refPos] + 1, blackPixels);
  30655. blackPixels ^= 1;
  30656. if (codingLine[this.codingPos] < columns) {
  30657. ++refPos;
  30658. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30659. refPos += 2;
  30660. }
  30661. }
  30662. break;
  30663. case twoDimVert0:
  30664. this.addPixels(refLine[refPos], blackPixels);
  30665. blackPixels ^= 1;
  30666. if (codingLine[this.codingPos] < columns) {
  30667. ++refPos;
  30668. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30669. refPos += 2;
  30670. }
  30671. }
  30672. break;
  30673. case twoDimVertL3:
  30674. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  30675. blackPixels ^= 1;
  30676. if (codingLine[this.codingPos] < columns) {
  30677. if (refPos > 0) {
  30678. --refPos;
  30679. } else {
  30680. ++refPos;
  30681. }
  30682. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30683. refPos += 2;
  30684. }
  30685. }
  30686. break;
  30687. case twoDimVertL2:
  30688. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  30689. blackPixels ^= 1;
  30690. if (codingLine[this.codingPos] < columns) {
  30691. if (refPos > 0) {
  30692. --refPos;
  30693. } else {
  30694. ++refPos;
  30695. }
  30696. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30697. refPos += 2;
  30698. }
  30699. }
  30700. break;
  30701. case twoDimVertL1:
  30702. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  30703. blackPixels ^= 1;
  30704. if (codingLine[this.codingPos] < columns) {
  30705. if (refPos > 0) {
  30706. --refPos;
  30707. } else {
  30708. ++refPos;
  30709. }
  30710. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30711. refPos += 2;
  30712. }
  30713. }
  30714. break;
  30715. case ccittEOF:
  30716. this.addPixels(columns, 0);
  30717. this.eof = true;
  30718. break;
  30719. default:
  30720. info('bad 2d code');
  30721. this.addPixels(columns, 0);
  30722. this.err = true;
  30723. }
  30724. }
  30725. } else {
  30726. codingLine[0] = 0;
  30727. this.codingPos = 0;
  30728. blackPixels = 0;
  30729. while (codingLine[this.codingPos] < columns) {
  30730. code1 = 0;
  30731. if (blackPixels) {
  30732. do {
  30733. code1 += code3 = this.getBlackCode();
  30734. } while (code3 >= 64);
  30735. } else {
  30736. do {
  30737. code1 += code3 = this.getWhiteCode();
  30738. } while (code3 >= 64);
  30739. }
  30740. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30741. blackPixels ^= 1;
  30742. }
  30743. }
  30744. var gotEOL = false;
  30745. if (this.byteAlign) {
  30746. this.inputBits &= ~7;
  30747. }
  30748. if (!this.eoblock && this.row === this.rows - 1) {
  30749. this.eof = true;
  30750. } else {
  30751. code1 = this.lookBits(12);
  30752. if (this.eoline) {
  30753. while (code1 !== ccittEOF && code1 !== 1) {
  30754. this.eatBits(1);
  30755. code1 = this.lookBits(12);
  30756. }
  30757. } else {
  30758. while (code1 === 0) {
  30759. this.eatBits(1);
  30760. code1 = this.lookBits(12);
  30761. }
  30762. }
  30763. if (code1 === 1) {
  30764. this.eatBits(12);
  30765. gotEOL = true;
  30766. } else if (code1 === ccittEOF) {
  30767. this.eof = true;
  30768. }
  30769. }
  30770. if (!this.eof && this.encoding > 0) {
  30771. this.nextLine2D = !this.lookBits(1);
  30772. this.eatBits(1);
  30773. }
  30774. if (this.eoblock && gotEOL && this.byteAlign) {
  30775. code1 = this.lookBits(12);
  30776. if (code1 === 1) {
  30777. this.eatBits(12);
  30778. if (this.encoding > 0) {
  30779. this.lookBits(1);
  30780. this.eatBits(1);
  30781. }
  30782. if (this.encoding >= 0) {
  30783. for (i = 0; i < 4; ++i) {
  30784. code1 = this.lookBits(12);
  30785. if (code1 !== 1) {
  30786. info('bad rtc code: ' + code1);
  30787. }
  30788. this.eatBits(12);
  30789. if (this.encoding > 0) {
  30790. this.lookBits(1);
  30791. this.eatBits(1);
  30792. }
  30793. }
  30794. }
  30795. this.eof = true;
  30796. }
  30797. } else if (this.err && this.eoline) {
  30798. while (true) {
  30799. code1 = this.lookBits(13);
  30800. if (code1 === ccittEOF) {
  30801. this.eof = true;
  30802. return null;
  30803. }
  30804. if (code1 >> 1 === 1) {
  30805. break;
  30806. }
  30807. this.eatBits(1);
  30808. }
  30809. this.eatBits(12);
  30810. if (this.encoding > 0) {
  30811. this.eatBits(1);
  30812. this.nextLine2D = !(code1 & 1);
  30813. }
  30814. }
  30815. if (codingLine[0] > 0) {
  30816. this.outputBits = codingLine[this.codingPos = 0];
  30817. } else {
  30818. this.outputBits = codingLine[this.codingPos = 1];
  30819. }
  30820. this.row++;
  30821. }
  30822. var c;
  30823. if (this.outputBits >= 8) {
  30824. c = this.codingPos & 1 ? 0 : 0xFF;
  30825. this.outputBits -= 8;
  30826. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  30827. this.codingPos++;
  30828. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30829. }
  30830. } else {
  30831. bits = 8;
  30832. c = 0;
  30833. do {
  30834. if (this.outputBits > bits) {
  30835. c <<= bits;
  30836. if (!(this.codingPos & 1)) {
  30837. c |= 0xFF >> 8 - bits;
  30838. }
  30839. this.outputBits -= bits;
  30840. bits = 0;
  30841. } else {
  30842. c <<= this.outputBits;
  30843. if (!(this.codingPos & 1)) {
  30844. c |= 0xFF >> 8 - this.outputBits;
  30845. }
  30846. bits -= this.outputBits;
  30847. this.outputBits = 0;
  30848. if (codingLine[this.codingPos] < columns) {
  30849. this.codingPos++;
  30850. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30851. } else if (bits > 0) {
  30852. c <<= bits;
  30853. bits = 0;
  30854. }
  30855. }
  30856. } while (bits);
  30857. }
  30858. if (this.black) {
  30859. c ^= 0xFF;
  30860. }
  30861. return c;
  30862. };
  30863. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  30864. var limitValue = limit || 0;
  30865. for (var i = start; i <= end; ++i) {
  30866. var code = this.lookBits(i);
  30867. if (code === ccittEOF) {
  30868. return [
  30869. true,
  30870. 1,
  30871. false
  30872. ];
  30873. }
  30874. if (i < end) {
  30875. code <<= end - i;
  30876. }
  30877. if (!limitValue || code >= limitValue) {
  30878. var p = table[code - limitValue];
  30879. if (p[0] === i) {
  30880. this.eatBits(i);
  30881. return [
  30882. true,
  30883. p[1],
  30884. true
  30885. ];
  30886. }
  30887. }
  30888. }
  30889. return [
  30890. false,
  30891. 0,
  30892. false
  30893. ];
  30894. };
  30895. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  30896. var code = 0;
  30897. var p;
  30898. if (this.eoblock) {
  30899. code = this.lookBits(7);
  30900. p = twoDimTable[code];
  30901. if (p && p[0] > 0) {
  30902. this.eatBits(p[0]);
  30903. return p[1];
  30904. }
  30905. } else {
  30906. var result = this.findTableCode(1, 7, twoDimTable);
  30907. if (result[0] && result[2]) {
  30908. return result[1];
  30909. }
  30910. }
  30911. info('Bad two dim code');
  30912. return ccittEOF;
  30913. };
  30914. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  30915. var code = 0;
  30916. var p;
  30917. if (this.eoblock) {
  30918. code = this.lookBits(12);
  30919. if (code === ccittEOF) {
  30920. return 1;
  30921. }
  30922. if (code >> 5 === 0) {
  30923. p = whiteTable1[code];
  30924. } else {
  30925. p = whiteTable2[code >> 3];
  30926. }
  30927. if (p[0] > 0) {
  30928. this.eatBits(p[0]);
  30929. return p[1];
  30930. }
  30931. } else {
  30932. var result = this.findTableCode(1, 9, whiteTable2);
  30933. if (result[0]) {
  30934. return result[1];
  30935. }
  30936. result = this.findTableCode(11, 12, whiteTable1);
  30937. if (result[0]) {
  30938. return result[1];
  30939. }
  30940. }
  30941. info('bad white code');
  30942. this.eatBits(1);
  30943. return 1;
  30944. };
  30945. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  30946. var code, p;
  30947. if (this.eoblock) {
  30948. code = this.lookBits(13);
  30949. if (code === ccittEOF) {
  30950. return 1;
  30951. }
  30952. if (code >> 7 === 0) {
  30953. p = blackTable1[code];
  30954. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  30955. p = blackTable2[(code >> 1) - 64];
  30956. } else {
  30957. p = blackTable3[code >> 7];
  30958. }
  30959. if (p[0] > 0) {
  30960. this.eatBits(p[0]);
  30961. return p[1];
  30962. }
  30963. } else {
  30964. var result = this.findTableCode(2, 6, blackTable3);
  30965. if (result[0]) {
  30966. return result[1];
  30967. }
  30968. result = this.findTableCode(7, 12, blackTable2, 64);
  30969. if (result[0]) {
  30970. return result[1];
  30971. }
  30972. result = this.findTableCode(10, 13, blackTable1);
  30973. if (result[0]) {
  30974. return result[1];
  30975. }
  30976. }
  30977. info('bad black code');
  30978. this.eatBits(1);
  30979. return 1;
  30980. };
  30981. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  30982. var c;
  30983. while (this.inputBits < n) {
  30984. if ((c = this.str.getByte()) === -1) {
  30985. if (this.inputBits === 0) {
  30986. return ccittEOF;
  30987. }
  30988. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  30989. }
  30990. this.inputBuf = this.inputBuf << 8 | c;
  30991. this.inputBits += 8;
  30992. }
  30993. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  30994. };
  30995. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  30996. if ((this.inputBits -= n) < 0) {
  30997. this.inputBits = 0;
  30998. }
  30999. };
  31000. return CCITTFaxStream;
  31001. }();
  31002. var LZWStream = function LZWStreamClosure() {
  31003. function LZWStream(str, maybeLength, earlyChange) {
  31004. this.str = str;
  31005. this.dict = str.dict;
  31006. this.cachedData = 0;
  31007. this.bitsCached = 0;
  31008. var maxLzwDictionarySize = 4096;
  31009. var lzwState = {
  31010. earlyChange: earlyChange,
  31011. codeLength: 9,
  31012. nextCode: 258,
  31013. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31014. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31015. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31016. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31017. currentSequenceLength: 0
  31018. };
  31019. for (var i = 0; i < 256; ++i) {
  31020. lzwState.dictionaryValues[i] = i;
  31021. lzwState.dictionaryLengths[i] = 1;
  31022. }
  31023. this.lzwState = lzwState;
  31024. DecodeStream.call(this, maybeLength);
  31025. }
  31026. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31027. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31028. var bitsCached = this.bitsCached;
  31029. var cachedData = this.cachedData;
  31030. while (bitsCached < n) {
  31031. var c = this.str.getByte();
  31032. if (c === -1) {
  31033. this.eof = true;
  31034. return null;
  31035. }
  31036. cachedData = cachedData << 8 | c;
  31037. bitsCached += 8;
  31038. }
  31039. this.bitsCached = bitsCached -= n;
  31040. this.cachedData = cachedData;
  31041. this.lastCode = null;
  31042. return cachedData >>> bitsCached & (1 << n) - 1;
  31043. };
  31044. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31045. var blockSize = 512;
  31046. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31047. var i, j, q;
  31048. var lzwState = this.lzwState;
  31049. if (!lzwState) {
  31050. return;
  31051. }
  31052. var earlyChange = lzwState.earlyChange;
  31053. var nextCode = lzwState.nextCode;
  31054. var dictionaryValues = lzwState.dictionaryValues;
  31055. var dictionaryLengths = lzwState.dictionaryLengths;
  31056. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31057. var codeLength = lzwState.codeLength;
  31058. var prevCode = lzwState.prevCode;
  31059. var currentSequence = lzwState.currentSequence;
  31060. var currentSequenceLength = lzwState.currentSequenceLength;
  31061. var decodedLength = 0;
  31062. var currentBufferLength = this.bufferLength;
  31063. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31064. for (i = 0; i < blockSize; i++) {
  31065. var code = this.readBits(codeLength);
  31066. var hasPrev = currentSequenceLength > 0;
  31067. if (code < 256) {
  31068. currentSequence[0] = code;
  31069. currentSequenceLength = 1;
  31070. } else if (code >= 258) {
  31071. if (code < nextCode) {
  31072. currentSequenceLength = dictionaryLengths[code];
  31073. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31074. currentSequence[j] = dictionaryValues[q];
  31075. q = dictionaryPrevCodes[q];
  31076. }
  31077. } else {
  31078. currentSequence[currentSequenceLength++] = currentSequence[0];
  31079. }
  31080. } else if (code === 256) {
  31081. codeLength = 9;
  31082. nextCode = 258;
  31083. currentSequenceLength = 0;
  31084. continue;
  31085. } else {
  31086. this.eof = true;
  31087. delete this.lzwState;
  31088. break;
  31089. }
  31090. if (hasPrev) {
  31091. dictionaryPrevCodes[nextCode] = prevCode;
  31092. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31093. dictionaryValues[nextCode] = currentSequence[0];
  31094. nextCode++;
  31095. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31096. }
  31097. prevCode = code;
  31098. decodedLength += currentSequenceLength;
  31099. if (estimatedDecodedSize < decodedLength) {
  31100. do {
  31101. estimatedDecodedSize += decodedSizeDelta;
  31102. } while (estimatedDecodedSize < decodedLength);
  31103. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31104. }
  31105. for (j = 0; j < currentSequenceLength; j++) {
  31106. buffer[currentBufferLength++] = currentSequence[j];
  31107. }
  31108. }
  31109. lzwState.nextCode = nextCode;
  31110. lzwState.codeLength = codeLength;
  31111. lzwState.prevCode = prevCode;
  31112. lzwState.currentSequenceLength = currentSequenceLength;
  31113. this.bufferLength = currentBufferLength;
  31114. };
  31115. return LZWStream;
  31116. }();
  31117. var NullStream = function NullStreamClosure() {
  31118. function NullStream() {
  31119. Stream.call(this, new Uint8Array(0));
  31120. }
  31121. NullStream.prototype = Stream.prototype;
  31122. return NullStream;
  31123. }();
  31124. exports.Ascii85Stream = Ascii85Stream;
  31125. exports.AsciiHexStream = AsciiHexStream;
  31126. exports.CCITTFaxStream = CCITTFaxStream;
  31127. exports.DecryptStream = DecryptStream;
  31128. exports.DecodeStream = DecodeStream;
  31129. exports.FlateStream = FlateStream;
  31130. exports.Jbig2Stream = Jbig2Stream;
  31131. exports.JpegStream = JpegStream;
  31132. exports.JpxStream = JpxStream;
  31133. exports.NullStream = NullStream;
  31134. exports.PredictorStream = PredictorStream;
  31135. exports.RunLengthStream = RunLengthStream;
  31136. exports.Stream = Stream;
  31137. exports.StreamsSequenceStream = StreamsSequenceStream;
  31138. exports.StringStream = StringStream;
  31139. exports.LZWStream = LZWStream;
  31140. }));
  31141. (function (root, factory) {
  31142. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31143. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31144. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31145. var AnnotationType = sharedUtil.AnnotationType;
  31146. var Util = sharedUtil.Util;
  31147. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31148. var LinkTarget = displayDOMUtils.LinkTarget;
  31149. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31150. var warn = sharedUtil.warn;
  31151. var CustomStyle = displayDOMUtils.CustomStyle;
  31152. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31153. function AnnotationElementFactory() {
  31154. }
  31155. AnnotationElementFactory.prototype = {
  31156. create: function AnnotationElementFactory_create(parameters) {
  31157. var subtype = parameters.data.annotationType;
  31158. switch (subtype) {
  31159. case AnnotationType.LINK:
  31160. return new LinkAnnotationElement(parameters);
  31161. case AnnotationType.TEXT:
  31162. return new TextAnnotationElement(parameters);
  31163. case AnnotationType.WIDGET:
  31164. var fieldType = parameters.data.fieldType;
  31165. switch (fieldType) {
  31166. case 'Tx':
  31167. return new TextWidgetAnnotationElement(parameters);
  31168. case 'Ch':
  31169. return new ChoiceWidgetAnnotationElement(parameters);
  31170. }
  31171. return new WidgetAnnotationElement(parameters);
  31172. case AnnotationType.POPUP:
  31173. return new PopupAnnotationElement(parameters);
  31174. case AnnotationType.HIGHLIGHT:
  31175. return new HighlightAnnotationElement(parameters);
  31176. case AnnotationType.UNDERLINE:
  31177. return new UnderlineAnnotationElement(parameters);
  31178. case AnnotationType.SQUIGGLY:
  31179. return new SquigglyAnnotationElement(parameters);
  31180. case AnnotationType.STRIKEOUT:
  31181. return new StrikeOutAnnotationElement(parameters);
  31182. case AnnotationType.FILEATTACHMENT:
  31183. return new FileAttachmentAnnotationElement(parameters);
  31184. default:
  31185. return new AnnotationElement(parameters);
  31186. }
  31187. }
  31188. };
  31189. var AnnotationElement = function AnnotationElementClosure() {
  31190. function AnnotationElement(parameters, isRenderable) {
  31191. this.isRenderable = isRenderable || false;
  31192. this.data = parameters.data;
  31193. this.layer = parameters.layer;
  31194. this.page = parameters.page;
  31195. this.viewport = parameters.viewport;
  31196. this.linkService = parameters.linkService;
  31197. this.downloadManager = parameters.downloadManager;
  31198. this.imageResourcesPath = parameters.imageResourcesPath;
  31199. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31200. if (isRenderable) {
  31201. this.container = this._createContainer();
  31202. }
  31203. }
  31204. AnnotationElement.prototype = {
  31205. _createContainer: function AnnotationElement_createContainer() {
  31206. var data = this.data, page = this.page, viewport = this.viewport;
  31207. var container = document.createElement('section');
  31208. var width = data.rect[2] - data.rect[0];
  31209. var height = data.rect[3] - data.rect[1];
  31210. container.setAttribute('data-annotation-id', data.id);
  31211. var rect = Util.normalizeRect([
  31212. data.rect[0],
  31213. page.view[3] - data.rect[1] + page.view[1],
  31214. data.rect[2],
  31215. page.view[3] - data.rect[3] + page.view[1]
  31216. ]);
  31217. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31218. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31219. if (data.borderStyle.width > 0) {
  31220. container.style.borderWidth = data.borderStyle.width + 'px';
  31221. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31222. width = width - 2 * data.borderStyle.width;
  31223. height = height - 2 * data.borderStyle.width;
  31224. }
  31225. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31226. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31227. if (horizontalRadius > 0 || verticalRadius > 0) {
  31228. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31229. CustomStyle.setProp('borderRadius', container, radius);
  31230. }
  31231. switch (data.borderStyle.style) {
  31232. case AnnotationBorderStyleType.SOLID:
  31233. container.style.borderStyle = 'solid';
  31234. break;
  31235. case AnnotationBorderStyleType.DASHED:
  31236. container.style.borderStyle = 'dashed';
  31237. break;
  31238. case AnnotationBorderStyleType.BEVELED:
  31239. warn('Unimplemented border style: beveled');
  31240. break;
  31241. case AnnotationBorderStyleType.INSET:
  31242. warn('Unimplemented border style: inset');
  31243. break;
  31244. case AnnotationBorderStyleType.UNDERLINE:
  31245. container.style.borderBottomStyle = 'solid';
  31246. break;
  31247. default:
  31248. break;
  31249. }
  31250. if (data.color) {
  31251. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31252. } else {
  31253. container.style.borderWidth = 0;
  31254. }
  31255. }
  31256. container.style.left = rect[0] + 'px';
  31257. container.style.top = rect[1] + 'px';
  31258. container.style.width = width + 'px';
  31259. container.style.height = height + 'px';
  31260. return container;
  31261. },
  31262. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31263. if (!trigger) {
  31264. trigger = document.createElement('div');
  31265. trigger.style.height = container.style.height;
  31266. trigger.style.width = container.style.width;
  31267. container.appendChild(trigger);
  31268. }
  31269. var popupElement = new PopupElement({
  31270. container: container,
  31271. trigger: trigger,
  31272. color: data.color,
  31273. title: data.title,
  31274. contents: data.contents,
  31275. hideWrapper: true
  31276. });
  31277. var popup = popupElement.render();
  31278. popup.style.left = container.style.width;
  31279. container.appendChild(popup);
  31280. },
  31281. render: function AnnotationElement_render() {
  31282. throw new Error('Abstract method AnnotationElement.render called');
  31283. }
  31284. };
  31285. return AnnotationElement;
  31286. }();
  31287. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31288. function LinkAnnotationElement(parameters) {
  31289. AnnotationElement.call(this, parameters, true);
  31290. }
  31291. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31292. render: function LinkAnnotationElement_render() {
  31293. this.container.className = 'linkAnnotation';
  31294. var link = document.createElement('a');
  31295. addLinkAttributes(link, {
  31296. url: this.data.url,
  31297. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31298. });
  31299. if (!this.data.url) {
  31300. if (this.data.action) {
  31301. this._bindNamedAction(link, this.data.action);
  31302. } else {
  31303. this._bindLink(link, this.data.dest);
  31304. }
  31305. }
  31306. this.container.appendChild(link);
  31307. return this.container;
  31308. },
  31309. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31310. var self = this;
  31311. link.href = this.linkService.getDestinationHash(destination);
  31312. link.onclick = function () {
  31313. if (destination) {
  31314. self.linkService.navigateTo(destination);
  31315. }
  31316. return false;
  31317. };
  31318. if (destination) {
  31319. link.className = 'internalLink';
  31320. }
  31321. },
  31322. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31323. var self = this;
  31324. link.href = this.linkService.getAnchorUrl('');
  31325. link.onclick = function () {
  31326. self.linkService.executeNamedAction(action);
  31327. return false;
  31328. };
  31329. link.className = 'internalLink';
  31330. }
  31331. });
  31332. return LinkAnnotationElement;
  31333. }();
  31334. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31335. function TextAnnotationElement(parameters) {
  31336. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31337. AnnotationElement.call(this, parameters, isRenderable);
  31338. }
  31339. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31340. render: function TextAnnotationElement_render() {
  31341. this.container.className = 'textAnnotation';
  31342. var image = document.createElement('img');
  31343. image.style.height = this.container.style.height;
  31344. image.style.width = this.container.style.width;
  31345. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31346. image.alt = '[{{type}} Annotation]';
  31347. image.dataset.l10nId = 'text_annotation_type';
  31348. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31349. if (!this.data.hasPopup) {
  31350. this._createPopup(this.container, image, this.data);
  31351. }
  31352. this.container.appendChild(image);
  31353. return this.container;
  31354. }
  31355. });
  31356. return TextAnnotationElement;
  31357. }();
  31358. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31359. function WidgetAnnotationElement(parameters, isRenderable) {
  31360. AnnotationElement.call(this, parameters, isRenderable);
  31361. }
  31362. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31363. render: function WidgetAnnotationElement_render() {
  31364. return this.container;
  31365. }
  31366. });
  31367. return WidgetAnnotationElement;
  31368. }();
  31369. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31370. var TEXT_ALIGNMENT = [
  31371. 'left',
  31372. 'center',
  31373. 'right'
  31374. ];
  31375. function TextWidgetAnnotationElement(parameters) {
  31376. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31377. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31378. }
  31379. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31380. render: function TextWidgetAnnotationElement_render() {
  31381. this.container.className = 'textWidgetAnnotation';
  31382. var element = null;
  31383. if (this.renderInteractiveForms) {
  31384. if (this.data.multiLine) {
  31385. element = document.createElement('textarea');
  31386. element.textContent = this.data.fieldValue;
  31387. } else {
  31388. element = document.createElement('input');
  31389. element.type = 'text';
  31390. element.setAttribute('value', this.data.fieldValue);
  31391. }
  31392. element.disabled = this.data.readOnly;
  31393. if (this.data.maxLen !== null) {
  31394. element.maxLength = this.data.maxLen;
  31395. }
  31396. if (this.data.comb) {
  31397. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31398. var combWidth = fieldWidth / this.data.maxLen;
  31399. element.classList.add('comb');
  31400. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31401. }
  31402. } else {
  31403. element = document.createElement('div');
  31404. element.textContent = this.data.fieldValue;
  31405. element.style.verticalAlign = 'middle';
  31406. element.style.display = 'table-cell';
  31407. var font = null;
  31408. if (this.data.fontRefName) {
  31409. font = this.page.commonObjs.getData(this.data.fontRefName);
  31410. }
  31411. this._setTextStyle(element, font);
  31412. }
  31413. if (this.data.textAlignment !== null) {
  31414. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31415. }
  31416. this.container.appendChild(element);
  31417. return this.container;
  31418. },
  31419. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31420. var style = element.style;
  31421. style.fontSize = this.data.fontSize + 'px';
  31422. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31423. if (!font) {
  31424. return;
  31425. }
  31426. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31427. style.fontStyle = font.italic ? 'italic' : 'normal';
  31428. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31429. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31430. style.fontFamily = fontFamily + fallbackName;
  31431. }
  31432. });
  31433. return TextWidgetAnnotationElement;
  31434. }();
  31435. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31436. function ChoiceWidgetAnnotationElement(parameters) {
  31437. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31438. }
  31439. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31440. render: function ChoiceWidgetAnnotationElement_render() {
  31441. this.container.className = 'choiceWidgetAnnotation';
  31442. var selectElement = document.createElement('select');
  31443. selectElement.disabled = this.data.readOnly;
  31444. if (!this.data.combo) {
  31445. selectElement.size = this.data.options.length;
  31446. if (this.data.multiSelect) {
  31447. selectElement.multiple = true;
  31448. }
  31449. }
  31450. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31451. var option = this.data.options[i];
  31452. var optionElement = document.createElement('option');
  31453. optionElement.textContent = option.displayValue;
  31454. optionElement.value = option.exportValue;
  31455. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31456. optionElement.setAttribute('selected', true);
  31457. }
  31458. selectElement.appendChild(optionElement);
  31459. }
  31460. this.container.appendChild(selectElement);
  31461. return this.container;
  31462. }
  31463. });
  31464. return ChoiceWidgetAnnotationElement;
  31465. }();
  31466. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31467. function PopupAnnotationElement(parameters) {
  31468. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31469. AnnotationElement.call(this, parameters, isRenderable);
  31470. }
  31471. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31472. render: function PopupAnnotationElement_render() {
  31473. this.container.className = 'popupAnnotation';
  31474. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31475. var parentElement = this.layer.querySelector(selector);
  31476. if (!parentElement) {
  31477. return this.container;
  31478. }
  31479. var popup = new PopupElement({
  31480. container: this.container,
  31481. trigger: parentElement,
  31482. color: this.data.color,
  31483. title: this.data.title,
  31484. contents: this.data.contents
  31485. });
  31486. var parentLeft = parseFloat(parentElement.style.left);
  31487. var parentWidth = parseFloat(parentElement.style.width);
  31488. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31489. this.container.style.left = parentLeft + parentWidth + 'px';
  31490. this.container.appendChild(popup.render());
  31491. return this.container;
  31492. }
  31493. });
  31494. return PopupAnnotationElement;
  31495. }();
  31496. var PopupElement = function PopupElementClosure() {
  31497. var BACKGROUND_ENLIGHT = 0.7;
  31498. function PopupElement(parameters) {
  31499. this.container = parameters.container;
  31500. this.trigger = parameters.trigger;
  31501. this.color = parameters.color;
  31502. this.title = parameters.title;
  31503. this.contents = parameters.contents;
  31504. this.hideWrapper = parameters.hideWrapper || false;
  31505. this.pinned = false;
  31506. }
  31507. PopupElement.prototype = {
  31508. render: function PopupElement_render() {
  31509. var wrapper = document.createElement('div');
  31510. wrapper.className = 'popupWrapper';
  31511. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31512. this.hideElement.setAttribute('hidden', true);
  31513. var popup = document.createElement('div');
  31514. popup.className = 'popup';
  31515. var color = this.color;
  31516. if (color) {
  31517. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31518. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31519. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31520. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31521. }
  31522. var contents = this._formatContents(this.contents);
  31523. var title = document.createElement('h1');
  31524. title.textContent = this.title;
  31525. this.trigger.addEventListener('click', this._toggle.bind(this));
  31526. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31527. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31528. popup.addEventListener('click', this._hide.bind(this, true));
  31529. popup.appendChild(title);
  31530. popup.appendChild(contents);
  31531. wrapper.appendChild(popup);
  31532. return wrapper;
  31533. },
  31534. _formatContents: function PopupElement_formatContents(contents) {
  31535. var p = document.createElement('p');
  31536. var lines = contents.split(/(?:\r\n?|\n)/);
  31537. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31538. var line = lines[i];
  31539. p.appendChild(document.createTextNode(line));
  31540. if (i < ii - 1) {
  31541. p.appendChild(document.createElement('br'));
  31542. }
  31543. }
  31544. return p;
  31545. },
  31546. _toggle: function PopupElement_toggle() {
  31547. if (this.pinned) {
  31548. this._hide(true);
  31549. } else {
  31550. this._show(true);
  31551. }
  31552. },
  31553. _show: function PopupElement_show(pin) {
  31554. if (pin) {
  31555. this.pinned = true;
  31556. }
  31557. if (this.hideElement.hasAttribute('hidden')) {
  31558. this.hideElement.removeAttribute('hidden');
  31559. this.container.style.zIndex += 1;
  31560. }
  31561. },
  31562. _hide: function PopupElement_hide(unpin) {
  31563. if (unpin) {
  31564. this.pinned = false;
  31565. }
  31566. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31567. this.hideElement.setAttribute('hidden', true);
  31568. this.container.style.zIndex -= 1;
  31569. }
  31570. }
  31571. };
  31572. return PopupElement;
  31573. }();
  31574. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31575. function HighlightAnnotationElement(parameters) {
  31576. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31577. AnnotationElement.call(this, parameters, isRenderable);
  31578. }
  31579. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31580. render: function HighlightAnnotationElement_render() {
  31581. this.container.className = 'highlightAnnotation';
  31582. if (!this.data.hasPopup) {
  31583. this._createPopup(this.container, null, this.data);
  31584. }
  31585. return this.container;
  31586. }
  31587. });
  31588. return HighlightAnnotationElement;
  31589. }();
  31590. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31591. function UnderlineAnnotationElement(parameters) {
  31592. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31593. AnnotationElement.call(this, parameters, isRenderable);
  31594. }
  31595. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31596. render: function UnderlineAnnotationElement_render() {
  31597. this.container.className = 'underlineAnnotation';
  31598. if (!this.data.hasPopup) {
  31599. this._createPopup(this.container, null, this.data);
  31600. }
  31601. return this.container;
  31602. }
  31603. });
  31604. return UnderlineAnnotationElement;
  31605. }();
  31606. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31607. function SquigglyAnnotationElement(parameters) {
  31608. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31609. AnnotationElement.call(this, parameters, isRenderable);
  31610. }
  31611. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31612. render: function SquigglyAnnotationElement_render() {
  31613. this.container.className = 'squigglyAnnotation';
  31614. if (!this.data.hasPopup) {
  31615. this._createPopup(this.container, null, this.data);
  31616. }
  31617. return this.container;
  31618. }
  31619. });
  31620. return SquigglyAnnotationElement;
  31621. }();
  31622. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31623. function StrikeOutAnnotationElement(parameters) {
  31624. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31625. AnnotationElement.call(this, parameters, isRenderable);
  31626. }
  31627. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31628. render: function StrikeOutAnnotationElement_render() {
  31629. this.container.className = 'strikeoutAnnotation';
  31630. if (!this.data.hasPopup) {
  31631. this._createPopup(this.container, null, this.data);
  31632. }
  31633. return this.container;
  31634. }
  31635. });
  31636. return StrikeOutAnnotationElement;
  31637. }();
  31638. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31639. function FileAttachmentAnnotationElement(parameters) {
  31640. AnnotationElement.call(this, parameters, true);
  31641. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31642. this.content = parameters.data.file.content;
  31643. }
  31644. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31645. render: function FileAttachmentAnnotationElement_render() {
  31646. this.container.className = 'fileAttachmentAnnotation';
  31647. var trigger = document.createElement('div');
  31648. trigger.style.height = this.container.style.height;
  31649. trigger.style.width = this.container.style.width;
  31650. trigger.addEventListener('dblclick', this._download.bind(this));
  31651. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31652. this._createPopup(this.container, trigger, this.data);
  31653. }
  31654. this.container.appendChild(trigger);
  31655. return this.container;
  31656. },
  31657. _download: function FileAttachmentAnnotationElement_download() {
  31658. if (!this.downloadManager) {
  31659. warn('Download cannot be started due to unavailable download manager');
  31660. return;
  31661. }
  31662. this.downloadManager.downloadData(this.content, this.filename, '');
  31663. }
  31664. });
  31665. return FileAttachmentAnnotationElement;
  31666. }();
  31667. var AnnotationLayer = function AnnotationLayerClosure() {
  31668. return {
  31669. render: function AnnotationLayer_render(parameters) {
  31670. var annotationElementFactory = new AnnotationElementFactory();
  31671. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31672. var data = parameters.annotations[i];
  31673. if (!data) {
  31674. continue;
  31675. }
  31676. var properties = {
  31677. data: data,
  31678. layer: parameters.div,
  31679. page: parameters.page,
  31680. viewport: parameters.viewport,
  31681. linkService: parameters.linkService,
  31682. downloadManager: parameters.downloadManager,
  31683. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31684. renderInteractiveForms: parameters.renderInteractiveForms || false
  31685. };
  31686. var element = annotationElementFactory.create(properties);
  31687. if (element.isRenderable) {
  31688. parameters.div.appendChild(element.render());
  31689. }
  31690. }
  31691. },
  31692. update: function AnnotationLayer_update(parameters) {
  31693. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31694. var data = parameters.annotations[i];
  31695. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31696. if (element) {
  31697. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31698. }
  31699. }
  31700. parameters.div.removeAttribute('hidden');
  31701. }
  31702. };
  31703. }();
  31704. exports.AnnotationLayer = AnnotationLayer;
  31705. }));
  31706. (function (root, factory) {
  31707. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31708. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31709. var Util = sharedUtil.Util;
  31710. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31711. var CustomStyle = displayDOMUtils.CustomStyle;
  31712. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31713. var renderTextLayer = function renderTextLayerClosure() {
  31714. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31715. var NonWhitespaceRegexp = /\S/;
  31716. function isAllWhitespace(str) {
  31717. return !NonWhitespaceRegexp.test(str);
  31718. }
  31719. var styleBuf = [
  31720. 'left: ',
  31721. 0,
  31722. 'px; top: ',
  31723. 0,
  31724. 'px; font-size: ',
  31725. 0,
  31726. 'px; font-family: ',
  31727. '',
  31728. ';'
  31729. ];
  31730. function appendText(task, geom, styles) {
  31731. var textDiv = document.createElement('div');
  31732. var textDivProperties = {
  31733. style: null,
  31734. angle: 0,
  31735. canvasWidth: 0,
  31736. isWhitespace: false,
  31737. originalTransform: null,
  31738. paddingBottom: 0,
  31739. paddingLeft: 0,
  31740. paddingRight: 0,
  31741. paddingTop: 0,
  31742. scale: 1
  31743. };
  31744. task._textDivs.push(textDiv);
  31745. if (isAllWhitespace(geom.str)) {
  31746. textDivProperties.isWhitespace = true;
  31747. task._textDivProperties.set(textDiv, textDivProperties);
  31748. return;
  31749. }
  31750. var tx = Util.transform(task._viewport.transform, geom.transform);
  31751. var angle = Math.atan2(tx[1], tx[0]);
  31752. var style = styles[geom.fontName];
  31753. if (style.vertical) {
  31754. angle += Math.PI / 2;
  31755. }
  31756. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31757. var fontAscent = fontHeight;
  31758. if (style.ascent) {
  31759. fontAscent = style.ascent * fontAscent;
  31760. } else if (style.descent) {
  31761. fontAscent = (1 + style.descent) * fontAscent;
  31762. }
  31763. var left;
  31764. var top;
  31765. if (angle === 0) {
  31766. left = tx[4];
  31767. top = tx[5] - fontAscent;
  31768. } else {
  31769. left = tx[4] + fontAscent * Math.sin(angle);
  31770. top = tx[5] - fontAscent * Math.cos(angle);
  31771. }
  31772. styleBuf[1] = left;
  31773. styleBuf[3] = top;
  31774. styleBuf[5] = fontHeight;
  31775. styleBuf[7] = style.fontFamily;
  31776. textDivProperties.style = styleBuf.join('');
  31777. textDiv.setAttribute('style', textDivProperties.style);
  31778. textDiv.textContent = geom.str;
  31779. if (getDefaultSetting('pdfBug')) {
  31780. textDiv.dataset.fontName = geom.fontName;
  31781. }
  31782. if (angle !== 0) {
  31783. textDivProperties.angle = angle * (180 / Math.PI);
  31784. }
  31785. if (geom.str.length > 1) {
  31786. if (style.vertical) {
  31787. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31788. } else {
  31789. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31790. }
  31791. }
  31792. task._textDivProperties.set(textDiv, textDivProperties);
  31793. if (task._enhanceTextSelection) {
  31794. var angleCos = 1, angleSin = 0;
  31795. if (angle !== 0) {
  31796. angleCos = Math.cos(angle);
  31797. angleSin = Math.sin(angle);
  31798. }
  31799. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31800. var divHeight = fontHeight;
  31801. var m, b;
  31802. if (angle !== 0) {
  31803. m = [
  31804. angleCos,
  31805. angleSin,
  31806. -angleSin,
  31807. angleCos,
  31808. left,
  31809. top
  31810. ];
  31811. b = Util.getAxialAlignedBoundingBox([
  31812. 0,
  31813. 0,
  31814. divWidth,
  31815. divHeight
  31816. ], m);
  31817. } else {
  31818. b = [
  31819. left,
  31820. top,
  31821. left + divWidth,
  31822. top + divHeight
  31823. ];
  31824. }
  31825. task._bounds.push({
  31826. left: b[0],
  31827. top: b[1],
  31828. right: b[2],
  31829. bottom: b[3],
  31830. div: textDiv,
  31831. size: [
  31832. divWidth,
  31833. divHeight
  31834. ],
  31835. m: m
  31836. });
  31837. }
  31838. }
  31839. function render(task) {
  31840. if (task._canceled) {
  31841. return;
  31842. }
  31843. var textLayerFrag = task._container;
  31844. var textDivs = task._textDivs;
  31845. var capability = task._capability;
  31846. var textDivsLength = textDivs.length;
  31847. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  31848. task._renderingDone = true;
  31849. capability.resolve();
  31850. return;
  31851. }
  31852. var canvas = document.createElement('canvas');
  31853. var ctx = canvas.getContext('2d', { alpha: false });
  31854. var lastFontSize;
  31855. var lastFontFamily;
  31856. for (var i = 0; i < textDivsLength; i++) {
  31857. var textDiv = textDivs[i];
  31858. var textDivProperties = task._textDivProperties.get(textDiv);
  31859. if (textDivProperties.isWhitespace) {
  31860. continue;
  31861. }
  31862. var fontSize = textDiv.style.fontSize;
  31863. var fontFamily = textDiv.style.fontFamily;
  31864. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  31865. ctx.font = fontSize + ' ' + fontFamily;
  31866. lastFontSize = fontSize;
  31867. lastFontFamily = fontFamily;
  31868. }
  31869. var width = ctx.measureText(textDiv.textContent).width;
  31870. textLayerFrag.appendChild(textDiv);
  31871. var transform = '';
  31872. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  31873. textDivProperties.scale = textDivProperties.canvasWidth / width;
  31874. transform = 'scaleX(' + textDivProperties.scale + ')';
  31875. }
  31876. if (textDivProperties.angle !== 0) {
  31877. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  31878. }
  31879. if (transform !== '') {
  31880. textDivProperties.originalTransform = transform;
  31881. CustomStyle.setProp('transform', textDiv, transform);
  31882. }
  31883. task._textDivProperties.set(textDiv, textDivProperties);
  31884. }
  31885. task._renderingDone = true;
  31886. capability.resolve();
  31887. }
  31888. function expand(task) {
  31889. var bounds = task._bounds;
  31890. var viewport = task._viewport;
  31891. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  31892. for (var i = 0; i < expanded.length; i++) {
  31893. var div = bounds[i].div;
  31894. var divProperties = task._textDivProperties.get(div);
  31895. if (divProperties.angle === 0) {
  31896. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  31897. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  31898. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  31899. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  31900. task._textDivProperties.set(div, divProperties);
  31901. continue;
  31902. }
  31903. var e = expanded[i], b = bounds[i];
  31904. var m = b.m, c = m[0], s = m[1];
  31905. var points = [
  31906. [
  31907. 0,
  31908. 0
  31909. ],
  31910. [
  31911. 0,
  31912. b.size[1]
  31913. ],
  31914. [
  31915. b.size[0],
  31916. 0
  31917. ],
  31918. b.size
  31919. ];
  31920. var ts = new Float64Array(64);
  31921. points.forEach(function (p, i) {
  31922. var t = Util.applyTransform(p, m);
  31923. ts[i + 0] = c && (e.left - t[0]) / c;
  31924. ts[i + 4] = s && (e.top - t[1]) / s;
  31925. ts[i + 8] = c && (e.right - t[0]) / c;
  31926. ts[i + 12] = s && (e.bottom - t[1]) / s;
  31927. ts[i + 16] = s && (e.left - t[0]) / -s;
  31928. ts[i + 20] = c && (e.top - t[1]) / c;
  31929. ts[i + 24] = s && (e.right - t[0]) / -s;
  31930. ts[i + 28] = c && (e.bottom - t[1]) / c;
  31931. ts[i + 32] = c && (e.left - t[0]) / -c;
  31932. ts[i + 36] = s && (e.top - t[1]) / -s;
  31933. ts[i + 40] = c && (e.right - t[0]) / -c;
  31934. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  31935. ts[i + 48] = s && (e.left - t[0]) / s;
  31936. ts[i + 52] = c && (e.top - t[1]) / -c;
  31937. ts[i + 56] = s && (e.right - t[0]) / s;
  31938. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  31939. });
  31940. var findPositiveMin = function (ts, offset, count) {
  31941. var result = 0;
  31942. for (var i = 0; i < count; i++) {
  31943. var t = ts[offset++];
  31944. if (t > 0) {
  31945. result = result ? Math.min(t, result) : t;
  31946. }
  31947. }
  31948. return result;
  31949. };
  31950. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  31951. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  31952. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  31953. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  31954. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  31955. task._textDivProperties.set(div, divProperties);
  31956. }
  31957. }
  31958. function expandBounds(width, height, boxes) {
  31959. var bounds = boxes.map(function (box, i) {
  31960. return {
  31961. x1: box.left,
  31962. y1: box.top,
  31963. x2: box.right,
  31964. y2: box.bottom,
  31965. index: i,
  31966. x1New: undefined,
  31967. x2New: undefined
  31968. };
  31969. });
  31970. expandBoundsLTR(width, bounds);
  31971. var expanded = new Array(boxes.length);
  31972. bounds.forEach(function (b) {
  31973. var i = b.index;
  31974. expanded[i] = {
  31975. left: b.x1New,
  31976. top: 0,
  31977. right: b.x2New,
  31978. bottom: 0
  31979. };
  31980. });
  31981. boxes.map(function (box, i) {
  31982. var e = expanded[i], b = bounds[i];
  31983. b.x1 = box.top;
  31984. b.y1 = width - e.right;
  31985. b.x2 = box.bottom;
  31986. b.y2 = width - e.left;
  31987. b.index = i;
  31988. b.x1New = undefined;
  31989. b.x2New = undefined;
  31990. });
  31991. expandBoundsLTR(height, bounds);
  31992. bounds.forEach(function (b) {
  31993. var i = b.index;
  31994. expanded[i].top = b.x1New;
  31995. expanded[i].bottom = b.x2New;
  31996. });
  31997. return expanded;
  31998. }
  31999. function expandBoundsLTR(width, bounds) {
  32000. bounds.sort(function (a, b) {
  32001. return a.x1 - b.x1 || a.index - b.index;
  32002. });
  32003. var fakeBoundary = {
  32004. x1: -Infinity,
  32005. y1: -Infinity,
  32006. x2: 0,
  32007. y2: Infinity,
  32008. index: -1,
  32009. x1New: 0,
  32010. x2New: 0
  32011. };
  32012. var horizon = [{
  32013. start: -Infinity,
  32014. end: Infinity,
  32015. boundary: fakeBoundary
  32016. }];
  32017. bounds.forEach(function (boundary) {
  32018. var i = 0;
  32019. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32020. i++;
  32021. }
  32022. var j = horizon.length - 1;
  32023. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32024. j--;
  32025. }
  32026. var horizonPart, affectedBoundary;
  32027. var q, k, maxXNew = -Infinity;
  32028. for (q = i; q <= j; q++) {
  32029. horizonPart = horizon[q];
  32030. affectedBoundary = horizonPart.boundary;
  32031. var xNew;
  32032. if (affectedBoundary.x2 > boundary.x1) {
  32033. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32034. } else if (affectedBoundary.x2New === undefined) {
  32035. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32036. } else {
  32037. xNew = affectedBoundary.x2New;
  32038. }
  32039. if (xNew > maxXNew) {
  32040. maxXNew = xNew;
  32041. }
  32042. }
  32043. boundary.x1New = maxXNew;
  32044. for (q = i; q <= j; q++) {
  32045. horizonPart = horizon[q];
  32046. affectedBoundary = horizonPart.boundary;
  32047. if (affectedBoundary.x2New === undefined) {
  32048. if (affectedBoundary.x2 > boundary.x1) {
  32049. if (affectedBoundary.index > boundary.index) {
  32050. affectedBoundary.x2New = affectedBoundary.x2;
  32051. }
  32052. } else {
  32053. affectedBoundary.x2New = maxXNew;
  32054. }
  32055. } else if (affectedBoundary.x2New > maxXNew) {
  32056. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32057. }
  32058. }
  32059. var changedHorizon = [], lastBoundary = null;
  32060. for (q = i; q <= j; q++) {
  32061. horizonPart = horizon[q];
  32062. affectedBoundary = horizonPart.boundary;
  32063. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32064. if (lastBoundary === useBoundary) {
  32065. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32066. } else {
  32067. changedHorizon.push({
  32068. start: horizonPart.start,
  32069. end: horizonPart.end,
  32070. boundary: useBoundary
  32071. });
  32072. lastBoundary = useBoundary;
  32073. }
  32074. }
  32075. if (horizon[i].start < boundary.y1) {
  32076. changedHorizon[0].start = boundary.y1;
  32077. changedHorizon.unshift({
  32078. start: horizon[i].start,
  32079. end: boundary.y1,
  32080. boundary: horizon[i].boundary
  32081. });
  32082. }
  32083. if (boundary.y2 < horizon[j].end) {
  32084. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32085. changedHorizon.push({
  32086. start: boundary.y2,
  32087. end: horizon[j].end,
  32088. boundary: horizon[j].boundary
  32089. });
  32090. }
  32091. for (q = i; q <= j; q++) {
  32092. horizonPart = horizon[q];
  32093. affectedBoundary = horizonPart.boundary;
  32094. if (affectedBoundary.x2New !== undefined) {
  32095. continue;
  32096. }
  32097. var used = false;
  32098. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32099. used = horizon[k].boundary === affectedBoundary;
  32100. }
  32101. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32102. used = horizon[k].boundary === affectedBoundary;
  32103. }
  32104. for (k = 0; !used && k < changedHorizon.length; k++) {
  32105. used = changedHorizon[k].boundary === affectedBoundary;
  32106. }
  32107. if (!used) {
  32108. affectedBoundary.x2New = maxXNew;
  32109. }
  32110. }
  32111. Array.prototype.splice.apply(horizon, [
  32112. i,
  32113. j - i + 1
  32114. ].concat(changedHorizon));
  32115. });
  32116. horizon.forEach(function (horizonPart) {
  32117. var affectedBoundary = horizonPart.boundary;
  32118. if (affectedBoundary.x2New === undefined) {
  32119. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32120. }
  32121. });
  32122. }
  32123. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32124. this._textContent = textContent;
  32125. this._container = container;
  32126. this._viewport = viewport;
  32127. this._textDivs = textDivs || [];
  32128. this._textDivProperties = new WeakMap();
  32129. this._renderingDone = false;
  32130. this._canceled = false;
  32131. this._capability = createPromiseCapability();
  32132. this._renderTimer = null;
  32133. this._bounds = [];
  32134. this._enhanceTextSelection = !!enhanceTextSelection;
  32135. }
  32136. TextLayerRenderTask.prototype = {
  32137. get promise() {
  32138. return this._capability.promise;
  32139. },
  32140. cancel: function TextLayer_cancel() {
  32141. this._canceled = true;
  32142. if (this._renderTimer !== null) {
  32143. clearTimeout(this._renderTimer);
  32144. this._renderTimer = null;
  32145. }
  32146. this._capability.reject('canceled');
  32147. },
  32148. _render: function TextLayer_render(timeout) {
  32149. var textItems = this._textContent.items;
  32150. var textStyles = this._textContent.styles;
  32151. for (var i = 0, len = textItems.length; i < len; i++) {
  32152. appendText(this, textItems[i], textStyles);
  32153. }
  32154. if (!timeout) {
  32155. render(this);
  32156. } else {
  32157. var self = this;
  32158. this._renderTimer = setTimeout(function () {
  32159. render(self);
  32160. self._renderTimer = null;
  32161. }, timeout);
  32162. }
  32163. },
  32164. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32165. if (!this._enhanceTextSelection || !this._renderingDone) {
  32166. return;
  32167. }
  32168. if (this._bounds !== null) {
  32169. expand(this);
  32170. this._bounds = null;
  32171. }
  32172. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32173. var div = this._textDivs[i];
  32174. var divProperties = this._textDivProperties.get(div);
  32175. if (divProperties.isWhitespace) {
  32176. continue;
  32177. }
  32178. if (expandDivs) {
  32179. var transform = '', padding = '';
  32180. if (divProperties.scale !== 1) {
  32181. transform = 'scaleX(' + divProperties.scale + ')';
  32182. }
  32183. if (divProperties.angle !== 0) {
  32184. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32185. }
  32186. if (divProperties.paddingLeft !== 0) {
  32187. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32188. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32189. }
  32190. if (divProperties.paddingTop !== 0) {
  32191. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32192. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32193. }
  32194. if (divProperties.paddingRight !== 0) {
  32195. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32196. }
  32197. if (divProperties.paddingBottom !== 0) {
  32198. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32199. }
  32200. if (padding !== '') {
  32201. div.setAttribute('style', divProperties.style + padding);
  32202. }
  32203. if (transform !== '') {
  32204. CustomStyle.setProp('transform', div, transform);
  32205. }
  32206. } else {
  32207. div.style.padding = 0;
  32208. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32209. }
  32210. }
  32211. }
  32212. };
  32213. function renderTextLayer(renderParameters) {
  32214. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32215. task._render(renderParameters.timeout);
  32216. return task;
  32217. }
  32218. return renderTextLayer;
  32219. }();
  32220. exports.renderTextLayer = renderTextLayer;
  32221. }));
  32222. (function (root, factory) {
  32223. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32224. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32225. var shadow = sharedUtil.shadow;
  32226. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32227. var WebGLUtils = function WebGLUtilsClosure() {
  32228. function loadShader(gl, code, shaderType) {
  32229. var shader = gl.createShader(shaderType);
  32230. gl.shaderSource(shader, code);
  32231. gl.compileShader(shader);
  32232. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32233. if (!compiled) {
  32234. var errorMsg = gl.getShaderInfoLog(shader);
  32235. throw new Error('Error during shader compilation: ' + errorMsg);
  32236. }
  32237. return shader;
  32238. }
  32239. function createVertexShader(gl, code) {
  32240. return loadShader(gl, code, gl.VERTEX_SHADER);
  32241. }
  32242. function createFragmentShader(gl, code) {
  32243. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32244. }
  32245. function createProgram(gl, shaders) {
  32246. var program = gl.createProgram();
  32247. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32248. gl.attachShader(program, shaders[i]);
  32249. }
  32250. gl.linkProgram(program);
  32251. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32252. if (!linked) {
  32253. var errorMsg = gl.getProgramInfoLog(program);
  32254. throw new Error('Error during program linking: ' + errorMsg);
  32255. }
  32256. return program;
  32257. }
  32258. function createTexture(gl, image, textureId) {
  32259. gl.activeTexture(textureId);
  32260. var texture = gl.createTexture();
  32261. gl.bindTexture(gl.TEXTURE_2D, texture);
  32262. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32263. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32264. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32265. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32266. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32267. return texture;
  32268. }
  32269. var currentGL, currentCanvas;
  32270. function generateGL() {
  32271. if (currentGL) {
  32272. return;
  32273. }
  32274. currentCanvas = document.createElement('canvas');
  32275. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32276. }
  32277. var smaskVertexShaderCode = '\
  32278. attribute vec2 a_position; \
  32279. attribute vec2 a_texCoord; \
  32280. \
  32281. uniform vec2 u_resolution; \
  32282. \
  32283. varying vec2 v_texCoord; \
  32284. \
  32285. void main() { \
  32286. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32287. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32288. \
  32289. v_texCoord = a_texCoord; \
  32290. } ';
  32291. var smaskFragmentShaderCode = '\
  32292. precision mediump float; \
  32293. \
  32294. uniform vec4 u_backdrop; \
  32295. uniform int u_subtype; \
  32296. uniform sampler2D u_image; \
  32297. uniform sampler2D u_mask; \
  32298. \
  32299. varying vec2 v_texCoord; \
  32300. \
  32301. void main() { \
  32302. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32303. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32304. if (u_backdrop.a > 0.0) { \
  32305. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32306. u_backdrop.rgb * (1.0 - maskColor.a); \
  32307. } \
  32308. float lum; \
  32309. if (u_subtype == 0) { \
  32310. lum = maskColor.a; \
  32311. } else { \
  32312. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32313. maskColor.b * 0.11; \
  32314. } \
  32315. imageColor.a *= lum; \
  32316. imageColor.rgb *= imageColor.a; \
  32317. gl_FragColor = imageColor; \
  32318. } ';
  32319. var smaskCache = null;
  32320. function initSmaskGL() {
  32321. var canvas, gl;
  32322. generateGL();
  32323. canvas = currentCanvas;
  32324. currentCanvas = null;
  32325. gl = currentGL;
  32326. currentGL = null;
  32327. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32328. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32329. var program = createProgram(gl, [
  32330. vertexShader,
  32331. fragmentShader
  32332. ]);
  32333. gl.useProgram(program);
  32334. var cache = {};
  32335. cache.gl = gl;
  32336. cache.canvas = canvas;
  32337. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32338. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32339. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32340. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32341. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32342. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32343. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32344. var texCoordBuffer = gl.createBuffer();
  32345. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32346. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32347. 0.0,
  32348. 0.0,
  32349. 1.0,
  32350. 0.0,
  32351. 0.0,
  32352. 1.0,
  32353. 0.0,
  32354. 1.0,
  32355. 1.0,
  32356. 0.0,
  32357. 1.0,
  32358. 1.0
  32359. ]), gl.STATIC_DRAW);
  32360. gl.enableVertexAttribArray(texCoordLocation);
  32361. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32362. gl.uniform1i(texLayerLocation, 0);
  32363. gl.uniform1i(texMaskLocation, 1);
  32364. smaskCache = cache;
  32365. }
  32366. function composeSMask(layer, mask, properties) {
  32367. var width = layer.width, height = layer.height;
  32368. if (!smaskCache) {
  32369. initSmaskGL();
  32370. }
  32371. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32372. canvas.width = width;
  32373. canvas.height = height;
  32374. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32375. gl.uniform2f(cache.resolutionLocation, width, height);
  32376. if (properties.backdrop) {
  32377. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32378. } else {
  32379. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32380. }
  32381. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32382. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32383. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32384. var buffer = gl.createBuffer();
  32385. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32386. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32387. 0,
  32388. 0,
  32389. width,
  32390. 0,
  32391. 0,
  32392. height,
  32393. 0,
  32394. height,
  32395. width,
  32396. 0,
  32397. width,
  32398. height
  32399. ]), gl.STATIC_DRAW);
  32400. gl.enableVertexAttribArray(cache.positionLocation);
  32401. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32402. gl.clearColor(0, 0, 0, 0);
  32403. gl.enable(gl.BLEND);
  32404. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32405. gl.clear(gl.COLOR_BUFFER_BIT);
  32406. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32407. gl.flush();
  32408. gl.deleteTexture(texture);
  32409. gl.deleteTexture(maskTexture);
  32410. gl.deleteBuffer(buffer);
  32411. return canvas;
  32412. }
  32413. var figuresVertexShaderCode = '\
  32414. attribute vec2 a_position; \
  32415. attribute vec3 a_color; \
  32416. \
  32417. uniform vec2 u_resolution; \
  32418. uniform vec2 u_scale; \
  32419. uniform vec2 u_offset; \
  32420. \
  32421. varying vec4 v_color; \
  32422. \
  32423. void main() { \
  32424. vec2 position = (a_position + u_offset) * u_scale; \
  32425. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32426. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32427. \
  32428. v_color = vec4(a_color / 255.0, 1.0); \
  32429. } ';
  32430. var figuresFragmentShaderCode = '\
  32431. precision mediump float; \
  32432. \
  32433. varying vec4 v_color; \
  32434. \
  32435. void main() { \
  32436. gl_FragColor = v_color; \
  32437. } ';
  32438. var figuresCache = null;
  32439. function initFiguresGL() {
  32440. var canvas, gl;
  32441. generateGL();
  32442. canvas = currentCanvas;
  32443. currentCanvas = null;
  32444. gl = currentGL;
  32445. currentGL = null;
  32446. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32447. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32448. var program = createProgram(gl, [
  32449. vertexShader,
  32450. fragmentShader
  32451. ]);
  32452. gl.useProgram(program);
  32453. var cache = {};
  32454. cache.gl = gl;
  32455. cache.canvas = canvas;
  32456. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32457. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32458. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32459. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32460. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32461. figuresCache = cache;
  32462. }
  32463. function drawFigures(width, height, backgroundColor, figures, context) {
  32464. if (!figuresCache) {
  32465. initFiguresGL();
  32466. }
  32467. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32468. canvas.width = width;
  32469. canvas.height = height;
  32470. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32471. gl.uniform2f(cache.resolutionLocation, width, height);
  32472. var count = 0;
  32473. var i, ii, rows;
  32474. for (i = 0, ii = figures.length; i < ii; i++) {
  32475. switch (figures[i].type) {
  32476. case 'lattice':
  32477. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32478. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32479. break;
  32480. case 'triangles':
  32481. count += figures[i].coords.length;
  32482. break;
  32483. }
  32484. }
  32485. var coords = new Float32Array(count * 2);
  32486. var colors = new Uint8Array(count * 3);
  32487. var coordsMap = context.coords, colorsMap = context.colors;
  32488. var pIndex = 0, cIndex = 0;
  32489. for (i = 0, ii = figures.length; i < ii; i++) {
  32490. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32491. switch (figure.type) {
  32492. case 'lattice':
  32493. var cols = figure.verticesPerRow;
  32494. rows = ps.length / cols | 0;
  32495. for (var row = 1; row < rows; row++) {
  32496. var offset = row * cols + 1;
  32497. for (var col = 1; col < cols; col++, offset++) {
  32498. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32499. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32500. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32501. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32502. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32503. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32504. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32505. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32506. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32507. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32508. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32509. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32510. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32511. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32512. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32513. coords[pIndex + 6] = coords[pIndex + 2];
  32514. coords[pIndex + 7] = coords[pIndex + 3];
  32515. coords[pIndex + 8] = coords[pIndex + 4];
  32516. coords[pIndex + 9] = coords[pIndex + 5];
  32517. coords[pIndex + 10] = coordsMap[ps[offset]];
  32518. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32519. colors[cIndex + 9] = colors[cIndex + 3];
  32520. colors[cIndex + 10] = colors[cIndex + 4];
  32521. colors[cIndex + 11] = colors[cIndex + 5];
  32522. colors[cIndex + 12] = colors[cIndex + 6];
  32523. colors[cIndex + 13] = colors[cIndex + 7];
  32524. colors[cIndex + 14] = colors[cIndex + 8];
  32525. colors[cIndex + 15] = colorsMap[cs[offset]];
  32526. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32527. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32528. pIndex += 12;
  32529. cIndex += 18;
  32530. }
  32531. }
  32532. break;
  32533. case 'triangles':
  32534. for (var j = 0, jj = ps.length; j < jj; j++) {
  32535. coords[pIndex] = coordsMap[ps[j]];
  32536. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32537. colors[cIndex] = colorsMap[cs[j]];
  32538. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32539. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32540. pIndex += 2;
  32541. cIndex += 3;
  32542. }
  32543. break;
  32544. }
  32545. }
  32546. if (backgroundColor) {
  32547. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32548. } else {
  32549. gl.clearColor(0, 0, 0, 0);
  32550. }
  32551. gl.clear(gl.COLOR_BUFFER_BIT);
  32552. var coordsBuffer = gl.createBuffer();
  32553. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32554. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32555. gl.enableVertexAttribArray(cache.positionLocation);
  32556. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32557. var colorsBuffer = gl.createBuffer();
  32558. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32559. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32560. gl.enableVertexAttribArray(cache.colorLocation);
  32561. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32562. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32563. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32564. gl.drawArrays(gl.TRIANGLES, 0, count);
  32565. gl.flush();
  32566. gl.deleteBuffer(coordsBuffer);
  32567. gl.deleteBuffer(colorsBuffer);
  32568. return canvas;
  32569. }
  32570. function cleanup() {
  32571. if (smaskCache && smaskCache.canvas) {
  32572. smaskCache.canvas.width = 0;
  32573. smaskCache.canvas.height = 0;
  32574. }
  32575. if (figuresCache && figuresCache.canvas) {
  32576. figuresCache.canvas.width = 0;
  32577. figuresCache.canvas.height = 0;
  32578. }
  32579. smaskCache = null;
  32580. figuresCache = null;
  32581. }
  32582. return {
  32583. get isEnabled() {
  32584. if (getDefaultSetting('disableWebGL')) {
  32585. return false;
  32586. }
  32587. var enabled = false;
  32588. try {
  32589. generateGL();
  32590. enabled = !!currentGL;
  32591. } catch (e) {
  32592. }
  32593. return shadow(this, 'isEnabled', enabled);
  32594. },
  32595. composeSMask: composeSMask,
  32596. drawFigures: drawFigures,
  32597. clear: cleanup
  32598. };
  32599. }();
  32600. exports.WebGLUtils = WebGLUtils;
  32601. }));
  32602. (function (root, factory) {
  32603. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32604. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32605. var PasswordException = sharedUtil.PasswordException;
  32606. var PasswordResponses = sharedUtil.PasswordResponses;
  32607. var bytesToString = sharedUtil.bytesToString;
  32608. var warn = sharedUtil.warn;
  32609. var error = sharedUtil.error;
  32610. var assert = sharedUtil.assert;
  32611. var isInt = sharedUtil.isInt;
  32612. var stringToBytes = sharedUtil.stringToBytes;
  32613. var utf8StringToString = sharedUtil.utf8StringToString;
  32614. var Name = corePrimitives.Name;
  32615. var isName = corePrimitives.isName;
  32616. var isDict = corePrimitives.isDict;
  32617. var DecryptStream = coreStream.DecryptStream;
  32618. var ARCFourCipher = function ARCFourCipherClosure() {
  32619. function ARCFourCipher(key) {
  32620. this.a = 0;
  32621. this.b = 0;
  32622. var s = new Uint8Array(256);
  32623. var i, j = 0, tmp, keyLength = key.length;
  32624. for (i = 0; i < 256; ++i) {
  32625. s[i] = i;
  32626. }
  32627. for (i = 0; i < 256; ++i) {
  32628. tmp = s[i];
  32629. j = j + tmp + key[i % keyLength] & 0xFF;
  32630. s[i] = s[j];
  32631. s[j] = tmp;
  32632. }
  32633. this.s = s;
  32634. }
  32635. ARCFourCipher.prototype = {
  32636. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32637. var i, n = data.length, tmp, tmp2;
  32638. var a = this.a, b = this.b, s = this.s;
  32639. var output = new Uint8Array(n);
  32640. for (i = 0; i < n; ++i) {
  32641. a = a + 1 & 0xFF;
  32642. tmp = s[a];
  32643. b = b + tmp & 0xFF;
  32644. tmp2 = s[b];
  32645. s[a] = tmp2;
  32646. s[b] = tmp;
  32647. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32648. }
  32649. this.a = a;
  32650. this.b = b;
  32651. return output;
  32652. }
  32653. };
  32654. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32655. return ARCFourCipher;
  32656. }();
  32657. var calculateMD5 = function calculateMD5Closure() {
  32658. var r = new Uint8Array([
  32659. 7,
  32660. 12,
  32661. 17,
  32662. 22,
  32663. 7,
  32664. 12,
  32665. 17,
  32666. 22,
  32667. 7,
  32668. 12,
  32669. 17,
  32670. 22,
  32671. 7,
  32672. 12,
  32673. 17,
  32674. 22,
  32675. 5,
  32676. 9,
  32677. 14,
  32678. 20,
  32679. 5,
  32680. 9,
  32681. 14,
  32682. 20,
  32683. 5,
  32684. 9,
  32685. 14,
  32686. 20,
  32687. 5,
  32688. 9,
  32689. 14,
  32690. 20,
  32691. 4,
  32692. 11,
  32693. 16,
  32694. 23,
  32695. 4,
  32696. 11,
  32697. 16,
  32698. 23,
  32699. 4,
  32700. 11,
  32701. 16,
  32702. 23,
  32703. 4,
  32704. 11,
  32705. 16,
  32706. 23,
  32707. 6,
  32708. 10,
  32709. 15,
  32710. 21,
  32711. 6,
  32712. 10,
  32713. 15,
  32714. 21,
  32715. 6,
  32716. 10,
  32717. 15,
  32718. 21,
  32719. 6,
  32720. 10,
  32721. 15,
  32722. 21
  32723. ]);
  32724. var k = new Int32Array([
  32725. -680876936,
  32726. -389564586,
  32727. 606105819,
  32728. -1044525330,
  32729. -176418897,
  32730. 1200080426,
  32731. -1473231341,
  32732. -45705983,
  32733. 1770035416,
  32734. -1958414417,
  32735. -42063,
  32736. -1990404162,
  32737. 1804603682,
  32738. -40341101,
  32739. -1502002290,
  32740. 1236535329,
  32741. -165796510,
  32742. -1069501632,
  32743. 643717713,
  32744. -373897302,
  32745. -701558691,
  32746. 38016083,
  32747. -660478335,
  32748. -405537848,
  32749. 568446438,
  32750. -1019803690,
  32751. -187363961,
  32752. 1163531501,
  32753. -1444681467,
  32754. -51403784,
  32755. 1735328473,
  32756. -1926607734,
  32757. -378558,
  32758. -2022574463,
  32759. 1839030562,
  32760. -35309556,
  32761. -1530992060,
  32762. 1272893353,
  32763. -155497632,
  32764. -1094730640,
  32765. 681279174,
  32766. -358537222,
  32767. -722521979,
  32768. 76029189,
  32769. -640364487,
  32770. -421815835,
  32771. 530742520,
  32772. -995338651,
  32773. -198630844,
  32774. 1126891415,
  32775. -1416354905,
  32776. -57434055,
  32777. 1700485571,
  32778. -1894986606,
  32779. -1051523,
  32780. -2054922799,
  32781. 1873313359,
  32782. -30611744,
  32783. -1560198380,
  32784. 1309151649,
  32785. -145523070,
  32786. -1120210379,
  32787. 718787259,
  32788. -343485551
  32789. ]);
  32790. function hash(data, offset, length) {
  32791. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32792. var paddedLength = length + 72 & ~63;
  32793. var padded = new Uint8Array(paddedLength);
  32794. var i, j, n;
  32795. for (i = 0; i < length; ++i) {
  32796. padded[i] = data[offset++];
  32797. }
  32798. padded[i++] = 0x80;
  32799. n = paddedLength - 8;
  32800. while (i < n) {
  32801. padded[i++] = 0;
  32802. }
  32803. padded[i++] = length << 3 & 0xFF;
  32804. padded[i++] = length >> 5 & 0xFF;
  32805. padded[i++] = length >> 13 & 0xFF;
  32806. padded[i++] = length >> 21 & 0xFF;
  32807. padded[i++] = length >>> 29 & 0xFF;
  32808. padded[i++] = 0;
  32809. padded[i++] = 0;
  32810. padded[i++] = 0;
  32811. var w = new Int32Array(16);
  32812. for (i = 0; i < paddedLength;) {
  32813. for (j = 0; j < 16; ++j, i += 4) {
  32814. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32815. }
  32816. var a = h0, b = h1, c = h2, d = h3, f, g;
  32817. for (j = 0; j < 64; ++j) {
  32818. if (j < 16) {
  32819. f = b & c | ~b & d;
  32820. g = j;
  32821. } else if (j < 32) {
  32822. f = d & b | ~d & c;
  32823. g = 5 * j + 1 & 15;
  32824. } else if (j < 48) {
  32825. f = b ^ c ^ d;
  32826. g = 3 * j + 5 & 15;
  32827. } else {
  32828. f = c ^ (b | ~d);
  32829. g = 7 * j & 15;
  32830. }
  32831. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  32832. d = c;
  32833. c = b;
  32834. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  32835. a = tmp;
  32836. }
  32837. h0 = h0 + a | 0;
  32838. h1 = h1 + b | 0;
  32839. h2 = h2 + c | 0;
  32840. h3 = h3 + d | 0;
  32841. }
  32842. return new Uint8Array([
  32843. h0 & 0xFF,
  32844. h0 >> 8 & 0xFF,
  32845. h0 >> 16 & 0xFF,
  32846. h0 >>> 24 & 0xFF,
  32847. h1 & 0xFF,
  32848. h1 >> 8 & 0xFF,
  32849. h1 >> 16 & 0xFF,
  32850. h1 >>> 24 & 0xFF,
  32851. h2 & 0xFF,
  32852. h2 >> 8 & 0xFF,
  32853. h2 >> 16 & 0xFF,
  32854. h2 >>> 24 & 0xFF,
  32855. h3 & 0xFF,
  32856. h3 >> 8 & 0xFF,
  32857. h3 >> 16 & 0xFF,
  32858. h3 >>> 24 & 0xFF
  32859. ]);
  32860. }
  32861. return hash;
  32862. }();
  32863. var Word64 = function Word64Closure() {
  32864. function Word64(highInteger, lowInteger) {
  32865. this.high = highInteger | 0;
  32866. this.low = lowInteger | 0;
  32867. }
  32868. Word64.prototype = {
  32869. and: function Word64_and(word) {
  32870. this.high &= word.high;
  32871. this.low &= word.low;
  32872. },
  32873. xor: function Word64_xor(word) {
  32874. this.high ^= word.high;
  32875. this.low ^= word.low;
  32876. },
  32877. or: function Word64_or(word) {
  32878. this.high |= word.high;
  32879. this.low |= word.low;
  32880. },
  32881. shiftRight: function Word64_shiftRight(places) {
  32882. if (places >= 32) {
  32883. this.low = this.high >>> places - 32 | 0;
  32884. this.high = 0;
  32885. } else {
  32886. this.low = this.low >>> places | this.high << 32 - places;
  32887. this.high = this.high >>> places | 0;
  32888. }
  32889. },
  32890. shiftLeft: function Word64_shiftLeft(places) {
  32891. if (places >= 32) {
  32892. this.high = this.low << places - 32;
  32893. this.low = 0;
  32894. } else {
  32895. this.high = this.high << places | this.low >>> 32 - places;
  32896. this.low = this.low << places;
  32897. }
  32898. },
  32899. rotateRight: function Word64_rotateRight(places) {
  32900. var low, high;
  32901. if (places & 32) {
  32902. high = this.low;
  32903. low = this.high;
  32904. } else {
  32905. low = this.low;
  32906. high = this.high;
  32907. }
  32908. places &= 31;
  32909. this.low = low >>> places | high << 32 - places;
  32910. this.high = high >>> places | low << 32 - places;
  32911. },
  32912. not: function Word64_not() {
  32913. this.high = ~this.high;
  32914. this.low = ~this.low;
  32915. },
  32916. add: function Word64_add(word) {
  32917. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  32918. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  32919. if (lowAdd > 0xFFFFFFFF) {
  32920. highAdd += 1;
  32921. }
  32922. this.low = lowAdd | 0;
  32923. this.high = highAdd | 0;
  32924. },
  32925. copyTo: function Word64_copyTo(bytes, offset) {
  32926. bytes[offset] = this.high >>> 24 & 0xFF;
  32927. bytes[offset + 1] = this.high >> 16 & 0xFF;
  32928. bytes[offset + 2] = this.high >> 8 & 0xFF;
  32929. bytes[offset + 3] = this.high & 0xFF;
  32930. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  32931. bytes[offset + 5] = this.low >> 16 & 0xFF;
  32932. bytes[offset + 6] = this.low >> 8 & 0xFF;
  32933. bytes[offset + 7] = this.low & 0xFF;
  32934. },
  32935. assign: function Word64_assign(word) {
  32936. this.high = word.high;
  32937. this.low = word.low;
  32938. }
  32939. };
  32940. return Word64;
  32941. }();
  32942. var calculateSHA256 = function calculateSHA256Closure() {
  32943. function rotr(x, n) {
  32944. return x >>> n | x << 32 - n;
  32945. }
  32946. function ch(x, y, z) {
  32947. return x & y ^ ~x & z;
  32948. }
  32949. function maj(x, y, z) {
  32950. return x & y ^ x & z ^ y & z;
  32951. }
  32952. function sigma(x) {
  32953. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  32954. }
  32955. function sigmaPrime(x) {
  32956. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  32957. }
  32958. function littleSigma(x) {
  32959. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  32960. }
  32961. function littleSigmaPrime(x) {
  32962. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  32963. }
  32964. var k = [
  32965. 0x428a2f98,
  32966. 0x71374491,
  32967. 0xb5c0fbcf,
  32968. 0xe9b5dba5,
  32969. 0x3956c25b,
  32970. 0x59f111f1,
  32971. 0x923f82a4,
  32972. 0xab1c5ed5,
  32973. 0xd807aa98,
  32974. 0x12835b01,
  32975. 0x243185be,
  32976. 0x550c7dc3,
  32977. 0x72be5d74,
  32978. 0x80deb1fe,
  32979. 0x9bdc06a7,
  32980. 0xc19bf174,
  32981. 0xe49b69c1,
  32982. 0xefbe4786,
  32983. 0x0fc19dc6,
  32984. 0x240ca1cc,
  32985. 0x2de92c6f,
  32986. 0x4a7484aa,
  32987. 0x5cb0a9dc,
  32988. 0x76f988da,
  32989. 0x983e5152,
  32990. 0xa831c66d,
  32991. 0xb00327c8,
  32992. 0xbf597fc7,
  32993. 0xc6e00bf3,
  32994. 0xd5a79147,
  32995. 0x06ca6351,
  32996. 0x14292967,
  32997. 0x27b70a85,
  32998. 0x2e1b2138,
  32999. 0x4d2c6dfc,
  33000. 0x53380d13,
  33001. 0x650a7354,
  33002. 0x766a0abb,
  33003. 0x81c2c92e,
  33004. 0x92722c85,
  33005. 0xa2bfe8a1,
  33006. 0xa81a664b,
  33007. 0xc24b8b70,
  33008. 0xc76c51a3,
  33009. 0xd192e819,
  33010. 0xd6990624,
  33011. 0xf40e3585,
  33012. 0x106aa070,
  33013. 0x19a4c116,
  33014. 0x1e376c08,
  33015. 0x2748774c,
  33016. 0x34b0bcb5,
  33017. 0x391c0cb3,
  33018. 0x4ed8aa4a,
  33019. 0x5b9cca4f,
  33020. 0x682e6ff3,
  33021. 0x748f82ee,
  33022. 0x78a5636f,
  33023. 0x84c87814,
  33024. 0x8cc70208,
  33025. 0x90befffa,
  33026. 0xa4506ceb,
  33027. 0xbef9a3f7,
  33028. 0xc67178f2
  33029. ];
  33030. function hash(data, offset, length) {
  33031. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33032. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33033. var padded = new Uint8Array(paddedLength);
  33034. var i, j, n;
  33035. for (i = 0; i < length; ++i) {
  33036. padded[i] = data[offset++];
  33037. }
  33038. padded[i++] = 0x80;
  33039. n = paddedLength - 8;
  33040. while (i < n) {
  33041. padded[i++] = 0;
  33042. }
  33043. padded[i++] = 0;
  33044. padded[i++] = 0;
  33045. padded[i++] = 0;
  33046. padded[i++] = length >>> 29 & 0xFF;
  33047. padded[i++] = length >> 21 & 0xFF;
  33048. padded[i++] = length >> 13 & 0xFF;
  33049. padded[i++] = length >> 5 & 0xFF;
  33050. padded[i++] = length << 3 & 0xFF;
  33051. var w = new Uint32Array(64);
  33052. for (i = 0; i < paddedLength;) {
  33053. for (j = 0; j < 16; ++j) {
  33054. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33055. i += 4;
  33056. }
  33057. for (j = 16; j < 64; ++j) {
  33058. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33059. }
  33060. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33061. for (j = 0; j < 64; ++j) {
  33062. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33063. t2 = sigma(a) + maj(a, b, c);
  33064. h = g;
  33065. g = f;
  33066. f = e;
  33067. e = d + t1 | 0;
  33068. d = c;
  33069. c = b;
  33070. b = a;
  33071. a = t1 + t2 | 0;
  33072. }
  33073. h0 = h0 + a | 0;
  33074. h1 = h1 + b | 0;
  33075. h2 = h2 + c | 0;
  33076. h3 = h3 + d | 0;
  33077. h4 = h4 + e | 0;
  33078. h5 = h5 + f | 0;
  33079. h6 = h6 + g | 0;
  33080. h7 = h7 + h | 0;
  33081. }
  33082. return new Uint8Array([
  33083. h0 >> 24 & 0xFF,
  33084. h0 >> 16 & 0xFF,
  33085. h0 >> 8 & 0xFF,
  33086. h0 & 0xFF,
  33087. h1 >> 24 & 0xFF,
  33088. h1 >> 16 & 0xFF,
  33089. h1 >> 8 & 0xFF,
  33090. h1 & 0xFF,
  33091. h2 >> 24 & 0xFF,
  33092. h2 >> 16 & 0xFF,
  33093. h2 >> 8 & 0xFF,
  33094. h2 & 0xFF,
  33095. h3 >> 24 & 0xFF,
  33096. h3 >> 16 & 0xFF,
  33097. h3 >> 8 & 0xFF,
  33098. h3 & 0xFF,
  33099. h4 >> 24 & 0xFF,
  33100. h4 >> 16 & 0xFF,
  33101. h4 >> 8 & 0xFF,
  33102. h4 & 0xFF,
  33103. h5 >> 24 & 0xFF,
  33104. h5 >> 16 & 0xFF,
  33105. h5 >> 8 & 0xFF,
  33106. h5 & 0xFF,
  33107. h6 >> 24 & 0xFF,
  33108. h6 >> 16 & 0xFF,
  33109. h6 >> 8 & 0xFF,
  33110. h6 & 0xFF,
  33111. h7 >> 24 & 0xFF,
  33112. h7 >> 16 & 0xFF,
  33113. h7 >> 8 & 0xFF,
  33114. h7 & 0xFF
  33115. ]);
  33116. }
  33117. return hash;
  33118. }();
  33119. var calculateSHA512 = function calculateSHA512Closure() {
  33120. function ch(result, x, y, z, tmp) {
  33121. result.assign(x);
  33122. result.and(y);
  33123. tmp.assign(x);
  33124. tmp.not();
  33125. tmp.and(z);
  33126. result.xor(tmp);
  33127. }
  33128. function maj(result, x, y, z, tmp) {
  33129. result.assign(x);
  33130. result.and(y);
  33131. tmp.assign(x);
  33132. tmp.and(z);
  33133. result.xor(tmp);
  33134. tmp.assign(y);
  33135. tmp.and(z);
  33136. result.xor(tmp);
  33137. }
  33138. function sigma(result, x, tmp) {
  33139. result.assign(x);
  33140. result.rotateRight(28);
  33141. tmp.assign(x);
  33142. tmp.rotateRight(34);
  33143. result.xor(tmp);
  33144. tmp.assign(x);
  33145. tmp.rotateRight(39);
  33146. result.xor(tmp);
  33147. }
  33148. function sigmaPrime(result, x, tmp) {
  33149. result.assign(x);
  33150. result.rotateRight(14);
  33151. tmp.assign(x);
  33152. tmp.rotateRight(18);
  33153. result.xor(tmp);
  33154. tmp.assign(x);
  33155. tmp.rotateRight(41);
  33156. result.xor(tmp);
  33157. }
  33158. function littleSigma(result, x, tmp) {
  33159. result.assign(x);
  33160. result.rotateRight(1);
  33161. tmp.assign(x);
  33162. tmp.rotateRight(8);
  33163. result.xor(tmp);
  33164. tmp.assign(x);
  33165. tmp.shiftRight(7);
  33166. result.xor(tmp);
  33167. }
  33168. function littleSigmaPrime(result, x, tmp) {
  33169. result.assign(x);
  33170. result.rotateRight(19);
  33171. tmp.assign(x);
  33172. tmp.rotateRight(61);
  33173. result.xor(tmp);
  33174. tmp.assign(x);
  33175. tmp.shiftRight(6);
  33176. result.xor(tmp);
  33177. }
  33178. var k = [
  33179. new Word64(0x428a2f98, 0xd728ae22),
  33180. new Word64(0x71374491, 0x23ef65cd),
  33181. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33182. new Word64(0xe9b5dba5, 0x8189dbbc),
  33183. new Word64(0x3956c25b, 0xf348b538),
  33184. new Word64(0x59f111f1, 0xb605d019),
  33185. new Word64(0x923f82a4, 0xaf194f9b),
  33186. new Word64(0xab1c5ed5, 0xda6d8118),
  33187. new Word64(0xd807aa98, 0xa3030242),
  33188. new Word64(0x12835b01, 0x45706fbe),
  33189. new Word64(0x243185be, 0x4ee4b28c),
  33190. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33191. new Word64(0x72be5d74, 0xf27b896f),
  33192. new Word64(0x80deb1fe, 0x3b1696b1),
  33193. new Word64(0x9bdc06a7, 0x25c71235),
  33194. new Word64(0xc19bf174, 0xcf692694),
  33195. new Word64(0xe49b69c1, 0x9ef14ad2),
  33196. new Word64(0xefbe4786, 0x384f25e3),
  33197. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33198. new Word64(0x240ca1cc, 0x77ac9c65),
  33199. new Word64(0x2de92c6f, 0x592b0275),
  33200. new Word64(0x4a7484aa, 0x6ea6e483),
  33201. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33202. new Word64(0x76f988da, 0x831153b5),
  33203. new Word64(0x983e5152, 0xee66dfab),
  33204. new Word64(0xa831c66d, 0x2db43210),
  33205. new Word64(0xb00327c8, 0x98fb213f),
  33206. new Word64(0xbf597fc7, 0xbeef0ee4),
  33207. new Word64(0xc6e00bf3, 0x3da88fc2),
  33208. new Word64(0xd5a79147, 0x930aa725),
  33209. new Word64(0x06ca6351, 0xe003826f),
  33210. new Word64(0x14292967, 0x0a0e6e70),
  33211. new Word64(0x27b70a85, 0x46d22ffc),
  33212. new Word64(0x2e1b2138, 0x5c26c926),
  33213. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33214. new Word64(0x53380d13, 0x9d95b3df),
  33215. new Word64(0x650a7354, 0x8baf63de),
  33216. new Word64(0x766a0abb, 0x3c77b2a8),
  33217. new Word64(0x81c2c92e, 0x47edaee6),
  33218. new Word64(0x92722c85, 0x1482353b),
  33219. new Word64(0xa2bfe8a1, 0x4cf10364),
  33220. new Word64(0xa81a664b, 0xbc423001),
  33221. new Word64(0xc24b8b70, 0xd0f89791),
  33222. new Word64(0xc76c51a3, 0x0654be30),
  33223. new Word64(0xd192e819, 0xd6ef5218),
  33224. new Word64(0xd6990624, 0x5565a910),
  33225. new Word64(0xf40e3585, 0x5771202a),
  33226. new Word64(0x106aa070, 0x32bbd1b8),
  33227. new Word64(0x19a4c116, 0xb8d2d0c8),
  33228. new Word64(0x1e376c08, 0x5141ab53),
  33229. new Word64(0x2748774c, 0xdf8eeb99),
  33230. new Word64(0x34b0bcb5, 0xe19b48a8),
  33231. new Word64(0x391c0cb3, 0xc5c95a63),
  33232. new Word64(0x4ed8aa4a, 0xe3418acb),
  33233. new Word64(0x5b9cca4f, 0x7763e373),
  33234. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33235. new Word64(0x748f82ee, 0x5defb2fc),
  33236. new Word64(0x78a5636f, 0x43172f60),
  33237. new Word64(0x84c87814, 0xa1f0ab72),
  33238. new Word64(0x8cc70208, 0x1a6439ec),
  33239. new Word64(0x90befffa, 0x23631e28),
  33240. new Word64(0xa4506ceb, 0xde82bde9),
  33241. new Word64(0xbef9a3f7, 0xb2c67915),
  33242. new Word64(0xc67178f2, 0xe372532b),
  33243. new Word64(0xca273ece, 0xea26619c),
  33244. new Word64(0xd186b8c7, 0x21c0c207),
  33245. new Word64(0xeada7dd6, 0xcde0eb1e),
  33246. new Word64(0xf57d4f7f, 0xee6ed178),
  33247. new Word64(0x06f067aa, 0x72176fba),
  33248. new Word64(0x0a637dc5, 0xa2c898a6),
  33249. new Word64(0x113f9804, 0xbef90dae),
  33250. new Word64(0x1b710b35, 0x131c471b),
  33251. new Word64(0x28db77f5, 0x23047d84),
  33252. new Word64(0x32caab7b, 0x40c72493),
  33253. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33254. new Word64(0x431d67c4, 0x9c100d4c),
  33255. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33256. new Word64(0x597f299c, 0xfc657e2a),
  33257. new Word64(0x5fcb6fab, 0x3ad6faec),
  33258. new Word64(0x6c44198c, 0x4a475817)
  33259. ];
  33260. function hash(data, offset, length, mode384) {
  33261. mode384 = !!mode384;
  33262. var h0, h1, h2, h3, h4, h5, h6, h7;
  33263. if (!mode384) {
  33264. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33265. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33266. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33267. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33268. h4 = new Word64(0x510e527f, 0xade682d1);
  33269. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33270. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33271. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33272. } else {
  33273. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33274. h1 = new Word64(0x629a292a, 0x367cd507);
  33275. h2 = new Word64(0x9159015a, 0x3070dd17);
  33276. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33277. h4 = new Word64(0x67332667, 0xffc00b31);
  33278. h5 = new Word64(0x8eb44a87, 0x68581511);
  33279. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33280. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33281. }
  33282. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33283. var padded = new Uint8Array(paddedLength);
  33284. var i, j, n;
  33285. for (i = 0; i < length; ++i) {
  33286. padded[i] = data[offset++];
  33287. }
  33288. padded[i++] = 0x80;
  33289. n = paddedLength - 16;
  33290. while (i < n) {
  33291. padded[i++] = 0;
  33292. }
  33293. padded[i++] = 0;
  33294. padded[i++] = 0;
  33295. padded[i++] = 0;
  33296. padded[i++] = 0;
  33297. padded[i++] = 0;
  33298. padded[i++] = 0;
  33299. padded[i++] = 0;
  33300. padded[i++] = 0;
  33301. padded[i++] = 0;
  33302. padded[i++] = 0;
  33303. padded[i++] = 0;
  33304. padded[i++] = length >>> 29 & 0xFF;
  33305. padded[i++] = length >> 21 & 0xFF;
  33306. padded[i++] = length >> 13 & 0xFF;
  33307. padded[i++] = length >> 5 & 0xFF;
  33308. padded[i++] = length << 3 & 0xFF;
  33309. var w = new Array(80);
  33310. for (i = 0; i < 80; i++) {
  33311. w[i] = new Word64(0, 0);
  33312. }
  33313. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33314. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33315. var g = new Word64(0, 0), h = new Word64(0, 0);
  33316. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33317. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33318. for (i = 0; i < paddedLength;) {
  33319. for (j = 0; j < 16; ++j) {
  33320. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33321. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33322. i += 8;
  33323. }
  33324. for (j = 16; j < 80; ++j) {
  33325. tmp3 = w[j];
  33326. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33327. tmp3.add(w[j - 7]);
  33328. littleSigma(tmp1, w[j - 15], tmp2);
  33329. tmp3.add(tmp1);
  33330. tmp3.add(w[j - 16]);
  33331. }
  33332. a.assign(h0);
  33333. b.assign(h1);
  33334. c.assign(h2);
  33335. d.assign(h3);
  33336. e.assign(h4);
  33337. f.assign(h5);
  33338. g.assign(h6);
  33339. h.assign(h7);
  33340. for (j = 0; j < 80; ++j) {
  33341. t1.assign(h);
  33342. sigmaPrime(tmp1, e, tmp2);
  33343. t1.add(tmp1);
  33344. ch(tmp1, e, f, g, tmp2);
  33345. t1.add(tmp1);
  33346. t1.add(k[j]);
  33347. t1.add(w[j]);
  33348. sigma(t2, a, tmp2);
  33349. maj(tmp1, a, b, c, tmp2);
  33350. t2.add(tmp1);
  33351. tmp3 = h;
  33352. h = g;
  33353. g = f;
  33354. f = e;
  33355. d.add(t1);
  33356. e = d;
  33357. d = c;
  33358. c = b;
  33359. b = a;
  33360. tmp3.assign(t1);
  33361. tmp3.add(t2);
  33362. a = tmp3;
  33363. }
  33364. h0.add(a);
  33365. h1.add(b);
  33366. h2.add(c);
  33367. h3.add(d);
  33368. h4.add(e);
  33369. h5.add(f);
  33370. h6.add(g);
  33371. h7.add(h);
  33372. }
  33373. var result;
  33374. if (!mode384) {
  33375. result = new Uint8Array(64);
  33376. h0.copyTo(result, 0);
  33377. h1.copyTo(result, 8);
  33378. h2.copyTo(result, 16);
  33379. h3.copyTo(result, 24);
  33380. h4.copyTo(result, 32);
  33381. h5.copyTo(result, 40);
  33382. h6.copyTo(result, 48);
  33383. h7.copyTo(result, 56);
  33384. } else {
  33385. result = new Uint8Array(48);
  33386. h0.copyTo(result, 0);
  33387. h1.copyTo(result, 8);
  33388. h2.copyTo(result, 16);
  33389. h3.copyTo(result, 24);
  33390. h4.copyTo(result, 32);
  33391. h5.copyTo(result, 40);
  33392. }
  33393. return result;
  33394. }
  33395. return hash;
  33396. }();
  33397. var calculateSHA384 = function calculateSHA384Closure() {
  33398. function hash(data, offset, length) {
  33399. return calculateSHA512(data, offset, length, true);
  33400. }
  33401. return hash;
  33402. }();
  33403. var NullCipher = function NullCipherClosure() {
  33404. function NullCipher() {
  33405. }
  33406. NullCipher.prototype = {
  33407. decryptBlock: function NullCipher_decryptBlock(data) {
  33408. return data;
  33409. }
  33410. };
  33411. return NullCipher;
  33412. }();
  33413. var AES128Cipher = function AES128CipherClosure() {
  33414. var rcon = new Uint8Array([
  33415. 0x8d,
  33416. 0x01,
  33417. 0x02,
  33418. 0x04,
  33419. 0x08,
  33420. 0x10,
  33421. 0x20,
  33422. 0x40,
  33423. 0x80,
  33424. 0x1b,
  33425. 0x36,
  33426. 0x6c,
  33427. 0xd8,
  33428. 0xab,
  33429. 0x4d,
  33430. 0x9a,
  33431. 0x2f,
  33432. 0x5e,
  33433. 0xbc,
  33434. 0x63,
  33435. 0xc6,
  33436. 0x97,
  33437. 0x35,
  33438. 0x6a,
  33439. 0xd4,
  33440. 0xb3,
  33441. 0x7d,
  33442. 0xfa,
  33443. 0xef,
  33444. 0xc5,
  33445. 0x91,
  33446. 0x39,
  33447. 0x72,
  33448. 0xe4,
  33449. 0xd3,
  33450. 0xbd,
  33451. 0x61,
  33452. 0xc2,
  33453. 0x9f,
  33454. 0x25,
  33455. 0x4a,
  33456. 0x94,
  33457. 0x33,
  33458. 0x66,
  33459. 0xcc,
  33460. 0x83,
  33461. 0x1d,
  33462. 0x3a,
  33463. 0x74,
  33464. 0xe8,
  33465. 0xcb,
  33466. 0x8d,
  33467. 0x01,
  33468. 0x02,
  33469. 0x04,
  33470. 0x08,
  33471. 0x10,
  33472. 0x20,
  33473. 0x40,
  33474. 0x80,
  33475. 0x1b,
  33476. 0x36,
  33477. 0x6c,
  33478. 0xd8,
  33479. 0xab,
  33480. 0x4d,
  33481. 0x9a,
  33482. 0x2f,
  33483. 0x5e,
  33484. 0xbc,
  33485. 0x63,
  33486. 0xc6,
  33487. 0x97,
  33488. 0x35,
  33489. 0x6a,
  33490. 0xd4,
  33491. 0xb3,
  33492. 0x7d,
  33493. 0xfa,
  33494. 0xef,
  33495. 0xc5,
  33496. 0x91,
  33497. 0x39,
  33498. 0x72,
  33499. 0xe4,
  33500. 0xd3,
  33501. 0xbd,
  33502. 0x61,
  33503. 0xc2,
  33504. 0x9f,
  33505. 0x25,
  33506. 0x4a,
  33507. 0x94,
  33508. 0x33,
  33509. 0x66,
  33510. 0xcc,
  33511. 0x83,
  33512. 0x1d,
  33513. 0x3a,
  33514. 0x74,
  33515. 0xe8,
  33516. 0xcb,
  33517. 0x8d,
  33518. 0x01,
  33519. 0x02,
  33520. 0x04,
  33521. 0x08,
  33522. 0x10,
  33523. 0x20,
  33524. 0x40,
  33525. 0x80,
  33526. 0x1b,
  33527. 0x36,
  33528. 0x6c,
  33529. 0xd8,
  33530. 0xab,
  33531. 0x4d,
  33532. 0x9a,
  33533. 0x2f,
  33534. 0x5e,
  33535. 0xbc,
  33536. 0x63,
  33537. 0xc6,
  33538. 0x97,
  33539. 0x35,
  33540. 0x6a,
  33541. 0xd4,
  33542. 0xb3,
  33543. 0x7d,
  33544. 0xfa,
  33545. 0xef,
  33546. 0xc5,
  33547. 0x91,
  33548. 0x39,
  33549. 0x72,
  33550. 0xe4,
  33551. 0xd3,
  33552. 0xbd,
  33553. 0x61,
  33554. 0xc2,
  33555. 0x9f,
  33556. 0x25,
  33557. 0x4a,
  33558. 0x94,
  33559. 0x33,
  33560. 0x66,
  33561. 0xcc,
  33562. 0x83,
  33563. 0x1d,
  33564. 0x3a,
  33565. 0x74,
  33566. 0xe8,
  33567. 0xcb,
  33568. 0x8d,
  33569. 0x01,
  33570. 0x02,
  33571. 0x04,
  33572. 0x08,
  33573. 0x10,
  33574. 0x20,
  33575. 0x40,
  33576. 0x80,
  33577. 0x1b,
  33578. 0x36,
  33579. 0x6c,
  33580. 0xd8,
  33581. 0xab,
  33582. 0x4d,
  33583. 0x9a,
  33584. 0x2f,
  33585. 0x5e,
  33586. 0xbc,
  33587. 0x63,
  33588. 0xc6,
  33589. 0x97,
  33590. 0x35,
  33591. 0x6a,
  33592. 0xd4,
  33593. 0xb3,
  33594. 0x7d,
  33595. 0xfa,
  33596. 0xef,
  33597. 0xc5,
  33598. 0x91,
  33599. 0x39,
  33600. 0x72,
  33601. 0xe4,
  33602. 0xd3,
  33603. 0xbd,
  33604. 0x61,
  33605. 0xc2,
  33606. 0x9f,
  33607. 0x25,
  33608. 0x4a,
  33609. 0x94,
  33610. 0x33,
  33611. 0x66,
  33612. 0xcc,
  33613. 0x83,
  33614. 0x1d,
  33615. 0x3a,
  33616. 0x74,
  33617. 0xe8,
  33618. 0xcb,
  33619. 0x8d,
  33620. 0x01,
  33621. 0x02,
  33622. 0x04,
  33623. 0x08,
  33624. 0x10,
  33625. 0x20,
  33626. 0x40,
  33627. 0x80,
  33628. 0x1b,
  33629. 0x36,
  33630. 0x6c,
  33631. 0xd8,
  33632. 0xab,
  33633. 0x4d,
  33634. 0x9a,
  33635. 0x2f,
  33636. 0x5e,
  33637. 0xbc,
  33638. 0x63,
  33639. 0xc6,
  33640. 0x97,
  33641. 0x35,
  33642. 0x6a,
  33643. 0xd4,
  33644. 0xb3,
  33645. 0x7d,
  33646. 0xfa,
  33647. 0xef,
  33648. 0xc5,
  33649. 0x91,
  33650. 0x39,
  33651. 0x72,
  33652. 0xe4,
  33653. 0xd3,
  33654. 0xbd,
  33655. 0x61,
  33656. 0xc2,
  33657. 0x9f,
  33658. 0x25,
  33659. 0x4a,
  33660. 0x94,
  33661. 0x33,
  33662. 0x66,
  33663. 0xcc,
  33664. 0x83,
  33665. 0x1d,
  33666. 0x3a,
  33667. 0x74,
  33668. 0xe8,
  33669. 0xcb,
  33670. 0x8d
  33671. ]);
  33672. var s = new Uint8Array([
  33673. 0x63,
  33674. 0x7c,
  33675. 0x77,
  33676. 0x7b,
  33677. 0xf2,
  33678. 0x6b,
  33679. 0x6f,
  33680. 0xc5,
  33681. 0x30,
  33682. 0x01,
  33683. 0x67,
  33684. 0x2b,
  33685. 0xfe,
  33686. 0xd7,
  33687. 0xab,
  33688. 0x76,
  33689. 0xca,
  33690. 0x82,
  33691. 0xc9,
  33692. 0x7d,
  33693. 0xfa,
  33694. 0x59,
  33695. 0x47,
  33696. 0xf0,
  33697. 0xad,
  33698. 0xd4,
  33699. 0xa2,
  33700. 0xaf,
  33701. 0x9c,
  33702. 0xa4,
  33703. 0x72,
  33704. 0xc0,
  33705. 0xb7,
  33706. 0xfd,
  33707. 0x93,
  33708. 0x26,
  33709. 0x36,
  33710. 0x3f,
  33711. 0xf7,
  33712. 0xcc,
  33713. 0x34,
  33714. 0xa5,
  33715. 0xe5,
  33716. 0xf1,
  33717. 0x71,
  33718. 0xd8,
  33719. 0x31,
  33720. 0x15,
  33721. 0x04,
  33722. 0xc7,
  33723. 0x23,
  33724. 0xc3,
  33725. 0x18,
  33726. 0x96,
  33727. 0x05,
  33728. 0x9a,
  33729. 0x07,
  33730. 0x12,
  33731. 0x80,
  33732. 0xe2,
  33733. 0xeb,
  33734. 0x27,
  33735. 0xb2,
  33736. 0x75,
  33737. 0x09,
  33738. 0x83,
  33739. 0x2c,
  33740. 0x1a,
  33741. 0x1b,
  33742. 0x6e,
  33743. 0x5a,
  33744. 0xa0,
  33745. 0x52,
  33746. 0x3b,
  33747. 0xd6,
  33748. 0xb3,
  33749. 0x29,
  33750. 0xe3,
  33751. 0x2f,
  33752. 0x84,
  33753. 0x53,
  33754. 0xd1,
  33755. 0x00,
  33756. 0xed,
  33757. 0x20,
  33758. 0xfc,
  33759. 0xb1,
  33760. 0x5b,
  33761. 0x6a,
  33762. 0xcb,
  33763. 0xbe,
  33764. 0x39,
  33765. 0x4a,
  33766. 0x4c,
  33767. 0x58,
  33768. 0xcf,
  33769. 0xd0,
  33770. 0xef,
  33771. 0xaa,
  33772. 0xfb,
  33773. 0x43,
  33774. 0x4d,
  33775. 0x33,
  33776. 0x85,
  33777. 0x45,
  33778. 0xf9,
  33779. 0x02,
  33780. 0x7f,
  33781. 0x50,
  33782. 0x3c,
  33783. 0x9f,
  33784. 0xa8,
  33785. 0x51,
  33786. 0xa3,
  33787. 0x40,
  33788. 0x8f,
  33789. 0x92,
  33790. 0x9d,
  33791. 0x38,
  33792. 0xf5,
  33793. 0xbc,
  33794. 0xb6,
  33795. 0xda,
  33796. 0x21,
  33797. 0x10,
  33798. 0xff,
  33799. 0xf3,
  33800. 0xd2,
  33801. 0xcd,
  33802. 0x0c,
  33803. 0x13,
  33804. 0xec,
  33805. 0x5f,
  33806. 0x97,
  33807. 0x44,
  33808. 0x17,
  33809. 0xc4,
  33810. 0xa7,
  33811. 0x7e,
  33812. 0x3d,
  33813. 0x64,
  33814. 0x5d,
  33815. 0x19,
  33816. 0x73,
  33817. 0x60,
  33818. 0x81,
  33819. 0x4f,
  33820. 0xdc,
  33821. 0x22,
  33822. 0x2a,
  33823. 0x90,
  33824. 0x88,
  33825. 0x46,
  33826. 0xee,
  33827. 0xb8,
  33828. 0x14,
  33829. 0xde,
  33830. 0x5e,
  33831. 0x0b,
  33832. 0xdb,
  33833. 0xe0,
  33834. 0x32,
  33835. 0x3a,
  33836. 0x0a,
  33837. 0x49,
  33838. 0x06,
  33839. 0x24,
  33840. 0x5c,
  33841. 0xc2,
  33842. 0xd3,
  33843. 0xac,
  33844. 0x62,
  33845. 0x91,
  33846. 0x95,
  33847. 0xe4,
  33848. 0x79,
  33849. 0xe7,
  33850. 0xc8,
  33851. 0x37,
  33852. 0x6d,
  33853. 0x8d,
  33854. 0xd5,
  33855. 0x4e,
  33856. 0xa9,
  33857. 0x6c,
  33858. 0x56,
  33859. 0xf4,
  33860. 0xea,
  33861. 0x65,
  33862. 0x7a,
  33863. 0xae,
  33864. 0x08,
  33865. 0xba,
  33866. 0x78,
  33867. 0x25,
  33868. 0x2e,
  33869. 0x1c,
  33870. 0xa6,
  33871. 0xb4,
  33872. 0xc6,
  33873. 0xe8,
  33874. 0xdd,
  33875. 0x74,
  33876. 0x1f,
  33877. 0x4b,
  33878. 0xbd,
  33879. 0x8b,
  33880. 0x8a,
  33881. 0x70,
  33882. 0x3e,
  33883. 0xb5,
  33884. 0x66,
  33885. 0x48,
  33886. 0x03,
  33887. 0xf6,
  33888. 0x0e,
  33889. 0x61,
  33890. 0x35,
  33891. 0x57,
  33892. 0xb9,
  33893. 0x86,
  33894. 0xc1,
  33895. 0x1d,
  33896. 0x9e,
  33897. 0xe1,
  33898. 0xf8,
  33899. 0x98,
  33900. 0x11,
  33901. 0x69,
  33902. 0xd9,
  33903. 0x8e,
  33904. 0x94,
  33905. 0x9b,
  33906. 0x1e,
  33907. 0x87,
  33908. 0xe9,
  33909. 0xce,
  33910. 0x55,
  33911. 0x28,
  33912. 0xdf,
  33913. 0x8c,
  33914. 0xa1,
  33915. 0x89,
  33916. 0x0d,
  33917. 0xbf,
  33918. 0xe6,
  33919. 0x42,
  33920. 0x68,
  33921. 0x41,
  33922. 0x99,
  33923. 0x2d,
  33924. 0x0f,
  33925. 0xb0,
  33926. 0x54,
  33927. 0xbb,
  33928. 0x16
  33929. ]);
  33930. var inv_s = new Uint8Array([
  33931. 0x52,
  33932. 0x09,
  33933. 0x6a,
  33934. 0xd5,
  33935. 0x30,
  33936. 0x36,
  33937. 0xa5,
  33938. 0x38,
  33939. 0xbf,
  33940. 0x40,
  33941. 0xa3,
  33942. 0x9e,
  33943. 0x81,
  33944. 0xf3,
  33945. 0xd7,
  33946. 0xfb,
  33947. 0x7c,
  33948. 0xe3,
  33949. 0x39,
  33950. 0x82,
  33951. 0x9b,
  33952. 0x2f,
  33953. 0xff,
  33954. 0x87,
  33955. 0x34,
  33956. 0x8e,
  33957. 0x43,
  33958. 0x44,
  33959. 0xc4,
  33960. 0xde,
  33961. 0xe9,
  33962. 0xcb,
  33963. 0x54,
  33964. 0x7b,
  33965. 0x94,
  33966. 0x32,
  33967. 0xa6,
  33968. 0xc2,
  33969. 0x23,
  33970. 0x3d,
  33971. 0xee,
  33972. 0x4c,
  33973. 0x95,
  33974. 0x0b,
  33975. 0x42,
  33976. 0xfa,
  33977. 0xc3,
  33978. 0x4e,
  33979. 0x08,
  33980. 0x2e,
  33981. 0xa1,
  33982. 0x66,
  33983. 0x28,
  33984. 0xd9,
  33985. 0x24,
  33986. 0xb2,
  33987. 0x76,
  33988. 0x5b,
  33989. 0xa2,
  33990. 0x49,
  33991. 0x6d,
  33992. 0x8b,
  33993. 0xd1,
  33994. 0x25,
  33995. 0x72,
  33996. 0xf8,
  33997. 0xf6,
  33998. 0x64,
  33999. 0x86,
  34000. 0x68,
  34001. 0x98,
  34002. 0x16,
  34003. 0xd4,
  34004. 0xa4,
  34005. 0x5c,
  34006. 0xcc,
  34007. 0x5d,
  34008. 0x65,
  34009. 0xb6,
  34010. 0x92,
  34011. 0x6c,
  34012. 0x70,
  34013. 0x48,
  34014. 0x50,
  34015. 0xfd,
  34016. 0xed,
  34017. 0xb9,
  34018. 0xda,
  34019. 0x5e,
  34020. 0x15,
  34021. 0x46,
  34022. 0x57,
  34023. 0xa7,
  34024. 0x8d,
  34025. 0x9d,
  34026. 0x84,
  34027. 0x90,
  34028. 0xd8,
  34029. 0xab,
  34030. 0x00,
  34031. 0x8c,
  34032. 0xbc,
  34033. 0xd3,
  34034. 0x0a,
  34035. 0xf7,
  34036. 0xe4,
  34037. 0x58,
  34038. 0x05,
  34039. 0xb8,
  34040. 0xb3,
  34041. 0x45,
  34042. 0x06,
  34043. 0xd0,
  34044. 0x2c,
  34045. 0x1e,
  34046. 0x8f,
  34047. 0xca,
  34048. 0x3f,
  34049. 0x0f,
  34050. 0x02,
  34051. 0xc1,
  34052. 0xaf,
  34053. 0xbd,
  34054. 0x03,
  34055. 0x01,
  34056. 0x13,
  34057. 0x8a,
  34058. 0x6b,
  34059. 0x3a,
  34060. 0x91,
  34061. 0x11,
  34062. 0x41,
  34063. 0x4f,
  34064. 0x67,
  34065. 0xdc,
  34066. 0xea,
  34067. 0x97,
  34068. 0xf2,
  34069. 0xcf,
  34070. 0xce,
  34071. 0xf0,
  34072. 0xb4,
  34073. 0xe6,
  34074. 0x73,
  34075. 0x96,
  34076. 0xac,
  34077. 0x74,
  34078. 0x22,
  34079. 0xe7,
  34080. 0xad,
  34081. 0x35,
  34082. 0x85,
  34083. 0xe2,
  34084. 0xf9,
  34085. 0x37,
  34086. 0xe8,
  34087. 0x1c,
  34088. 0x75,
  34089. 0xdf,
  34090. 0x6e,
  34091. 0x47,
  34092. 0xf1,
  34093. 0x1a,
  34094. 0x71,
  34095. 0x1d,
  34096. 0x29,
  34097. 0xc5,
  34098. 0x89,
  34099. 0x6f,
  34100. 0xb7,
  34101. 0x62,
  34102. 0x0e,
  34103. 0xaa,
  34104. 0x18,
  34105. 0xbe,
  34106. 0x1b,
  34107. 0xfc,
  34108. 0x56,
  34109. 0x3e,
  34110. 0x4b,
  34111. 0xc6,
  34112. 0xd2,
  34113. 0x79,
  34114. 0x20,
  34115. 0x9a,
  34116. 0xdb,
  34117. 0xc0,
  34118. 0xfe,
  34119. 0x78,
  34120. 0xcd,
  34121. 0x5a,
  34122. 0xf4,
  34123. 0x1f,
  34124. 0xdd,
  34125. 0xa8,
  34126. 0x33,
  34127. 0x88,
  34128. 0x07,
  34129. 0xc7,
  34130. 0x31,
  34131. 0xb1,
  34132. 0x12,
  34133. 0x10,
  34134. 0x59,
  34135. 0x27,
  34136. 0x80,
  34137. 0xec,
  34138. 0x5f,
  34139. 0x60,
  34140. 0x51,
  34141. 0x7f,
  34142. 0xa9,
  34143. 0x19,
  34144. 0xb5,
  34145. 0x4a,
  34146. 0x0d,
  34147. 0x2d,
  34148. 0xe5,
  34149. 0x7a,
  34150. 0x9f,
  34151. 0x93,
  34152. 0xc9,
  34153. 0x9c,
  34154. 0xef,
  34155. 0xa0,
  34156. 0xe0,
  34157. 0x3b,
  34158. 0x4d,
  34159. 0xae,
  34160. 0x2a,
  34161. 0xf5,
  34162. 0xb0,
  34163. 0xc8,
  34164. 0xeb,
  34165. 0xbb,
  34166. 0x3c,
  34167. 0x83,
  34168. 0x53,
  34169. 0x99,
  34170. 0x61,
  34171. 0x17,
  34172. 0x2b,
  34173. 0x04,
  34174. 0x7e,
  34175. 0xba,
  34176. 0x77,
  34177. 0xd6,
  34178. 0x26,
  34179. 0xe1,
  34180. 0x69,
  34181. 0x14,
  34182. 0x63,
  34183. 0x55,
  34184. 0x21,
  34185. 0x0c,
  34186. 0x7d
  34187. ]);
  34188. var mixCol = new Uint8Array(256);
  34189. for (var i = 0; i < 256; i++) {
  34190. if (i < 128) {
  34191. mixCol[i] = i << 1;
  34192. } else {
  34193. mixCol[i] = i << 1 ^ 0x1b;
  34194. }
  34195. }
  34196. var mix = new Uint32Array([
  34197. 0x00000000,
  34198. 0x0e090d0b,
  34199. 0x1c121a16,
  34200. 0x121b171d,
  34201. 0x3824342c,
  34202. 0x362d3927,
  34203. 0x24362e3a,
  34204. 0x2a3f2331,
  34205. 0x70486858,
  34206. 0x7e416553,
  34207. 0x6c5a724e,
  34208. 0x62537f45,
  34209. 0x486c5c74,
  34210. 0x4665517f,
  34211. 0x547e4662,
  34212. 0x5a774b69,
  34213. 0xe090d0b0,
  34214. 0xee99ddbb,
  34215. 0xfc82caa6,
  34216. 0xf28bc7ad,
  34217. 0xd8b4e49c,
  34218. 0xd6bde997,
  34219. 0xc4a6fe8a,
  34220. 0xcaaff381,
  34221. 0x90d8b8e8,
  34222. 0x9ed1b5e3,
  34223. 0x8ccaa2fe,
  34224. 0x82c3aff5,
  34225. 0xa8fc8cc4,
  34226. 0xa6f581cf,
  34227. 0xb4ee96d2,
  34228. 0xbae79bd9,
  34229. 0xdb3bbb7b,
  34230. 0xd532b670,
  34231. 0xc729a16d,
  34232. 0xc920ac66,
  34233. 0xe31f8f57,
  34234. 0xed16825c,
  34235. 0xff0d9541,
  34236. 0xf104984a,
  34237. 0xab73d323,
  34238. 0xa57ade28,
  34239. 0xb761c935,
  34240. 0xb968c43e,
  34241. 0x9357e70f,
  34242. 0x9d5eea04,
  34243. 0x8f45fd19,
  34244. 0x814cf012,
  34245. 0x3bab6bcb,
  34246. 0x35a266c0,
  34247. 0x27b971dd,
  34248. 0x29b07cd6,
  34249. 0x038f5fe7,
  34250. 0x0d8652ec,
  34251. 0x1f9d45f1,
  34252. 0x119448fa,
  34253. 0x4be30393,
  34254. 0x45ea0e98,
  34255. 0x57f11985,
  34256. 0x59f8148e,
  34257. 0x73c737bf,
  34258. 0x7dce3ab4,
  34259. 0x6fd52da9,
  34260. 0x61dc20a2,
  34261. 0xad766df6,
  34262. 0xa37f60fd,
  34263. 0xb16477e0,
  34264. 0xbf6d7aeb,
  34265. 0x955259da,
  34266. 0x9b5b54d1,
  34267. 0x894043cc,
  34268. 0x87494ec7,
  34269. 0xdd3e05ae,
  34270. 0xd33708a5,
  34271. 0xc12c1fb8,
  34272. 0xcf2512b3,
  34273. 0xe51a3182,
  34274. 0xeb133c89,
  34275. 0xf9082b94,
  34276. 0xf701269f,
  34277. 0x4de6bd46,
  34278. 0x43efb04d,
  34279. 0x51f4a750,
  34280. 0x5ffdaa5b,
  34281. 0x75c2896a,
  34282. 0x7bcb8461,
  34283. 0x69d0937c,
  34284. 0x67d99e77,
  34285. 0x3daed51e,
  34286. 0x33a7d815,
  34287. 0x21bccf08,
  34288. 0x2fb5c203,
  34289. 0x058ae132,
  34290. 0x0b83ec39,
  34291. 0x1998fb24,
  34292. 0x1791f62f,
  34293. 0x764dd68d,
  34294. 0x7844db86,
  34295. 0x6a5fcc9b,
  34296. 0x6456c190,
  34297. 0x4e69e2a1,
  34298. 0x4060efaa,
  34299. 0x527bf8b7,
  34300. 0x5c72f5bc,
  34301. 0x0605bed5,
  34302. 0x080cb3de,
  34303. 0x1a17a4c3,
  34304. 0x141ea9c8,
  34305. 0x3e218af9,
  34306. 0x302887f2,
  34307. 0x223390ef,
  34308. 0x2c3a9de4,
  34309. 0x96dd063d,
  34310. 0x98d40b36,
  34311. 0x8acf1c2b,
  34312. 0x84c61120,
  34313. 0xaef93211,
  34314. 0xa0f03f1a,
  34315. 0xb2eb2807,
  34316. 0xbce2250c,
  34317. 0xe6956e65,
  34318. 0xe89c636e,
  34319. 0xfa877473,
  34320. 0xf48e7978,
  34321. 0xdeb15a49,
  34322. 0xd0b85742,
  34323. 0xc2a3405f,
  34324. 0xccaa4d54,
  34325. 0x41ecdaf7,
  34326. 0x4fe5d7fc,
  34327. 0x5dfec0e1,
  34328. 0x53f7cdea,
  34329. 0x79c8eedb,
  34330. 0x77c1e3d0,
  34331. 0x65daf4cd,
  34332. 0x6bd3f9c6,
  34333. 0x31a4b2af,
  34334. 0x3fadbfa4,
  34335. 0x2db6a8b9,
  34336. 0x23bfa5b2,
  34337. 0x09808683,
  34338. 0x07898b88,
  34339. 0x15929c95,
  34340. 0x1b9b919e,
  34341. 0xa17c0a47,
  34342. 0xaf75074c,
  34343. 0xbd6e1051,
  34344. 0xb3671d5a,
  34345. 0x99583e6b,
  34346. 0x97513360,
  34347. 0x854a247d,
  34348. 0x8b432976,
  34349. 0xd134621f,
  34350. 0xdf3d6f14,
  34351. 0xcd267809,
  34352. 0xc32f7502,
  34353. 0xe9105633,
  34354. 0xe7195b38,
  34355. 0xf5024c25,
  34356. 0xfb0b412e,
  34357. 0x9ad7618c,
  34358. 0x94de6c87,
  34359. 0x86c57b9a,
  34360. 0x88cc7691,
  34361. 0xa2f355a0,
  34362. 0xacfa58ab,
  34363. 0xbee14fb6,
  34364. 0xb0e842bd,
  34365. 0xea9f09d4,
  34366. 0xe49604df,
  34367. 0xf68d13c2,
  34368. 0xf8841ec9,
  34369. 0xd2bb3df8,
  34370. 0xdcb230f3,
  34371. 0xcea927ee,
  34372. 0xc0a02ae5,
  34373. 0x7a47b13c,
  34374. 0x744ebc37,
  34375. 0x6655ab2a,
  34376. 0x685ca621,
  34377. 0x42638510,
  34378. 0x4c6a881b,
  34379. 0x5e719f06,
  34380. 0x5078920d,
  34381. 0x0a0fd964,
  34382. 0x0406d46f,
  34383. 0x161dc372,
  34384. 0x1814ce79,
  34385. 0x322bed48,
  34386. 0x3c22e043,
  34387. 0x2e39f75e,
  34388. 0x2030fa55,
  34389. 0xec9ab701,
  34390. 0xe293ba0a,
  34391. 0xf088ad17,
  34392. 0xfe81a01c,
  34393. 0xd4be832d,
  34394. 0xdab78e26,
  34395. 0xc8ac993b,
  34396. 0xc6a59430,
  34397. 0x9cd2df59,
  34398. 0x92dbd252,
  34399. 0x80c0c54f,
  34400. 0x8ec9c844,
  34401. 0xa4f6eb75,
  34402. 0xaaffe67e,
  34403. 0xb8e4f163,
  34404. 0xb6edfc68,
  34405. 0x0c0a67b1,
  34406. 0x02036aba,
  34407. 0x10187da7,
  34408. 0x1e1170ac,
  34409. 0x342e539d,
  34410. 0x3a275e96,
  34411. 0x283c498b,
  34412. 0x26354480,
  34413. 0x7c420fe9,
  34414. 0x724b02e2,
  34415. 0x605015ff,
  34416. 0x6e5918f4,
  34417. 0x44663bc5,
  34418. 0x4a6f36ce,
  34419. 0x587421d3,
  34420. 0x567d2cd8,
  34421. 0x37a10c7a,
  34422. 0x39a80171,
  34423. 0x2bb3166c,
  34424. 0x25ba1b67,
  34425. 0x0f853856,
  34426. 0x018c355d,
  34427. 0x13972240,
  34428. 0x1d9e2f4b,
  34429. 0x47e96422,
  34430. 0x49e06929,
  34431. 0x5bfb7e34,
  34432. 0x55f2733f,
  34433. 0x7fcd500e,
  34434. 0x71c45d05,
  34435. 0x63df4a18,
  34436. 0x6dd64713,
  34437. 0xd731dcca,
  34438. 0xd938d1c1,
  34439. 0xcb23c6dc,
  34440. 0xc52acbd7,
  34441. 0xef15e8e6,
  34442. 0xe11ce5ed,
  34443. 0xf307f2f0,
  34444. 0xfd0efffb,
  34445. 0xa779b492,
  34446. 0xa970b999,
  34447. 0xbb6bae84,
  34448. 0xb562a38f,
  34449. 0x9f5d80be,
  34450. 0x91548db5,
  34451. 0x834f9aa8,
  34452. 0x8d4697a3
  34453. ]);
  34454. function expandKey128(cipherKey) {
  34455. var b = 176, result = new Uint8Array(b);
  34456. result.set(cipherKey);
  34457. for (var j = 16, i = 1; j < b; ++i) {
  34458. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34459. t1 = s[t1];
  34460. t2 = s[t2];
  34461. t3 = s[t3];
  34462. t4 = s[t4];
  34463. t1 = t1 ^ rcon[i];
  34464. for (var n = 0; n < 4; ++n) {
  34465. result[j] = t1 ^= result[j - 16];
  34466. j++;
  34467. result[j] = t2 ^= result[j - 16];
  34468. j++;
  34469. result[j] = t3 ^= result[j - 16];
  34470. j++;
  34471. result[j] = t4 ^= result[j - 16];
  34472. j++;
  34473. }
  34474. }
  34475. return result;
  34476. }
  34477. function decrypt128(input, key) {
  34478. var state = new Uint8Array(16);
  34479. state.set(input);
  34480. var i, j, k;
  34481. var t, u, v;
  34482. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34483. state[j] ^= key[k];
  34484. }
  34485. for (i = 9; i >= 1; --i) {
  34486. t = state[13];
  34487. state[13] = state[9];
  34488. state[9] = state[5];
  34489. state[5] = state[1];
  34490. state[1] = t;
  34491. t = state[14];
  34492. u = state[10];
  34493. state[14] = state[6];
  34494. state[10] = state[2];
  34495. state[6] = t;
  34496. state[2] = u;
  34497. t = state[15];
  34498. u = state[11];
  34499. v = state[7];
  34500. state[15] = state[3];
  34501. state[11] = t;
  34502. state[7] = u;
  34503. state[3] = v;
  34504. for (j = 0; j < 16; ++j) {
  34505. state[j] = inv_s[state[j]];
  34506. }
  34507. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34508. state[j] ^= key[k];
  34509. }
  34510. for (j = 0; j < 16; j += 4) {
  34511. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34512. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34513. state[j] = t >>> 24 & 0xFF;
  34514. state[j + 1] = t >> 16 & 0xFF;
  34515. state[j + 2] = t >> 8 & 0xFF;
  34516. state[j + 3] = t & 0xFF;
  34517. }
  34518. }
  34519. t = state[13];
  34520. state[13] = state[9];
  34521. state[9] = state[5];
  34522. state[5] = state[1];
  34523. state[1] = t;
  34524. t = state[14];
  34525. u = state[10];
  34526. state[14] = state[6];
  34527. state[10] = state[2];
  34528. state[6] = t;
  34529. state[2] = u;
  34530. t = state[15];
  34531. u = state[11];
  34532. v = state[7];
  34533. state[15] = state[3];
  34534. state[11] = t;
  34535. state[7] = u;
  34536. state[3] = v;
  34537. for (j = 0; j < 16; ++j) {
  34538. state[j] = inv_s[state[j]];
  34539. state[j] ^= key[j];
  34540. }
  34541. return state;
  34542. }
  34543. function encrypt128(input, key) {
  34544. var t, u, v, k;
  34545. var state = new Uint8Array(16);
  34546. state.set(input);
  34547. for (j = 0; j < 16; ++j) {
  34548. state[j] ^= key[j];
  34549. }
  34550. for (i = 1; i < 10; i++) {
  34551. for (j = 0; j < 16; ++j) {
  34552. state[j] = s[state[j]];
  34553. }
  34554. v = state[1];
  34555. state[1] = state[5];
  34556. state[5] = state[9];
  34557. state[9] = state[13];
  34558. state[13] = v;
  34559. v = state[2];
  34560. u = state[6];
  34561. state[2] = state[10];
  34562. state[6] = state[14];
  34563. state[10] = v;
  34564. state[14] = u;
  34565. v = state[3];
  34566. u = state[7];
  34567. t = state[11];
  34568. state[3] = state[15];
  34569. state[7] = v;
  34570. state[11] = u;
  34571. state[15] = t;
  34572. for (var j = 0; j < 16; j += 4) {
  34573. var s0 = state[j + 0], s1 = state[j + 1];
  34574. var s2 = state[j + 2], s3 = state[j + 3];
  34575. t = s0 ^ s1 ^ s2 ^ s3;
  34576. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34577. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34578. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34579. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34580. }
  34581. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34582. state[j] ^= key[k];
  34583. }
  34584. }
  34585. for (j = 0; j < 16; ++j) {
  34586. state[j] = s[state[j]];
  34587. }
  34588. v = state[1];
  34589. state[1] = state[5];
  34590. state[5] = state[9];
  34591. state[9] = state[13];
  34592. state[13] = v;
  34593. v = state[2];
  34594. u = state[6];
  34595. state[2] = state[10];
  34596. state[6] = state[14];
  34597. state[10] = v;
  34598. state[14] = u;
  34599. v = state[3];
  34600. u = state[7];
  34601. t = state[11];
  34602. state[3] = state[15];
  34603. state[7] = v;
  34604. state[11] = u;
  34605. state[15] = t;
  34606. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34607. state[j] ^= key[k];
  34608. }
  34609. return state;
  34610. }
  34611. function AES128Cipher(key) {
  34612. this.key = expandKey128(key);
  34613. this.buffer = new Uint8Array(16);
  34614. this.bufferPosition = 0;
  34615. }
  34616. function decryptBlock2(data, finalize) {
  34617. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34618. for (i = 0; i < sourceLength; ++i) {
  34619. buffer[bufferLength] = data[i];
  34620. ++bufferLength;
  34621. if (bufferLength < 16) {
  34622. continue;
  34623. }
  34624. var plain = decrypt128(buffer, this.key);
  34625. for (j = 0; j < 16; ++j) {
  34626. plain[j] ^= iv[j];
  34627. }
  34628. iv = buffer;
  34629. result.push(plain);
  34630. buffer = new Uint8Array(16);
  34631. bufferLength = 0;
  34632. }
  34633. this.buffer = buffer;
  34634. this.bufferLength = bufferLength;
  34635. this.iv = iv;
  34636. if (result.length === 0) {
  34637. return new Uint8Array([]);
  34638. }
  34639. var outputLength = 16 * result.length;
  34640. if (finalize) {
  34641. var lastBlock = result[result.length - 1];
  34642. var psLen = lastBlock[15];
  34643. if (psLen <= 16) {
  34644. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34645. if (lastBlock[i] !== psLen) {
  34646. psLen = 0;
  34647. break;
  34648. }
  34649. }
  34650. outputLength -= psLen;
  34651. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34652. }
  34653. }
  34654. var output = new Uint8Array(outputLength);
  34655. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34656. output.set(result[i], j);
  34657. }
  34658. return output;
  34659. }
  34660. AES128Cipher.prototype = {
  34661. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34662. var i, sourceLength = data.length;
  34663. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34664. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34665. buffer[bufferLength] = data[i];
  34666. }
  34667. if (bufferLength < 16) {
  34668. this.bufferLength = bufferLength;
  34669. return new Uint8Array([]);
  34670. }
  34671. this.iv = buffer;
  34672. this.buffer = new Uint8Array(16);
  34673. this.bufferLength = 0;
  34674. this.decryptBlock = decryptBlock2;
  34675. return this.decryptBlock(data.subarray(16), finalize);
  34676. },
  34677. encrypt: function AES128Cipher_encrypt(data, iv) {
  34678. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34679. if (!iv) {
  34680. iv = new Uint8Array(16);
  34681. }
  34682. for (i = 0; i < sourceLength; ++i) {
  34683. buffer[bufferLength] = data[i];
  34684. ++bufferLength;
  34685. if (bufferLength < 16) {
  34686. continue;
  34687. }
  34688. for (j = 0; j < 16; ++j) {
  34689. buffer[j] ^= iv[j];
  34690. }
  34691. var cipher = encrypt128(buffer, this.key);
  34692. iv = cipher;
  34693. result.push(cipher);
  34694. buffer = new Uint8Array(16);
  34695. bufferLength = 0;
  34696. }
  34697. this.buffer = buffer;
  34698. this.bufferLength = bufferLength;
  34699. this.iv = iv;
  34700. if (result.length === 0) {
  34701. return new Uint8Array([]);
  34702. }
  34703. var outputLength = 16 * result.length;
  34704. var output = new Uint8Array(outputLength);
  34705. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34706. output.set(result[i], j);
  34707. }
  34708. return output;
  34709. }
  34710. };
  34711. return AES128Cipher;
  34712. }();
  34713. var AES256Cipher = function AES256CipherClosure() {
  34714. var rcon = new Uint8Array([
  34715. 0x8d,
  34716. 0x01,
  34717. 0x02,
  34718. 0x04,
  34719. 0x08,
  34720. 0x10,
  34721. 0x20,
  34722. 0x40,
  34723. 0x80,
  34724. 0x1b,
  34725. 0x36,
  34726. 0x6c,
  34727. 0xd8,
  34728. 0xab,
  34729. 0x4d,
  34730. 0x9a,
  34731. 0x2f,
  34732. 0x5e,
  34733. 0xbc,
  34734. 0x63,
  34735. 0xc6,
  34736. 0x97,
  34737. 0x35,
  34738. 0x6a,
  34739. 0xd4,
  34740. 0xb3,
  34741. 0x7d,
  34742. 0xfa,
  34743. 0xef,
  34744. 0xc5,
  34745. 0x91,
  34746. 0x39,
  34747. 0x72,
  34748. 0xe4,
  34749. 0xd3,
  34750. 0xbd,
  34751. 0x61,
  34752. 0xc2,
  34753. 0x9f,
  34754. 0x25,
  34755. 0x4a,
  34756. 0x94,
  34757. 0x33,
  34758. 0x66,
  34759. 0xcc,
  34760. 0x83,
  34761. 0x1d,
  34762. 0x3a,
  34763. 0x74,
  34764. 0xe8,
  34765. 0xcb,
  34766. 0x8d,
  34767. 0x01,
  34768. 0x02,
  34769. 0x04,
  34770. 0x08,
  34771. 0x10,
  34772. 0x20,
  34773. 0x40,
  34774. 0x80,
  34775. 0x1b,
  34776. 0x36,
  34777. 0x6c,
  34778. 0xd8,
  34779. 0xab,
  34780. 0x4d,
  34781. 0x9a,
  34782. 0x2f,
  34783. 0x5e,
  34784. 0xbc,
  34785. 0x63,
  34786. 0xc6,
  34787. 0x97,
  34788. 0x35,
  34789. 0x6a,
  34790. 0xd4,
  34791. 0xb3,
  34792. 0x7d,
  34793. 0xfa,
  34794. 0xef,
  34795. 0xc5,
  34796. 0x91,
  34797. 0x39,
  34798. 0x72,
  34799. 0xe4,
  34800. 0xd3,
  34801. 0xbd,
  34802. 0x61,
  34803. 0xc2,
  34804. 0x9f,
  34805. 0x25,
  34806. 0x4a,
  34807. 0x94,
  34808. 0x33,
  34809. 0x66,
  34810. 0xcc,
  34811. 0x83,
  34812. 0x1d,
  34813. 0x3a,
  34814. 0x74,
  34815. 0xe8,
  34816. 0xcb,
  34817. 0x8d,
  34818. 0x01,
  34819. 0x02,
  34820. 0x04,
  34821. 0x08,
  34822. 0x10,
  34823. 0x20,
  34824. 0x40,
  34825. 0x80,
  34826. 0x1b,
  34827. 0x36,
  34828. 0x6c,
  34829. 0xd8,
  34830. 0xab,
  34831. 0x4d,
  34832. 0x9a,
  34833. 0x2f,
  34834. 0x5e,
  34835. 0xbc,
  34836. 0x63,
  34837. 0xc6,
  34838. 0x97,
  34839. 0x35,
  34840. 0x6a,
  34841. 0xd4,
  34842. 0xb3,
  34843. 0x7d,
  34844. 0xfa,
  34845. 0xef,
  34846. 0xc5,
  34847. 0x91,
  34848. 0x39,
  34849. 0x72,
  34850. 0xe4,
  34851. 0xd3,
  34852. 0xbd,
  34853. 0x61,
  34854. 0xc2,
  34855. 0x9f,
  34856. 0x25,
  34857. 0x4a,
  34858. 0x94,
  34859. 0x33,
  34860. 0x66,
  34861. 0xcc,
  34862. 0x83,
  34863. 0x1d,
  34864. 0x3a,
  34865. 0x74,
  34866. 0xe8,
  34867. 0xcb,
  34868. 0x8d,
  34869. 0x01,
  34870. 0x02,
  34871. 0x04,
  34872. 0x08,
  34873. 0x10,
  34874. 0x20,
  34875. 0x40,
  34876. 0x80,
  34877. 0x1b,
  34878. 0x36,
  34879. 0x6c,
  34880. 0xd8,
  34881. 0xab,
  34882. 0x4d,
  34883. 0x9a,
  34884. 0x2f,
  34885. 0x5e,
  34886. 0xbc,
  34887. 0x63,
  34888. 0xc6,
  34889. 0x97,
  34890. 0x35,
  34891. 0x6a,
  34892. 0xd4,
  34893. 0xb3,
  34894. 0x7d,
  34895. 0xfa,
  34896. 0xef,
  34897. 0xc5,
  34898. 0x91,
  34899. 0x39,
  34900. 0x72,
  34901. 0xe4,
  34902. 0xd3,
  34903. 0xbd,
  34904. 0x61,
  34905. 0xc2,
  34906. 0x9f,
  34907. 0x25,
  34908. 0x4a,
  34909. 0x94,
  34910. 0x33,
  34911. 0x66,
  34912. 0xcc,
  34913. 0x83,
  34914. 0x1d,
  34915. 0x3a,
  34916. 0x74,
  34917. 0xe8,
  34918. 0xcb,
  34919. 0x8d,
  34920. 0x01,
  34921. 0x02,
  34922. 0x04,
  34923. 0x08,
  34924. 0x10,
  34925. 0x20,
  34926. 0x40,
  34927. 0x80,
  34928. 0x1b,
  34929. 0x36,
  34930. 0x6c,
  34931. 0xd8,
  34932. 0xab,
  34933. 0x4d,
  34934. 0x9a,
  34935. 0x2f,
  34936. 0x5e,
  34937. 0xbc,
  34938. 0x63,
  34939. 0xc6,
  34940. 0x97,
  34941. 0x35,
  34942. 0x6a,
  34943. 0xd4,
  34944. 0xb3,
  34945. 0x7d,
  34946. 0xfa,
  34947. 0xef,
  34948. 0xc5,
  34949. 0x91,
  34950. 0x39,
  34951. 0x72,
  34952. 0xe4,
  34953. 0xd3,
  34954. 0xbd,
  34955. 0x61,
  34956. 0xc2,
  34957. 0x9f,
  34958. 0x25,
  34959. 0x4a,
  34960. 0x94,
  34961. 0x33,
  34962. 0x66,
  34963. 0xcc,
  34964. 0x83,
  34965. 0x1d,
  34966. 0x3a,
  34967. 0x74,
  34968. 0xe8,
  34969. 0xcb,
  34970. 0x8d
  34971. ]);
  34972. var s = new Uint8Array([
  34973. 0x63,
  34974. 0x7c,
  34975. 0x77,
  34976. 0x7b,
  34977. 0xf2,
  34978. 0x6b,
  34979. 0x6f,
  34980. 0xc5,
  34981. 0x30,
  34982. 0x01,
  34983. 0x67,
  34984. 0x2b,
  34985. 0xfe,
  34986. 0xd7,
  34987. 0xab,
  34988. 0x76,
  34989. 0xca,
  34990. 0x82,
  34991. 0xc9,
  34992. 0x7d,
  34993. 0xfa,
  34994. 0x59,
  34995. 0x47,
  34996. 0xf0,
  34997. 0xad,
  34998. 0xd4,
  34999. 0xa2,
  35000. 0xaf,
  35001. 0x9c,
  35002. 0xa4,
  35003. 0x72,
  35004. 0xc0,
  35005. 0xb7,
  35006. 0xfd,
  35007. 0x93,
  35008. 0x26,
  35009. 0x36,
  35010. 0x3f,
  35011. 0xf7,
  35012. 0xcc,
  35013. 0x34,
  35014. 0xa5,
  35015. 0xe5,
  35016. 0xf1,
  35017. 0x71,
  35018. 0xd8,
  35019. 0x31,
  35020. 0x15,
  35021. 0x04,
  35022. 0xc7,
  35023. 0x23,
  35024. 0xc3,
  35025. 0x18,
  35026. 0x96,
  35027. 0x05,
  35028. 0x9a,
  35029. 0x07,
  35030. 0x12,
  35031. 0x80,
  35032. 0xe2,
  35033. 0xeb,
  35034. 0x27,
  35035. 0xb2,
  35036. 0x75,
  35037. 0x09,
  35038. 0x83,
  35039. 0x2c,
  35040. 0x1a,
  35041. 0x1b,
  35042. 0x6e,
  35043. 0x5a,
  35044. 0xa0,
  35045. 0x52,
  35046. 0x3b,
  35047. 0xd6,
  35048. 0xb3,
  35049. 0x29,
  35050. 0xe3,
  35051. 0x2f,
  35052. 0x84,
  35053. 0x53,
  35054. 0xd1,
  35055. 0x00,
  35056. 0xed,
  35057. 0x20,
  35058. 0xfc,
  35059. 0xb1,
  35060. 0x5b,
  35061. 0x6a,
  35062. 0xcb,
  35063. 0xbe,
  35064. 0x39,
  35065. 0x4a,
  35066. 0x4c,
  35067. 0x58,
  35068. 0xcf,
  35069. 0xd0,
  35070. 0xef,
  35071. 0xaa,
  35072. 0xfb,
  35073. 0x43,
  35074. 0x4d,
  35075. 0x33,
  35076. 0x85,
  35077. 0x45,
  35078. 0xf9,
  35079. 0x02,
  35080. 0x7f,
  35081. 0x50,
  35082. 0x3c,
  35083. 0x9f,
  35084. 0xa8,
  35085. 0x51,
  35086. 0xa3,
  35087. 0x40,
  35088. 0x8f,
  35089. 0x92,
  35090. 0x9d,
  35091. 0x38,
  35092. 0xf5,
  35093. 0xbc,
  35094. 0xb6,
  35095. 0xda,
  35096. 0x21,
  35097. 0x10,
  35098. 0xff,
  35099. 0xf3,
  35100. 0xd2,
  35101. 0xcd,
  35102. 0x0c,
  35103. 0x13,
  35104. 0xec,
  35105. 0x5f,
  35106. 0x97,
  35107. 0x44,
  35108. 0x17,
  35109. 0xc4,
  35110. 0xa7,
  35111. 0x7e,
  35112. 0x3d,
  35113. 0x64,
  35114. 0x5d,
  35115. 0x19,
  35116. 0x73,
  35117. 0x60,
  35118. 0x81,
  35119. 0x4f,
  35120. 0xdc,
  35121. 0x22,
  35122. 0x2a,
  35123. 0x90,
  35124. 0x88,
  35125. 0x46,
  35126. 0xee,
  35127. 0xb8,
  35128. 0x14,
  35129. 0xde,
  35130. 0x5e,
  35131. 0x0b,
  35132. 0xdb,
  35133. 0xe0,
  35134. 0x32,
  35135. 0x3a,
  35136. 0x0a,
  35137. 0x49,
  35138. 0x06,
  35139. 0x24,
  35140. 0x5c,
  35141. 0xc2,
  35142. 0xd3,
  35143. 0xac,
  35144. 0x62,
  35145. 0x91,
  35146. 0x95,
  35147. 0xe4,
  35148. 0x79,
  35149. 0xe7,
  35150. 0xc8,
  35151. 0x37,
  35152. 0x6d,
  35153. 0x8d,
  35154. 0xd5,
  35155. 0x4e,
  35156. 0xa9,
  35157. 0x6c,
  35158. 0x56,
  35159. 0xf4,
  35160. 0xea,
  35161. 0x65,
  35162. 0x7a,
  35163. 0xae,
  35164. 0x08,
  35165. 0xba,
  35166. 0x78,
  35167. 0x25,
  35168. 0x2e,
  35169. 0x1c,
  35170. 0xa6,
  35171. 0xb4,
  35172. 0xc6,
  35173. 0xe8,
  35174. 0xdd,
  35175. 0x74,
  35176. 0x1f,
  35177. 0x4b,
  35178. 0xbd,
  35179. 0x8b,
  35180. 0x8a,
  35181. 0x70,
  35182. 0x3e,
  35183. 0xb5,
  35184. 0x66,
  35185. 0x48,
  35186. 0x03,
  35187. 0xf6,
  35188. 0x0e,
  35189. 0x61,
  35190. 0x35,
  35191. 0x57,
  35192. 0xb9,
  35193. 0x86,
  35194. 0xc1,
  35195. 0x1d,
  35196. 0x9e,
  35197. 0xe1,
  35198. 0xf8,
  35199. 0x98,
  35200. 0x11,
  35201. 0x69,
  35202. 0xd9,
  35203. 0x8e,
  35204. 0x94,
  35205. 0x9b,
  35206. 0x1e,
  35207. 0x87,
  35208. 0xe9,
  35209. 0xce,
  35210. 0x55,
  35211. 0x28,
  35212. 0xdf,
  35213. 0x8c,
  35214. 0xa1,
  35215. 0x89,
  35216. 0x0d,
  35217. 0xbf,
  35218. 0xe6,
  35219. 0x42,
  35220. 0x68,
  35221. 0x41,
  35222. 0x99,
  35223. 0x2d,
  35224. 0x0f,
  35225. 0xb0,
  35226. 0x54,
  35227. 0xbb,
  35228. 0x16
  35229. ]);
  35230. var inv_s = new Uint8Array([
  35231. 0x52,
  35232. 0x09,
  35233. 0x6a,
  35234. 0xd5,
  35235. 0x30,
  35236. 0x36,
  35237. 0xa5,
  35238. 0x38,
  35239. 0xbf,
  35240. 0x40,
  35241. 0xa3,
  35242. 0x9e,
  35243. 0x81,
  35244. 0xf3,
  35245. 0xd7,
  35246. 0xfb,
  35247. 0x7c,
  35248. 0xe3,
  35249. 0x39,
  35250. 0x82,
  35251. 0x9b,
  35252. 0x2f,
  35253. 0xff,
  35254. 0x87,
  35255. 0x34,
  35256. 0x8e,
  35257. 0x43,
  35258. 0x44,
  35259. 0xc4,
  35260. 0xde,
  35261. 0xe9,
  35262. 0xcb,
  35263. 0x54,
  35264. 0x7b,
  35265. 0x94,
  35266. 0x32,
  35267. 0xa6,
  35268. 0xc2,
  35269. 0x23,
  35270. 0x3d,
  35271. 0xee,
  35272. 0x4c,
  35273. 0x95,
  35274. 0x0b,
  35275. 0x42,
  35276. 0xfa,
  35277. 0xc3,
  35278. 0x4e,
  35279. 0x08,
  35280. 0x2e,
  35281. 0xa1,
  35282. 0x66,
  35283. 0x28,
  35284. 0xd9,
  35285. 0x24,
  35286. 0xb2,
  35287. 0x76,
  35288. 0x5b,
  35289. 0xa2,
  35290. 0x49,
  35291. 0x6d,
  35292. 0x8b,
  35293. 0xd1,
  35294. 0x25,
  35295. 0x72,
  35296. 0xf8,
  35297. 0xf6,
  35298. 0x64,
  35299. 0x86,
  35300. 0x68,
  35301. 0x98,
  35302. 0x16,
  35303. 0xd4,
  35304. 0xa4,
  35305. 0x5c,
  35306. 0xcc,
  35307. 0x5d,
  35308. 0x65,
  35309. 0xb6,
  35310. 0x92,
  35311. 0x6c,
  35312. 0x70,
  35313. 0x48,
  35314. 0x50,
  35315. 0xfd,
  35316. 0xed,
  35317. 0xb9,
  35318. 0xda,
  35319. 0x5e,
  35320. 0x15,
  35321. 0x46,
  35322. 0x57,
  35323. 0xa7,
  35324. 0x8d,
  35325. 0x9d,
  35326. 0x84,
  35327. 0x90,
  35328. 0xd8,
  35329. 0xab,
  35330. 0x00,
  35331. 0x8c,
  35332. 0xbc,
  35333. 0xd3,
  35334. 0x0a,
  35335. 0xf7,
  35336. 0xe4,
  35337. 0x58,
  35338. 0x05,
  35339. 0xb8,
  35340. 0xb3,
  35341. 0x45,
  35342. 0x06,
  35343. 0xd0,
  35344. 0x2c,
  35345. 0x1e,
  35346. 0x8f,
  35347. 0xca,
  35348. 0x3f,
  35349. 0x0f,
  35350. 0x02,
  35351. 0xc1,
  35352. 0xaf,
  35353. 0xbd,
  35354. 0x03,
  35355. 0x01,
  35356. 0x13,
  35357. 0x8a,
  35358. 0x6b,
  35359. 0x3a,
  35360. 0x91,
  35361. 0x11,
  35362. 0x41,
  35363. 0x4f,
  35364. 0x67,
  35365. 0xdc,
  35366. 0xea,
  35367. 0x97,
  35368. 0xf2,
  35369. 0xcf,
  35370. 0xce,
  35371. 0xf0,
  35372. 0xb4,
  35373. 0xe6,
  35374. 0x73,
  35375. 0x96,
  35376. 0xac,
  35377. 0x74,
  35378. 0x22,
  35379. 0xe7,
  35380. 0xad,
  35381. 0x35,
  35382. 0x85,
  35383. 0xe2,
  35384. 0xf9,
  35385. 0x37,
  35386. 0xe8,
  35387. 0x1c,
  35388. 0x75,
  35389. 0xdf,
  35390. 0x6e,
  35391. 0x47,
  35392. 0xf1,
  35393. 0x1a,
  35394. 0x71,
  35395. 0x1d,
  35396. 0x29,
  35397. 0xc5,
  35398. 0x89,
  35399. 0x6f,
  35400. 0xb7,
  35401. 0x62,
  35402. 0x0e,
  35403. 0xaa,
  35404. 0x18,
  35405. 0xbe,
  35406. 0x1b,
  35407. 0xfc,
  35408. 0x56,
  35409. 0x3e,
  35410. 0x4b,
  35411. 0xc6,
  35412. 0xd2,
  35413. 0x79,
  35414. 0x20,
  35415. 0x9a,
  35416. 0xdb,
  35417. 0xc0,
  35418. 0xfe,
  35419. 0x78,
  35420. 0xcd,
  35421. 0x5a,
  35422. 0xf4,
  35423. 0x1f,
  35424. 0xdd,
  35425. 0xa8,
  35426. 0x33,
  35427. 0x88,
  35428. 0x07,
  35429. 0xc7,
  35430. 0x31,
  35431. 0xb1,
  35432. 0x12,
  35433. 0x10,
  35434. 0x59,
  35435. 0x27,
  35436. 0x80,
  35437. 0xec,
  35438. 0x5f,
  35439. 0x60,
  35440. 0x51,
  35441. 0x7f,
  35442. 0xa9,
  35443. 0x19,
  35444. 0xb5,
  35445. 0x4a,
  35446. 0x0d,
  35447. 0x2d,
  35448. 0xe5,
  35449. 0x7a,
  35450. 0x9f,
  35451. 0x93,
  35452. 0xc9,
  35453. 0x9c,
  35454. 0xef,
  35455. 0xa0,
  35456. 0xe0,
  35457. 0x3b,
  35458. 0x4d,
  35459. 0xae,
  35460. 0x2a,
  35461. 0xf5,
  35462. 0xb0,
  35463. 0xc8,
  35464. 0xeb,
  35465. 0xbb,
  35466. 0x3c,
  35467. 0x83,
  35468. 0x53,
  35469. 0x99,
  35470. 0x61,
  35471. 0x17,
  35472. 0x2b,
  35473. 0x04,
  35474. 0x7e,
  35475. 0xba,
  35476. 0x77,
  35477. 0xd6,
  35478. 0x26,
  35479. 0xe1,
  35480. 0x69,
  35481. 0x14,
  35482. 0x63,
  35483. 0x55,
  35484. 0x21,
  35485. 0x0c,
  35486. 0x7d
  35487. ]);
  35488. var mixCol = new Uint8Array(256);
  35489. for (var i = 0; i < 256; i++) {
  35490. if (i < 128) {
  35491. mixCol[i] = i << 1;
  35492. } else {
  35493. mixCol[i] = i << 1 ^ 0x1b;
  35494. }
  35495. }
  35496. var mix = new Uint32Array([
  35497. 0x00000000,
  35498. 0x0e090d0b,
  35499. 0x1c121a16,
  35500. 0x121b171d,
  35501. 0x3824342c,
  35502. 0x362d3927,
  35503. 0x24362e3a,
  35504. 0x2a3f2331,
  35505. 0x70486858,
  35506. 0x7e416553,
  35507. 0x6c5a724e,
  35508. 0x62537f45,
  35509. 0x486c5c74,
  35510. 0x4665517f,
  35511. 0x547e4662,
  35512. 0x5a774b69,
  35513. 0xe090d0b0,
  35514. 0xee99ddbb,
  35515. 0xfc82caa6,
  35516. 0xf28bc7ad,
  35517. 0xd8b4e49c,
  35518. 0xd6bde997,
  35519. 0xc4a6fe8a,
  35520. 0xcaaff381,
  35521. 0x90d8b8e8,
  35522. 0x9ed1b5e3,
  35523. 0x8ccaa2fe,
  35524. 0x82c3aff5,
  35525. 0xa8fc8cc4,
  35526. 0xa6f581cf,
  35527. 0xb4ee96d2,
  35528. 0xbae79bd9,
  35529. 0xdb3bbb7b,
  35530. 0xd532b670,
  35531. 0xc729a16d,
  35532. 0xc920ac66,
  35533. 0xe31f8f57,
  35534. 0xed16825c,
  35535. 0xff0d9541,
  35536. 0xf104984a,
  35537. 0xab73d323,
  35538. 0xa57ade28,
  35539. 0xb761c935,
  35540. 0xb968c43e,
  35541. 0x9357e70f,
  35542. 0x9d5eea04,
  35543. 0x8f45fd19,
  35544. 0x814cf012,
  35545. 0x3bab6bcb,
  35546. 0x35a266c0,
  35547. 0x27b971dd,
  35548. 0x29b07cd6,
  35549. 0x038f5fe7,
  35550. 0x0d8652ec,
  35551. 0x1f9d45f1,
  35552. 0x119448fa,
  35553. 0x4be30393,
  35554. 0x45ea0e98,
  35555. 0x57f11985,
  35556. 0x59f8148e,
  35557. 0x73c737bf,
  35558. 0x7dce3ab4,
  35559. 0x6fd52da9,
  35560. 0x61dc20a2,
  35561. 0xad766df6,
  35562. 0xa37f60fd,
  35563. 0xb16477e0,
  35564. 0xbf6d7aeb,
  35565. 0x955259da,
  35566. 0x9b5b54d1,
  35567. 0x894043cc,
  35568. 0x87494ec7,
  35569. 0xdd3e05ae,
  35570. 0xd33708a5,
  35571. 0xc12c1fb8,
  35572. 0xcf2512b3,
  35573. 0xe51a3182,
  35574. 0xeb133c89,
  35575. 0xf9082b94,
  35576. 0xf701269f,
  35577. 0x4de6bd46,
  35578. 0x43efb04d,
  35579. 0x51f4a750,
  35580. 0x5ffdaa5b,
  35581. 0x75c2896a,
  35582. 0x7bcb8461,
  35583. 0x69d0937c,
  35584. 0x67d99e77,
  35585. 0x3daed51e,
  35586. 0x33a7d815,
  35587. 0x21bccf08,
  35588. 0x2fb5c203,
  35589. 0x058ae132,
  35590. 0x0b83ec39,
  35591. 0x1998fb24,
  35592. 0x1791f62f,
  35593. 0x764dd68d,
  35594. 0x7844db86,
  35595. 0x6a5fcc9b,
  35596. 0x6456c190,
  35597. 0x4e69e2a1,
  35598. 0x4060efaa,
  35599. 0x527bf8b7,
  35600. 0x5c72f5bc,
  35601. 0x0605bed5,
  35602. 0x080cb3de,
  35603. 0x1a17a4c3,
  35604. 0x141ea9c8,
  35605. 0x3e218af9,
  35606. 0x302887f2,
  35607. 0x223390ef,
  35608. 0x2c3a9de4,
  35609. 0x96dd063d,
  35610. 0x98d40b36,
  35611. 0x8acf1c2b,
  35612. 0x84c61120,
  35613. 0xaef93211,
  35614. 0xa0f03f1a,
  35615. 0xb2eb2807,
  35616. 0xbce2250c,
  35617. 0xe6956e65,
  35618. 0xe89c636e,
  35619. 0xfa877473,
  35620. 0xf48e7978,
  35621. 0xdeb15a49,
  35622. 0xd0b85742,
  35623. 0xc2a3405f,
  35624. 0xccaa4d54,
  35625. 0x41ecdaf7,
  35626. 0x4fe5d7fc,
  35627. 0x5dfec0e1,
  35628. 0x53f7cdea,
  35629. 0x79c8eedb,
  35630. 0x77c1e3d0,
  35631. 0x65daf4cd,
  35632. 0x6bd3f9c6,
  35633. 0x31a4b2af,
  35634. 0x3fadbfa4,
  35635. 0x2db6a8b9,
  35636. 0x23bfa5b2,
  35637. 0x09808683,
  35638. 0x07898b88,
  35639. 0x15929c95,
  35640. 0x1b9b919e,
  35641. 0xa17c0a47,
  35642. 0xaf75074c,
  35643. 0xbd6e1051,
  35644. 0xb3671d5a,
  35645. 0x99583e6b,
  35646. 0x97513360,
  35647. 0x854a247d,
  35648. 0x8b432976,
  35649. 0xd134621f,
  35650. 0xdf3d6f14,
  35651. 0xcd267809,
  35652. 0xc32f7502,
  35653. 0xe9105633,
  35654. 0xe7195b38,
  35655. 0xf5024c25,
  35656. 0xfb0b412e,
  35657. 0x9ad7618c,
  35658. 0x94de6c87,
  35659. 0x86c57b9a,
  35660. 0x88cc7691,
  35661. 0xa2f355a0,
  35662. 0xacfa58ab,
  35663. 0xbee14fb6,
  35664. 0xb0e842bd,
  35665. 0xea9f09d4,
  35666. 0xe49604df,
  35667. 0xf68d13c2,
  35668. 0xf8841ec9,
  35669. 0xd2bb3df8,
  35670. 0xdcb230f3,
  35671. 0xcea927ee,
  35672. 0xc0a02ae5,
  35673. 0x7a47b13c,
  35674. 0x744ebc37,
  35675. 0x6655ab2a,
  35676. 0x685ca621,
  35677. 0x42638510,
  35678. 0x4c6a881b,
  35679. 0x5e719f06,
  35680. 0x5078920d,
  35681. 0x0a0fd964,
  35682. 0x0406d46f,
  35683. 0x161dc372,
  35684. 0x1814ce79,
  35685. 0x322bed48,
  35686. 0x3c22e043,
  35687. 0x2e39f75e,
  35688. 0x2030fa55,
  35689. 0xec9ab701,
  35690. 0xe293ba0a,
  35691. 0xf088ad17,
  35692. 0xfe81a01c,
  35693. 0xd4be832d,
  35694. 0xdab78e26,
  35695. 0xc8ac993b,
  35696. 0xc6a59430,
  35697. 0x9cd2df59,
  35698. 0x92dbd252,
  35699. 0x80c0c54f,
  35700. 0x8ec9c844,
  35701. 0xa4f6eb75,
  35702. 0xaaffe67e,
  35703. 0xb8e4f163,
  35704. 0xb6edfc68,
  35705. 0x0c0a67b1,
  35706. 0x02036aba,
  35707. 0x10187da7,
  35708. 0x1e1170ac,
  35709. 0x342e539d,
  35710. 0x3a275e96,
  35711. 0x283c498b,
  35712. 0x26354480,
  35713. 0x7c420fe9,
  35714. 0x724b02e2,
  35715. 0x605015ff,
  35716. 0x6e5918f4,
  35717. 0x44663bc5,
  35718. 0x4a6f36ce,
  35719. 0x587421d3,
  35720. 0x567d2cd8,
  35721. 0x37a10c7a,
  35722. 0x39a80171,
  35723. 0x2bb3166c,
  35724. 0x25ba1b67,
  35725. 0x0f853856,
  35726. 0x018c355d,
  35727. 0x13972240,
  35728. 0x1d9e2f4b,
  35729. 0x47e96422,
  35730. 0x49e06929,
  35731. 0x5bfb7e34,
  35732. 0x55f2733f,
  35733. 0x7fcd500e,
  35734. 0x71c45d05,
  35735. 0x63df4a18,
  35736. 0x6dd64713,
  35737. 0xd731dcca,
  35738. 0xd938d1c1,
  35739. 0xcb23c6dc,
  35740. 0xc52acbd7,
  35741. 0xef15e8e6,
  35742. 0xe11ce5ed,
  35743. 0xf307f2f0,
  35744. 0xfd0efffb,
  35745. 0xa779b492,
  35746. 0xa970b999,
  35747. 0xbb6bae84,
  35748. 0xb562a38f,
  35749. 0x9f5d80be,
  35750. 0x91548db5,
  35751. 0x834f9aa8,
  35752. 0x8d4697a3
  35753. ]);
  35754. function expandKey256(cipherKey) {
  35755. var b = 240, result = new Uint8Array(b);
  35756. var r = 1;
  35757. result.set(cipherKey);
  35758. for (var j = 32, i = 1; j < b; ++i) {
  35759. if (j % 32 === 16) {
  35760. t1 = s[t1];
  35761. t2 = s[t2];
  35762. t3 = s[t3];
  35763. t4 = s[t4];
  35764. } else if (j % 32 === 0) {
  35765. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35766. t1 = s[t1];
  35767. t2 = s[t2];
  35768. t3 = s[t3];
  35769. t4 = s[t4];
  35770. t1 = t1 ^ r;
  35771. if ((r <<= 1) >= 256) {
  35772. r = (r ^ 0x1b) & 0xFF;
  35773. }
  35774. }
  35775. for (var n = 0; n < 4; ++n) {
  35776. result[j] = t1 ^= result[j - 32];
  35777. j++;
  35778. result[j] = t2 ^= result[j - 32];
  35779. j++;
  35780. result[j] = t3 ^= result[j - 32];
  35781. j++;
  35782. result[j] = t4 ^= result[j - 32];
  35783. j++;
  35784. }
  35785. }
  35786. return result;
  35787. }
  35788. function decrypt256(input, key) {
  35789. var state = new Uint8Array(16);
  35790. state.set(input);
  35791. var i, j, k;
  35792. var t, u, v;
  35793. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35794. state[j] ^= key[k];
  35795. }
  35796. for (i = 13; i >= 1; --i) {
  35797. t = state[13];
  35798. state[13] = state[9];
  35799. state[9] = state[5];
  35800. state[5] = state[1];
  35801. state[1] = t;
  35802. t = state[14];
  35803. u = state[10];
  35804. state[14] = state[6];
  35805. state[10] = state[2];
  35806. state[6] = t;
  35807. state[2] = u;
  35808. t = state[15];
  35809. u = state[11];
  35810. v = state[7];
  35811. state[15] = state[3];
  35812. state[11] = t;
  35813. state[7] = u;
  35814. state[3] = v;
  35815. for (j = 0; j < 16; ++j) {
  35816. state[j] = inv_s[state[j]];
  35817. }
  35818. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35819. state[j] ^= key[k];
  35820. }
  35821. for (j = 0; j < 16; j += 4) {
  35822. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35823. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35824. state[j] = t >>> 24 & 0xFF;
  35825. state[j + 1] = t >> 16 & 0xFF;
  35826. state[j + 2] = t >> 8 & 0xFF;
  35827. state[j + 3] = t & 0xFF;
  35828. }
  35829. }
  35830. t = state[13];
  35831. state[13] = state[9];
  35832. state[9] = state[5];
  35833. state[5] = state[1];
  35834. state[1] = t;
  35835. t = state[14];
  35836. u = state[10];
  35837. state[14] = state[6];
  35838. state[10] = state[2];
  35839. state[6] = t;
  35840. state[2] = u;
  35841. t = state[15];
  35842. u = state[11];
  35843. v = state[7];
  35844. state[15] = state[3];
  35845. state[11] = t;
  35846. state[7] = u;
  35847. state[3] = v;
  35848. for (j = 0; j < 16; ++j) {
  35849. state[j] = inv_s[state[j]];
  35850. state[j] ^= key[j];
  35851. }
  35852. return state;
  35853. }
  35854. function encrypt256(input, key) {
  35855. var t, u, v, k;
  35856. var state = new Uint8Array(16);
  35857. state.set(input);
  35858. for (j = 0; j < 16; ++j) {
  35859. state[j] ^= key[j];
  35860. }
  35861. for (i = 1; i < 14; i++) {
  35862. for (j = 0; j < 16; ++j) {
  35863. state[j] = s[state[j]];
  35864. }
  35865. v = state[1];
  35866. state[1] = state[5];
  35867. state[5] = state[9];
  35868. state[9] = state[13];
  35869. state[13] = v;
  35870. v = state[2];
  35871. u = state[6];
  35872. state[2] = state[10];
  35873. state[6] = state[14];
  35874. state[10] = v;
  35875. state[14] = u;
  35876. v = state[3];
  35877. u = state[7];
  35878. t = state[11];
  35879. state[3] = state[15];
  35880. state[7] = v;
  35881. state[11] = u;
  35882. state[15] = t;
  35883. for (var j = 0; j < 16; j += 4) {
  35884. var s0 = state[j + 0], s1 = state[j + 1];
  35885. var s2 = state[j + 2], s3 = state[j + 3];
  35886. t = s0 ^ s1 ^ s2 ^ s3;
  35887. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  35888. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  35889. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  35890. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  35891. }
  35892. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35893. state[j] ^= key[k];
  35894. }
  35895. }
  35896. for (j = 0; j < 16; ++j) {
  35897. state[j] = s[state[j]];
  35898. }
  35899. v = state[1];
  35900. state[1] = state[5];
  35901. state[5] = state[9];
  35902. state[9] = state[13];
  35903. state[13] = v;
  35904. v = state[2];
  35905. u = state[6];
  35906. state[2] = state[10];
  35907. state[6] = state[14];
  35908. state[10] = v;
  35909. state[14] = u;
  35910. v = state[3];
  35911. u = state[7];
  35912. t = state[11];
  35913. state[3] = state[15];
  35914. state[7] = v;
  35915. state[11] = u;
  35916. state[15] = t;
  35917. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35918. state[j] ^= key[k];
  35919. }
  35920. return state;
  35921. }
  35922. function AES256Cipher(key) {
  35923. this.key = expandKey256(key);
  35924. this.buffer = new Uint8Array(16);
  35925. this.bufferPosition = 0;
  35926. }
  35927. function decryptBlock2(data, finalize) {
  35928. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  35929. for (i = 0; i < sourceLength; ++i) {
  35930. buffer[bufferLength] = data[i];
  35931. ++bufferLength;
  35932. if (bufferLength < 16) {
  35933. continue;
  35934. }
  35935. var plain = decrypt256(buffer, this.key);
  35936. for (j = 0; j < 16; ++j) {
  35937. plain[j] ^= iv[j];
  35938. }
  35939. iv = buffer;
  35940. result.push(plain);
  35941. buffer = new Uint8Array(16);
  35942. bufferLength = 0;
  35943. }
  35944. this.buffer = buffer;
  35945. this.bufferLength = bufferLength;
  35946. this.iv = iv;
  35947. if (result.length === 0) {
  35948. return new Uint8Array([]);
  35949. }
  35950. var outputLength = 16 * result.length;
  35951. if (finalize) {
  35952. var lastBlock = result[result.length - 1];
  35953. var psLen = lastBlock[15];
  35954. if (psLen <= 16) {
  35955. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  35956. if (lastBlock[i] !== psLen) {
  35957. psLen = 0;
  35958. break;
  35959. }
  35960. }
  35961. outputLength -= psLen;
  35962. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  35963. }
  35964. }
  35965. var output = new Uint8Array(outputLength);
  35966. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35967. output.set(result[i], j);
  35968. }
  35969. return output;
  35970. }
  35971. AES256Cipher.prototype = {
  35972. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  35973. var i, sourceLength = data.length;
  35974. var buffer = this.buffer, bufferLength = this.bufferPosition;
  35975. if (iv) {
  35976. this.iv = iv;
  35977. } else {
  35978. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  35979. buffer[bufferLength] = data[i];
  35980. }
  35981. if (bufferLength < 16) {
  35982. this.bufferLength = bufferLength;
  35983. return new Uint8Array([]);
  35984. }
  35985. this.iv = buffer;
  35986. data = data.subarray(16);
  35987. }
  35988. this.buffer = new Uint8Array(16);
  35989. this.bufferLength = 0;
  35990. this.decryptBlock = decryptBlock2;
  35991. return this.decryptBlock(data, finalize);
  35992. },
  35993. encrypt: function AES256Cipher_encrypt(data, iv) {
  35994. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  35995. if (!iv) {
  35996. iv = new Uint8Array(16);
  35997. }
  35998. for (i = 0; i < sourceLength; ++i) {
  35999. buffer[bufferLength] = data[i];
  36000. ++bufferLength;
  36001. if (bufferLength < 16) {
  36002. continue;
  36003. }
  36004. for (j = 0; j < 16; ++j) {
  36005. buffer[j] ^= iv[j];
  36006. }
  36007. var cipher = encrypt256(buffer, this.key);
  36008. this.iv = cipher;
  36009. result.push(cipher);
  36010. buffer = new Uint8Array(16);
  36011. bufferLength = 0;
  36012. }
  36013. this.buffer = buffer;
  36014. this.bufferLength = bufferLength;
  36015. this.iv = iv;
  36016. if (result.length === 0) {
  36017. return new Uint8Array([]);
  36018. }
  36019. var outputLength = 16 * result.length;
  36020. var output = new Uint8Array(outputLength);
  36021. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36022. output.set(result[i], j);
  36023. }
  36024. return output;
  36025. }
  36026. };
  36027. return AES256Cipher;
  36028. }();
  36029. var PDF17 = function PDF17Closure() {
  36030. function compareByteArrays(array1, array2) {
  36031. if (array1.length !== array2.length) {
  36032. return false;
  36033. }
  36034. for (var i = 0; i < array1.length; i++) {
  36035. if (array1[i] !== array2[i]) {
  36036. return false;
  36037. }
  36038. }
  36039. return true;
  36040. }
  36041. function PDF17() {
  36042. }
  36043. PDF17.prototype = {
  36044. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36045. var hashData = new Uint8Array(password.length + 56);
  36046. hashData.set(password, 0);
  36047. hashData.set(ownerValidationSalt, password.length);
  36048. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36049. var result = calculateSHA256(hashData, 0, hashData.length);
  36050. return compareByteArrays(result, ownerPassword);
  36051. },
  36052. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36053. var hashData = new Uint8Array(password.length + 8);
  36054. hashData.set(password, 0);
  36055. hashData.set(userValidationSalt, password.length);
  36056. var result = calculateSHA256(hashData, 0, hashData.length);
  36057. return compareByteArrays(result, userPassword);
  36058. },
  36059. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36060. var hashData = new Uint8Array(password.length + 56);
  36061. hashData.set(password, 0);
  36062. hashData.set(ownerKeySalt, password.length);
  36063. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36064. var key = calculateSHA256(hashData, 0, hashData.length);
  36065. var cipher = new AES256Cipher(key);
  36066. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36067. },
  36068. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36069. var hashData = new Uint8Array(password.length + 8);
  36070. hashData.set(password, 0);
  36071. hashData.set(userKeySalt, password.length);
  36072. var key = calculateSHA256(hashData, 0, hashData.length);
  36073. var cipher = new AES256Cipher(key);
  36074. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36075. }
  36076. };
  36077. return PDF17;
  36078. }();
  36079. var PDF20 = function PDF20Closure() {
  36080. function concatArrays(array1, array2) {
  36081. var t = new Uint8Array(array1.length + array2.length);
  36082. t.set(array1, 0);
  36083. t.set(array2, array1.length);
  36084. return t;
  36085. }
  36086. function calculatePDF20Hash(password, input, userBytes) {
  36087. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36088. var e = [0];
  36089. var i = 0;
  36090. while (i < 64 || e[e.length - 1] > i - 32) {
  36091. var arrayLength = password.length + k.length + userBytes.length;
  36092. var k1 = new Uint8Array(arrayLength * 64);
  36093. var array = concatArrays(password, k);
  36094. array = concatArrays(array, userBytes);
  36095. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36096. k1.set(array, pos);
  36097. }
  36098. var cipher = new AES128Cipher(k.subarray(0, 16));
  36099. e = cipher.encrypt(k1, k.subarray(16, 32));
  36100. var remainder = 0;
  36101. for (var z = 0; z < 16; z++) {
  36102. remainder *= 256 % 3;
  36103. remainder %= 3;
  36104. remainder += (e[z] >>> 0) % 3;
  36105. remainder %= 3;
  36106. }
  36107. if (remainder === 0) {
  36108. k = calculateSHA256(e, 0, e.length);
  36109. } else if (remainder === 1) {
  36110. k = calculateSHA384(e, 0, e.length);
  36111. } else if (remainder === 2) {
  36112. k = calculateSHA512(e, 0, e.length);
  36113. }
  36114. i++;
  36115. }
  36116. return k.subarray(0, 32);
  36117. }
  36118. function PDF20() {
  36119. }
  36120. function compareByteArrays(array1, array2) {
  36121. if (array1.length !== array2.length) {
  36122. return false;
  36123. }
  36124. for (var i = 0; i < array1.length; i++) {
  36125. if (array1[i] !== array2[i]) {
  36126. return false;
  36127. }
  36128. }
  36129. return true;
  36130. }
  36131. PDF20.prototype = {
  36132. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36133. return calculatePDF20Hash(password, concatBytes, userBytes);
  36134. },
  36135. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36136. var hashData = new Uint8Array(password.length + 56);
  36137. hashData.set(password, 0);
  36138. hashData.set(ownerValidationSalt, password.length);
  36139. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36140. var result = calculatePDF20Hash(password, hashData, userBytes);
  36141. return compareByteArrays(result, ownerPassword);
  36142. },
  36143. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36144. var hashData = new Uint8Array(password.length + 8);
  36145. hashData.set(password, 0);
  36146. hashData.set(userValidationSalt, password.length);
  36147. var result = calculatePDF20Hash(password, hashData, []);
  36148. return compareByteArrays(result, userPassword);
  36149. },
  36150. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36151. var hashData = new Uint8Array(password.length + 56);
  36152. hashData.set(password, 0);
  36153. hashData.set(ownerKeySalt, password.length);
  36154. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36155. var key = calculatePDF20Hash(password, hashData, userBytes);
  36156. var cipher = new AES256Cipher(key);
  36157. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36158. },
  36159. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36160. var hashData = new Uint8Array(password.length + 8);
  36161. hashData.set(password, 0);
  36162. hashData.set(userKeySalt, password.length);
  36163. var key = calculatePDF20Hash(password, hashData, []);
  36164. var cipher = new AES256Cipher(key);
  36165. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36166. }
  36167. };
  36168. return PDF20;
  36169. }();
  36170. var CipherTransform = function CipherTransformClosure() {
  36171. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36172. this.stringCipherConstructor = stringCipherConstructor;
  36173. this.streamCipherConstructor = streamCipherConstructor;
  36174. }
  36175. CipherTransform.prototype = {
  36176. createStream: function CipherTransform_createStream(stream, length) {
  36177. var cipher = new this.streamCipherConstructor();
  36178. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36179. return cipher.decryptBlock(data, finalize);
  36180. });
  36181. },
  36182. decryptString: function CipherTransform_decryptString(s) {
  36183. var cipher = new this.stringCipherConstructor();
  36184. var data = stringToBytes(s);
  36185. data = cipher.decryptBlock(data, true);
  36186. return bytesToString(data);
  36187. }
  36188. };
  36189. return CipherTransform;
  36190. }();
  36191. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36192. var defaultPasswordBytes = new Uint8Array([
  36193. 0x28,
  36194. 0xBF,
  36195. 0x4E,
  36196. 0x5E,
  36197. 0x4E,
  36198. 0x75,
  36199. 0x8A,
  36200. 0x41,
  36201. 0x64,
  36202. 0x00,
  36203. 0x4E,
  36204. 0x56,
  36205. 0xFF,
  36206. 0xFA,
  36207. 0x01,
  36208. 0x08,
  36209. 0x2E,
  36210. 0x2E,
  36211. 0x00,
  36212. 0xB6,
  36213. 0xD0,
  36214. 0x68,
  36215. 0x3E,
  36216. 0x80,
  36217. 0x2F,
  36218. 0x0C,
  36219. 0xA9,
  36220. 0xFE,
  36221. 0x64,
  36222. 0x53,
  36223. 0x69,
  36224. 0x7A
  36225. ]);
  36226. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36227. if (password) {
  36228. var passwordLength = Math.min(127, password.length);
  36229. password = password.subarray(0, passwordLength);
  36230. } else {
  36231. password = [];
  36232. }
  36233. var pdfAlgorithm;
  36234. if (revision === 6) {
  36235. pdfAlgorithm = new PDF20();
  36236. } else {
  36237. pdfAlgorithm = new PDF17();
  36238. }
  36239. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36240. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36241. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36242. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36243. }
  36244. return null;
  36245. }
  36246. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36247. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36248. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36249. if (password) {
  36250. n = Math.min(32, password.length);
  36251. for (; i < n; ++i) {
  36252. hashData[i] = password[i];
  36253. }
  36254. }
  36255. j = 0;
  36256. while (i < 32) {
  36257. hashData[i++] = defaultPasswordBytes[j++];
  36258. }
  36259. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36260. hashData[i++] = ownerPassword[j];
  36261. }
  36262. hashData[i++] = flags & 0xFF;
  36263. hashData[i++] = flags >> 8 & 0xFF;
  36264. hashData[i++] = flags >> 16 & 0xFF;
  36265. hashData[i++] = flags >>> 24 & 0xFF;
  36266. for (j = 0, n = fileId.length; j < n; ++j) {
  36267. hashData[i++] = fileId[j];
  36268. }
  36269. if (revision >= 4 && !encryptMetadata) {
  36270. hashData[i++] = 0xFF;
  36271. hashData[i++] = 0xFF;
  36272. hashData[i++] = 0xFF;
  36273. hashData[i++] = 0xFF;
  36274. }
  36275. var hash = calculateMD5(hashData, 0, i);
  36276. var keyLengthInBytes = keyLength >> 3;
  36277. if (revision >= 3) {
  36278. for (j = 0; j < 50; ++j) {
  36279. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36280. }
  36281. }
  36282. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36283. var cipher, checkData;
  36284. if (revision >= 3) {
  36285. for (i = 0; i < 32; ++i) {
  36286. hashData[i] = defaultPasswordBytes[i];
  36287. }
  36288. for (j = 0, n = fileId.length; j < n; ++j) {
  36289. hashData[i++] = fileId[j];
  36290. }
  36291. cipher = new ARCFourCipher(encryptionKey);
  36292. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36293. n = encryptionKey.length;
  36294. var derivedKey = new Uint8Array(n), k;
  36295. for (j = 1; j <= 19; ++j) {
  36296. for (k = 0; k < n; ++k) {
  36297. derivedKey[k] = encryptionKey[k] ^ j;
  36298. }
  36299. cipher = new ARCFourCipher(derivedKey);
  36300. checkData = cipher.encryptBlock(checkData);
  36301. }
  36302. for (j = 0, n = checkData.length; j < n; ++j) {
  36303. if (userPassword[j] !== checkData[j]) {
  36304. return null;
  36305. }
  36306. }
  36307. } else {
  36308. cipher = new ARCFourCipher(encryptionKey);
  36309. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36310. for (j = 0, n = checkData.length; j < n; ++j) {
  36311. if (userPassword[j] !== checkData[j]) {
  36312. return null;
  36313. }
  36314. }
  36315. }
  36316. return encryptionKey;
  36317. }
  36318. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36319. var hashData = new Uint8Array(32), i = 0, j, n;
  36320. n = Math.min(32, password.length);
  36321. for (; i < n; ++i) {
  36322. hashData[i] = password[i];
  36323. }
  36324. j = 0;
  36325. while (i < 32) {
  36326. hashData[i++] = defaultPasswordBytes[j++];
  36327. }
  36328. var hash = calculateMD5(hashData, 0, i);
  36329. var keyLengthInBytes = keyLength >> 3;
  36330. if (revision >= 3) {
  36331. for (j = 0; j < 50; ++j) {
  36332. hash = calculateMD5(hash, 0, hash.length);
  36333. }
  36334. }
  36335. var cipher, userPassword;
  36336. if (revision >= 3) {
  36337. userPassword = ownerPassword;
  36338. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36339. for (j = 19; j >= 0; j--) {
  36340. for (k = 0; k < keyLengthInBytes; ++k) {
  36341. derivedKey[k] = hash[k] ^ j;
  36342. }
  36343. cipher = new ARCFourCipher(derivedKey);
  36344. userPassword = cipher.encryptBlock(userPassword);
  36345. }
  36346. } else {
  36347. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36348. userPassword = cipher.encryptBlock(ownerPassword);
  36349. }
  36350. return userPassword;
  36351. }
  36352. var identityName = Name.get('Identity');
  36353. function CipherTransformFactory(dict, fileId, password) {
  36354. var filter = dict.get('Filter');
  36355. if (!isName(filter, 'Standard')) {
  36356. error('unknown encryption method');
  36357. }
  36358. this.dict = dict;
  36359. var algorithm = dict.get('V');
  36360. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36361. error('unsupported encryption algorithm');
  36362. }
  36363. this.algorithm = algorithm;
  36364. var keyLength = dict.get('Length');
  36365. if (!keyLength) {
  36366. if (algorithm <= 3) {
  36367. keyLength = 40;
  36368. } else {
  36369. var cfDict = dict.get('CF');
  36370. var streamCryptoName = dict.get('StmF');
  36371. if (isDict(cfDict) && isName(streamCryptoName)) {
  36372. cfDict.suppressEncryption = true;
  36373. var handlerDict = cfDict.get(streamCryptoName.name);
  36374. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36375. if (keyLength < 40) {
  36376. keyLength <<= 3;
  36377. }
  36378. }
  36379. }
  36380. }
  36381. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36382. error('invalid key length');
  36383. }
  36384. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36385. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36386. var flags = dict.get('P');
  36387. var revision = dict.get('R');
  36388. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36389. this.encryptMetadata = encryptMetadata;
  36390. var fileIdBytes = stringToBytes(fileId);
  36391. var passwordBytes;
  36392. if (password) {
  36393. if (revision === 6) {
  36394. try {
  36395. password = utf8StringToString(password);
  36396. } catch (ex) {
  36397. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36398. }
  36399. }
  36400. passwordBytes = stringToBytes(password);
  36401. }
  36402. var encryptionKey;
  36403. if (algorithm !== 5) {
  36404. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36405. } else {
  36406. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36407. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36408. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36409. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36410. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36411. var ownerEncryption = stringToBytes(dict.get('OE'));
  36412. var userEncryption = stringToBytes(dict.get('UE'));
  36413. var perms = stringToBytes(dict.get('Perms'));
  36414. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36415. }
  36416. if (!encryptionKey && !password) {
  36417. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36418. } else if (!encryptionKey && password) {
  36419. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36420. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36421. }
  36422. if (!encryptionKey) {
  36423. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36424. }
  36425. this.encryptionKey = encryptionKey;
  36426. if (algorithm >= 4) {
  36427. var cf = dict.get('CF');
  36428. if (isDict(cf)) {
  36429. cf.suppressEncryption = true;
  36430. }
  36431. this.cf = cf;
  36432. this.stmf = dict.get('StmF') || identityName;
  36433. this.strf = dict.get('StrF') || identityName;
  36434. this.eff = dict.get('EFF') || this.stmf;
  36435. }
  36436. }
  36437. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36438. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36439. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36440. key[i] = encryptionKey[i];
  36441. }
  36442. key[i++] = num & 0xFF;
  36443. key[i++] = num >> 8 & 0xFF;
  36444. key[i++] = num >> 16 & 0xFF;
  36445. key[i++] = gen & 0xFF;
  36446. key[i++] = gen >> 8 & 0xFF;
  36447. if (isAes) {
  36448. key[i++] = 0x73;
  36449. key[i++] = 0x41;
  36450. key[i++] = 0x6C;
  36451. key[i++] = 0x54;
  36452. }
  36453. var hash = calculateMD5(key, 0, i);
  36454. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36455. }
  36456. function buildCipherConstructor(cf, name, num, gen, key) {
  36457. assert(isName(name), 'Invalid crypt filter name.');
  36458. var cryptFilter = cf.get(name.name);
  36459. var cfm;
  36460. if (cryptFilter !== null && cryptFilter !== undefined) {
  36461. cfm = cryptFilter.get('CFM');
  36462. }
  36463. if (!cfm || cfm.name === 'None') {
  36464. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36465. return new NullCipher();
  36466. };
  36467. }
  36468. if ('V2' === cfm.name) {
  36469. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36470. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36471. };
  36472. }
  36473. if ('AESV2' === cfm.name) {
  36474. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36475. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36476. };
  36477. }
  36478. if ('AESV3' === cfm.name) {
  36479. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36480. return new AES256Cipher(key);
  36481. };
  36482. }
  36483. error('Unknown crypto method');
  36484. }
  36485. CipherTransformFactory.prototype = {
  36486. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36487. if (this.algorithm === 4 || this.algorithm === 5) {
  36488. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36489. }
  36490. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36491. var cipherConstructor = function buildCipherCipherConstructor() {
  36492. return new ARCFourCipher(key);
  36493. };
  36494. return new CipherTransform(cipherConstructor, cipherConstructor);
  36495. }
  36496. };
  36497. return CipherTransformFactory;
  36498. }();
  36499. exports.AES128Cipher = AES128Cipher;
  36500. exports.AES256Cipher = AES256Cipher;
  36501. exports.ARCFourCipher = ARCFourCipher;
  36502. exports.CipherTransformFactory = CipherTransformFactory;
  36503. exports.PDF17 = PDF17;
  36504. exports.PDF20 = PDF20;
  36505. exports.calculateMD5 = calculateMD5;
  36506. exports.calculateSHA256 = calculateSHA256;
  36507. exports.calculateSHA384 = calculateSHA384;
  36508. exports.calculateSHA512 = calculateSHA512;
  36509. }));
  36510. (function (root, factory) {
  36511. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36512. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36513. var Util = sharedUtil.Util;
  36514. var bytesToString = sharedUtil.bytesToString;
  36515. var error = sharedUtil.error;
  36516. var Stream = coreStream.Stream;
  36517. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36518. var StandardEncoding = coreEncodings.StandardEncoding;
  36519. var CFFParser = coreCFFParser.CFFParser;
  36520. var FontRendererFactory = function FontRendererFactoryClosure() {
  36521. function getLong(data, offset) {
  36522. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36523. }
  36524. function getUshort(data, offset) {
  36525. return data[offset] << 8 | data[offset + 1];
  36526. }
  36527. function parseCmap(data, start, end) {
  36528. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36529. var format = getUshort(data, start + offset);
  36530. var length, ranges, p, i;
  36531. if (format === 4) {
  36532. length = getUshort(data, start + offset + 2);
  36533. var segCount = getUshort(data, start + offset + 6) >> 1;
  36534. p = start + offset + 14;
  36535. ranges = [];
  36536. for (i = 0; i < segCount; i++, p += 2) {
  36537. ranges[i] = { end: getUshort(data, p) };
  36538. }
  36539. p += 2;
  36540. for (i = 0; i < segCount; i++, p += 2) {
  36541. ranges[i].start = getUshort(data, p);
  36542. }
  36543. for (i = 0; i < segCount; i++, p += 2) {
  36544. ranges[i].idDelta = getUshort(data, p);
  36545. }
  36546. for (i = 0; i < segCount; i++, p += 2) {
  36547. var idOffset = getUshort(data, p);
  36548. if (idOffset === 0) {
  36549. continue;
  36550. }
  36551. ranges[i].ids = [];
  36552. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36553. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36554. idOffset += 2;
  36555. }
  36556. }
  36557. return ranges;
  36558. } else if (format === 12) {
  36559. length = getLong(data, start + offset + 4);
  36560. var groups = getLong(data, start + offset + 12);
  36561. p = start + offset + 16;
  36562. ranges = [];
  36563. for (i = 0; i < groups; i++) {
  36564. ranges.push({
  36565. start: getLong(data, p),
  36566. end: getLong(data, p + 4),
  36567. idDelta: getLong(data, p + 8) - getLong(data, p)
  36568. });
  36569. p += 12;
  36570. }
  36571. return ranges;
  36572. }
  36573. error('not supported cmap: ' + format);
  36574. }
  36575. function parseCff(data, start, end, seacAnalysisEnabled) {
  36576. var properties = {};
  36577. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36578. var cff = parser.parse();
  36579. return {
  36580. glyphs: cff.charStrings.objects,
  36581. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36582. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36583. };
  36584. }
  36585. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36586. var itemSize, itemDecode;
  36587. if (isGlyphLocationsLong) {
  36588. itemSize = 4;
  36589. itemDecode = function fontItemDecodeLong(data, offset) {
  36590. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36591. };
  36592. } else {
  36593. itemSize = 2;
  36594. itemDecode = function fontItemDecode(data, offset) {
  36595. return data[offset] << 9 | data[offset + 1] << 1;
  36596. };
  36597. }
  36598. var glyphs = [];
  36599. var startOffset = itemDecode(loca, 0);
  36600. for (var j = itemSize; j < loca.length; j += itemSize) {
  36601. var endOffset = itemDecode(loca, j);
  36602. glyphs.push(glyf.subarray(startOffset, endOffset));
  36603. startOffset = endOffset;
  36604. }
  36605. return glyphs;
  36606. }
  36607. function lookupCmap(ranges, unicode) {
  36608. var code = unicode.charCodeAt(0), gid = 0;
  36609. var l = 0, r = ranges.length - 1;
  36610. while (l < r) {
  36611. var c = l + r + 1 >> 1;
  36612. if (code < ranges[c].start) {
  36613. r = c - 1;
  36614. } else {
  36615. l = c;
  36616. }
  36617. }
  36618. if (ranges[l].start <= code && code <= ranges[l].end) {
  36619. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36620. }
  36621. return {
  36622. charCode: code,
  36623. glyphId: gid
  36624. };
  36625. }
  36626. function compileGlyf(code, cmds, font) {
  36627. function moveTo(x, y) {
  36628. cmds.push({
  36629. cmd: 'moveTo',
  36630. args: [
  36631. x,
  36632. y
  36633. ]
  36634. });
  36635. }
  36636. function lineTo(x, y) {
  36637. cmds.push({
  36638. cmd: 'lineTo',
  36639. args: [
  36640. x,
  36641. y
  36642. ]
  36643. });
  36644. }
  36645. function quadraticCurveTo(xa, ya, x, y) {
  36646. cmds.push({
  36647. cmd: 'quadraticCurveTo',
  36648. args: [
  36649. xa,
  36650. ya,
  36651. x,
  36652. y
  36653. ]
  36654. });
  36655. }
  36656. var i = 0;
  36657. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36658. var flags;
  36659. var x = 0, y = 0;
  36660. i += 10;
  36661. if (numberOfContours < 0) {
  36662. do {
  36663. flags = code[i] << 8 | code[i + 1];
  36664. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36665. i += 4;
  36666. var arg1, arg2;
  36667. if (flags & 0x01) {
  36668. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36669. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36670. i += 4;
  36671. } else {
  36672. arg1 = code[i++];
  36673. arg2 = code[i++];
  36674. }
  36675. if (flags & 0x02) {
  36676. x = arg1;
  36677. y = arg2;
  36678. } else {
  36679. x = 0;
  36680. y = 0;
  36681. }
  36682. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36683. if (flags & 0x08) {
  36684. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36685. i += 2;
  36686. } else if (flags & 0x40) {
  36687. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36688. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36689. i += 4;
  36690. } else if (flags & 0x80) {
  36691. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36692. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36693. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36694. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36695. i += 8;
  36696. }
  36697. var subglyph = font.glyphs[glyphIndex];
  36698. if (subglyph) {
  36699. cmds.push({ cmd: 'save' });
  36700. cmds.push({
  36701. cmd: 'transform',
  36702. args: [
  36703. scaleX,
  36704. scale01,
  36705. scale10,
  36706. scaleY,
  36707. x,
  36708. y
  36709. ]
  36710. });
  36711. compileGlyf(subglyph, cmds, font);
  36712. cmds.push({ cmd: 'restore' });
  36713. }
  36714. } while (flags & 0x20);
  36715. } else {
  36716. var endPtsOfContours = [];
  36717. var j, jj;
  36718. for (j = 0; j < numberOfContours; j++) {
  36719. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36720. i += 2;
  36721. }
  36722. var instructionLength = code[i] << 8 | code[i + 1];
  36723. i += 2 + instructionLength;
  36724. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36725. var points = [];
  36726. while (points.length < numberOfPoints) {
  36727. flags = code[i++];
  36728. var repeat = 1;
  36729. if (flags & 0x08) {
  36730. repeat += code[i++];
  36731. }
  36732. while (repeat-- > 0) {
  36733. points.push({ flags: flags });
  36734. }
  36735. }
  36736. for (j = 0; j < numberOfPoints; j++) {
  36737. switch (points[j].flags & 0x12) {
  36738. case 0x00:
  36739. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36740. i += 2;
  36741. break;
  36742. case 0x02:
  36743. x -= code[i++];
  36744. break;
  36745. case 0x12:
  36746. x += code[i++];
  36747. break;
  36748. }
  36749. points[j].x = x;
  36750. }
  36751. for (j = 0; j < numberOfPoints; j++) {
  36752. switch (points[j].flags & 0x24) {
  36753. case 0x00:
  36754. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36755. i += 2;
  36756. break;
  36757. case 0x04:
  36758. y -= code[i++];
  36759. break;
  36760. case 0x24:
  36761. y += code[i++];
  36762. break;
  36763. }
  36764. points[j].y = y;
  36765. }
  36766. var startPoint = 0;
  36767. for (i = 0; i < numberOfContours; i++) {
  36768. var endPoint = endPtsOfContours[i];
  36769. var contour = points.slice(startPoint, endPoint + 1);
  36770. if (contour[0].flags & 1) {
  36771. contour.push(contour[0]);
  36772. } else if (contour[contour.length - 1].flags & 1) {
  36773. contour.unshift(contour[contour.length - 1]);
  36774. } else {
  36775. var p = {
  36776. flags: 1,
  36777. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36778. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36779. };
  36780. contour.unshift(p);
  36781. contour.push(p);
  36782. }
  36783. moveTo(contour[0].x, contour[0].y);
  36784. for (j = 1, jj = contour.length; j < jj; j++) {
  36785. if (contour[j].flags & 1) {
  36786. lineTo(contour[j].x, contour[j].y);
  36787. } else if (contour[j + 1].flags & 1) {
  36788. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36789. j++;
  36790. } else {
  36791. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36792. }
  36793. }
  36794. startPoint = endPoint + 1;
  36795. }
  36796. }
  36797. }
  36798. function compileCharString(code, cmds, font) {
  36799. var stack = [];
  36800. var x = 0, y = 0;
  36801. var stems = 0;
  36802. function moveTo(x, y) {
  36803. cmds.push({
  36804. cmd: 'moveTo',
  36805. args: [
  36806. x,
  36807. y
  36808. ]
  36809. });
  36810. }
  36811. function lineTo(x, y) {
  36812. cmds.push({
  36813. cmd: 'lineTo',
  36814. args: [
  36815. x,
  36816. y
  36817. ]
  36818. });
  36819. }
  36820. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36821. cmds.push({
  36822. cmd: 'bezierCurveTo',
  36823. args: [
  36824. x1,
  36825. y1,
  36826. x2,
  36827. y2,
  36828. x,
  36829. y
  36830. ]
  36831. });
  36832. }
  36833. function parse(code) {
  36834. var i = 0;
  36835. while (i < code.length) {
  36836. var stackClean = false;
  36837. var v = code[i++];
  36838. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  36839. switch (v) {
  36840. case 1:
  36841. stems += stack.length >> 1;
  36842. stackClean = true;
  36843. break;
  36844. case 3:
  36845. stems += stack.length >> 1;
  36846. stackClean = true;
  36847. break;
  36848. case 4:
  36849. y += stack.pop();
  36850. moveTo(x, y);
  36851. stackClean = true;
  36852. break;
  36853. case 5:
  36854. while (stack.length > 0) {
  36855. x += stack.shift();
  36856. y += stack.shift();
  36857. lineTo(x, y);
  36858. }
  36859. break;
  36860. case 6:
  36861. while (stack.length > 0) {
  36862. x += stack.shift();
  36863. lineTo(x, y);
  36864. if (stack.length === 0) {
  36865. break;
  36866. }
  36867. y += stack.shift();
  36868. lineTo(x, y);
  36869. }
  36870. break;
  36871. case 7:
  36872. while (stack.length > 0) {
  36873. y += stack.shift();
  36874. lineTo(x, y);
  36875. if (stack.length === 0) {
  36876. break;
  36877. }
  36878. x += stack.shift();
  36879. lineTo(x, y);
  36880. }
  36881. break;
  36882. case 8:
  36883. while (stack.length > 0) {
  36884. xa = x + stack.shift();
  36885. ya = y + stack.shift();
  36886. xb = xa + stack.shift();
  36887. yb = ya + stack.shift();
  36888. x = xb + stack.shift();
  36889. y = yb + stack.shift();
  36890. bezierCurveTo(xa, ya, xb, yb, x, y);
  36891. }
  36892. break;
  36893. case 10:
  36894. n = stack.pop() + font.subrsBias;
  36895. subrCode = font.subrs[n];
  36896. if (subrCode) {
  36897. parse(subrCode);
  36898. }
  36899. break;
  36900. case 11:
  36901. return;
  36902. case 12:
  36903. v = code[i++];
  36904. switch (v) {
  36905. case 34:
  36906. xa = x + stack.shift();
  36907. xb = xa + stack.shift();
  36908. y1 = y + stack.shift();
  36909. x = xb + stack.shift();
  36910. bezierCurveTo(xa, y, xb, y1, x, y1);
  36911. xa = x + stack.shift();
  36912. xb = xa + stack.shift();
  36913. x = xb + stack.shift();
  36914. bezierCurveTo(xa, y1, xb, y, x, y);
  36915. break;
  36916. case 35:
  36917. xa = x + stack.shift();
  36918. ya = y + stack.shift();
  36919. xb = xa + stack.shift();
  36920. yb = ya + stack.shift();
  36921. x = xb + stack.shift();
  36922. y = yb + stack.shift();
  36923. bezierCurveTo(xa, ya, xb, yb, x, y);
  36924. xa = x + stack.shift();
  36925. ya = y + stack.shift();
  36926. xb = xa + stack.shift();
  36927. yb = ya + stack.shift();
  36928. x = xb + stack.shift();
  36929. y = yb + stack.shift();
  36930. bezierCurveTo(xa, ya, xb, yb, x, y);
  36931. stack.pop();
  36932. break;
  36933. case 36:
  36934. xa = x + stack.shift();
  36935. y1 = y + stack.shift();
  36936. xb = xa + stack.shift();
  36937. y2 = y1 + stack.shift();
  36938. x = xb + stack.shift();
  36939. bezierCurveTo(xa, y1, xb, y2, x, y2);
  36940. xa = x + stack.shift();
  36941. xb = xa + stack.shift();
  36942. y3 = y2 + stack.shift();
  36943. x = xb + stack.shift();
  36944. bezierCurveTo(xa, y2, xb, y3, x, y);
  36945. break;
  36946. case 37:
  36947. var x0 = x, y0 = y;
  36948. xa = x + stack.shift();
  36949. ya = y + stack.shift();
  36950. xb = xa + stack.shift();
  36951. yb = ya + stack.shift();
  36952. x = xb + stack.shift();
  36953. y = yb + stack.shift();
  36954. bezierCurveTo(xa, ya, xb, yb, x, y);
  36955. xa = x + stack.shift();
  36956. ya = y + stack.shift();
  36957. xb = xa + stack.shift();
  36958. yb = ya + stack.shift();
  36959. x = xb;
  36960. y = yb;
  36961. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  36962. x += stack.shift();
  36963. } else {
  36964. y += stack.shift();
  36965. }
  36966. bezierCurveTo(xa, ya, xb, yb, x, y);
  36967. break;
  36968. default:
  36969. error('unknown operator: 12 ' + v);
  36970. }
  36971. break;
  36972. case 14:
  36973. if (stack.length >= 4) {
  36974. var achar = stack.pop();
  36975. var bchar = stack.pop();
  36976. y = stack.pop();
  36977. x = stack.pop();
  36978. cmds.push({ cmd: 'save' });
  36979. cmds.push({
  36980. cmd: 'translate',
  36981. args: [
  36982. x,
  36983. y
  36984. ]
  36985. });
  36986. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  36987. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36988. cmds.push({ cmd: 'restore' });
  36989. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  36990. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36991. }
  36992. return;
  36993. case 18:
  36994. stems += stack.length >> 1;
  36995. stackClean = true;
  36996. break;
  36997. case 19:
  36998. stems += stack.length >> 1;
  36999. i += stems + 7 >> 3;
  37000. stackClean = true;
  37001. break;
  37002. case 20:
  37003. stems += stack.length >> 1;
  37004. i += stems + 7 >> 3;
  37005. stackClean = true;
  37006. break;
  37007. case 21:
  37008. y += stack.pop();
  37009. x += stack.pop();
  37010. moveTo(x, y);
  37011. stackClean = true;
  37012. break;
  37013. case 22:
  37014. x += stack.pop();
  37015. moveTo(x, y);
  37016. stackClean = true;
  37017. break;
  37018. case 23:
  37019. stems += stack.length >> 1;
  37020. stackClean = true;
  37021. break;
  37022. case 24:
  37023. while (stack.length > 2) {
  37024. xa = x + stack.shift();
  37025. ya = y + stack.shift();
  37026. xb = xa + stack.shift();
  37027. yb = ya + stack.shift();
  37028. x = xb + stack.shift();
  37029. y = yb + stack.shift();
  37030. bezierCurveTo(xa, ya, xb, yb, x, y);
  37031. }
  37032. x += stack.shift();
  37033. y += stack.shift();
  37034. lineTo(x, y);
  37035. break;
  37036. case 25:
  37037. while (stack.length > 6) {
  37038. x += stack.shift();
  37039. y += stack.shift();
  37040. lineTo(x, y);
  37041. }
  37042. xa = x + stack.shift();
  37043. ya = y + stack.shift();
  37044. xb = xa + stack.shift();
  37045. yb = ya + stack.shift();
  37046. x = xb + stack.shift();
  37047. y = yb + stack.shift();
  37048. bezierCurveTo(xa, ya, xb, yb, x, y);
  37049. break;
  37050. case 26:
  37051. if (stack.length % 2) {
  37052. x += stack.shift();
  37053. }
  37054. while (stack.length > 0) {
  37055. xa = x;
  37056. ya = y + stack.shift();
  37057. xb = xa + stack.shift();
  37058. yb = ya + stack.shift();
  37059. x = xb;
  37060. y = yb + stack.shift();
  37061. bezierCurveTo(xa, ya, xb, yb, x, y);
  37062. }
  37063. break;
  37064. case 27:
  37065. if (stack.length % 2) {
  37066. y += stack.shift();
  37067. }
  37068. while (stack.length > 0) {
  37069. xa = x + stack.shift();
  37070. ya = y;
  37071. xb = xa + stack.shift();
  37072. yb = ya + stack.shift();
  37073. x = xb + stack.shift();
  37074. y = yb;
  37075. bezierCurveTo(xa, ya, xb, yb, x, y);
  37076. }
  37077. break;
  37078. case 28:
  37079. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37080. i += 2;
  37081. break;
  37082. case 29:
  37083. n = stack.pop() + font.gsubrsBias;
  37084. subrCode = font.gsubrs[n];
  37085. if (subrCode) {
  37086. parse(subrCode);
  37087. }
  37088. break;
  37089. case 30:
  37090. while (stack.length > 0) {
  37091. xa = x;
  37092. ya = y + stack.shift();
  37093. xb = xa + stack.shift();
  37094. yb = ya + stack.shift();
  37095. x = xb + stack.shift();
  37096. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37097. bezierCurveTo(xa, ya, xb, yb, x, y);
  37098. if (stack.length === 0) {
  37099. break;
  37100. }
  37101. xa = x + stack.shift();
  37102. ya = y;
  37103. xb = xa + stack.shift();
  37104. yb = ya + stack.shift();
  37105. y = yb + stack.shift();
  37106. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37107. bezierCurveTo(xa, ya, xb, yb, x, y);
  37108. }
  37109. break;
  37110. case 31:
  37111. while (stack.length > 0) {
  37112. xa = x + stack.shift();
  37113. ya = y;
  37114. xb = xa + stack.shift();
  37115. yb = ya + stack.shift();
  37116. y = yb + stack.shift();
  37117. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37118. bezierCurveTo(xa, ya, xb, yb, x, y);
  37119. if (stack.length === 0) {
  37120. break;
  37121. }
  37122. xa = x;
  37123. ya = y + stack.shift();
  37124. xb = xa + stack.shift();
  37125. yb = ya + stack.shift();
  37126. x = xb + stack.shift();
  37127. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37128. bezierCurveTo(xa, ya, xb, yb, x, y);
  37129. }
  37130. break;
  37131. default:
  37132. if (v < 32) {
  37133. error('unknown operator: ' + v);
  37134. }
  37135. if (v < 247) {
  37136. stack.push(v - 139);
  37137. } else if (v < 251) {
  37138. stack.push((v - 247) * 256 + code[i++] + 108);
  37139. } else if (v < 255) {
  37140. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37141. } else {
  37142. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37143. i += 4;
  37144. }
  37145. break;
  37146. }
  37147. if (stackClean) {
  37148. stack.length = 0;
  37149. }
  37150. }
  37151. }
  37152. parse(code);
  37153. }
  37154. var noop = '';
  37155. function CompiledFont(fontMatrix) {
  37156. this.compiledGlyphs = Object.create(null);
  37157. this.compiledCharCodeToGlyphId = Object.create(null);
  37158. this.fontMatrix = fontMatrix;
  37159. }
  37160. CompiledFont.prototype = {
  37161. getPathJs: function (unicode) {
  37162. var cmap = lookupCmap(this.cmap, unicode);
  37163. var fn = this.compiledGlyphs[cmap.glyphId];
  37164. if (!fn) {
  37165. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37166. this.compiledGlyphs[cmap.glyphId] = fn;
  37167. }
  37168. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37169. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37170. }
  37171. return fn;
  37172. },
  37173. compileGlyph: function (code) {
  37174. if (!code || code.length === 0 || code[0] === 14) {
  37175. return noop;
  37176. }
  37177. var cmds = [];
  37178. cmds.push({ cmd: 'save' });
  37179. cmds.push({
  37180. cmd: 'transform',
  37181. args: this.fontMatrix.slice()
  37182. });
  37183. cmds.push({
  37184. cmd: 'scale',
  37185. args: [
  37186. 'size',
  37187. '-size'
  37188. ]
  37189. });
  37190. this.compileGlyphImpl(code, cmds);
  37191. cmds.push({ cmd: 'restore' });
  37192. return cmds;
  37193. },
  37194. compileGlyphImpl: function () {
  37195. error('Children classes should implement this.');
  37196. },
  37197. hasBuiltPath: function (unicode) {
  37198. var cmap = lookupCmap(this.cmap, unicode);
  37199. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37200. }
  37201. };
  37202. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37203. fontMatrix = fontMatrix || [
  37204. 0.000488,
  37205. 0,
  37206. 0,
  37207. 0.000488,
  37208. 0,
  37209. 0
  37210. ];
  37211. CompiledFont.call(this, fontMatrix);
  37212. this.glyphs = glyphs;
  37213. this.cmap = cmap;
  37214. }
  37215. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37216. compileGlyphImpl: function (code, cmds) {
  37217. compileGlyf(code, cmds, this);
  37218. }
  37219. });
  37220. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37221. fontMatrix = fontMatrix || [
  37222. 0.001,
  37223. 0,
  37224. 0,
  37225. 0.001,
  37226. 0,
  37227. 0
  37228. ];
  37229. CompiledFont.call(this, fontMatrix);
  37230. this.glyphs = cffInfo.glyphs;
  37231. this.gsubrs = cffInfo.gsubrs || [];
  37232. this.subrs = cffInfo.subrs || [];
  37233. this.cmap = cmap;
  37234. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37235. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37236. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37237. }
  37238. Util.inherit(Type2Compiled, CompiledFont, {
  37239. compileGlyphImpl: function (code, cmds) {
  37240. compileCharString(code, cmds, this);
  37241. }
  37242. });
  37243. return {
  37244. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37245. var data = new Uint8Array(font.data);
  37246. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37247. var numTables = getUshort(data, 4);
  37248. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37249. var tag = bytesToString(data.subarray(p, p + 4));
  37250. var offset = getLong(data, p + 8);
  37251. var length = getLong(data, p + 12);
  37252. switch (tag) {
  37253. case 'cmap':
  37254. cmap = parseCmap(data, offset, offset + length);
  37255. break;
  37256. case 'glyf':
  37257. glyf = data.subarray(offset, offset + length);
  37258. break;
  37259. case 'loca':
  37260. loca = data.subarray(offset, offset + length);
  37261. break;
  37262. case 'head':
  37263. unitsPerEm = getUshort(data, offset + 18);
  37264. indexToLocFormat = getUshort(data, offset + 50);
  37265. break;
  37266. case 'CFF ':
  37267. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37268. break;
  37269. }
  37270. }
  37271. if (glyf) {
  37272. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37273. 1 / unitsPerEm,
  37274. 0,
  37275. 0,
  37276. 1 / unitsPerEm,
  37277. 0,
  37278. 0
  37279. ];
  37280. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37281. } else {
  37282. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37283. }
  37284. }
  37285. };
  37286. }();
  37287. exports.FontRendererFactory = FontRendererFactory;
  37288. }));
  37289. (function (root, factory) {
  37290. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37291. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37292. var MissingDataException = sharedUtil.MissingDataException;
  37293. var StreamType = sharedUtil.StreamType;
  37294. var assert = sharedUtil.assert;
  37295. var error = sharedUtil.error;
  37296. var info = sharedUtil.info;
  37297. var isArray = sharedUtil.isArray;
  37298. var isInt = sharedUtil.isInt;
  37299. var isNum = sharedUtil.isNum;
  37300. var isString = sharedUtil.isString;
  37301. var warn = sharedUtil.warn;
  37302. var Cmd = corePrimitives.Cmd;
  37303. var Dict = corePrimitives.Dict;
  37304. var Name = corePrimitives.Name;
  37305. var Ref = corePrimitives.Ref;
  37306. var isCmd = corePrimitives.isCmd;
  37307. var isDict = corePrimitives.isDict;
  37308. var isName = corePrimitives.isName;
  37309. var Ascii85Stream = coreStream.Ascii85Stream;
  37310. var AsciiHexStream = coreStream.AsciiHexStream;
  37311. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37312. var FlateStream = coreStream.FlateStream;
  37313. var Jbig2Stream = coreStream.Jbig2Stream;
  37314. var JpegStream = coreStream.JpegStream;
  37315. var JpxStream = coreStream.JpxStream;
  37316. var LZWStream = coreStream.LZWStream;
  37317. var NullStream = coreStream.NullStream;
  37318. var PredictorStream = coreStream.PredictorStream;
  37319. var RunLengthStream = coreStream.RunLengthStream;
  37320. var EOF = {};
  37321. function isEOF(v) {
  37322. return v === EOF;
  37323. }
  37324. var MAX_LENGTH_TO_CACHE = 1000;
  37325. var Parser = function ParserClosure() {
  37326. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37327. this.lexer = lexer;
  37328. this.allowStreams = allowStreams;
  37329. this.xref = xref;
  37330. this.recoveryMode = recoveryMode || false;
  37331. this.imageCache = Object.create(null);
  37332. this.refill();
  37333. }
  37334. Parser.prototype = {
  37335. refill: function Parser_refill() {
  37336. this.buf1 = this.lexer.getObj();
  37337. this.buf2 = this.lexer.getObj();
  37338. },
  37339. shift: function Parser_shift() {
  37340. if (isCmd(this.buf2, 'ID')) {
  37341. this.buf1 = this.buf2;
  37342. this.buf2 = null;
  37343. } else {
  37344. this.buf1 = this.buf2;
  37345. this.buf2 = this.lexer.getObj();
  37346. }
  37347. },
  37348. tryShift: function Parser_tryShift() {
  37349. try {
  37350. this.shift();
  37351. return true;
  37352. } catch (e) {
  37353. if (e instanceof MissingDataException) {
  37354. throw e;
  37355. }
  37356. return false;
  37357. }
  37358. },
  37359. getObj: function Parser_getObj(cipherTransform) {
  37360. var buf1 = this.buf1;
  37361. this.shift();
  37362. if (buf1 instanceof Cmd) {
  37363. switch (buf1.cmd) {
  37364. case 'BI':
  37365. return this.makeInlineImage(cipherTransform);
  37366. case '[':
  37367. var array = [];
  37368. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37369. array.push(this.getObj(cipherTransform));
  37370. }
  37371. if (isEOF(this.buf1)) {
  37372. if (!this.recoveryMode) {
  37373. error('End of file inside array');
  37374. }
  37375. return array;
  37376. }
  37377. this.shift();
  37378. return array;
  37379. case '<<':
  37380. var dict = new Dict(this.xref);
  37381. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37382. if (!isName(this.buf1)) {
  37383. info('Malformed dictionary: key must be a name object');
  37384. this.shift();
  37385. continue;
  37386. }
  37387. var key = this.buf1.name;
  37388. this.shift();
  37389. if (isEOF(this.buf1)) {
  37390. break;
  37391. }
  37392. dict.set(key, this.getObj(cipherTransform));
  37393. }
  37394. if (isEOF(this.buf1)) {
  37395. if (!this.recoveryMode) {
  37396. error('End of file inside dictionary');
  37397. }
  37398. return dict;
  37399. }
  37400. if (isCmd(this.buf2, 'stream')) {
  37401. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37402. }
  37403. this.shift();
  37404. return dict;
  37405. default:
  37406. return buf1;
  37407. }
  37408. }
  37409. if (isInt(buf1)) {
  37410. var num = buf1;
  37411. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37412. var ref = new Ref(num, this.buf1);
  37413. this.shift();
  37414. this.shift();
  37415. return ref;
  37416. }
  37417. return num;
  37418. }
  37419. if (isString(buf1)) {
  37420. var str = buf1;
  37421. if (cipherTransform) {
  37422. str = cipherTransform.decryptString(str);
  37423. }
  37424. return str;
  37425. }
  37426. return buf1;
  37427. },
  37428. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37429. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37430. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37431. while ((ch = stream.getByte()) !== -1) {
  37432. if (state === 0) {
  37433. state = ch === E ? 1 : 0;
  37434. } else if (state === 1) {
  37435. state = ch === I ? 2 : 0;
  37436. } else {
  37437. assert(state === 2);
  37438. if (ch === SPACE || ch === LF || ch === CR) {
  37439. n = 5;
  37440. followingBytes = stream.peekBytes(n);
  37441. for (i = 0; i < n; i++) {
  37442. ch = followingBytes[i];
  37443. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37444. state = 0;
  37445. break;
  37446. }
  37447. }
  37448. if (state === 2) {
  37449. break;
  37450. }
  37451. } else
  37452. {
  37453. state = 0;
  37454. }
  37455. }
  37456. }
  37457. return stream.pos - 4 - startPos;
  37458. },
  37459. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37460. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37461. while ((b = stream.getByte()) !== -1) {
  37462. if (b !== 0xFF) {
  37463. continue;
  37464. }
  37465. switch (stream.getByte()) {
  37466. case 0x00:
  37467. break;
  37468. case 0xFF:
  37469. stream.skip(-1);
  37470. break;
  37471. case 0xD9:
  37472. foundEOI = true;
  37473. break;
  37474. case 0xC0:
  37475. case 0xC1:
  37476. case 0xC2:
  37477. case 0xC3:
  37478. case 0xC5:
  37479. case 0xC6:
  37480. case 0xC7:
  37481. case 0xC9:
  37482. case 0xCA:
  37483. case 0xCB:
  37484. case 0xCD:
  37485. case 0xCE:
  37486. case 0xCF:
  37487. case 0xC4:
  37488. case 0xCC:
  37489. case 0xDA:
  37490. case 0xDB:
  37491. case 0xDC:
  37492. case 0xDD:
  37493. case 0xDE:
  37494. case 0xDF:
  37495. case 0xE0:
  37496. case 0xE1:
  37497. case 0xE2:
  37498. case 0xE3:
  37499. case 0xE4:
  37500. case 0xE5:
  37501. case 0xE6:
  37502. case 0xE7:
  37503. case 0xE8:
  37504. case 0xE9:
  37505. case 0xEA:
  37506. case 0xEB:
  37507. case 0xEC:
  37508. case 0xED:
  37509. case 0xEE:
  37510. case 0xEF:
  37511. case 0xFE:
  37512. markerLength = stream.getUint16();
  37513. if (markerLength > 2) {
  37514. stream.skip(markerLength - 2);
  37515. } else
  37516. {
  37517. stream.skip(-2);
  37518. }
  37519. break;
  37520. }
  37521. if (foundEOI) {
  37522. break;
  37523. }
  37524. }
  37525. length = stream.pos - startPos;
  37526. if (b === -1) {
  37527. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37528. stream.skip(-length);
  37529. return this.findDefaultInlineStreamEnd(stream);
  37530. }
  37531. this.inlineStreamSkipEI(stream);
  37532. return length;
  37533. },
  37534. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37535. var TILDE = 0x7E, GT = 0x3E;
  37536. var startPos = stream.pos, ch, length;
  37537. while ((ch = stream.getByte()) !== -1) {
  37538. if (ch === TILDE && stream.peekByte() === GT) {
  37539. stream.skip();
  37540. break;
  37541. }
  37542. }
  37543. length = stream.pos - startPos;
  37544. if (ch === -1) {
  37545. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37546. stream.skip(-length);
  37547. return this.findDefaultInlineStreamEnd(stream);
  37548. }
  37549. this.inlineStreamSkipEI(stream);
  37550. return length;
  37551. },
  37552. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37553. var GT = 0x3E;
  37554. var startPos = stream.pos, ch, length;
  37555. while ((ch = stream.getByte()) !== -1) {
  37556. if (ch === GT) {
  37557. break;
  37558. }
  37559. }
  37560. length = stream.pos - startPos;
  37561. if (ch === -1) {
  37562. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37563. stream.skip(-length);
  37564. return this.findDefaultInlineStreamEnd(stream);
  37565. }
  37566. this.inlineStreamSkipEI(stream);
  37567. return length;
  37568. },
  37569. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37570. var E = 0x45, I = 0x49;
  37571. var state = 0, ch;
  37572. while ((ch = stream.getByte()) !== -1) {
  37573. if (state === 0) {
  37574. state = ch === E ? 1 : 0;
  37575. } else if (state === 1) {
  37576. state = ch === I ? 2 : 0;
  37577. } else if (state === 2) {
  37578. break;
  37579. }
  37580. }
  37581. },
  37582. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37583. var lexer = this.lexer;
  37584. var stream = lexer.stream;
  37585. var dict = new Dict(this.xref);
  37586. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37587. if (!isName(this.buf1)) {
  37588. error('Dictionary key must be a name object');
  37589. }
  37590. var key = this.buf1.name;
  37591. this.shift();
  37592. if (isEOF(this.buf1)) {
  37593. break;
  37594. }
  37595. dict.set(key, this.getObj(cipherTransform));
  37596. }
  37597. var filter = dict.get('Filter', 'F'), filterName;
  37598. if (isName(filter)) {
  37599. filterName = filter.name;
  37600. } else if (isArray(filter) && isName(filter[0])) {
  37601. filterName = filter[0].name;
  37602. }
  37603. var startPos = stream.pos, length, i, ii;
  37604. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37605. length = this.findDCTDecodeInlineStreamEnd(stream);
  37606. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37607. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37608. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37609. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37610. } else {
  37611. length = this.findDefaultInlineStreamEnd(stream);
  37612. }
  37613. var imageStream = stream.makeSubStream(startPos, length, dict);
  37614. var adler32;
  37615. if (length < MAX_LENGTH_TO_CACHE) {
  37616. var imageBytes = imageStream.getBytes();
  37617. imageStream.reset();
  37618. var a = 1;
  37619. var b = 0;
  37620. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37621. a += imageBytes[i] & 0xff;
  37622. b += a;
  37623. }
  37624. adler32 = b % 65521 << 16 | a % 65521;
  37625. if (this.imageCache.adler32 === adler32) {
  37626. this.buf2 = Cmd.get('EI');
  37627. this.shift();
  37628. this.imageCache[adler32].reset();
  37629. return this.imageCache[adler32];
  37630. }
  37631. }
  37632. if (cipherTransform) {
  37633. imageStream = cipherTransform.createStream(imageStream, length);
  37634. }
  37635. imageStream = this.filter(imageStream, dict, length);
  37636. imageStream.dict = dict;
  37637. if (adler32 !== undefined) {
  37638. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37639. this.imageCache[adler32] = imageStream;
  37640. }
  37641. this.buf2 = Cmd.get('EI');
  37642. this.shift();
  37643. return imageStream;
  37644. },
  37645. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37646. var lexer = this.lexer;
  37647. var stream = lexer.stream;
  37648. lexer.skipToNextLine();
  37649. var pos = stream.pos - 1;
  37650. var length = dict.get('Length');
  37651. if (!isInt(length)) {
  37652. info('Bad ' + length + ' attribute in stream');
  37653. length = 0;
  37654. }
  37655. stream.pos = pos + length;
  37656. lexer.nextChar();
  37657. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37658. this.shift();
  37659. } else
  37660. {
  37661. stream.pos = pos;
  37662. var SCAN_BLOCK_SIZE = 2048;
  37663. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37664. var ENDSTREAM_SIGNATURE = [
  37665. 0x65,
  37666. 0x6E,
  37667. 0x64,
  37668. 0x73,
  37669. 0x74,
  37670. 0x72,
  37671. 0x65,
  37672. 0x61,
  37673. 0x6D
  37674. ];
  37675. var skipped = 0, found = false, i, j;
  37676. while (stream.pos < stream.end) {
  37677. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37678. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37679. if (scanLength <= 0) {
  37680. break;
  37681. }
  37682. found = false;
  37683. i = 0;
  37684. while (i < scanLength) {
  37685. j = 0;
  37686. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37687. j++;
  37688. }
  37689. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37690. found = true;
  37691. break;
  37692. }
  37693. i++;
  37694. }
  37695. if (found) {
  37696. skipped += i;
  37697. stream.pos += i;
  37698. break;
  37699. }
  37700. skipped += scanLength;
  37701. stream.pos += scanLength;
  37702. }
  37703. if (!found) {
  37704. error('Missing endstream');
  37705. }
  37706. length = skipped;
  37707. lexer.nextChar();
  37708. this.shift();
  37709. this.shift();
  37710. }
  37711. this.shift();
  37712. stream = stream.makeSubStream(pos, length, dict);
  37713. if (cipherTransform) {
  37714. stream = cipherTransform.createStream(stream, length);
  37715. }
  37716. stream = this.filter(stream, dict, length);
  37717. stream.dict = dict;
  37718. return stream;
  37719. },
  37720. filter: function Parser_filter(stream, dict, length) {
  37721. var filter = dict.get('Filter', 'F');
  37722. var params = dict.get('DecodeParms', 'DP');
  37723. if (isName(filter)) {
  37724. if (isArray(params)) {
  37725. params = params[0];
  37726. }
  37727. return this.makeFilter(stream, filter.name, length, params);
  37728. }
  37729. var maybeLength = length;
  37730. if (isArray(filter)) {
  37731. var filterArray = filter;
  37732. var paramsArray = params;
  37733. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37734. filter = filterArray[i];
  37735. if (!isName(filter)) {
  37736. error('Bad filter name: ' + filter);
  37737. }
  37738. params = null;
  37739. if (isArray(paramsArray) && i in paramsArray) {
  37740. params = paramsArray[i];
  37741. }
  37742. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37743. maybeLength = null;
  37744. }
  37745. }
  37746. return stream;
  37747. },
  37748. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37749. if (maybeLength === 0) {
  37750. warn('Empty "' + name + '" stream.');
  37751. return new NullStream(stream);
  37752. }
  37753. try {
  37754. if (params && this.xref) {
  37755. params = this.xref.fetchIfRef(params);
  37756. }
  37757. var xrefStreamStats = this.xref.stats.streamTypes;
  37758. if (name === 'FlateDecode' || name === 'Fl') {
  37759. xrefStreamStats[StreamType.FLATE] = true;
  37760. if (params) {
  37761. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37762. }
  37763. return new FlateStream(stream, maybeLength);
  37764. }
  37765. if (name === 'LZWDecode' || name === 'LZW') {
  37766. xrefStreamStats[StreamType.LZW] = true;
  37767. var earlyChange = 1;
  37768. if (params) {
  37769. if (params.has('EarlyChange')) {
  37770. earlyChange = params.get('EarlyChange');
  37771. }
  37772. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37773. }
  37774. return new LZWStream(stream, maybeLength, earlyChange);
  37775. }
  37776. if (name === 'DCTDecode' || name === 'DCT') {
  37777. xrefStreamStats[StreamType.DCT] = true;
  37778. return new JpegStream(stream, maybeLength, stream.dict, params);
  37779. }
  37780. if (name === 'JPXDecode' || name === 'JPX') {
  37781. xrefStreamStats[StreamType.JPX] = true;
  37782. return new JpxStream(stream, maybeLength, stream.dict, params);
  37783. }
  37784. if (name === 'ASCII85Decode' || name === 'A85') {
  37785. xrefStreamStats[StreamType.A85] = true;
  37786. return new Ascii85Stream(stream, maybeLength);
  37787. }
  37788. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37789. xrefStreamStats[StreamType.AHX] = true;
  37790. return new AsciiHexStream(stream, maybeLength);
  37791. }
  37792. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37793. xrefStreamStats[StreamType.CCF] = true;
  37794. return new CCITTFaxStream(stream, maybeLength, params);
  37795. }
  37796. if (name === 'RunLengthDecode' || name === 'RL') {
  37797. xrefStreamStats[StreamType.RL] = true;
  37798. return new RunLengthStream(stream, maybeLength);
  37799. }
  37800. if (name === 'JBIG2Decode') {
  37801. xrefStreamStats[StreamType.JBIG] = true;
  37802. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37803. }
  37804. warn('filter "' + name + '" not supported yet');
  37805. return stream;
  37806. } catch (ex) {
  37807. if (ex instanceof MissingDataException) {
  37808. throw ex;
  37809. }
  37810. warn('Invalid stream: \"' + ex + '\"');
  37811. return new NullStream(stream);
  37812. }
  37813. }
  37814. };
  37815. return Parser;
  37816. }();
  37817. var Lexer = function LexerClosure() {
  37818. function Lexer(stream, knownCommands) {
  37819. this.stream = stream;
  37820. this.nextChar();
  37821. this.strBuf = [];
  37822. this.knownCommands = knownCommands;
  37823. }
  37824. var specialChars = [
  37825. 1,
  37826. 0,
  37827. 0,
  37828. 0,
  37829. 0,
  37830. 0,
  37831. 0,
  37832. 0,
  37833. 0,
  37834. 1,
  37835. 1,
  37836. 0,
  37837. 1,
  37838. 1,
  37839. 0,
  37840. 0,
  37841. 0,
  37842. 0,
  37843. 0,
  37844. 0,
  37845. 0,
  37846. 0,
  37847. 0,
  37848. 0,
  37849. 0,
  37850. 0,
  37851. 0,
  37852. 0,
  37853. 0,
  37854. 0,
  37855. 0,
  37856. 0,
  37857. 1,
  37858. 0,
  37859. 0,
  37860. 0,
  37861. 0,
  37862. 2,
  37863. 0,
  37864. 0,
  37865. 2,
  37866. 2,
  37867. 0,
  37868. 0,
  37869. 0,
  37870. 0,
  37871. 0,
  37872. 2,
  37873. 0,
  37874. 0,
  37875. 0,
  37876. 0,
  37877. 0,
  37878. 0,
  37879. 0,
  37880. 0,
  37881. 0,
  37882. 0,
  37883. 0,
  37884. 0,
  37885. 2,
  37886. 0,
  37887. 2,
  37888. 0,
  37889. 0,
  37890. 0,
  37891. 0,
  37892. 0,
  37893. 0,
  37894. 0,
  37895. 0,
  37896. 0,
  37897. 0,
  37898. 0,
  37899. 0,
  37900. 0,
  37901. 0,
  37902. 0,
  37903. 0,
  37904. 0,
  37905. 0,
  37906. 0,
  37907. 0,
  37908. 0,
  37909. 0,
  37910. 0,
  37911. 0,
  37912. 0,
  37913. 0,
  37914. 0,
  37915. 0,
  37916. 2,
  37917. 0,
  37918. 2,
  37919. 0,
  37920. 0,
  37921. 0,
  37922. 0,
  37923. 0,
  37924. 0,
  37925. 0,
  37926. 0,
  37927. 0,
  37928. 0,
  37929. 0,
  37930. 0,
  37931. 0,
  37932. 0,
  37933. 0,
  37934. 0,
  37935. 0,
  37936. 0,
  37937. 0,
  37938. 0,
  37939. 0,
  37940. 0,
  37941. 0,
  37942. 0,
  37943. 0,
  37944. 0,
  37945. 0,
  37946. 0,
  37947. 0,
  37948. 2,
  37949. 0,
  37950. 2,
  37951. 0,
  37952. 0,
  37953. 0,
  37954. 0,
  37955. 0,
  37956. 0,
  37957. 0,
  37958. 0,
  37959. 0,
  37960. 0,
  37961. 0,
  37962. 0,
  37963. 0,
  37964. 0,
  37965. 0,
  37966. 0,
  37967. 0,
  37968. 0,
  37969. 0,
  37970. 0,
  37971. 0,
  37972. 0,
  37973. 0,
  37974. 0,
  37975. 0,
  37976. 0,
  37977. 0,
  37978. 0,
  37979. 0,
  37980. 0,
  37981. 0,
  37982. 0,
  37983. 0,
  37984. 0,
  37985. 0,
  37986. 0,
  37987. 0,
  37988. 0,
  37989. 0,
  37990. 0,
  37991. 0,
  37992. 0,
  37993. 0,
  37994. 0,
  37995. 0,
  37996. 0,
  37997. 0,
  37998. 0,
  37999. 0,
  38000. 0,
  38001. 0,
  38002. 0,
  38003. 0,
  38004. 0,
  38005. 0,
  38006. 0,
  38007. 0,
  38008. 0,
  38009. 0,
  38010. 0,
  38011. 0,
  38012. 0,
  38013. 0,
  38014. 0,
  38015. 0,
  38016. 0,
  38017. 0,
  38018. 0,
  38019. 0,
  38020. 0,
  38021. 0,
  38022. 0,
  38023. 0,
  38024. 0,
  38025. 0,
  38026. 0,
  38027. 0,
  38028. 0,
  38029. 0,
  38030. 0,
  38031. 0,
  38032. 0,
  38033. 0,
  38034. 0,
  38035. 0,
  38036. 0,
  38037. 0,
  38038. 0,
  38039. 0,
  38040. 0,
  38041. 0,
  38042. 0,
  38043. 0,
  38044. 0,
  38045. 0,
  38046. 0,
  38047. 0,
  38048. 0,
  38049. 0,
  38050. 0,
  38051. 0,
  38052. 0,
  38053. 0,
  38054. 0,
  38055. 0,
  38056. 0,
  38057. 0,
  38058. 0,
  38059. 0,
  38060. 0,
  38061. 0,
  38062. 0,
  38063. 0,
  38064. 0,
  38065. 0,
  38066. 0,
  38067. 0,
  38068. 0,
  38069. 0,
  38070. 0,
  38071. 0,
  38072. 0,
  38073. 0,
  38074. 0,
  38075. 0,
  38076. 0,
  38077. 0,
  38078. 0,
  38079. 0,
  38080. 0
  38081. ];
  38082. function toHexDigit(ch) {
  38083. if (ch >= 0x30 && ch <= 0x39) {
  38084. return ch & 0x0F;
  38085. }
  38086. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38087. return (ch & 0x0F) + 9;
  38088. }
  38089. return -1;
  38090. }
  38091. Lexer.prototype = {
  38092. nextChar: function Lexer_nextChar() {
  38093. return this.currentChar = this.stream.getByte();
  38094. },
  38095. peekChar: function Lexer_peekChar() {
  38096. return this.stream.peekByte();
  38097. },
  38098. getNumber: function Lexer_getNumber() {
  38099. var ch = this.currentChar;
  38100. var eNotation = false;
  38101. var divideBy = 0;
  38102. var sign = 1;
  38103. if (ch === 0x2D) {
  38104. sign = -1;
  38105. ch = this.nextChar();
  38106. if (ch === 0x2D) {
  38107. ch = this.nextChar();
  38108. }
  38109. } else if (ch === 0x2B) {
  38110. ch = this.nextChar();
  38111. }
  38112. if (ch === 0x2E) {
  38113. divideBy = 10;
  38114. ch = this.nextChar();
  38115. }
  38116. if (ch < 0x30 || ch > 0x39) {
  38117. error('Invalid number: ' + String.fromCharCode(ch));
  38118. return 0;
  38119. }
  38120. var baseValue = ch - 0x30;
  38121. var powerValue = 0;
  38122. var powerValueSign = 1;
  38123. while ((ch = this.nextChar()) >= 0) {
  38124. if (0x30 <= ch && ch <= 0x39) {
  38125. var currentDigit = ch - 0x30;
  38126. if (eNotation) {
  38127. powerValue = powerValue * 10 + currentDigit;
  38128. } else {
  38129. if (divideBy !== 0) {
  38130. divideBy *= 10;
  38131. }
  38132. baseValue = baseValue * 10 + currentDigit;
  38133. }
  38134. } else if (ch === 0x2E) {
  38135. if (divideBy === 0) {
  38136. divideBy = 1;
  38137. } else {
  38138. break;
  38139. }
  38140. } else if (ch === 0x2D) {
  38141. warn('Badly formatted number');
  38142. } else if (ch === 0x45 || ch === 0x65) {
  38143. ch = this.peekChar();
  38144. if (ch === 0x2B || ch === 0x2D) {
  38145. powerValueSign = ch === 0x2D ? -1 : 1;
  38146. this.nextChar();
  38147. } else if (ch < 0x30 || ch > 0x39) {
  38148. break;
  38149. }
  38150. eNotation = true;
  38151. } else {
  38152. break;
  38153. }
  38154. }
  38155. if (divideBy !== 0) {
  38156. baseValue /= divideBy;
  38157. }
  38158. if (eNotation) {
  38159. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38160. }
  38161. return sign * baseValue;
  38162. },
  38163. getString: function Lexer_getString() {
  38164. var numParen = 1;
  38165. var done = false;
  38166. var strBuf = this.strBuf;
  38167. strBuf.length = 0;
  38168. var ch = this.nextChar();
  38169. while (true) {
  38170. var charBuffered = false;
  38171. switch (ch | 0) {
  38172. case -1:
  38173. warn('Unterminated string');
  38174. done = true;
  38175. break;
  38176. case 0x28:
  38177. ++numParen;
  38178. strBuf.push('(');
  38179. break;
  38180. case 0x29:
  38181. if (--numParen === 0) {
  38182. this.nextChar();
  38183. done = true;
  38184. } else {
  38185. strBuf.push(')');
  38186. }
  38187. break;
  38188. case 0x5C:
  38189. ch = this.nextChar();
  38190. switch (ch) {
  38191. case -1:
  38192. warn('Unterminated string');
  38193. done = true;
  38194. break;
  38195. case 0x6E:
  38196. strBuf.push('\n');
  38197. break;
  38198. case 0x72:
  38199. strBuf.push('\r');
  38200. break;
  38201. case 0x74:
  38202. strBuf.push('\t');
  38203. break;
  38204. case 0x62:
  38205. strBuf.push('\b');
  38206. break;
  38207. case 0x66:
  38208. strBuf.push('\f');
  38209. break;
  38210. case 0x5C:
  38211. case 0x28:
  38212. case 0x29:
  38213. strBuf.push(String.fromCharCode(ch));
  38214. break;
  38215. case 0x30:
  38216. case 0x31:
  38217. case 0x32:
  38218. case 0x33:
  38219. case 0x34:
  38220. case 0x35:
  38221. case 0x36:
  38222. case 0x37:
  38223. var x = ch & 0x0F;
  38224. ch = this.nextChar();
  38225. charBuffered = true;
  38226. if (ch >= 0x30 && ch <= 0x37) {
  38227. x = (x << 3) + (ch & 0x0F);
  38228. ch = this.nextChar();
  38229. if (ch >= 0x30 && ch <= 0x37) {
  38230. charBuffered = false;
  38231. x = (x << 3) + (ch & 0x0F);
  38232. }
  38233. }
  38234. strBuf.push(String.fromCharCode(x));
  38235. break;
  38236. case 0x0D:
  38237. if (this.peekChar() === 0x0A) {
  38238. this.nextChar();
  38239. }
  38240. break;
  38241. case 0x0A:
  38242. break;
  38243. default:
  38244. strBuf.push(String.fromCharCode(ch));
  38245. break;
  38246. }
  38247. break;
  38248. default:
  38249. strBuf.push(String.fromCharCode(ch));
  38250. break;
  38251. }
  38252. if (done) {
  38253. break;
  38254. }
  38255. if (!charBuffered) {
  38256. ch = this.nextChar();
  38257. }
  38258. }
  38259. return strBuf.join('');
  38260. },
  38261. getName: function Lexer_getName() {
  38262. var ch, previousCh;
  38263. var strBuf = this.strBuf;
  38264. strBuf.length = 0;
  38265. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38266. if (ch === 0x23) {
  38267. ch = this.nextChar();
  38268. if (specialChars[ch]) {
  38269. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38270. strBuf.push('#');
  38271. break;
  38272. }
  38273. var x = toHexDigit(ch);
  38274. if (x !== -1) {
  38275. previousCh = ch;
  38276. ch = this.nextChar();
  38277. var x2 = toHexDigit(ch);
  38278. if (x2 === -1) {
  38279. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38280. strBuf.push('#', String.fromCharCode(previousCh));
  38281. if (specialChars[ch]) {
  38282. break;
  38283. }
  38284. strBuf.push(String.fromCharCode(ch));
  38285. continue;
  38286. }
  38287. strBuf.push(String.fromCharCode(x << 4 | x2));
  38288. } else {
  38289. strBuf.push('#', String.fromCharCode(ch));
  38290. }
  38291. } else {
  38292. strBuf.push(String.fromCharCode(ch));
  38293. }
  38294. }
  38295. if (strBuf.length > 127) {
  38296. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38297. }
  38298. return Name.get(strBuf.join(''));
  38299. },
  38300. getHexString: function Lexer_getHexString() {
  38301. var strBuf = this.strBuf;
  38302. strBuf.length = 0;
  38303. var ch = this.currentChar;
  38304. var isFirstHex = true;
  38305. var firstDigit;
  38306. var secondDigit;
  38307. while (true) {
  38308. if (ch < 0) {
  38309. warn('Unterminated hex string');
  38310. break;
  38311. } else if (ch === 0x3E) {
  38312. this.nextChar();
  38313. break;
  38314. } else if (specialChars[ch] === 1) {
  38315. ch = this.nextChar();
  38316. continue;
  38317. } else {
  38318. if (isFirstHex) {
  38319. firstDigit = toHexDigit(ch);
  38320. if (firstDigit === -1) {
  38321. warn('Ignoring invalid character "' + ch + '" in hex string');
  38322. ch = this.nextChar();
  38323. continue;
  38324. }
  38325. } else {
  38326. secondDigit = toHexDigit(ch);
  38327. if (secondDigit === -1) {
  38328. warn('Ignoring invalid character "' + ch + '" in hex string');
  38329. ch = this.nextChar();
  38330. continue;
  38331. }
  38332. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38333. }
  38334. isFirstHex = !isFirstHex;
  38335. ch = this.nextChar();
  38336. }
  38337. }
  38338. return strBuf.join('');
  38339. },
  38340. getObj: function Lexer_getObj() {
  38341. var comment = false;
  38342. var ch = this.currentChar;
  38343. while (true) {
  38344. if (ch < 0) {
  38345. return EOF;
  38346. }
  38347. if (comment) {
  38348. if (ch === 0x0A || ch === 0x0D) {
  38349. comment = false;
  38350. }
  38351. } else if (ch === 0x25) {
  38352. comment = true;
  38353. } else if (specialChars[ch] !== 1) {
  38354. break;
  38355. }
  38356. ch = this.nextChar();
  38357. }
  38358. switch (ch | 0) {
  38359. case 0x30:
  38360. case 0x31:
  38361. case 0x32:
  38362. case 0x33:
  38363. case 0x34:
  38364. case 0x35:
  38365. case 0x36:
  38366. case 0x37:
  38367. case 0x38:
  38368. case 0x39:
  38369. case 0x2B:
  38370. case 0x2D:
  38371. case 0x2E:
  38372. return this.getNumber();
  38373. case 0x28:
  38374. return this.getString();
  38375. case 0x2F:
  38376. return this.getName();
  38377. case 0x5B:
  38378. this.nextChar();
  38379. return Cmd.get('[');
  38380. case 0x5D:
  38381. this.nextChar();
  38382. return Cmd.get(']');
  38383. case 0x3C:
  38384. ch = this.nextChar();
  38385. if (ch === 0x3C) {
  38386. this.nextChar();
  38387. return Cmd.get('<<');
  38388. }
  38389. return this.getHexString();
  38390. case 0x3E:
  38391. ch = this.nextChar();
  38392. if (ch === 0x3E) {
  38393. this.nextChar();
  38394. return Cmd.get('>>');
  38395. }
  38396. return Cmd.get('>');
  38397. case 0x7B:
  38398. this.nextChar();
  38399. return Cmd.get('{');
  38400. case 0x7D:
  38401. this.nextChar();
  38402. return Cmd.get('}');
  38403. case 0x29:
  38404. error('Illegal character: ' + ch);
  38405. break;
  38406. }
  38407. var str = String.fromCharCode(ch);
  38408. var knownCommands = this.knownCommands;
  38409. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38410. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38411. var possibleCommand = str + String.fromCharCode(ch);
  38412. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38413. break;
  38414. }
  38415. if (str.length === 128) {
  38416. error('Command token too long: ' + str.length);
  38417. }
  38418. str = possibleCommand;
  38419. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38420. }
  38421. if (str === 'true') {
  38422. return true;
  38423. }
  38424. if (str === 'false') {
  38425. return false;
  38426. }
  38427. if (str === 'null') {
  38428. return null;
  38429. }
  38430. return Cmd.get(str);
  38431. },
  38432. skipToNextLine: function Lexer_skipToNextLine() {
  38433. var ch = this.currentChar;
  38434. while (ch >= 0) {
  38435. if (ch === 0x0D) {
  38436. ch = this.nextChar();
  38437. if (ch === 0x0A) {
  38438. this.nextChar();
  38439. }
  38440. break;
  38441. } else if (ch === 0x0A) {
  38442. this.nextChar();
  38443. break;
  38444. }
  38445. ch = this.nextChar();
  38446. }
  38447. }
  38448. };
  38449. return Lexer;
  38450. }();
  38451. var Linearization = {
  38452. create: function LinearizationCreate(stream) {
  38453. function getInt(name, allowZeroValue) {
  38454. var obj = linDict.get(name);
  38455. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38456. return obj;
  38457. }
  38458. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38459. }
  38460. function getHints() {
  38461. var hints = linDict.get('H'), hintsLength, item;
  38462. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38463. for (var index = 0; index < hintsLength; index++) {
  38464. if (!(isInt(item = hints[index]) && item > 0)) {
  38465. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38466. }
  38467. }
  38468. return hints;
  38469. }
  38470. throw new Error('Hint array in the linearization dictionary is invalid.');
  38471. }
  38472. var parser = new Parser(new Lexer(stream), false, null);
  38473. var obj1 = parser.getObj();
  38474. var obj2 = parser.getObj();
  38475. var obj3 = parser.getObj();
  38476. var linDict = parser.getObj();
  38477. var obj, length;
  38478. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38479. return null;
  38480. } else if ((length = getInt('L')) !== stream.length) {
  38481. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38482. }
  38483. return {
  38484. length: length,
  38485. hints: getHints(),
  38486. objectNumberFirst: getInt('O'),
  38487. endFirst: getInt('E'),
  38488. numPages: getInt('N'),
  38489. mainXRefEntriesOffset: getInt('T'),
  38490. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38491. };
  38492. }
  38493. };
  38494. exports.EOF = EOF;
  38495. exports.Lexer = Lexer;
  38496. exports.Linearization = Linearization;
  38497. exports.Parser = Parser;
  38498. exports.isEOF = isEOF;
  38499. }));
  38500. (function (root, factory) {
  38501. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38502. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38503. var warn = sharedUtil.warn;
  38504. var isSpace = sharedUtil.isSpace;
  38505. var Stream = coreStream.Stream;
  38506. var getEncoding = coreEncodings.getEncoding;
  38507. var HINTING_ENABLED = false;
  38508. var Type1CharString = function Type1CharStringClosure() {
  38509. var COMMAND_MAP = {
  38510. 'hstem': [1],
  38511. 'vstem': [3],
  38512. 'vmoveto': [4],
  38513. 'rlineto': [5],
  38514. 'hlineto': [6],
  38515. 'vlineto': [7],
  38516. 'rrcurveto': [8],
  38517. 'callsubr': [10],
  38518. 'flex': [
  38519. 12,
  38520. 35
  38521. ],
  38522. 'drop': [
  38523. 12,
  38524. 18
  38525. ],
  38526. 'endchar': [14],
  38527. 'rmoveto': [21],
  38528. 'hmoveto': [22],
  38529. 'vhcurveto': [30],
  38530. 'hvcurveto': [31]
  38531. };
  38532. function Type1CharString() {
  38533. this.width = 0;
  38534. this.lsb = 0;
  38535. this.flexing = false;
  38536. this.output = [];
  38537. this.stack = [];
  38538. }
  38539. Type1CharString.prototype = {
  38540. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38541. var count = encoded.length;
  38542. var error = false;
  38543. var wx, sbx, subrNumber;
  38544. for (var i = 0; i < count; i++) {
  38545. var value = encoded[i];
  38546. if (value < 32) {
  38547. if (value === 12) {
  38548. value = (value << 8) + encoded[++i];
  38549. }
  38550. switch (value) {
  38551. case 1:
  38552. if (!HINTING_ENABLED) {
  38553. this.stack = [];
  38554. break;
  38555. }
  38556. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38557. break;
  38558. case 3:
  38559. if (!HINTING_ENABLED) {
  38560. this.stack = [];
  38561. break;
  38562. }
  38563. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38564. break;
  38565. case 4:
  38566. if (this.flexing) {
  38567. if (this.stack.length < 1) {
  38568. error = true;
  38569. break;
  38570. }
  38571. var dy = this.stack.pop();
  38572. this.stack.push(0, dy);
  38573. break;
  38574. }
  38575. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38576. break;
  38577. case 5:
  38578. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38579. break;
  38580. case 6:
  38581. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38582. break;
  38583. case 7:
  38584. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38585. break;
  38586. case 8:
  38587. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38588. break;
  38589. case 9:
  38590. this.stack = [];
  38591. break;
  38592. case 10:
  38593. if (this.stack.length < 1) {
  38594. error = true;
  38595. break;
  38596. }
  38597. subrNumber = this.stack.pop();
  38598. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38599. break;
  38600. case 11:
  38601. return error;
  38602. case 13:
  38603. if (this.stack.length < 2) {
  38604. error = true;
  38605. break;
  38606. }
  38607. wx = this.stack.pop();
  38608. sbx = this.stack.pop();
  38609. this.lsb = sbx;
  38610. this.width = wx;
  38611. this.stack.push(wx, sbx);
  38612. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38613. break;
  38614. case 14:
  38615. this.output.push(COMMAND_MAP.endchar[0]);
  38616. break;
  38617. case 21:
  38618. if (this.flexing) {
  38619. break;
  38620. }
  38621. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38622. break;
  38623. case 22:
  38624. if (this.flexing) {
  38625. this.stack.push(0);
  38626. break;
  38627. }
  38628. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38629. break;
  38630. case 30:
  38631. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38632. break;
  38633. case 31:
  38634. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38635. break;
  38636. case (12 << 8) + 0:
  38637. this.stack = [];
  38638. break;
  38639. case (12 << 8) + 1:
  38640. if (!HINTING_ENABLED) {
  38641. this.stack = [];
  38642. break;
  38643. }
  38644. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38645. break;
  38646. case (12 << 8) + 2:
  38647. if (!HINTING_ENABLED) {
  38648. this.stack = [];
  38649. break;
  38650. }
  38651. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38652. break;
  38653. case (12 << 8) + 6:
  38654. if (seacAnalysisEnabled) {
  38655. this.seac = this.stack.splice(-4, 4);
  38656. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38657. } else {
  38658. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38659. }
  38660. break;
  38661. case (12 << 8) + 7:
  38662. if (this.stack.length < 4) {
  38663. error = true;
  38664. break;
  38665. }
  38666. var wy = this.stack.pop();
  38667. wx = this.stack.pop();
  38668. var sby = this.stack.pop();
  38669. sbx = this.stack.pop();
  38670. this.lsb = sbx;
  38671. this.width = wx;
  38672. this.stack.push(wx, sbx, sby);
  38673. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38674. break;
  38675. case (12 << 8) + 12:
  38676. if (this.stack.length < 2) {
  38677. error = true;
  38678. break;
  38679. }
  38680. var num2 = this.stack.pop();
  38681. var num1 = this.stack.pop();
  38682. this.stack.push(num1 / num2);
  38683. break;
  38684. case (12 << 8) + 16:
  38685. if (this.stack.length < 2) {
  38686. error = true;
  38687. break;
  38688. }
  38689. subrNumber = this.stack.pop();
  38690. var numArgs = this.stack.pop();
  38691. if (subrNumber === 0 && numArgs === 3) {
  38692. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38693. 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]);
  38694. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38695. this.flexing = false;
  38696. this.stack.push(flexArgs[15], flexArgs[16]);
  38697. } else if (subrNumber === 1 && numArgs === 0) {
  38698. this.flexing = true;
  38699. }
  38700. break;
  38701. case (12 << 8) + 17:
  38702. break;
  38703. case (12 << 8) + 33:
  38704. this.stack = [];
  38705. break;
  38706. default:
  38707. warn('Unknown type 1 charstring command of "' + value + '"');
  38708. break;
  38709. }
  38710. if (error) {
  38711. break;
  38712. }
  38713. continue;
  38714. } else if (value <= 246) {
  38715. value = value - 139;
  38716. } else if (value <= 250) {
  38717. value = (value - 247) * 256 + encoded[++i] + 108;
  38718. } else if (value <= 254) {
  38719. value = -((value - 251) * 256) - encoded[++i] - 108;
  38720. } else {
  38721. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38722. }
  38723. this.stack.push(value);
  38724. }
  38725. return error;
  38726. },
  38727. executeCommand: function (howManyArgs, command, keepStack) {
  38728. var stackLength = this.stack.length;
  38729. if (howManyArgs > stackLength) {
  38730. return true;
  38731. }
  38732. var start = stackLength - howManyArgs;
  38733. for (var i = start; i < stackLength; i++) {
  38734. var value = this.stack[i];
  38735. if (value === (value | 0)) {
  38736. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38737. } else {
  38738. value = 65536 * value | 0;
  38739. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38740. }
  38741. }
  38742. this.output.push.apply(this.output, command);
  38743. if (keepStack) {
  38744. this.stack.splice(start, howManyArgs);
  38745. } else {
  38746. this.stack.length = 0;
  38747. }
  38748. return false;
  38749. }
  38750. };
  38751. return Type1CharString;
  38752. }();
  38753. var Type1Parser = function Type1ParserClosure() {
  38754. var EEXEC_ENCRYPT_KEY = 55665;
  38755. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38756. function isHexDigit(code) {
  38757. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38758. }
  38759. function decrypt(data, key, discardNumber) {
  38760. if (discardNumber >= data.length) {
  38761. return new Uint8Array(0);
  38762. }
  38763. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38764. for (i = 0; i < discardNumber; i++) {
  38765. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38766. }
  38767. var count = data.length - discardNumber;
  38768. var decrypted = new Uint8Array(count);
  38769. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38770. var value = data[i];
  38771. decrypted[j] = value ^ r >> 8;
  38772. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38773. }
  38774. return decrypted;
  38775. }
  38776. function decryptAscii(data, key, discardNumber) {
  38777. var r = key | 0, c1 = 52845, c2 = 22719;
  38778. var count = data.length, maybeLength = count >>> 1;
  38779. var decrypted = new Uint8Array(maybeLength);
  38780. var i, j;
  38781. for (i = 0, j = 0; i < count; i++) {
  38782. var digit1 = data[i];
  38783. if (!isHexDigit(digit1)) {
  38784. continue;
  38785. }
  38786. i++;
  38787. var digit2;
  38788. while (i < count && !isHexDigit(digit2 = data[i])) {
  38789. i++;
  38790. }
  38791. if (i < count) {
  38792. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38793. decrypted[j++] = value ^ r >> 8;
  38794. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38795. }
  38796. }
  38797. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38798. }
  38799. function isSpecial(c) {
  38800. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38801. }
  38802. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38803. if (encrypted) {
  38804. var data = stream.getBytes();
  38805. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38806. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38807. }
  38808. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38809. this.stream = stream;
  38810. this.nextChar();
  38811. }
  38812. Type1Parser.prototype = {
  38813. readNumberArray: function Type1Parser_readNumberArray() {
  38814. this.getToken();
  38815. var array = [];
  38816. while (true) {
  38817. var token = this.getToken();
  38818. if (token === null || token === ']' || token === '}') {
  38819. break;
  38820. }
  38821. array.push(parseFloat(token || 0));
  38822. }
  38823. return array;
  38824. },
  38825. readNumber: function Type1Parser_readNumber() {
  38826. var token = this.getToken();
  38827. return parseFloat(token || 0);
  38828. },
  38829. readInt: function Type1Parser_readInt() {
  38830. var token = this.getToken();
  38831. return parseInt(token || 0, 10) | 0;
  38832. },
  38833. readBoolean: function Type1Parser_readBoolean() {
  38834. var token = this.getToken();
  38835. return token === 'true' ? 1 : 0;
  38836. },
  38837. nextChar: function Type1_nextChar() {
  38838. return this.currentChar = this.stream.getByte();
  38839. },
  38840. getToken: function Type1Parser_getToken() {
  38841. var comment = false;
  38842. var ch = this.currentChar;
  38843. while (true) {
  38844. if (ch === -1) {
  38845. return null;
  38846. }
  38847. if (comment) {
  38848. if (ch === 0x0A || ch === 0x0D) {
  38849. comment = false;
  38850. }
  38851. } else if (ch === 0x25) {
  38852. comment = true;
  38853. } else if (!isSpace(ch)) {
  38854. break;
  38855. }
  38856. ch = this.nextChar();
  38857. }
  38858. if (isSpecial(ch)) {
  38859. this.nextChar();
  38860. return String.fromCharCode(ch);
  38861. }
  38862. var token = '';
  38863. do {
  38864. token += String.fromCharCode(ch);
  38865. ch = this.nextChar();
  38866. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  38867. return token;
  38868. },
  38869. extractFontProgram: function Type1Parser_extractFontProgram() {
  38870. var stream = this.stream;
  38871. var subrs = [], charstrings = [];
  38872. var privateData = Object.create(null);
  38873. privateData['lenIV'] = 4;
  38874. var program = {
  38875. subrs: [],
  38876. charstrings: [],
  38877. properties: { 'privateData': privateData }
  38878. };
  38879. var token, length, data, lenIV, encoded;
  38880. while ((token = this.getToken()) !== null) {
  38881. if (token !== '/') {
  38882. continue;
  38883. }
  38884. token = this.getToken();
  38885. switch (token) {
  38886. case 'CharStrings':
  38887. this.getToken();
  38888. this.getToken();
  38889. this.getToken();
  38890. this.getToken();
  38891. while (true) {
  38892. token = this.getToken();
  38893. if (token === null || token === 'end') {
  38894. break;
  38895. }
  38896. if (token !== '/') {
  38897. continue;
  38898. }
  38899. var glyph = this.getToken();
  38900. length = this.readInt();
  38901. this.getToken();
  38902. data = stream.makeSubStream(stream.pos, length);
  38903. lenIV = program.properties.privateData['lenIV'];
  38904. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38905. stream.skip(length);
  38906. this.nextChar();
  38907. token = this.getToken();
  38908. if (token === 'noaccess') {
  38909. this.getToken();
  38910. }
  38911. charstrings.push({
  38912. glyph: glyph,
  38913. encoded: encoded
  38914. });
  38915. }
  38916. break;
  38917. case 'Subrs':
  38918. var num = this.readInt();
  38919. this.getToken();
  38920. while ((token = this.getToken()) === 'dup') {
  38921. var index = this.readInt();
  38922. length = this.readInt();
  38923. this.getToken();
  38924. data = stream.makeSubStream(stream.pos, length);
  38925. lenIV = program.properties.privateData['lenIV'];
  38926. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38927. stream.skip(length);
  38928. this.nextChar();
  38929. token = this.getToken();
  38930. if (token === 'noaccess') {
  38931. this.getToken();
  38932. }
  38933. subrs[index] = encoded;
  38934. }
  38935. break;
  38936. case 'BlueValues':
  38937. case 'OtherBlues':
  38938. case 'FamilyBlues':
  38939. case 'FamilyOtherBlues':
  38940. var blueArray = this.readNumberArray();
  38941. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  38942. program.properties.privateData[token] = blueArray;
  38943. }
  38944. break;
  38945. case 'StemSnapH':
  38946. case 'StemSnapV':
  38947. program.properties.privateData[token] = this.readNumberArray();
  38948. break;
  38949. case 'StdHW':
  38950. case 'StdVW':
  38951. program.properties.privateData[token] = this.readNumberArray()[0];
  38952. break;
  38953. case 'BlueShift':
  38954. case 'lenIV':
  38955. case 'BlueFuzz':
  38956. case 'BlueScale':
  38957. case 'LanguageGroup':
  38958. case 'ExpansionFactor':
  38959. program.properties.privateData[token] = this.readNumber();
  38960. break;
  38961. case 'ForceBold':
  38962. program.properties.privateData[token] = this.readBoolean();
  38963. break;
  38964. }
  38965. }
  38966. for (var i = 0; i < charstrings.length; i++) {
  38967. glyph = charstrings[i].glyph;
  38968. encoded = charstrings[i].encoded;
  38969. var charString = new Type1CharString();
  38970. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  38971. var output = charString.output;
  38972. if (error) {
  38973. output = [14];
  38974. }
  38975. program.charstrings.push({
  38976. glyphName: glyph,
  38977. charstring: output,
  38978. width: charString.width,
  38979. lsb: charString.lsb,
  38980. seac: charString.seac
  38981. });
  38982. }
  38983. return program;
  38984. },
  38985. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  38986. var token;
  38987. while ((token = this.getToken()) !== null) {
  38988. if (token !== '/') {
  38989. continue;
  38990. }
  38991. token = this.getToken();
  38992. switch (token) {
  38993. case 'FontMatrix':
  38994. var matrix = this.readNumberArray();
  38995. properties.fontMatrix = matrix;
  38996. break;
  38997. case 'Encoding':
  38998. var encodingArg = this.getToken();
  38999. var encoding;
  39000. if (!/^\d+$/.test(encodingArg)) {
  39001. encoding = getEncoding(encodingArg);
  39002. } else {
  39003. encoding = [];
  39004. var size = parseInt(encodingArg, 10) | 0;
  39005. this.getToken();
  39006. for (var j = 0; j < size; j++) {
  39007. token = this.getToken();
  39008. while (token !== 'dup' && token !== 'def') {
  39009. token = this.getToken();
  39010. if (token === null) {
  39011. return;
  39012. }
  39013. }
  39014. if (token === 'def') {
  39015. break;
  39016. }
  39017. var index = this.readInt();
  39018. this.getToken();
  39019. var glyph = this.getToken();
  39020. encoding[index] = glyph;
  39021. this.getToken();
  39022. }
  39023. }
  39024. properties.builtInEncoding = encoding;
  39025. break;
  39026. case 'FontBBox':
  39027. var fontBBox = this.readNumberArray();
  39028. properties.ascent = fontBBox[3];
  39029. properties.descent = fontBBox[1];
  39030. properties.ascentScaled = true;
  39031. break;
  39032. }
  39033. }
  39034. }
  39035. };
  39036. return Type1Parser;
  39037. }();
  39038. exports.Type1Parser = Type1Parser;
  39039. }));
  39040. (function (root, factory) {
  39041. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39042. }(this, function (exports, sharedUtil, displayWebGL) {
  39043. var Util = sharedUtil.Util;
  39044. var info = sharedUtil.info;
  39045. var isArray = sharedUtil.isArray;
  39046. var error = sharedUtil.error;
  39047. var WebGLUtils = displayWebGL.WebGLUtils;
  39048. var ShadingIRs = {};
  39049. ShadingIRs.RadialAxial = {
  39050. fromIR: function RadialAxial_fromIR(raw) {
  39051. var type = raw[1];
  39052. var colorStops = raw[2];
  39053. var p0 = raw[3];
  39054. var p1 = raw[4];
  39055. var r0 = raw[5];
  39056. var r1 = raw[6];
  39057. return {
  39058. type: 'Pattern',
  39059. getPattern: function RadialAxial_getPattern(ctx) {
  39060. var grad;
  39061. if (type === 'axial') {
  39062. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39063. } else if (type === 'radial') {
  39064. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39065. }
  39066. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39067. var c = colorStops[i];
  39068. grad.addColorStop(c[0], c[1]);
  39069. }
  39070. return grad;
  39071. }
  39072. };
  39073. }
  39074. };
  39075. var createMeshCanvas = function createMeshCanvasClosure() {
  39076. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39077. var coords = context.coords, colors = context.colors;
  39078. var bytes = data.data, rowSize = data.width * 4;
  39079. var tmp;
  39080. if (coords[p1 + 1] > coords[p2 + 1]) {
  39081. tmp = p1;
  39082. p1 = p2;
  39083. p2 = tmp;
  39084. tmp = c1;
  39085. c1 = c2;
  39086. c2 = tmp;
  39087. }
  39088. if (coords[p2 + 1] > coords[p3 + 1]) {
  39089. tmp = p2;
  39090. p2 = p3;
  39091. p3 = tmp;
  39092. tmp = c2;
  39093. c2 = c3;
  39094. c3 = tmp;
  39095. }
  39096. if (coords[p1 + 1] > coords[p2 + 1]) {
  39097. tmp = p1;
  39098. p1 = p2;
  39099. p2 = tmp;
  39100. tmp = c1;
  39101. c1 = c2;
  39102. c2 = tmp;
  39103. }
  39104. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39105. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39106. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39107. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39108. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39109. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39110. if (y1 >= y3) {
  39111. return;
  39112. }
  39113. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39114. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39115. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39116. var minY = Math.round(y1), maxY = Math.round(y3);
  39117. var xa, car, cag, cab;
  39118. var xb, cbr, cbg, cbb;
  39119. var k;
  39120. for (var y = minY; y <= maxY; y++) {
  39121. if (y < y2) {
  39122. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39123. xa = x1 - (x1 - x2) * k;
  39124. car = c1r - (c1r - c2r) * k;
  39125. cag = c1g - (c1g - c2g) * k;
  39126. cab = c1b - (c1b - c2b) * k;
  39127. } else {
  39128. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39129. xa = x2 - (x2 - x3) * k;
  39130. car = c2r - (c2r - c3r) * k;
  39131. cag = c2g - (c2g - c3g) * k;
  39132. cab = c2b - (c2b - c3b) * k;
  39133. }
  39134. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39135. xb = x1 - (x1 - x3) * k;
  39136. cbr = c1r - (c1r - c3r) * k;
  39137. cbg = c1g - (c1g - c3g) * k;
  39138. cbb = c1b - (c1b - c3b) * k;
  39139. var x1_ = Math.round(Math.min(xa, xb));
  39140. var x2_ = Math.round(Math.max(xa, xb));
  39141. var j = rowSize * y + x1_ * 4;
  39142. for (var x = x1_; x <= x2_; x++) {
  39143. k = (xa - x) / (xa - xb);
  39144. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39145. bytes[j++] = car - (car - cbr) * k | 0;
  39146. bytes[j++] = cag - (cag - cbg) * k | 0;
  39147. bytes[j++] = cab - (cab - cbb) * k | 0;
  39148. bytes[j++] = 255;
  39149. }
  39150. }
  39151. }
  39152. function drawFigure(data, figure, context) {
  39153. var ps = figure.coords;
  39154. var cs = figure.colors;
  39155. var i, ii;
  39156. switch (figure.type) {
  39157. case 'lattice':
  39158. var verticesPerRow = figure.verticesPerRow;
  39159. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39160. var cols = verticesPerRow - 1;
  39161. for (i = 0; i < rows; i++) {
  39162. var q = i * verticesPerRow;
  39163. for (var j = 0; j < cols; j++, q++) {
  39164. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39165. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39166. }
  39167. }
  39168. break;
  39169. case 'triangles':
  39170. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39171. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39172. }
  39173. break;
  39174. default:
  39175. error('illigal figure');
  39176. break;
  39177. }
  39178. }
  39179. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39180. var EXPECTED_SCALE = 1.1;
  39181. var MAX_PATTERN_SIZE = 3000;
  39182. var BORDER_SIZE = 2;
  39183. var offsetX = Math.floor(bounds[0]);
  39184. var offsetY = Math.floor(bounds[1]);
  39185. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39186. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39187. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39188. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39189. var scaleX = boundsWidth / width;
  39190. var scaleY = boundsHeight / height;
  39191. var context = {
  39192. coords: coords,
  39193. colors: colors,
  39194. offsetX: -offsetX,
  39195. offsetY: -offsetY,
  39196. scaleX: 1 / scaleX,
  39197. scaleY: 1 / scaleY
  39198. };
  39199. var paddedWidth = width + BORDER_SIZE * 2;
  39200. var paddedHeight = height + BORDER_SIZE * 2;
  39201. var canvas, tmpCanvas, i, ii;
  39202. if (WebGLUtils.isEnabled) {
  39203. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39204. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39205. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39206. canvas = tmpCanvas.canvas;
  39207. } else {
  39208. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39209. var tmpCtx = tmpCanvas.context;
  39210. var data = tmpCtx.createImageData(width, height);
  39211. if (backgroundColor) {
  39212. var bytes = data.data;
  39213. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39214. bytes[i] = backgroundColor[0];
  39215. bytes[i + 1] = backgroundColor[1];
  39216. bytes[i + 2] = backgroundColor[2];
  39217. bytes[i + 3] = 255;
  39218. }
  39219. }
  39220. for (i = 0; i < figures.length; i++) {
  39221. drawFigure(data, figures[i], context);
  39222. }
  39223. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39224. canvas = tmpCanvas.canvas;
  39225. }
  39226. return {
  39227. canvas: canvas,
  39228. offsetX: offsetX - BORDER_SIZE * scaleX,
  39229. offsetY: offsetY - BORDER_SIZE * scaleY,
  39230. scaleX: scaleX,
  39231. scaleY: scaleY
  39232. };
  39233. }
  39234. return createMeshCanvas;
  39235. }();
  39236. ShadingIRs.Mesh = {
  39237. fromIR: function Mesh_fromIR(raw) {
  39238. var coords = raw[2];
  39239. var colors = raw[3];
  39240. var figures = raw[4];
  39241. var bounds = raw[5];
  39242. var matrix = raw[6];
  39243. var background = raw[8];
  39244. return {
  39245. type: 'Pattern',
  39246. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39247. var scale;
  39248. if (shadingFill) {
  39249. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39250. } else {
  39251. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39252. if (matrix) {
  39253. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39254. scale = [
  39255. scale[0] * matrixScale[0],
  39256. scale[1] * matrixScale[1]
  39257. ];
  39258. }
  39259. }
  39260. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39261. if (!shadingFill) {
  39262. ctx.setTransform.apply(ctx, owner.baseTransform);
  39263. if (matrix) {
  39264. ctx.transform.apply(ctx, matrix);
  39265. }
  39266. }
  39267. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39268. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39269. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39270. }
  39271. };
  39272. }
  39273. };
  39274. ShadingIRs.Dummy = {
  39275. fromIR: function Dummy_fromIR() {
  39276. return {
  39277. type: 'Pattern',
  39278. getPattern: function Dummy_fromIR_getPattern() {
  39279. return 'hotpink';
  39280. }
  39281. };
  39282. }
  39283. };
  39284. function getShadingPatternFromIR(raw) {
  39285. var shadingIR = ShadingIRs[raw[0]];
  39286. if (!shadingIR) {
  39287. error('Unknown IR type: ' + raw[0]);
  39288. }
  39289. return shadingIR.fromIR(raw);
  39290. }
  39291. var TilingPattern = function TilingPatternClosure() {
  39292. var PaintType = {
  39293. COLORED: 1,
  39294. UNCOLORED: 2
  39295. };
  39296. var MAX_PATTERN_SIZE = 3000;
  39297. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39298. this.operatorList = IR[2];
  39299. this.matrix = IR[3] || [
  39300. 1,
  39301. 0,
  39302. 0,
  39303. 1,
  39304. 0,
  39305. 0
  39306. ];
  39307. this.bbox = IR[4];
  39308. this.xstep = IR[5];
  39309. this.ystep = IR[6];
  39310. this.paintType = IR[7];
  39311. this.tilingType = IR[8];
  39312. this.color = color;
  39313. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39314. this.baseTransform = baseTransform;
  39315. this.type = 'Pattern';
  39316. this.ctx = ctx;
  39317. }
  39318. TilingPattern.prototype = {
  39319. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39320. var operatorList = this.operatorList;
  39321. var bbox = this.bbox;
  39322. var xstep = this.xstep;
  39323. var ystep = this.ystep;
  39324. var paintType = this.paintType;
  39325. var tilingType = this.tilingType;
  39326. var color = this.color;
  39327. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39328. info('TilingType: ' + tilingType);
  39329. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39330. var topLeft = [
  39331. x0,
  39332. y0
  39333. ];
  39334. var botRight = [
  39335. x0 + xstep,
  39336. y0 + ystep
  39337. ];
  39338. var width = botRight[0] - topLeft[0];
  39339. var height = botRight[1] - topLeft[1];
  39340. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39341. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39342. var combinedScale = [
  39343. matrixScale[0] * curMatrixScale[0],
  39344. matrixScale[1] * curMatrixScale[1]
  39345. ];
  39346. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39347. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39348. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39349. var tmpCtx = tmpCanvas.context;
  39350. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39351. graphics.groupLevel = owner.groupLevel;
  39352. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39353. this.setScale(width, height, xstep, ystep);
  39354. this.transformToScale(graphics);
  39355. var tmpTranslate = [
  39356. 1,
  39357. 0,
  39358. 0,
  39359. 1,
  39360. -topLeft[0],
  39361. -topLeft[1]
  39362. ];
  39363. graphics.transform.apply(graphics, tmpTranslate);
  39364. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39365. graphics.executeOperatorList(operatorList);
  39366. return tmpCanvas.canvas;
  39367. },
  39368. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39369. this.scale = [
  39370. width / xstep,
  39371. height / ystep
  39372. ];
  39373. },
  39374. transformToScale: function TilingPattern_transformToScale(graphics) {
  39375. var scale = this.scale;
  39376. var tmpScale = [
  39377. scale[0],
  39378. 0,
  39379. 0,
  39380. scale[1],
  39381. 0,
  39382. 0
  39383. ];
  39384. graphics.transform.apply(graphics, tmpScale);
  39385. },
  39386. scaleToContext: function TilingPattern_scaleToContext() {
  39387. var scale = this.scale;
  39388. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39389. },
  39390. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39391. if (bbox && isArray(bbox) && bbox.length === 4) {
  39392. var bboxWidth = x1 - x0;
  39393. var bboxHeight = y1 - y0;
  39394. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39395. graphics.clip();
  39396. graphics.endPath();
  39397. }
  39398. },
  39399. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39400. switch (paintType) {
  39401. case PaintType.COLORED:
  39402. var ctx = this.ctx;
  39403. context.fillStyle = ctx.fillStyle;
  39404. context.strokeStyle = ctx.strokeStyle;
  39405. break;
  39406. case PaintType.UNCOLORED:
  39407. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39408. context.fillStyle = cssColor;
  39409. context.strokeStyle = cssColor;
  39410. break;
  39411. default:
  39412. error('Unsupported paint type: ' + paintType);
  39413. }
  39414. },
  39415. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39416. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39417. ctx = this.ctx;
  39418. ctx.setTransform.apply(ctx, this.baseTransform);
  39419. ctx.transform.apply(ctx, this.matrix);
  39420. this.scaleToContext();
  39421. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39422. }
  39423. };
  39424. return TilingPattern;
  39425. }();
  39426. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39427. exports.TilingPattern = TilingPattern;
  39428. }));
  39429. (function (root, factory) {
  39430. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39431. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39432. var Util = sharedUtil.Util;
  39433. var assert = sharedUtil.assert;
  39434. var warn = sharedUtil.warn;
  39435. var error = sharedUtil.error;
  39436. var isInt = sharedUtil.isInt;
  39437. var isString = sharedUtil.isString;
  39438. var MissingDataException = sharedUtil.MissingDataException;
  39439. var isName = corePrimitives.isName;
  39440. var isCmd = corePrimitives.isCmd;
  39441. var isStream = corePrimitives.isStream;
  39442. var StringStream = coreStream.StringStream;
  39443. var Lexer = coreParser.Lexer;
  39444. var isEOF = coreParser.isEOF;
  39445. var BUILT_IN_CMAPS = [
  39446. 'Adobe-GB1-UCS2',
  39447. 'Adobe-CNS1-UCS2',
  39448. 'Adobe-Japan1-UCS2',
  39449. 'Adobe-Korea1-UCS2',
  39450. '78-EUC-H',
  39451. '78-EUC-V',
  39452. '78-H',
  39453. '78-RKSJ-H',
  39454. '78-RKSJ-V',
  39455. '78-V',
  39456. '78ms-RKSJ-H',
  39457. '78ms-RKSJ-V',
  39458. '83pv-RKSJ-H',
  39459. '90ms-RKSJ-H',
  39460. '90ms-RKSJ-V',
  39461. '90msp-RKSJ-H',
  39462. '90msp-RKSJ-V',
  39463. '90pv-RKSJ-H',
  39464. '90pv-RKSJ-V',
  39465. 'Add-H',
  39466. 'Add-RKSJ-H',
  39467. 'Add-RKSJ-V',
  39468. 'Add-V',
  39469. 'Adobe-CNS1-0',
  39470. 'Adobe-CNS1-1',
  39471. 'Adobe-CNS1-2',
  39472. 'Adobe-CNS1-3',
  39473. 'Adobe-CNS1-4',
  39474. 'Adobe-CNS1-5',
  39475. 'Adobe-CNS1-6',
  39476. 'Adobe-GB1-0',
  39477. 'Adobe-GB1-1',
  39478. 'Adobe-GB1-2',
  39479. 'Adobe-GB1-3',
  39480. 'Adobe-GB1-4',
  39481. 'Adobe-GB1-5',
  39482. 'Adobe-Japan1-0',
  39483. 'Adobe-Japan1-1',
  39484. 'Adobe-Japan1-2',
  39485. 'Adobe-Japan1-3',
  39486. 'Adobe-Japan1-4',
  39487. 'Adobe-Japan1-5',
  39488. 'Adobe-Japan1-6',
  39489. 'Adobe-Korea1-0',
  39490. 'Adobe-Korea1-1',
  39491. 'Adobe-Korea1-2',
  39492. 'B5-H',
  39493. 'B5-V',
  39494. 'B5pc-H',
  39495. 'B5pc-V',
  39496. 'CNS-EUC-H',
  39497. 'CNS-EUC-V',
  39498. 'CNS1-H',
  39499. 'CNS1-V',
  39500. 'CNS2-H',
  39501. 'CNS2-V',
  39502. 'ETHK-B5-H',
  39503. 'ETHK-B5-V',
  39504. 'ETen-B5-H',
  39505. 'ETen-B5-V',
  39506. 'ETenms-B5-H',
  39507. 'ETenms-B5-V',
  39508. 'EUC-H',
  39509. 'EUC-V',
  39510. 'Ext-H',
  39511. 'Ext-RKSJ-H',
  39512. 'Ext-RKSJ-V',
  39513. 'Ext-V',
  39514. 'GB-EUC-H',
  39515. 'GB-EUC-V',
  39516. 'GB-H',
  39517. 'GB-V',
  39518. 'GBK-EUC-H',
  39519. 'GBK-EUC-V',
  39520. 'GBK2K-H',
  39521. 'GBK2K-V',
  39522. 'GBKp-EUC-H',
  39523. 'GBKp-EUC-V',
  39524. 'GBT-EUC-H',
  39525. 'GBT-EUC-V',
  39526. 'GBT-H',
  39527. 'GBT-V',
  39528. 'GBTpc-EUC-H',
  39529. 'GBTpc-EUC-V',
  39530. 'GBpc-EUC-H',
  39531. 'GBpc-EUC-V',
  39532. 'H',
  39533. 'HKdla-B5-H',
  39534. 'HKdla-B5-V',
  39535. 'HKdlb-B5-H',
  39536. 'HKdlb-B5-V',
  39537. 'HKgccs-B5-H',
  39538. 'HKgccs-B5-V',
  39539. 'HKm314-B5-H',
  39540. 'HKm314-B5-V',
  39541. 'HKm471-B5-H',
  39542. 'HKm471-B5-V',
  39543. 'HKscs-B5-H',
  39544. 'HKscs-B5-V',
  39545. 'Hankaku',
  39546. 'Hiragana',
  39547. 'KSC-EUC-H',
  39548. 'KSC-EUC-V',
  39549. 'KSC-H',
  39550. 'KSC-Johab-H',
  39551. 'KSC-Johab-V',
  39552. 'KSC-V',
  39553. 'KSCms-UHC-H',
  39554. 'KSCms-UHC-HW-H',
  39555. 'KSCms-UHC-HW-V',
  39556. 'KSCms-UHC-V',
  39557. 'KSCpc-EUC-H',
  39558. 'KSCpc-EUC-V',
  39559. 'Katakana',
  39560. 'NWP-H',
  39561. 'NWP-V',
  39562. 'RKSJ-H',
  39563. 'RKSJ-V',
  39564. 'Roman',
  39565. 'UniCNS-UCS2-H',
  39566. 'UniCNS-UCS2-V',
  39567. 'UniCNS-UTF16-H',
  39568. 'UniCNS-UTF16-V',
  39569. 'UniCNS-UTF32-H',
  39570. 'UniCNS-UTF32-V',
  39571. 'UniCNS-UTF8-H',
  39572. 'UniCNS-UTF8-V',
  39573. 'UniGB-UCS2-H',
  39574. 'UniGB-UCS2-V',
  39575. 'UniGB-UTF16-H',
  39576. 'UniGB-UTF16-V',
  39577. 'UniGB-UTF32-H',
  39578. 'UniGB-UTF32-V',
  39579. 'UniGB-UTF8-H',
  39580. 'UniGB-UTF8-V',
  39581. 'UniJIS-UCS2-H',
  39582. 'UniJIS-UCS2-HW-H',
  39583. 'UniJIS-UCS2-HW-V',
  39584. 'UniJIS-UCS2-V',
  39585. 'UniJIS-UTF16-H',
  39586. 'UniJIS-UTF16-V',
  39587. 'UniJIS-UTF32-H',
  39588. 'UniJIS-UTF32-V',
  39589. 'UniJIS-UTF8-H',
  39590. 'UniJIS-UTF8-V',
  39591. 'UniJIS2004-UTF16-H',
  39592. 'UniJIS2004-UTF16-V',
  39593. 'UniJIS2004-UTF32-H',
  39594. 'UniJIS2004-UTF32-V',
  39595. 'UniJIS2004-UTF8-H',
  39596. 'UniJIS2004-UTF8-V',
  39597. 'UniJISPro-UCS2-HW-V',
  39598. 'UniJISPro-UCS2-V',
  39599. 'UniJISPro-UTF8-V',
  39600. 'UniJISX0213-UTF32-H',
  39601. 'UniJISX0213-UTF32-V',
  39602. 'UniJISX02132004-UTF32-H',
  39603. 'UniJISX02132004-UTF32-V',
  39604. 'UniKS-UCS2-H',
  39605. 'UniKS-UCS2-V',
  39606. 'UniKS-UTF16-H',
  39607. 'UniKS-UTF16-V',
  39608. 'UniKS-UTF32-H',
  39609. 'UniKS-UTF32-V',
  39610. 'UniKS-UTF8-H',
  39611. 'UniKS-UTF8-V',
  39612. 'V',
  39613. 'WP-Symbol'
  39614. ];
  39615. var CMap = function CMapClosure() {
  39616. function CMap(builtInCMap) {
  39617. this.codespaceRanges = [
  39618. [],
  39619. [],
  39620. [],
  39621. []
  39622. ];
  39623. this.numCodespaceRanges = 0;
  39624. this._map = [];
  39625. this.name = '';
  39626. this.vertical = false;
  39627. this.useCMap = null;
  39628. this.builtInCMap = builtInCMap;
  39629. }
  39630. CMap.prototype = {
  39631. addCodespaceRange: function (n, low, high) {
  39632. this.codespaceRanges[n - 1].push(low, high);
  39633. this.numCodespaceRanges++;
  39634. },
  39635. mapCidRange: function (low, high, dstLow) {
  39636. while (low <= high) {
  39637. this._map[low++] = dstLow++;
  39638. }
  39639. },
  39640. mapBfRange: function (low, high, dstLow) {
  39641. var lastByte = dstLow.length - 1;
  39642. while (low <= high) {
  39643. this._map[low++] = dstLow;
  39644. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39645. }
  39646. },
  39647. mapBfRangeToArray: function (low, high, array) {
  39648. var i = 0, ii = array.length;
  39649. while (low <= high && i < ii) {
  39650. this._map[low] = array[i++];
  39651. ++low;
  39652. }
  39653. },
  39654. mapOne: function (src, dst) {
  39655. this._map[src] = dst;
  39656. },
  39657. lookup: function (code) {
  39658. return this._map[code];
  39659. },
  39660. contains: function (code) {
  39661. return this._map[code] !== undefined;
  39662. },
  39663. forEach: function (callback) {
  39664. var map = this._map;
  39665. var length = map.length;
  39666. var i;
  39667. if (length <= 0x10000) {
  39668. for (i = 0; i < length; i++) {
  39669. if (map[i] !== undefined) {
  39670. callback(i, map[i]);
  39671. }
  39672. }
  39673. } else {
  39674. for (i in this._map) {
  39675. callback(i, map[i]);
  39676. }
  39677. }
  39678. },
  39679. charCodeOf: function (value) {
  39680. return this._map.indexOf(value);
  39681. },
  39682. getMap: function () {
  39683. return this._map;
  39684. },
  39685. readCharCode: function (str, offset, out) {
  39686. var c = 0;
  39687. var codespaceRanges = this.codespaceRanges;
  39688. var codespaceRangesLen = this.codespaceRanges.length;
  39689. for (var n = 0; n < codespaceRangesLen; n++) {
  39690. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39691. var codespaceRange = codespaceRanges[n];
  39692. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39693. var low = codespaceRange[k++];
  39694. var high = codespaceRange[k++];
  39695. if (c >= low && c <= high) {
  39696. out.charcode = c;
  39697. out.length = n + 1;
  39698. return;
  39699. }
  39700. }
  39701. }
  39702. out.charcode = 0;
  39703. out.length = 1;
  39704. },
  39705. get length() {
  39706. return this._map.length;
  39707. },
  39708. get isIdentityCMap() {
  39709. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39710. return false;
  39711. }
  39712. if (this._map.length !== 0x10000) {
  39713. return false;
  39714. }
  39715. for (var i = 0; i < 0x10000; i++) {
  39716. if (this._map[i] !== i) {
  39717. return false;
  39718. }
  39719. }
  39720. return true;
  39721. }
  39722. };
  39723. return CMap;
  39724. }();
  39725. var IdentityCMap = function IdentityCMapClosure() {
  39726. function IdentityCMap(vertical, n) {
  39727. CMap.call(this);
  39728. this.vertical = vertical;
  39729. this.addCodespaceRange(n, 0, 0xffff);
  39730. }
  39731. Util.inherit(IdentityCMap, CMap, {});
  39732. IdentityCMap.prototype = {
  39733. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39734. mapCidRange: function (low, high, dstLow) {
  39735. error('should not call mapCidRange');
  39736. },
  39737. mapBfRange: function (low, high, dstLow) {
  39738. error('should not call mapBfRange');
  39739. },
  39740. mapBfRangeToArray: function (low, high, array) {
  39741. error('should not call mapBfRangeToArray');
  39742. },
  39743. mapOne: function (src, dst) {
  39744. error('should not call mapCidOne');
  39745. },
  39746. lookup: function (code) {
  39747. return isInt(code) && code <= 0xffff ? code : undefined;
  39748. },
  39749. contains: function (code) {
  39750. return isInt(code) && code <= 0xffff;
  39751. },
  39752. forEach: function (callback) {
  39753. for (var i = 0; i <= 0xffff; i++) {
  39754. callback(i, i);
  39755. }
  39756. },
  39757. charCodeOf: function (value) {
  39758. return isInt(value) && value <= 0xffff ? value : -1;
  39759. },
  39760. getMap: function () {
  39761. var map = new Array(0x10000);
  39762. for (var i = 0; i <= 0xffff; i++) {
  39763. map[i] = i;
  39764. }
  39765. return map;
  39766. },
  39767. readCharCode: CMap.prototype.readCharCode,
  39768. get length() {
  39769. return 0x10000;
  39770. },
  39771. get isIdentityCMap() {
  39772. error('should not access .isIdentityCMap');
  39773. }
  39774. };
  39775. return IdentityCMap;
  39776. }();
  39777. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39778. function fetchBinaryData(url) {
  39779. return new Promise(function (resolve, reject) {
  39780. var request = new XMLHttpRequest();
  39781. request.open('GET', url, true);
  39782. request.responseType = 'arraybuffer';
  39783. request.onreadystatechange = function () {
  39784. if (request.readyState === XMLHttpRequest.DONE) {
  39785. if (!request.response || request.status !== 200 && request.status !== 0) {
  39786. reject(new Error('Unable to get binary cMap at: ' + url));
  39787. } else {
  39788. resolve(new Uint8Array(request.response));
  39789. }
  39790. }
  39791. };
  39792. request.send(null);
  39793. });
  39794. }
  39795. function hexToInt(a, size) {
  39796. var n = 0;
  39797. for (var i = 0; i <= size; i++) {
  39798. n = n << 8 | a[i];
  39799. }
  39800. return n >>> 0;
  39801. }
  39802. function hexToStr(a, size) {
  39803. if (size === 1) {
  39804. return String.fromCharCode(a[0], a[1]);
  39805. }
  39806. if (size === 3) {
  39807. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39808. }
  39809. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39810. }
  39811. function addHex(a, b, size) {
  39812. var c = 0;
  39813. for (var i = size; i >= 0; i--) {
  39814. c += a[i] + b[i];
  39815. a[i] = c & 255;
  39816. c >>= 8;
  39817. }
  39818. }
  39819. function incHex(a, size) {
  39820. var c = 1;
  39821. for (var i = size; i >= 0 && c > 0; i--) {
  39822. c += a[i];
  39823. a[i] = c & 255;
  39824. c >>= 8;
  39825. }
  39826. }
  39827. var MAX_NUM_SIZE = 16;
  39828. var MAX_ENCODED_NUM_SIZE = 19;
  39829. function BinaryCMapStream(data) {
  39830. this.buffer = data;
  39831. this.pos = 0;
  39832. this.end = data.length;
  39833. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  39834. }
  39835. BinaryCMapStream.prototype = {
  39836. readByte: function () {
  39837. if (this.pos >= this.end) {
  39838. return -1;
  39839. }
  39840. return this.buffer[this.pos++];
  39841. },
  39842. readNumber: function () {
  39843. var n = 0;
  39844. var last;
  39845. do {
  39846. var b = this.readByte();
  39847. if (b < 0) {
  39848. error('unexpected EOF in bcmap');
  39849. }
  39850. last = !(b & 0x80);
  39851. n = n << 7 | b & 0x7F;
  39852. } while (!last);
  39853. return n;
  39854. },
  39855. readSigned: function () {
  39856. var n = this.readNumber();
  39857. return n & 1 ? ~(n >>> 1) : n >>> 1;
  39858. },
  39859. readHex: function (num, size) {
  39860. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  39861. this.pos += size + 1;
  39862. },
  39863. readHexNumber: function (num, size) {
  39864. var last;
  39865. var stack = this.tmpBuf, sp = 0;
  39866. do {
  39867. var b = this.readByte();
  39868. if (b < 0) {
  39869. error('unexpected EOF in bcmap');
  39870. }
  39871. last = !(b & 0x80);
  39872. stack[sp++] = b & 0x7F;
  39873. } while (!last);
  39874. var i = size, buffer = 0, bufferSize = 0;
  39875. while (i >= 0) {
  39876. while (bufferSize < 8 && stack.length > 0) {
  39877. buffer = stack[--sp] << bufferSize | buffer;
  39878. bufferSize += 7;
  39879. }
  39880. num[i] = buffer & 255;
  39881. i--;
  39882. buffer >>= 8;
  39883. bufferSize -= 8;
  39884. }
  39885. },
  39886. readHexSigned: function (num, size) {
  39887. this.readHexNumber(num, size);
  39888. var sign = num[size] & 1 ? 255 : 0;
  39889. var c = 0;
  39890. for (var i = 0; i <= size; i++) {
  39891. c = (c & 1) << 8 | num[i];
  39892. num[i] = c >> 1 ^ sign;
  39893. }
  39894. },
  39895. readString: function () {
  39896. var len = this.readNumber();
  39897. var s = '';
  39898. for (var i = 0; i < len; i++) {
  39899. s += String.fromCharCode(this.readNumber());
  39900. }
  39901. return s;
  39902. }
  39903. };
  39904. function processBinaryCMap(url, cMap, extend) {
  39905. return fetchBinaryData(url).then(function (data) {
  39906. var stream = new BinaryCMapStream(data);
  39907. var header = stream.readByte();
  39908. cMap.vertical = !!(header & 1);
  39909. var useCMap = null;
  39910. var start = new Uint8Array(MAX_NUM_SIZE);
  39911. var end = new Uint8Array(MAX_NUM_SIZE);
  39912. var char = new Uint8Array(MAX_NUM_SIZE);
  39913. var charCode = new Uint8Array(MAX_NUM_SIZE);
  39914. var tmp = new Uint8Array(MAX_NUM_SIZE);
  39915. var code;
  39916. var b;
  39917. while ((b = stream.readByte()) >= 0) {
  39918. var type = b >> 5;
  39919. if (type === 7) {
  39920. switch (b & 0x1F) {
  39921. case 0:
  39922. stream.readString();
  39923. break;
  39924. case 1:
  39925. useCMap = stream.readString();
  39926. break;
  39927. }
  39928. continue;
  39929. }
  39930. var sequence = !!(b & 0x10);
  39931. var dataSize = b & 15;
  39932. assert(dataSize + 1 <= MAX_NUM_SIZE);
  39933. var ucs2DataSize = 1;
  39934. var subitemsCount = stream.readNumber();
  39935. var i;
  39936. switch (type) {
  39937. case 0:
  39938. stream.readHex(start, dataSize);
  39939. stream.readHexNumber(end, dataSize);
  39940. addHex(end, start, dataSize);
  39941. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39942. for (i = 1; i < subitemsCount; i++) {
  39943. incHex(end, dataSize);
  39944. stream.readHexNumber(start, dataSize);
  39945. addHex(start, end, dataSize);
  39946. stream.readHexNumber(end, dataSize);
  39947. addHex(end, start, dataSize);
  39948. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39949. }
  39950. break;
  39951. case 1:
  39952. stream.readHex(start, dataSize);
  39953. stream.readHexNumber(end, dataSize);
  39954. addHex(end, start, dataSize);
  39955. code = stream.readNumber();
  39956. for (i = 1; i < subitemsCount; i++) {
  39957. incHex(end, dataSize);
  39958. stream.readHexNumber(start, dataSize);
  39959. addHex(start, end, dataSize);
  39960. stream.readHexNumber(end, dataSize);
  39961. addHex(end, start, dataSize);
  39962. code = stream.readNumber();
  39963. }
  39964. break;
  39965. case 2:
  39966. stream.readHex(char, dataSize);
  39967. code = stream.readNumber();
  39968. cMap.mapOne(hexToInt(char, dataSize), code);
  39969. for (i = 1; i < subitemsCount; i++) {
  39970. incHex(char, dataSize);
  39971. if (!sequence) {
  39972. stream.readHexNumber(tmp, dataSize);
  39973. addHex(char, tmp, dataSize);
  39974. }
  39975. code = stream.readSigned() + (code + 1);
  39976. cMap.mapOne(hexToInt(char, dataSize), code);
  39977. }
  39978. break;
  39979. case 3:
  39980. stream.readHex(start, dataSize);
  39981. stream.readHexNumber(end, dataSize);
  39982. addHex(end, start, dataSize);
  39983. code = stream.readNumber();
  39984. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39985. for (i = 1; i < subitemsCount; i++) {
  39986. incHex(end, dataSize);
  39987. if (!sequence) {
  39988. stream.readHexNumber(start, dataSize);
  39989. addHex(start, end, dataSize);
  39990. } else {
  39991. start.set(end);
  39992. }
  39993. stream.readHexNumber(end, dataSize);
  39994. addHex(end, start, dataSize);
  39995. code = stream.readNumber();
  39996. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39997. }
  39998. break;
  39999. case 4:
  40000. stream.readHex(char, ucs2DataSize);
  40001. stream.readHex(charCode, dataSize);
  40002. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40003. for (i = 1; i < subitemsCount; i++) {
  40004. incHex(char, ucs2DataSize);
  40005. if (!sequence) {
  40006. stream.readHexNumber(tmp, ucs2DataSize);
  40007. addHex(char, tmp, ucs2DataSize);
  40008. }
  40009. incHex(charCode, dataSize);
  40010. stream.readHexSigned(tmp, dataSize);
  40011. addHex(charCode, tmp, dataSize);
  40012. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40013. }
  40014. break;
  40015. case 5:
  40016. stream.readHex(start, ucs2DataSize);
  40017. stream.readHexNumber(end, ucs2DataSize);
  40018. addHex(end, start, ucs2DataSize);
  40019. stream.readHex(charCode, dataSize);
  40020. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40021. for (i = 1; i < subitemsCount; i++) {
  40022. incHex(end, ucs2DataSize);
  40023. if (!sequence) {
  40024. stream.readHexNumber(start, ucs2DataSize);
  40025. addHex(start, end, ucs2DataSize);
  40026. } else {
  40027. start.set(end);
  40028. }
  40029. stream.readHexNumber(end, ucs2DataSize);
  40030. addHex(end, start, ucs2DataSize);
  40031. stream.readHex(charCode, dataSize);
  40032. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40033. }
  40034. break;
  40035. default:
  40036. error('Unknown type: ' + type);
  40037. break;
  40038. }
  40039. }
  40040. if (useCMap) {
  40041. return extend(useCMap);
  40042. }
  40043. return cMap;
  40044. });
  40045. }
  40046. function BinaryCMapReader() {
  40047. }
  40048. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40049. return BinaryCMapReader;
  40050. }();
  40051. var CMapFactory = function CMapFactoryClosure() {
  40052. function strToInt(str) {
  40053. var a = 0;
  40054. for (var i = 0; i < str.length; i++) {
  40055. a = a << 8 | str.charCodeAt(i);
  40056. }
  40057. return a >>> 0;
  40058. }
  40059. function expectString(obj) {
  40060. if (!isString(obj)) {
  40061. error('Malformed CMap: expected string.');
  40062. }
  40063. }
  40064. function expectInt(obj) {
  40065. if (!isInt(obj)) {
  40066. error('Malformed CMap: expected int.');
  40067. }
  40068. }
  40069. function parseBfChar(cMap, lexer) {
  40070. while (true) {
  40071. var obj = lexer.getObj();
  40072. if (isEOF(obj)) {
  40073. break;
  40074. }
  40075. if (isCmd(obj, 'endbfchar')) {
  40076. return;
  40077. }
  40078. expectString(obj);
  40079. var src = strToInt(obj);
  40080. obj = lexer.getObj();
  40081. expectString(obj);
  40082. var dst = obj;
  40083. cMap.mapOne(src, dst);
  40084. }
  40085. }
  40086. function parseBfRange(cMap, lexer) {
  40087. while (true) {
  40088. var obj = lexer.getObj();
  40089. if (isEOF(obj)) {
  40090. break;
  40091. }
  40092. if (isCmd(obj, 'endbfrange')) {
  40093. return;
  40094. }
  40095. expectString(obj);
  40096. var low = strToInt(obj);
  40097. obj = lexer.getObj();
  40098. expectString(obj);
  40099. var high = strToInt(obj);
  40100. obj = lexer.getObj();
  40101. if (isInt(obj) || isString(obj)) {
  40102. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40103. cMap.mapBfRange(low, high, dstLow);
  40104. } else if (isCmd(obj, '[')) {
  40105. obj = lexer.getObj();
  40106. var array = [];
  40107. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40108. array.push(obj);
  40109. obj = lexer.getObj();
  40110. }
  40111. cMap.mapBfRangeToArray(low, high, array);
  40112. } else {
  40113. break;
  40114. }
  40115. }
  40116. error('Invalid bf range.');
  40117. }
  40118. function parseCidChar(cMap, lexer) {
  40119. while (true) {
  40120. var obj = lexer.getObj();
  40121. if (isEOF(obj)) {
  40122. break;
  40123. }
  40124. if (isCmd(obj, 'endcidchar')) {
  40125. return;
  40126. }
  40127. expectString(obj);
  40128. var src = strToInt(obj);
  40129. obj = lexer.getObj();
  40130. expectInt(obj);
  40131. var dst = obj;
  40132. cMap.mapOne(src, dst);
  40133. }
  40134. }
  40135. function parseCidRange(cMap, lexer) {
  40136. while (true) {
  40137. var obj = lexer.getObj();
  40138. if (isEOF(obj)) {
  40139. break;
  40140. }
  40141. if (isCmd(obj, 'endcidrange')) {
  40142. return;
  40143. }
  40144. expectString(obj);
  40145. var low = strToInt(obj);
  40146. obj = lexer.getObj();
  40147. expectString(obj);
  40148. var high = strToInt(obj);
  40149. obj = lexer.getObj();
  40150. expectInt(obj);
  40151. var dstLow = obj;
  40152. cMap.mapCidRange(low, high, dstLow);
  40153. }
  40154. }
  40155. function parseCodespaceRange(cMap, lexer) {
  40156. while (true) {
  40157. var obj = lexer.getObj();
  40158. if (isEOF(obj)) {
  40159. break;
  40160. }
  40161. if (isCmd(obj, 'endcodespacerange')) {
  40162. return;
  40163. }
  40164. if (!isString(obj)) {
  40165. break;
  40166. }
  40167. var low = strToInt(obj);
  40168. obj = lexer.getObj();
  40169. if (!isString(obj)) {
  40170. break;
  40171. }
  40172. var high = strToInt(obj);
  40173. cMap.addCodespaceRange(obj.length, low, high);
  40174. }
  40175. error('Invalid codespace range.');
  40176. }
  40177. function parseWMode(cMap, lexer) {
  40178. var obj = lexer.getObj();
  40179. if (isInt(obj)) {
  40180. cMap.vertical = !!obj;
  40181. }
  40182. }
  40183. function parseCMapName(cMap, lexer) {
  40184. var obj = lexer.getObj();
  40185. if (isName(obj) && isString(obj.name)) {
  40186. cMap.name = obj.name;
  40187. }
  40188. }
  40189. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40190. var previous;
  40191. var embededUseCMap;
  40192. objLoop:
  40193. while (true) {
  40194. try {
  40195. var obj = lexer.getObj();
  40196. if (isEOF(obj)) {
  40197. break;
  40198. } else if (isName(obj)) {
  40199. if (obj.name === 'WMode') {
  40200. parseWMode(cMap, lexer);
  40201. } else if (obj.name === 'CMapName') {
  40202. parseCMapName(cMap, lexer);
  40203. }
  40204. previous = obj;
  40205. } else if (isCmd(obj)) {
  40206. switch (obj.cmd) {
  40207. case 'endcmap':
  40208. break objLoop;
  40209. case 'usecmap':
  40210. if (isName(previous)) {
  40211. embededUseCMap = previous.name;
  40212. }
  40213. break;
  40214. case 'begincodespacerange':
  40215. parseCodespaceRange(cMap, lexer);
  40216. break;
  40217. case 'beginbfchar':
  40218. parseBfChar(cMap, lexer);
  40219. break;
  40220. case 'begincidchar':
  40221. parseCidChar(cMap, lexer);
  40222. break;
  40223. case 'beginbfrange':
  40224. parseBfRange(cMap, lexer);
  40225. break;
  40226. case 'begincidrange':
  40227. parseCidRange(cMap, lexer);
  40228. break;
  40229. }
  40230. }
  40231. } catch (ex) {
  40232. if (ex instanceof MissingDataException) {
  40233. throw ex;
  40234. }
  40235. warn('Invalid cMap data: ' + ex);
  40236. continue;
  40237. }
  40238. }
  40239. if (!useCMap && embededUseCMap) {
  40240. useCMap = embededUseCMap;
  40241. }
  40242. if (useCMap) {
  40243. return extendCMap(cMap, builtInCMapParams, useCMap);
  40244. }
  40245. return Promise.resolve(cMap);
  40246. }
  40247. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40248. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40249. cMap.useCMap = newCMap;
  40250. if (cMap.numCodespaceRanges === 0) {
  40251. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40252. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40253. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40254. }
  40255. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40256. }
  40257. cMap.useCMap.forEach(function (key, value) {
  40258. if (!cMap.contains(key)) {
  40259. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40260. }
  40261. });
  40262. return cMap;
  40263. });
  40264. }
  40265. function parseBinaryCMap(name, builtInCMapParams) {
  40266. var url = builtInCMapParams.url + name + '.bcmap';
  40267. var cMap = new CMap(true);
  40268. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40269. return extendCMap(cMap, builtInCMapParams, useCMap);
  40270. });
  40271. }
  40272. function createBuiltInCMap(name, builtInCMapParams) {
  40273. if (name === 'Identity-H') {
  40274. return Promise.resolve(new IdentityCMap(false, 2));
  40275. } else if (name === 'Identity-V') {
  40276. return Promise.resolve(new IdentityCMap(true, 2));
  40277. }
  40278. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40279. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40280. }
  40281. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40282. if (builtInCMapParams.packed) {
  40283. return parseBinaryCMap(name, builtInCMapParams);
  40284. }
  40285. return new Promise(function (resolve, reject) {
  40286. var url = builtInCMapParams.url + name;
  40287. var request = new XMLHttpRequest();
  40288. request.onreadystatechange = function () {
  40289. if (request.readyState === XMLHttpRequest.DONE) {
  40290. if (request.status === 200 || request.status === 0) {
  40291. var cMap = new CMap(true);
  40292. var lexer = new Lexer(new StringStream(request.responseText));
  40293. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40294. resolve(parsedCMap);
  40295. });
  40296. } else {
  40297. reject(new Error('Unable to get cMap at: ' + url));
  40298. }
  40299. }
  40300. };
  40301. request.open('GET', url, true);
  40302. request.send(null);
  40303. });
  40304. }
  40305. return {
  40306. create: function (encoding, builtInCMapParams, useCMap) {
  40307. if (isName(encoding)) {
  40308. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40309. } else if (isStream(encoding)) {
  40310. var cMap = new CMap();
  40311. var lexer = new Lexer(encoding);
  40312. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40313. if (parsedCMap.isIdentityCMap) {
  40314. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40315. }
  40316. return parsedCMap;
  40317. });
  40318. }
  40319. return Promise.reject(new Error('Encoding required.'));
  40320. }
  40321. };
  40322. }();
  40323. exports.CMap = CMap;
  40324. exports.CMapFactory = CMapFactory;
  40325. exports.IdentityCMap = IdentityCMap;
  40326. }));
  40327. (function (root, factory) {
  40328. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40329. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40330. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40331. var FontType = sharedUtil.FontType;
  40332. var assert = sharedUtil.assert;
  40333. var bytesToString = sharedUtil.bytesToString;
  40334. var error = sharedUtil.error;
  40335. var info = sharedUtil.info;
  40336. var isArray = sharedUtil.isArray;
  40337. var isInt = sharedUtil.isInt;
  40338. var isNum = sharedUtil.isNum;
  40339. var readUint32 = sharedUtil.readUint32;
  40340. var shadow = sharedUtil.shadow;
  40341. var string32 = sharedUtil.string32;
  40342. var warn = sharedUtil.warn;
  40343. var MissingDataException = sharedUtil.MissingDataException;
  40344. var isSpace = sharedUtil.isSpace;
  40345. var Stream = coreStream.Stream;
  40346. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40347. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40348. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40349. var StandardEncoding = coreEncodings.StandardEncoding;
  40350. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40351. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40352. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40353. var getEncoding = coreEncodings.getEncoding;
  40354. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40355. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40356. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40357. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40358. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40359. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40360. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40361. var Type1Parser = coreType1Parser.Type1Parser;
  40362. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40363. var CFFParser = coreCFFParser.CFFParser;
  40364. var CFFCompiler = coreCFFParser.CFFCompiler;
  40365. var CFF = coreCFFParser.CFF;
  40366. var CFFHeader = coreCFFParser.CFFHeader;
  40367. var CFFTopDict = coreCFFParser.CFFTopDict;
  40368. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40369. var CFFStrings = coreCFFParser.CFFStrings;
  40370. var CFFIndex = coreCFFParser.CFFIndex;
  40371. var CFFCharset = coreCFFParser.CFFCharset;
  40372. var PRIVATE_USE_OFFSET_START = 0xE000;
  40373. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40374. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40375. var PDF_GLYPH_SPACE_UNITS = 1000;
  40376. var SEAC_ANALYSIS_ENABLED = false;
  40377. var FontFlags = {
  40378. FixedPitch: 1,
  40379. Serif: 2,
  40380. Symbolic: 4,
  40381. Script: 8,
  40382. Nonsymbolic: 32,
  40383. Italic: 64,
  40384. AllCap: 65536,
  40385. SmallCap: 131072,
  40386. ForceBold: 262144
  40387. };
  40388. var MacStandardGlyphOrdering = [
  40389. '.notdef',
  40390. '.null',
  40391. 'nonmarkingreturn',
  40392. 'space',
  40393. 'exclam',
  40394. 'quotedbl',
  40395. 'numbersign',
  40396. 'dollar',
  40397. 'percent',
  40398. 'ampersand',
  40399. 'quotesingle',
  40400. 'parenleft',
  40401. 'parenright',
  40402. 'asterisk',
  40403. 'plus',
  40404. 'comma',
  40405. 'hyphen',
  40406. 'period',
  40407. 'slash',
  40408. 'zero',
  40409. 'one',
  40410. 'two',
  40411. 'three',
  40412. 'four',
  40413. 'five',
  40414. 'six',
  40415. 'seven',
  40416. 'eight',
  40417. 'nine',
  40418. 'colon',
  40419. 'semicolon',
  40420. 'less',
  40421. 'equal',
  40422. 'greater',
  40423. 'question',
  40424. 'at',
  40425. 'A',
  40426. 'B',
  40427. 'C',
  40428. 'D',
  40429. 'E',
  40430. 'F',
  40431. 'G',
  40432. 'H',
  40433. 'I',
  40434. 'J',
  40435. 'K',
  40436. 'L',
  40437. 'M',
  40438. 'N',
  40439. 'O',
  40440. 'P',
  40441. 'Q',
  40442. 'R',
  40443. 'S',
  40444. 'T',
  40445. 'U',
  40446. 'V',
  40447. 'W',
  40448. 'X',
  40449. 'Y',
  40450. 'Z',
  40451. 'bracketleft',
  40452. 'backslash',
  40453. 'bracketright',
  40454. 'asciicircum',
  40455. 'underscore',
  40456. 'grave',
  40457. 'a',
  40458. 'b',
  40459. 'c',
  40460. 'd',
  40461. 'e',
  40462. 'f',
  40463. 'g',
  40464. 'h',
  40465. 'i',
  40466. 'j',
  40467. 'k',
  40468. 'l',
  40469. 'm',
  40470. 'n',
  40471. 'o',
  40472. 'p',
  40473. 'q',
  40474. 'r',
  40475. 's',
  40476. 't',
  40477. 'u',
  40478. 'v',
  40479. 'w',
  40480. 'x',
  40481. 'y',
  40482. 'z',
  40483. 'braceleft',
  40484. 'bar',
  40485. 'braceright',
  40486. 'asciitilde',
  40487. 'Adieresis',
  40488. 'Aring',
  40489. 'Ccedilla',
  40490. 'Eacute',
  40491. 'Ntilde',
  40492. 'Odieresis',
  40493. 'Udieresis',
  40494. 'aacute',
  40495. 'agrave',
  40496. 'acircumflex',
  40497. 'adieresis',
  40498. 'atilde',
  40499. 'aring',
  40500. 'ccedilla',
  40501. 'eacute',
  40502. 'egrave',
  40503. 'ecircumflex',
  40504. 'edieresis',
  40505. 'iacute',
  40506. 'igrave',
  40507. 'icircumflex',
  40508. 'idieresis',
  40509. 'ntilde',
  40510. 'oacute',
  40511. 'ograve',
  40512. 'ocircumflex',
  40513. 'odieresis',
  40514. 'otilde',
  40515. 'uacute',
  40516. 'ugrave',
  40517. 'ucircumflex',
  40518. 'udieresis',
  40519. 'dagger',
  40520. 'degree',
  40521. 'cent',
  40522. 'sterling',
  40523. 'section',
  40524. 'bullet',
  40525. 'paragraph',
  40526. 'germandbls',
  40527. 'registered',
  40528. 'copyright',
  40529. 'trademark',
  40530. 'acute',
  40531. 'dieresis',
  40532. 'notequal',
  40533. 'AE',
  40534. 'Oslash',
  40535. 'infinity',
  40536. 'plusminus',
  40537. 'lessequal',
  40538. 'greaterequal',
  40539. 'yen',
  40540. 'mu',
  40541. 'partialdiff',
  40542. 'summation',
  40543. 'product',
  40544. 'pi',
  40545. 'integral',
  40546. 'ordfeminine',
  40547. 'ordmasculine',
  40548. 'Omega',
  40549. 'ae',
  40550. 'oslash',
  40551. 'questiondown',
  40552. 'exclamdown',
  40553. 'logicalnot',
  40554. 'radical',
  40555. 'florin',
  40556. 'approxequal',
  40557. 'Delta',
  40558. 'guillemotleft',
  40559. 'guillemotright',
  40560. 'ellipsis',
  40561. 'nonbreakingspace',
  40562. 'Agrave',
  40563. 'Atilde',
  40564. 'Otilde',
  40565. 'OE',
  40566. 'oe',
  40567. 'endash',
  40568. 'emdash',
  40569. 'quotedblleft',
  40570. 'quotedblright',
  40571. 'quoteleft',
  40572. 'quoteright',
  40573. 'divide',
  40574. 'lozenge',
  40575. 'ydieresis',
  40576. 'Ydieresis',
  40577. 'fraction',
  40578. 'currency',
  40579. 'guilsinglleft',
  40580. 'guilsinglright',
  40581. 'fi',
  40582. 'fl',
  40583. 'daggerdbl',
  40584. 'periodcentered',
  40585. 'quotesinglbase',
  40586. 'quotedblbase',
  40587. 'perthousand',
  40588. 'Acircumflex',
  40589. 'Ecircumflex',
  40590. 'Aacute',
  40591. 'Edieresis',
  40592. 'Egrave',
  40593. 'Iacute',
  40594. 'Icircumflex',
  40595. 'Idieresis',
  40596. 'Igrave',
  40597. 'Oacute',
  40598. 'Ocircumflex',
  40599. 'apple',
  40600. 'Ograve',
  40601. 'Uacute',
  40602. 'Ucircumflex',
  40603. 'Ugrave',
  40604. 'dotlessi',
  40605. 'circumflex',
  40606. 'tilde',
  40607. 'macron',
  40608. 'breve',
  40609. 'dotaccent',
  40610. 'ring',
  40611. 'cedilla',
  40612. 'hungarumlaut',
  40613. 'ogonek',
  40614. 'caron',
  40615. 'Lslash',
  40616. 'lslash',
  40617. 'Scaron',
  40618. 'scaron',
  40619. 'Zcaron',
  40620. 'zcaron',
  40621. 'brokenbar',
  40622. 'Eth',
  40623. 'eth',
  40624. 'Yacute',
  40625. 'yacute',
  40626. 'Thorn',
  40627. 'thorn',
  40628. 'minus',
  40629. 'multiply',
  40630. 'onesuperior',
  40631. 'twosuperior',
  40632. 'threesuperior',
  40633. 'onehalf',
  40634. 'onequarter',
  40635. 'threequarters',
  40636. 'franc',
  40637. 'Gbreve',
  40638. 'gbreve',
  40639. 'Idotaccent',
  40640. 'Scedilla',
  40641. 'scedilla',
  40642. 'Cacute',
  40643. 'cacute',
  40644. 'Ccaron',
  40645. 'ccaron',
  40646. 'dcroat'
  40647. ];
  40648. function adjustWidths(properties) {
  40649. if (!properties.fontMatrix) {
  40650. return;
  40651. }
  40652. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40653. return;
  40654. }
  40655. var scale = 0.001 / properties.fontMatrix[0];
  40656. var glyphsWidths = properties.widths;
  40657. for (var glyph in glyphsWidths) {
  40658. glyphsWidths[glyph] *= scale;
  40659. }
  40660. properties.defaultWidth *= scale;
  40661. }
  40662. function adjustToUnicode(properties, builtInEncoding) {
  40663. if (properties.hasIncludedToUnicodeMap) {
  40664. return;
  40665. }
  40666. if (properties.hasEncoding) {
  40667. return;
  40668. }
  40669. if (builtInEncoding === properties.defaultEncoding) {
  40670. return;
  40671. }
  40672. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40673. return;
  40674. }
  40675. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40676. for (var charCode in builtInEncoding) {
  40677. var glyphName = builtInEncoding[charCode];
  40678. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40679. if (unicode !== -1) {
  40680. toUnicode[charCode] = String.fromCharCode(unicode);
  40681. }
  40682. }
  40683. properties.toUnicode.amend(toUnicode);
  40684. }
  40685. function getFontType(type, subtype) {
  40686. switch (type) {
  40687. case 'Type1':
  40688. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40689. case 'CIDFontType0':
  40690. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40691. case 'OpenType':
  40692. return FontType.OPENTYPE;
  40693. case 'TrueType':
  40694. return FontType.TRUETYPE;
  40695. case 'CIDFontType2':
  40696. return FontType.CIDFONTTYPE2;
  40697. case 'MMType1':
  40698. return FontType.MMTYPE1;
  40699. case 'Type0':
  40700. return FontType.TYPE0;
  40701. default:
  40702. return FontType.UNKNOWN;
  40703. }
  40704. }
  40705. function recoverGlyphName(name, glyphsUnicodeMap) {
  40706. if (glyphsUnicodeMap[name] !== undefined) {
  40707. return name;
  40708. }
  40709. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40710. if (unicode !== -1) {
  40711. for (var key in glyphsUnicodeMap) {
  40712. if (glyphsUnicodeMap[key] === unicode) {
  40713. return key;
  40714. }
  40715. }
  40716. }
  40717. info('Unable to recover a standard glyph name for: ' + name);
  40718. return name;
  40719. }
  40720. var Glyph = function GlyphClosure() {
  40721. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40722. this.fontChar = fontChar;
  40723. this.unicode = unicode;
  40724. this.accent = accent;
  40725. this.width = width;
  40726. this.vmetric = vmetric;
  40727. this.operatorListId = operatorListId;
  40728. this.isSpace = isSpace;
  40729. this.isInFont = isInFont;
  40730. }
  40731. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40732. 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;
  40733. };
  40734. return Glyph;
  40735. }();
  40736. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40737. function ToUnicodeMap(cmap) {
  40738. this._map = cmap;
  40739. }
  40740. ToUnicodeMap.prototype = {
  40741. get length() {
  40742. return this._map.length;
  40743. },
  40744. forEach: function (callback) {
  40745. for (var charCode in this._map) {
  40746. callback(charCode, this._map[charCode].charCodeAt(0));
  40747. }
  40748. },
  40749. has: function (i) {
  40750. return this._map[i] !== undefined;
  40751. },
  40752. get: function (i) {
  40753. return this._map[i];
  40754. },
  40755. charCodeOf: function (v) {
  40756. return this._map.indexOf(v);
  40757. },
  40758. amend: function (map) {
  40759. for (var charCode in map) {
  40760. this._map[charCode] = map[charCode];
  40761. }
  40762. }
  40763. };
  40764. return ToUnicodeMap;
  40765. }();
  40766. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40767. function IdentityToUnicodeMap(firstChar, lastChar) {
  40768. this.firstChar = firstChar;
  40769. this.lastChar = lastChar;
  40770. }
  40771. IdentityToUnicodeMap.prototype = {
  40772. get length() {
  40773. return this.lastChar + 1 - this.firstChar;
  40774. },
  40775. forEach: function (callback) {
  40776. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40777. callback(i, i);
  40778. }
  40779. },
  40780. has: function (i) {
  40781. return this.firstChar <= i && i <= this.lastChar;
  40782. },
  40783. get: function (i) {
  40784. if (this.firstChar <= i && i <= this.lastChar) {
  40785. return String.fromCharCode(i);
  40786. }
  40787. return undefined;
  40788. },
  40789. charCodeOf: function (v) {
  40790. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40791. },
  40792. amend: function (map) {
  40793. error('Should not call amend()');
  40794. }
  40795. };
  40796. return IdentityToUnicodeMap;
  40797. }();
  40798. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40799. function writeInt16(dest, offset, num) {
  40800. dest[offset] = num >> 8 & 0xFF;
  40801. dest[offset + 1] = num & 0xFF;
  40802. }
  40803. function writeInt32(dest, offset, num) {
  40804. dest[offset] = num >> 24 & 0xFF;
  40805. dest[offset + 1] = num >> 16 & 0xFF;
  40806. dest[offset + 2] = num >> 8 & 0xFF;
  40807. dest[offset + 3] = num & 0xFF;
  40808. }
  40809. function writeData(dest, offset, data) {
  40810. var i, ii;
  40811. if (data instanceof Uint8Array) {
  40812. dest.set(data, offset);
  40813. } else if (typeof data === 'string') {
  40814. for (i = 0, ii = data.length; i < ii; i++) {
  40815. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40816. }
  40817. } else {
  40818. for (i = 0, ii = data.length; i < ii; i++) {
  40819. dest[offset++] = data[i] & 0xFF;
  40820. }
  40821. }
  40822. }
  40823. function OpenTypeFileBuilder(sfnt) {
  40824. this.sfnt = sfnt;
  40825. this.tables = Object.create(null);
  40826. }
  40827. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40828. var maxPower2 = 1, log2 = 0;
  40829. while ((maxPower2 ^ entriesCount) > maxPower2) {
  40830. maxPower2 <<= 1;
  40831. log2++;
  40832. }
  40833. var searchRange = maxPower2 * entrySize;
  40834. return {
  40835. range: searchRange,
  40836. entry: log2,
  40837. rangeShift: entrySize * entriesCount - searchRange
  40838. };
  40839. };
  40840. var OTF_HEADER_SIZE = 12;
  40841. var OTF_TABLE_ENTRY_SIZE = 16;
  40842. OpenTypeFileBuilder.prototype = {
  40843. toArray: function OpenTypeFileBuilder_toArray() {
  40844. var sfnt = this.sfnt;
  40845. var tables = this.tables;
  40846. var tablesNames = Object.keys(tables);
  40847. tablesNames.sort();
  40848. var numTables = tablesNames.length;
  40849. var i, j, jj, table, tableName;
  40850. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  40851. var tableOffsets = [offset];
  40852. for (i = 0; i < numTables; i++) {
  40853. table = tables[tablesNames[i]];
  40854. var paddedLength = (table.length + 3 & ~3) >>> 0;
  40855. offset += paddedLength;
  40856. tableOffsets.push(offset);
  40857. }
  40858. var file = new Uint8Array(offset);
  40859. for (i = 0; i < numTables; i++) {
  40860. table = tables[tablesNames[i]];
  40861. writeData(file, tableOffsets[i], table);
  40862. }
  40863. if (sfnt === 'true') {
  40864. sfnt = string32(0x00010000);
  40865. }
  40866. file[0] = sfnt.charCodeAt(0) & 0xFF;
  40867. file[1] = sfnt.charCodeAt(1) & 0xFF;
  40868. file[2] = sfnt.charCodeAt(2) & 0xFF;
  40869. file[3] = sfnt.charCodeAt(3) & 0xFF;
  40870. writeInt16(file, 4, numTables);
  40871. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  40872. writeInt16(file, 6, searchParams.range);
  40873. writeInt16(file, 8, searchParams.entry);
  40874. writeInt16(file, 10, searchParams.rangeShift);
  40875. offset = OTF_HEADER_SIZE;
  40876. for (i = 0; i < numTables; i++) {
  40877. tableName = tablesNames[i];
  40878. file[offset] = tableName.charCodeAt(0) & 0xFF;
  40879. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  40880. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  40881. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  40882. var checksum = 0;
  40883. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  40884. var quad = readUint32(file, j);
  40885. checksum = checksum + quad >>> 0;
  40886. }
  40887. writeInt32(file, offset + 4, checksum);
  40888. writeInt32(file, offset + 8, tableOffsets[i]);
  40889. writeInt32(file, offset + 12, tables[tableName].length);
  40890. offset += OTF_TABLE_ENTRY_SIZE;
  40891. }
  40892. return file;
  40893. },
  40894. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  40895. if (tag in this.tables) {
  40896. throw new Error('Table ' + tag + ' already exists');
  40897. }
  40898. this.tables[tag] = data;
  40899. }
  40900. };
  40901. return OpenTypeFileBuilder;
  40902. }();
  40903. var ProblematicCharRanges = new Int32Array([
  40904. 0x0000,
  40905. 0x0020,
  40906. 0x007F,
  40907. 0x00A1,
  40908. 0x00AD,
  40909. 0x00AE,
  40910. 0x0600,
  40911. 0x0780,
  40912. 0x08A0,
  40913. 0x10A0,
  40914. 0x1780,
  40915. 0x1800,
  40916. 0x1C00,
  40917. 0x1C50,
  40918. 0x2000,
  40919. 0x2010,
  40920. 0x2011,
  40921. 0x2012,
  40922. 0x2028,
  40923. 0x2030,
  40924. 0x205F,
  40925. 0x2070,
  40926. 0x25CC,
  40927. 0x25CD,
  40928. 0x3000,
  40929. 0x3001,
  40930. 0xAA60,
  40931. 0xAA80,
  40932. 0xFFF0,
  40933. 0x10000
  40934. ]);
  40935. var Font = function FontClosure() {
  40936. function Font(name, file, properties) {
  40937. var charCode, glyphName, unicode;
  40938. this.name = name;
  40939. this.loadedName = properties.loadedName;
  40940. this.isType3Font = properties.isType3Font;
  40941. this.sizes = [];
  40942. this.missingFile = false;
  40943. this.glyphCache = Object.create(null);
  40944. var names = name.split('+');
  40945. names = names.length > 1 ? names[1] : names[0];
  40946. names = names.split(/[-,_]/g)[0];
  40947. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  40948. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  40949. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  40950. var type = properties.type;
  40951. var subtype = properties.subtype;
  40952. this.type = type;
  40953. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  40954. this.differences = properties.differences;
  40955. this.widths = properties.widths;
  40956. this.defaultWidth = properties.defaultWidth;
  40957. this.composite = properties.composite;
  40958. this.wideChars = properties.wideChars;
  40959. this.cMap = properties.cMap;
  40960. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  40961. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  40962. this.fontMatrix = properties.fontMatrix;
  40963. this.bbox = properties.bbox;
  40964. this.toUnicode = properties.toUnicode;
  40965. this.toFontChar = [];
  40966. if (properties.type === 'Type3') {
  40967. for (charCode = 0; charCode < 256; charCode++) {
  40968. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  40969. }
  40970. this.fontType = FontType.TYPE3;
  40971. return;
  40972. }
  40973. this.cidEncoding = properties.cidEncoding;
  40974. this.vertical = properties.vertical;
  40975. if (this.vertical) {
  40976. this.vmetrics = properties.vmetrics;
  40977. this.defaultVMetrics = properties.defaultVMetrics;
  40978. }
  40979. var glyphsUnicodeMap;
  40980. if (!file || file.isEmpty) {
  40981. if (file) {
  40982. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  40983. }
  40984. this.missingFile = true;
  40985. var fontName = name.replace(/[,_]/g, '-');
  40986. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  40987. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  40988. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  40989. this.bold = fontName.search(/bold/gi) !== -1;
  40990. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  40991. this.black = name.search(/Black/g) !== -1;
  40992. this.remeasure = Object.keys(this.widths).length > 0;
  40993. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  40994. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  40995. var map = [];
  40996. for (charCode in GlyphMapForStandardFonts) {
  40997. map[+charCode] = GlyphMapForStandardFonts[charCode];
  40998. }
  40999. if (/Arial-?Black/i.test(name)) {
  41000. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  41001. for (charCode in SupplementalGlyphMapForArialBlack) {
  41002. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  41003. }
  41004. }
  41005. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41006. if (!isIdentityUnicode) {
  41007. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41008. map[+charCode] = unicodeCharCode;
  41009. });
  41010. }
  41011. this.toFontChar = map;
  41012. this.toUnicode = new ToUnicodeMap(map);
  41013. } else if (/Symbol/i.test(fontName)) {
  41014. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41015. } else if (/Dingbats/i.test(fontName)) {
  41016. if (/Wingdings/i.test(name)) {
  41017. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41018. }
  41019. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41020. } else if (isStandardFont) {
  41021. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41022. } else {
  41023. glyphsUnicodeMap = getGlyphsUnicode();
  41024. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41025. if (!this.composite) {
  41026. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41027. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41028. if (unicode !== -1) {
  41029. unicodeCharCode = unicode;
  41030. }
  41031. }
  41032. this.toFontChar[charCode] = unicodeCharCode;
  41033. }.bind(this));
  41034. }
  41035. this.loadedName = fontName.split('-')[0];
  41036. this.loading = false;
  41037. this.fontType = getFontType(type, subtype);
  41038. return;
  41039. }
  41040. if (subtype === 'Type1C') {
  41041. if (type !== 'Type1' && type !== 'MMType1') {
  41042. if (isTrueTypeFile(file)) {
  41043. subtype = 'TrueType';
  41044. } else {
  41045. type = 'Type1';
  41046. }
  41047. } else if (isOpenTypeFile(file)) {
  41048. type = subtype = 'OpenType';
  41049. }
  41050. }
  41051. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41052. type = 'CIDFontType0';
  41053. }
  41054. if (subtype === 'OpenType') {
  41055. type = 'OpenType';
  41056. }
  41057. if (type === 'CIDFontType0') {
  41058. if (isType1File(file)) {
  41059. subtype = 'CIDFontType0';
  41060. } else if (isOpenTypeFile(file)) {
  41061. type = subtype = 'OpenType';
  41062. } else {
  41063. subtype = 'CIDFontType0C';
  41064. }
  41065. }
  41066. var data;
  41067. switch (type) {
  41068. case 'MMType1':
  41069. info('MMType1 font (' + name + '), falling back to Type1.');
  41070. case 'Type1':
  41071. case 'CIDFontType0':
  41072. this.mimetype = 'font/opentype';
  41073. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41074. adjustWidths(properties);
  41075. data = this.convert(name, cff, properties);
  41076. break;
  41077. case 'OpenType':
  41078. case 'TrueType':
  41079. case 'CIDFontType2':
  41080. this.mimetype = 'font/opentype';
  41081. data = this.checkAndRepair(name, file, properties);
  41082. if (this.isOpenType) {
  41083. adjustWidths(properties);
  41084. type = 'OpenType';
  41085. }
  41086. break;
  41087. default:
  41088. error('Font ' + type + ' is not supported');
  41089. break;
  41090. }
  41091. this.data = data;
  41092. this.fontType = getFontType(type, subtype);
  41093. this.fontMatrix = properties.fontMatrix;
  41094. this.widths = properties.widths;
  41095. this.defaultWidth = properties.defaultWidth;
  41096. this.toUnicode = properties.toUnicode;
  41097. this.encoding = properties.baseEncoding;
  41098. this.seacMap = properties.seacMap;
  41099. this.loading = true;
  41100. }
  41101. Font.getFontID = function () {
  41102. var ID = 1;
  41103. return function Font_getFontID() {
  41104. return String(ID++);
  41105. };
  41106. }();
  41107. function int16(b0, b1) {
  41108. return (b0 << 8) + b1;
  41109. }
  41110. function signedInt16(b0, b1) {
  41111. var value = (b0 << 8) + b1;
  41112. return value & 1 << 15 ? value - 0x10000 : value;
  41113. }
  41114. function int32(b0, b1, b2, b3) {
  41115. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41116. }
  41117. function string16(value) {
  41118. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41119. }
  41120. function safeString16(value) {
  41121. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41122. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41123. }
  41124. function isTrueTypeFile(file) {
  41125. var header = file.peekBytes(4);
  41126. return readUint32(header, 0) === 0x00010000;
  41127. }
  41128. function isOpenTypeFile(file) {
  41129. var header = file.peekBytes(4);
  41130. return bytesToString(header) === 'OTTO';
  41131. }
  41132. function isType1File(file) {
  41133. var header = file.peekBytes(2);
  41134. if (header[0] === 0x25 && header[1] === 0x21) {
  41135. return true;
  41136. }
  41137. if (header[0] === 0x80 && header[1] === 0x01) {
  41138. return true;
  41139. }
  41140. return false;
  41141. }
  41142. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41143. var toFontChar = [], unicode;
  41144. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41145. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41146. if (unicode !== -1) {
  41147. toFontChar[i] = unicode;
  41148. }
  41149. }
  41150. for (var charCode in differences) {
  41151. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41152. if (unicode !== -1) {
  41153. toFontChar[+charCode] = unicode;
  41154. }
  41155. }
  41156. return toFontChar;
  41157. }
  41158. function isProblematicUnicodeLocation(code) {
  41159. var i = 0, j = ProblematicCharRanges.length - 1;
  41160. while (i < j) {
  41161. var c = i + j + 1 >> 1;
  41162. if (code < ProblematicCharRanges[c]) {
  41163. j = c - 1;
  41164. } else {
  41165. i = c;
  41166. }
  41167. }
  41168. return !(i & 1);
  41169. }
  41170. function adjustMapping(charCodeToGlyphId, properties) {
  41171. var toUnicode = properties.toUnicode;
  41172. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41173. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41174. var newMap = Object.create(null);
  41175. var toFontChar = [];
  41176. var usedFontCharCodes = [];
  41177. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41178. for (var originalCharCode in charCodeToGlyphId) {
  41179. originalCharCode |= 0;
  41180. var glyphId = charCodeToGlyphId[originalCharCode];
  41181. var fontCharCode = originalCharCode;
  41182. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41183. var unicode = toUnicode.get(fontCharCode);
  41184. if (unicode.length === 1) {
  41185. fontCharCode = unicode.charCodeAt(0);
  41186. }
  41187. }
  41188. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && isIdentityUnicode) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41189. do {
  41190. fontCharCode = nextAvailableFontCharCode++;
  41191. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41192. fontCharCode = 0xF020;
  41193. nextAvailableFontCharCode = fontCharCode + 1;
  41194. }
  41195. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41196. }
  41197. newMap[fontCharCode] = glyphId;
  41198. toFontChar[originalCharCode] = fontCharCode;
  41199. usedFontCharCodes[fontCharCode] = true;
  41200. }
  41201. return {
  41202. toFontChar: toFontChar,
  41203. charCodeToGlyphId: newMap,
  41204. nextAvailableFontCharCode: nextAvailableFontCharCode
  41205. };
  41206. }
  41207. function getRanges(glyphs, numGlyphs) {
  41208. var codes = [];
  41209. for (var charCode in glyphs) {
  41210. if (glyphs[charCode] >= numGlyphs) {
  41211. continue;
  41212. }
  41213. codes.push({
  41214. fontCharCode: charCode | 0,
  41215. glyphId: glyphs[charCode]
  41216. });
  41217. }
  41218. codes.sort(function fontGetRangesSort(a, b) {
  41219. return a.fontCharCode - b.fontCharCode;
  41220. });
  41221. var ranges = [];
  41222. var length = codes.length;
  41223. for (var n = 0; n < length;) {
  41224. var start = codes[n].fontCharCode;
  41225. var codeIndices = [codes[n].glyphId];
  41226. ++n;
  41227. var end = start;
  41228. while (n < length && end + 1 === codes[n].fontCharCode) {
  41229. codeIndices.push(codes[n].glyphId);
  41230. ++end;
  41231. ++n;
  41232. if (end === 0xFFFF) {
  41233. break;
  41234. }
  41235. }
  41236. ranges.push([
  41237. start,
  41238. end,
  41239. codeIndices
  41240. ]);
  41241. }
  41242. return ranges;
  41243. }
  41244. function createCmapTable(glyphs, numGlyphs) {
  41245. var ranges = getRanges(glyphs, numGlyphs);
  41246. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41247. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41248. var i, ii, j, jj;
  41249. for (i = ranges.length - 1; i >= 0; --i) {
  41250. if (ranges[i][0] <= 0xFFFF) {
  41251. break;
  41252. }
  41253. }
  41254. var bmpLength = i + 1;
  41255. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41256. ranges[i][1] = 0xFFFE;
  41257. }
  41258. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41259. var segCount = bmpLength + trailingRangesCount;
  41260. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41261. var startCount = '';
  41262. var endCount = '';
  41263. var idDeltas = '';
  41264. var idRangeOffsets = '';
  41265. var glyphsIds = '';
  41266. var bias = 0;
  41267. var range, start, end, codes;
  41268. for (i = 0, ii = bmpLength; i < ii; i++) {
  41269. range = ranges[i];
  41270. start = range[0];
  41271. end = range[1];
  41272. startCount += string16(start);
  41273. endCount += string16(end);
  41274. codes = range[2];
  41275. var contiguous = true;
  41276. for (j = 1, jj = codes.length; j < jj; ++j) {
  41277. if (codes[j] !== codes[j - 1] + 1) {
  41278. contiguous = false;
  41279. break;
  41280. }
  41281. }
  41282. if (!contiguous) {
  41283. var offset = (segCount - i) * 2 + bias * 2;
  41284. bias += end - start + 1;
  41285. idDeltas += string16(0);
  41286. idRangeOffsets += string16(offset);
  41287. for (j = 0, jj = codes.length; j < jj; ++j) {
  41288. glyphsIds += string16(codes[j]);
  41289. }
  41290. } else {
  41291. var startCode = codes[0];
  41292. idDeltas += string16(startCode - start & 0xFFFF);
  41293. idRangeOffsets += string16(0);
  41294. }
  41295. }
  41296. if (trailingRangesCount > 0) {
  41297. endCount += '\xFF\xFF';
  41298. startCount += '\xFF\xFF';
  41299. idDeltas += '\x00\x01';
  41300. idRangeOffsets += '\x00\x00';
  41301. }
  41302. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41303. var format31012 = '';
  41304. var header31012 = '';
  41305. if (numTables > 1) {
  41306. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41307. format31012 = '';
  41308. for (i = 0, ii = ranges.length; i < ii; i++) {
  41309. range = ranges[i];
  41310. start = range[0];
  41311. codes = range[2];
  41312. var code = codes[0];
  41313. for (j = 1, jj = codes.length; j < jj; ++j) {
  41314. if (codes[j] !== codes[j - 1] + 1) {
  41315. end = range[0] + j - 1;
  41316. format31012 += string32(start) + string32(end) + string32(code);
  41317. start = end + 1;
  41318. code = codes[j];
  41319. }
  41320. }
  41321. format31012 += string32(start) + string32(range[1]) + string32(code);
  41322. }
  41323. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41324. }
  41325. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41326. }
  41327. function validateOS2Table(os2) {
  41328. var stream = new Stream(os2.data);
  41329. var version = stream.getUint16();
  41330. stream.getBytes(60);
  41331. var selection = stream.getUint16();
  41332. if (version < 4 && selection & 0x0300) {
  41333. return false;
  41334. }
  41335. var firstChar = stream.getUint16();
  41336. var lastChar = stream.getUint16();
  41337. if (firstChar > lastChar) {
  41338. return false;
  41339. }
  41340. stream.getBytes(6);
  41341. var usWinAscent = stream.getUint16();
  41342. if (usWinAscent === 0) {
  41343. return false;
  41344. }
  41345. os2.data[8] = os2.data[9] = 0;
  41346. return true;
  41347. }
  41348. function createOS2Table(properties, charstrings, override) {
  41349. override = override || {
  41350. unitsPerEm: 0,
  41351. yMax: 0,
  41352. yMin: 0,
  41353. ascent: 0,
  41354. descent: 0
  41355. };
  41356. var ulUnicodeRange1 = 0;
  41357. var ulUnicodeRange2 = 0;
  41358. var ulUnicodeRange3 = 0;
  41359. var ulUnicodeRange4 = 0;
  41360. var firstCharIndex = null;
  41361. var lastCharIndex = 0;
  41362. if (charstrings) {
  41363. for (var code in charstrings) {
  41364. code |= 0;
  41365. if (firstCharIndex > code || !firstCharIndex) {
  41366. firstCharIndex = code;
  41367. }
  41368. if (lastCharIndex < code) {
  41369. lastCharIndex = code;
  41370. }
  41371. var position = getUnicodeRangeFor(code);
  41372. if (position < 32) {
  41373. ulUnicodeRange1 |= 1 << position;
  41374. } else if (position < 64) {
  41375. ulUnicodeRange2 |= 1 << position - 32;
  41376. } else if (position < 96) {
  41377. ulUnicodeRange3 |= 1 << position - 64;
  41378. } else if (position < 123) {
  41379. ulUnicodeRange4 |= 1 << position - 96;
  41380. } else {
  41381. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41382. }
  41383. }
  41384. } else {
  41385. firstCharIndex = 0;
  41386. lastCharIndex = 255;
  41387. }
  41388. var bbox = properties.bbox || [
  41389. 0,
  41390. 0,
  41391. 0,
  41392. 0
  41393. ];
  41394. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41395. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41396. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41397. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41398. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41399. typoDescent = -typoDescent;
  41400. }
  41401. var winAscent = override.yMax || typoAscent;
  41402. var winDescent = -override.yMin || -typoDescent;
  41403. 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';
  41404. }
  41405. function createPostTable(properties) {
  41406. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41407. 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';
  41408. }
  41409. function createNameTable(name, proto) {
  41410. if (!proto) {
  41411. proto = [
  41412. [],
  41413. []
  41414. ];
  41415. }
  41416. var strings = [
  41417. proto[0][0] || 'Original licence',
  41418. proto[0][1] || name,
  41419. proto[0][2] || 'Unknown',
  41420. proto[0][3] || 'uniqueID',
  41421. proto[0][4] || name,
  41422. proto[0][5] || 'Version 0.11',
  41423. proto[0][6] || '',
  41424. proto[0][7] || 'Unknown',
  41425. proto[0][8] || 'Unknown',
  41426. proto[0][9] || 'Unknown'
  41427. ];
  41428. var stringsUnicode = [];
  41429. var i, ii, j, jj, str;
  41430. for (i = 0, ii = strings.length; i < ii; i++) {
  41431. str = proto[1][i] || strings[i];
  41432. var strBufUnicode = [];
  41433. for (j = 0, jj = str.length; j < jj; j++) {
  41434. strBufUnicode.push(string16(str.charCodeAt(j)));
  41435. }
  41436. stringsUnicode.push(strBufUnicode.join(''));
  41437. }
  41438. var names = [
  41439. strings,
  41440. stringsUnicode
  41441. ];
  41442. var platforms = [
  41443. '\x00\x01',
  41444. '\x00\x03'
  41445. ];
  41446. var encodings = [
  41447. '\x00\x00',
  41448. '\x00\x01'
  41449. ];
  41450. var languages = [
  41451. '\x00\x00',
  41452. '\x04\x09'
  41453. ];
  41454. var namesRecordCount = strings.length * platforms.length;
  41455. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41456. var strOffset = 0;
  41457. for (i = 0, ii = platforms.length; i < ii; i++) {
  41458. var strs = names[i];
  41459. for (j = 0, jj = strs.length; j < jj; j++) {
  41460. str = strs[j];
  41461. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41462. nameTable += nameRecord;
  41463. strOffset += str.length;
  41464. }
  41465. }
  41466. nameTable += strings.join('') + stringsUnicode.join('');
  41467. return nameTable;
  41468. }
  41469. Font.prototype = {
  41470. name: null,
  41471. font: null,
  41472. mimetype: null,
  41473. encoding: null,
  41474. get renderer() {
  41475. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41476. return shadow(this, 'renderer', renderer);
  41477. },
  41478. exportData: function Font_exportData() {
  41479. var data = {};
  41480. for (var i in this) {
  41481. if (this.hasOwnProperty(i)) {
  41482. data[i] = this[i];
  41483. }
  41484. }
  41485. return data;
  41486. },
  41487. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41488. function readTableEntry(file) {
  41489. var tag = bytesToString(file.getBytes(4));
  41490. var checksum = file.getInt32() >>> 0;
  41491. var offset = file.getInt32() >>> 0;
  41492. var length = file.getInt32() >>> 0;
  41493. var previousPosition = file.pos;
  41494. file.pos = file.start ? file.start : 0;
  41495. file.skip(offset);
  41496. var data = file.getBytes(length);
  41497. file.pos = previousPosition;
  41498. if (tag === 'head') {
  41499. data[8] = data[9] = data[10] = data[11] = 0;
  41500. data[17] |= 0x20;
  41501. }
  41502. return {
  41503. tag: tag,
  41504. checksum: checksum,
  41505. length: length,
  41506. offset: offset,
  41507. data: data
  41508. };
  41509. }
  41510. function readOpenTypeHeader(ttf) {
  41511. return {
  41512. version: bytesToString(ttf.getBytes(4)),
  41513. numTables: ttf.getUint16(),
  41514. searchRange: ttf.getUint16(),
  41515. entrySelector: ttf.getUint16(),
  41516. rangeShift: ttf.getUint16()
  41517. };
  41518. }
  41519. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41520. if (!cmap) {
  41521. warn('No cmap table available.');
  41522. return {
  41523. platformId: -1,
  41524. encodingId: -1,
  41525. mappings: [],
  41526. hasShortCmap: false
  41527. };
  41528. }
  41529. var segment;
  41530. var start = (font.start ? font.start : 0) + cmap.offset;
  41531. font.pos = start;
  41532. var version = font.getUint16();
  41533. var numTables = font.getUint16();
  41534. var potentialTable;
  41535. var canBreak = false;
  41536. for (var i = 0; i < numTables; i++) {
  41537. var platformId = font.getUint16();
  41538. var encodingId = font.getUint16();
  41539. var offset = font.getInt32() >>> 0;
  41540. var useTable = false;
  41541. if (platformId === 0 && encodingId === 0) {
  41542. useTable = true;
  41543. } else if (platformId === 1 && encodingId === 0) {
  41544. useTable = true;
  41545. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41546. useTable = true;
  41547. if (!isSymbolicFont) {
  41548. canBreak = true;
  41549. }
  41550. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41551. useTable = true;
  41552. canBreak = true;
  41553. }
  41554. if (useTable) {
  41555. potentialTable = {
  41556. platformId: platformId,
  41557. encodingId: encodingId,
  41558. offset: offset
  41559. };
  41560. }
  41561. if (canBreak) {
  41562. break;
  41563. }
  41564. }
  41565. if (potentialTable) {
  41566. font.pos = start + potentialTable.offset;
  41567. }
  41568. if (!potentialTable || font.peekByte() === -1) {
  41569. warn('Could not find a preferred cmap table.');
  41570. return {
  41571. platformId: -1,
  41572. encodingId: -1,
  41573. mappings: [],
  41574. hasShortCmap: false
  41575. };
  41576. }
  41577. var format = font.getUint16();
  41578. var length = font.getUint16();
  41579. var language = font.getUint16();
  41580. var hasShortCmap = false;
  41581. var mappings = [];
  41582. var j, glyphId;
  41583. if (format === 0) {
  41584. for (j = 0; j < 256; j++) {
  41585. var index = font.getByte();
  41586. if (!index) {
  41587. continue;
  41588. }
  41589. mappings.push({
  41590. charCode: j,
  41591. glyphId: index
  41592. });
  41593. }
  41594. hasShortCmap = true;
  41595. } else if (format === 4) {
  41596. var segCount = font.getUint16() >> 1;
  41597. font.getBytes(6);
  41598. var segIndex, segments = [];
  41599. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41600. segments.push({ end: font.getUint16() });
  41601. }
  41602. font.getUint16();
  41603. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41604. segments[segIndex].start = font.getUint16();
  41605. }
  41606. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41607. segments[segIndex].delta = font.getUint16();
  41608. }
  41609. var offsetsCount = 0;
  41610. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41611. segment = segments[segIndex];
  41612. var rangeOffset = font.getUint16();
  41613. if (!rangeOffset) {
  41614. segment.offsetIndex = -1;
  41615. continue;
  41616. }
  41617. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41618. segment.offsetIndex = offsetIndex;
  41619. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41620. }
  41621. var offsets = [];
  41622. for (j = 0; j < offsetsCount; j++) {
  41623. offsets.push(font.getUint16());
  41624. }
  41625. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41626. segment = segments[segIndex];
  41627. start = segment.start;
  41628. var end = segment.end;
  41629. var delta = segment.delta;
  41630. offsetIndex = segment.offsetIndex;
  41631. for (j = start; j <= end; j++) {
  41632. if (j === 0xFFFF) {
  41633. continue;
  41634. }
  41635. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41636. glyphId = glyphId + delta & 0xFFFF;
  41637. if (glyphId === 0) {
  41638. continue;
  41639. }
  41640. mappings.push({
  41641. charCode: j,
  41642. glyphId: glyphId
  41643. });
  41644. }
  41645. }
  41646. } else if (format === 6) {
  41647. var firstCode = font.getUint16();
  41648. var entryCount = font.getUint16();
  41649. for (j = 0; j < entryCount; j++) {
  41650. glyphId = font.getUint16();
  41651. var charCode = firstCode + j;
  41652. mappings.push({
  41653. charCode: charCode,
  41654. glyphId: glyphId
  41655. });
  41656. }
  41657. } else {
  41658. warn('cmap table has unsupported format: ' + format);
  41659. return {
  41660. platformId: -1,
  41661. encodingId: -1,
  41662. mappings: [],
  41663. hasShortCmap: false
  41664. };
  41665. }
  41666. mappings.sort(function (a, b) {
  41667. return a.charCode - b.charCode;
  41668. });
  41669. for (i = 1; i < mappings.length; i++) {
  41670. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41671. mappings.splice(i, 1);
  41672. i--;
  41673. }
  41674. }
  41675. return {
  41676. platformId: potentialTable.platformId,
  41677. encodingId: potentialTable.encodingId,
  41678. mappings: mappings,
  41679. hasShortCmap: hasShortCmap
  41680. };
  41681. }
  41682. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41683. if (!header) {
  41684. if (metrics) {
  41685. metrics.data = null;
  41686. }
  41687. return;
  41688. }
  41689. font.pos = (font.start ? font.start : 0) + header.offset;
  41690. font.pos += header.length - 2;
  41691. var numOfMetrics = font.getUint16();
  41692. if (numOfMetrics > numGlyphs) {
  41693. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41694. numOfMetrics = numGlyphs;
  41695. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41696. header.data[35] = numOfMetrics & 0x00ff;
  41697. }
  41698. var numOfSidebearings = numGlyphs - numOfMetrics;
  41699. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41700. if (numMissing > 0) {
  41701. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41702. entries.set(metrics.data);
  41703. metrics.data = entries;
  41704. }
  41705. }
  41706. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41707. if (sourceEnd - sourceStart <= 12) {
  41708. return 0;
  41709. }
  41710. var glyf = source.subarray(sourceStart, sourceEnd);
  41711. var contoursCount = glyf[0] << 8 | glyf[1];
  41712. if (contoursCount & 0x8000) {
  41713. dest.set(glyf, destStart);
  41714. return glyf.length;
  41715. }
  41716. var i, j = 10, flagsCount = 0;
  41717. for (i = 0; i < contoursCount; i++) {
  41718. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41719. flagsCount = endPoint + 1;
  41720. j += 2;
  41721. }
  41722. var instructionsStart = j;
  41723. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41724. j += 2 + instructionsLength;
  41725. var instructionsEnd = j;
  41726. var coordinatesLength = 0;
  41727. for (i = 0; i < flagsCount; i++) {
  41728. var flag = glyf[j++];
  41729. if (flag & 0xC0) {
  41730. glyf[j - 1] = flag & 0x3F;
  41731. }
  41732. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41733. coordinatesLength += xyLength;
  41734. if (flag & 8) {
  41735. var repeat = glyf[j++];
  41736. i += repeat;
  41737. coordinatesLength += repeat * xyLength;
  41738. }
  41739. }
  41740. if (coordinatesLength === 0) {
  41741. return 0;
  41742. }
  41743. var glyphDataLength = j + coordinatesLength;
  41744. if (glyphDataLength > glyf.length) {
  41745. return 0;
  41746. }
  41747. if (!hintsValid && instructionsLength > 0) {
  41748. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41749. dest.set([
  41750. 0,
  41751. 0
  41752. ], destStart + instructionsStart);
  41753. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41754. glyphDataLength -= instructionsLength;
  41755. if (glyf.length - glyphDataLength > 3) {
  41756. glyphDataLength = glyphDataLength + 3 & ~3;
  41757. }
  41758. return glyphDataLength;
  41759. }
  41760. if (glyf.length - glyphDataLength > 3) {
  41761. glyphDataLength = glyphDataLength + 3 & ~3;
  41762. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41763. return glyphDataLength;
  41764. }
  41765. dest.set(glyf, destStart);
  41766. return glyf.length;
  41767. }
  41768. function sanitizeHead(head, numGlyphs, locaLength) {
  41769. var data = head.data;
  41770. var version = int32(data[0], data[1], data[2], data[3]);
  41771. if (version >> 16 !== 1) {
  41772. info('Attempting to fix invalid version in head table: ' + version);
  41773. data[0] = 0;
  41774. data[1] = 1;
  41775. data[2] = 0;
  41776. data[3] = 0;
  41777. }
  41778. var indexToLocFormat = int16(data[50], data[51]);
  41779. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41780. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41781. var numGlyphsPlusOne = numGlyphs + 1;
  41782. if (locaLength === numGlyphsPlusOne << 1) {
  41783. data[50] = 0;
  41784. data[51] = 0;
  41785. } else if (locaLength === numGlyphsPlusOne << 2) {
  41786. data[50] = 0;
  41787. data[51] = 1;
  41788. } else {
  41789. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41790. }
  41791. }
  41792. }
  41793. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41794. var itemSize, itemDecode, itemEncode;
  41795. if (isGlyphLocationsLong) {
  41796. itemSize = 4;
  41797. itemDecode = function fontItemDecodeLong(data, offset) {
  41798. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41799. };
  41800. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41801. data[offset] = value >>> 24 & 0xFF;
  41802. data[offset + 1] = value >> 16 & 0xFF;
  41803. data[offset + 2] = value >> 8 & 0xFF;
  41804. data[offset + 3] = value & 0xFF;
  41805. };
  41806. } else {
  41807. itemSize = 2;
  41808. itemDecode = function fontItemDecode(data, offset) {
  41809. return data[offset] << 9 | data[offset + 1] << 1;
  41810. };
  41811. itemEncode = function fontItemEncode(data, offset, value) {
  41812. data[offset] = value >> 9 & 0xFF;
  41813. data[offset + 1] = value >> 1 & 0xFF;
  41814. };
  41815. }
  41816. var locaData = loca.data;
  41817. var locaDataSize = itemSize * (1 + numGlyphs);
  41818. if (locaData.length !== locaDataSize) {
  41819. locaData = new Uint8Array(locaDataSize);
  41820. locaData.set(loca.data.subarray(0, locaDataSize));
  41821. loca.data = locaData;
  41822. }
  41823. var oldGlyfData = glyf.data;
  41824. var oldGlyfDataLength = oldGlyfData.length;
  41825. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41826. var startOffset = itemDecode(locaData, 0);
  41827. var writeOffset = 0;
  41828. var missingGlyphData = Object.create(null);
  41829. itemEncode(locaData, 0, writeOffset);
  41830. var i, j;
  41831. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41832. var endOffset = itemDecode(locaData, j);
  41833. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  41834. endOffset = oldGlyfDataLength;
  41835. }
  41836. if (endOffset > oldGlyfDataLength) {
  41837. itemEncode(locaData, j, writeOffset);
  41838. startOffset = endOffset;
  41839. continue;
  41840. }
  41841. if (startOffset === endOffset) {
  41842. missingGlyphData[i] = true;
  41843. }
  41844. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  41845. writeOffset += newLength;
  41846. itemEncode(locaData, j, writeOffset);
  41847. startOffset = endOffset;
  41848. }
  41849. if (writeOffset === 0) {
  41850. var simpleGlyph = new Uint8Array([
  41851. 0,
  41852. 1,
  41853. 0,
  41854. 0,
  41855. 0,
  41856. 0,
  41857. 0,
  41858. 0,
  41859. 0,
  41860. 0,
  41861. 0,
  41862. 0,
  41863. 0,
  41864. 0,
  41865. 49,
  41866. 0
  41867. ]);
  41868. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41869. itemEncode(locaData, j, simpleGlyph.length);
  41870. }
  41871. glyf.data = simpleGlyph;
  41872. return missingGlyphData;
  41873. }
  41874. if (dupFirstEntry) {
  41875. var firstEntryLength = itemDecode(locaData, itemSize);
  41876. if (newGlyfData.length > firstEntryLength + writeOffset) {
  41877. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  41878. } else {
  41879. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  41880. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  41881. }
  41882. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  41883. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  41884. } else {
  41885. glyf.data = newGlyfData.subarray(0, writeOffset);
  41886. }
  41887. return missingGlyphData;
  41888. }
  41889. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  41890. var start = (font.start ? font.start : 0) + post.offset;
  41891. font.pos = start;
  41892. var length = post.length, end = start + length;
  41893. var version = font.getInt32();
  41894. font.getBytes(28);
  41895. var glyphNames;
  41896. var valid = true;
  41897. var i;
  41898. switch (version) {
  41899. case 0x00010000:
  41900. glyphNames = MacStandardGlyphOrdering;
  41901. break;
  41902. case 0x00020000:
  41903. var numGlyphs = font.getUint16();
  41904. if (numGlyphs !== maxpNumGlyphs) {
  41905. valid = false;
  41906. break;
  41907. }
  41908. var glyphNameIndexes = [];
  41909. for (i = 0; i < numGlyphs; ++i) {
  41910. var index = font.getUint16();
  41911. if (index >= 32768) {
  41912. valid = false;
  41913. break;
  41914. }
  41915. glyphNameIndexes.push(index);
  41916. }
  41917. if (!valid) {
  41918. break;
  41919. }
  41920. var customNames = [];
  41921. var strBuf = [];
  41922. while (font.pos < end) {
  41923. var stringLength = font.getByte();
  41924. strBuf.length = stringLength;
  41925. for (i = 0; i < stringLength; ++i) {
  41926. strBuf[i] = String.fromCharCode(font.getByte());
  41927. }
  41928. customNames.push(strBuf.join(''));
  41929. }
  41930. glyphNames = [];
  41931. for (i = 0; i < numGlyphs; ++i) {
  41932. var j = glyphNameIndexes[i];
  41933. if (j < 258) {
  41934. glyphNames.push(MacStandardGlyphOrdering[j]);
  41935. continue;
  41936. }
  41937. glyphNames.push(customNames[j - 258]);
  41938. }
  41939. break;
  41940. case 0x00030000:
  41941. break;
  41942. default:
  41943. warn('Unknown/unsupported post table version ' + version);
  41944. valid = false;
  41945. if (properties.defaultEncoding) {
  41946. glyphNames = properties.defaultEncoding;
  41947. }
  41948. break;
  41949. }
  41950. properties.glyphNames = glyphNames;
  41951. return valid;
  41952. }
  41953. function readNameTable(nameTable) {
  41954. var start = (font.start ? font.start : 0) + nameTable.offset;
  41955. font.pos = start;
  41956. var names = [
  41957. [],
  41958. []
  41959. ];
  41960. var length = nameTable.length, end = start + length;
  41961. var format = font.getUint16();
  41962. var FORMAT_0_HEADER_LENGTH = 6;
  41963. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  41964. return names;
  41965. }
  41966. var numRecords = font.getUint16();
  41967. var stringsStart = font.getUint16();
  41968. var records = [];
  41969. var NAME_RECORD_LENGTH = 12;
  41970. var i, ii;
  41971. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  41972. var r = {
  41973. platform: font.getUint16(),
  41974. encoding: font.getUint16(),
  41975. language: font.getUint16(),
  41976. name: font.getUint16(),
  41977. length: font.getUint16(),
  41978. offset: font.getUint16()
  41979. };
  41980. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  41981. records.push(r);
  41982. }
  41983. }
  41984. for (i = 0, ii = records.length; i < ii; i++) {
  41985. var record = records[i];
  41986. if (record.length <= 0) {
  41987. continue;
  41988. }
  41989. var pos = start + stringsStart + record.offset;
  41990. if (pos + record.length > end) {
  41991. continue;
  41992. }
  41993. font.pos = pos;
  41994. var nameIndex = record.name;
  41995. if (record.encoding) {
  41996. var str = '';
  41997. for (var j = 0, jj = record.length; j < jj; j += 2) {
  41998. str += String.fromCharCode(font.getUint16());
  41999. }
  42000. names[1][nameIndex] = str;
  42001. } else {
  42002. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  42003. }
  42004. }
  42005. return names;
  42006. }
  42007. var TTOpsStackDeltas = [
  42008. 0,
  42009. 0,
  42010. 0,
  42011. 0,
  42012. 0,
  42013. 0,
  42014. 0,
  42015. 0,
  42016. -2,
  42017. -2,
  42018. -2,
  42019. -2,
  42020. 0,
  42021. 0,
  42022. -2,
  42023. -5,
  42024. -1,
  42025. -1,
  42026. -1,
  42027. -1,
  42028. -1,
  42029. -1,
  42030. -1,
  42031. -1,
  42032. 0,
  42033. 0,
  42034. -1,
  42035. 0,
  42036. -1,
  42037. -1,
  42038. -1,
  42039. -1,
  42040. 1,
  42041. -1,
  42042. -999,
  42043. 0,
  42044. 1,
  42045. 0,
  42046. -1,
  42047. -2,
  42048. 0,
  42049. -1,
  42050. -2,
  42051. -1,
  42052. -1,
  42053. 0,
  42054. -1,
  42055. -1,
  42056. 0,
  42057. 0,
  42058. -999,
  42059. -999,
  42060. -1,
  42061. -1,
  42062. -1,
  42063. -1,
  42064. -2,
  42065. -999,
  42066. -2,
  42067. -2,
  42068. -999,
  42069. 0,
  42070. -2,
  42071. -2,
  42072. 0,
  42073. 0,
  42074. -2,
  42075. 0,
  42076. -2,
  42077. 0,
  42078. 0,
  42079. 0,
  42080. -2,
  42081. -1,
  42082. -1,
  42083. 1,
  42084. 1,
  42085. 0,
  42086. 0,
  42087. -1,
  42088. -1,
  42089. -1,
  42090. -1,
  42091. -1,
  42092. -1,
  42093. -1,
  42094. 0,
  42095. 0,
  42096. -1,
  42097. 0,
  42098. -1,
  42099. -1,
  42100. 0,
  42101. -999,
  42102. -1,
  42103. -1,
  42104. -1,
  42105. -1,
  42106. -1,
  42107. -1,
  42108. 0,
  42109. 0,
  42110. 0,
  42111. 0,
  42112. 0,
  42113. 0,
  42114. 0,
  42115. 0,
  42116. 0,
  42117. 0,
  42118. 0,
  42119. 0,
  42120. -2,
  42121. -999,
  42122. -999,
  42123. -999,
  42124. -999,
  42125. -999,
  42126. -1,
  42127. -1,
  42128. -2,
  42129. -2,
  42130. 0,
  42131. 0,
  42132. 0,
  42133. 0,
  42134. -1,
  42135. -1,
  42136. -999,
  42137. -2,
  42138. -2,
  42139. 0,
  42140. 0,
  42141. -1,
  42142. -2,
  42143. -2,
  42144. 0,
  42145. 0,
  42146. 0,
  42147. -1,
  42148. -1,
  42149. -1,
  42150. -2
  42151. ];
  42152. function sanitizeTTProgram(table, ttContext) {
  42153. var data = table.data;
  42154. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42155. var stack = [];
  42156. var callstack = [];
  42157. var functionsCalled = [];
  42158. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42159. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42160. for (var ii = data.length; i < ii;) {
  42161. var op = data[i++];
  42162. if (op === 0x40) {
  42163. n = data[i++];
  42164. if (inFDEF || inELSE) {
  42165. i += n;
  42166. } else {
  42167. for (j = 0; j < n; j++) {
  42168. stack.push(data[i++]);
  42169. }
  42170. }
  42171. } else if (op === 0x41) {
  42172. n = data[i++];
  42173. if (inFDEF || inELSE) {
  42174. i += n * 2;
  42175. } else {
  42176. for (j = 0; j < n; j++) {
  42177. b = data[i++];
  42178. stack.push(b << 8 | data[i++]);
  42179. }
  42180. }
  42181. } else if ((op & 0xF8) === 0xB0) {
  42182. n = op - 0xB0 + 1;
  42183. if (inFDEF || inELSE) {
  42184. i += n;
  42185. } else {
  42186. for (j = 0; j < n; j++) {
  42187. stack.push(data[i++]);
  42188. }
  42189. }
  42190. } else if ((op & 0xF8) === 0xB8) {
  42191. n = op - 0xB8 + 1;
  42192. if (inFDEF || inELSE) {
  42193. i += n * 2;
  42194. } else {
  42195. for (j = 0; j < n; j++) {
  42196. b = data[i++];
  42197. stack.push(b << 8 | data[i++]);
  42198. }
  42199. }
  42200. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42201. if (!inFDEF && !inELSE) {
  42202. funcId = stack[stack.length - 1];
  42203. ttContext.functionsUsed[funcId] = true;
  42204. if (funcId in ttContext.functionsStackDeltas) {
  42205. stack.length += ttContext.functionsStackDeltas[funcId];
  42206. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42207. callstack.push({
  42208. data: data,
  42209. i: i,
  42210. stackTop: stack.length - 1
  42211. });
  42212. functionsCalled.push(funcId);
  42213. pc = ttContext.functionsDefined[funcId];
  42214. if (!pc) {
  42215. warn('TT: CALL non-existent function');
  42216. ttContext.hintsValid = false;
  42217. return;
  42218. }
  42219. data = pc.data;
  42220. i = pc.i;
  42221. }
  42222. }
  42223. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42224. if (inFDEF || inELSE) {
  42225. warn('TT: nested FDEFs not allowed');
  42226. tooComplexToFollowFunctions = true;
  42227. }
  42228. inFDEF = true;
  42229. lastDeff = i;
  42230. funcId = stack.pop();
  42231. ttContext.functionsDefined[funcId] = {
  42232. data: data,
  42233. i: i
  42234. };
  42235. } else if (op === 0x2D) {
  42236. if (inFDEF) {
  42237. inFDEF = false;
  42238. lastEndf = i;
  42239. } else {
  42240. pc = callstack.pop();
  42241. if (!pc) {
  42242. warn('TT: ENDF bad stack');
  42243. ttContext.hintsValid = false;
  42244. return;
  42245. }
  42246. funcId = functionsCalled.pop();
  42247. data = pc.data;
  42248. i = pc.i;
  42249. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42250. }
  42251. } else if (op === 0x89) {
  42252. if (inFDEF || inELSE) {
  42253. warn('TT: nested IDEFs not allowed');
  42254. tooComplexToFollowFunctions = true;
  42255. }
  42256. inFDEF = true;
  42257. lastDeff = i;
  42258. } else if (op === 0x58) {
  42259. ++ifLevel;
  42260. } else if (op === 0x1B) {
  42261. inELSE = ifLevel;
  42262. } else if (op === 0x59) {
  42263. if (inELSE === ifLevel) {
  42264. inELSE = 0;
  42265. }
  42266. --ifLevel;
  42267. } else if (op === 0x1C) {
  42268. if (!inFDEF && !inELSE) {
  42269. var offset = stack[stack.length - 1];
  42270. if (offset > 0) {
  42271. i += offset - 1;
  42272. }
  42273. }
  42274. }
  42275. if (!inFDEF && !inELSE) {
  42276. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42277. if (op >= 0x71 && op <= 0x75) {
  42278. n = stack.pop();
  42279. if (n === n) {
  42280. stackDelta = -n * 2;
  42281. }
  42282. }
  42283. while (stackDelta < 0 && stack.length > 0) {
  42284. stack.pop();
  42285. stackDelta++;
  42286. }
  42287. while (stackDelta > 0) {
  42288. stack.push(NaN);
  42289. stackDelta--;
  42290. }
  42291. }
  42292. }
  42293. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42294. var content = [data];
  42295. if (i > data.length) {
  42296. content.push(new Uint8Array(i - data.length));
  42297. }
  42298. if (lastDeff > lastEndf) {
  42299. warn('TT: complementing a missing function tail');
  42300. content.push(new Uint8Array([
  42301. 0x22,
  42302. 0x2D
  42303. ]));
  42304. }
  42305. foldTTTable(table, content);
  42306. }
  42307. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42308. if (ttContext.tooComplexToFollowFunctions) {
  42309. return;
  42310. }
  42311. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42312. warn('TT: more functions defined than expected');
  42313. ttContext.hintsValid = false;
  42314. return;
  42315. }
  42316. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42317. if (j > maxFunctionDefs) {
  42318. warn('TT: invalid function id: ' + j);
  42319. ttContext.hintsValid = false;
  42320. return;
  42321. }
  42322. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42323. warn('TT: undefined function: ' + j);
  42324. ttContext.hintsValid = false;
  42325. return;
  42326. }
  42327. }
  42328. }
  42329. function foldTTTable(table, content) {
  42330. if (content.length > 1) {
  42331. var newLength = 0;
  42332. var j, jj;
  42333. for (j = 0, jj = content.length; j < jj; j++) {
  42334. newLength += content[j].length;
  42335. }
  42336. newLength = newLength + 3 & ~3;
  42337. var result = new Uint8Array(newLength);
  42338. var pos = 0;
  42339. for (j = 0, jj = content.length; j < jj; j++) {
  42340. result.set(content[j], pos);
  42341. pos += content[j].length;
  42342. }
  42343. table.data = result;
  42344. table.length = newLength;
  42345. }
  42346. }
  42347. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42348. var ttContext = {
  42349. functionsDefined: [],
  42350. functionsUsed: [],
  42351. functionsStackDeltas: [],
  42352. tooComplexToFollowFunctions: false,
  42353. hintsValid: true
  42354. };
  42355. if (fpgm) {
  42356. sanitizeTTProgram(fpgm, ttContext);
  42357. }
  42358. if (prep) {
  42359. sanitizeTTProgram(prep, ttContext);
  42360. }
  42361. if (fpgm) {
  42362. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42363. }
  42364. if (cvt && cvt.length & 1) {
  42365. var cvtData = new Uint8Array(cvt.length + 1);
  42366. cvtData.set(cvt.data);
  42367. cvt.data = cvtData;
  42368. }
  42369. return ttContext.hintsValid;
  42370. }
  42371. font = new Stream(new Uint8Array(font.getBytes()));
  42372. var VALID_TABLES = [
  42373. 'OS/2',
  42374. 'cmap',
  42375. 'head',
  42376. 'hhea',
  42377. 'hmtx',
  42378. 'maxp',
  42379. 'name',
  42380. 'post',
  42381. 'loca',
  42382. 'glyf',
  42383. 'fpgm',
  42384. 'prep',
  42385. 'cvt ',
  42386. 'CFF '
  42387. ];
  42388. var header = readOpenTypeHeader(font);
  42389. var numTables = header.numTables;
  42390. var cff, cffFile;
  42391. var tables = Object.create(null);
  42392. tables['OS/2'] = null;
  42393. tables['cmap'] = null;
  42394. tables['head'] = null;
  42395. tables['hhea'] = null;
  42396. tables['hmtx'] = null;
  42397. tables['maxp'] = null;
  42398. tables['name'] = null;
  42399. tables['post'] = null;
  42400. var table;
  42401. for (var i = 0; i < numTables; i++) {
  42402. table = readTableEntry(font);
  42403. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42404. continue;
  42405. }
  42406. if (table.length === 0) {
  42407. continue;
  42408. }
  42409. tables[table.tag] = table;
  42410. }
  42411. var isTrueType = !tables['CFF '];
  42412. if (!isTrueType) {
  42413. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42414. cffFile = new Stream(tables['CFF '].data);
  42415. cff = new CFFFont(cffFile, properties);
  42416. adjustWidths(properties);
  42417. return this.convert(name, cff, properties);
  42418. }
  42419. delete tables['glyf'];
  42420. delete tables['loca'];
  42421. delete tables['fpgm'];
  42422. delete tables['prep'];
  42423. delete tables['cvt '];
  42424. this.isOpenType = true;
  42425. } else {
  42426. if (!tables['loca']) {
  42427. error('Required "loca" table is not found');
  42428. }
  42429. if (!tables['glyf']) {
  42430. warn('Required "glyf" table is not found -- trying to recover.');
  42431. tables['glyf'] = {
  42432. tag: 'glyf',
  42433. data: new Uint8Array(0)
  42434. };
  42435. }
  42436. this.isOpenType = false;
  42437. }
  42438. if (!tables['maxp']) {
  42439. error('Required "maxp" table is not found');
  42440. }
  42441. font.pos = (font.start || 0) + tables['maxp'].offset;
  42442. var version = font.getInt32();
  42443. var numGlyphs = font.getUint16();
  42444. var maxFunctionDefs = 0;
  42445. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42446. font.pos += 8;
  42447. var maxZones = font.getUint16();
  42448. if (maxZones > 2) {
  42449. tables['maxp'].data[14] = 0;
  42450. tables['maxp'].data[15] = 2;
  42451. }
  42452. font.pos += 4;
  42453. maxFunctionDefs = font.getUint16();
  42454. }
  42455. var dupFirstEntry = false;
  42456. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42457. dupFirstEntry = true;
  42458. numGlyphs++;
  42459. tables['maxp'].data[4] = numGlyphs >> 8;
  42460. tables['maxp'].data[5] = numGlyphs & 255;
  42461. }
  42462. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42463. if (!hintsValid) {
  42464. delete tables['fpgm'];
  42465. delete tables['prep'];
  42466. delete tables['cvt '];
  42467. }
  42468. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42469. if (!tables['head']) {
  42470. error('Required "head" table is not found');
  42471. }
  42472. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42473. var missingGlyphs = Object.create(null);
  42474. if (isTrueType) {
  42475. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42476. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42477. }
  42478. if (!tables['hhea']) {
  42479. error('Required "hhea" table is not found');
  42480. }
  42481. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42482. tables['hhea'].data[10] = 0xFF;
  42483. tables['hhea'].data[11] = 0xFF;
  42484. }
  42485. var metricsOverride = {
  42486. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42487. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42488. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42489. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42490. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42491. };
  42492. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42493. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42494. if (tables['post']) {
  42495. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42496. if (!valid) {
  42497. tables['post'] = null;
  42498. }
  42499. }
  42500. var charCodeToGlyphId = [], charCode;
  42501. var toUnicode = properties.toUnicode, widths = properties.widths;
  42502. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42503. function hasGlyph(glyphId, charCode, widthCode) {
  42504. if (!missingGlyphs[glyphId]) {
  42505. return true;
  42506. }
  42507. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42508. return true;
  42509. }
  42510. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42511. return true;
  42512. }
  42513. return false;
  42514. }
  42515. if (properties.type === 'CIDFontType2') {
  42516. var cidToGidMap = properties.cidToGidMap || [];
  42517. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42518. properties.cMap.forEach(function (charCode, cid) {
  42519. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42520. var glyphId = -1;
  42521. if (isCidToGidMapEmpty) {
  42522. glyphId = cid;
  42523. } else if (cidToGidMap[cid] !== undefined) {
  42524. glyphId = cidToGidMap[cid];
  42525. }
  42526. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42527. charCodeToGlyphId[charCode] = glyphId;
  42528. }
  42529. });
  42530. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42531. charCodeToGlyphId[0] = numGlyphs - 1;
  42532. }
  42533. } else {
  42534. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42535. var cmapPlatformId = cmapTable.platformId;
  42536. var cmapEncodingId = cmapTable.encodingId;
  42537. var cmapMappings = cmapTable.mappings;
  42538. var cmapMappingsLength = cmapMappings.length;
  42539. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42540. var baseEncoding = [];
  42541. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42542. baseEncoding = getEncoding(properties.baseEncodingName);
  42543. }
  42544. var glyphsUnicodeMap = getGlyphsUnicode();
  42545. for (charCode = 0; charCode < 256; charCode++) {
  42546. var glyphName, standardGlyphName;
  42547. if (this.differences && charCode in this.differences) {
  42548. glyphName = this.differences[charCode];
  42549. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42550. glyphName = baseEncoding[charCode];
  42551. } else {
  42552. glyphName = StandardEncoding[charCode];
  42553. }
  42554. if (!glyphName) {
  42555. continue;
  42556. }
  42557. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42558. var unicodeOrCharCode, isUnicode = false;
  42559. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42560. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42561. isUnicode = true;
  42562. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42563. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42564. }
  42565. var found = false;
  42566. for (i = 0; i < cmapMappingsLength; ++i) {
  42567. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42568. continue;
  42569. }
  42570. var code = isUnicode ? charCode : unicodeOrCharCode;
  42571. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42572. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42573. found = true;
  42574. break;
  42575. }
  42576. }
  42577. if (!found && properties.glyphNames) {
  42578. var glyphId = properties.glyphNames.indexOf(glyphName);
  42579. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42580. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42581. }
  42582. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42583. charCodeToGlyphId[charCode] = glyphId;
  42584. found = true;
  42585. }
  42586. }
  42587. if (!found) {
  42588. charCodeToGlyphId[charCode] = 0;
  42589. }
  42590. }
  42591. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42592. for (i = 0; i < cmapMappingsLength; ++i) {
  42593. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42594. }
  42595. } else {
  42596. for (i = 0; i < cmapMappingsLength; ++i) {
  42597. charCode = cmapMappings[i].charCode & 0xFF;
  42598. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42599. }
  42600. }
  42601. }
  42602. if (charCodeToGlyphId.length === 0) {
  42603. charCodeToGlyphId[0] = 0;
  42604. }
  42605. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42606. this.toFontChar = newMapping.toFontChar;
  42607. tables['cmap'] = {
  42608. tag: 'cmap',
  42609. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42610. };
  42611. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42612. tables['OS/2'] = {
  42613. tag: 'OS/2',
  42614. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42615. };
  42616. }
  42617. if (!tables['post']) {
  42618. tables['post'] = {
  42619. tag: 'post',
  42620. data: createPostTable(properties)
  42621. };
  42622. }
  42623. if (!isTrueType) {
  42624. try {
  42625. cffFile = new Stream(tables['CFF '].data);
  42626. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42627. cff = parser.parse();
  42628. var compiler = new CFFCompiler(cff);
  42629. tables['CFF '].data = compiler.compile();
  42630. } catch (e) {
  42631. warn('Failed to compile font ' + properties.loadedName);
  42632. }
  42633. }
  42634. if (!tables['name']) {
  42635. tables['name'] = {
  42636. tag: 'name',
  42637. data: createNameTable(this.name)
  42638. };
  42639. } else {
  42640. var namePrototype = readNameTable(tables['name']);
  42641. tables['name'].data = createNameTable(name, namePrototype);
  42642. }
  42643. var builder = new OpenTypeFileBuilder(header.version);
  42644. for (var tableTag in tables) {
  42645. builder.addTable(tableTag, tables[tableTag].data);
  42646. }
  42647. return builder.toArray();
  42648. },
  42649. convert: function Font_convert(fontName, font, properties) {
  42650. properties.fixedPitch = false;
  42651. if (properties.builtInEncoding) {
  42652. adjustToUnicode(properties, properties.builtInEncoding);
  42653. }
  42654. var mapping = font.getGlyphMapping(properties);
  42655. var newMapping = adjustMapping(mapping, properties);
  42656. this.toFontChar = newMapping.toFontChar;
  42657. var numGlyphs = font.numGlyphs;
  42658. function getCharCodes(charCodeToGlyphId, glyphId) {
  42659. var charCodes = null;
  42660. for (var charCode in charCodeToGlyphId) {
  42661. if (glyphId === charCodeToGlyphId[charCode]) {
  42662. if (!charCodes) {
  42663. charCodes = [];
  42664. }
  42665. charCodes.push(charCode | 0);
  42666. }
  42667. }
  42668. return charCodes;
  42669. }
  42670. function createCharCode(charCodeToGlyphId, glyphId) {
  42671. for (var charCode in charCodeToGlyphId) {
  42672. if (glyphId === charCodeToGlyphId[charCode]) {
  42673. return charCode | 0;
  42674. }
  42675. }
  42676. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42677. return newMapping.nextAvailableFontCharCode++;
  42678. }
  42679. var seacs = font.seacs;
  42680. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42681. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42682. var charset = font.getCharset();
  42683. var seacMap = Object.create(null);
  42684. for (var glyphId in seacs) {
  42685. glyphId |= 0;
  42686. var seac = seacs[glyphId];
  42687. var baseGlyphName = StandardEncoding[seac[2]];
  42688. var accentGlyphName = StandardEncoding[seac[3]];
  42689. var baseGlyphId = charset.indexOf(baseGlyphName);
  42690. var accentGlyphId = charset.indexOf(accentGlyphName);
  42691. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42692. continue;
  42693. }
  42694. var accentOffset = {
  42695. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42696. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42697. };
  42698. var charCodes = getCharCodes(mapping, glyphId);
  42699. if (!charCodes) {
  42700. continue;
  42701. }
  42702. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42703. var charCode = charCodes[i];
  42704. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42705. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42706. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42707. seacMap[charCode] = {
  42708. baseFontCharCode: baseFontCharCode,
  42709. accentFontCharCode: accentFontCharCode,
  42710. accentOffset: accentOffset
  42711. };
  42712. }
  42713. }
  42714. properties.seacMap = seacMap;
  42715. }
  42716. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42717. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42718. builder.addTable('CFF ', font.data);
  42719. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42720. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42721. 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');
  42722. 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));
  42723. builder.addTable('hmtx', function fontFieldsHmtx() {
  42724. var charstrings = font.charstrings;
  42725. var cffWidths = font.cff ? font.cff.widths : null;
  42726. var hmtx = '\x00\x00\x00\x00';
  42727. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42728. var width = 0;
  42729. if (charstrings) {
  42730. var charstring = charstrings[i - 1];
  42731. width = 'width' in charstring ? charstring.width : 0;
  42732. } else if (cffWidths) {
  42733. width = Math.ceil(cffWidths[i] || 0);
  42734. }
  42735. hmtx += string16(width) + string16(0);
  42736. }
  42737. return hmtx;
  42738. }());
  42739. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42740. builder.addTable('name', createNameTable(fontName));
  42741. builder.addTable('post', createPostTable(properties));
  42742. return builder.toArray();
  42743. },
  42744. get spaceWidth() {
  42745. if ('_shadowWidth' in this) {
  42746. return this._shadowWidth;
  42747. }
  42748. var possibleSpaceReplacements = [
  42749. 'space',
  42750. 'minus',
  42751. 'one',
  42752. 'i',
  42753. 'I'
  42754. ];
  42755. var width;
  42756. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42757. var glyphName = possibleSpaceReplacements[i];
  42758. if (glyphName in this.widths) {
  42759. width = this.widths[glyphName];
  42760. break;
  42761. }
  42762. var glyphsUnicodeMap = getGlyphsUnicode();
  42763. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42764. var charcode = 0;
  42765. if (this.composite) {
  42766. if (this.cMap.contains(glyphUnicode)) {
  42767. charcode = this.cMap.lookup(glyphUnicode);
  42768. }
  42769. }
  42770. if (!charcode && this.toUnicode) {
  42771. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42772. }
  42773. if (charcode <= 0) {
  42774. charcode = glyphUnicode;
  42775. }
  42776. width = this.widths[charcode];
  42777. if (width) {
  42778. break;
  42779. }
  42780. }
  42781. width = width || this.defaultWidth;
  42782. this._shadowWidth = width;
  42783. return width;
  42784. },
  42785. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42786. var fontCharCode, width, operatorListId;
  42787. var widthCode = charcode;
  42788. if (this.cMap && this.cMap.contains(charcode)) {
  42789. widthCode = this.cMap.lookup(charcode);
  42790. }
  42791. width = this.widths[widthCode];
  42792. width = isNum(width) ? width : this.defaultWidth;
  42793. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42794. var unicode = this.toUnicode.get(charcode) || charcode;
  42795. if (typeof unicode === 'number') {
  42796. unicode = String.fromCharCode(unicode);
  42797. }
  42798. var isInFont = charcode in this.toFontChar;
  42799. fontCharCode = this.toFontChar[charcode] || charcode;
  42800. if (this.missingFile) {
  42801. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42802. }
  42803. if (this.isType3Font) {
  42804. operatorListId = fontCharCode;
  42805. }
  42806. var accent = null;
  42807. if (this.seacMap && this.seacMap[charcode]) {
  42808. isInFont = true;
  42809. var seac = this.seacMap[charcode];
  42810. fontCharCode = seac.baseFontCharCode;
  42811. accent = {
  42812. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42813. offset: seac.accentOffset
  42814. };
  42815. }
  42816. var fontChar = String.fromCharCode(fontCharCode);
  42817. var glyph = this.glyphCache[charcode];
  42818. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42819. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42820. this.glyphCache[charcode] = glyph;
  42821. }
  42822. return glyph;
  42823. },
  42824. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42825. var charsCache = this.charsCache;
  42826. var glyphs, glyph, charcode;
  42827. if (charsCache) {
  42828. glyphs = charsCache[chars];
  42829. if (glyphs) {
  42830. return glyphs;
  42831. }
  42832. }
  42833. if (!charsCache) {
  42834. charsCache = this.charsCache = Object.create(null);
  42835. }
  42836. glyphs = [];
  42837. var charsCacheKey = chars;
  42838. var i = 0, ii;
  42839. if (this.cMap) {
  42840. var c = Object.create(null);
  42841. while (i < chars.length) {
  42842. this.cMap.readCharCode(chars, i, c);
  42843. charcode = c.charcode;
  42844. var length = c.length;
  42845. i += length;
  42846. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  42847. glyph = this.charToGlyph(charcode, isSpace);
  42848. glyphs.push(glyph);
  42849. }
  42850. } else {
  42851. for (i = 0, ii = chars.length; i < ii; ++i) {
  42852. charcode = chars.charCodeAt(i);
  42853. glyph = this.charToGlyph(charcode, charcode === 0x20);
  42854. glyphs.push(glyph);
  42855. }
  42856. }
  42857. return charsCache[charsCacheKey] = glyphs;
  42858. }
  42859. };
  42860. return Font;
  42861. }();
  42862. var ErrorFont = function ErrorFontClosure() {
  42863. function ErrorFont(error) {
  42864. this.error = error;
  42865. this.loadedName = 'g_font_error';
  42866. this.loading = false;
  42867. }
  42868. ErrorFont.prototype = {
  42869. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  42870. return [];
  42871. },
  42872. exportData: function ErrorFont_exportData() {
  42873. return { error: this.error };
  42874. }
  42875. };
  42876. return ErrorFont;
  42877. }();
  42878. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  42879. var charCodeToGlyphId = Object.create(null);
  42880. var glyphId, charCode, baseEncoding;
  42881. if (properties.baseEncodingName) {
  42882. baseEncoding = getEncoding(properties.baseEncodingName);
  42883. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42884. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42885. if (glyphId >= 0) {
  42886. charCodeToGlyphId[charCode] = glyphId;
  42887. } else {
  42888. charCodeToGlyphId[charCode] = 0;
  42889. }
  42890. }
  42891. } else if (!!(properties.flags & FontFlags.Symbolic)) {
  42892. for (charCode in builtInEncoding) {
  42893. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  42894. }
  42895. } else {
  42896. baseEncoding = StandardEncoding;
  42897. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42898. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42899. if (glyphId >= 0) {
  42900. charCodeToGlyphId[charCode] = glyphId;
  42901. } else {
  42902. charCodeToGlyphId[charCode] = 0;
  42903. }
  42904. }
  42905. }
  42906. var differences = properties.differences, glyphsUnicodeMap;
  42907. if (differences) {
  42908. for (charCode in differences) {
  42909. var glyphName = differences[charCode];
  42910. glyphId = glyphNames.indexOf(glyphName);
  42911. if (glyphId === -1) {
  42912. if (!glyphsUnicodeMap) {
  42913. glyphsUnicodeMap = getGlyphsUnicode();
  42914. }
  42915. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42916. if (standardGlyphName !== glyphName) {
  42917. glyphId = glyphNames.indexOf(standardGlyphName);
  42918. }
  42919. }
  42920. if (glyphId >= 0) {
  42921. charCodeToGlyphId[charCode] = glyphId;
  42922. } else {
  42923. charCodeToGlyphId[charCode] = 0;
  42924. }
  42925. }
  42926. }
  42927. return charCodeToGlyphId;
  42928. }
  42929. var Type1Font = function Type1FontClosure() {
  42930. function findBlock(streamBytes, signature, startIndex) {
  42931. var streamBytesLength = streamBytes.length;
  42932. var signatureLength = signature.length;
  42933. var scanLength = streamBytesLength - signatureLength;
  42934. var i = startIndex, j, found = false;
  42935. while (i < scanLength) {
  42936. j = 0;
  42937. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  42938. j++;
  42939. }
  42940. if (j >= signatureLength) {
  42941. i += j;
  42942. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  42943. i++;
  42944. }
  42945. found = true;
  42946. break;
  42947. }
  42948. i++;
  42949. }
  42950. return {
  42951. found: found,
  42952. length: i
  42953. };
  42954. }
  42955. function getHeaderBlock(stream, suggestedLength) {
  42956. var EEXEC_SIGNATURE = [
  42957. 0x65,
  42958. 0x65,
  42959. 0x78,
  42960. 0x65,
  42961. 0x63
  42962. ];
  42963. var streamStartPos = stream.pos;
  42964. var headerBytes, headerBytesLength, block;
  42965. try {
  42966. headerBytes = stream.getBytes(suggestedLength);
  42967. headerBytesLength = headerBytes.length;
  42968. } catch (ex) {
  42969. if (ex instanceof MissingDataException) {
  42970. throw ex;
  42971. }
  42972. }
  42973. if (headerBytesLength === suggestedLength) {
  42974. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  42975. if (block.found && block.length === suggestedLength) {
  42976. return {
  42977. stream: new Stream(headerBytes),
  42978. length: suggestedLength
  42979. };
  42980. }
  42981. }
  42982. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  42983. stream.pos = streamStartPos;
  42984. var SCAN_BLOCK_LENGTH = 2048;
  42985. var actualLength;
  42986. while (true) {
  42987. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  42988. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  42989. if (block.length === 0) {
  42990. break;
  42991. }
  42992. stream.pos += block.length;
  42993. if (block.found) {
  42994. actualLength = stream.pos - streamStartPos;
  42995. break;
  42996. }
  42997. }
  42998. stream.pos = streamStartPos;
  42999. if (actualLength) {
  43000. return {
  43001. stream: new Stream(stream.getBytes(actualLength)),
  43002. length: actualLength
  43003. };
  43004. }
  43005. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43006. return {
  43007. stream: new Stream(stream.getBytes(suggestedLength)),
  43008. length: suggestedLength
  43009. };
  43010. }
  43011. function getEexecBlock(stream, suggestedLength) {
  43012. var eexecBytes = stream.getBytes();
  43013. return {
  43014. stream: new Stream(eexecBytes),
  43015. length: eexecBytes.length
  43016. };
  43017. }
  43018. function Type1Font(name, file, properties) {
  43019. var PFB_HEADER_SIZE = 6;
  43020. var headerBlockLength = properties.length1;
  43021. var eexecBlockLength = properties.length2;
  43022. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43023. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43024. if (pfbHeaderPresent) {
  43025. file.skip(PFB_HEADER_SIZE);
  43026. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43027. }
  43028. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43029. headerBlockLength = headerBlock.length;
  43030. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43031. headerBlockParser.extractFontHeader(properties);
  43032. if (pfbHeaderPresent) {
  43033. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43034. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43035. }
  43036. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43037. eexecBlockLength = eexecBlock.length;
  43038. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43039. var data = eexecBlockParser.extractFontProgram();
  43040. for (var info in data.properties) {
  43041. properties[info] = data.properties[info];
  43042. }
  43043. var charstrings = data.charstrings;
  43044. var type2Charstrings = this.getType2Charstrings(charstrings);
  43045. var subrs = this.getType2Subrs(data.subrs);
  43046. this.charstrings = charstrings;
  43047. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43048. this.seacs = this.getSeacs(data.charstrings);
  43049. }
  43050. Type1Font.prototype = {
  43051. get numGlyphs() {
  43052. return this.charstrings.length + 1;
  43053. },
  43054. getCharset: function Type1Font_getCharset() {
  43055. var charset = ['.notdef'];
  43056. var charstrings = this.charstrings;
  43057. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43058. charset.push(charstrings[glyphId].glyphName);
  43059. }
  43060. return charset;
  43061. },
  43062. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43063. var charstrings = this.charstrings;
  43064. var glyphNames = ['.notdef'], glyphId;
  43065. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43066. glyphNames.push(charstrings[glyphId].glyphName);
  43067. }
  43068. var encoding = properties.builtInEncoding;
  43069. if (encoding) {
  43070. var builtInEncoding = Object.create(null);
  43071. for (var charCode in encoding) {
  43072. glyphId = glyphNames.indexOf(encoding[charCode]);
  43073. if (glyphId >= 0) {
  43074. builtInEncoding[charCode] = glyphId;
  43075. }
  43076. }
  43077. }
  43078. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43079. },
  43080. getSeacs: function Type1Font_getSeacs(charstrings) {
  43081. var i, ii;
  43082. var seacMap = [];
  43083. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43084. var charstring = charstrings[i];
  43085. if (charstring.seac) {
  43086. seacMap[i + 1] = charstring.seac;
  43087. }
  43088. }
  43089. return seacMap;
  43090. },
  43091. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43092. var type2Charstrings = [];
  43093. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43094. type2Charstrings.push(type1Charstrings[i].charstring);
  43095. }
  43096. return type2Charstrings;
  43097. },
  43098. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43099. var bias = 0;
  43100. var count = type1Subrs.length;
  43101. if (count < 1133) {
  43102. bias = 107;
  43103. } else if (count < 33769) {
  43104. bias = 1131;
  43105. } else {
  43106. bias = 32768;
  43107. }
  43108. var type2Subrs = [];
  43109. var i;
  43110. for (i = 0; i < bias; i++) {
  43111. type2Subrs.push([0x0B]);
  43112. }
  43113. for (i = 0; i < count; i++) {
  43114. type2Subrs.push(type1Subrs[i]);
  43115. }
  43116. return type2Subrs;
  43117. },
  43118. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43119. var cff = new CFF();
  43120. cff.header = new CFFHeader(1, 0, 4, 4);
  43121. cff.names = [name];
  43122. var topDict = new CFFTopDict();
  43123. topDict.setByName('version', 391);
  43124. topDict.setByName('Notice', 392);
  43125. topDict.setByName('FullName', 393);
  43126. topDict.setByName('FamilyName', 394);
  43127. topDict.setByName('Weight', 395);
  43128. topDict.setByName('Encoding', null);
  43129. topDict.setByName('FontMatrix', properties.fontMatrix);
  43130. topDict.setByName('FontBBox', properties.bbox);
  43131. topDict.setByName('charset', null);
  43132. topDict.setByName('CharStrings', null);
  43133. topDict.setByName('Private', null);
  43134. cff.topDict = topDict;
  43135. var strings = new CFFStrings();
  43136. strings.add('Version 0.11');
  43137. strings.add('See original notice');
  43138. strings.add(name);
  43139. strings.add(name);
  43140. strings.add('Medium');
  43141. cff.strings = strings;
  43142. cff.globalSubrIndex = new CFFIndex();
  43143. var count = glyphs.length;
  43144. var charsetArray = [0];
  43145. var i, ii;
  43146. for (i = 0; i < count; i++) {
  43147. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43148. if (index === -1) {
  43149. index = 0;
  43150. }
  43151. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43152. }
  43153. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43154. var charStringsIndex = new CFFIndex();
  43155. charStringsIndex.add([
  43156. 0x8B,
  43157. 0x0E
  43158. ]);
  43159. for (i = 0; i < count; i++) {
  43160. var glyph = glyphs[i];
  43161. if (glyph.length === 0) {
  43162. charStringsIndex.add([
  43163. 0x8B,
  43164. 0x0E
  43165. ]);
  43166. continue;
  43167. }
  43168. charStringsIndex.add(glyph);
  43169. }
  43170. cff.charStrings = charStringsIndex;
  43171. var privateDict = new CFFPrivateDict();
  43172. privateDict.setByName('Subrs', null);
  43173. var fields = [
  43174. 'BlueValues',
  43175. 'OtherBlues',
  43176. 'FamilyBlues',
  43177. 'FamilyOtherBlues',
  43178. 'StemSnapH',
  43179. 'StemSnapV',
  43180. 'BlueShift',
  43181. 'BlueFuzz',
  43182. 'BlueScale',
  43183. 'LanguageGroup',
  43184. 'ExpansionFactor',
  43185. 'ForceBold',
  43186. 'StdHW',
  43187. 'StdVW'
  43188. ];
  43189. for (i = 0, ii = fields.length; i < ii; i++) {
  43190. var field = fields[i];
  43191. if (!(field in properties.privateData)) {
  43192. continue;
  43193. }
  43194. var value = properties.privateData[field];
  43195. if (isArray(value)) {
  43196. for (var j = value.length - 1; j > 0; j--) {
  43197. value[j] -= value[j - 1];
  43198. }
  43199. }
  43200. privateDict.setByName(field, value);
  43201. }
  43202. cff.topDict.privateDict = privateDict;
  43203. var subrIndex = new CFFIndex();
  43204. for (i = 0, ii = subrs.length; i < ii; i++) {
  43205. subrIndex.add(subrs[i]);
  43206. }
  43207. privateDict.subrsIndex = subrIndex;
  43208. var compiler = new CFFCompiler(cff);
  43209. return compiler.compile();
  43210. }
  43211. };
  43212. return Type1Font;
  43213. }();
  43214. var CFFFont = function CFFFontClosure() {
  43215. function CFFFont(file, properties) {
  43216. this.properties = properties;
  43217. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43218. this.cff = parser.parse();
  43219. var compiler = new CFFCompiler(this.cff);
  43220. this.seacs = this.cff.seacs;
  43221. try {
  43222. this.data = compiler.compile();
  43223. } catch (e) {
  43224. warn('Failed to compile font ' + properties.loadedName);
  43225. this.data = file;
  43226. }
  43227. }
  43228. CFFFont.prototype = {
  43229. get numGlyphs() {
  43230. return this.cff.charStrings.count;
  43231. },
  43232. getCharset: function CFFFont_getCharset() {
  43233. return this.cff.charset.charset;
  43234. },
  43235. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43236. var cff = this.cff;
  43237. var properties = this.properties;
  43238. var charsets = cff.charset.charset;
  43239. var charCodeToGlyphId;
  43240. var glyphId;
  43241. if (properties.composite) {
  43242. charCodeToGlyphId = Object.create(null);
  43243. if (cff.isCIDFont) {
  43244. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43245. var cid = charsets[glyphId];
  43246. var charCode = properties.cMap.charCodeOf(cid);
  43247. charCodeToGlyphId[charCode] = glyphId;
  43248. }
  43249. } else {
  43250. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43251. charCodeToGlyphId[glyphId] = glyphId;
  43252. }
  43253. }
  43254. return charCodeToGlyphId;
  43255. }
  43256. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43257. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43258. return charCodeToGlyphId;
  43259. }
  43260. };
  43261. return CFFFont;
  43262. }();
  43263. (function checkSeacSupport() {
  43264. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43265. SEAC_ANALYSIS_ENABLED = true;
  43266. }
  43267. }());
  43268. (function checkChromeWindows() {
  43269. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43270. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43271. }
  43272. }());
  43273. exports.ErrorFont = ErrorFont;
  43274. exports.Font = Font;
  43275. exports.FontFlags = FontFlags;
  43276. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43277. exports.ToUnicodeMap = ToUnicodeMap;
  43278. exports.getFontType = getFontType;
  43279. }));
  43280. (function (root, factory) {
  43281. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43282. }(this, function (exports, sharedUtil, coreParser) {
  43283. var error = sharedUtil.error;
  43284. var isSpace = sharedUtil.isSpace;
  43285. var EOF = coreParser.EOF;
  43286. var PostScriptParser = function PostScriptParserClosure() {
  43287. function PostScriptParser(lexer) {
  43288. this.lexer = lexer;
  43289. this.operators = [];
  43290. this.token = null;
  43291. this.prev = null;
  43292. }
  43293. PostScriptParser.prototype = {
  43294. nextToken: function PostScriptParser_nextToken() {
  43295. this.prev = this.token;
  43296. this.token = this.lexer.getToken();
  43297. },
  43298. accept: function PostScriptParser_accept(type) {
  43299. if (this.token.type === type) {
  43300. this.nextToken();
  43301. return true;
  43302. }
  43303. return false;
  43304. },
  43305. expect: function PostScriptParser_expect(type) {
  43306. if (this.accept(type)) {
  43307. return true;
  43308. }
  43309. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43310. },
  43311. parse: function PostScriptParser_parse() {
  43312. this.nextToken();
  43313. this.expect(PostScriptTokenTypes.LBRACE);
  43314. this.parseBlock();
  43315. this.expect(PostScriptTokenTypes.RBRACE);
  43316. return this.operators;
  43317. },
  43318. parseBlock: function PostScriptParser_parseBlock() {
  43319. while (true) {
  43320. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43321. this.operators.push(this.prev.value);
  43322. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43323. this.operators.push(this.prev.value);
  43324. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43325. this.parseCondition();
  43326. } else {
  43327. return;
  43328. }
  43329. }
  43330. },
  43331. parseCondition: function PostScriptParser_parseCondition() {
  43332. var conditionLocation = this.operators.length;
  43333. this.operators.push(null, null);
  43334. this.parseBlock();
  43335. this.expect(PostScriptTokenTypes.RBRACE);
  43336. if (this.accept(PostScriptTokenTypes.IF)) {
  43337. this.operators[conditionLocation] = this.operators.length;
  43338. this.operators[conditionLocation + 1] = 'jz';
  43339. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43340. var jumpLocation = this.operators.length;
  43341. this.operators.push(null, null);
  43342. var endOfTrue = this.operators.length;
  43343. this.parseBlock();
  43344. this.expect(PostScriptTokenTypes.RBRACE);
  43345. this.expect(PostScriptTokenTypes.IFELSE);
  43346. this.operators[jumpLocation] = this.operators.length;
  43347. this.operators[jumpLocation + 1] = 'j';
  43348. this.operators[conditionLocation] = endOfTrue;
  43349. this.operators[conditionLocation + 1] = 'jz';
  43350. } else {
  43351. error('PS Function: error parsing conditional.');
  43352. }
  43353. }
  43354. };
  43355. return PostScriptParser;
  43356. }();
  43357. var PostScriptTokenTypes = {
  43358. LBRACE: 0,
  43359. RBRACE: 1,
  43360. NUMBER: 2,
  43361. OPERATOR: 3,
  43362. IF: 4,
  43363. IFELSE: 5
  43364. };
  43365. var PostScriptToken = function PostScriptTokenClosure() {
  43366. function PostScriptToken(type, value) {
  43367. this.type = type;
  43368. this.value = value;
  43369. }
  43370. var opCache = Object.create(null);
  43371. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43372. var opValue = opCache[op];
  43373. if (opValue) {
  43374. return opValue;
  43375. }
  43376. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43377. };
  43378. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43379. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43380. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43381. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43382. return PostScriptToken;
  43383. }();
  43384. var PostScriptLexer = function PostScriptLexerClosure() {
  43385. function PostScriptLexer(stream) {
  43386. this.stream = stream;
  43387. this.nextChar();
  43388. this.strBuf = [];
  43389. }
  43390. PostScriptLexer.prototype = {
  43391. nextChar: function PostScriptLexer_nextChar() {
  43392. return this.currentChar = this.stream.getByte();
  43393. },
  43394. getToken: function PostScriptLexer_getToken() {
  43395. var comment = false;
  43396. var ch = this.currentChar;
  43397. while (true) {
  43398. if (ch < 0) {
  43399. return EOF;
  43400. }
  43401. if (comment) {
  43402. if (ch === 0x0A || ch === 0x0D) {
  43403. comment = false;
  43404. }
  43405. } else if (ch === 0x25) {
  43406. comment = true;
  43407. } else if (!isSpace(ch)) {
  43408. break;
  43409. }
  43410. ch = this.nextChar();
  43411. }
  43412. switch (ch | 0) {
  43413. case 0x30:
  43414. case 0x31:
  43415. case 0x32:
  43416. case 0x33:
  43417. case 0x34:
  43418. case 0x35:
  43419. case 0x36:
  43420. case 0x37:
  43421. case 0x38:
  43422. case 0x39:
  43423. case 0x2B:
  43424. case 0x2D:
  43425. case 0x2E:
  43426. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43427. case 0x7B:
  43428. this.nextChar();
  43429. return PostScriptToken.LBRACE;
  43430. case 0x7D:
  43431. this.nextChar();
  43432. return PostScriptToken.RBRACE;
  43433. }
  43434. var strBuf = this.strBuf;
  43435. strBuf.length = 0;
  43436. strBuf[0] = String.fromCharCode(ch);
  43437. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43438. strBuf.push(String.fromCharCode(ch));
  43439. }
  43440. var str = strBuf.join('');
  43441. switch (str.toLowerCase()) {
  43442. case 'if':
  43443. return PostScriptToken.IF;
  43444. case 'ifelse':
  43445. return PostScriptToken.IFELSE;
  43446. default:
  43447. return PostScriptToken.getOperator(str);
  43448. }
  43449. },
  43450. getNumber: function PostScriptLexer_getNumber() {
  43451. var ch = this.currentChar;
  43452. var strBuf = this.strBuf;
  43453. strBuf.length = 0;
  43454. strBuf[0] = String.fromCharCode(ch);
  43455. while ((ch = this.nextChar()) >= 0) {
  43456. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43457. strBuf.push(String.fromCharCode(ch));
  43458. } else {
  43459. break;
  43460. }
  43461. }
  43462. var value = parseFloat(strBuf.join(''));
  43463. if (isNaN(value)) {
  43464. error('Invalid floating point number: ' + value);
  43465. }
  43466. return value;
  43467. }
  43468. };
  43469. return PostScriptLexer;
  43470. }();
  43471. exports.PostScriptLexer = PostScriptLexer;
  43472. exports.PostScriptParser = PostScriptParser;
  43473. }));
  43474. (function (root, factory) {
  43475. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43476. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43477. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43478. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43479. var ImageKind = sharedUtil.ImageKind;
  43480. var OPS = sharedUtil.OPS;
  43481. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43482. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43483. var Util = sharedUtil.Util;
  43484. var assert = sharedUtil.assert;
  43485. var info = sharedUtil.info;
  43486. var isNum = sharedUtil.isNum;
  43487. var isArray = sharedUtil.isArray;
  43488. var isLittleEndian = sharedUtil.isLittleEndian;
  43489. var error = sharedUtil.error;
  43490. var shadow = sharedUtil.shadow;
  43491. var warn = sharedUtil.warn;
  43492. var TilingPattern = displayPatternHelper.TilingPattern;
  43493. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43494. var WebGLUtils = displayWebGL.WebGLUtils;
  43495. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43496. var MIN_FONT_SIZE = 16;
  43497. var MAX_FONT_SIZE = 100;
  43498. var MAX_GROUP_SIZE = 4096;
  43499. var MIN_WIDTH_FACTOR = 0.65;
  43500. var COMPILE_TYPE3_GLYPHS = true;
  43501. var MAX_SIZE_TO_COMPILE = 1000;
  43502. var FULL_CHUNK_HEIGHT = 16;
  43503. var HasCanvasTypedArraysCached = {
  43504. get value() {
  43505. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43506. }
  43507. };
  43508. var IsLittleEndianCached = {
  43509. get value() {
  43510. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43511. }
  43512. };
  43513. function createScratchCanvas(width, height) {
  43514. var canvas = document.createElement('canvas');
  43515. canvas.width = width;
  43516. canvas.height = height;
  43517. return canvas;
  43518. }
  43519. function addContextCurrentTransform(ctx) {
  43520. if (!ctx.mozCurrentTransform) {
  43521. ctx._originalSave = ctx.save;
  43522. ctx._originalRestore = ctx.restore;
  43523. ctx._originalRotate = ctx.rotate;
  43524. ctx._originalScale = ctx.scale;
  43525. ctx._originalTranslate = ctx.translate;
  43526. ctx._originalTransform = ctx.transform;
  43527. ctx._originalSetTransform = ctx.setTransform;
  43528. ctx._transformMatrix = ctx._transformMatrix || [
  43529. 1,
  43530. 0,
  43531. 0,
  43532. 1,
  43533. 0,
  43534. 0
  43535. ];
  43536. ctx._transformStack = [];
  43537. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43538. get: function getCurrentTransform() {
  43539. return this._transformMatrix;
  43540. }
  43541. });
  43542. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43543. get: function getCurrentTransformInverse() {
  43544. var m = this._transformMatrix;
  43545. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43546. var ad_bc = a * d - b * c;
  43547. var bc_ad = b * c - a * d;
  43548. return [
  43549. d / ad_bc,
  43550. b / bc_ad,
  43551. c / bc_ad,
  43552. a / ad_bc,
  43553. (d * e - c * f) / bc_ad,
  43554. (b * e - a * f) / ad_bc
  43555. ];
  43556. }
  43557. });
  43558. ctx.save = function ctxSave() {
  43559. var old = this._transformMatrix;
  43560. this._transformStack.push(old);
  43561. this._transformMatrix = old.slice(0, 6);
  43562. this._originalSave();
  43563. };
  43564. ctx.restore = function ctxRestore() {
  43565. var prev = this._transformStack.pop();
  43566. if (prev) {
  43567. this._transformMatrix = prev;
  43568. this._originalRestore();
  43569. }
  43570. };
  43571. ctx.translate = function ctxTranslate(x, y) {
  43572. var m = this._transformMatrix;
  43573. m[4] = m[0] * x + m[2] * y + m[4];
  43574. m[5] = m[1] * x + m[3] * y + m[5];
  43575. this._originalTranslate(x, y);
  43576. };
  43577. ctx.scale = function ctxScale(x, y) {
  43578. var m = this._transformMatrix;
  43579. m[0] = m[0] * x;
  43580. m[1] = m[1] * x;
  43581. m[2] = m[2] * y;
  43582. m[3] = m[3] * y;
  43583. this._originalScale(x, y);
  43584. };
  43585. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43586. var m = this._transformMatrix;
  43587. this._transformMatrix = [
  43588. m[0] * a + m[2] * b,
  43589. m[1] * a + m[3] * b,
  43590. m[0] * c + m[2] * d,
  43591. m[1] * c + m[3] * d,
  43592. m[0] * e + m[2] * f + m[4],
  43593. m[1] * e + m[3] * f + m[5]
  43594. ];
  43595. ctx._originalTransform(a, b, c, d, e, f);
  43596. };
  43597. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43598. this._transformMatrix = [
  43599. a,
  43600. b,
  43601. c,
  43602. d,
  43603. e,
  43604. f
  43605. ];
  43606. ctx._originalSetTransform(a, b, c, d, e, f);
  43607. };
  43608. ctx.rotate = function ctxRotate(angle) {
  43609. var cosValue = Math.cos(angle);
  43610. var sinValue = Math.sin(angle);
  43611. var m = this._transformMatrix;
  43612. this._transformMatrix = [
  43613. m[0] * cosValue + m[2] * sinValue,
  43614. m[1] * cosValue + m[3] * sinValue,
  43615. m[0] * -sinValue + m[2] * cosValue,
  43616. m[1] * -sinValue + m[3] * cosValue,
  43617. m[4],
  43618. m[5]
  43619. ];
  43620. this._originalRotate(angle);
  43621. };
  43622. }
  43623. }
  43624. var CachedCanvases = function CachedCanvasesClosure() {
  43625. function CachedCanvases() {
  43626. this.cache = Object.create(null);
  43627. }
  43628. CachedCanvases.prototype = {
  43629. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43630. var canvasEntry;
  43631. if (this.cache[id] !== undefined) {
  43632. canvasEntry = this.cache[id];
  43633. canvasEntry.canvas.width = width;
  43634. canvasEntry.canvas.height = height;
  43635. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43636. } else {
  43637. var canvas = createScratchCanvas(width, height);
  43638. var ctx = canvas.getContext('2d');
  43639. if (trackTransform) {
  43640. addContextCurrentTransform(ctx);
  43641. }
  43642. this.cache[id] = canvasEntry = {
  43643. canvas: canvas,
  43644. context: ctx
  43645. };
  43646. }
  43647. return canvasEntry;
  43648. },
  43649. clear: function () {
  43650. for (var id in this.cache) {
  43651. var canvasEntry = this.cache[id];
  43652. canvasEntry.canvas.width = 0;
  43653. canvasEntry.canvas.height = 0;
  43654. delete this.cache[id];
  43655. }
  43656. }
  43657. };
  43658. return CachedCanvases;
  43659. }();
  43660. function compileType3Glyph(imgData) {
  43661. var POINT_TO_PROCESS_LIMIT = 1000;
  43662. var width = imgData.width, height = imgData.height;
  43663. var i, j, j0, width1 = width + 1;
  43664. var points = new Uint8Array(width1 * (height + 1));
  43665. var POINT_TYPES = new Uint8Array([
  43666. 0,
  43667. 2,
  43668. 4,
  43669. 0,
  43670. 1,
  43671. 0,
  43672. 5,
  43673. 4,
  43674. 8,
  43675. 10,
  43676. 0,
  43677. 8,
  43678. 0,
  43679. 2,
  43680. 1,
  43681. 0
  43682. ]);
  43683. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43684. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43685. for (i = 0, ii = data0.length; i < ii; i++) {
  43686. var mask = 128, elem = data0[i];
  43687. while (mask > 0) {
  43688. data[pos++] = elem & mask ? 0 : 255;
  43689. mask >>= 1;
  43690. }
  43691. }
  43692. var count = 0;
  43693. pos = 0;
  43694. if (data[pos] !== 0) {
  43695. points[0] = 1;
  43696. ++count;
  43697. }
  43698. for (j = 1; j < width; j++) {
  43699. if (data[pos] !== data[pos + 1]) {
  43700. points[j] = data[pos] ? 2 : 1;
  43701. ++count;
  43702. }
  43703. pos++;
  43704. }
  43705. if (data[pos] !== 0) {
  43706. points[j] = 2;
  43707. ++count;
  43708. }
  43709. for (i = 1; i < height; i++) {
  43710. pos = i * lineSize;
  43711. j0 = i * width1;
  43712. if (data[pos - lineSize] !== data[pos]) {
  43713. points[j0] = data[pos] ? 1 : 8;
  43714. ++count;
  43715. }
  43716. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43717. for (j = 1; j < width; j++) {
  43718. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43719. if (POINT_TYPES[sum]) {
  43720. points[j0 + j] = POINT_TYPES[sum];
  43721. ++count;
  43722. }
  43723. pos++;
  43724. }
  43725. if (data[pos - lineSize] !== data[pos]) {
  43726. points[j0 + j] = data[pos] ? 2 : 4;
  43727. ++count;
  43728. }
  43729. if (count > POINT_TO_PROCESS_LIMIT) {
  43730. return null;
  43731. }
  43732. }
  43733. pos = lineSize * (height - 1);
  43734. j0 = i * width1;
  43735. if (data[pos] !== 0) {
  43736. points[j0] = 8;
  43737. ++count;
  43738. }
  43739. for (j = 1; j < width; j++) {
  43740. if (data[pos] !== data[pos + 1]) {
  43741. points[j0 + j] = data[pos] ? 4 : 8;
  43742. ++count;
  43743. }
  43744. pos++;
  43745. }
  43746. if (data[pos] !== 0) {
  43747. points[j0 + j] = 4;
  43748. ++count;
  43749. }
  43750. if (count > POINT_TO_PROCESS_LIMIT) {
  43751. return null;
  43752. }
  43753. var steps = new Int32Array([
  43754. 0,
  43755. width1,
  43756. -1,
  43757. 0,
  43758. -width1,
  43759. 0,
  43760. 0,
  43761. 0,
  43762. 1
  43763. ]);
  43764. var outlines = [];
  43765. for (i = 0; count && i <= height; i++) {
  43766. var p = i * width1;
  43767. var end = p + width;
  43768. while (p < end && !points[p]) {
  43769. p++;
  43770. }
  43771. if (p === end) {
  43772. continue;
  43773. }
  43774. var coords = [
  43775. p % width1,
  43776. i
  43777. ];
  43778. var type = points[p], p0 = p, pp;
  43779. do {
  43780. var step = steps[type];
  43781. do {
  43782. p += step;
  43783. } while (!points[p]);
  43784. pp = points[p];
  43785. if (pp !== 5 && pp !== 10) {
  43786. type = pp;
  43787. points[p] = 0;
  43788. } else {
  43789. type = pp & 0x33 * type >> 4;
  43790. points[p] &= type >> 2 | type << 2;
  43791. }
  43792. coords.push(p % width1);
  43793. coords.push(p / width1 | 0);
  43794. --count;
  43795. } while (p0 !== p);
  43796. outlines.push(coords);
  43797. --i;
  43798. }
  43799. var drawOutline = function (c) {
  43800. c.save();
  43801. c.scale(1 / width, -1 / height);
  43802. c.translate(0, -height);
  43803. c.beginPath();
  43804. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43805. var o = outlines[i];
  43806. c.moveTo(o[0], o[1]);
  43807. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43808. c.lineTo(o[j], o[j + 1]);
  43809. }
  43810. }
  43811. c.fill();
  43812. c.beginPath();
  43813. c.restore();
  43814. };
  43815. return drawOutline;
  43816. }
  43817. var CanvasExtraState = function CanvasExtraStateClosure() {
  43818. function CanvasExtraState(old) {
  43819. this.alphaIsShape = false;
  43820. this.fontSize = 0;
  43821. this.fontSizeScale = 1;
  43822. this.textMatrix = IDENTITY_MATRIX;
  43823. this.textMatrixScale = 1;
  43824. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43825. this.leading = 0;
  43826. this.x = 0;
  43827. this.y = 0;
  43828. this.lineX = 0;
  43829. this.lineY = 0;
  43830. this.charSpacing = 0;
  43831. this.wordSpacing = 0;
  43832. this.textHScale = 1;
  43833. this.textRenderingMode = TextRenderingMode.FILL;
  43834. this.textRise = 0;
  43835. this.fillColor = '#000000';
  43836. this.strokeColor = '#000000';
  43837. this.patternFill = false;
  43838. this.fillAlpha = 1;
  43839. this.strokeAlpha = 1;
  43840. this.lineWidth = 1;
  43841. this.activeSMask = null;
  43842. this.resumeSMaskCtx = null;
  43843. this.old = old;
  43844. }
  43845. CanvasExtraState.prototype = {
  43846. clone: function CanvasExtraState_clone() {
  43847. return Object.create(this);
  43848. },
  43849. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  43850. this.x = x;
  43851. this.y = y;
  43852. }
  43853. };
  43854. return CanvasExtraState;
  43855. }();
  43856. var CanvasGraphics = function CanvasGraphicsClosure() {
  43857. var EXECUTION_TIME = 15;
  43858. var EXECUTION_STEPS = 10;
  43859. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  43860. this.ctx = canvasCtx;
  43861. this.current = new CanvasExtraState();
  43862. this.stateStack = [];
  43863. this.pendingClip = null;
  43864. this.pendingEOFill = false;
  43865. this.res = null;
  43866. this.xobjs = null;
  43867. this.commonObjs = commonObjs;
  43868. this.objs = objs;
  43869. this.imageLayer = imageLayer;
  43870. this.groupStack = [];
  43871. this.processingType3 = null;
  43872. this.baseTransform = null;
  43873. this.baseTransformStack = [];
  43874. this.groupLevel = 0;
  43875. this.smaskStack = [];
  43876. this.smaskCounter = 0;
  43877. this.tempSMask = null;
  43878. this.cachedCanvases = new CachedCanvases();
  43879. if (canvasCtx) {
  43880. addContextCurrentTransform(canvasCtx);
  43881. }
  43882. this.cachedGetSinglePixelWidth = null;
  43883. }
  43884. function putBinaryImageData(ctx, imgData) {
  43885. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  43886. ctx.putImageData(imgData, 0, 0);
  43887. return;
  43888. }
  43889. var height = imgData.height, width = imgData.width;
  43890. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43891. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43892. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43893. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43894. var srcPos = 0, destPos;
  43895. var src = imgData.data;
  43896. var dest = chunkImgData.data;
  43897. var i, j, thisChunkHeight, elemsInThisChunk;
  43898. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  43899. var srcLength = src.byteLength;
  43900. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  43901. var dest32DataLength = dest32.length;
  43902. var fullSrcDiff = width + 7 >> 3;
  43903. var white = 0xFFFFFFFF;
  43904. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  43905. for (i = 0; i < totalChunks; i++) {
  43906. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43907. destPos = 0;
  43908. for (j = 0; j < thisChunkHeight; j++) {
  43909. var srcDiff = srcLength - srcPos;
  43910. var k = 0;
  43911. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  43912. var kEndUnrolled = kEnd & ~7;
  43913. var mask = 0;
  43914. var srcByte = 0;
  43915. for (; k < kEndUnrolled; k += 8) {
  43916. srcByte = src[srcPos++];
  43917. dest32[destPos++] = srcByte & 128 ? white : black;
  43918. dest32[destPos++] = srcByte & 64 ? white : black;
  43919. dest32[destPos++] = srcByte & 32 ? white : black;
  43920. dest32[destPos++] = srcByte & 16 ? white : black;
  43921. dest32[destPos++] = srcByte & 8 ? white : black;
  43922. dest32[destPos++] = srcByte & 4 ? white : black;
  43923. dest32[destPos++] = srcByte & 2 ? white : black;
  43924. dest32[destPos++] = srcByte & 1 ? white : black;
  43925. }
  43926. for (; k < kEnd; k++) {
  43927. if (mask === 0) {
  43928. srcByte = src[srcPos++];
  43929. mask = 128;
  43930. }
  43931. dest32[destPos++] = srcByte & mask ? white : black;
  43932. mask >>= 1;
  43933. }
  43934. }
  43935. while (destPos < dest32DataLength) {
  43936. dest32[destPos++] = 0;
  43937. }
  43938. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43939. }
  43940. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  43941. j = 0;
  43942. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  43943. for (i = 0; i < fullChunks; i++) {
  43944. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43945. srcPos += elemsInThisChunk;
  43946. ctx.putImageData(chunkImgData, 0, j);
  43947. j += FULL_CHUNK_HEIGHT;
  43948. }
  43949. if (i < totalChunks) {
  43950. elemsInThisChunk = width * partialChunkHeight * 4;
  43951. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43952. ctx.putImageData(chunkImgData, 0, j);
  43953. }
  43954. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  43955. thisChunkHeight = FULL_CHUNK_HEIGHT;
  43956. elemsInThisChunk = width * thisChunkHeight;
  43957. for (i = 0; i < totalChunks; i++) {
  43958. if (i >= fullChunks) {
  43959. thisChunkHeight = partialChunkHeight;
  43960. elemsInThisChunk = width * thisChunkHeight;
  43961. }
  43962. destPos = 0;
  43963. for (j = elemsInThisChunk; j--;) {
  43964. dest[destPos++] = src[srcPos++];
  43965. dest[destPos++] = src[srcPos++];
  43966. dest[destPos++] = src[srcPos++];
  43967. dest[destPos++] = 255;
  43968. }
  43969. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43970. }
  43971. } else {
  43972. error('bad image kind: ' + imgData.kind);
  43973. }
  43974. }
  43975. function putBinaryImageMask(ctx, imgData) {
  43976. var height = imgData.height, width = imgData.width;
  43977. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43978. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43979. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43980. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43981. var srcPos = 0;
  43982. var src = imgData.data;
  43983. var dest = chunkImgData.data;
  43984. for (var i = 0; i < totalChunks; i++) {
  43985. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43986. var destPos = 3;
  43987. for (var j = 0; j < thisChunkHeight; j++) {
  43988. var mask = 0;
  43989. for (var k = 0; k < width; k++) {
  43990. if (!mask) {
  43991. var elem = src[srcPos++];
  43992. mask = 128;
  43993. }
  43994. dest[destPos] = elem & mask ? 0 : 255;
  43995. destPos += 4;
  43996. mask >>= 1;
  43997. }
  43998. }
  43999. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44000. }
  44001. }
  44002. function copyCtxState(sourceCtx, destCtx) {
  44003. var properties = [
  44004. 'strokeStyle',
  44005. 'fillStyle',
  44006. 'fillRule',
  44007. 'globalAlpha',
  44008. 'lineWidth',
  44009. 'lineCap',
  44010. 'lineJoin',
  44011. 'miterLimit',
  44012. 'globalCompositeOperation',
  44013. 'font'
  44014. ];
  44015. for (var i = 0, ii = properties.length; i < ii; i++) {
  44016. var property = properties[i];
  44017. if (sourceCtx[property] !== undefined) {
  44018. destCtx[property] = sourceCtx[property];
  44019. }
  44020. }
  44021. if (sourceCtx.setLineDash !== undefined) {
  44022. destCtx.setLineDash(sourceCtx.getLineDash());
  44023. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44024. }
  44025. }
  44026. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44027. var length = bytes.length;
  44028. for (var i = 3; i < length; i += 4) {
  44029. var alpha = bytes[i];
  44030. if (alpha === 0) {
  44031. bytes[i - 3] = r0;
  44032. bytes[i - 2] = g0;
  44033. bytes[i - 1] = b0;
  44034. } else if (alpha < 255) {
  44035. var alpha_ = 255 - alpha;
  44036. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44037. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44038. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44039. }
  44040. }
  44041. }
  44042. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44043. var length = maskData.length;
  44044. var scale = 1 / 255;
  44045. for (var i = 3; i < length; i += 4) {
  44046. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44047. layerData[i] = layerData[i] * alpha * scale | 0;
  44048. }
  44049. }
  44050. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44051. var length = maskData.length;
  44052. for (var i = 3; i < length; i += 4) {
  44053. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44054. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44055. }
  44056. }
  44057. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44058. var hasBackdrop = !!backdrop;
  44059. var r0 = hasBackdrop ? backdrop[0] : 0;
  44060. var g0 = hasBackdrop ? backdrop[1] : 0;
  44061. var b0 = hasBackdrop ? backdrop[2] : 0;
  44062. var composeFn;
  44063. if (subtype === 'Luminosity') {
  44064. composeFn = composeSMaskLuminosity;
  44065. } else {
  44066. composeFn = composeSMaskAlpha;
  44067. }
  44068. var PIXELS_TO_PROCESS = 1048576;
  44069. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44070. for (var row = 0; row < height; row += chunkSize) {
  44071. var chunkHeight = Math.min(chunkSize, height - row);
  44072. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44073. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44074. if (hasBackdrop) {
  44075. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44076. }
  44077. composeFn(maskData.data, layerData.data, transferMap);
  44078. maskCtx.putImageData(layerData, 0, row);
  44079. }
  44080. }
  44081. function composeSMask(ctx, smask, layerCtx) {
  44082. var mask = smask.canvas;
  44083. var maskCtx = smask.context;
  44084. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44085. var backdrop = smask.backdrop || null;
  44086. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44087. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44088. subtype: smask.subtype,
  44089. backdrop: backdrop
  44090. });
  44091. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44092. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44093. return;
  44094. }
  44095. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44096. ctx.drawImage(mask, 0, 0);
  44097. }
  44098. var LINE_CAP_STYLES = [
  44099. 'butt',
  44100. 'round',
  44101. 'square'
  44102. ];
  44103. var LINE_JOIN_STYLES = [
  44104. 'miter',
  44105. 'round',
  44106. 'bevel'
  44107. ];
  44108. var NORMAL_CLIP = {};
  44109. var EO_CLIP = {};
  44110. CanvasGraphics.prototype = {
  44111. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44112. var width = this.ctx.canvas.width;
  44113. var height = this.ctx.canvas.height;
  44114. this.ctx.save();
  44115. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44116. this.ctx.fillRect(0, 0, width, height);
  44117. this.ctx.restore();
  44118. if (transparency) {
  44119. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44120. this.compositeCtx = this.ctx;
  44121. this.transparentCanvas = transparentCanvas.canvas;
  44122. this.ctx = transparentCanvas.context;
  44123. this.ctx.save();
  44124. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44125. }
  44126. this.ctx.save();
  44127. if (transform) {
  44128. this.ctx.transform.apply(this.ctx, transform);
  44129. }
  44130. this.ctx.transform.apply(this.ctx, viewport.transform);
  44131. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44132. if (this.imageLayer) {
  44133. this.imageLayer.beginLayout();
  44134. }
  44135. },
  44136. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44137. var argsArray = operatorList.argsArray;
  44138. var fnArray = operatorList.fnArray;
  44139. var i = executionStartIdx || 0;
  44140. var argsArrayLen = argsArray.length;
  44141. if (argsArrayLen === i) {
  44142. return i;
  44143. }
  44144. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44145. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44146. var steps = 0;
  44147. var commonObjs = this.commonObjs;
  44148. var objs = this.objs;
  44149. var fnId;
  44150. while (true) {
  44151. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44152. stepper.breakIt(i, continueCallback);
  44153. return i;
  44154. }
  44155. fnId = fnArray[i];
  44156. if (fnId !== OPS.dependency) {
  44157. this[fnId].apply(this, argsArray[i]);
  44158. } else {
  44159. var deps = argsArray[i];
  44160. for (var n = 0, nn = deps.length; n < nn; n++) {
  44161. var depObjId = deps[n];
  44162. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44163. var objsPool = common ? commonObjs : objs;
  44164. if (!objsPool.isResolved(depObjId)) {
  44165. objsPool.get(depObjId, continueCallback);
  44166. return i;
  44167. }
  44168. }
  44169. }
  44170. i++;
  44171. if (i === argsArrayLen) {
  44172. return i;
  44173. }
  44174. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44175. if (Date.now() > endTime) {
  44176. continueCallback();
  44177. return i;
  44178. }
  44179. steps = 0;
  44180. }
  44181. }
  44182. },
  44183. endDrawing: function CanvasGraphics_endDrawing() {
  44184. if (this.current.activeSMask !== null) {
  44185. this.endSMaskGroup();
  44186. }
  44187. this.ctx.restore();
  44188. if (this.transparentCanvas) {
  44189. this.ctx = this.compositeCtx;
  44190. this.ctx.save();
  44191. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44192. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44193. this.ctx.restore();
  44194. this.transparentCanvas = null;
  44195. }
  44196. this.cachedCanvases.clear();
  44197. WebGLUtils.clear();
  44198. if (this.imageLayer) {
  44199. this.imageLayer.endLayout();
  44200. }
  44201. },
  44202. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44203. this.current.lineWidth = width;
  44204. this.ctx.lineWidth = width;
  44205. },
  44206. setLineCap: function CanvasGraphics_setLineCap(style) {
  44207. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44208. },
  44209. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44210. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44211. },
  44212. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44213. this.ctx.miterLimit = limit;
  44214. },
  44215. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44216. var ctx = this.ctx;
  44217. if (ctx.setLineDash !== undefined) {
  44218. ctx.setLineDash(dashArray);
  44219. ctx.lineDashOffset = dashPhase;
  44220. }
  44221. },
  44222. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44223. },
  44224. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44225. },
  44226. setGState: function CanvasGraphics_setGState(states) {
  44227. for (var i = 0, ii = states.length; i < ii; i++) {
  44228. var state = states[i];
  44229. var key = state[0];
  44230. var value = state[1];
  44231. switch (key) {
  44232. case 'LW':
  44233. this.setLineWidth(value);
  44234. break;
  44235. case 'LC':
  44236. this.setLineCap(value);
  44237. break;
  44238. case 'LJ':
  44239. this.setLineJoin(value);
  44240. break;
  44241. case 'ML':
  44242. this.setMiterLimit(value);
  44243. break;
  44244. case 'D':
  44245. this.setDash(value[0], value[1]);
  44246. break;
  44247. case 'RI':
  44248. this.setRenderingIntent(value);
  44249. break;
  44250. case 'FL':
  44251. this.setFlatness(value);
  44252. break;
  44253. case 'Font':
  44254. this.setFont(value[0], value[1]);
  44255. break;
  44256. case 'CA':
  44257. this.current.strokeAlpha = state[1];
  44258. break;
  44259. case 'ca':
  44260. this.current.fillAlpha = state[1];
  44261. this.ctx.globalAlpha = state[1];
  44262. break;
  44263. case 'BM':
  44264. if (value && value.name && value.name !== 'Normal') {
  44265. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44266. return '-' + c.toLowerCase();
  44267. }).substring(1);
  44268. this.ctx.globalCompositeOperation = mode;
  44269. if (this.ctx.globalCompositeOperation !== mode) {
  44270. warn('globalCompositeOperation "' + mode + '" is not supported');
  44271. }
  44272. } else {
  44273. this.ctx.globalCompositeOperation = 'source-over';
  44274. }
  44275. break;
  44276. case 'SMask':
  44277. if (this.current.activeSMask) {
  44278. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44279. this.suspendSMaskGroup();
  44280. } else {
  44281. this.endSMaskGroup();
  44282. }
  44283. }
  44284. this.current.activeSMask = value ? this.tempSMask : null;
  44285. if (this.current.activeSMask) {
  44286. this.beginSMaskGroup();
  44287. }
  44288. this.tempSMask = null;
  44289. break;
  44290. }
  44291. }
  44292. },
  44293. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44294. var activeSMask = this.current.activeSMask;
  44295. var drawnWidth = activeSMask.canvas.width;
  44296. var drawnHeight = activeSMask.canvas.height;
  44297. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44298. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44299. var currentCtx = this.ctx;
  44300. var currentTransform = currentCtx.mozCurrentTransform;
  44301. this.ctx.save();
  44302. var groupCtx = scratchCanvas.context;
  44303. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44304. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44305. groupCtx.transform.apply(groupCtx, currentTransform);
  44306. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44307. copyCtxState(currentCtx, groupCtx);
  44308. this.ctx = groupCtx;
  44309. this.setGState([
  44310. [
  44311. 'BM',
  44312. 'Normal'
  44313. ],
  44314. [
  44315. 'ca',
  44316. 1
  44317. ],
  44318. [
  44319. 'CA',
  44320. 1
  44321. ]
  44322. ]);
  44323. this.groupStack.push(currentCtx);
  44324. this.groupLevel++;
  44325. },
  44326. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44327. var groupCtx = this.ctx;
  44328. this.groupLevel--;
  44329. this.ctx = this.groupStack.pop();
  44330. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44331. this.ctx.restore();
  44332. this.ctx.save();
  44333. copyCtxState(groupCtx, this.ctx);
  44334. this.current.resumeSMaskCtx = groupCtx;
  44335. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44336. this.ctx.transform.apply(this.ctx, deltaTransform);
  44337. groupCtx.save();
  44338. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44339. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44340. groupCtx.restore();
  44341. },
  44342. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44343. var groupCtx = this.current.resumeSMaskCtx;
  44344. var currentCtx = this.ctx;
  44345. this.ctx = groupCtx;
  44346. this.groupStack.push(currentCtx);
  44347. this.groupLevel++;
  44348. },
  44349. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44350. var groupCtx = this.ctx;
  44351. this.groupLevel--;
  44352. this.ctx = this.groupStack.pop();
  44353. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44354. this.ctx.restore();
  44355. copyCtxState(groupCtx, this.ctx);
  44356. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44357. this.ctx.transform.apply(this.ctx, deltaTransform);
  44358. },
  44359. save: function CanvasGraphics_save() {
  44360. this.ctx.save();
  44361. var old = this.current;
  44362. this.stateStack.push(old);
  44363. this.current = old.clone();
  44364. this.current.resumeSMaskCtx = null;
  44365. },
  44366. restore: function CanvasGraphics_restore() {
  44367. if (this.current.resumeSMaskCtx) {
  44368. this.resumeSMaskGroup();
  44369. }
  44370. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44371. this.endSMaskGroup();
  44372. }
  44373. if (this.stateStack.length !== 0) {
  44374. this.current = this.stateStack.pop();
  44375. this.ctx.restore();
  44376. this.pendingClip = null;
  44377. this.cachedGetSinglePixelWidth = null;
  44378. }
  44379. },
  44380. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44381. this.ctx.transform(a, b, c, d, e, f);
  44382. this.cachedGetSinglePixelWidth = null;
  44383. },
  44384. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44385. var ctx = this.ctx;
  44386. var current = this.current;
  44387. var x = current.x, y = current.y;
  44388. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44389. switch (ops[i] | 0) {
  44390. case OPS.rectangle:
  44391. x = args[j++];
  44392. y = args[j++];
  44393. var width = args[j++];
  44394. var height = args[j++];
  44395. if (width === 0) {
  44396. width = this.getSinglePixelWidth();
  44397. }
  44398. if (height === 0) {
  44399. height = this.getSinglePixelWidth();
  44400. }
  44401. var xw = x + width;
  44402. var yh = y + height;
  44403. this.ctx.moveTo(x, y);
  44404. this.ctx.lineTo(xw, y);
  44405. this.ctx.lineTo(xw, yh);
  44406. this.ctx.lineTo(x, yh);
  44407. this.ctx.lineTo(x, y);
  44408. this.ctx.closePath();
  44409. break;
  44410. case OPS.moveTo:
  44411. x = args[j++];
  44412. y = args[j++];
  44413. ctx.moveTo(x, y);
  44414. break;
  44415. case OPS.lineTo:
  44416. x = args[j++];
  44417. y = args[j++];
  44418. ctx.lineTo(x, y);
  44419. break;
  44420. case OPS.curveTo:
  44421. x = args[j + 4];
  44422. y = args[j + 5];
  44423. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44424. j += 6;
  44425. break;
  44426. case OPS.curveTo2:
  44427. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44428. x = args[j + 2];
  44429. y = args[j + 3];
  44430. j += 4;
  44431. break;
  44432. case OPS.curveTo3:
  44433. x = args[j + 2];
  44434. y = args[j + 3];
  44435. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44436. j += 4;
  44437. break;
  44438. case OPS.closePath:
  44439. ctx.closePath();
  44440. break;
  44441. }
  44442. }
  44443. current.setCurrentPoint(x, y);
  44444. },
  44445. closePath: function CanvasGraphics_closePath() {
  44446. this.ctx.closePath();
  44447. },
  44448. stroke: function CanvasGraphics_stroke(consumePath) {
  44449. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44450. var ctx = this.ctx;
  44451. var strokeColor = this.current.strokeColor;
  44452. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44453. ctx.globalAlpha = this.current.strokeAlpha;
  44454. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44455. ctx.save();
  44456. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44457. ctx.stroke();
  44458. ctx.restore();
  44459. } else {
  44460. ctx.stroke();
  44461. }
  44462. if (consumePath) {
  44463. this.consumePath();
  44464. }
  44465. ctx.globalAlpha = this.current.fillAlpha;
  44466. },
  44467. closeStroke: function CanvasGraphics_closeStroke() {
  44468. this.closePath();
  44469. this.stroke();
  44470. },
  44471. fill: function CanvasGraphics_fill(consumePath) {
  44472. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44473. var ctx = this.ctx;
  44474. var fillColor = this.current.fillColor;
  44475. var isPatternFill = this.current.patternFill;
  44476. var needRestore = false;
  44477. if (isPatternFill) {
  44478. ctx.save();
  44479. if (this.baseTransform) {
  44480. ctx.setTransform.apply(ctx, this.baseTransform);
  44481. }
  44482. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44483. needRestore = true;
  44484. }
  44485. if (this.pendingEOFill) {
  44486. if (ctx.mozFillRule !== undefined) {
  44487. ctx.mozFillRule = 'evenodd';
  44488. ctx.fill();
  44489. ctx.mozFillRule = 'nonzero';
  44490. } else {
  44491. ctx.fill('evenodd');
  44492. }
  44493. this.pendingEOFill = false;
  44494. } else {
  44495. ctx.fill();
  44496. }
  44497. if (needRestore) {
  44498. ctx.restore();
  44499. }
  44500. if (consumePath) {
  44501. this.consumePath();
  44502. }
  44503. },
  44504. eoFill: function CanvasGraphics_eoFill() {
  44505. this.pendingEOFill = true;
  44506. this.fill();
  44507. },
  44508. fillStroke: function CanvasGraphics_fillStroke() {
  44509. this.fill(false);
  44510. this.stroke(false);
  44511. this.consumePath();
  44512. },
  44513. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44514. this.pendingEOFill = true;
  44515. this.fillStroke();
  44516. },
  44517. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44518. this.closePath();
  44519. this.fillStroke();
  44520. },
  44521. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44522. this.pendingEOFill = true;
  44523. this.closePath();
  44524. this.fillStroke();
  44525. },
  44526. endPath: function CanvasGraphics_endPath() {
  44527. this.consumePath();
  44528. },
  44529. clip: function CanvasGraphics_clip() {
  44530. this.pendingClip = NORMAL_CLIP;
  44531. },
  44532. eoClip: function CanvasGraphics_eoClip() {
  44533. this.pendingClip = EO_CLIP;
  44534. },
  44535. beginText: function CanvasGraphics_beginText() {
  44536. this.current.textMatrix = IDENTITY_MATRIX;
  44537. this.current.textMatrixScale = 1;
  44538. this.current.x = this.current.lineX = 0;
  44539. this.current.y = this.current.lineY = 0;
  44540. },
  44541. endText: function CanvasGraphics_endText() {
  44542. var paths = this.pendingTextPaths;
  44543. var ctx = this.ctx;
  44544. if (paths === undefined) {
  44545. ctx.beginPath();
  44546. return;
  44547. }
  44548. ctx.save();
  44549. ctx.beginPath();
  44550. for (var i = 0; i < paths.length; i++) {
  44551. var path = paths[i];
  44552. ctx.setTransform.apply(ctx, path.transform);
  44553. ctx.translate(path.x, path.y);
  44554. path.addToPath(ctx, path.fontSize);
  44555. }
  44556. ctx.restore();
  44557. ctx.clip();
  44558. ctx.beginPath();
  44559. delete this.pendingTextPaths;
  44560. },
  44561. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44562. this.current.charSpacing = spacing;
  44563. },
  44564. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44565. this.current.wordSpacing = spacing;
  44566. },
  44567. setHScale: function CanvasGraphics_setHScale(scale) {
  44568. this.current.textHScale = scale / 100;
  44569. },
  44570. setLeading: function CanvasGraphics_setLeading(leading) {
  44571. this.current.leading = -leading;
  44572. },
  44573. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44574. var fontObj = this.commonObjs.get(fontRefName);
  44575. var current = this.current;
  44576. if (!fontObj) {
  44577. error('Can\'t find font for ' + fontRefName);
  44578. }
  44579. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44580. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44581. warn('Invalid font matrix for font ' + fontRefName);
  44582. }
  44583. if (size < 0) {
  44584. size = -size;
  44585. current.fontDirection = -1;
  44586. } else {
  44587. current.fontDirection = 1;
  44588. }
  44589. this.current.font = fontObj;
  44590. this.current.fontSize = size;
  44591. if (fontObj.isType3Font) {
  44592. return;
  44593. }
  44594. var name = fontObj.loadedName || 'sans-serif';
  44595. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  44596. var italic = fontObj.italic ? 'italic' : 'normal';
  44597. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44598. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44599. this.current.fontSizeScale = size / browserFontSize;
  44600. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44601. this.ctx.font = rule;
  44602. },
  44603. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44604. this.current.textRenderingMode = mode;
  44605. },
  44606. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44607. this.current.textRise = rise;
  44608. },
  44609. moveText: function CanvasGraphics_moveText(x, y) {
  44610. this.current.x = this.current.lineX += x;
  44611. this.current.y = this.current.lineY += y;
  44612. },
  44613. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44614. this.setLeading(-y);
  44615. this.moveText(x, y);
  44616. },
  44617. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44618. this.current.textMatrix = [
  44619. a,
  44620. b,
  44621. c,
  44622. d,
  44623. e,
  44624. f
  44625. ];
  44626. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44627. this.current.x = this.current.lineX = 0;
  44628. this.current.y = this.current.lineY = 0;
  44629. },
  44630. nextLine: function CanvasGraphics_nextLine() {
  44631. this.moveText(0, this.current.leading);
  44632. },
  44633. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44634. var ctx = this.ctx;
  44635. var current = this.current;
  44636. var font = current.font;
  44637. var textRenderingMode = current.textRenderingMode;
  44638. var fontSize = current.fontSize / current.fontSizeScale;
  44639. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44640. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44641. var addToPath;
  44642. if (font.disableFontFace || isAddToPathSet) {
  44643. addToPath = font.getPathGenerator(this.commonObjs, character);
  44644. }
  44645. if (font.disableFontFace) {
  44646. ctx.save();
  44647. ctx.translate(x, y);
  44648. ctx.beginPath();
  44649. addToPath(ctx, fontSize);
  44650. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44651. ctx.fill();
  44652. }
  44653. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44654. ctx.stroke();
  44655. }
  44656. ctx.restore();
  44657. } else {
  44658. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44659. ctx.fillText(character, x, y);
  44660. }
  44661. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44662. ctx.strokeText(character, x, y);
  44663. }
  44664. }
  44665. if (isAddToPathSet) {
  44666. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44667. paths.push({
  44668. transform: ctx.mozCurrentTransform,
  44669. x: x,
  44670. y: y,
  44671. fontSize: fontSize,
  44672. addToPath: addToPath
  44673. });
  44674. }
  44675. },
  44676. get isFontSubpixelAAEnabled() {
  44677. var ctx = document.createElement('canvas').getContext('2d');
  44678. ctx.scale(1.5, 1);
  44679. ctx.fillText('I', 0, 10);
  44680. var data = ctx.getImageData(0, 0, 10, 10).data;
  44681. var enabled = false;
  44682. for (var i = 3; i < data.length; i += 4) {
  44683. if (data[i] > 0 && data[i] < 255) {
  44684. enabled = true;
  44685. break;
  44686. }
  44687. }
  44688. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44689. },
  44690. showText: function CanvasGraphics_showText(glyphs) {
  44691. var current = this.current;
  44692. var font = current.font;
  44693. if (font.isType3Font) {
  44694. return this.showType3Text(glyphs);
  44695. }
  44696. var fontSize = current.fontSize;
  44697. if (fontSize === 0) {
  44698. return;
  44699. }
  44700. var ctx = this.ctx;
  44701. var fontSizeScale = current.fontSizeScale;
  44702. var charSpacing = current.charSpacing;
  44703. var wordSpacing = current.wordSpacing;
  44704. var fontDirection = current.fontDirection;
  44705. var textHScale = current.textHScale * fontDirection;
  44706. var glyphsLength = glyphs.length;
  44707. var vertical = font.vertical;
  44708. var spacingDir = vertical ? 1 : -1;
  44709. var defaultVMetrics = font.defaultVMetrics;
  44710. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44711. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44712. ctx.save();
  44713. ctx.transform.apply(ctx, current.textMatrix);
  44714. ctx.translate(current.x, current.y + current.textRise);
  44715. if (current.patternFill) {
  44716. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44717. }
  44718. if (fontDirection > 0) {
  44719. ctx.scale(textHScale, -1);
  44720. } else {
  44721. ctx.scale(textHScale, 1);
  44722. }
  44723. var lineWidth = current.lineWidth;
  44724. var scale = current.textMatrixScale;
  44725. if (scale === 0 || lineWidth === 0) {
  44726. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44727. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44728. this.cachedGetSinglePixelWidth = null;
  44729. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44730. }
  44731. } else {
  44732. lineWidth /= scale;
  44733. }
  44734. if (fontSizeScale !== 1.0) {
  44735. ctx.scale(fontSizeScale, fontSizeScale);
  44736. lineWidth /= fontSizeScale;
  44737. }
  44738. ctx.lineWidth = lineWidth;
  44739. var x = 0, i;
  44740. for (i = 0; i < glyphsLength; ++i) {
  44741. var glyph = glyphs[i];
  44742. if (isNum(glyph)) {
  44743. x += spacingDir * glyph * fontSize / 1000;
  44744. continue;
  44745. }
  44746. var restoreNeeded = false;
  44747. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44748. var character = glyph.fontChar;
  44749. var accent = glyph.accent;
  44750. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44751. var width = glyph.width;
  44752. if (vertical) {
  44753. var vmetric, vx, vy;
  44754. vmetric = glyph.vmetric || defaultVMetrics;
  44755. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44756. vx = -vx * widthAdvanceScale;
  44757. vy = vmetric[2] * widthAdvanceScale;
  44758. width = vmetric ? -vmetric[0] : width;
  44759. scaledX = vx / fontSizeScale;
  44760. scaledY = (x + vy) / fontSizeScale;
  44761. } else {
  44762. scaledX = x / fontSizeScale;
  44763. scaledY = 0;
  44764. }
  44765. if (font.remeasure && width > 0) {
  44766. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44767. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44768. var characterScaleX = width / measuredWidth;
  44769. restoreNeeded = true;
  44770. ctx.save();
  44771. ctx.scale(characterScaleX, 1);
  44772. scaledX /= characterScaleX;
  44773. } else if (width !== measuredWidth) {
  44774. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44775. }
  44776. }
  44777. if (glyph.isInFont || font.missingFile) {
  44778. if (simpleFillText && !accent) {
  44779. ctx.fillText(character, scaledX, scaledY);
  44780. } else {
  44781. this.paintChar(character, scaledX, scaledY);
  44782. if (accent) {
  44783. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44784. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44785. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44786. }
  44787. }
  44788. }
  44789. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44790. x += charWidth;
  44791. if (restoreNeeded) {
  44792. ctx.restore();
  44793. }
  44794. }
  44795. if (vertical) {
  44796. current.y -= x * textHScale;
  44797. } else {
  44798. current.x += x * textHScale;
  44799. }
  44800. ctx.restore();
  44801. },
  44802. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44803. var ctx = this.ctx;
  44804. var current = this.current;
  44805. var font = current.font;
  44806. var fontSize = current.fontSize;
  44807. var fontDirection = current.fontDirection;
  44808. var spacingDir = font.vertical ? 1 : -1;
  44809. var charSpacing = current.charSpacing;
  44810. var wordSpacing = current.wordSpacing;
  44811. var textHScale = current.textHScale * fontDirection;
  44812. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44813. var glyphsLength = glyphs.length;
  44814. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44815. var i, glyph, width, spacingLength;
  44816. if (isTextInvisible || fontSize === 0) {
  44817. return;
  44818. }
  44819. this.cachedGetSinglePixelWidth = null;
  44820. ctx.save();
  44821. ctx.transform.apply(ctx, current.textMatrix);
  44822. ctx.translate(current.x, current.y);
  44823. ctx.scale(textHScale, fontDirection);
  44824. for (i = 0; i < glyphsLength; ++i) {
  44825. glyph = glyphs[i];
  44826. if (isNum(glyph)) {
  44827. spacingLength = spacingDir * glyph * fontSize / 1000;
  44828. this.ctx.translate(spacingLength, 0);
  44829. current.x += spacingLength * textHScale;
  44830. continue;
  44831. }
  44832. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44833. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  44834. if (!operatorList) {
  44835. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  44836. continue;
  44837. }
  44838. this.processingType3 = glyph;
  44839. this.save();
  44840. ctx.scale(fontSize, fontSize);
  44841. ctx.transform.apply(ctx, fontMatrix);
  44842. this.executeOperatorList(operatorList);
  44843. this.restore();
  44844. var transformed = Util.applyTransform([
  44845. glyph.width,
  44846. 0
  44847. ], fontMatrix);
  44848. width = transformed[0] * fontSize + spacing;
  44849. ctx.translate(width, 0);
  44850. current.x += width * textHScale;
  44851. }
  44852. ctx.restore();
  44853. this.processingType3 = null;
  44854. },
  44855. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  44856. },
  44857. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  44858. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  44859. this.clip();
  44860. this.endPath();
  44861. },
  44862. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  44863. var pattern;
  44864. if (IR[0] === 'TilingPattern') {
  44865. var color = IR[1];
  44866. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  44867. var self = this;
  44868. var canvasGraphicsFactory = {
  44869. createCanvasGraphics: function (ctx) {
  44870. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  44871. }
  44872. };
  44873. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  44874. } else {
  44875. pattern = getShadingPatternFromIR(IR);
  44876. }
  44877. return pattern;
  44878. },
  44879. setStrokeColorN: function CanvasGraphics_setStrokeColorN()
  44880. {
  44881. this.current.strokeColor = this.getColorN_Pattern(arguments);
  44882. },
  44883. setFillColorN: function CanvasGraphics_setFillColorN()
  44884. {
  44885. this.current.fillColor = this.getColorN_Pattern(arguments);
  44886. this.current.patternFill = true;
  44887. },
  44888. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  44889. var color = Util.makeCssRgb(r, g, b);
  44890. this.ctx.strokeStyle = color;
  44891. this.current.strokeColor = color;
  44892. },
  44893. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  44894. var color = Util.makeCssRgb(r, g, b);
  44895. this.ctx.fillStyle = color;
  44896. this.current.fillColor = color;
  44897. this.current.patternFill = false;
  44898. },
  44899. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  44900. var ctx = this.ctx;
  44901. this.save();
  44902. var pattern = getShadingPatternFromIR(patternIR);
  44903. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  44904. var inv = ctx.mozCurrentTransformInverse;
  44905. if (inv) {
  44906. var canvas = ctx.canvas;
  44907. var width = canvas.width;
  44908. var height = canvas.height;
  44909. var bl = Util.applyTransform([
  44910. 0,
  44911. 0
  44912. ], inv);
  44913. var br = Util.applyTransform([
  44914. 0,
  44915. height
  44916. ], inv);
  44917. var ul = Util.applyTransform([
  44918. width,
  44919. 0
  44920. ], inv);
  44921. var ur = Util.applyTransform([
  44922. width,
  44923. height
  44924. ], inv);
  44925. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  44926. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  44927. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  44928. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  44929. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  44930. } else {
  44931. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  44932. }
  44933. this.restore();
  44934. },
  44935. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  44936. error('Should not call beginInlineImage');
  44937. },
  44938. beginImageData: function CanvasGraphics_beginImageData() {
  44939. error('Should not call beginImageData');
  44940. },
  44941. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  44942. this.save();
  44943. this.baseTransformStack.push(this.baseTransform);
  44944. if (isArray(matrix) && 6 === matrix.length) {
  44945. this.transform.apply(this, matrix);
  44946. }
  44947. this.baseTransform = this.ctx.mozCurrentTransform;
  44948. if (isArray(bbox) && 4 === bbox.length) {
  44949. var width = bbox[2] - bbox[0];
  44950. var height = bbox[3] - bbox[1];
  44951. this.ctx.rect(bbox[0], bbox[1], width, height);
  44952. this.clip();
  44953. this.endPath();
  44954. }
  44955. },
  44956. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  44957. this.restore();
  44958. this.baseTransform = this.baseTransformStack.pop();
  44959. },
  44960. beginGroup: function CanvasGraphics_beginGroup(group) {
  44961. this.save();
  44962. var currentCtx = this.ctx;
  44963. if (!group.isolated) {
  44964. info('TODO: Support non-isolated groups.');
  44965. }
  44966. if (group.knockout) {
  44967. warn('Knockout groups not supported.');
  44968. }
  44969. var currentTransform = currentCtx.mozCurrentTransform;
  44970. if (group.matrix) {
  44971. currentCtx.transform.apply(currentCtx, group.matrix);
  44972. }
  44973. assert(group.bbox, 'Bounding box is required.');
  44974. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  44975. var canvasBounds = [
  44976. 0,
  44977. 0,
  44978. currentCtx.canvas.width,
  44979. currentCtx.canvas.height
  44980. ];
  44981. bounds = Util.intersect(bounds, canvasBounds) || [
  44982. 0,
  44983. 0,
  44984. 0,
  44985. 0
  44986. ];
  44987. var offsetX = Math.floor(bounds[0]);
  44988. var offsetY = Math.floor(bounds[1]);
  44989. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  44990. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  44991. var scaleX = 1, scaleY = 1;
  44992. if (drawnWidth > MAX_GROUP_SIZE) {
  44993. scaleX = drawnWidth / MAX_GROUP_SIZE;
  44994. drawnWidth = MAX_GROUP_SIZE;
  44995. }
  44996. if (drawnHeight > MAX_GROUP_SIZE) {
  44997. scaleY = drawnHeight / MAX_GROUP_SIZE;
  44998. drawnHeight = MAX_GROUP_SIZE;
  44999. }
  45000. var cacheId = 'groupAt' + this.groupLevel;
  45001. if (group.smask) {
  45002. cacheId += '_smask_' + this.smaskCounter++ % 2;
  45003. }
  45004. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45005. var groupCtx = scratchCanvas.context;
  45006. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45007. groupCtx.translate(-offsetX, -offsetY);
  45008. groupCtx.transform.apply(groupCtx, currentTransform);
  45009. if (group.smask) {
  45010. this.smaskStack.push({
  45011. canvas: scratchCanvas.canvas,
  45012. context: groupCtx,
  45013. offsetX: offsetX,
  45014. offsetY: offsetY,
  45015. scaleX: scaleX,
  45016. scaleY: scaleY,
  45017. subtype: group.smask.subtype,
  45018. backdrop: group.smask.backdrop,
  45019. transferMap: group.smask.transferMap || null,
  45020. startTransformInverse: null
  45021. });
  45022. } else
  45023. {
  45024. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45025. currentCtx.translate(offsetX, offsetY);
  45026. currentCtx.scale(scaleX, scaleY);
  45027. }
  45028. copyCtxState(currentCtx, groupCtx);
  45029. this.ctx = groupCtx;
  45030. this.setGState([
  45031. [
  45032. 'BM',
  45033. 'Normal'
  45034. ],
  45035. [
  45036. 'ca',
  45037. 1
  45038. ],
  45039. [
  45040. 'CA',
  45041. 1
  45042. ]
  45043. ]);
  45044. this.groupStack.push(currentCtx);
  45045. this.groupLevel++;
  45046. this.current.activeSMask = null;
  45047. },
  45048. endGroup: function CanvasGraphics_endGroup(group) {
  45049. this.groupLevel--;
  45050. var groupCtx = this.ctx;
  45051. this.ctx = this.groupStack.pop();
  45052. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45053. this.ctx.imageSmoothingEnabled = false;
  45054. } else {
  45055. this.ctx.mozImageSmoothingEnabled = false;
  45056. }
  45057. if (group.smask) {
  45058. this.tempSMask = this.smaskStack.pop();
  45059. } else {
  45060. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45061. }
  45062. this.restore();
  45063. },
  45064. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45065. this.save();
  45066. this.current = new CanvasExtraState();
  45067. if (this.baseTransform) {
  45068. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45069. }
  45070. },
  45071. endAnnotations: function CanvasGraphics_endAnnotations() {
  45072. this.restore();
  45073. },
  45074. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45075. this.save();
  45076. if (isArray(rect) && 4 === rect.length) {
  45077. var width = rect[2] - rect[0];
  45078. var height = rect[3] - rect[1];
  45079. this.ctx.rect(rect[0], rect[1], width, height);
  45080. this.clip();
  45081. this.endPath();
  45082. }
  45083. this.transform.apply(this, transform);
  45084. this.transform.apply(this, matrix);
  45085. },
  45086. endAnnotation: function CanvasGraphics_endAnnotation() {
  45087. this.restore();
  45088. },
  45089. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45090. var domImage = this.objs.get(objId);
  45091. if (!domImage) {
  45092. warn('Dependent image isn\'t ready yet');
  45093. return;
  45094. }
  45095. this.save();
  45096. var ctx = this.ctx;
  45097. ctx.scale(1 / w, -1 / h);
  45098. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45099. if (this.imageLayer) {
  45100. var currentTransform = ctx.mozCurrentTransformInverse;
  45101. var position = this.getCanvasPosition(0, 0);
  45102. this.imageLayer.appendImage({
  45103. objId: objId,
  45104. left: position[0],
  45105. top: position[1],
  45106. width: w / currentTransform[0],
  45107. height: h / currentTransform[3]
  45108. });
  45109. }
  45110. this.restore();
  45111. },
  45112. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45113. var ctx = this.ctx;
  45114. var width = img.width, height = img.height;
  45115. var fillColor = this.current.fillColor;
  45116. var isPatternFill = this.current.patternFill;
  45117. var glyph = this.processingType3;
  45118. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45119. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45120. glyph.compiled = compileType3Glyph({
  45121. data: img.data,
  45122. width: width,
  45123. height: height
  45124. });
  45125. } else {
  45126. glyph.compiled = null;
  45127. }
  45128. }
  45129. if (glyph && glyph.compiled) {
  45130. glyph.compiled(ctx);
  45131. return;
  45132. }
  45133. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45134. var maskCtx = maskCanvas.context;
  45135. maskCtx.save();
  45136. putBinaryImageMask(maskCtx, img);
  45137. maskCtx.globalCompositeOperation = 'source-in';
  45138. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45139. maskCtx.fillRect(0, 0, width, height);
  45140. maskCtx.restore();
  45141. this.paintInlineImageXObject(maskCanvas.canvas);
  45142. },
  45143. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45144. var width = imgData.width;
  45145. var height = imgData.height;
  45146. var fillColor = this.current.fillColor;
  45147. var isPatternFill = this.current.patternFill;
  45148. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45149. var maskCtx = maskCanvas.context;
  45150. maskCtx.save();
  45151. putBinaryImageMask(maskCtx, imgData);
  45152. maskCtx.globalCompositeOperation = 'source-in';
  45153. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45154. maskCtx.fillRect(0, 0, width, height);
  45155. maskCtx.restore();
  45156. var ctx = this.ctx;
  45157. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45158. ctx.save();
  45159. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45160. ctx.scale(1, -1);
  45161. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45162. ctx.restore();
  45163. }
  45164. },
  45165. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45166. var ctx = this.ctx;
  45167. var fillColor = this.current.fillColor;
  45168. var isPatternFill = this.current.patternFill;
  45169. for (var i = 0, ii = images.length; i < ii; i++) {
  45170. var image = images[i];
  45171. var width = image.width, height = image.height;
  45172. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45173. var maskCtx = maskCanvas.context;
  45174. maskCtx.save();
  45175. putBinaryImageMask(maskCtx, image);
  45176. maskCtx.globalCompositeOperation = 'source-in';
  45177. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45178. maskCtx.fillRect(0, 0, width, height);
  45179. maskCtx.restore();
  45180. ctx.save();
  45181. ctx.transform.apply(ctx, image.transform);
  45182. ctx.scale(1, -1);
  45183. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45184. ctx.restore();
  45185. }
  45186. },
  45187. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45188. var imgData = this.objs.get(objId);
  45189. if (!imgData) {
  45190. warn('Dependent image isn\'t ready yet');
  45191. return;
  45192. }
  45193. this.paintInlineImageXObject(imgData);
  45194. },
  45195. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45196. var imgData = this.objs.get(objId);
  45197. if (!imgData) {
  45198. warn('Dependent image isn\'t ready yet');
  45199. return;
  45200. }
  45201. var width = imgData.width;
  45202. var height = imgData.height;
  45203. var map = [];
  45204. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45205. map.push({
  45206. transform: [
  45207. scaleX,
  45208. 0,
  45209. 0,
  45210. scaleY,
  45211. positions[i],
  45212. positions[i + 1]
  45213. ],
  45214. x: 0,
  45215. y: 0,
  45216. w: width,
  45217. h: height
  45218. });
  45219. }
  45220. this.paintInlineImageXObjectGroup(imgData, map);
  45221. },
  45222. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45223. var width = imgData.width;
  45224. var height = imgData.height;
  45225. var ctx = this.ctx;
  45226. this.save();
  45227. ctx.scale(1 / width, -1 / height);
  45228. var currentTransform = ctx.mozCurrentTransformInverse;
  45229. var a = currentTransform[0], b = currentTransform[1];
  45230. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45231. var c = currentTransform[2], d = currentTransform[3];
  45232. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45233. var imgToPaint, tmpCanvas;
  45234. if (imgData instanceof HTMLElement || !imgData.data) {
  45235. imgToPaint = imgData;
  45236. } else {
  45237. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45238. var tmpCtx = tmpCanvas.context;
  45239. putBinaryImageData(tmpCtx, imgData);
  45240. imgToPaint = tmpCanvas.canvas;
  45241. }
  45242. var paintWidth = width, paintHeight = height;
  45243. var tmpCanvasId = 'prescale1';
  45244. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45245. var newWidth = paintWidth, newHeight = paintHeight;
  45246. if (widthScale > 2 && paintWidth > 1) {
  45247. newWidth = Math.ceil(paintWidth / 2);
  45248. widthScale /= paintWidth / newWidth;
  45249. }
  45250. if (heightScale > 2 && paintHeight > 1) {
  45251. newHeight = Math.ceil(paintHeight / 2);
  45252. heightScale /= paintHeight / newHeight;
  45253. }
  45254. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45255. tmpCtx = tmpCanvas.context;
  45256. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45257. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45258. imgToPaint = tmpCanvas.canvas;
  45259. paintWidth = newWidth;
  45260. paintHeight = newHeight;
  45261. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45262. }
  45263. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45264. if (this.imageLayer) {
  45265. var position = this.getCanvasPosition(0, -height);
  45266. this.imageLayer.appendImage({
  45267. imgData: imgData,
  45268. left: position[0],
  45269. top: position[1],
  45270. width: width / currentTransform[0],
  45271. height: height / currentTransform[3]
  45272. });
  45273. }
  45274. this.restore();
  45275. },
  45276. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45277. var ctx = this.ctx;
  45278. var w = imgData.width;
  45279. var h = imgData.height;
  45280. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45281. var tmpCtx = tmpCanvas.context;
  45282. putBinaryImageData(tmpCtx, imgData);
  45283. for (var i = 0, ii = map.length; i < ii; i++) {
  45284. var entry = map[i];
  45285. ctx.save();
  45286. ctx.transform.apply(ctx, entry.transform);
  45287. ctx.scale(1, -1);
  45288. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45289. if (this.imageLayer) {
  45290. var position = this.getCanvasPosition(entry.x, entry.y);
  45291. this.imageLayer.appendImage({
  45292. imgData: imgData,
  45293. left: position[0],
  45294. top: position[1],
  45295. width: w,
  45296. height: h
  45297. });
  45298. }
  45299. ctx.restore();
  45300. }
  45301. },
  45302. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45303. this.ctx.fillRect(0, 0, 1, 1);
  45304. },
  45305. paintXObject: function CanvasGraphics_paintXObject() {
  45306. warn('Unsupported \'paintXObject\' command.');
  45307. },
  45308. markPoint: function CanvasGraphics_markPoint(tag) {
  45309. },
  45310. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45311. },
  45312. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45313. },
  45314. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45315. },
  45316. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45317. },
  45318. beginCompat: function CanvasGraphics_beginCompat() {
  45319. },
  45320. endCompat: function CanvasGraphics_endCompat() {
  45321. },
  45322. consumePath: function CanvasGraphics_consumePath() {
  45323. var ctx = this.ctx;
  45324. if (this.pendingClip) {
  45325. if (this.pendingClip === EO_CLIP) {
  45326. if (ctx.mozFillRule !== undefined) {
  45327. ctx.mozFillRule = 'evenodd';
  45328. ctx.clip();
  45329. ctx.mozFillRule = 'nonzero';
  45330. } else {
  45331. ctx.clip('evenodd');
  45332. }
  45333. } else {
  45334. ctx.clip();
  45335. }
  45336. this.pendingClip = null;
  45337. }
  45338. ctx.beginPath();
  45339. },
  45340. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45341. if (this.cachedGetSinglePixelWidth === null) {
  45342. this.ctx.save();
  45343. var inverse = this.ctx.mozCurrentTransformInverse;
  45344. this.ctx.restore();
  45345. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45346. }
  45347. return this.cachedGetSinglePixelWidth;
  45348. },
  45349. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45350. var transform = this.ctx.mozCurrentTransform;
  45351. return [
  45352. transform[0] * x + transform[2] * y + transform[4],
  45353. transform[1] * x + transform[3] * y + transform[5]
  45354. ];
  45355. }
  45356. };
  45357. for (var op in OPS) {
  45358. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45359. }
  45360. return CanvasGraphics;
  45361. }();
  45362. exports.CanvasGraphics = CanvasGraphics;
  45363. exports.createScratchCanvas = createScratchCanvas;
  45364. }));
  45365. (function (root, factory) {
  45366. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45367. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45368. var error = sharedUtil.error;
  45369. var info = sharedUtil.info;
  45370. var isArray = sharedUtil.isArray;
  45371. var isBool = sharedUtil.isBool;
  45372. var isDict = corePrimitives.isDict;
  45373. var isStream = corePrimitives.isStream;
  45374. var PostScriptLexer = corePsParser.PostScriptLexer;
  45375. var PostScriptParser = corePsParser.PostScriptParser;
  45376. var PDFFunction = function PDFFunctionClosure() {
  45377. var CONSTRUCT_SAMPLED = 0;
  45378. var CONSTRUCT_INTERPOLATED = 2;
  45379. var CONSTRUCT_STICHED = 3;
  45380. var CONSTRUCT_POSTSCRIPT = 4;
  45381. return {
  45382. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45383. var i, ii;
  45384. var length = 1;
  45385. for (i = 0, ii = size.length; i < ii; i++) {
  45386. length *= size[i];
  45387. }
  45388. length *= outputSize;
  45389. var array = new Array(length);
  45390. var codeSize = 0;
  45391. var codeBuf = 0;
  45392. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45393. var strBytes = str.getBytes((length * bps + 7) / 8);
  45394. var strIdx = 0;
  45395. for (i = 0; i < length; i++) {
  45396. while (codeSize < bps) {
  45397. codeBuf <<= 8;
  45398. codeBuf |= strBytes[strIdx++];
  45399. codeSize += 8;
  45400. }
  45401. codeSize -= bps;
  45402. array[i] = (codeBuf >> codeSize) * sampleMul;
  45403. codeBuf &= (1 << codeSize) - 1;
  45404. }
  45405. return array;
  45406. },
  45407. getIR: function PDFFunction_getIR(xref, fn) {
  45408. var dict = fn.dict;
  45409. if (!dict) {
  45410. dict = fn;
  45411. }
  45412. var types = [
  45413. this.constructSampled,
  45414. null,
  45415. this.constructInterpolated,
  45416. this.constructStiched,
  45417. this.constructPostScript
  45418. ];
  45419. var typeNum = dict.get('FunctionType');
  45420. var typeFn = types[typeNum];
  45421. if (!typeFn) {
  45422. error('Unknown type of function');
  45423. }
  45424. return typeFn.call(this, fn, dict, xref);
  45425. },
  45426. fromIR: function PDFFunction_fromIR(IR) {
  45427. var type = IR[0];
  45428. switch (type) {
  45429. case CONSTRUCT_SAMPLED:
  45430. return this.constructSampledFromIR(IR);
  45431. case CONSTRUCT_INTERPOLATED:
  45432. return this.constructInterpolatedFromIR(IR);
  45433. case CONSTRUCT_STICHED:
  45434. return this.constructStichedFromIR(IR);
  45435. default:
  45436. return this.constructPostScriptFromIR(IR);
  45437. }
  45438. },
  45439. parse: function PDFFunction_parse(xref, fn) {
  45440. var IR = this.getIR(xref, fn);
  45441. return this.fromIR(IR);
  45442. },
  45443. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45444. if (!isArray(fnObj)) {
  45445. return this.parse(xref, fnObj);
  45446. }
  45447. var fnArray = [];
  45448. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45449. var obj = xref.fetchIfRef(fnObj[j]);
  45450. fnArray.push(PDFFunction.parse(xref, obj));
  45451. }
  45452. return function (src, srcOffset, dest, destOffset) {
  45453. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45454. fnArray[i](src, srcOffset, dest, destOffset + i);
  45455. }
  45456. };
  45457. },
  45458. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45459. function toMultiArray(arr) {
  45460. var inputLength = arr.length;
  45461. var out = [];
  45462. var index = 0;
  45463. for (var i = 0; i < inputLength; i += 2) {
  45464. out[index] = [
  45465. arr[i],
  45466. arr[i + 1]
  45467. ];
  45468. ++index;
  45469. }
  45470. return out;
  45471. }
  45472. var domain = dict.getArray('Domain');
  45473. var range = dict.getArray('Range');
  45474. if (!domain || !range) {
  45475. error('No domain or range');
  45476. }
  45477. var inputSize = domain.length / 2;
  45478. var outputSize = range.length / 2;
  45479. domain = toMultiArray(domain);
  45480. range = toMultiArray(range);
  45481. var size = dict.get('Size');
  45482. var bps = dict.get('BitsPerSample');
  45483. var order = dict.get('Order') || 1;
  45484. if (order !== 1) {
  45485. info('No support for cubic spline interpolation: ' + order);
  45486. }
  45487. var encode = dict.getArray('Encode');
  45488. if (!encode) {
  45489. encode = [];
  45490. for (var i = 0; i < inputSize; ++i) {
  45491. encode.push(0);
  45492. encode.push(size[i] - 1);
  45493. }
  45494. }
  45495. encode = toMultiArray(encode);
  45496. var decode = dict.getArray('Decode');
  45497. if (!decode) {
  45498. decode = range;
  45499. } else {
  45500. decode = toMultiArray(decode);
  45501. }
  45502. var samples = this.getSampleArray(size, outputSize, bps, str);
  45503. return [
  45504. CONSTRUCT_SAMPLED,
  45505. inputSize,
  45506. domain,
  45507. encode,
  45508. decode,
  45509. samples,
  45510. size,
  45511. outputSize,
  45512. Math.pow(2, bps) - 1,
  45513. range
  45514. ];
  45515. },
  45516. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45517. function interpolate(x, xmin, xmax, ymin, ymax) {
  45518. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45519. }
  45520. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45521. var m = IR[1];
  45522. var domain = IR[2];
  45523. var encode = IR[3];
  45524. var decode = IR[4];
  45525. var samples = IR[5];
  45526. var size = IR[6];
  45527. var n = IR[7];
  45528. var range = IR[9];
  45529. var cubeVertices = 1 << m;
  45530. var cubeN = new Float64Array(cubeVertices);
  45531. var cubeVertex = new Uint32Array(cubeVertices);
  45532. var i, j;
  45533. for (j = 0; j < cubeVertices; j++) {
  45534. cubeN[j] = 1;
  45535. }
  45536. var k = n, pos = 1;
  45537. for (i = 0; i < m; ++i) {
  45538. var domain_2i = domain[i][0];
  45539. var domain_2i_1 = domain[i][1];
  45540. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45541. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45542. var size_i = size[i];
  45543. e = Math.min(Math.max(e, 0), size_i - 1);
  45544. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45545. var n0 = e0 + 1 - e;
  45546. var n1 = e - e0;
  45547. var offset0 = e0 * k;
  45548. var offset1 = offset0 + k;
  45549. for (j = 0; j < cubeVertices; j++) {
  45550. if (j & pos) {
  45551. cubeN[j] *= n1;
  45552. cubeVertex[j] += offset1;
  45553. } else {
  45554. cubeN[j] *= n0;
  45555. cubeVertex[j] += offset0;
  45556. }
  45557. }
  45558. k *= size_i;
  45559. pos <<= 1;
  45560. }
  45561. for (j = 0; j < n; ++j) {
  45562. var rj = 0;
  45563. for (i = 0; i < cubeVertices; i++) {
  45564. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45565. }
  45566. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45567. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45568. }
  45569. };
  45570. },
  45571. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45572. var c0 = dict.getArray('C0') || [0];
  45573. var c1 = dict.getArray('C1') || [1];
  45574. var n = dict.get('N');
  45575. if (!isArray(c0) || !isArray(c1)) {
  45576. error('Illegal dictionary for interpolated function');
  45577. }
  45578. var length = c0.length;
  45579. var diff = [];
  45580. for (var i = 0; i < length; ++i) {
  45581. diff.push(c1[i] - c0[i]);
  45582. }
  45583. return [
  45584. CONSTRUCT_INTERPOLATED,
  45585. c0,
  45586. diff,
  45587. n
  45588. ];
  45589. },
  45590. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45591. var c0 = IR[1];
  45592. var diff = IR[2];
  45593. var n = IR[3];
  45594. var length = diff.length;
  45595. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45596. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45597. for (var j = 0; j < length; ++j) {
  45598. dest[destOffset + j] = c0[j] + x * diff[j];
  45599. }
  45600. };
  45601. },
  45602. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45603. var domain = dict.getArray('Domain');
  45604. if (!domain) {
  45605. error('No domain');
  45606. }
  45607. var inputSize = domain.length / 2;
  45608. if (inputSize !== 1) {
  45609. error('Bad domain for stiched function');
  45610. }
  45611. var fnRefs = dict.get('Functions');
  45612. var fns = [];
  45613. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45614. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45615. }
  45616. var bounds = dict.getArray('Bounds');
  45617. var encode = dict.getArray('Encode');
  45618. return [
  45619. CONSTRUCT_STICHED,
  45620. domain,
  45621. bounds,
  45622. encode,
  45623. fns
  45624. ];
  45625. },
  45626. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45627. var domain = IR[1];
  45628. var bounds = IR[2];
  45629. var encode = IR[3];
  45630. var fnsIR = IR[4];
  45631. var fns = [];
  45632. var tmpBuf = new Float32Array(1);
  45633. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45634. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45635. }
  45636. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45637. var clip = function constructStichedFromIRClip(v, min, max) {
  45638. if (v > max) {
  45639. v = max;
  45640. } else if (v < min) {
  45641. v = min;
  45642. }
  45643. return v;
  45644. };
  45645. var v = clip(src[srcOffset], domain[0], domain[1]);
  45646. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45647. if (v < bounds[i]) {
  45648. break;
  45649. }
  45650. }
  45651. var dmin = domain[0];
  45652. if (i > 0) {
  45653. dmin = bounds[i - 1];
  45654. }
  45655. var dmax = domain[1];
  45656. if (i < bounds.length) {
  45657. dmax = bounds[i];
  45658. }
  45659. var rmin = encode[2 * i];
  45660. var rmax = encode[2 * i + 1];
  45661. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45662. fns[i](tmpBuf, 0, dest, destOffset);
  45663. };
  45664. },
  45665. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45666. var domain = dict.getArray('Domain');
  45667. var range = dict.getArray('Range');
  45668. if (!domain) {
  45669. error('No domain.');
  45670. }
  45671. if (!range) {
  45672. error('No range.');
  45673. }
  45674. var lexer = new PostScriptLexer(fn);
  45675. var parser = new PostScriptParser(lexer);
  45676. var code = parser.parse();
  45677. return [
  45678. CONSTRUCT_POSTSCRIPT,
  45679. domain,
  45680. range,
  45681. code
  45682. ];
  45683. },
  45684. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45685. var domain = IR[1];
  45686. var range = IR[2];
  45687. var code = IR[3];
  45688. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45689. if (compiled) {
  45690. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45691. }
  45692. info('Unable to compile PS function');
  45693. var numOutputs = range.length >> 1;
  45694. var numInputs = domain.length >> 1;
  45695. var evaluator = new PostScriptEvaluator(code);
  45696. var cache = Object.create(null);
  45697. var MAX_CACHE_SIZE = 2048 * 4;
  45698. var cache_available = MAX_CACHE_SIZE;
  45699. var tmpBuf = new Float32Array(numInputs);
  45700. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45701. var i, value;
  45702. var key = '';
  45703. var input = tmpBuf;
  45704. for (i = 0; i < numInputs; i++) {
  45705. value = src[srcOffset + i];
  45706. input[i] = value;
  45707. key += value + '_';
  45708. }
  45709. var cachedValue = cache[key];
  45710. if (cachedValue !== undefined) {
  45711. dest.set(cachedValue, destOffset);
  45712. return;
  45713. }
  45714. var output = new Float32Array(numOutputs);
  45715. var stack = evaluator.execute(input);
  45716. var stackIndex = stack.length - numOutputs;
  45717. for (i = 0; i < numOutputs; i++) {
  45718. value = stack[stackIndex + i];
  45719. var bound = range[i * 2];
  45720. if (value < bound) {
  45721. value = bound;
  45722. } else {
  45723. bound = range[i * 2 + 1];
  45724. if (value > bound) {
  45725. value = bound;
  45726. }
  45727. }
  45728. output[i] = value;
  45729. }
  45730. if (cache_available > 0) {
  45731. cache_available--;
  45732. cache[key] = output;
  45733. }
  45734. dest.set(output, destOffset);
  45735. };
  45736. }
  45737. };
  45738. }();
  45739. function isPDFFunction(v) {
  45740. var fnDict;
  45741. if (typeof v !== 'object') {
  45742. return false;
  45743. } else if (isDict(v)) {
  45744. fnDict = v;
  45745. } else if (isStream(v)) {
  45746. fnDict = v.dict;
  45747. } else {
  45748. return false;
  45749. }
  45750. return fnDict.has('FunctionType');
  45751. }
  45752. var PostScriptStack = function PostScriptStackClosure() {
  45753. var MAX_STACK_SIZE = 100;
  45754. function PostScriptStack(initialStack) {
  45755. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45756. }
  45757. PostScriptStack.prototype = {
  45758. push: function PostScriptStack_push(value) {
  45759. if (this.stack.length >= MAX_STACK_SIZE) {
  45760. error('PostScript function stack overflow.');
  45761. }
  45762. this.stack.push(value);
  45763. },
  45764. pop: function PostScriptStack_pop() {
  45765. if (this.stack.length <= 0) {
  45766. error('PostScript function stack underflow.');
  45767. }
  45768. return this.stack.pop();
  45769. },
  45770. copy: function PostScriptStack_copy(n) {
  45771. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45772. error('PostScript function stack overflow.');
  45773. }
  45774. var stack = this.stack;
  45775. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45776. stack.push(stack[i]);
  45777. }
  45778. },
  45779. index: function PostScriptStack_index(n) {
  45780. this.push(this.stack[this.stack.length - n - 1]);
  45781. },
  45782. roll: function PostScriptStack_roll(n, p) {
  45783. var stack = this.stack;
  45784. var l = stack.length - n;
  45785. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45786. for (i = l, j = r; i < j; i++, j--) {
  45787. t = stack[i];
  45788. stack[i] = stack[j];
  45789. stack[j] = t;
  45790. }
  45791. for (i = l, j = c - 1; i < j; i++, j--) {
  45792. t = stack[i];
  45793. stack[i] = stack[j];
  45794. stack[j] = t;
  45795. }
  45796. for (i = c, j = r; i < j; i++, j--) {
  45797. t = stack[i];
  45798. stack[i] = stack[j];
  45799. stack[j] = t;
  45800. }
  45801. }
  45802. };
  45803. return PostScriptStack;
  45804. }();
  45805. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45806. function PostScriptEvaluator(operators) {
  45807. this.operators = operators;
  45808. }
  45809. PostScriptEvaluator.prototype = {
  45810. execute: function PostScriptEvaluator_execute(initialStack) {
  45811. var stack = new PostScriptStack(initialStack);
  45812. var counter = 0;
  45813. var operators = this.operators;
  45814. var length = operators.length;
  45815. var operator, a, b;
  45816. while (counter < length) {
  45817. operator = operators[counter++];
  45818. if (typeof operator === 'number') {
  45819. stack.push(operator);
  45820. continue;
  45821. }
  45822. switch (operator) {
  45823. case 'jz':
  45824. b = stack.pop();
  45825. a = stack.pop();
  45826. if (!a) {
  45827. counter = b;
  45828. }
  45829. break;
  45830. case 'j':
  45831. a = stack.pop();
  45832. counter = a;
  45833. break;
  45834. case 'abs':
  45835. a = stack.pop();
  45836. stack.push(Math.abs(a));
  45837. break;
  45838. case 'add':
  45839. b = stack.pop();
  45840. a = stack.pop();
  45841. stack.push(a + b);
  45842. break;
  45843. case 'and':
  45844. b = stack.pop();
  45845. a = stack.pop();
  45846. if (isBool(a) && isBool(b)) {
  45847. stack.push(a && b);
  45848. } else {
  45849. stack.push(a & b);
  45850. }
  45851. break;
  45852. case 'atan':
  45853. a = stack.pop();
  45854. stack.push(Math.atan(a));
  45855. break;
  45856. case 'bitshift':
  45857. b = stack.pop();
  45858. a = stack.pop();
  45859. if (a > 0) {
  45860. stack.push(a << b);
  45861. } else {
  45862. stack.push(a >> b);
  45863. }
  45864. break;
  45865. case 'ceiling':
  45866. a = stack.pop();
  45867. stack.push(Math.ceil(a));
  45868. break;
  45869. case 'copy':
  45870. a = stack.pop();
  45871. stack.copy(a);
  45872. break;
  45873. case 'cos':
  45874. a = stack.pop();
  45875. stack.push(Math.cos(a));
  45876. break;
  45877. case 'cvi':
  45878. a = stack.pop() | 0;
  45879. stack.push(a);
  45880. break;
  45881. case 'cvr':
  45882. break;
  45883. case 'div':
  45884. b = stack.pop();
  45885. a = stack.pop();
  45886. stack.push(a / b);
  45887. break;
  45888. case 'dup':
  45889. stack.copy(1);
  45890. break;
  45891. case 'eq':
  45892. b = stack.pop();
  45893. a = stack.pop();
  45894. stack.push(a === b);
  45895. break;
  45896. case 'exch':
  45897. stack.roll(2, 1);
  45898. break;
  45899. case 'exp':
  45900. b = stack.pop();
  45901. a = stack.pop();
  45902. stack.push(Math.pow(a, b));
  45903. break;
  45904. case 'false':
  45905. stack.push(false);
  45906. break;
  45907. case 'floor':
  45908. a = stack.pop();
  45909. stack.push(Math.floor(a));
  45910. break;
  45911. case 'ge':
  45912. b = stack.pop();
  45913. a = stack.pop();
  45914. stack.push(a >= b);
  45915. break;
  45916. case 'gt':
  45917. b = stack.pop();
  45918. a = stack.pop();
  45919. stack.push(a > b);
  45920. break;
  45921. case 'idiv':
  45922. b = stack.pop();
  45923. a = stack.pop();
  45924. stack.push(a / b | 0);
  45925. break;
  45926. case 'index':
  45927. a = stack.pop();
  45928. stack.index(a);
  45929. break;
  45930. case 'le':
  45931. b = stack.pop();
  45932. a = stack.pop();
  45933. stack.push(a <= b);
  45934. break;
  45935. case 'ln':
  45936. a = stack.pop();
  45937. stack.push(Math.log(a));
  45938. break;
  45939. case 'log':
  45940. a = stack.pop();
  45941. stack.push(Math.log(a) / Math.LN10);
  45942. break;
  45943. case 'lt':
  45944. b = stack.pop();
  45945. a = stack.pop();
  45946. stack.push(a < b);
  45947. break;
  45948. case 'mod':
  45949. b = stack.pop();
  45950. a = stack.pop();
  45951. stack.push(a % b);
  45952. break;
  45953. case 'mul':
  45954. b = stack.pop();
  45955. a = stack.pop();
  45956. stack.push(a * b);
  45957. break;
  45958. case 'ne':
  45959. b = stack.pop();
  45960. a = stack.pop();
  45961. stack.push(a !== b);
  45962. break;
  45963. case 'neg':
  45964. a = stack.pop();
  45965. stack.push(-a);
  45966. break;
  45967. case 'not':
  45968. a = stack.pop();
  45969. if (isBool(a)) {
  45970. stack.push(!a);
  45971. } else {
  45972. stack.push(~a);
  45973. }
  45974. break;
  45975. case 'or':
  45976. b = stack.pop();
  45977. a = stack.pop();
  45978. if (isBool(a) && isBool(b)) {
  45979. stack.push(a || b);
  45980. } else {
  45981. stack.push(a | b);
  45982. }
  45983. break;
  45984. case 'pop':
  45985. stack.pop();
  45986. break;
  45987. case 'roll':
  45988. b = stack.pop();
  45989. a = stack.pop();
  45990. stack.roll(a, b);
  45991. break;
  45992. case 'round':
  45993. a = stack.pop();
  45994. stack.push(Math.round(a));
  45995. break;
  45996. case 'sin':
  45997. a = stack.pop();
  45998. stack.push(Math.sin(a));
  45999. break;
  46000. case 'sqrt':
  46001. a = stack.pop();
  46002. stack.push(Math.sqrt(a));
  46003. break;
  46004. case 'sub':
  46005. b = stack.pop();
  46006. a = stack.pop();
  46007. stack.push(a - b);
  46008. break;
  46009. case 'true':
  46010. stack.push(true);
  46011. break;
  46012. case 'truncate':
  46013. a = stack.pop();
  46014. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46015. stack.push(a);
  46016. break;
  46017. case 'xor':
  46018. b = stack.pop();
  46019. a = stack.pop();
  46020. if (isBool(a) && isBool(b)) {
  46021. stack.push(a !== b);
  46022. } else {
  46023. stack.push(a ^ b);
  46024. }
  46025. break;
  46026. default:
  46027. error('Unknown operator ' + operator);
  46028. break;
  46029. }
  46030. }
  46031. return stack.stack;
  46032. }
  46033. };
  46034. return PostScriptEvaluator;
  46035. }();
  46036. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46037. function AstNode(type) {
  46038. this.type = type;
  46039. }
  46040. AstNode.prototype.visit = function (visitor) {
  46041. throw new Error('abstract method');
  46042. };
  46043. function AstArgument(index, min, max) {
  46044. AstNode.call(this, 'args');
  46045. this.index = index;
  46046. this.min = min;
  46047. this.max = max;
  46048. }
  46049. AstArgument.prototype = Object.create(AstNode.prototype);
  46050. AstArgument.prototype.visit = function (visitor) {
  46051. visitor.visitArgument(this);
  46052. };
  46053. function AstLiteral(number) {
  46054. AstNode.call(this, 'literal');
  46055. this.number = number;
  46056. this.min = number;
  46057. this.max = number;
  46058. }
  46059. AstLiteral.prototype = Object.create(AstNode.prototype);
  46060. AstLiteral.prototype.visit = function (visitor) {
  46061. visitor.visitLiteral(this);
  46062. };
  46063. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46064. AstNode.call(this, 'binary');
  46065. this.op = op;
  46066. this.arg1 = arg1;
  46067. this.arg2 = arg2;
  46068. this.min = min;
  46069. this.max = max;
  46070. }
  46071. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46072. AstBinaryOperation.prototype.visit = function (visitor) {
  46073. visitor.visitBinaryOperation(this);
  46074. };
  46075. function AstMin(arg, max) {
  46076. AstNode.call(this, 'max');
  46077. this.arg = arg;
  46078. this.min = arg.min;
  46079. this.max = max;
  46080. }
  46081. AstMin.prototype = Object.create(AstNode.prototype);
  46082. AstMin.prototype.visit = function (visitor) {
  46083. visitor.visitMin(this);
  46084. };
  46085. function AstVariable(index, min, max) {
  46086. AstNode.call(this, 'var');
  46087. this.index = index;
  46088. this.min = min;
  46089. this.max = max;
  46090. }
  46091. AstVariable.prototype = Object.create(AstNode.prototype);
  46092. AstVariable.prototype.visit = function (visitor) {
  46093. visitor.visitVariable(this);
  46094. };
  46095. function AstVariableDefinition(variable, arg) {
  46096. AstNode.call(this, 'definition');
  46097. this.variable = variable;
  46098. this.arg = arg;
  46099. }
  46100. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46101. AstVariableDefinition.prototype.visit = function (visitor) {
  46102. visitor.visitVariableDefinition(this);
  46103. };
  46104. function ExpressionBuilderVisitor() {
  46105. this.parts = [];
  46106. }
  46107. ExpressionBuilderVisitor.prototype = {
  46108. visitArgument: function (arg) {
  46109. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46110. },
  46111. visitVariable: function (variable) {
  46112. this.parts.push('v', variable.index);
  46113. },
  46114. visitLiteral: function (literal) {
  46115. this.parts.push(literal.number);
  46116. },
  46117. visitBinaryOperation: function (operation) {
  46118. this.parts.push('(');
  46119. operation.arg1.visit(this);
  46120. this.parts.push(' ', operation.op, ' ');
  46121. operation.arg2.visit(this);
  46122. this.parts.push(')');
  46123. },
  46124. visitVariableDefinition: function (definition) {
  46125. this.parts.push('var ');
  46126. definition.variable.visit(this);
  46127. this.parts.push(' = ');
  46128. definition.arg.visit(this);
  46129. this.parts.push(';');
  46130. },
  46131. visitMin: function (max) {
  46132. this.parts.push('Math.min(');
  46133. max.arg.visit(this);
  46134. this.parts.push(', ', max.max, ')');
  46135. },
  46136. toString: function () {
  46137. return this.parts.join('');
  46138. }
  46139. };
  46140. function buildAddOperation(num1, num2) {
  46141. if (num2.type === 'literal' && num2.number === 0) {
  46142. return num1;
  46143. }
  46144. if (num1.type === 'literal' && num1.number === 0) {
  46145. return num2;
  46146. }
  46147. if (num2.type === 'literal' && num1.type === 'literal') {
  46148. return new AstLiteral(num1.number + num2.number);
  46149. }
  46150. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46151. }
  46152. function buildMulOperation(num1, num2) {
  46153. if (num2.type === 'literal') {
  46154. if (num2.number === 0) {
  46155. return new AstLiteral(0);
  46156. } else if (num2.number === 1) {
  46157. return num1;
  46158. } else if (num1.type === 'literal') {
  46159. return new AstLiteral(num1.number * num2.number);
  46160. }
  46161. }
  46162. if (num1.type === 'literal') {
  46163. if (num1.number === 0) {
  46164. return new AstLiteral(0);
  46165. } else if (num1.number === 1) {
  46166. return num2;
  46167. }
  46168. }
  46169. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46170. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46171. return new AstBinaryOperation('*', num1, num2, min, max);
  46172. }
  46173. function buildSubOperation(num1, num2) {
  46174. if (num2.type === 'literal') {
  46175. if (num2.number === 0) {
  46176. return num1;
  46177. } else if (num1.type === 'literal') {
  46178. return new AstLiteral(num1.number - num2.number);
  46179. }
  46180. }
  46181. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46182. return num2.arg2;
  46183. }
  46184. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46185. }
  46186. function buildMinOperation(num1, max) {
  46187. if (num1.min >= max) {
  46188. return new AstLiteral(max);
  46189. } else if (num1.max <= max) {
  46190. return num1;
  46191. }
  46192. return new AstMin(num1, max);
  46193. }
  46194. function PostScriptCompiler() {
  46195. }
  46196. PostScriptCompiler.prototype = {
  46197. compile: function PostScriptCompiler_compile(code, domain, range) {
  46198. var stack = [];
  46199. var i, ii;
  46200. var instructions = [];
  46201. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46202. var lastRegister = 0;
  46203. var n, j;
  46204. var num1, num2, ast1, ast2, tmpVar, item;
  46205. for (i = 0; i < inputSize; i++) {
  46206. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46207. }
  46208. for (i = 0, ii = code.length; i < ii; i++) {
  46209. item = code[i];
  46210. if (typeof item === 'number') {
  46211. stack.push(new AstLiteral(item));
  46212. continue;
  46213. }
  46214. switch (item) {
  46215. case 'add':
  46216. if (stack.length < 2) {
  46217. return null;
  46218. }
  46219. num2 = stack.pop();
  46220. num1 = stack.pop();
  46221. stack.push(buildAddOperation(num1, num2));
  46222. break;
  46223. case 'cvr':
  46224. if (stack.length < 1) {
  46225. return null;
  46226. }
  46227. break;
  46228. case 'mul':
  46229. if (stack.length < 2) {
  46230. return null;
  46231. }
  46232. num2 = stack.pop();
  46233. num1 = stack.pop();
  46234. stack.push(buildMulOperation(num1, num2));
  46235. break;
  46236. case 'sub':
  46237. if (stack.length < 2) {
  46238. return null;
  46239. }
  46240. num2 = stack.pop();
  46241. num1 = stack.pop();
  46242. stack.push(buildSubOperation(num1, num2));
  46243. break;
  46244. case 'exch':
  46245. if (stack.length < 2) {
  46246. return null;
  46247. }
  46248. ast1 = stack.pop();
  46249. ast2 = stack.pop();
  46250. stack.push(ast1, ast2);
  46251. break;
  46252. case 'pop':
  46253. if (stack.length < 1) {
  46254. return null;
  46255. }
  46256. stack.pop();
  46257. break;
  46258. case 'index':
  46259. if (stack.length < 1) {
  46260. return null;
  46261. }
  46262. num1 = stack.pop();
  46263. if (num1.type !== 'literal') {
  46264. return null;
  46265. }
  46266. n = num1.number;
  46267. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46268. return null;
  46269. }
  46270. ast1 = stack[stack.length - n - 1];
  46271. if (ast1.type === 'literal' || ast1.type === 'var') {
  46272. stack.push(ast1);
  46273. break;
  46274. }
  46275. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46276. stack[stack.length - n - 1] = tmpVar;
  46277. stack.push(tmpVar);
  46278. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46279. break;
  46280. case 'dup':
  46281. if (stack.length < 1) {
  46282. return null;
  46283. }
  46284. 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]) {
  46285. num1 = stack.pop();
  46286. stack.push(buildMinOperation(num1, code[i + 1]));
  46287. i += 6;
  46288. break;
  46289. }
  46290. ast1 = stack[stack.length - 1];
  46291. if (ast1.type === 'literal' || ast1.type === 'var') {
  46292. stack.push(ast1);
  46293. break;
  46294. }
  46295. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46296. stack[stack.length - 1] = tmpVar;
  46297. stack.push(tmpVar);
  46298. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46299. break;
  46300. case 'roll':
  46301. if (stack.length < 2) {
  46302. return null;
  46303. }
  46304. num2 = stack.pop();
  46305. num1 = stack.pop();
  46306. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46307. return null;
  46308. }
  46309. j = num2.number;
  46310. n = num1.number;
  46311. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46312. return null;
  46313. }
  46314. j = (j % n + n) % n;
  46315. if (j === 0) {
  46316. break;
  46317. }
  46318. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46319. break;
  46320. default:
  46321. return null;
  46322. }
  46323. }
  46324. if (stack.length !== outputSize) {
  46325. return null;
  46326. }
  46327. var result = [];
  46328. instructions.forEach(function (instruction) {
  46329. var statementBuilder = new ExpressionBuilderVisitor();
  46330. instruction.visit(statementBuilder);
  46331. result.push(statementBuilder.toString());
  46332. });
  46333. stack.forEach(function (expr, i) {
  46334. var statementBuilder = new ExpressionBuilderVisitor();
  46335. expr.visit(statementBuilder);
  46336. var min = range[i * 2], max = range[i * 2 + 1];
  46337. var out = [statementBuilder.toString()];
  46338. if (min > expr.min) {
  46339. out.unshift('Math.max(', min, ', ');
  46340. out.push(')');
  46341. }
  46342. if (max < expr.max) {
  46343. out.unshift('Math.min(', max, ', ');
  46344. out.push(')');
  46345. }
  46346. out.unshift('dest[destOffset + ', i, '] = ');
  46347. out.push(';');
  46348. result.push(out.join(''));
  46349. });
  46350. return result.join('\n');
  46351. }
  46352. };
  46353. return PostScriptCompiler;
  46354. }();
  46355. exports.isPDFFunction = isPDFFunction;
  46356. exports.PDFFunction = PDFFunction;
  46357. exports.PostScriptEvaluator = PostScriptEvaluator;
  46358. exports.PostScriptCompiler = PostScriptCompiler;
  46359. }));
  46360. (function (root, factory) {
  46361. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46362. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46363. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46364. var MessageHandler = sharedUtil.MessageHandler;
  46365. var MissingPDFException = sharedUtil.MissingPDFException;
  46366. var PageViewport = sharedUtil.PageViewport;
  46367. var PasswordResponses = sharedUtil.PasswordResponses;
  46368. var PasswordException = sharedUtil.PasswordException;
  46369. var StatTimer = sharedUtil.StatTimer;
  46370. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46371. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46372. var Util = sharedUtil.Util;
  46373. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46374. var error = sharedUtil.error;
  46375. var deprecated = sharedUtil.deprecated;
  46376. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46377. var info = sharedUtil.info;
  46378. var isInt = sharedUtil.isInt;
  46379. var isArray = sharedUtil.isArray;
  46380. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46381. var isSameOrigin = sharedUtil.isSameOrigin;
  46382. var loadJpegStream = sharedUtil.loadJpegStream;
  46383. var stringToBytes = sharedUtil.stringToBytes;
  46384. var globalScope = sharedUtil.globalScope;
  46385. var warn = sharedUtil.warn;
  46386. var FontFaceObject = displayFontLoader.FontFaceObject;
  46387. var FontLoader = displayFontLoader.FontLoader;
  46388. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46389. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46390. var Metadata = displayMetadata.Metadata;
  46391. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46392. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46393. var isWorkerDisabled = false;
  46394. var workerSrc;
  46395. var isPostMessageTransfersDisabled = false;
  46396. var fakeWorkerFilesLoader = null;
  46397. var useRequireEnsure = false;
  46398. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46399. var task = new PDFDocumentLoadingTask();
  46400. if (arguments.length > 1) {
  46401. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46402. }
  46403. if (pdfDataRangeTransport) {
  46404. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46405. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46406. pdfDataRangeTransport.length = src.length;
  46407. pdfDataRangeTransport.initialData = src.initialData;
  46408. if (!pdfDataRangeTransport.abort) {
  46409. pdfDataRangeTransport.abort = function () {
  46410. };
  46411. }
  46412. }
  46413. src = Object.create(src);
  46414. src.range = pdfDataRangeTransport;
  46415. }
  46416. task.onPassword = passwordCallback || null;
  46417. task.onProgress = progressCallback || null;
  46418. var source;
  46419. if (typeof src === 'string') {
  46420. source = { url: src };
  46421. } else if (isArrayBuffer(src)) {
  46422. source = { data: src };
  46423. } else if (src instanceof PDFDataRangeTransport) {
  46424. source = { range: src };
  46425. } else {
  46426. if (typeof src !== 'object') {
  46427. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46428. }
  46429. if (!src.url && !src.data && !src.range) {
  46430. error('Invalid parameter object: need either .data, .range or .url');
  46431. }
  46432. source = src;
  46433. }
  46434. var params = {};
  46435. var rangeTransport = null;
  46436. var worker = null;
  46437. for (var key in source) {
  46438. if (key === 'url' && typeof window !== 'undefined') {
  46439. params[key] = new URL(source[key], window.location).href;
  46440. continue;
  46441. } else if (key === 'range') {
  46442. rangeTransport = source[key];
  46443. continue;
  46444. } else if (key === 'worker') {
  46445. worker = source[key];
  46446. continue;
  46447. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46448. var pdfBytes = source[key];
  46449. if (typeof pdfBytes === 'string') {
  46450. params[key] = stringToBytes(pdfBytes);
  46451. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46452. params[key] = new Uint8Array(pdfBytes);
  46453. } else if (isArrayBuffer(pdfBytes)) {
  46454. params[key] = new Uint8Array(pdfBytes);
  46455. } else {
  46456. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46457. }
  46458. continue;
  46459. }
  46460. params[key] = source[key];
  46461. }
  46462. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46463. if (!worker) {
  46464. worker = new PDFWorker();
  46465. task._worker = worker;
  46466. }
  46467. var docId = task.docId;
  46468. worker.promise.then(function () {
  46469. if (task.destroyed) {
  46470. throw new Error('Loading aborted');
  46471. }
  46472. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46473. if (task.destroyed) {
  46474. throw new Error('Loading aborted');
  46475. }
  46476. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46477. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46478. task._transport = transport;
  46479. messageHandler.send('Ready', null);
  46480. });
  46481. }).catch(task._capability.reject);
  46482. return task;
  46483. }
  46484. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46485. if (worker.destroyed) {
  46486. return Promise.reject(new Error('Worker was destroyed'));
  46487. }
  46488. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46489. source.disableStream = getDefaultSetting('disableStream');
  46490. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46491. if (pdfDataRangeTransport) {
  46492. source.length = pdfDataRangeTransport.length;
  46493. source.initialData = pdfDataRangeTransport.initialData;
  46494. }
  46495. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46496. docId: docId,
  46497. source: source,
  46498. disableRange: getDefaultSetting('disableRange'),
  46499. maxImageSize: getDefaultSetting('maxImageSize'),
  46500. cMapUrl: getDefaultSetting('cMapUrl'),
  46501. cMapPacked: getDefaultSetting('cMapPacked'),
  46502. disableFontFace: getDefaultSetting('disableFontFace'),
  46503. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46504. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46505. docBaseUrl: source.docBaseUrl
  46506. }).then(function (workerId) {
  46507. if (worker.destroyed) {
  46508. throw new Error('Worker was destroyed');
  46509. }
  46510. return workerId;
  46511. });
  46512. }
  46513. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46514. var nextDocumentId = 0;
  46515. function PDFDocumentLoadingTask() {
  46516. this._capability = createPromiseCapability();
  46517. this._transport = null;
  46518. this._worker = null;
  46519. this.docId = 'd' + nextDocumentId++;
  46520. this.destroyed = false;
  46521. this.onPassword = null;
  46522. this.onProgress = null;
  46523. this.onUnsupportedFeature = null;
  46524. }
  46525. PDFDocumentLoadingTask.prototype = {
  46526. get promise() {
  46527. return this._capability.promise;
  46528. },
  46529. destroy: function () {
  46530. this.destroyed = true;
  46531. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46532. return transportDestroyed.then(function () {
  46533. this._transport = null;
  46534. if (this._worker) {
  46535. this._worker.destroy();
  46536. this._worker = null;
  46537. }
  46538. }.bind(this));
  46539. },
  46540. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46541. return this.promise.then.apply(this.promise, arguments);
  46542. }
  46543. };
  46544. return PDFDocumentLoadingTask;
  46545. }();
  46546. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46547. function PDFDataRangeTransport(length, initialData) {
  46548. this.length = length;
  46549. this.initialData = initialData;
  46550. this._rangeListeners = [];
  46551. this._progressListeners = [];
  46552. this._progressiveReadListeners = [];
  46553. this._readyCapability = createPromiseCapability();
  46554. }
  46555. PDFDataRangeTransport.prototype = {
  46556. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46557. this._rangeListeners.push(listener);
  46558. },
  46559. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46560. this._progressListeners.push(listener);
  46561. },
  46562. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46563. this._progressiveReadListeners.push(listener);
  46564. },
  46565. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46566. var listeners = this._rangeListeners;
  46567. for (var i = 0, n = listeners.length; i < n; ++i) {
  46568. listeners[i](begin, chunk);
  46569. }
  46570. },
  46571. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46572. this._readyCapability.promise.then(function () {
  46573. var listeners = this._progressListeners;
  46574. for (var i = 0, n = listeners.length; i < n; ++i) {
  46575. listeners[i](loaded);
  46576. }
  46577. }.bind(this));
  46578. },
  46579. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46580. this._readyCapability.promise.then(function () {
  46581. var listeners = this._progressiveReadListeners;
  46582. for (var i = 0, n = listeners.length; i < n; ++i) {
  46583. listeners[i](chunk);
  46584. }
  46585. }.bind(this));
  46586. },
  46587. transportReady: function PDFDataRangeTransport_transportReady() {
  46588. this._readyCapability.resolve();
  46589. },
  46590. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46591. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46592. },
  46593. abort: function PDFDataRangeTransport_abort() {
  46594. }
  46595. };
  46596. return PDFDataRangeTransport;
  46597. }();
  46598. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46599. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46600. this.pdfInfo = pdfInfo;
  46601. this.transport = transport;
  46602. this.loadingTask = loadingTask;
  46603. }
  46604. PDFDocumentProxy.prototype = {
  46605. get numPages() {
  46606. return this.pdfInfo.numPages;
  46607. },
  46608. get fingerprint() {
  46609. return this.pdfInfo.fingerprint;
  46610. },
  46611. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46612. return this.transport.getPage(pageNumber);
  46613. },
  46614. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46615. return this.transport.getPageIndex(ref);
  46616. },
  46617. getDestinations: function PDFDocumentProxy_getDestinations() {
  46618. return this.transport.getDestinations();
  46619. },
  46620. getDestination: function PDFDocumentProxy_getDestination(id) {
  46621. return this.transport.getDestination(id);
  46622. },
  46623. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46624. return this.transport.getPageLabels();
  46625. },
  46626. getAttachments: function PDFDocumentProxy_getAttachments() {
  46627. return this.transport.getAttachments();
  46628. },
  46629. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46630. return this.transport.getJavaScript();
  46631. },
  46632. getOutline: function PDFDocumentProxy_getOutline() {
  46633. return this.transport.getOutline();
  46634. },
  46635. getMetadata: function PDFDocumentProxy_getMetadata() {
  46636. return this.transport.getMetadata();
  46637. },
  46638. getData: function PDFDocumentProxy_getData() {
  46639. return this.transport.getData();
  46640. },
  46641. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46642. return this.transport.downloadInfoCapability.promise;
  46643. },
  46644. getStats: function PDFDocumentProxy_getStats() {
  46645. return this.transport.getStats();
  46646. },
  46647. cleanup: function PDFDocumentProxy_cleanup() {
  46648. this.transport.startCleanup();
  46649. },
  46650. destroy: function PDFDocumentProxy_destroy() {
  46651. return this.loadingTask.destroy();
  46652. }
  46653. };
  46654. return PDFDocumentProxy;
  46655. }();
  46656. var PDFPageProxy = function PDFPageProxyClosure() {
  46657. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46658. this.pageIndex = pageIndex;
  46659. this.pageInfo = pageInfo;
  46660. this.transport = transport;
  46661. this.stats = new StatTimer();
  46662. this.stats.enabled = getDefaultSetting('enableStats');
  46663. this.commonObjs = transport.commonObjs;
  46664. this.objs = new PDFObjects();
  46665. this.cleanupAfterRender = false;
  46666. this.pendingCleanup = false;
  46667. this.intentStates = Object.create(null);
  46668. this.destroyed = false;
  46669. }
  46670. PDFPageProxy.prototype = {
  46671. get pageNumber() {
  46672. return this.pageIndex + 1;
  46673. },
  46674. get rotate() {
  46675. return this.pageInfo.rotate;
  46676. },
  46677. get ref() {
  46678. return this.pageInfo.ref;
  46679. },
  46680. get userUnit() {
  46681. return this.pageInfo.userUnit;
  46682. },
  46683. get view() {
  46684. return this.pageInfo.view;
  46685. },
  46686. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46687. if (arguments.length < 2) {
  46688. rotate = this.rotate;
  46689. }
  46690. return new PageViewport(this.view, scale, rotate, 0, 0);
  46691. },
  46692. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46693. var intent = params && params.intent || null;
  46694. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46695. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46696. this.annotationsIntent = intent;
  46697. }
  46698. return this.annotationsPromise;
  46699. },
  46700. render: function PDFPageProxy_render(params) {
  46701. var stats = this.stats;
  46702. stats.time('Overall');
  46703. this.pendingCleanup = false;
  46704. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46705. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46706. if (!this.intentStates[renderingIntent]) {
  46707. this.intentStates[renderingIntent] = Object.create(null);
  46708. }
  46709. var intentState = this.intentStates[renderingIntent];
  46710. if (!intentState.displayReadyCapability) {
  46711. intentState.receivingOperatorList = true;
  46712. intentState.displayReadyCapability = createPromiseCapability();
  46713. intentState.operatorList = {
  46714. fnArray: [],
  46715. argsArray: [],
  46716. lastChunk: false
  46717. };
  46718. this.stats.time('Page Request');
  46719. this.transport.messageHandler.send('RenderPageRequest', {
  46720. pageIndex: this.pageNumber - 1,
  46721. intent: renderingIntent,
  46722. renderInteractiveForms: renderInteractiveForms
  46723. });
  46724. }
  46725. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46726. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46727. if (!intentState.renderTasks) {
  46728. intentState.renderTasks = [];
  46729. }
  46730. intentState.renderTasks.push(internalRenderTask);
  46731. var renderTask = internalRenderTask.task;
  46732. if (params.continueCallback) {
  46733. deprecated('render is used with continueCallback parameter');
  46734. renderTask.onContinue = params.continueCallback;
  46735. }
  46736. var self = this;
  46737. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46738. if (self.pendingCleanup) {
  46739. complete();
  46740. return;
  46741. }
  46742. stats.time('Rendering');
  46743. internalRenderTask.initializeGraphics(transparency);
  46744. internalRenderTask.operatorListChanged();
  46745. }, function pageDisplayReadPromiseError(reason) {
  46746. complete(reason);
  46747. });
  46748. function complete(error) {
  46749. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46750. if (i >= 0) {
  46751. intentState.renderTasks.splice(i, 1);
  46752. }
  46753. if (self.cleanupAfterRender) {
  46754. self.pendingCleanup = true;
  46755. }
  46756. self._tryCleanup();
  46757. if (error) {
  46758. internalRenderTask.capability.reject(error);
  46759. } else {
  46760. internalRenderTask.capability.resolve();
  46761. }
  46762. stats.timeEnd('Rendering');
  46763. stats.timeEnd('Overall');
  46764. }
  46765. return renderTask;
  46766. },
  46767. getOperatorList: function PDFPageProxy_getOperatorList() {
  46768. function operatorListChanged() {
  46769. if (intentState.operatorList.lastChunk) {
  46770. intentState.opListReadCapability.resolve(intentState.operatorList);
  46771. var i = intentState.renderTasks.indexOf(opListTask);
  46772. if (i >= 0) {
  46773. intentState.renderTasks.splice(i, 1);
  46774. }
  46775. }
  46776. }
  46777. var renderingIntent = 'oplist';
  46778. if (!this.intentStates[renderingIntent]) {
  46779. this.intentStates[renderingIntent] = Object.create(null);
  46780. }
  46781. var intentState = this.intentStates[renderingIntent];
  46782. var opListTask;
  46783. if (!intentState.opListReadCapability) {
  46784. opListTask = {};
  46785. opListTask.operatorListChanged = operatorListChanged;
  46786. intentState.receivingOperatorList = true;
  46787. intentState.opListReadCapability = createPromiseCapability();
  46788. intentState.renderTasks = [];
  46789. intentState.renderTasks.push(opListTask);
  46790. intentState.operatorList = {
  46791. fnArray: [],
  46792. argsArray: [],
  46793. lastChunk: false
  46794. };
  46795. this.transport.messageHandler.send('RenderPageRequest', {
  46796. pageIndex: this.pageIndex,
  46797. intent: renderingIntent
  46798. });
  46799. }
  46800. return intentState.opListReadCapability.promise;
  46801. },
  46802. getTextContent: function PDFPageProxy_getTextContent(params) {
  46803. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46804. pageIndex: this.pageNumber - 1,
  46805. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46806. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46807. });
  46808. },
  46809. _destroy: function PDFPageProxy_destroy() {
  46810. this.destroyed = true;
  46811. this.transport.pageCache[this.pageIndex] = null;
  46812. var waitOn = [];
  46813. Object.keys(this.intentStates).forEach(function (intent) {
  46814. if (intent === 'oplist') {
  46815. return;
  46816. }
  46817. var intentState = this.intentStates[intent];
  46818. intentState.renderTasks.forEach(function (renderTask) {
  46819. var renderCompleted = renderTask.capability.promise.catch(function () {
  46820. });
  46821. waitOn.push(renderCompleted);
  46822. renderTask.cancel();
  46823. });
  46824. }, this);
  46825. this.objs.clear();
  46826. this.annotationsPromise = null;
  46827. this.pendingCleanup = false;
  46828. return Promise.all(waitOn);
  46829. },
  46830. destroy: function () {
  46831. deprecated('page destroy method, use cleanup() instead');
  46832. this.cleanup();
  46833. },
  46834. cleanup: function PDFPageProxy_cleanup() {
  46835. this.pendingCleanup = true;
  46836. this._tryCleanup();
  46837. },
  46838. _tryCleanup: function PDFPageProxy_tryCleanup() {
  46839. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  46840. var intentState = this.intentStates[intent];
  46841. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  46842. }, this)) {
  46843. return;
  46844. }
  46845. Object.keys(this.intentStates).forEach(function (intent) {
  46846. delete this.intentStates[intent];
  46847. }, this);
  46848. this.objs.clear();
  46849. this.annotationsPromise = null;
  46850. this.pendingCleanup = false;
  46851. },
  46852. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  46853. var intentState = this.intentStates[intent];
  46854. if (intentState.displayReadyCapability) {
  46855. intentState.displayReadyCapability.resolve(transparency);
  46856. }
  46857. },
  46858. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  46859. var intentState = this.intentStates[intent];
  46860. var i, ii;
  46861. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  46862. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  46863. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  46864. }
  46865. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  46866. for (i = 0; i < intentState.renderTasks.length; i++) {
  46867. intentState.renderTasks[i].operatorListChanged();
  46868. }
  46869. if (operatorListChunk.lastChunk) {
  46870. intentState.receivingOperatorList = false;
  46871. this._tryCleanup();
  46872. }
  46873. }
  46874. };
  46875. return PDFPageProxy;
  46876. }();
  46877. var PDFWorker = function PDFWorkerClosure() {
  46878. var nextFakeWorkerId = 0;
  46879. function getWorkerSrc() {
  46880. if (typeof workerSrc !== 'undefined') {
  46881. return workerSrc;
  46882. }
  46883. if (getDefaultSetting('workerSrc')) {
  46884. return getDefaultSetting('workerSrc');
  46885. }
  46886. if (pdfjsFilePath) {
  46887. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  46888. }
  46889. error('No PDFJS.workerSrc specified');
  46890. }
  46891. var fakeWorkerFilesLoadedCapability;
  46892. function setupFakeWorkerGlobal() {
  46893. var WorkerMessageHandler;
  46894. if (fakeWorkerFilesLoadedCapability) {
  46895. return fakeWorkerFilesLoadedCapability.promise;
  46896. }
  46897. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  46898. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  46899. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  46900. return fakeWorkerFilesLoadedCapability.promise;
  46901. }
  46902. function FakeWorkerPort(defer) {
  46903. this._listeners = [];
  46904. this._defer = defer;
  46905. this._deferred = Promise.resolve(undefined);
  46906. }
  46907. FakeWorkerPort.prototype = {
  46908. postMessage: function (obj, transfers) {
  46909. function cloneValue(value) {
  46910. if (typeof value !== 'object' || value === null) {
  46911. return value;
  46912. }
  46913. if (cloned.has(value)) {
  46914. return cloned.get(value);
  46915. }
  46916. var result;
  46917. var buffer;
  46918. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  46919. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  46920. if (value === buffer) {
  46921. result = value;
  46922. } else if (transferable) {
  46923. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  46924. } else {
  46925. result = new value.constructor(value);
  46926. }
  46927. cloned.set(value, result);
  46928. return result;
  46929. }
  46930. result = isArray(value) ? [] : {};
  46931. cloned.set(value, result);
  46932. for (var i in value) {
  46933. var desc, p = value;
  46934. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  46935. p = Object.getPrototypeOf(p);
  46936. }
  46937. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  46938. continue;
  46939. }
  46940. result[i] = cloneValue(desc.value);
  46941. }
  46942. return result;
  46943. }
  46944. if (!this._defer) {
  46945. this._listeners.forEach(function (listener) {
  46946. listener.call(this, { data: obj });
  46947. }, this);
  46948. return;
  46949. }
  46950. var cloned = new WeakMap();
  46951. var e = { data: cloneValue(obj) };
  46952. this._deferred.then(function () {
  46953. this._listeners.forEach(function (listener) {
  46954. listener.call(this, e);
  46955. }, this);
  46956. }.bind(this));
  46957. },
  46958. addEventListener: function (name, listener) {
  46959. this._listeners.push(listener);
  46960. },
  46961. removeEventListener: function (name, listener) {
  46962. var i = this._listeners.indexOf(listener);
  46963. this._listeners.splice(i, 1);
  46964. },
  46965. terminate: function () {
  46966. this._listeners = [];
  46967. }
  46968. };
  46969. function createCDNWrapper(url) {
  46970. var wrapper = 'importScripts(\'' + url + '\');';
  46971. return URL.createObjectURL(new Blob([wrapper]));
  46972. }
  46973. function PDFWorker(name) {
  46974. this.name = name;
  46975. this.destroyed = false;
  46976. this._readyCapability = createPromiseCapability();
  46977. this._port = null;
  46978. this._webWorker = null;
  46979. this._messageHandler = null;
  46980. this._initialize();
  46981. }
  46982. PDFWorker.prototype = {
  46983. get promise() {
  46984. return this._readyCapability.promise;
  46985. },
  46986. get port() {
  46987. return this._port;
  46988. },
  46989. get messageHandler() {
  46990. return this._messageHandler;
  46991. },
  46992. _initialize: function PDFWorker_initialize() {
  46993. this._setupFakeWorker();
  46994. },
  46995. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  46996. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  46997. warn('Setting up fake worker.');
  46998. isWorkerDisabled = true;
  46999. }
  47000. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  47001. if (this.destroyed) {
  47002. this._readyCapability.reject(new Error('Worker was destroyed'));
  47003. return;
  47004. }
  47005. var isTypedArraysPresent = Uint8Array !== Float32Array;
  47006. var port = new FakeWorkerPort(isTypedArraysPresent);
  47007. this._port = port;
  47008. var id = 'fake' + nextFakeWorkerId++;
  47009. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47010. WorkerMessageHandler.setup(workerHandler, port);
  47011. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47012. this._messageHandler = messageHandler;
  47013. this._readyCapability.resolve();
  47014. }.bind(this));
  47015. },
  47016. destroy: function PDFWorker_destroy() {
  47017. this.destroyed = true;
  47018. if (this._webWorker) {
  47019. this._webWorker.terminate();
  47020. this._webWorker = null;
  47021. }
  47022. this._port = null;
  47023. if (this._messageHandler) {
  47024. this._messageHandler.destroy();
  47025. this._messageHandler = null;
  47026. }
  47027. }
  47028. };
  47029. return PDFWorker;
  47030. }();
  47031. var WorkerTransport = function WorkerTransportClosure() {
  47032. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47033. this.messageHandler = messageHandler;
  47034. this.loadingTask = loadingTask;
  47035. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47036. this.commonObjs = new PDFObjects();
  47037. this.fontLoader = new FontLoader(loadingTask.docId);
  47038. this.destroyed = false;
  47039. this.destroyCapability = null;
  47040. this.pageCache = [];
  47041. this.pagePromises = [];
  47042. this.downloadInfoCapability = createPromiseCapability();
  47043. this.setupMessageHandler();
  47044. }
  47045. WorkerTransport.prototype = {
  47046. destroy: function WorkerTransport_destroy() {
  47047. if (this.destroyCapability) {
  47048. return this.destroyCapability.promise;
  47049. }
  47050. this.destroyed = true;
  47051. this.destroyCapability = createPromiseCapability();
  47052. var waitOn = [];
  47053. this.pageCache.forEach(function (page) {
  47054. if (page) {
  47055. waitOn.push(page._destroy());
  47056. }
  47057. });
  47058. this.pageCache = [];
  47059. this.pagePromises = [];
  47060. var self = this;
  47061. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  47062. waitOn.push(terminated);
  47063. Promise.all(waitOn).then(function () {
  47064. self.fontLoader.clear();
  47065. if (self.pdfDataRangeTransport) {
  47066. self.pdfDataRangeTransport.abort();
  47067. self.pdfDataRangeTransport = null;
  47068. }
  47069. if (self.messageHandler) {
  47070. self.messageHandler.destroy();
  47071. self.messageHandler = null;
  47072. }
  47073. self.destroyCapability.resolve();
  47074. }, this.destroyCapability.reject);
  47075. return this.destroyCapability.promise;
  47076. },
  47077. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  47078. var messageHandler = this.messageHandler;
  47079. function updatePassword(password) {
  47080. messageHandler.send('UpdatePassword', password);
  47081. }
  47082. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47083. if (pdfDataRangeTransport) {
  47084. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47085. messageHandler.send('OnDataRange', {
  47086. begin: begin,
  47087. chunk: chunk
  47088. });
  47089. });
  47090. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47091. messageHandler.send('OnDataProgress', { loaded: loaded });
  47092. });
  47093. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47094. messageHandler.send('OnDataRange', { chunk: chunk });
  47095. });
  47096. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47097. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47098. }, this);
  47099. }
  47100. messageHandler.on('GetDoc', function transportDoc(data) {
  47101. var pdfInfo = data.pdfInfo;
  47102. this.numPages = data.pdfInfo.numPages;
  47103. var loadingTask = this.loadingTask;
  47104. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47105. this.pdfDocument = pdfDocument;
  47106. loadingTask._capability.resolve(pdfDocument);
  47107. }, this);
  47108. messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
  47109. var loadingTask = this.loadingTask;
  47110. if (loadingTask.onPassword) {
  47111. return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
  47112. }
  47113. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47114. }, this);
  47115. messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
  47116. var loadingTask = this.loadingTask;
  47117. if (loadingTask.onPassword) {
  47118. return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
  47119. }
  47120. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47121. }, this);
  47122. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47123. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47124. }, this);
  47125. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47126. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47127. }, this);
  47128. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47129. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47130. }, this);
  47131. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47132. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47133. }, this);
  47134. messageHandler.on('DataLoaded', function transportPage(data) {
  47135. this.downloadInfoCapability.resolve(data);
  47136. }, this);
  47137. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47138. if (this.pdfDataRangeTransport) {
  47139. this.pdfDataRangeTransport.transportReady();
  47140. }
  47141. }, this);
  47142. messageHandler.on('StartRenderPage', function transportRender(data) {
  47143. if (this.destroyed) {
  47144. return;
  47145. }
  47146. var page = this.pageCache[data.pageIndex];
  47147. page.stats.timeEnd('Page Request');
  47148. page._startRenderPage(data.transparency, data.intent);
  47149. }, this);
  47150. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47151. if (this.destroyed) {
  47152. return;
  47153. }
  47154. var page = this.pageCache[data.pageIndex];
  47155. page._renderPageChunk(data.operatorList, data.intent);
  47156. }, this);
  47157. messageHandler.on('commonobj', function transportObj(data) {
  47158. if (this.destroyed) {
  47159. return;
  47160. }
  47161. var id = data[0];
  47162. var type = data[1];
  47163. if (this.commonObjs.hasData(id)) {
  47164. return;
  47165. }
  47166. switch (type) {
  47167. case 'Font':
  47168. var exportedData = data[2];
  47169. if ('error' in exportedData) {
  47170. var exportedError = exportedData.error;
  47171. warn('Error during font loading: ' + exportedError);
  47172. this.commonObjs.resolve(id, exportedError);
  47173. break;
  47174. }
  47175. var fontRegistry = null;
  47176. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47177. fontRegistry = {
  47178. registerFont: function (font, url) {
  47179. globalScope['FontInspector'].fontAdded(font, url);
  47180. }
  47181. };
  47182. }
  47183. var font = new FontFaceObject(exportedData, {
  47184. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47185. disableFontFace: getDefaultSetting('disableFontFace'),
  47186. fontRegistry: fontRegistry
  47187. });
  47188. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47189. this.commonObjs.resolve(id, font);
  47190. }.bind(this));
  47191. break;
  47192. case 'FontPath':
  47193. this.commonObjs.resolve(id, data[2]);
  47194. break;
  47195. default:
  47196. error('Got unknown common object type ' + type);
  47197. }
  47198. }, this);
  47199. messageHandler.on('obj', function transportObj(data) {
  47200. if (this.destroyed) {
  47201. return;
  47202. }
  47203. var id = data[0];
  47204. var pageIndex = data[1];
  47205. var type = data[2];
  47206. var pageProxy = this.pageCache[pageIndex];
  47207. var imageData;
  47208. if (pageProxy.objs.hasData(id)) {
  47209. return;
  47210. }
  47211. switch (type) {
  47212. case 'JpegStream':
  47213. imageData = data[3];
  47214. loadJpegStream(id, imageData, pageProxy.objs);
  47215. break;
  47216. case 'Image':
  47217. imageData = data[3];
  47218. pageProxy.objs.resolve(id, imageData);
  47219. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47220. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47221. pageProxy.cleanupAfterRender = true;
  47222. }
  47223. break;
  47224. default:
  47225. error('Got unknown object type ' + type);
  47226. }
  47227. }, this);
  47228. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47229. if (this.destroyed) {
  47230. return;
  47231. }
  47232. var loadingTask = this.loadingTask;
  47233. if (loadingTask.onProgress) {
  47234. loadingTask.onProgress({
  47235. loaded: data.loaded,
  47236. total: data.total
  47237. });
  47238. }
  47239. }, this);
  47240. messageHandler.on('PageError', function transportError(data) {
  47241. if (this.destroyed) {
  47242. return;
  47243. }
  47244. var page = this.pageCache[data.pageNum - 1];
  47245. var intentState = page.intentStates[data.intent];
  47246. if (intentState.displayReadyCapability) {
  47247. intentState.displayReadyCapability.reject(data.error);
  47248. } else {
  47249. error(data.error);
  47250. }
  47251. if (intentState.operatorList) {
  47252. intentState.operatorList.lastChunk = true;
  47253. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47254. intentState.renderTasks[i].operatorListChanged();
  47255. }
  47256. }
  47257. }, this);
  47258. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47259. if (this.destroyed) {
  47260. return;
  47261. }
  47262. var featureId = data.featureId;
  47263. var loadingTask = this.loadingTask;
  47264. if (loadingTask.onUnsupportedFeature) {
  47265. loadingTask.onUnsupportedFeature(featureId);
  47266. }
  47267. _UnsupportedManager.notify(featureId);
  47268. }, this);
  47269. messageHandler.on('JpegDecode', function (data) {
  47270. if (this.destroyed) {
  47271. return Promise.reject(new Error('Worker was destroyed'));
  47272. }
  47273. var imageUrl = data[0];
  47274. var components = data[1];
  47275. if (components !== 3 && components !== 1) {
  47276. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47277. }
  47278. return new Promise(function (resolve, reject) {
  47279. var img = new Image();
  47280. img.onload = function () {
  47281. var width = img.width;
  47282. var height = img.height;
  47283. var size = width * height;
  47284. var rgbaLength = size * 4;
  47285. var buf = new Uint8Array(size * components);
  47286. var tmpCanvas = createScratchCanvas(width, height);
  47287. var tmpCtx = tmpCanvas.getContext('2d');
  47288. tmpCtx.drawImage(img, 0, 0);
  47289. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47290. var i, j;
  47291. if (components === 3) {
  47292. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47293. buf[j] = data[i];
  47294. buf[j + 1] = data[i + 1];
  47295. buf[j + 2] = data[i + 2];
  47296. }
  47297. } else if (components === 1) {
  47298. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47299. buf[j] = data[i];
  47300. }
  47301. }
  47302. resolve({
  47303. data: buf,
  47304. width: width,
  47305. height: height
  47306. });
  47307. };
  47308. img.onerror = function () {
  47309. reject(new Error('JpegDecode failed to load image'));
  47310. };
  47311. img.src = imageUrl;
  47312. });
  47313. }, this);
  47314. },
  47315. getData: function WorkerTransport_getData() {
  47316. return this.messageHandler.sendWithPromise('GetData', null);
  47317. },
  47318. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47319. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47320. return Promise.reject(new Error('Invalid page request'));
  47321. }
  47322. var pageIndex = pageNumber - 1;
  47323. if (pageIndex in this.pagePromises) {
  47324. return this.pagePromises[pageIndex];
  47325. }
  47326. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47327. if (this.destroyed) {
  47328. throw new Error('Transport destroyed');
  47329. }
  47330. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47331. this.pageCache[pageIndex] = page;
  47332. return page;
  47333. }.bind(this));
  47334. this.pagePromises[pageIndex] = promise;
  47335. return promise;
  47336. },
  47337. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47338. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47339. return Promise.reject(new Error(reason));
  47340. });
  47341. },
  47342. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47343. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47344. pageIndex: pageIndex,
  47345. intent: intent
  47346. });
  47347. },
  47348. getDestinations: function WorkerTransport_getDestinations() {
  47349. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47350. },
  47351. getDestination: function WorkerTransport_getDestination(id) {
  47352. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47353. },
  47354. getPageLabels: function WorkerTransport_getPageLabels() {
  47355. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47356. },
  47357. getAttachments: function WorkerTransport_getAttachments() {
  47358. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47359. },
  47360. getJavaScript: function WorkerTransport_getJavaScript() {
  47361. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47362. },
  47363. getOutline: function WorkerTransport_getOutline() {
  47364. return this.messageHandler.sendWithPromise('GetOutline', null);
  47365. },
  47366. getMetadata: function WorkerTransport_getMetadata() {
  47367. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47368. return {
  47369. info: results[0],
  47370. metadata: results[1] ? new Metadata(results[1]) : null
  47371. };
  47372. });
  47373. },
  47374. getStats: function WorkerTransport_getStats() {
  47375. return this.messageHandler.sendWithPromise('GetStats', null);
  47376. },
  47377. startCleanup: function WorkerTransport_startCleanup() {
  47378. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47379. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47380. var page = this.pageCache[i];
  47381. if (page) {
  47382. page.cleanup();
  47383. }
  47384. }
  47385. this.commonObjs.clear();
  47386. this.fontLoader.clear();
  47387. }.bind(this));
  47388. }
  47389. };
  47390. return WorkerTransport;
  47391. }();
  47392. var PDFObjects = function PDFObjectsClosure() {
  47393. function PDFObjects() {
  47394. this.objs = Object.create(null);
  47395. }
  47396. PDFObjects.prototype = {
  47397. ensureObj: function PDFObjects_ensureObj(objId) {
  47398. if (this.objs[objId]) {
  47399. return this.objs[objId];
  47400. }
  47401. var obj = {
  47402. capability: createPromiseCapability(),
  47403. data: null,
  47404. resolved: false
  47405. };
  47406. this.objs[objId] = obj;
  47407. return obj;
  47408. },
  47409. get: function PDFObjects_get(objId, callback) {
  47410. if (callback) {
  47411. this.ensureObj(objId).capability.promise.then(callback);
  47412. return null;
  47413. }
  47414. var obj = this.objs[objId];
  47415. if (!obj || !obj.resolved) {
  47416. error('Requesting object that isn\'t resolved yet ' + objId);
  47417. }
  47418. return obj.data;
  47419. },
  47420. resolve: function PDFObjects_resolve(objId, data) {
  47421. var obj = this.ensureObj(objId);
  47422. obj.resolved = true;
  47423. obj.data = data;
  47424. obj.capability.resolve(data);
  47425. },
  47426. isResolved: function PDFObjects_isResolved(objId) {
  47427. var objs = this.objs;
  47428. if (!objs[objId]) {
  47429. return false;
  47430. } else {
  47431. return objs[objId].resolved;
  47432. }
  47433. },
  47434. hasData: function PDFObjects_hasData(objId) {
  47435. return this.isResolved(objId);
  47436. },
  47437. getData: function PDFObjects_getData(objId) {
  47438. var objs = this.objs;
  47439. if (!objs[objId] || !objs[objId].resolved) {
  47440. return null;
  47441. } else {
  47442. return objs[objId].data;
  47443. }
  47444. },
  47445. clear: function PDFObjects_clear() {
  47446. this.objs = Object.create(null);
  47447. }
  47448. };
  47449. return PDFObjects;
  47450. }();
  47451. var RenderTask = function RenderTaskClosure() {
  47452. function RenderTask(internalRenderTask) {
  47453. this._internalRenderTask = internalRenderTask;
  47454. this.onContinue = null;
  47455. }
  47456. RenderTask.prototype = {
  47457. get promise() {
  47458. return this._internalRenderTask.capability.promise;
  47459. },
  47460. cancel: function RenderTask_cancel() {
  47461. this._internalRenderTask.cancel();
  47462. },
  47463. then: function RenderTask_then(onFulfilled, onRejected) {
  47464. return this.promise.then.apply(this.promise, arguments);
  47465. }
  47466. };
  47467. return RenderTask;
  47468. }();
  47469. var InternalRenderTask = function InternalRenderTaskClosure() {
  47470. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47471. this.callback = callback;
  47472. this.params = params;
  47473. this.objs = objs;
  47474. this.commonObjs = commonObjs;
  47475. this.operatorListIdx = null;
  47476. this.operatorList = operatorList;
  47477. this.pageNumber = pageNumber;
  47478. this.running = false;
  47479. this.graphicsReadyCallback = null;
  47480. this.graphicsReady = false;
  47481. this.useRequestAnimationFrame = false;
  47482. this.cancelled = false;
  47483. this.capability = createPromiseCapability();
  47484. this.task = new RenderTask(this);
  47485. this._continueBound = this._continue.bind(this);
  47486. this._scheduleNextBound = this._scheduleNext.bind(this);
  47487. this._nextBound = this._next.bind(this);
  47488. }
  47489. InternalRenderTask.prototype = {
  47490. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47491. if (this.cancelled) {
  47492. return;
  47493. }
  47494. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47495. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47496. this.stepper.init(this.operatorList);
  47497. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47498. }
  47499. var params = this.params;
  47500. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47501. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47502. this.operatorListIdx = 0;
  47503. this.graphicsReady = true;
  47504. if (this.graphicsReadyCallback) {
  47505. this.graphicsReadyCallback();
  47506. }
  47507. },
  47508. cancel: function InternalRenderTask_cancel() {
  47509. this.running = false;
  47510. this.cancelled = true;
  47511. this.callback('cancelled');
  47512. },
  47513. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47514. if (!this.graphicsReady) {
  47515. if (!this.graphicsReadyCallback) {
  47516. this.graphicsReadyCallback = this._continueBound;
  47517. }
  47518. return;
  47519. }
  47520. if (this.stepper) {
  47521. this.stepper.updateOperatorList(this.operatorList);
  47522. }
  47523. if (this.running) {
  47524. return;
  47525. }
  47526. this._continue();
  47527. },
  47528. _continue: function InternalRenderTask__continue() {
  47529. this.running = true;
  47530. if (this.cancelled) {
  47531. return;
  47532. }
  47533. if (this.task.onContinue) {
  47534. this.task.onContinue.call(this.task, this._scheduleNextBound);
  47535. } else {
  47536. this._scheduleNext();
  47537. }
  47538. },
  47539. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47540. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47541. window.requestAnimationFrame(this._nextBound);
  47542. } else {
  47543. Promise.resolve(undefined).then(this._nextBound);
  47544. }
  47545. },
  47546. _next: function InternalRenderTask__next() {
  47547. if (this.cancelled) {
  47548. return;
  47549. }
  47550. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47551. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47552. this.running = false;
  47553. if (this.operatorList.lastChunk) {
  47554. this.gfx.endDrawing();
  47555. this.callback();
  47556. }
  47557. }
  47558. }
  47559. };
  47560. return InternalRenderTask;
  47561. }();
  47562. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47563. var listeners = [];
  47564. return {
  47565. listen: function (cb) {
  47566. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47567. listeners.push(cb);
  47568. },
  47569. notify: function (featureId) {
  47570. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47571. listeners[i](featureId);
  47572. }
  47573. }
  47574. };
  47575. }();
  47576. if (typeof pdfjsVersion !== 'undefined') {
  47577. exports.version = pdfjsVersion;
  47578. }
  47579. if (typeof pdfjsBuild !== 'undefined') {
  47580. exports.build = pdfjsBuild;
  47581. }
  47582. exports.getDocument = getDocument;
  47583. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47584. exports.PDFWorker = PDFWorker;
  47585. exports.PDFDocumentProxy = PDFDocumentProxy;
  47586. exports.PDFPageProxy = PDFPageProxy;
  47587. exports._UnsupportedManager = _UnsupportedManager;
  47588. }));
  47589. (function (root, factory) {
  47590. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47591. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47592. var error = sharedUtil.error;
  47593. var info = sharedUtil.info;
  47594. var isArray = sharedUtil.isArray;
  47595. var isString = sharedUtil.isString;
  47596. var shadow = sharedUtil.shadow;
  47597. var warn = sharedUtil.warn;
  47598. var isDict = corePrimitives.isDict;
  47599. var isName = corePrimitives.isName;
  47600. var isStream = corePrimitives.isStream;
  47601. var PDFFunction = coreFunction.PDFFunction;
  47602. var ColorSpace = function ColorSpaceClosure() {
  47603. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47604. var COMPONENTS = 3;
  47605. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47606. var xRatio = w1 / w2;
  47607. var yRatio = h1 / h2;
  47608. var i, j, py, newIndex = 0, oldIndex;
  47609. var xScaled = new Uint16Array(w2);
  47610. var w1Scanline = w1 * COMPONENTS;
  47611. for (i = 0; i < w2; i++) {
  47612. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47613. }
  47614. for (i = 0; i < h2; i++) {
  47615. py = Math.floor(i * yRatio) * w1Scanline;
  47616. for (j = 0; j < w2; j++) {
  47617. oldIndex = py + xScaled[j];
  47618. dest[newIndex++] = src[oldIndex++];
  47619. dest[newIndex++] = src[oldIndex++];
  47620. dest[newIndex++] = src[oldIndex++];
  47621. newIndex += alpha01;
  47622. }
  47623. }
  47624. }
  47625. function ColorSpace() {
  47626. error('should not call ColorSpace constructor');
  47627. }
  47628. ColorSpace.prototype = {
  47629. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47630. var rgb = new Uint8Array(3);
  47631. this.getRgbItem(src, srcOffset, rgb, 0);
  47632. return rgb;
  47633. },
  47634. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47635. error('Should not call ColorSpace.getRgbItem');
  47636. },
  47637. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47638. error('Should not call ColorSpace.getRgbBuffer');
  47639. },
  47640. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47641. error('Should not call ColorSpace.getOutputLength');
  47642. },
  47643. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47644. return false;
  47645. },
  47646. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47647. var count = originalWidth * originalHeight;
  47648. var rgbBuf = null;
  47649. var numComponentColors = 1 << bpc;
  47650. var needsResizing = originalHeight !== height || originalWidth !== width;
  47651. var i, ii;
  47652. if (this.isPassthrough(bpc)) {
  47653. rgbBuf = comps;
  47654. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47655. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47656. var key;
  47657. for (i = 0; i < numComponentColors; i++) {
  47658. allColors[i] = i;
  47659. }
  47660. var colorMap = new Uint8Array(numComponentColors * 3);
  47661. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47662. var destPos, rgbPos;
  47663. if (!needsResizing) {
  47664. destPos = 0;
  47665. for (i = 0; i < count; ++i) {
  47666. key = comps[i] * 3;
  47667. dest[destPos++] = colorMap[key];
  47668. dest[destPos++] = colorMap[key + 1];
  47669. dest[destPos++] = colorMap[key + 2];
  47670. destPos += alpha01;
  47671. }
  47672. } else {
  47673. rgbBuf = new Uint8Array(count * 3);
  47674. rgbPos = 0;
  47675. for (i = 0; i < count; ++i) {
  47676. key = comps[i] * 3;
  47677. rgbBuf[rgbPos++] = colorMap[key];
  47678. rgbBuf[rgbPos++] = colorMap[key + 1];
  47679. rgbBuf[rgbPos++] = colorMap[key + 2];
  47680. }
  47681. }
  47682. } else {
  47683. if (!needsResizing) {
  47684. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47685. } else {
  47686. rgbBuf = new Uint8Array(count * 3);
  47687. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47688. }
  47689. }
  47690. if (rgbBuf) {
  47691. if (needsResizing) {
  47692. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47693. } else {
  47694. rgbPos = 0;
  47695. destPos = 0;
  47696. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47697. dest[destPos++] = rgbBuf[rgbPos++];
  47698. dest[destPos++] = rgbBuf[rgbPos++];
  47699. dest[destPos++] = rgbBuf[rgbPos++];
  47700. destPos += alpha01;
  47701. }
  47702. }
  47703. }
  47704. },
  47705. usesZeroToOneRange: true
  47706. };
  47707. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47708. var IR = ColorSpace.parseToIR(cs, xref, res);
  47709. if (IR instanceof AlternateCS) {
  47710. return IR;
  47711. }
  47712. return ColorSpace.fromIR(IR);
  47713. };
  47714. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47715. var name = isArray(IR) ? IR[0] : IR;
  47716. var whitePoint, blackPoint, gamma;
  47717. switch (name) {
  47718. case 'DeviceGrayCS':
  47719. return this.singletons.gray;
  47720. case 'DeviceRgbCS':
  47721. return this.singletons.rgb;
  47722. case 'DeviceCmykCS':
  47723. return this.singletons.cmyk;
  47724. case 'CalGrayCS':
  47725. whitePoint = IR[1];
  47726. blackPoint = IR[2];
  47727. gamma = IR[3];
  47728. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47729. case 'CalRGBCS':
  47730. whitePoint = IR[1];
  47731. blackPoint = IR[2];
  47732. gamma = IR[3];
  47733. var matrix = IR[4];
  47734. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47735. case 'PatternCS':
  47736. var basePatternCS = IR[1];
  47737. if (basePatternCS) {
  47738. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47739. }
  47740. return new PatternCS(basePatternCS);
  47741. case 'IndexedCS':
  47742. var baseIndexedCS = IR[1];
  47743. var hiVal = IR[2];
  47744. var lookup = IR[3];
  47745. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47746. case 'AlternateCS':
  47747. var numComps = IR[1];
  47748. var alt = IR[2];
  47749. var tintFnIR = IR[3];
  47750. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47751. case 'LabCS':
  47752. whitePoint = IR[1];
  47753. blackPoint = IR[2];
  47754. var range = IR[3];
  47755. return new LabCS(whitePoint, blackPoint, range);
  47756. default:
  47757. error('Unknown name ' + name);
  47758. }
  47759. return null;
  47760. };
  47761. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47762. if (isName(cs)) {
  47763. var colorSpaces = res.get('ColorSpace');
  47764. if (isDict(colorSpaces)) {
  47765. var refcs = colorSpaces.get(cs.name);
  47766. if (refcs) {
  47767. cs = refcs;
  47768. }
  47769. }
  47770. }
  47771. cs = xref.fetchIfRef(cs);
  47772. var mode;
  47773. if (isName(cs)) {
  47774. mode = cs.name;
  47775. this.mode = mode;
  47776. switch (mode) {
  47777. case 'DeviceGray':
  47778. case 'G':
  47779. return 'DeviceGrayCS';
  47780. case 'DeviceRGB':
  47781. case 'RGB':
  47782. return 'DeviceRgbCS';
  47783. case 'DeviceCMYK':
  47784. case 'CMYK':
  47785. return 'DeviceCmykCS';
  47786. case 'Pattern':
  47787. return [
  47788. 'PatternCS',
  47789. null
  47790. ];
  47791. default:
  47792. error('unrecognized colorspace ' + mode);
  47793. }
  47794. } else if (isArray(cs)) {
  47795. mode = xref.fetchIfRef(cs[0]).name;
  47796. this.mode = mode;
  47797. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47798. switch (mode) {
  47799. case 'DeviceGray':
  47800. case 'G':
  47801. return 'DeviceGrayCS';
  47802. case 'DeviceRGB':
  47803. case 'RGB':
  47804. return 'DeviceRgbCS';
  47805. case 'DeviceCMYK':
  47806. case 'CMYK':
  47807. return 'DeviceCmykCS';
  47808. case 'CalGray':
  47809. params = xref.fetchIfRef(cs[1]);
  47810. whitePoint = params.getArray('WhitePoint');
  47811. blackPoint = params.getArray('BlackPoint');
  47812. gamma = params.get('Gamma');
  47813. return [
  47814. 'CalGrayCS',
  47815. whitePoint,
  47816. blackPoint,
  47817. gamma
  47818. ];
  47819. case 'CalRGB':
  47820. params = xref.fetchIfRef(cs[1]);
  47821. whitePoint = params.getArray('WhitePoint');
  47822. blackPoint = params.getArray('BlackPoint');
  47823. gamma = params.getArray('Gamma');
  47824. var matrix = params.getArray('Matrix');
  47825. return [
  47826. 'CalRGBCS',
  47827. whitePoint,
  47828. blackPoint,
  47829. gamma,
  47830. matrix
  47831. ];
  47832. case 'ICCBased':
  47833. var stream = xref.fetchIfRef(cs[1]);
  47834. var dict = stream.dict;
  47835. numComps = dict.get('N');
  47836. alt = dict.get('Alternate');
  47837. if (alt) {
  47838. var altIR = ColorSpace.parseToIR(alt, xref, res);
  47839. var altCS = ColorSpace.fromIR(altIR);
  47840. if (altCS.numComps === numComps) {
  47841. return altIR;
  47842. }
  47843. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  47844. }
  47845. if (numComps === 1) {
  47846. return 'DeviceGrayCS';
  47847. } else if (numComps === 3) {
  47848. return 'DeviceRgbCS';
  47849. } else if (numComps === 4) {
  47850. return 'DeviceCmykCS';
  47851. }
  47852. break;
  47853. case 'Pattern':
  47854. var basePatternCS = cs[1] || null;
  47855. if (basePatternCS) {
  47856. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  47857. }
  47858. return [
  47859. 'PatternCS',
  47860. basePatternCS
  47861. ];
  47862. case 'Indexed':
  47863. case 'I':
  47864. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  47865. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  47866. var lookup = xref.fetchIfRef(cs[3]);
  47867. if (isStream(lookup)) {
  47868. lookup = lookup.getBytes();
  47869. }
  47870. return [
  47871. 'IndexedCS',
  47872. baseIndexedCS,
  47873. hiVal,
  47874. lookup
  47875. ];
  47876. case 'Separation':
  47877. case 'DeviceN':
  47878. var name = xref.fetchIfRef(cs[1]);
  47879. numComps = 1;
  47880. if (isName(name)) {
  47881. numComps = 1;
  47882. } else if (isArray(name)) {
  47883. numComps = name.length;
  47884. }
  47885. alt = ColorSpace.parseToIR(cs[2], xref, res);
  47886. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  47887. return [
  47888. 'AlternateCS',
  47889. numComps,
  47890. alt,
  47891. tintFnIR
  47892. ];
  47893. case 'Lab':
  47894. params = xref.fetchIfRef(cs[1]);
  47895. whitePoint = params.getArray('WhitePoint');
  47896. blackPoint = params.getArray('BlackPoint');
  47897. var range = params.getArray('Range');
  47898. return [
  47899. 'LabCS',
  47900. whitePoint,
  47901. blackPoint,
  47902. range
  47903. ];
  47904. default:
  47905. error('unimplemented color space object "' + mode + '"');
  47906. }
  47907. } else {
  47908. error('unrecognized color space object: "' + cs + '"');
  47909. }
  47910. return null;
  47911. };
  47912. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  47913. if (!isArray(decode)) {
  47914. return true;
  47915. }
  47916. if (n * 2 !== decode.length) {
  47917. warn('The decode map is not the correct length');
  47918. return true;
  47919. }
  47920. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  47921. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  47922. return false;
  47923. }
  47924. }
  47925. return true;
  47926. };
  47927. ColorSpace.singletons = {
  47928. get gray() {
  47929. return shadow(this, 'gray', new DeviceGrayCS());
  47930. },
  47931. get rgb() {
  47932. return shadow(this, 'rgb', new DeviceRgbCS());
  47933. },
  47934. get cmyk() {
  47935. return shadow(this, 'cmyk', new DeviceCmykCS());
  47936. }
  47937. };
  47938. return ColorSpace;
  47939. }();
  47940. var AlternateCS = function AlternateCSClosure() {
  47941. function AlternateCS(numComps, base, tintFn) {
  47942. this.name = 'Alternate';
  47943. this.numComps = numComps;
  47944. this.defaultColor = new Float32Array(numComps);
  47945. for (var i = 0; i < numComps; ++i) {
  47946. this.defaultColor[i] = 1;
  47947. }
  47948. this.base = base;
  47949. this.tintFn = tintFn;
  47950. this.tmpBuf = new Float32Array(base.numComps);
  47951. }
  47952. AlternateCS.prototype = {
  47953. getRgb: ColorSpace.prototype.getRgb,
  47954. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  47955. var tmpBuf = this.tmpBuf;
  47956. this.tintFn(src, srcOffset, tmpBuf, 0);
  47957. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  47958. },
  47959. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47960. var tintFn = this.tintFn;
  47961. var base = this.base;
  47962. var scale = 1 / ((1 << bits) - 1);
  47963. var baseNumComps = base.numComps;
  47964. var usesZeroToOneRange = base.usesZeroToOneRange;
  47965. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  47966. var pos = isPassthrough ? destOffset : 0;
  47967. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  47968. var numComps = this.numComps;
  47969. var scaled = new Float32Array(numComps);
  47970. var tinted = new Float32Array(baseNumComps);
  47971. var i, j;
  47972. if (usesZeroToOneRange) {
  47973. for (i = 0; i < count; i++) {
  47974. for (j = 0; j < numComps; j++) {
  47975. scaled[j] = src[srcOffset++] * scale;
  47976. }
  47977. tintFn(scaled, 0, tinted, 0);
  47978. for (j = 0; j < baseNumComps; j++) {
  47979. baseBuf[pos++] = tinted[j] * 255;
  47980. }
  47981. }
  47982. } else {
  47983. for (i = 0; i < count; i++) {
  47984. for (j = 0; j < numComps; j++) {
  47985. scaled[j] = src[srcOffset++] * scale;
  47986. }
  47987. tintFn(scaled, 0, tinted, 0);
  47988. base.getRgbItem(tinted, 0, baseBuf, pos);
  47989. pos += baseNumComps;
  47990. }
  47991. }
  47992. if (!isPassthrough) {
  47993. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  47994. }
  47995. },
  47996. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  47997. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  47998. },
  47999. isPassthrough: ColorSpace.prototype.isPassthrough,
  48000. fillRgb: ColorSpace.prototype.fillRgb,
  48001. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  48002. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48003. },
  48004. usesZeroToOneRange: true
  48005. };
  48006. return AlternateCS;
  48007. }();
  48008. var PatternCS = function PatternCSClosure() {
  48009. function PatternCS(baseCS) {
  48010. this.name = 'Pattern';
  48011. this.base = baseCS;
  48012. }
  48013. PatternCS.prototype = {};
  48014. return PatternCS;
  48015. }();
  48016. var IndexedCS = function IndexedCSClosure() {
  48017. function IndexedCS(base, highVal, lookup) {
  48018. this.name = 'Indexed';
  48019. this.numComps = 1;
  48020. this.defaultColor = new Uint8Array([0]);
  48021. this.base = base;
  48022. this.highVal = highVal;
  48023. var baseNumComps = base.numComps;
  48024. var length = baseNumComps * highVal;
  48025. var lookupArray;
  48026. if (isStream(lookup)) {
  48027. lookupArray = new Uint8Array(length);
  48028. var bytes = lookup.getBytes(length);
  48029. lookupArray.set(bytes);
  48030. } else if (isString(lookup)) {
  48031. lookupArray = new Uint8Array(length);
  48032. for (var i = 0; i < length; ++i) {
  48033. lookupArray[i] = lookup.charCodeAt(i);
  48034. }
  48035. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48036. lookupArray = lookup;
  48037. } else {
  48038. error('Unrecognized lookup table: ' + lookup);
  48039. }
  48040. this.lookup = lookupArray;
  48041. }
  48042. IndexedCS.prototype = {
  48043. getRgb: ColorSpace.prototype.getRgb,
  48044. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48045. var numComps = this.base.numComps;
  48046. var start = src[srcOffset] * numComps;
  48047. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48048. },
  48049. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48050. var base = this.base;
  48051. var numComps = base.numComps;
  48052. var outputDelta = base.getOutputLength(numComps, alpha01);
  48053. var lookup = this.lookup;
  48054. for (var i = 0; i < count; ++i) {
  48055. var lookupPos = src[srcOffset++] * numComps;
  48056. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48057. destOffset += outputDelta;
  48058. }
  48059. },
  48060. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48061. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48062. },
  48063. isPassthrough: ColorSpace.prototype.isPassthrough,
  48064. fillRgb: ColorSpace.prototype.fillRgb,
  48065. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48066. return true;
  48067. },
  48068. usesZeroToOneRange: true
  48069. };
  48070. return IndexedCS;
  48071. }();
  48072. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48073. function DeviceGrayCS() {
  48074. this.name = 'DeviceGray';
  48075. this.numComps = 1;
  48076. this.defaultColor = new Float32Array([0]);
  48077. }
  48078. DeviceGrayCS.prototype = {
  48079. getRgb: ColorSpace.prototype.getRgb,
  48080. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48081. var c = src[srcOffset] * 255 | 0;
  48082. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48083. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48084. },
  48085. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48086. var scale = 255 / ((1 << bits) - 1);
  48087. var j = srcOffset, q = destOffset;
  48088. for (var i = 0; i < count; ++i) {
  48089. var c = scale * src[j++] | 0;
  48090. dest[q++] = c;
  48091. dest[q++] = c;
  48092. dest[q++] = c;
  48093. q += alpha01;
  48094. }
  48095. },
  48096. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48097. return inputLength * (3 + alpha01);
  48098. },
  48099. isPassthrough: ColorSpace.prototype.isPassthrough,
  48100. fillRgb: ColorSpace.prototype.fillRgb,
  48101. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48102. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48103. },
  48104. usesZeroToOneRange: true
  48105. };
  48106. return DeviceGrayCS;
  48107. }();
  48108. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48109. function DeviceRgbCS() {
  48110. this.name = 'DeviceRGB';
  48111. this.numComps = 3;
  48112. this.defaultColor = new Float32Array([
  48113. 0,
  48114. 0,
  48115. 0
  48116. ]);
  48117. }
  48118. DeviceRgbCS.prototype = {
  48119. getRgb: ColorSpace.prototype.getRgb,
  48120. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48121. var r = src[srcOffset] * 255 | 0;
  48122. var g = src[srcOffset + 1] * 255 | 0;
  48123. var b = src[srcOffset + 2] * 255 | 0;
  48124. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48125. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48126. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48127. },
  48128. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48129. if (bits === 8 && alpha01 === 0) {
  48130. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48131. return;
  48132. }
  48133. var scale = 255 / ((1 << bits) - 1);
  48134. var j = srcOffset, q = destOffset;
  48135. for (var i = 0; i < count; ++i) {
  48136. dest[q++] = scale * src[j++] | 0;
  48137. dest[q++] = scale * src[j++] | 0;
  48138. dest[q++] = scale * src[j++] | 0;
  48139. q += alpha01;
  48140. }
  48141. },
  48142. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48143. return inputLength * (3 + alpha01) / 3 | 0;
  48144. },
  48145. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48146. return bits === 8;
  48147. },
  48148. fillRgb: ColorSpace.prototype.fillRgb,
  48149. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48150. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48151. },
  48152. usesZeroToOneRange: true
  48153. };
  48154. return DeviceRgbCS;
  48155. }();
  48156. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48157. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48158. var c = src[srcOffset + 0] * srcScale;
  48159. var m = src[srcOffset + 1] * srcScale;
  48160. var y = src[srcOffset + 2] * srcScale;
  48161. var k = src[srcOffset + 3] * srcScale;
  48162. 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;
  48163. 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;
  48164. 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;
  48165. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48166. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48167. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48168. }
  48169. function DeviceCmykCS() {
  48170. this.name = 'DeviceCMYK';
  48171. this.numComps = 4;
  48172. this.defaultColor = new Float32Array([
  48173. 0,
  48174. 0,
  48175. 0,
  48176. 1
  48177. ]);
  48178. }
  48179. DeviceCmykCS.prototype = {
  48180. getRgb: ColorSpace.prototype.getRgb,
  48181. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48182. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48183. },
  48184. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48185. var scale = 1 / ((1 << bits) - 1);
  48186. for (var i = 0; i < count; i++) {
  48187. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48188. srcOffset += 4;
  48189. destOffset += 3 + alpha01;
  48190. }
  48191. },
  48192. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48193. return inputLength / 4 * (3 + alpha01) | 0;
  48194. },
  48195. isPassthrough: ColorSpace.prototype.isPassthrough,
  48196. fillRgb: ColorSpace.prototype.fillRgb,
  48197. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48198. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48199. },
  48200. usesZeroToOneRange: true
  48201. };
  48202. return DeviceCmykCS;
  48203. }();
  48204. var CalGrayCS = function CalGrayCSClosure() {
  48205. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48206. this.name = 'CalGray';
  48207. this.numComps = 1;
  48208. this.defaultColor = new Float32Array([0]);
  48209. if (!whitePoint) {
  48210. error('WhitePoint missing - required for color space CalGray');
  48211. }
  48212. blackPoint = blackPoint || [
  48213. 0,
  48214. 0,
  48215. 0
  48216. ];
  48217. gamma = gamma || 1;
  48218. this.XW = whitePoint[0];
  48219. this.YW = whitePoint[1];
  48220. this.ZW = whitePoint[2];
  48221. this.XB = blackPoint[0];
  48222. this.YB = blackPoint[1];
  48223. this.ZB = blackPoint[2];
  48224. this.G = gamma;
  48225. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48226. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48227. }
  48228. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48229. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48230. this.XB = this.YB = this.ZB = 0;
  48231. }
  48232. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48233. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48234. }
  48235. if (this.G < 1) {
  48236. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48237. this.G = 1;
  48238. }
  48239. }
  48240. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48241. var A = src[srcOffset] * scale;
  48242. var AG = Math.pow(A, cs.G);
  48243. var L = cs.YW * AG;
  48244. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48245. dest[destOffset] = val;
  48246. dest[destOffset + 1] = val;
  48247. dest[destOffset + 2] = val;
  48248. }
  48249. CalGrayCS.prototype = {
  48250. getRgb: ColorSpace.prototype.getRgb,
  48251. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48252. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48253. },
  48254. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48255. var scale = 1 / ((1 << bits) - 1);
  48256. for (var i = 0; i < count; ++i) {
  48257. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48258. srcOffset += 1;
  48259. destOffset += 3 + alpha01;
  48260. }
  48261. },
  48262. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48263. return inputLength * (3 + alpha01);
  48264. },
  48265. isPassthrough: ColorSpace.prototype.isPassthrough,
  48266. fillRgb: ColorSpace.prototype.fillRgb,
  48267. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48268. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48269. },
  48270. usesZeroToOneRange: true
  48271. };
  48272. return CalGrayCS;
  48273. }();
  48274. var CalRGBCS = function CalRGBCSClosure() {
  48275. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48276. 0.8951,
  48277. 0.2664,
  48278. -0.1614,
  48279. -0.7502,
  48280. 1.7135,
  48281. 0.0367,
  48282. 0.0389,
  48283. -0.0685,
  48284. 1.0296
  48285. ]);
  48286. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48287. 0.9869929,
  48288. -0.1470543,
  48289. 0.1599627,
  48290. 0.4323053,
  48291. 0.5183603,
  48292. 0.0492912,
  48293. -0.0085287,
  48294. 0.0400428,
  48295. 0.9684867
  48296. ]);
  48297. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48298. 3.2404542,
  48299. -1.5371385,
  48300. -0.4985314,
  48301. -0.9692660,
  48302. 1.8760108,
  48303. 0.0415560,
  48304. 0.0556434,
  48305. -0.2040259,
  48306. 1.0572252
  48307. ]);
  48308. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48309. 1,
  48310. 1,
  48311. 1
  48312. ]);
  48313. var tempNormalizeMatrix = new Float32Array(3);
  48314. var tempConvertMatrix1 = new Float32Array(3);
  48315. var tempConvertMatrix2 = new Float32Array(3);
  48316. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48317. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48318. this.name = 'CalRGB';
  48319. this.numComps = 3;
  48320. this.defaultColor = new Float32Array(3);
  48321. if (!whitePoint) {
  48322. error('WhitePoint missing - required for color space CalRGB');
  48323. }
  48324. blackPoint = blackPoint || new Float32Array(3);
  48325. gamma = gamma || new Float32Array([
  48326. 1,
  48327. 1,
  48328. 1
  48329. ]);
  48330. matrix = matrix || new Float32Array([
  48331. 1,
  48332. 0,
  48333. 0,
  48334. 0,
  48335. 1,
  48336. 0,
  48337. 0,
  48338. 0,
  48339. 1
  48340. ]);
  48341. var XW = whitePoint[0];
  48342. var YW = whitePoint[1];
  48343. var ZW = whitePoint[2];
  48344. this.whitePoint = whitePoint;
  48345. var XB = blackPoint[0];
  48346. var YB = blackPoint[1];
  48347. var ZB = blackPoint[2];
  48348. this.blackPoint = blackPoint;
  48349. this.GR = gamma[0];
  48350. this.GG = gamma[1];
  48351. this.GB = gamma[2];
  48352. this.MXA = matrix[0];
  48353. this.MYA = matrix[1];
  48354. this.MZA = matrix[2];
  48355. this.MXB = matrix[3];
  48356. this.MYB = matrix[4];
  48357. this.MZB = matrix[5];
  48358. this.MXC = matrix[6];
  48359. this.MYC = matrix[7];
  48360. this.MZC = matrix[8];
  48361. if (XW < 0 || ZW < 0 || YW !== 1) {
  48362. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48363. }
  48364. if (XB < 0 || YB < 0 || ZB < 0) {
  48365. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48366. this.blackPoint = new Float32Array(3);
  48367. }
  48368. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48369. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48370. this.GR = this.GG = this.GB = 1;
  48371. }
  48372. 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) {
  48373. 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');
  48374. this.MXA = this.MYB = this.MZC = 1;
  48375. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48376. }
  48377. }
  48378. function matrixProduct(a, b, result) {
  48379. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48380. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48381. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48382. }
  48383. function convertToFlat(sourceWhitePoint, LMS, result) {
  48384. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48385. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48386. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48387. }
  48388. function convertToD65(sourceWhitePoint, LMS, result) {
  48389. var D65X = 0.95047;
  48390. var D65Y = 1;
  48391. var D65Z = 1.08883;
  48392. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48393. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48394. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48395. }
  48396. function sRGBTransferFunction(color) {
  48397. if (color <= 0.0031308) {
  48398. return adjustToRange(0, 1, 12.92 * color);
  48399. }
  48400. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48401. }
  48402. function adjustToRange(min, max, value) {
  48403. return Math.max(min, Math.min(max, value));
  48404. }
  48405. function decodeL(L) {
  48406. if (L < 0) {
  48407. return -decodeL(-L);
  48408. }
  48409. if (L > 8.0) {
  48410. return Math.pow((L + 16) / 116, 3);
  48411. }
  48412. return L * DECODE_L_CONSTANT;
  48413. }
  48414. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48415. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48416. result[0] = XYZ_Flat[0];
  48417. result[1] = XYZ_Flat[1];
  48418. result[2] = XYZ_Flat[2];
  48419. return;
  48420. }
  48421. var zeroDecodeL = decodeL(0);
  48422. var X_DST = zeroDecodeL;
  48423. var X_SRC = decodeL(sourceBlackPoint[0]);
  48424. var Y_DST = zeroDecodeL;
  48425. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48426. var Z_DST = zeroDecodeL;
  48427. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48428. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48429. var X_Offset = 1 - X_Scale;
  48430. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48431. var Y_Offset = 1 - Y_Scale;
  48432. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48433. var Z_Offset = 1 - Z_Scale;
  48434. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48435. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48436. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48437. }
  48438. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48439. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48440. result[0] = XYZ_In[0];
  48441. result[1] = XYZ_In[1];
  48442. result[2] = XYZ_In[2];
  48443. return;
  48444. }
  48445. var LMS = result;
  48446. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48447. var LMS_Flat = tempNormalizeMatrix;
  48448. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48449. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48450. }
  48451. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48452. var LMS = result;
  48453. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48454. var LMS_D65 = tempNormalizeMatrix;
  48455. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48456. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48457. }
  48458. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48459. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48460. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48461. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48462. var AGR = Math.pow(A, cs.GR);
  48463. var BGG = Math.pow(B, cs.GG);
  48464. var CGB = Math.pow(C, cs.GB);
  48465. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48466. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48467. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48468. var XYZ = tempConvertMatrix1;
  48469. XYZ[0] = X;
  48470. XYZ[1] = Y;
  48471. XYZ[2] = Z;
  48472. var XYZ_Flat = tempConvertMatrix2;
  48473. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48474. var XYZ_Black = tempConvertMatrix1;
  48475. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48476. var XYZ_D65 = tempConvertMatrix2;
  48477. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48478. var SRGB = tempConvertMatrix1;
  48479. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48480. var sR = sRGBTransferFunction(SRGB[0]);
  48481. var sG = sRGBTransferFunction(SRGB[1]);
  48482. var sB = sRGBTransferFunction(SRGB[2]);
  48483. dest[destOffset] = Math.round(sR * 255);
  48484. dest[destOffset + 1] = Math.round(sG * 255);
  48485. dest[destOffset + 2] = Math.round(sB * 255);
  48486. }
  48487. CalRGBCS.prototype = {
  48488. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48489. var rgb = new Uint8Array(3);
  48490. this.getRgbItem(src, srcOffset, rgb, 0);
  48491. return rgb;
  48492. },
  48493. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48494. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48495. },
  48496. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48497. var scale = 1 / ((1 << bits) - 1);
  48498. for (var i = 0; i < count; ++i) {
  48499. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48500. srcOffset += 3;
  48501. destOffset += 3 + alpha01;
  48502. }
  48503. },
  48504. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48505. return inputLength * (3 + alpha01) / 3 | 0;
  48506. },
  48507. isPassthrough: ColorSpace.prototype.isPassthrough,
  48508. fillRgb: ColorSpace.prototype.fillRgb,
  48509. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48510. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48511. },
  48512. usesZeroToOneRange: true
  48513. };
  48514. return CalRGBCS;
  48515. }();
  48516. var LabCS = function LabCSClosure() {
  48517. function LabCS(whitePoint, blackPoint, range) {
  48518. this.name = 'Lab';
  48519. this.numComps = 3;
  48520. this.defaultColor = new Float32Array([
  48521. 0,
  48522. 0,
  48523. 0
  48524. ]);
  48525. if (!whitePoint) {
  48526. error('WhitePoint missing - required for color space Lab');
  48527. }
  48528. blackPoint = blackPoint || [
  48529. 0,
  48530. 0,
  48531. 0
  48532. ];
  48533. range = range || [
  48534. -100,
  48535. 100,
  48536. -100,
  48537. 100
  48538. ];
  48539. this.XW = whitePoint[0];
  48540. this.YW = whitePoint[1];
  48541. this.ZW = whitePoint[2];
  48542. this.amin = range[0];
  48543. this.amax = range[1];
  48544. this.bmin = range[2];
  48545. this.bmax = range[3];
  48546. this.XB = blackPoint[0];
  48547. this.YB = blackPoint[1];
  48548. this.ZB = blackPoint[2];
  48549. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48550. error('Invalid WhitePoint components, no fallback available');
  48551. }
  48552. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48553. info('Invalid BlackPoint, falling back to default');
  48554. this.XB = this.YB = this.ZB = 0;
  48555. }
  48556. if (this.amin > this.amax || this.bmin > this.bmax) {
  48557. info('Invalid Range, falling back to defaults');
  48558. this.amin = -100;
  48559. this.amax = 100;
  48560. this.bmin = -100;
  48561. this.bmax = 100;
  48562. }
  48563. }
  48564. function fn_g(x) {
  48565. if (x >= 6 / 29) {
  48566. return x * x * x;
  48567. } else {
  48568. return 108 / 841 * (x - 4 / 29);
  48569. }
  48570. }
  48571. function decode(value, high1, low2, high2) {
  48572. return low2 + value * (high2 - low2) / high1;
  48573. }
  48574. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48575. var Ls = src[srcOffset];
  48576. var as = src[srcOffset + 1];
  48577. var bs = src[srcOffset + 2];
  48578. if (maxVal !== false) {
  48579. Ls = decode(Ls, maxVal, 0, 100);
  48580. as = decode(as, maxVal, cs.amin, cs.amax);
  48581. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48582. }
  48583. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48584. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48585. var M = (Ls + 16) / 116;
  48586. var L = M + as / 500;
  48587. var N = M - bs / 200;
  48588. var X = cs.XW * fn_g(L);
  48589. var Y = cs.YW * fn_g(M);
  48590. var Z = cs.ZW * fn_g(N);
  48591. var r, g, b;
  48592. if (cs.ZW < 1) {
  48593. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48594. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48595. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48596. } else {
  48597. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48598. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48599. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48600. }
  48601. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48602. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48603. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48604. }
  48605. LabCS.prototype = {
  48606. getRgb: ColorSpace.prototype.getRgb,
  48607. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48608. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48609. },
  48610. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48611. var maxVal = (1 << bits) - 1;
  48612. for (var i = 0; i < count; i++) {
  48613. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48614. srcOffset += 3;
  48615. destOffset += 3 + alpha01;
  48616. }
  48617. },
  48618. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48619. return inputLength * (3 + alpha01) / 3 | 0;
  48620. },
  48621. isPassthrough: ColorSpace.prototype.isPassthrough,
  48622. fillRgb: ColorSpace.prototype.fillRgb,
  48623. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48624. return true;
  48625. },
  48626. usesZeroToOneRange: false
  48627. };
  48628. return LabCS;
  48629. }();
  48630. exports.ColorSpace = ColorSpace;
  48631. }));
  48632. (function (root, factory) {
  48633. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48634. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48635. var globalScope = sharedUtil.globalScope;
  48636. var deprecated = sharedUtil.deprecated;
  48637. var warn = sharedUtil.warn;
  48638. var LinkTarget = displayDOMUtils.LinkTarget;
  48639. var isWorker = typeof window === 'undefined';
  48640. if (!globalScope.PDFJS) {
  48641. globalScope.PDFJS = {};
  48642. }
  48643. var PDFJS = globalScope.PDFJS;
  48644. if (typeof pdfjsVersion !== 'undefined') {
  48645. PDFJS.version = pdfjsVersion;
  48646. }
  48647. if (typeof pdfjsBuild !== 'undefined') {
  48648. PDFJS.build = pdfjsBuild;
  48649. }
  48650. PDFJS.pdfBug = false;
  48651. if (PDFJS.verbosity !== undefined) {
  48652. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  48653. }
  48654. delete PDFJS.verbosity;
  48655. Object.defineProperty(PDFJS, 'verbosity', {
  48656. get: function () {
  48657. return sharedUtil.getVerbosityLevel();
  48658. },
  48659. set: function (level) {
  48660. sharedUtil.setVerbosityLevel(level);
  48661. },
  48662. enumerable: true,
  48663. configurable: true
  48664. });
  48665. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  48666. PDFJS.OPS = sharedUtil.OPS;
  48667. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  48668. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  48669. PDFJS.shadow = sharedUtil.shadow;
  48670. PDFJS.createBlob = sharedUtil.createBlob;
  48671. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  48672. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  48673. };
  48674. Object.defineProperty(PDFJS, 'isLittleEndian', {
  48675. configurable: true,
  48676. get: function PDFJS_isLittleEndian() {
  48677. var value = sharedUtil.isLittleEndian();
  48678. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  48679. }
  48680. });
  48681. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  48682. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  48683. PDFJS.PasswordException = sharedUtil.PasswordException;
  48684. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  48685. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  48686. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  48687. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  48688. PDFJS.Util = sharedUtil.Util;
  48689. PDFJS.PageViewport = sharedUtil.PageViewport;
  48690. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  48691. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  48692. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  48693. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  48694. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  48695. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  48696. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  48697. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  48698. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  48699. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  48700. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  48701. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  48702. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  48703. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  48704. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  48705. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  48706. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? 'noreferrer' : PDFJS.externalLinkRel;
  48707. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  48708. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  48709. delete PDFJS.openExternalLinksInNewWindow;
  48710. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  48711. get: function () {
  48712. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  48713. },
  48714. set: function (value) {
  48715. if (value) {
  48716. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  48717. }
  48718. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  48719. warn('PDFJS.externalLinkTarget is already initialized');
  48720. return;
  48721. }
  48722. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  48723. },
  48724. enumerable: true,
  48725. configurable: true
  48726. });
  48727. if (savedOpenExternalLinksInNewWindow) {
  48728. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  48729. }
  48730. PDFJS.getDocument = displayAPI.getDocument;
  48731. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  48732. PDFJS.PDFWorker = displayAPI.PDFWorker;
  48733. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  48734. configurable: true,
  48735. get: function PDFJS_hasCanvasTypedArrays() {
  48736. var value = displayDOMUtils.hasCanvasTypedArrays();
  48737. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  48738. }
  48739. });
  48740. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  48741. PDFJS.LinkTarget = LinkTarget;
  48742. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  48743. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  48744. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  48745. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  48746. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  48747. PDFJS.Metadata = displayMetadata.Metadata;
  48748. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  48749. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  48750. exports.globalScope = globalScope;
  48751. exports.isWorker = isWorker;
  48752. exports.PDFJS = globalScope.PDFJS;
  48753. }));
  48754. (function (root, factory) {
  48755. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  48756. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  48757. var ImageKind = sharedUtil.ImageKind;
  48758. var assert = sharedUtil.assert;
  48759. var error = sharedUtil.error;
  48760. var info = sharedUtil.info;
  48761. var isArray = sharedUtil.isArray;
  48762. var warn = sharedUtil.warn;
  48763. var Name = corePrimitives.Name;
  48764. var isStream = corePrimitives.isStream;
  48765. var ColorSpace = coreColorSpace.ColorSpace;
  48766. var DecodeStream = coreStream.DecodeStream;
  48767. var JpegStream = coreStream.JpegStream;
  48768. var JpxImage = coreJpx.JpxImage;
  48769. var PDFImage = function PDFImageClosure() {
  48770. function handleImageData(image, nativeDecoder) {
  48771. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  48772. return nativeDecoder.decode(image);
  48773. } else {
  48774. return Promise.resolve(image);
  48775. }
  48776. }
  48777. function decodeAndClamp(value, addend, coefficient, max) {
  48778. value = addend + value * coefficient;
  48779. return value < 0 ? 0 : value > max ? max : value;
  48780. }
  48781. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48782. var length = w2 * h2;
  48783. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48784. var xRatio = w1 / w2;
  48785. var yRatio = h1 / h2;
  48786. var i, j, py, newIndex = 0, oldIndex;
  48787. var xScaled = new Uint16Array(w2);
  48788. var w1Scanline = w1;
  48789. for (i = 0; i < w2; i++) {
  48790. xScaled[i] = Math.floor(i * xRatio);
  48791. }
  48792. for (i = 0; i < h2; i++) {
  48793. py = Math.floor(i * yRatio) * w1Scanline;
  48794. for (j = 0; j < w2; j++) {
  48795. oldIndex = py + xScaled[j];
  48796. dest[newIndex++] = src[oldIndex];
  48797. }
  48798. }
  48799. return dest;
  48800. }
  48801. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48802. this.image = image;
  48803. var dict = image.dict;
  48804. if (dict.has('Filter')) {
  48805. var filter = dict.get('Filter').name;
  48806. if (filter === 'JPXDecode') {
  48807. var jpxImage = new JpxImage();
  48808. jpxImage.parseImageProperties(image.stream);
  48809. image.stream.reset();
  48810. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48811. image.numComps = jpxImage.componentsCount;
  48812. } else if (filter === 'JBIG2Decode') {
  48813. image.bitsPerComponent = 1;
  48814. image.numComps = 1;
  48815. }
  48816. }
  48817. this.width = dict.get('Width', 'W');
  48818. this.height = dict.get('Height', 'H');
  48819. if (this.width < 1 || this.height < 1) {
  48820. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48821. }
  48822. this.interpolate = dict.get('Interpolate', 'I') || false;
  48823. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48824. this.matte = dict.get('Matte') || false;
  48825. var bitsPerComponent = image.bitsPerComponent;
  48826. if (!bitsPerComponent) {
  48827. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48828. if (!bitsPerComponent) {
  48829. if (this.imageMask) {
  48830. bitsPerComponent = 1;
  48831. } else {
  48832. error('Bits per component missing in image: ' + this.imageMask);
  48833. }
  48834. }
  48835. }
  48836. this.bpc = bitsPerComponent;
  48837. if (!this.imageMask) {
  48838. var colorSpace = dict.get('ColorSpace', 'CS');
  48839. if (!colorSpace) {
  48840. info('JPX images (which do not require color spaces)');
  48841. switch (image.numComps) {
  48842. case 1:
  48843. colorSpace = Name.get('DeviceGray');
  48844. break;
  48845. case 3:
  48846. colorSpace = Name.get('DeviceRGB');
  48847. break;
  48848. case 4:
  48849. colorSpace = Name.get('DeviceCMYK');
  48850. break;
  48851. default:
  48852. error('JPX images with ' + this.numComps + ' color components not supported.');
  48853. }
  48854. }
  48855. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  48856. this.numComps = this.colorSpace.numComps;
  48857. }
  48858. this.decode = dict.getArray('Decode', 'D');
  48859. this.needsDecode = false;
  48860. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  48861. this.needsDecode = true;
  48862. var max = (1 << bitsPerComponent) - 1;
  48863. this.decodeCoefficients = [];
  48864. this.decodeAddends = [];
  48865. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  48866. var dmin = this.decode[i];
  48867. var dmax = this.decode[i + 1];
  48868. this.decodeCoefficients[j] = dmax - dmin;
  48869. this.decodeAddends[j] = max * dmin;
  48870. }
  48871. }
  48872. if (smask) {
  48873. this.smask = new PDFImage(xref, res, smask, false);
  48874. } else if (mask) {
  48875. if (isStream(mask)) {
  48876. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  48877. if (!imageMask) {
  48878. warn('Ignoring /Mask in image without /ImageMask.');
  48879. } else {
  48880. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  48881. }
  48882. } else {
  48883. this.mask = mask;
  48884. }
  48885. }
  48886. }
  48887. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  48888. var imagePromise = handleImageData(image, nativeDecoder);
  48889. var smaskPromise;
  48890. var maskPromise;
  48891. var smask = image.dict.get('SMask');
  48892. var mask = image.dict.get('Mask');
  48893. if (smask) {
  48894. smaskPromise = handleImageData(smask, nativeDecoder);
  48895. maskPromise = Promise.resolve(null);
  48896. } else {
  48897. smaskPromise = Promise.resolve(null);
  48898. if (mask) {
  48899. if (isStream(mask)) {
  48900. maskPromise = handleImageData(mask, nativeDecoder);
  48901. } else if (isArray(mask)) {
  48902. maskPromise = Promise.resolve(mask);
  48903. } else {
  48904. warn('Unsupported mask format.');
  48905. maskPromise = Promise.resolve(null);
  48906. }
  48907. } else {
  48908. maskPromise = Promise.resolve(null);
  48909. }
  48910. }
  48911. return Promise.all([
  48912. imagePromise,
  48913. smaskPromise,
  48914. maskPromise
  48915. ]).then(function (results) {
  48916. var imageData = results[0];
  48917. var smaskData = results[1];
  48918. var maskData = results[2];
  48919. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  48920. });
  48921. };
  48922. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  48923. var computedLength = (width + 7 >> 3) * height;
  48924. var actualLength = imgArray.byteLength;
  48925. var haveFullData = computedLength === actualLength;
  48926. var data, i;
  48927. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  48928. data = imgArray;
  48929. } else if (!inverseDecode) {
  48930. data = new Uint8Array(actualLength);
  48931. data.set(imgArray);
  48932. } else {
  48933. data = new Uint8Array(computedLength);
  48934. data.set(imgArray);
  48935. for (i = actualLength; i < computedLength; i++) {
  48936. data[i] = 0xff;
  48937. }
  48938. }
  48939. if (inverseDecode) {
  48940. for (i = 0; i < actualLength; i++) {
  48941. data[i] = ~data[i];
  48942. }
  48943. }
  48944. return {
  48945. data: data,
  48946. width: width,
  48947. height: height
  48948. };
  48949. };
  48950. PDFImage.prototype = {
  48951. get drawWidth() {
  48952. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  48953. },
  48954. get drawHeight() {
  48955. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  48956. },
  48957. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  48958. var bpc = this.bpc;
  48959. var numComps = this.numComps;
  48960. var decodeAddends = this.decodeAddends;
  48961. var decodeCoefficients = this.decodeCoefficients;
  48962. var max = (1 << bpc) - 1;
  48963. var i, ii;
  48964. if (bpc === 1) {
  48965. for (i = 0, ii = buffer.length; i < ii; i++) {
  48966. buffer[i] = +!buffer[i];
  48967. }
  48968. return;
  48969. }
  48970. var index = 0;
  48971. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  48972. for (var j = 0; j < numComps; j++) {
  48973. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  48974. index++;
  48975. }
  48976. }
  48977. },
  48978. getComponents: function PDFImage_getComponents(buffer) {
  48979. var bpc = this.bpc;
  48980. if (bpc === 8) {
  48981. return buffer;
  48982. }
  48983. var width = this.width;
  48984. var height = this.height;
  48985. var numComps = this.numComps;
  48986. var length = width * height * numComps;
  48987. var bufferPos = 0;
  48988. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48989. var rowComps = width * numComps;
  48990. var max = (1 << bpc) - 1;
  48991. var i = 0, ii, buf;
  48992. if (bpc === 1) {
  48993. var mask, loop1End, loop2End;
  48994. for (var j = 0; j < height; j++) {
  48995. loop1End = i + (rowComps & ~7);
  48996. loop2End = i + rowComps;
  48997. while (i < loop1End) {
  48998. buf = buffer[bufferPos++];
  48999. output[i] = buf >> 7 & 1;
  49000. output[i + 1] = buf >> 6 & 1;
  49001. output[i + 2] = buf >> 5 & 1;
  49002. output[i + 3] = buf >> 4 & 1;
  49003. output[i + 4] = buf >> 3 & 1;
  49004. output[i + 5] = buf >> 2 & 1;
  49005. output[i + 6] = buf >> 1 & 1;
  49006. output[i + 7] = buf & 1;
  49007. i += 8;
  49008. }
  49009. if (i < loop2End) {
  49010. buf = buffer[bufferPos++];
  49011. mask = 128;
  49012. while (i < loop2End) {
  49013. output[i++] = +!!(buf & mask);
  49014. mask >>= 1;
  49015. }
  49016. }
  49017. }
  49018. } else {
  49019. var bits = 0;
  49020. buf = 0;
  49021. for (i = 0, ii = length; i < ii; ++i) {
  49022. if (i % rowComps === 0) {
  49023. buf = 0;
  49024. bits = 0;
  49025. }
  49026. while (bits < bpc) {
  49027. buf = buf << 8 | buffer[bufferPos++];
  49028. bits += 8;
  49029. }
  49030. var remainingBits = bits - bpc;
  49031. var value = buf >> remainingBits;
  49032. output[i] = value < 0 ? 0 : value > max ? max : value;
  49033. buf = buf & (1 << remainingBits) - 1;
  49034. bits = remainingBits;
  49035. }
  49036. }
  49037. return output;
  49038. },
  49039. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49040. var smask = this.smask;
  49041. var mask = this.mask;
  49042. var alphaBuf, sw, sh, i, ii, j;
  49043. if (smask) {
  49044. sw = smask.width;
  49045. sh = smask.height;
  49046. alphaBuf = new Uint8Array(sw * sh);
  49047. smask.fillGrayBuffer(alphaBuf);
  49048. if (sw !== width || sh !== height) {
  49049. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49050. }
  49051. } else if (mask) {
  49052. if (mask instanceof PDFImage) {
  49053. sw = mask.width;
  49054. sh = mask.height;
  49055. alphaBuf = new Uint8Array(sw * sh);
  49056. mask.numComps = 1;
  49057. mask.fillGrayBuffer(alphaBuf);
  49058. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49059. alphaBuf[i] = 255 - alphaBuf[i];
  49060. }
  49061. if (sw !== width || sh !== height) {
  49062. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49063. }
  49064. } else if (isArray(mask)) {
  49065. alphaBuf = new Uint8Array(width * height);
  49066. var numComps = this.numComps;
  49067. for (i = 0, ii = width * height; i < ii; ++i) {
  49068. var opacity = 0;
  49069. var imageOffset = i * numComps;
  49070. for (j = 0; j < numComps; ++j) {
  49071. var color = image[imageOffset + j];
  49072. var maskOffset = j * 2;
  49073. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49074. opacity = 255;
  49075. break;
  49076. }
  49077. }
  49078. alphaBuf[i] = opacity;
  49079. }
  49080. } else {
  49081. error('Unknown mask format.');
  49082. }
  49083. }
  49084. if (alphaBuf) {
  49085. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49086. rgbaBuf[j] = alphaBuf[i];
  49087. }
  49088. } else {
  49089. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49090. rgbaBuf[j] = 255;
  49091. }
  49092. }
  49093. },
  49094. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49095. var matte = this.smask && this.smask.matte;
  49096. if (!matte) {
  49097. return;
  49098. }
  49099. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49100. var matteR = matteRgb[0];
  49101. var matteG = matteRgb[1];
  49102. var matteB = matteRgb[2];
  49103. var length = width * height * 4;
  49104. var r, g, b;
  49105. for (var i = 0; i < length; i += 4) {
  49106. var alpha = buffer[i + 3];
  49107. if (alpha === 0) {
  49108. buffer[i] = 255;
  49109. buffer[i + 1] = 255;
  49110. buffer[i + 2] = 255;
  49111. continue;
  49112. }
  49113. var k = 255 / alpha;
  49114. r = (buffer[i] - matteR) * k + matteR;
  49115. g = (buffer[i + 1] - matteG) * k + matteG;
  49116. b = (buffer[i + 2] - matteB) * k + matteB;
  49117. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49118. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49119. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49120. }
  49121. },
  49122. createImageData: function PDFImage_createImageData(forceRGBA) {
  49123. var drawWidth = this.drawWidth;
  49124. var drawHeight = this.drawHeight;
  49125. var imgData = {
  49126. width: drawWidth,
  49127. height: drawHeight
  49128. };
  49129. var numComps = this.numComps;
  49130. var originalWidth = this.width;
  49131. var originalHeight = this.height;
  49132. var bpc = this.bpc;
  49133. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49134. var imgArray;
  49135. if (!forceRGBA) {
  49136. var kind;
  49137. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49138. kind = ImageKind.GRAYSCALE_1BPP;
  49139. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49140. kind = ImageKind.RGB_24BPP;
  49141. }
  49142. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49143. imgData.kind = kind;
  49144. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49145. if (this.image instanceof DecodeStream) {
  49146. imgData.data = imgArray;
  49147. } else {
  49148. var newArray = new Uint8Array(imgArray.length);
  49149. newArray.set(imgArray);
  49150. imgData.data = newArray;
  49151. }
  49152. if (this.needsDecode) {
  49153. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49154. var buffer = imgData.data;
  49155. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49156. buffer[i] ^= 0xff;
  49157. }
  49158. }
  49159. return imgData;
  49160. }
  49161. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49162. imgData.kind = ImageKind.RGB_24BPP;
  49163. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49164. return imgData;
  49165. }
  49166. }
  49167. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49168. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49169. var comps = this.getComponents(imgArray);
  49170. var alpha01, maybeUndoPreblend;
  49171. if (!forceRGBA && !this.smask && !this.mask) {
  49172. imgData.kind = ImageKind.RGB_24BPP;
  49173. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49174. alpha01 = 0;
  49175. maybeUndoPreblend = false;
  49176. } else {
  49177. imgData.kind = ImageKind.RGBA_32BPP;
  49178. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49179. alpha01 = 1;
  49180. maybeUndoPreblend = true;
  49181. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49182. }
  49183. if (this.needsDecode) {
  49184. this.decodeBuffer(comps);
  49185. }
  49186. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49187. if (maybeUndoPreblend) {
  49188. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49189. }
  49190. return imgData;
  49191. },
  49192. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49193. var numComps = this.numComps;
  49194. if (numComps !== 1) {
  49195. error('Reading gray scale from a color image: ' + numComps);
  49196. }
  49197. var width = this.width;
  49198. var height = this.height;
  49199. var bpc = this.bpc;
  49200. var rowBytes = width * numComps * bpc + 7 >> 3;
  49201. var imgArray = this.getImageBytes(height * rowBytes);
  49202. var comps = this.getComponents(imgArray);
  49203. var i, length;
  49204. if (bpc === 1) {
  49205. length = width * height;
  49206. if (this.needsDecode) {
  49207. for (i = 0; i < length; ++i) {
  49208. buffer[i] = comps[i] - 1 & 255;
  49209. }
  49210. } else {
  49211. for (i = 0; i < length; ++i) {
  49212. buffer[i] = -comps[i] & 255;
  49213. }
  49214. }
  49215. return;
  49216. }
  49217. if (this.needsDecode) {
  49218. this.decodeBuffer(comps);
  49219. }
  49220. length = width * height;
  49221. var scale = 255 / ((1 << bpc) - 1);
  49222. for (i = 0; i < length; ++i) {
  49223. buffer[i] = scale * comps[i] | 0;
  49224. }
  49225. },
  49226. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49227. this.image.reset();
  49228. this.image.drawWidth = drawWidth || this.width;
  49229. this.image.drawHeight = drawHeight || this.height;
  49230. this.image.forceRGB = !!forceRGB;
  49231. return this.image.getBytes(length);
  49232. }
  49233. };
  49234. return PDFImage;
  49235. }();
  49236. exports.PDFImage = PDFImage;
  49237. }));
  49238. (function (root, factory) {
  49239. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49240. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49241. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49242. var MissingDataException = sharedUtil.MissingDataException;
  49243. var XRefParseException = sharedUtil.XRefParseException;
  49244. var assert = sharedUtil.assert;
  49245. var bytesToString = sharedUtil.bytesToString;
  49246. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49247. var error = sharedUtil.error;
  49248. var info = sharedUtil.info;
  49249. var isArray = sharedUtil.isArray;
  49250. var isBool = sharedUtil.isBool;
  49251. var isInt = sharedUtil.isInt;
  49252. var isString = sharedUtil.isString;
  49253. var shadow = sharedUtil.shadow;
  49254. var stringToPDFString = sharedUtil.stringToPDFString;
  49255. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49256. var warn = sharedUtil.warn;
  49257. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49258. var Util = sharedUtil.Util;
  49259. var Ref = corePrimitives.Ref;
  49260. var RefSet = corePrimitives.RefSet;
  49261. var RefSetCache = corePrimitives.RefSetCache;
  49262. var isName = corePrimitives.isName;
  49263. var isCmd = corePrimitives.isCmd;
  49264. var isDict = corePrimitives.isDict;
  49265. var isRef = corePrimitives.isRef;
  49266. var isRefsEqual = corePrimitives.isRefsEqual;
  49267. var isStream = corePrimitives.isStream;
  49268. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49269. var Lexer = coreParser.Lexer;
  49270. var Parser = coreParser.Parser;
  49271. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49272. var ColorSpace = coreColorSpace.ColorSpace;
  49273. var Catalog = function CatalogClosure() {
  49274. function Catalog(pdfManager, xref, pageFactory) {
  49275. this.pdfManager = pdfManager;
  49276. this.xref = xref;
  49277. this.catDict = xref.getCatalogObj();
  49278. this.fontCache = new RefSetCache();
  49279. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49280. this.pageFactory = pageFactory;
  49281. this.pagePromises = [];
  49282. }
  49283. Catalog.prototype = {
  49284. get metadata() {
  49285. var streamRef = this.catDict.getRaw('Metadata');
  49286. if (!isRef(streamRef)) {
  49287. return shadow(this, 'metadata', null);
  49288. }
  49289. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49290. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49291. var metadata;
  49292. if (stream && isDict(stream.dict)) {
  49293. var type = stream.dict.get('Type');
  49294. var subtype = stream.dict.get('Subtype');
  49295. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49296. try {
  49297. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49298. } catch (e) {
  49299. info('Skipping invalid metadata.');
  49300. }
  49301. }
  49302. }
  49303. return shadow(this, 'metadata', metadata);
  49304. },
  49305. get toplevelPagesDict() {
  49306. var pagesObj = this.catDict.get('Pages');
  49307. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49308. return shadow(this, 'toplevelPagesDict', pagesObj);
  49309. },
  49310. get documentOutline() {
  49311. var obj = null;
  49312. try {
  49313. obj = this.readDocumentOutline();
  49314. } catch (ex) {
  49315. if (ex instanceof MissingDataException) {
  49316. throw ex;
  49317. }
  49318. warn('Unable to read document outline');
  49319. }
  49320. return shadow(this, 'documentOutline', obj);
  49321. },
  49322. readDocumentOutline: function Catalog_readDocumentOutline() {
  49323. var obj = this.catDict.get('Outlines');
  49324. if (!isDict(obj)) {
  49325. return null;
  49326. }
  49327. obj = obj.getRaw('First');
  49328. if (!isRef(obj)) {
  49329. return null;
  49330. }
  49331. var root = { items: [] };
  49332. var queue = [{
  49333. obj: obj,
  49334. parent: root
  49335. }];
  49336. var processed = new RefSet();
  49337. processed.put(obj);
  49338. var xref = this.xref, blackColor = new Uint8Array(3);
  49339. while (queue.length > 0) {
  49340. var i = queue.shift();
  49341. var outlineDict = xref.fetchIfRef(i.obj);
  49342. if (outlineDict === null) {
  49343. continue;
  49344. }
  49345. assert(outlineDict.has('Title'), 'Invalid outline item');
  49346. var data = {
  49347. url: null,
  49348. dest: null
  49349. };
  49350. Catalog.parseDestDictionary({
  49351. destDict: outlineDict,
  49352. resultObj: data,
  49353. docBaseUrl: this.pdfManager.docBaseUrl
  49354. });
  49355. var title = outlineDict.get('Title');
  49356. var flags = outlineDict.get('F') || 0;
  49357. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49358. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49359. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49360. }
  49361. var outlineItem = {
  49362. dest: data.dest,
  49363. url: data.url,
  49364. unsafeUrl: data.unsafeUrl,
  49365. newWindow: data.newWindow,
  49366. title: stringToPDFString(title),
  49367. color: rgbColor,
  49368. count: outlineDict.get('Count'),
  49369. bold: !!(flags & 2),
  49370. italic: !!(flags & 1),
  49371. items: []
  49372. };
  49373. i.parent.items.push(outlineItem);
  49374. obj = outlineDict.getRaw('First');
  49375. if (isRef(obj) && !processed.has(obj)) {
  49376. queue.push({
  49377. obj: obj,
  49378. parent: outlineItem
  49379. });
  49380. processed.put(obj);
  49381. }
  49382. obj = outlineDict.getRaw('Next');
  49383. if (isRef(obj) && !processed.has(obj)) {
  49384. queue.push({
  49385. obj: obj,
  49386. parent: i.parent
  49387. });
  49388. processed.put(obj);
  49389. }
  49390. }
  49391. return root.items.length > 0 ? root.items : null;
  49392. },
  49393. get numPages() {
  49394. var obj = this.toplevelPagesDict.get('Count');
  49395. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49396. return shadow(this, 'num', obj);
  49397. },
  49398. get destinations() {
  49399. function fetchDestination(dest) {
  49400. return isDict(dest) ? dest.get('D') : dest;
  49401. }
  49402. var xref = this.xref;
  49403. var dests = {}, nameTreeRef, nameDictionaryRef;
  49404. var obj = this.catDict.get('Names');
  49405. if (obj && obj.has('Dests')) {
  49406. nameTreeRef = obj.getRaw('Dests');
  49407. } else if (this.catDict.has('Dests')) {
  49408. nameDictionaryRef = this.catDict.get('Dests');
  49409. }
  49410. if (nameDictionaryRef) {
  49411. obj = nameDictionaryRef;
  49412. obj.forEach(function catalogForEach(key, value) {
  49413. if (!value) {
  49414. return;
  49415. }
  49416. dests[key] = fetchDestination(value);
  49417. });
  49418. }
  49419. if (nameTreeRef) {
  49420. var nameTree = new NameTree(nameTreeRef, xref);
  49421. var names = nameTree.getAll();
  49422. for (var name in names) {
  49423. dests[name] = fetchDestination(names[name]);
  49424. }
  49425. }
  49426. return shadow(this, 'destinations', dests);
  49427. },
  49428. getDestination: function Catalog_getDestination(destinationId) {
  49429. function fetchDestination(dest) {
  49430. return isDict(dest) ? dest.get('D') : dest;
  49431. }
  49432. var xref = this.xref;
  49433. var dest = null, nameTreeRef, nameDictionaryRef;
  49434. var obj = this.catDict.get('Names');
  49435. if (obj && obj.has('Dests')) {
  49436. nameTreeRef = obj.getRaw('Dests');
  49437. } else if (this.catDict.has('Dests')) {
  49438. nameDictionaryRef = this.catDict.get('Dests');
  49439. }
  49440. if (nameDictionaryRef) {
  49441. var value = nameDictionaryRef.get(destinationId);
  49442. if (value) {
  49443. dest = fetchDestination(value);
  49444. }
  49445. }
  49446. if (nameTreeRef) {
  49447. var nameTree = new NameTree(nameTreeRef, xref);
  49448. dest = fetchDestination(nameTree.get(destinationId));
  49449. }
  49450. return dest;
  49451. },
  49452. get pageLabels() {
  49453. var obj = null;
  49454. try {
  49455. obj = this.readPageLabels();
  49456. } catch (ex) {
  49457. if (ex instanceof MissingDataException) {
  49458. throw ex;
  49459. }
  49460. warn('Unable to read page labels.');
  49461. }
  49462. return shadow(this, 'pageLabels', obj);
  49463. },
  49464. readPageLabels: function Catalog_readPageLabels() {
  49465. var obj = this.catDict.getRaw('PageLabels');
  49466. if (!obj) {
  49467. return null;
  49468. }
  49469. var pageLabels = new Array(this.numPages);
  49470. var style = null;
  49471. var prefix = '';
  49472. var numberTree = new NumberTree(obj, this.xref);
  49473. var nums = numberTree.getAll();
  49474. var currentLabel = '', currentIndex = 1;
  49475. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49476. if (i in nums) {
  49477. var labelDict = nums[i];
  49478. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49479. var type = labelDict.get('Type');
  49480. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49481. var s = labelDict.get('S');
  49482. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49483. style = s ? s.name : null;
  49484. var p = labelDict.get('P');
  49485. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49486. prefix = p ? stringToPDFString(p) : '';
  49487. var st = labelDict.get('St');
  49488. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49489. currentIndex = st || 1;
  49490. }
  49491. switch (style) {
  49492. case 'D':
  49493. currentLabel = currentIndex;
  49494. break;
  49495. case 'R':
  49496. case 'r':
  49497. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49498. break;
  49499. case 'A':
  49500. case 'a':
  49501. var LIMIT = 26;
  49502. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49503. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49504. var letterIndex = currentIndex - 1;
  49505. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49506. var charBuf = [];
  49507. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49508. charBuf.push(character);
  49509. }
  49510. currentLabel = charBuf.join('');
  49511. break;
  49512. default:
  49513. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49514. }
  49515. pageLabels[i] = prefix + currentLabel;
  49516. currentLabel = '';
  49517. currentIndex++;
  49518. }
  49519. return pageLabels;
  49520. },
  49521. get attachments() {
  49522. var xref = this.xref;
  49523. var attachments = null, nameTreeRef;
  49524. var obj = this.catDict.get('Names');
  49525. if (obj) {
  49526. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49527. }
  49528. if (nameTreeRef) {
  49529. var nameTree = new NameTree(nameTreeRef, xref);
  49530. var names = nameTree.getAll();
  49531. for (var name in names) {
  49532. var fs = new FileSpec(names[name], xref);
  49533. if (!attachments) {
  49534. attachments = Object.create(null);
  49535. }
  49536. attachments[stringToPDFString(name)] = fs.serializable;
  49537. }
  49538. }
  49539. return shadow(this, 'attachments', attachments);
  49540. },
  49541. get javaScript() {
  49542. var xref = this.xref;
  49543. var obj = this.catDict.get('Names');
  49544. var javaScript = [];
  49545. function appendIfJavaScriptDict(jsDict) {
  49546. var type = jsDict.get('S');
  49547. if (!isName(type, 'JavaScript')) {
  49548. return;
  49549. }
  49550. var js = jsDict.get('JS');
  49551. if (isStream(js)) {
  49552. js = bytesToString(js.getBytes());
  49553. } else if (!isString(js)) {
  49554. return;
  49555. }
  49556. javaScript.push(stringToPDFString(js));
  49557. }
  49558. if (obj && obj.has('JavaScript')) {
  49559. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49560. var names = nameTree.getAll();
  49561. for (var name in names) {
  49562. var jsDict = names[name];
  49563. if (isDict(jsDict)) {
  49564. appendIfJavaScriptDict(jsDict);
  49565. }
  49566. }
  49567. }
  49568. var openactionDict = this.catDict.get('OpenAction');
  49569. if (isDict(openactionDict, 'Action')) {
  49570. var actionType = openactionDict.get('S');
  49571. if (isName(actionType, 'Named')) {
  49572. var action = openactionDict.get('N');
  49573. if (isName(action, 'Print')) {
  49574. javaScript.push('print({});');
  49575. }
  49576. } else {
  49577. appendIfJavaScriptDict(openactionDict);
  49578. }
  49579. }
  49580. return shadow(this, 'javaScript', javaScript);
  49581. },
  49582. cleanup: function Catalog_cleanup() {
  49583. var promises = [];
  49584. this.fontCache.forEach(function (promise) {
  49585. promises.push(promise);
  49586. });
  49587. return Promise.all(promises).then(function (translatedFonts) {
  49588. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49589. var font = translatedFonts[i].dict;
  49590. delete font.translated;
  49591. }
  49592. this.fontCache.clear();
  49593. }.bind(this));
  49594. },
  49595. getPage: function Catalog_getPage(pageIndex) {
  49596. if (!(pageIndex in this.pagePromises)) {
  49597. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49598. var dict = a[0];
  49599. var ref = a[1];
  49600. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49601. }.bind(this));
  49602. }
  49603. return this.pagePromises[pageIndex];
  49604. },
  49605. getPageDict: function Catalog_getPageDict(pageIndex) {
  49606. var capability = createPromiseCapability();
  49607. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49608. var currentPageIndex = 0;
  49609. var xref = this.xref;
  49610. var checkAllKids = false;
  49611. function next() {
  49612. while (nodesToVisit.length) {
  49613. var currentNode = nodesToVisit.pop();
  49614. if (isRef(currentNode)) {
  49615. xref.fetchAsync(currentNode).then(function (obj) {
  49616. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49617. if (pageIndex === currentPageIndex) {
  49618. capability.resolve([
  49619. obj,
  49620. currentNode
  49621. ]);
  49622. } else {
  49623. currentPageIndex++;
  49624. next();
  49625. }
  49626. return;
  49627. }
  49628. nodesToVisit.push(obj);
  49629. next();
  49630. }, capability.reject);
  49631. return;
  49632. }
  49633. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49634. var count = currentNode.get('Count');
  49635. if (count === 0) {
  49636. checkAllKids = true;
  49637. }
  49638. if (currentPageIndex + count <= pageIndex) {
  49639. currentPageIndex += count;
  49640. continue;
  49641. }
  49642. var kids = currentNode.get('Kids');
  49643. assert(isArray(kids), 'page dictionary kids object is not an array');
  49644. if (!checkAllKids && count === kids.length) {
  49645. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49646. currentPageIndex = pageIndex;
  49647. continue;
  49648. } else {
  49649. for (var last = kids.length - 1; last >= 0; last--) {
  49650. nodesToVisit.push(kids[last]);
  49651. }
  49652. }
  49653. }
  49654. capability.reject('Page index ' + pageIndex + ' not found.');
  49655. }
  49656. next();
  49657. return capability.promise;
  49658. },
  49659. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49660. var xref = this.xref;
  49661. function pagesBeforeRef(kidRef) {
  49662. var total = 0;
  49663. var parentRef;
  49664. return xref.fetchAsync(kidRef).then(function (node) {
  49665. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49666. throw new Error('The reference does not point to a /Page Dict.');
  49667. }
  49668. if (!node) {
  49669. return null;
  49670. }
  49671. assert(isDict(node), 'node must be a Dict.');
  49672. parentRef = node.getRaw('Parent');
  49673. return node.getAsync('Parent');
  49674. }).then(function (parent) {
  49675. if (!parent) {
  49676. return null;
  49677. }
  49678. assert(isDict(parent), 'parent must be a Dict.');
  49679. return parent.getAsync('Kids');
  49680. }).then(function (kids) {
  49681. if (!kids) {
  49682. return null;
  49683. }
  49684. var kidPromises = [];
  49685. var found = false;
  49686. for (var i = 0; i < kids.length; i++) {
  49687. var kid = kids[i];
  49688. assert(isRef(kid), 'kid must be a Ref.');
  49689. if (kid.num === kidRef.num) {
  49690. found = true;
  49691. break;
  49692. }
  49693. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49694. if (kid.has('Count')) {
  49695. var count = kid.get('Count');
  49696. total += count;
  49697. } else {
  49698. total++;
  49699. }
  49700. }));
  49701. }
  49702. if (!found) {
  49703. error('kid ref not found in parents kids');
  49704. }
  49705. return Promise.all(kidPromises).then(function () {
  49706. return [
  49707. total,
  49708. parentRef
  49709. ];
  49710. });
  49711. });
  49712. }
  49713. var total = 0;
  49714. function next(ref) {
  49715. return pagesBeforeRef(ref).then(function (args) {
  49716. if (!args) {
  49717. return total;
  49718. }
  49719. var count = args[0];
  49720. var parentRef = args[1];
  49721. total += count;
  49722. return next(parentRef);
  49723. });
  49724. }
  49725. return next(pageRef);
  49726. }
  49727. };
  49728. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49729. function addDefaultProtocolToUrl(url) {
  49730. if (url.indexOf('www.') === 0) {
  49731. return 'http://' + url;
  49732. }
  49733. return url;
  49734. }
  49735. function tryConvertUrlEncoding(url) {
  49736. try {
  49737. return stringToUTF8String(url);
  49738. } catch (e) {
  49739. return url;
  49740. }
  49741. }
  49742. var destDict = params.destDict;
  49743. if (!isDict(destDict)) {
  49744. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49745. return;
  49746. }
  49747. var resultObj = params.resultObj;
  49748. if (typeof resultObj !== 'object') {
  49749. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49750. return;
  49751. }
  49752. var docBaseUrl = params.docBaseUrl || null;
  49753. var action = destDict.get('A'), url, dest;
  49754. if (isDict(action)) {
  49755. var linkType = action.get('S').name;
  49756. switch (linkType) {
  49757. case 'URI':
  49758. url = action.get('URI');
  49759. if (isName(url)) {
  49760. url = '/' + url.name;
  49761. } else if (isString(url)) {
  49762. url = addDefaultProtocolToUrl(url);
  49763. }
  49764. break;
  49765. case 'GoTo':
  49766. dest = action.get('D');
  49767. break;
  49768. case 'Launch':
  49769. case 'GoToR':
  49770. var urlDict = action.get('F');
  49771. if (isDict(urlDict)) {
  49772. url = urlDict.get('F') || null;
  49773. } else if (isString(urlDict)) {
  49774. url = urlDict;
  49775. }
  49776. var remoteDest = action.get('D');
  49777. if (remoteDest) {
  49778. if (isName(remoteDest)) {
  49779. remoteDest = remoteDest.name;
  49780. }
  49781. if (isString(url)) {
  49782. var baseUrl = url.split('#')[0];
  49783. if (isString(remoteDest)) {
  49784. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49785. } else if (isArray(remoteDest)) {
  49786. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49787. }
  49788. }
  49789. }
  49790. var newWindow = action.get('NewWindow');
  49791. if (isBool(newWindow)) {
  49792. resultObj.newWindow = newWindow;
  49793. }
  49794. break;
  49795. case 'Named':
  49796. var namedAction = action.get('N');
  49797. if (isName(namedAction)) {
  49798. resultObj.action = namedAction.name;
  49799. }
  49800. break;
  49801. case 'JavaScript':
  49802. var jsAction = action.get('JS'), js;
  49803. if (isStream(jsAction)) {
  49804. js = bytesToString(jsAction.getBytes());
  49805. } else if (isString(jsAction)) {
  49806. js = jsAction;
  49807. }
  49808. if (js) {
  49809. var URL_OPEN_METHODS = [
  49810. 'app.launchURL',
  49811. 'window.open'
  49812. ];
  49813. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49814. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49815. if (jsUrl && jsUrl[1]) {
  49816. url = jsUrl[1];
  49817. break;
  49818. }
  49819. }
  49820. default:
  49821. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49822. break;
  49823. }
  49824. } else if (destDict.has('Dest')) {
  49825. dest = destDict.get('Dest');
  49826. }
  49827. if (isString(url)) {
  49828. url = tryConvertUrlEncoding(url);
  49829. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49830. if (absoluteUrl) {
  49831. resultObj.url = absoluteUrl.href;
  49832. }
  49833. resultObj.unsafeUrl = url;
  49834. }
  49835. if (dest) {
  49836. if (isName(dest)) {
  49837. dest = dest.name;
  49838. }
  49839. if (isString(dest) || isArray(dest)) {
  49840. resultObj.dest = dest;
  49841. }
  49842. }
  49843. };
  49844. return Catalog;
  49845. }();
  49846. var XRef = function XRefClosure() {
  49847. function XRef(stream, password) {
  49848. this.stream = stream;
  49849. this.entries = [];
  49850. this.xrefstms = Object.create(null);
  49851. this.cache = [];
  49852. this.password = password;
  49853. this.stats = {
  49854. streamTypes: [],
  49855. fontTypes: []
  49856. };
  49857. }
  49858. XRef.prototype = {
  49859. setStartXRef: function XRef_setStartXRef(startXRef) {
  49860. this.startXRefQueue = [startXRef];
  49861. },
  49862. parse: function XRef_parse(recoveryMode) {
  49863. var trailerDict;
  49864. if (!recoveryMode) {
  49865. trailerDict = this.readXRef();
  49866. } else {
  49867. warn('Indexing all PDF objects');
  49868. trailerDict = this.indexObjects();
  49869. }
  49870. trailerDict.assignXref(this);
  49871. this.trailer = trailerDict;
  49872. var encrypt = trailerDict.get('Encrypt');
  49873. if (encrypt) {
  49874. var ids = trailerDict.get('ID');
  49875. var fileId = ids && ids.length ? ids[0] : '';
  49876. encrypt.suppressEncryption = true;
  49877. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  49878. }
  49879. if (!(this.root = trailerDict.get('Root'))) {
  49880. error('Invalid root reference');
  49881. }
  49882. },
  49883. processXRefTable: function XRef_processXRefTable(parser) {
  49884. if (!('tableState' in this)) {
  49885. this.tableState = {
  49886. entryNum: 0,
  49887. streamPos: parser.lexer.stream.pos,
  49888. parserBuf1: parser.buf1,
  49889. parserBuf2: parser.buf2
  49890. };
  49891. }
  49892. var obj = this.readXRefTable(parser);
  49893. if (!isCmd(obj, 'trailer')) {
  49894. error('Invalid XRef table: could not find trailer dictionary');
  49895. }
  49896. var dict = parser.getObj();
  49897. if (!isDict(dict) && dict.dict) {
  49898. dict = dict.dict;
  49899. }
  49900. if (!isDict(dict)) {
  49901. error('Invalid XRef table: could not parse trailer dictionary');
  49902. }
  49903. delete this.tableState;
  49904. return dict;
  49905. },
  49906. readXRefTable: function XRef_readXRefTable(parser) {
  49907. var stream = parser.lexer.stream;
  49908. var tableState = this.tableState;
  49909. stream.pos = tableState.streamPos;
  49910. parser.buf1 = tableState.parserBuf1;
  49911. parser.buf2 = tableState.parserBuf2;
  49912. var obj;
  49913. while (true) {
  49914. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  49915. if (isCmd(obj = parser.getObj(), 'trailer')) {
  49916. break;
  49917. }
  49918. tableState.firstEntryNum = obj;
  49919. tableState.entryCount = parser.getObj();
  49920. }
  49921. var first = tableState.firstEntryNum;
  49922. var count = tableState.entryCount;
  49923. if (!isInt(first) || !isInt(count)) {
  49924. error('Invalid XRef table: wrong types in subsection header');
  49925. }
  49926. for (var i = tableState.entryNum; i < count; i++) {
  49927. tableState.streamPos = stream.pos;
  49928. tableState.entryNum = i;
  49929. tableState.parserBuf1 = parser.buf1;
  49930. tableState.parserBuf2 = parser.buf2;
  49931. var entry = {};
  49932. entry.offset = parser.getObj();
  49933. entry.gen = parser.getObj();
  49934. var type = parser.getObj();
  49935. if (isCmd(type, 'f')) {
  49936. entry.free = true;
  49937. } else if (isCmd(type, 'n')) {
  49938. entry.uncompressed = true;
  49939. }
  49940. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  49941. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  49942. }
  49943. if (i === 0 && entry.free && first === 1) {
  49944. first = 0;
  49945. }
  49946. if (!this.entries[i + first]) {
  49947. this.entries[i + first] = entry;
  49948. }
  49949. }
  49950. tableState.entryNum = 0;
  49951. tableState.streamPos = stream.pos;
  49952. tableState.parserBuf1 = parser.buf1;
  49953. tableState.parserBuf2 = parser.buf2;
  49954. delete tableState.firstEntryNum;
  49955. delete tableState.entryCount;
  49956. }
  49957. if (this.entries[0] && !this.entries[0].free) {
  49958. error('Invalid XRef table: unexpected first object');
  49959. }
  49960. return obj;
  49961. },
  49962. processXRefStream: function XRef_processXRefStream(stream) {
  49963. if (!('streamState' in this)) {
  49964. var streamParameters = stream.dict;
  49965. var byteWidths = streamParameters.get('W');
  49966. var range = streamParameters.get('Index');
  49967. if (!range) {
  49968. range = [
  49969. 0,
  49970. streamParameters.get('Size')
  49971. ];
  49972. }
  49973. this.streamState = {
  49974. entryRanges: range,
  49975. byteWidths: byteWidths,
  49976. entryNum: 0,
  49977. streamPos: stream.pos
  49978. };
  49979. }
  49980. this.readXRefStream(stream);
  49981. delete this.streamState;
  49982. return stream.dict;
  49983. },
  49984. readXRefStream: function XRef_readXRefStream(stream) {
  49985. var i, j;
  49986. var streamState = this.streamState;
  49987. stream.pos = streamState.streamPos;
  49988. var byteWidths = streamState.byteWidths;
  49989. var typeFieldWidth = byteWidths[0];
  49990. var offsetFieldWidth = byteWidths[1];
  49991. var generationFieldWidth = byteWidths[2];
  49992. var entryRanges = streamState.entryRanges;
  49993. while (entryRanges.length > 0) {
  49994. var first = entryRanges[0];
  49995. var n = entryRanges[1];
  49996. if (!isInt(first) || !isInt(n)) {
  49997. error('Invalid XRef range fields: ' + first + ', ' + n);
  49998. }
  49999. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  50000. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  50001. }
  50002. for (i = streamState.entryNum; i < n; ++i) {
  50003. streamState.entryNum = i;
  50004. streamState.streamPos = stream.pos;
  50005. var type = 0, offset = 0, generation = 0;
  50006. for (j = 0; j < typeFieldWidth; ++j) {
  50007. type = type << 8 | stream.getByte();
  50008. }
  50009. if (typeFieldWidth === 0) {
  50010. type = 1;
  50011. }
  50012. for (j = 0; j < offsetFieldWidth; ++j) {
  50013. offset = offset << 8 | stream.getByte();
  50014. }
  50015. for (j = 0; j < generationFieldWidth; ++j) {
  50016. generation = generation << 8 | stream.getByte();
  50017. }
  50018. var entry = {};
  50019. entry.offset = offset;
  50020. entry.gen = generation;
  50021. switch (type) {
  50022. case 0:
  50023. entry.free = true;
  50024. break;
  50025. case 1:
  50026. entry.uncompressed = true;
  50027. break;
  50028. case 2:
  50029. break;
  50030. default:
  50031. error('Invalid XRef entry type: ' + type);
  50032. }
  50033. if (!this.entries[first + i]) {
  50034. this.entries[first + i] = entry;
  50035. }
  50036. }
  50037. streamState.entryNum = 0;
  50038. streamState.streamPos = stream.pos;
  50039. entryRanges.splice(0, 2);
  50040. }
  50041. },
  50042. indexObjects: function XRef_indexObjects() {
  50043. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50044. var PERCENT = 0x25, LT = 0x3C;
  50045. function readToken(data, offset) {
  50046. var token = '', ch = data[offset];
  50047. while (ch !== LF && ch !== CR && ch !== LT) {
  50048. if (++offset >= data.length) {
  50049. break;
  50050. }
  50051. token += String.fromCharCode(ch);
  50052. ch = data[offset];
  50053. }
  50054. return token;
  50055. }
  50056. function skipUntil(data, offset, what) {
  50057. var length = what.length, dataLength = data.length;
  50058. var skipped = 0;
  50059. while (offset < dataLength) {
  50060. var i = 0;
  50061. while (i < length && data[offset + i] === what[i]) {
  50062. ++i;
  50063. }
  50064. if (i >= length) {
  50065. break;
  50066. }
  50067. offset++;
  50068. skipped++;
  50069. }
  50070. return skipped;
  50071. }
  50072. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50073. var trailerBytes = new Uint8Array([
  50074. 116,
  50075. 114,
  50076. 97,
  50077. 105,
  50078. 108,
  50079. 101,
  50080. 114
  50081. ]);
  50082. var startxrefBytes = new Uint8Array([
  50083. 115,
  50084. 116,
  50085. 97,
  50086. 114,
  50087. 116,
  50088. 120,
  50089. 114,
  50090. 101,
  50091. 102
  50092. ]);
  50093. var endobjBytes = new Uint8Array([
  50094. 101,
  50095. 110,
  50096. 100,
  50097. 111,
  50098. 98,
  50099. 106
  50100. ]);
  50101. var xrefBytes = new Uint8Array([
  50102. 47,
  50103. 88,
  50104. 82,
  50105. 101,
  50106. 102
  50107. ]);
  50108. this.entries.length = 0;
  50109. var stream = this.stream;
  50110. stream.pos = 0;
  50111. var buffer = stream.getBytes();
  50112. var position = stream.start, length = buffer.length;
  50113. var trailers = [], xrefStms = [];
  50114. while (position < length) {
  50115. var ch = buffer[position];
  50116. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50117. ++position;
  50118. continue;
  50119. }
  50120. if (ch === PERCENT) {
  50121. do {
  50122. ++position;
  50123. if (position >= length) {
  50124. break;
  50125. }
  50126. ch = buffer[position];
  50127. } while (ch !== LF && ch !== CR);
  50128. continue;
  50129. }
  50130. var token = readToken(buffer, position);
  50131. var m;
  50132. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50133. position += skipUntil(buffer, position, trailerBytes);
  50134. trailers.push(position);
  50135. position += skipUntil(buffer, position, startxrefBytes);
  50136. } else if (m = objRegExp.exec(token)) {
  50137. if (typeof this.entries[m[1]] === 'undefined') {
  50138. this.entries[m[1]] = {
  50139. offset: position - stream.start,
  50140. gen: m[2] | 0,
  50141. uncompressed: true
  50142. };
  50143. }
  50144. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50145. var content = buffer.subarray(position, position + contentLength);
  50146. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50147. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50148. xrefStms.push(position - stream.start);
  50149. this.xrefstms[position - stream.start] = 1;
  50150. }
  50151. position += contentLength;
  50152. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50153. trailers.push(position);
  50154. position += skipUntil(buffer, position, startxrefBytes);
  50155. } else {
  50156. position += token.length + 1;
  50157. }
  50158. }
  50159. var i, ii;
  50160. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50161. this.startXRefQueue.push(xrefStms[i]);
  50162. this.readXRef(true);
  50163. }
  50164. var dict;
  50165. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50166. stream.pos = trailers[i];
  50167. var parser = new Parser(new Lexer(stream), true, this, true);
  50168. var obj = parser.getObj();
  50169. if (!isCmd(obj, 'trailer')) {
  50170. continue;
  50171. }
  50172. dict = parser.getObj();
  50173. if (!isDict(dict)) {
  50174. continue;
  50175. }
  50176. if (dict.has('ID')) {
  50177. return dict;
  50178. }
  50179. }
  50180. if (dict) {
  50181. return dict;
  50182. }
  50183. throw new InvalidPDFException('Invalid PDF structure');
  50184. },
  50185. readXRef: function XRef_readXRef(recoveryMode) {
  50186. var stream = this.stream;
  50187. try {
  50188. while (this.startXRefQueue.length) {
  50189. var startXRef = this.startXRefQueue[0];
  50190. stream.pos = startXRef + stream.start;
  50191. var parser = new Parser(new Lexer(stream), true, this);
  50192. var obj = parser.getObj();
  50193. var dict;
  50194. if (isCmd(obj, 'xref')) {
  50195. dict = this.processXRefTable(parser);
  50196. if (!this.topDict) {
  50197. this.topDict = dict;
  50198. }
  50199. obj = dict.get('XRefStm');
  50200. if (isInt(obj)) {
  50201. var pos = obj;
  50202. if (!(pos in this.xrefstms)) {
  50203. this.xrefstms[pos] = 1;
  50204. this.startXRefQueue.push(pos);
  50205. }
  50206. }
  50207. } else if (isInt(obj)) {
  50208. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50209. error('Invalid XRef stream');
  50210. }
  50211. dict = this.processXRefStream(obj);
  50212. if (!this.topDict) {
  50213. this.topDict = dict;
  50214. }
  50215. if (!dict) {
  50216. error('Failed to read XRef stream');
  50217. }
  50218. } else {
  50219. error('Invalid XRef stream header');
  50220. }
  50221. obj = dict.get('Prev');
  50222. if (isInt(obj)) {
  50223. this.startXRefQueue.push(obj);
  50224. } else if (isRef(obj)) {
  50225. this.startXRefQueue.push(obj.num);
  50226. }
  50227. this.startXRefQueue.shift();
  50228. }
  50229. return this.topDict;
  50230. } catch (e) {
  50231. if (e instanceof MissingDataException) {
  50232. throw e;
  50233. }
  50234. info('(while reading XRef): ' + e);
  50235. }
  50236. if (recoveryMode) {
  50237. return;
  50238. }
  50239. throw new XRefParseException();
  50240. },
  50241. getEntry: function XRef_getEntry(i) {
  50242. var xrefEntry = this.entries[i];
  50243. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50244. return xrefEntry;
  50245. }
  50246. return null;
  50247. },
  50248. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50249. if (!isRef(obj)) {
  50250. return obj;
  50251. }
  50252. return this.fetch(obj, suppressEncryption);
  50253. },
  50254. fetch: function XRef_fetch(ref, suppressEncryption) {
  50255. assert(isRef(ref), 'ref object is not a reference');
  50256. var num = ref.num;
  50257. if (num in this.cache) {
  50258. var cacheEntry = this.cache[num];
  50259. return cacheEntry;
  50260. }
  50261. var xrefEntry = this.getEntry(num);
  50262. if (xrefEntry === null) {
  50263. return this.cache[num] = null;
  50264. }
  50265. if (xrefEntry.uncompressed) {
  50266. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50267. } else {
  50268. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50269. }
  50270. if (isDict(xrefEntry)) {
  50271. xrefEntry.objId = ref.toString();
  50272. } else if (isStream(xrefEntry)) {
  50273. xrefEntry.dict.objId = ref.toString();
  50274. }
  50275. return xrefEntry;
  50276. },
  50277. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50278. var gen = ref.gen;
  50279. var num = ref.num;
  50280. if (xrefEntry.gen !== gen) {
  50281. error('inconsistent generation in XRef');
  50282. }
  50283. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50284. var parser = new Parser(new Lexer(stream), true, this);
  50285. var obj1 = parser.getObj();
  50286. var obj2 = parser.getObj();
  50287. var obj3 = parser.getObj();
  50288. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50289. error('bad XRef entry');
  50290. }
  50291. if (!isCmd(obj3, 'obj')) {
  50292. if (obj3.cmd.indexOf('obj') === 0) {
  50293. num = parseInt(obj3.cmd.substring(3), 10);
  50294. if (!isNaN(num)) {
  50295. return num;
  50296. }
  50297. }
  50298. error('bad XRef entry');
  50299. }
  50300. if (this.encrypt && !suppressEncryption) {
  50301. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50302. } else {
  50303. xrefEntry = parser.getObj();
  50304. }
  50305. if (!isStream(xrefEntry)) {
  50306. this.cache[num] = xrefEntry;
  50307. }
  50308. return xrefEntry;
  50309. },
  50310. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50311. var tableOffset = xrefEntry.offset;
  50312. var stream = this.fetch(new Ref(tableOffset, 0));
  50313. if (!isStream(stream)) {
  50314. error('bad ObjStm stream');
  50315. }
  50316. var first = stream.dict.get('First');
  50317. var n = stream.dict.get('N');
  50318. if (!isInt(first) || !isInt(n)) {
  50319. error('invalid first and n parameters for ObjStm stream');
  50320. }
  50321. var parser = new Parser(new Lexer(stream), false, this);
  50322. parser.allowStreams = true;
  50323. var i, entries = [], num, nums = [];
  50324. for (i = 0; i < n; ++i) {
  50325. num = parser.getObj();
  50326. if (!isInt(num)) {
  50327. error('invalid object number in the ObjStm stream: ' + num);
  50328. }
  50329. nums.push(num);
  50330. var offset = parser.getObj();
  50331. if (!isInt(offset)) {
  50332. error('invalid object offset in the ObjStm stream: ' + offset);
  50333. }
  50334. }
  50335. for (i = 0; i < n; ++i) {
  50336. entries.push(parser.getObj());
  50337. if (isCmd(parser.buf1, 'endobj')) {
  50338. parser.shift();
  50339. }
  50340. num = nums[i];
  50341. var entry = this.entries[num];
  50342. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50343. this.cache[num] = entries[i];
  50344. }
  50345. }
  50346. xrefEntry = entries[xrefEntry.gen];
  50347. if (xrefEntry === undefined) {
  50348. error('bad XRef entry for compressed object');
  50349. }
  50350. return xrefEntry;
  50351. },
  50352. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50353. if (!isRef(obj)) {
  50354. return Promise.resolve(obj);
  50355. }
  50356. return this.fetchAsync(obj, suppressEncryption);
  50357. },
  50358. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50359. var streamManager = this.stream.manager;
  50360. var xref = this;
  50361. return new Promise(function tryFetch(resolve, reject) {
  50362. try {
  50363. resolve(xref.fetch(ref, suppressEncryption));
  50364. } catch (e) {
  50365. if (e instanceof MissingDataException) {
  50366. streamManager.requestRange(e.begin, e.end).then(function () {
  50367. tryFetch(resolve, reject);
  50368. }, reject);
  50369. return;
  50370. }
  50371. reject(e);
  50372. }
  50373. });
  50374. },
  50375. getCatalogObj: function XRef_getCatalogObj() {
  50376. return this.root;
  50377. }
  50378. };
  50379. return XRef;
  50380. }();
  50381. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50382. function NameOrNumberTree(root, xref) {
  50383. throw new Error('Cannot initialize NameOrNumberTree.');
  50384. }
  50385. NameOrNumberTree.prototype = {
  50386. getAll: function NameOrNumberTree_getAll() {
  50387. var dict = Object.create(null);
  50388. if (!this.root) {
  50389. return dict;
  50390. }
  50391. var xref = this.xref;
  50392. var processed = new RefSet();
  50393. processed.put(this.root);
  50394. var queue = [this.root];
  50395. while (queue.length > 0) {
  50396. var i, n;
  50397. var obj = xref.fetchIfRef(queue.shift());
  50398. if (!isDict(obj)) {
  50399. continue;
  50400. }
  50401. if (obj.has('Kids')) {
  50402. var kids = obj.get('Kids');
  50403. for (i = 0, n = kids.length; i < n; i++) {
  50404. var kid = kids[i];
  50405. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50406. queue.push(kid);
  50407. processed.put(kid);
  50408. }
  50409. continue;
  50410. }
  50411. var entries = obj.get(this._type);
  50412. if (isArray(entries)) {
  50413. for (i = 0, n = entries.length; i < n; i += 2) {
  50414. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50415. }
  50416. }
  50417. }
  50418. return dict;
  50419. },
  50420. get: function NameOrNumberTree_get(key) {
  50421. if (!this.root) {
  50422. return null;
  50423. }
  50424. var xref = this.xref;
  50425. var kidsOrEntries = xref.fetchIfRef(this.root);
  50426. var loopCount = 0;
  50427. var MAX_LEVELS = 10;
  50428. var l, r, m;
  50429. while (kidsOrEntries.has('Kids')) {
  50430. if (++loopCount > MAX_LEVELS) {
  50431. warn('Search depth limit reached for "' + this._type + '" tree.');
  50432. return null;
  50433. }
  50434. var kids = kidsOrEntries.get('Kids');
  50435. if (!isArray(kids)) {
  50436. return null;
  50437. }
  50438. l = 0;
  50439. r = kids.length - 1;
  50440. while (l <= r) {
  50441. m = l + r >> 1;
  50442. var kid = xref.fetchIfRef(kids[m]);
  50443. var limits = kid.get('Limits');
  50444. if (key < xref.fetchIfRef(limits[0])) {
  50445. r = m - 1;
  50446. } else if (key > xref.fetchIfRef(limits[1])) {
  50447. l = m + 1;
  50448. } else {
  50449. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50450. break;
  50451. }
  50452. }
  50453. if (l > r) {
  50454. return null;
  50455. }
  50456. }
  50457. var entries = kidsOrEntries.get(this._type);
  50458. if (isArray(entries)) {
  50459. l = 0;
  50460. r = entries.length - 2;
  50461. while (l <= r) {
  50462. m = l + r & ~1;
  50463. var currentKey = xref.fetchIfRef(entries[m]);
  50464. if (key < currentKey) {
  50465. r = m - 2;
  50466. } else if (key > currentKey) {
  50467. l = m + 2;
  50468. } else {
  50469. return xref.fetchIfRef(entries[m + 1]);
  50470. }
  50471. }
  50472. }
  50473. return null;
  50474. }
  50475. };
  50476. return NameOrNumberTree;
  50477. }();
  50478. var NameTree = function NameTreeClosure() {
  50479. function NameTree(root, xref) {
  50480. this.root = root;
  50481. this.xref = xref;
  50482. this._type = 'Names';
  50483. }
  50484. Util.inherit(NameTree, NameOrNumberTree, {});
  50485. return NameTree;
  50486. }();
  50487. var NumberTree = function NumberTreeClosure() {
  50488. function NumberTree(root, xref) {
  50489. this.root = root;
  50490. this.xref = xref;
  50491. this._type = 'Nums';
  50492. }
  50493. Util.inherit(NumberTree, NameOrNumberTree, {});
  50494. return NumberTree;
  50495. }();
  50496. var FileSpec = function FileSpecClosure() {
  50497. function FileSpec(root, xref) {
  50498. if (!root || !isDict(root)) {
  50499. return;
  50500. }
  50501. this.xref = xref;
  50502. this.root = root;
  50503. if (root.has('FS')) {
  50504. this.fs = root.get('FS');
  50505. }
  50506. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50507. if (root.has('RF')) {
  50508. warn('Related file specifications are not supported');
  50509. }
  50510. this.contentAvailable = true;
  50511. if (!root.has('EF')) {
  50512. this.contentAvailable = false;
  50513. warn('Non-embedded file specifications are not supported');
  50514. }
  50515. }
  50516. function pickPlatformItem(dict) {
  50517. if (dict.has('UF')) {
  50518. return dict.get('UF');
  50519. } else if (dict.has('F')) {
  50520. return dict.get('F');
  50521. } else if (dict.has('Unix')) {
  50522. return dict.get('Unix');
  50523. } else if (dict.has('Mac')) {
  50524. return dict.get('Mac');
  50525. } else if (dict.has('DOS')) {
  50526. return dict.get('DOS');
  50527. } else {
  50528. return null;
  50529. }
  50530. }
  50531. FileSpec.prototype = {
  50532. get filename() {
  50533. if (!this._filename && this.root) {
  50534. var filename = pickPlatformItem(this.root) || 'unnamed';
  50535. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50536. }
  50537. return this._filename;
  50538. },
  50539. get content() {
  50540. if (!this.contentAvailable) {
  50541. return null;
  50542. }
  50543. if (!this.contentRef && this.root) {
  50544. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50545. }
  50546. var content = null;
  50547. if (this.contentRef) {
  50548. var xref = this.xref;
  50549. var fileObj = xref.fetchIfRef(this.contentRef);
  50550. if (fileObj && isStream(fileObj)) {
  50551. content = fileObj.getBytes();
  50552. } else {
  50553. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50554. }
  50555. } else {
  50556. warn('Embedded file specification does not have a content');
  50557. }
  50558. return content;
  50559. },
  50560. get serializable() {
  50561. return {
  50562. filename: this.filename,
  50563. content: this.content
  50564. };
  50565. }
  50566. };
  50567. return FileSpec;
  50568. }();
  50569. var ObjectLoader = function () {
  50570. function mayHaveChildren(value) {
  50571. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50572. }
  50573. function addChildren(node, nodesToVisit) {
  50574. var value;
  50575. if (isDict(node) || isStream(node)) {
  50576. var map;
  50577. if (isDict(node)) {
  50578. map = node.map;
  50579. } else {
  50580. map = node.dict.map;
  50581. }
  50582. for (var key in map) {
  50583. value = map[key];
  50584. if (mayHaveChildren(value)) {
  50585. nodesToVisit.push(value);
  50586. }
  50587. }
  50588. } else if (isArray(node)) {
  50589. for (var i = 0, ii = node.length; i < ii; i++) {
  50590. value = node[i];
  50591. if (mayHaveChildren(value)) {
  50592. nodesToVisit.push(value);
  50593. }
  50594. }
  50595. }
  50596. }
  50597. function ObjectLoader(obj, keys, xref) {
  50598. this.obj = obj;
  50599. this.keys = keys;
  50600. this.xref = xref;
  50601. this.refSet = null;
  50602. this.capability = null;
  50603. }
  50604. ObjectLoader.prototype = {
  50605. load: function ObjectLoader_load() {
  50606. var keys = this.keys;
  50607. this.capability = createPromiseCapability();
  50608. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50609. this.capability.resolve();
  50610. return this.capability.promise;
  50611. }
  50612. this.refSet = new RefSet();
  50613. var nodesToVisit = [];
  50614. for (var i = 0; i < keys.length; i++) {
  50615. nodesToVisit.push(this.obj[keys[i]]);
  50616. }
  50617. this._walk(nodesToVisit);
  50618. return this.capability.promise;
  50619. },
  50620. _walk: function ObjectLoader_walk(nodesToVisit) {
  50621. var nodesToRevisit = [];
  50622. var pendingRequests = [];
  50623. while (nodesToVisit.length) {
  50624. var currentNode = nodesToVisit.pop();
  50625. if (isRef(currentNode)) {
  50626. if (this.refSet.has(currentNode)) {
  50627. continue;
  50628. }
  50629. try {
  50630. var ref = currentNode;
  50631. this.refSet.put(ref);
  50632. currentNode = this.xref.fetch(currentNode);
  50633. } catch (e) {
  50634. if (!(e instanceof MissingDataException)) {
  50635. throw e;
  50636. }
  50637. nodesToRevisit.push(currentNode);
  50638. pendingRequests.push({
  50639. begin: e.begin,
  50640. end: e.end
  50641. });
  50642. }
  50643. }
  50644. if (currentNode && currentNode.getBaseStreams) {
  50645. var baseStreams = currentNode.getBaseStreams();
  50646. var foundMissingData = false;
  50647. for (var i = 0; i < baseStreams.length; i++) {
  50648. var stream = baseStreams[i];
  50649. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50650. foundMissingData = true;
  50651. pendingRequests.push({
  50652. begin: stream.start,
  50653. end: stream.end
  50654. });
  50655. }
  50656. }
  50657. if (foundMissingData) {
  50658. nodesToRevisit.push(currentNode);
  50659. }
  50660. }
  50661. addChildren(currentNode, nodesToVisit);
  50662. }
  50663. if (pendingRequests.length) {
  50664. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50665. nodesToVisit = nodesToRevisit;
  50666. for (var i = 0; i < nodesToRevisit.length; i++) {
  50667. var node = nodesToRevisit[i];
  50668. if (isRef(node)) {
  50669. this.refSet.remove(node);
  50670. }
  50671. }
  50672. this._walk(nodesToVisit);
  50673. }.bind(this), this.capability.reject);
  50674. return;
  50675. }
  50676. this.refSet = null;
  50677. this.capability.resolve();
  50678. }
  50679. };
  50680. return ObjectLoader;
  50681. }();
  50682. exports.Catalog = Catalog;
  50683. exports.ObjectLoader = ObjectLoader;
  50684. exports.XRef = XRef;
  50685. exports.FileSpec = FileSpec;
  50686. }));
  50687. (function (root, factory) {
  50688. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50689. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50690. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50691. var MissingDataException = sharedUtil.MissingDataException;
  50692. var Util = sharedUtil.Util;
  50693. var assert = sharedUtil.assert;
  50694. var error = sharedUtil.error;
  50695. var info = sharedUtil.info;
  50696. var warn = sharedUtil.warn;
  50697. var isStream = corePrimitives.isStream;
  50698. var PDFFunction = coreFunction.PDFFunction;
  50699. var ColorSpace = coreColorSpace.ColorSpace;
  50700. var ShadingType = {
  50701. FUNCTION_BASED: 1,
  50702. AXIAL: 2,
  50703. RADIAL: 3,
  50704. FREE_FORM_MESH: 4,
  50705. LATTICE_FORM_MESH: 5,
  50706. COONS_PATCH_MESH: 6,
  50707. TENSOR_PATCH_MESH: 7
  50708. };
  50709. var Pattern = function PatternClosure() {
  50710. function Pattern() {
  50711. error('should not call Pattern constructor');
  50712. }
  50713. Pattern.prototype = {
  50714. getPattern: function Pattern_getPattern(ctx) {
  50715. error('Should not call Pattern.getStyle: ' + ctx);
  50716. }
  50717. };
  50718. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50719. var dict = isStream(shading) ? shading.dict : shading;
  50720. var type = dict.get('ShadingType');
  50721. try {
  50722. switch (type) {
  50723. case ShadingType.AXIAL:
  50724. case ShadingType.RADIAL:
  50725. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50726. case ShadingType.FREE_FORM_MESH:
  50727. case ShadingType.LATTICE_FORM_MESH:
  50728. case ShadingType.COONS_PATCH_MESH:
  50729. case ShadingType.TENSOR_PATCH_MESH:
  50730. return new Shadings.Mesh(shading, matrix, xref, res);
  50731. default:
  50732. throw new Error('Unsupported ShadingType: ' + type);
  50733. }
  50734. } catch (ex) {
  50735. if (ex instanceof MissingDataException) {
  50736. throw ex;
  50737. }
  50738. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50739. warn(ex);
  50740. return new Shadings.Dummy();
  50741. }
  50742. };
  50743. return Pattern;
  50744. }();
  50745. var Shadings = {};
  50746. Shadings.SMALL_NUMBER = 1e-6;
  50747. Shadings.RadialAxial = function RadialAxialClosure() {
  50748. function RadialAxial(dict, matrix, xref, res) {
  50749. this.matrix = matrix;
  50750. this.coordsArr = dict.getArray('Coords');
  50751. this.shadingType = dict.get('ShadingType');
  50752. this.type = 'Pattern';
  50753. var cs = dict.get('ColorSpace', 'CS');
  50754. cs = ColorSpace.parse(cs, xref, res);
  50755. this.cs = cs;
  50756. var t0 = 0.0, t1 = 1.0;
  50757. if (dict.has('Domain')) {
  50758. var domainArr = dict.getArray('Domain');
  50759. t0 = domainArr[0];
  50760. t1 = domainArr[1];
  50761. }
  50762. var extendStart = false, extendEnd = false;
  50763. if (dict.has('Extend')) {
  50764. var extendArr = dict.getArray('Extend');
  50765. extendStart = extendArr[0];
  50766. extendEnd = extendArr[1];
  50767. }
  50768. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50769. var x1 = this.coordsArr[0];
  50770. var y1 = this.coordsArr[1];
  50771. var r1 = this.coordsArr[2];
  50772. var x2 = this.coordsArr[3];
  50773. var y2 = this.coordsArr[4];
  50774. var r2 = this.coordsArr[5];
  50775. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50776. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50777. warn('Unsupported radial gradient.');
  50778. }
  50779. }
  50780. this.extendStart = extendStart;
  50781. this.extendEnd = extendEnd;
  50782. var fnObj = dict.get('Function');
  50783. var fn = PDFFunction.parseArray(xref, fnObj);
  50784. var diff = t1 - t0;
  50785. var step = diff / 10;
  50786. var colorStops = this.colorStops = [];
  50787. if (t0 >= t1 || step <= 0) {
  50788. info('Bad shading domain.');
  50789. return;
  50790. }
  50791. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50792. var rgbColor;
  50793. for (var i = t0; i <= t1; i += step) {
  50794. ratio[0] = i;
  50795. fn(ratio, 0, color, 0);
  50796. rgbColor = cs.getRgb(color, 0);
  50797. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50798. colorStops.push([
  50799. (i - t0) / diff,
  50800. cssColor
  50801. ]);
  50802. }
  50803. var background = 'transparent';
  50804. if (dict.has('Background')) {
  50805. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50806. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50807. }
  50808. if (!extendStart) {
  50809. colorStops.unshift([
  50810. 0,
  50811. background
  50812. ]);
  50813. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50814. }
  50815. if (!extendEnd) {
  50816. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50817. colorStops.push([
  50818. 1,
  50819. background
  50820. ]);
  50821. }
  50822. this.colorStops = colorStops;
  50823. }
  50824. RadialAxial.prototype = {
  50825. getIR: function RadialAxial_getIR() {
  50826. var coordsArr = this.coordsArr;
  50827. var shadingType = this.shadingType;
  50828. var type, p0, p1, r0, r1;
  50829. if (shadingType === ShadingType.AXIAL) {
  50830. p0 = [
  50831. coordsArr[0],
  50832. coordsArr[1]
  50833. ];
  50834. p1 = [
  50835. coordsArr[2],
  50836. coordsArr[3]
  50837. ];
  50838. r0 = null;
  50839. r1 = null;
  50840. type = 'axial';
  50841. } else if (shadingType === ShadingType.RADIAL) {
  50842. p0 = [
  50843. coordsArr[0],
  50844. coordsArr[1]
  50845. ];
  50846. p1 = [
  50847. coordsArr[3],
  50848. coordsArr[4]
  50849. ];
  50850. r0 = coordsArr[2];
  50851. r1 = coordsArr[5];
  50852. type = 'radial';
  50853. } else {
  50854. error('getPattern type unknown: ' + shadingType);
  50855. }
  50856. var matrix = this.matrix;
  50857. if (matrix) {
  50858. p0 = Util.applyTransform(p0, matrix);
  50859. p1 = Util.applyTransform(p1, matrix);
  50860. if (shadingType === ShadingType.RADIAL) {
  50861. var scale = Util.singularValueDecompose2dScale(matrix);
  50862. r0 *= scale[0];
  50863. r1 *= scale[1];
  50864. }
  50865. }
  50866. return [
  50867. 'RadialAxial',
  50868. type,
  50869. this.colorStops,
  50870. p0,
  50871. p1,
  50872. r0,
  50873. r1
  50874. ];
  50875. }
  50876. };
  50877. return RadialAxial;
  50878. }();
  50879. Shadings.Mesh = function MeshClosure() {
  50880. function MeshStreamReader(stream, context) {
  50881. this.stream = stream;
  50882. this.context = context;
  50883. this.buffer = 0;
  50884. this.bufferLength = 0;
  50885. var numComps = context.numComps;
  50886. this.tmpCompsBuf = new Float32Array(numComps);
  50887. var csNumComps = context.colorSpace.numComps;
  50888. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  50889. }
  50890. MeshStreamReader.prototype = {
  50891. get hasData() {
  50892. if (this.stream.end) {
  50893. return this.stream.pos < this.stream.end;
  50894. }
  50895. if (this.bufferLength > 0) {
  50896. return true;
  50897. }
  50898. var nextByte = this.stream.getByte();
  50899. if (nextByte < 0) {
  50900. return false;
  50901. }
  50902. this.buffer = nextByte;
  50903. this.bufferLength = 8;
  50904. return true;
  50905. },
  50906. readBits: function MeshStreamReader_readBits(n) {
  50907. var buffer = this.buffer;
  50908. var bufferLength = this.bufferLength;
  50909. if (n === 32) {
  50910. if (bufferLength === 0) {
  50911. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  50912. }
  50913. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  50914. var nextByte = this.stream.getByte();
  50915. this.buffer = nextByte & (1 << bufferLength) - 1;
  50916. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  50917. }
  50918. if (n === 8 && bufferLength === 0) {
  50919. return this.stream.getByte();
  50920. }
  50921. while (bufferLength < n) {
  50922. buffer = buffer << 8 | this.stream.getByte();
  50923. bufferLength += 8;
  50924. }
  50925. bufferLength -= n;
  50926. this.bufferLength = bufferLength;
  50927. this.buffer = buffer & (1 << bufferLength) - 1;
  50928. return buffer >> bufferLength;
  50929. },
  50930. align: function MeshStreamReader_align() {
  50931. this.buffer = 0;
  50932. this.bufferLength = 0;
  50933. },
  50934. readFlag: function MeshStreamReader_readFlag() {
  50935. return this.readBits(this.context.bitsPerFlag);
  50936. },
  50937. readCoordinate: function MeshStreamReader_readCoordinate() {
  50938. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  50939. var xi = this.readBits(bitsPerCoordinate);
  50940. var yi = this.readBits(bitsPerCoordinate);
  50941. var decode = this.context.decode;
  50942. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  50943. return [
  50944. xi * scale * (decode[1] - decode[0]) + decode[0],
  50945. yi * scale * (decode[3] - decode[2]) + decode[2]
  50946. ];
  50947. },
  50948. readComponents: function MeshStreamReader_readComponents() {
  50949. var numComps = this.context.numComps;
  50950. var bitsPerComponent = this.context.bitsPerComponent;
  50951. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  50952. var decode = this.context.decode;
  50953. var components = this.tmpCompsBuf;
  50954. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  50955. var ci = this.readBits(bitsPerComponent);
  50956. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  50957. }
  50958. var color = this.tmpCsCompsBuf;
  50959. if (this.context.colorFn) {
  50960. this.context.colorFn(components, 0, color, 0);
  50961. }
  50962. return this.context.colorSpace.getRgb(color, 0);
  50963. }
  50964. };
  50965. function decodeType4Shading(mesh, reader) {
  50966. var coords = mesh.coords;
  50967. var colors = mesh.colors;
  50968. var operators = [];
  50969. var ps = [];
  50970. var verticesLeft = 0;
  50971. while (reader.hasData) {
  50972. var f = reader.readFlag();
  50973. var coord = reader.readCoordinate();
  50974. var color = reader.readComponents();
  50975. if (verticesLeft === 0) {
  50976. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  50977. switch (f) {
  50978. case 0:
  50979. verticesLeft = 3;
  50980. break;
  50981. case 1:
  50982. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  50983. verticesLeft = 1;
  50984. break;
  50985. case 2:
  50986. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  50987. verticesLeft = 1;
  50988. break;
  50989. }
  50990. operators.push(f);
  50991. }
  50992. ps.push(coords.length);
  50993. coords.push(coord);
  50994. colors.push(color);
  50995. verticesLeft--;
  50996. reader.align();
  50997. }
  50998. mesh.figures.push({
  50999. type: 'triangles',
  51000. coords: new Int32Array(ps),
  51001. colors: new Int32Array(ps)
  51002. });
  51003. }
  51004. function decodeType5Shading(mesh, reader, verticesPerRow) {
  51005. var coords = mesh.coords;
  51006. var colors = mesh.colors;
  51007. var ps = [];
  51008. while (reader.hasData) {
  51009. var coord = reader.readCoordinate();
  51010. var color = reader.readComponents();
  51011. ps.push(coords.length);
  51012. coords.push(coord);
  51013. colors.push(color);
  51014. }
  51015. mesh.figures.push({
  51016. type: 'lattice',
  51017. coords: new Int32Array(ps),
  51018. colors: new Int32Array(ps),
  51019. verticesPerRow: verticesPerRow
  51020. });
  51021. }
  51022. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51023. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51024. var TRIANGLE_DENSITY = 20;
  51025. var getB = function getBClosure() {
  51026. function buildB(count) {
  51027. var lut = [];
  51028. for (var i = 0; i <= count; i++) {
  51029. var t = i / count, t_ = 1 - t;
  51030. lut.push(new Float32Array([
  51031. t_ * t_ * t_,
  51032. 3 * t * t_ * t_,
  51033. 3 * t * t * t_,
  51034. t * t * t
  51035. ]));
  51036. }
  51037. return lut;
  51038. }
  51039. var cache = [];
  51040. return function getB(count) {
  51041. if (!cache[count]) {
  51042. cache[count] = buildB(count);
  51043. }
  51044. return cache[count];
  51045. };
  51046. }();
  51047. function buildFigureFromPatch(mesh, index) {
  51048. var figure = mesh.figures[index];
  51049. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51050. var coords = mesh.coords, colors = mesh.colors;
  51051. var pi = figure.coords;
  51052. var ci = figure.colors;
  51053. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51054. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51055. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51056. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51057. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51058. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51059. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51060. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51061. var verticesPerRow = splitXBy + 1;
  51062. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51063. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51064. var k = 0;
  51065. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51066. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51067. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51068. for (var row = 0; row <= splitYBy; row++) {
  51069. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51070. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51071. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51072. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51073. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51074. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51075. for (var col = 0; col <= splitXBy; col++, k++) {
  51076. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51077. continue;
  51078. }
  51079. var x = 0, y = 0;
  51080. var q = 0;
  51081. for (var i = 0; i <= 3; i++) {
  51082. for (var j = 0; j <= 3; j++, q++) {
  51083. var m = bRow[row][i] * bCol[col][j];
  51084. x += coords[pi[q]][0] * m;
  51085. y += coords[pi[q]][1] * m;
  51086. }
  51087. }
  51088. figureCoords[k] = coords.length;
  51089. coords.push([
  51090. x,
  51091. y
  51092. ]);
  51093. figureColors[k] = colors.length;
  51094. var newColor = new Uint8Array(3);
  51095. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51096. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51097. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51098. colors.push(newColor);
  51099. }
  51100. }
  51101. figureCoords[0] = pi[0];
  51102. figureColors[0] = ci[0];
  51103. figureCoords[splitXBy] = pi[3];
  51104. figureColors[splitXBy] = ci[1];
  51105. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51106. figureColors[verticesPerRow * splitYBy] = ci[2];
  51107. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51108. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51109. mesh.figures[index] = {
  51110. type: 'lattice',
  51111. coords: figureCoords,
  51112. colors: figureColors,
  51113. verticesPerRow: verticesPerRow
  51114. };
  51115. }
  51116. function decodeType6Shading(mesh, reader) {
  51117. var coords = mesh.coords;
  51118. var colors = mesh.colors;
  51119. var ps = new Int32Array(16);
  51120. var cs = new Int32Array(4);
  51121. while (reader.hasData) {
  51122. var f = reader.readFlag();
  51123. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51124. var i, ii;
  51125. var pi = coords.length;
  51126. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51127. coords.push(reader.readCoordinate());
  51128. }
  51129. var ci = colors.length;
  51130. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51131. colors.push(reader.readComponents());
  51132. }
  51133. var tmp1, tmp2, tmp3, tmp4;
  51134. switch (f) {
  51135. case 0:
  51136. ps[12] = pi + 3;
  51137. ps[13] = pi + 4;
  51138. ps[14] = pi + 5;
  51139. ps[15] = pi + 6;
  51140. ps[8] = pi + 2;
  51141. ps[11] = pi + 7;
  51142. ps[4] = pi + 1;
  51143. ps[7] = pi + 8;
  51144. ps[0] = pi;
  51145. ps[1] = pi + 11;
  51146. ps[2] = pi + 10;
  51147. ps[3] = pi + 9;
  51148. cs[2] = ci + 1;
  51149. cs[3] = ci + 2;
  51150. cs[0] = ci;
  51151. cs[1] = ci + 3;
  51152. break;
  51153. case 1:
  51154. tmp1 = ps[12];
  51155. tmp2 = ps[13];
  51156. tmp3 = ps[14];
  51157. tmp4 = ps[15];
  51158. ps[12] = tmp4;
  51159. ps[13] = pi + 0;
  51160. ps[14] = pi + 1;
  51161. ps[15] = pi + 2;
  51162. ps[8] = tmp3;
  51163. ps[11] = pi + 3;
  51164. ps[4] = tmp2;
  51165. ps[7] = pi + 4;
  51166. ps[0] = tmp1;
  51167. ps[1] = pi + 7;
  51168. ps[2] = pi + 6;
  51169. ps[3] = pi + 5;
  51170. tmp1 = cs[2];
  51171. tmp2 = cs[3];
  51172. cs[2] = tmp2;
  51173. cs[3] = ci;
  51174. cs[0] = tmp1;
  51175. cs[1] = ci + 1;
  51176. break;
  51177. case 2:
  51178. tmp1 = ps[15];
  51179. tmp2 = ps[11];
  51180. ps[12] = ps[3];
  51181. ps[13] = pi + 0;
  51182. ps[14] = pi + 1;
  51183. ps[15] = pi + 2;
  51184. ps[8] = ps[7];
  51185. ps[11] = pi + 3;
  51186. ps[4] = tmp2;
  51187. ps[7] = pi + 4;
  51188. ps[0] = tmp1;
  51189. ps[1] = pi + 7;
  51190. ps[2] = pi + 6;
  51191. ps[3] = pi + 5;
  51192. tmp1 = cs[3];
  51193. cs[2] = cs[1];
  51194. cs[3] = ci;
  51195. cs[0] = tmp1;
  51196. cs[1] = ci + 1;
  51197. break;
  51198. case 3:
  51199. ps[12] = ps[0];
  51200. ps[13] = pi + 0;
  51201. ps[14] = pi + 1;
  51202. ps[15] = pi + 2;
  51203. ps[8] = ps[1];
  51204. ps[11] = pi + 3;
  51205. ps[4] = ps[2];
  51206. ps[7] = pi + 4;
  51207. ps[0] = ps[3];
  51208. ps[1] = pi + 7;
  51209. ps[2] = pi + 6;
  51210. ps[3] = pi + 5;
  51211. cs[2] = cs[0];
  51212. cs[3] = ci;
  51213. cs[0] = cs[1];
  51214. cs[1] = ci + 1;
  51215. break;
  51216. }
  51217. ps[5] = coords.length;
  51218. coords.push([
  51219. (-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,
  51220. (-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
  51221. ]);
  51222. ps[6] = coords.length;
  51223. coords.push([
  51224. (-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,
  51225. (-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
  51226. ]);
  51227. ps[9] = coords.length;
  51228. coords.push([
  51229. (-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,
  51230. (-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
  51231. ]);
  51232. ps[10] = coords.length;
  51233. coords.push([
  51234. (-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,
  51235. (-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
  51236. ]);
  51237. mesh.figures.push({
  51238. type: 'patch',
  51239. coords: new Int32Array(ps),
  51240. colors: new Int32Array(cs)
  51241. });
  51242. }
  51243. }
  51244. function decodeType7Shading(mesh, reader) {
  51245. var coords = mesh.coords;
  51246. var colors = mesh.colors;
  51247. var ps = new Int32Array(16);
  51248. var cs = new Int32Array(4);
  51249. while (reader.hasData) {
  51250. var f = reader.readFlag();
  51251. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51252. var i, ii;
  51253. var pi = coords.length;
  51254. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51255. coords.push(reader.readCoordinate());
  51256. }
  51257. var ci = colors.length;
  51258. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51259. colors.push(reader.readComponents());
  51260. }
  51261. var tmp1, tmp2, tmp3, tmp4;
  51262. switch (f) {
  51263. case 0:
  51264. ps[12] = pi + 3;
  51265. ps[13] = pi + 4;
  51266. ps[14] = pi + 5;
  51267. ps[15] = pi + 6;
  51268. ps[8] = pi + 2;
  51269. ps[9] = pi + 13;
  51270. ps[10] = pi + 14;
  51271. ps[11] = pi + 7;
  51272. ps[4] = pi + 1;
  51273. ps[5] = pi + 12;
  51274. ps[6] = pi + 15;
  51275. ps[7] = pi + 8;
  51276. ps[0] = pi;
  51277. ps[1] = pi + 11;
  51278. ps[2] = pi + 10;
  51279. ps[3] = pi + 9;
  51280. cs[2] = ci + 1;
  51281. cs[3] = ci + 2;
  51282. cs[0] = ci;
  51283. cs[1] = ci + 3;
  51284. break;
  51285. case 1:
  51286. tmp1 = ps[12];
  51287. tmp2 = ps[13];
  51288. tmp3 = ps[14];
  51289. tmp4 = ps[15];
  51290. ps[12] = tmp4;
  51291. ps[13] = pi + 0;
  51292. ps[14] = pi + 1;
  51293. ps[15] = pi + 2;
  51294. ps[8] = tmp3;
  51295. ps[9] = pi + 9;
  51296. ps[10] = pi + 10;
  51297. ps[11] = pi + 3;
  51298. ps[4] = tmp2;
  51299. ps[5] = pi + 8;
  51300. ps[6] = pi + 11;
  51301. ps[7] = pi + 4;
  51302. ps[0] = tmp1;
  51303. ps[1] = pi + 7;
  51304. ps[2] = pi + 6;
  51305. ps[3] = pi + 5;
  51306. tmp1 = cs[2];
  51307. tmp2 = cs[3];
  51308. cs[2] = tmp2;
  51309. cs[3] = ci;
  51310. cs[0] = tmp1;
  51311. cs[1] = ci + 1;
  51312. break;
  51313. case 2:
  51314. tmp1 = ps[15];
  51315. tmp2 = ps[11];
  51316. ps[12] = ps[3];
  51317. ps[13] = pi + 0;
  51318. ps[14] = pi + 1;
  51319. ps[15] = pi + 2;
  51320. ps[8] = ps[7];
  51321. ps[9] = pi + 9;
  51322. ps[10] = pi + 10;
  51323. ps[11] = pi + 3;
  51324. ps[4] = tmp2;
  51325. ps[5] = pi + 8;
  51326. ps[6] = pi + 11;
  51327. ps[7] = pi + 4;
  51328. ps[0] = tmp1;
  51329. ps[1] = pi + 7;
  51330. ps[2] = pi + 6;
  51331. ps[3] = pi + 5;
  51332. tmp1 = cs[3];
  51333. cs[2] = cs[1];
  51334. cs[3] = ci;
  51335. cs[0] = tmp1;
  51336. cs[1] = ci + 1;
  51337. break;
  51338. case 3:
  51339. ps[12] = ps[0];
  51340. ps[13] = pi + 0;
  51341. ps[14] = pi + 1;
  51342. ps[15] = pi + 2;
  51343. ps[8] = ps[1];
  51344. ps[9] = pi + 9;
  51345. ps[10] = pi + 10;
  51346. ps[11] = pi + 3;
  51347. ps[4] = ps[2];
  51348. ps[5] = pi + 8;
  51349. ps[6] = pi + 11;
  51350. ps[7] = pi + 4;
  51351. ps[0] = ps[3];
  51352. ps[1] = pi + 7;
  51353. ps[2] = pi + 6;
  51354. ps[3] = pi + 5;
  51355. cs[2] = cs[0];
  51356. cs[3] = ci;
  51357. cs[0] = cs[1];
  51358. cs[1] = ci + 1;
  51359. break;
  51360. }
  51361. mesh.figures.push({
  51362. type: 'patch',
  51363. coords: new Int32Array(ps),
  51364. colors: new Int32Array(cs)
  51365. });
  51366. }
  51367. }
  51368. function updateBounds(mesh) {
  51369. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51370. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51371. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51372. minX = minX > x ? x : minX;
  51373. minY = minY > y ? y : minY;
  51374. maxX = maxX < x ? x : maxX;
  51375. maxY = maxY < y ? y : maxY;
  51376. }
  51377. mesh.bounds = [
  51378. minX,
  51379. minY,
  51380. maxX,
  51381. maxY
  51382. ];
  51383. }
  51384. function packData(mesh) {
  51385. var i, ii, j, jj;
  51386. var coords = mesh.coords;
  51387. var coordsPacked = new Float32Array(coords.length * 2);
  51388. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51389. var xy = coords[i];
  51390. coordsPacked[j++] = xy[0];
  51391. coordsPacked[j++] = xy[1];
  51392. }
  51393. mesh.coords = coordsPacked;
  51394. var colors = mesh.colors;
  51395. var colorsPacked = new Uint8Array(colors.length * 3);
  51396. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51397. var c = colors[i];
  51398. colorsPacked[j++] = c[0];
  51399. colorsPacked[j++] = c[1];
  51400. colorsPacked[j++] = c[2];
  51401. }
  51402. mesh.colors = colorsPacked;
  51403. var figures = mesh.figures;
  51404. for (i = 0, ii = figures.length; i < ii; i++) {
  51405. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51406. for (j = 0, jj = ps.length; j < jj; j++) {
  51407. ps[j] *= 2;
  51408. cs[j] *= 3;
  51409. }
  51410. }
  51411. }
  51412. function Mesh(stream, matrix, xref, res) {
  51413. assert(isStream(stream), 'Mesh data is not a stream');
  51414. var dict = stream.dict;
  51415. this.matrix = matrix;
  51416. this.shadingType = dict.get('ShadingType');
  51417. this.type = 'Pattern';
  51418. this.bbox = dict.getArray('BBox');
  51419. var cs = dict.get('ColorSpace', 'CS');
  51420. cs = ColorSpace.parse(cs, xref, res);
  51421. this.cs = cs;
  51422. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51423. var fnObj = dict.get('Function');
  51424. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51425. this.coords = [];
  51426. this.colors = [];
  51427. this.figures = [];
  51428. var decodeContext = {
  51429. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51430. bitsPerComponent: dict.get('BitsPerComponent'),
  51431. bitsPerFlag: dict.get('BitsPerFlag'),
  51432. decode: dict.getArray('Decode'),
  51433. colorFn: fn,
  51434. colorSpace: cs,
  51435. numComps: fn ? 1 : cs.numComps
  51436. };
  51437. var reader = new MeshStreamReader(stream, decodeContext);
  51438. var patchMesh = false;
  51439. switch (this.shadingType) {
  51440. case ShadingType.FREE_FORM_MESH:
  51441. decodeType4Shading(this, reader);
  51442. break;
  51443. case ShadingType.LATTICE_FORM_MESH:
  51444. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51445. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51446. decodeType5Shading(this, reader, verticesPerRow);
  51447. break;
  51448. case ShadingType.COONS_PATCH_MESH:
  51449. decodeType6Shading(this, reader);
  51450. patchMesh = true;
  51451. break;
  51452. case ShadingType.TENSOR_PATCH_MESH:
  51453. decodeType7Shading(this, reader);
  51454. patchMesh = true;
  51455. break;
  51456. default:
  51457. error('Unsupported mesh type.');
  51458. break;
  51459. }
  51460. if (patchMesh) {
  51461. updateBounds(this);
  51462. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51463. buildFigureFromPatch(this, i);
  51464. }
  51465. }
  51466. updateBounds(this);
  51467. packData(this);
  51468. }
  51469. Mesh.prototype = {
  51470. getIR: function Mesh_getIR() {
  51471. return [
  51472. 'Mesh',
  51473. this.shadingType,
  51474. this.coords,
  51475. this.colors,
  51476. this.figures,
  51477. this.bounds,
  51478. this.matrix,
  51479. this.bbox,
  51480. this.background
  51481. ];
  51482. }
  51483. };
  51484. return Mesh;
  51485. }();
  51486. Shadings.Dummy = function DummyClosure() {
  51487. function Dummy() {
  51488. this.type = 'Pattern';
  51489. }
  51490. Dummy.prototype = {
  51491. getIR: function Dummy_getIR() {
  51492. return ['Dummy'];
  51493. }
  51494. };
  51495. return Dummy;
  51496. }();
  51497. function getTilingPatternIR(operatorList, dict, args) {
  51498. var matrix = dict.getArray('Matrix');
  51499. var bbox = dict.getArray('BBox');
  51500. var xstep = dict.get('XStep');
  51501. var ystep = dict.get('YStep');
  51502. var paintType = dict.get('PaintType');
  51503. var tilingType = dict.get('TilingType');
  51504. return [
  51505. 'TilingPattern',
  51506. args,
  51507. operatorList,
  51508. matrix,
  51509. bbox,
  51510. xstep,
  51511. ystep,
  51512. paintType,
  51513. tilingType
  51514. ];
  51515. }
  51516. exports.Pattern = Pattern;
  51517. exports.getTilingPatternIR = getTilingPatternIR;
  51518. }));
  51519. (function (root, factory) {
  51520. factory(root.pdfjsCoreEvaluator = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser, root.pdfjsCoreImage, root.pdfjsCoreColorSpace, root.pdfjsCoreMurmurHash3, root.pdfjsCoreFonts, root.pdfjsCoreFunction, root.pdfjsCorePattern, root.pdfjsCoreCMap, root.pdfjsCoreMetrics, root.pdfjsCoreBidi, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreGlyphList);
  51521. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51522. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51523. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51524. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51525. var ImageKind = sharedUtil.ImageKind;
  51526. var OPS = sharedUtil.OPS;
  51527. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51528. var Util = sharedUtil.Util;
  51529. var assert = sharedUtil.assert;
  51530. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51531. var error = sharedUtil.error;
  51532. var info = sharedUtil.info;
  51533. var isArray = sharedUtil.isArray;
  51534. var isNum = sharedUtil.isNum;
  51535. var isString = sharedUtil.isString;
  51536. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51537. var warn = sharedUtil.warn;
  51538. var Dict = corePrimitives.Dict;
  51539. var Name = corePrimitives.Name;
  51540. var isCmd = corePrimitives.isCmd;
  51541. var isDict = corePrimitives.isDict;
  51542. var isName = corePrimitives.isName;
  51543. var isRef = corePrimitives.isRef;
  51544. var isStream = corePrimitives.isStream;
  51545. var DecodeStream = coreStream.DecodeStream;
  51546. var JpegStream = coreStream.JpegStream;
  51547. var Stream = coreStream.Stream;
  51548. var Lexer = coreParser.Lexer;
  51549. var Parser = coreParser.Parser;
  51550. var isEOF = coreParser.isEOF;
  51551. var PDFImage = coreImage.PDFImage;
  51552. var ColorSpace = coreColorSpace.ColorSpace;
  51553. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51554. var ErrorFont = coreFonts.ErrorFont;
  51555. var FontFlags = coreFonts.FontFlags;
  51556. var Font = coreFonts.Font;
  51557. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51558. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51559. var getFontType = coreFonts.getFontType;
  51560. var isPDFFunction = coreFunction.isPDFFunction;
  51561. var PDFFunction = coreFunction.PDFFunction;
  51562. var Pattern = corePattern.Pattern;
  51563. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51564. var CMapFactory = coreCMap.CMapFactory;
  51565. var IdentityCMap = coreCMap.IdentityCMap;
  51566. var getMetrics = coreMetrics.getMetrics;
  51567. var bidi = coreBidi.bidi;
  51568. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51569. var StandardEncoding = coreEncodings.StandardEncoding;
  51570. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51571. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51572. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51573. var getEncoding = coreEncodings.getEncoding;
  51574. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51575. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51576. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51577. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51578. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51579. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51580. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51581. var PartialEvaluator = function PartialEvaluatorClosure() {
  51582. var DefaultPartialEvaluatorOptions = {
  51583. forceDataSchema: false,
  51584. maxImageSize: -1,
  51585. disableFontFace: false,
  51586. cMapOptions: {
  51587. url: null,
  51588. packed: false
  51589. }
  51590. };
  51591. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51592. this.xref = xref;
  51593. this.resources = resources;
  51594. this.handler = handler;
  51595. this.forceDataSchema = forceDataSchema;
  51596. }
  51597. NativeImageDecoder.prototype = {
  51598. canDecode: function (image) {
  51599. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51600. },
  51601. decode: function (image) {
  51602. var dict = image.dict;
  51603. var colorSpace = dict.get('ColorSpace', 'CS');
  51604. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51605. var numComps = colorSpace.numComps;
  51606. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51607. image.getIR(this.forceDataSchema),
  51608. numComps
  51609. ]);
  51610. return decodePromise.then(function (message) {
  51611. var data = message.data;
  51612. return new Stream(data, 0, data.length, image.dict);
  51613. });
  51614. }
  51615. };
  51616. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51617. var dict = image.dict;
  51618. if (dict.has('DecodeParms') || dict.has('DP')) {
  51619. return false;
  51620. }
  51621. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51622. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51623. };
  51624. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51625. var dict = image.dict;
  51626. if (dict.has('DecodeParms') || dict.has('DP')) {
  51627. return false;
  51628. }
  51629. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51630. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51631. };
  51632. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  51633. this.pdfManager = pdfManager;
  51634. this.xref = xref;
  51635. this.handler = handler;
  51636. this.pageIndex = pageIndex;
  51637. this.uniquePrefix = uniquePrefix;
  51638. this.idCounters = idCounters;
  51639. this.fontCache = fontCache;
  51640. this.options = options || DefaultPartialEvaluatorOptions;
  51641. }
  51642. var TIME_SLOT_DURATION_MS = 20;
  51643. var CHECK_TIME_EVERY = 100;
  51644. function TimeSlotManager() {
  51645. this.reset();
  51646. }
  51647. TimeSlotManager.prototype = {
  51648. check: function TimeSlotManager_check() {
  51649. if (++this.checked < CHECK_TIME_EVERY) {
  51650. return false;
  51651. }
  51652. this.checked = 0;
  51653. return this.endTime <= Date.now();
  51654. },
  51655. reset: function TimeSlotManager_reset() {
  51656. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51657. this.checked = 0;
  51658. }
  51659. };
  51660. var deferred = Promise.resolve();
  51661. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51662. PartialEvaluator.prototype = {
  51663. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51664. if (!isDict(resources)) {
  51665. return false;
  51666. }
  51667. var processed = Object.create(null);
  51668. if (resources.objId) {
  51669. processed[resources.objId] = true;
  51670. }
  51671. var nodes = [resources], xref = this.xref;
  51672. while (nodes.length) {
  51673. var key, i, ii;
  51674. var node = nodes.shift();
  51675. var graphicStates = node.get('ExtGState');
  51676. if (isDict(graphicStates)) {
  51677. var graphicStatesKeys = graphicStates.getKeys();
  51678. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51679. key = graphicStatesKeys[i];
  51680. var graphicState = graphicStates.get(key);
  51681. var bm = graphicState.get('BM');
  51682. if (isName(bm) && bm.name !== 'Normal') {
  51683. return true;
  51684. }
  51685. }
  51686. }
  51687. var xObjects = node.get('XObject');
  51688. if (!isDict(xObjects)) {
  51689. continue;
  51690. }
  51691. var xObjectsKeys = xObjects.getKeys();
  51692. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51693. key = xObjectsKeys[i];
  51694. var xObject = xObjects.getRaw(key);
  51695. if (isRef(xObject)) {
  51696. if (processed[xObject.toString()]) {
  51697. continue;
  51698. }
  51699. xObject = xref.fetch(xObject);
  51700. }
  51701. if (!isStream(xObject)) {
  51702. continue;
  51703. }
  51704. if (xObject.dict.objId) {
  51705. if (processed[xObject.dict.objId]) {
  51706. continue;
  51707. }
  51708. processed[xObject.dict.objId] = true;
  51709. }
  51710. var xResources = xObject.dict.get('Resources');
  51711. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51712. nodes.push(xResources);
  51713. if (xResources.objId) {
  51714. processed[xResources.objId] = true;
  51715. }
  51716. }
  51717. }
  51718. }
  51719. return false;
  51720. },
  51721. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51722. var matrix = xobj.dict.getArray('Matrix');
  51723. var bbox = xobj.dict.getArray('BBox');
  51724. var group = xobj.dict.get('Group');
  51725. if (group) {
  51726. var groupOptions = {
  51727. matrix: matrix,
  51728. bbox: bbox,
  51729. smask: smask,
  51730. isolated: false,
  51731. knockout: false
  51732. };
  51733. var groupSubtype = group.get('S');
  51734. var colorSpace;
  51735. if (isName(groupSubtype, 'Transparency')) {
  51736. groupOptions.isolated = group.get('I') || false;
  51737. groupOptions.knockout = group.get('K') || false;
  51738. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51739. }
  51740. if (smask && smask.backdrop) {
  51741. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51742. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51743. }
  51744. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51745. }
  51746. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51747. matrix,
  51748. bbox
  51749. ]);
  51750. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51751. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51752. if (group) {
  51753. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51754. }
  51755. });
  51756. },
  51757. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51758. var self = this;
  51759. var dict = image.dict;
  51760. var w = dict.get('Width', 'W');
  51761. var h = dict.get('Height', 'H');
  51762. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51763. warn('Image dimensions are missing, or not numbers.');
  51764. return;
  51765. }
  51766. var maxImageSize = this.options.maxImageSize;
  51767. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51768. warn('Image exceeded maximum allowed size and was removed.');
  51769. return;
  51770. }
  51771. var imageMask = dict.get('ImageMask', 'IM') || false;
  51772. var imgData, args;
  51773. if (imageMask) {
  51774. var width = dict.get('Width', 'W');
  51775. var height = dict.get('Height', 'H');
  51776. var bitStrideLength = width + 7 >> 3;
  51777. var imgArray = image.getBytes(bitStrideLength * height);
  51778. var decode = dict.getArray('Decode', 'D');
  51779. var inverseDecode = !!decode && decode[0] > 0;
  51780. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51781. imgData.cached = true;
  51782. args = [imgData];
  51783. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51784. if (cacheKey) {
  51785. imageCache[cacheKey] = {
  51786. fn: OPS.paintImageMaskXObject,
  51787. args: args
  51788. };
  51789. }
  51790. return;
  51791. }
  51792. var softMask = dict.get('SMask', 'SM') || false;
  51793. var mask = dict.get('Mask') || false;
  51794. var SMALL_IMAGE_DIMENSIONS = 200;
  51795. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51796. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51797. imgData = imageObj.createImageData(true);
  51798. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51799. return;
  51800. }
  51801. var uniquePrefix = this.uniquePrefix || '';
  51802. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  51803. operatorList.addDependency(objId);
  51804. args = [
  51805. objId,
  51806. w,
  51807. h
  51808. ];
  51809. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51810. operatorList.addOp(OPS.paintJpegXObject, args);
  51811. this.handler.send('obj', [
  51812. objId,
  51813. this.pageIndex,
  51814. 'JpegStream',
  51815. image.getIR(this.options.forceDataSchema)
  51816. ]);
  51817. return;
  51818. }
  51819. var nativeImageDecoder = null;
  51820. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51821. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51822. }
  51823. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51824. var imgData = imageObj.createImageData(false);
  51825. self.handler.send('obj', [
  51826. objId,
  51827. self.pageIndex,
  51828. 'Image',
  51829. imgData
  51830. ], [imgData.data.buffer]);
  51831. }).then(undefined, function (reason) {
  51832. warn('Unable to decode image: ' + reason);
  51833. self.handler.send('obj', [
  51834. objId,
  51835. self.pageIndex,
  51836. 'Image',
  51837. null
  51838. ]);
  51839. });
  51840. operatorList.addOp(OPS.paintImageXObject, args);
  51841. if (cacheKey) {
  51842. imageCache[cacheKey] = {
  51843. fn: OPS.paintImageXObject,
  51844. args: args
  51845. };
  51846. }
  51847. },
  51848. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51849. var smaskContent = smask.get('G');
  51850. var smaskOptions = {
  51851. subtype: smask.get('S').name,
  51852. backdrop: smask.get('BC')
  51853. };
  51854. var transferObj = smask.get('TR');
  51855. if (isPDFFunction(transferObj)) {
  51856. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51857. var transferMap = new Uint8Array(256);
  51858. var tmp = new Float32Array(1);
  51859. for (var i = 0; i < 256; i++) {
  51860. tmp[0] = i / 255;
  51861. transferFn(tmp, 0, tmp, 0);
  51862. transferMap[i] = tmp[0] * 255 | 0;
  51863. }
  51864. smaskOptions.transferMap = transferMap;
  51865. }
  51866. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  51867. },
  51868. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  51869. var tilingOpList = new OperatorList();
  51870. var resourcesArray = [
  51871. patternDict.get('Resources'),
  51872. resources
  51873. ];
  51874. var patternResources = Dict.merge(this.xref, resourcesArray);
  51875. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  51876. operatorList.addDependencies(tilingOpList.dependencies);
  51877. operatorList.addOp(fn, getTilingPatternIR({
  51878. fnArray: tilingOpList.fnArray,
  51879. argsArray: tilingOpList.argsArray
  51880. }, patternDict, args));
  51881. });
  51882. },
  51883. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  51884. var fontName;
  51885. if (fontArgs) {
  51886. fontArgs = fontArgs.slice();
  51887. fontName = fontArgs[0].name;
  51888. }
  51889. var self = this;
  51890. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  51891. if (!translated.font.isType3Font) {
  51892. return translated;
  51893. }
  51894. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  51895. return translated;
  51896. }, function (reason) {
  51897. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51898. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  51899. });
  51900. }).then(function (translated) {
  51901. state.font = translated.font;
  51902. translated.send(self.handler);
  51903. return translated.loadedName;
  51904. });
  51905. },
  51906. handleText: function PartialEvaluator_handleText(chars, state) {
  51907. var font = state.font;
  51908. var glyphs = font.charsToGlyphs(chars);
  51909. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  51910. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  51911. var buildPath = function (fontChar) {
  51912. if (!font.renderer.hasBuiltPath(fontChar)) {
  51913. var path = font.renderer.getPathJs(fontChar);
  51914. this.handler.send('commonobj', [
  51915. font.loadedName + '_path_' + fontChar,
  51916. 'FontPath',
  51917. path
  51918. ]);
  51919. }
  51920. }.bind(this);
  51921. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  51922. var glyph = glyphs[i];
  51923. buildPath(glyph.fontChar);
  51924. var accent = glyph.accent;
  51925. if (accent && accent.fontChar) {
  51926. buildPath(accent.fontChar);
  51927. }
  51928. }
  51929. }
  51930. return glyphs;
  51931. },
  51932. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  51933. var gStateObj = [];
  51934. var gStateKeys = gState.getKeys();
  51935. var self = this;
  51936. var promise = Promise.resolve();
  51937. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  51938. var key = gStateKeys[i];
  51939. var value = gState.get(key);
  51940. switch (key) {
  51941. case 'Type':
  51942. break;
  51943. case 'LW':
  51944. case 'LC':
  51945. case 'LJ':
  51946. case 'ML':
  51947. case 'D':
  51948. case 'RI':
  51949. case 'FL':
  51950. case 'CA':
  51951. case 'ca':
  51952. gStateObj.push([
  51953. key,
  51954. value
  51955. ]);
  51956. break;
  51957. case 'Font':
  51958. promise = promise.then(function () {
  51959. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  51960. operatorList.addDependency(loadedName);
  51961. gStateObj.push([
  51962. key,
  51963. [
  51964. loadedName,
  51965. value[1]
  51966. ]
  51967. ]);
  51968. });
  51969. });
  51970. break;
  51971. case 'BM':
  51972. gStateObj.push([
  51973. key,
  51974. value
  51975. ]);
  51976. break;
  51977. case 'SMask':
  51978. if (isName(value, 'None')) {
  51979. gStateObj.push([
  51980. key,
  51981. false
  51982. ]);
  51983. break;
  51984. }
  51985. if (isDict(value)) {
  51986. promise = promise.then(function (dict) {
  51987. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  51988. }.bind(this, value));
  51989. gStateObj.push([
  51990. key,
  51991. true
  51992. ]);
  51993. } else {
  51994. warn('Unsupported SMask type');
  51995. }
  51996. break;
  51997. case 'OP':
  51998. case 'op':
  51999. case 'OPM':
  52000. case 'BG':
  52001. case 'BG2':
  52002. case 'UCR':
  52003. case 'UCR2':
  52004. case 'TR':
  52005. case 'TR2':
  52006. case 'HT':
  52007. case 'SM':
  52008. case 'SA':
  52009. case 'AIS':
  52010. case 'TK':
  52011. info('graphic state operator ' + key);
  52012. break;
  52013. default:
  52014. info('Unknown graphic state operator ' + key);
  52015. break;
  52016. }
  52017. }
  52018. return promise.then(function () {
  52019. if (gStateObj.length > 0) {
  52020. operatorList.addOp(OPS.setGState, [gStateObj]);
  52021. }
  52022. });
  52023. },
  52024. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52025. function errorFont() {
  52026. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52027. }
  52028. var fontRef;
  52029. if (font) {
  52030. assert(isRef(font));
  52031. fontRef = font;
  52032. } else {
  52033. var fontRes = resources.get('Font');
  52034. if (fontRes) {
  52035. fontRef = fontRes.getRaw(fontName);
  52036. } else {
  52037. warn('fontRes not available');
  52038. return errorFont();
  52039. }
  52040. }
  52041. if (!fontRef) {
  52042. warn('fontRef not available');
  52043. return errorFont();
  52044. }
  52045. if (this.fontCache.has(fontRef)) {
  52046. return this.fontCache.get(fontRef);
  52047. }
  52048. font = xref.fetchIfRef(fontRef);
  52049. if (!isDict(font)) {
  52050. return errorFont();
  52051. }
  52052. if (font.translated) {
  52053. return font.translated;
  52054. }
  52055. var fontCapability = createPromiseCapability();
  52056. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52057. var descriptor = preEvaluatedFont.descriptor;
  52058. var fontRefIsRef = isRef(fontRef), fontID;
  52059. if (fontRefIsRef) {
  52060. fontID = fontRef.toString();
  52061. }
  52062. if (isDict(descriptor)) {
  52063. if (!descriptor.fontAliases) {
  52064. descriptor.fontAliases = Object.create(null);
  52065. }
  52066. var fontAliases = descriptor.fontAliases;
  52067. var hash = preEvaluatedFont.hash;
  52068. if (fontAliases[hash]) {
  52069. var aliasFontRef = fontAliases[hash].aliasRef;
  52070. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52071. this.fontCache.putAlias(fontRef, aliasFontRef);
  52072. return this.fontCache.get(fontRef);
  52073. }
  52074. } else {
  52075. fontAliases[hash] = { fontID: Font.getFontID() };
  52076. }
  52077. if (fontRefIsRef) {
  52078. fontAliases[hash].aliasRef = fontRef;
  52079. }
  52080. fontID = fontAliases[hash].fontID;
  52081. }
  52082. if (fontRefIsRef) {
  52083. this.fontCache.put(fontRef, fontCapability.promise);
  52084. } else {
  52085. if (!fontID) {
  52086. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  52087. }
  52088. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52089. }
  52090. assert(fontID, 'The "fontID" must be defined.');
  52091. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52092. font.translated = fontCapability.promise;
  52093. var translatedPromise;
  52094. try {
  52095. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52096. } catch (e) {
  52097. translatedPromise = Promise.reject(e);
  52098. }
  52099. var self = this;
  52100. translatedPromise.then(function (translatedFont) {
  52101. if (translatedFont.fontType !== undefined) {
  52102. var xrefFontStats = xref.stats.fontTypes;
  52103. xrefFontStats[translatedFont.fontType] = true;
  52104. }
  52105. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52106. }, function (reason) {
  52107. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52108. try {
  52109. var descriptor = preEvaluatedFont.descriptor;
  52110. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52111. var subtype = fontFile3 && fontFile3.get('Subtype');
  52112. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52113. var xrefFontStats = xref.stats.fontTypes;
  52114. xrefFontStats[fontType] = true;
  52115. } catch (ex) {
  52116. }
  52117. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52118. });
  52119. return fontCapability.promise;
  52120. },
  52121. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52122. var lastIndex = operatorList.length - 1;
  52123. if (!args) {
  52124. args = [];
  52125. }
  52126. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52127. operatorList.addOp(OPS.constructPath, [
  52128. [fn],
  52129. args
  52130. ]);
  52131. } else {
  52132. var opArgs = operatorList.argsArray[lastIndex];
  52133. opArgs[0].push(fn);
  52134. Array.prototype.push.apply(opArgs[1], args);
  52135. }
  52136. },
  52137. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52138. var patternName = args[args.length - 1];
  52139. var pattern;
  52140. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52141. var dict = isStream(pattern) ? pattern.dict : pattern;
  52142. var typeNum = dict.get('PatternType');
  52143. if (typeNum === TILING_PATTERN) {
  52144. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52145. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52146. } else if (typeNum === SHADING_PATTERN) {
  52147. var shading = dict.get('Shading');
  52148. var matrix = dict.getArray('Matrix');
  52149. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52150. operatorList.addOp(fn, pattern.getIR());
  52151. return Promise.resolve();
  52152. } else {
  52153. return Promise.reject('Unknown PatternType: ' + typeNum);
  52154. }
  52155. }
  52156. operatorList.addOp(fn, args);
  52157. return Promise.resolve();
  52158. },
  52159. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52160. var self = this;
  52161. var xref = this.xref;
  52162. var imageCache = Object.create(null);
  52163. assert(operatorList);
  52164. resources = resources || Dict.empty;
  52165. var xobjs = resources.get('XObject') || Dict.empty;
  52166. var patterns = resources.get('Pattern') || Dict.empty;
  52167. var stateManager = new StateManager(initialState || new EvalState());
  52168. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52169. var timeSlotManager = new TimeSlotManager();
  52170. return new Promise(function promiseBody(resolve, reject) {
  52171. var next = function (promise) {
  52172. promise.then(function () {
  52173. try {
  52174. promiseBody(resolve, reject);
  52175. } catch (ex) {
  52176. reject(ex);
  52177. }
  52178. }, reject);
  52179. };
  52180. task.ensureNotTerminated();
  52181. timeSlotManager.reset();
  52182. var stop, operation = {}, i, ii, cs;
  52183. while (!(stop = timeSlotManager.check())) {
  52184. operation.args = null;
  52185. if (!preprocessor.read(operation)) {
  52186. break;
  52187. }
  52188. var args = operation.args;
  52189. var fn = operation.fn;
  52190. switch (fn | 0) {
  52191. case OPS.paintXObject:
  52192. if (args[0].code) {
  52193. break;
  52194. }
  52195. var name = args[0].name;
  52196. if (!name) {
  52197. warn('XObject must be referred to by name.');
  52198. continue;
  52199. }
  52200. if (imageCache[name] !== undefined) {
  52201. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52202. args = null;
  52203. continue;
  52204. }
  52205. var xobj = xobjs.get(name);
  52206. if (xobj) {
  52207. assert(isStream(xobj), 'XObject should be a stream');
  52208. var type = xobj.dict.get('Subtype');
  52209. assert(isName(type), 'XObject should have a Name subtype');
  52210. if (type.name === 'Form') {
  52211. stateManager.save();
  52212. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52213. stateManager.restore();
  52214. }));
  52215. return;
  52216. } else if (type.name === 'Image') {
  52217. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52218. args = null;
  52219. continue;
  52220. } else if (type.name === 'PS') {
  52221. info('Ignored XObject subtype PS');
  52222. continue;
  52223. } else {
  52224. error('Unhandled XObject subtype ' + type.name);
  52225. }
  52226. }
  52227. break;
  52228. case OPS.setFont:
  52229. var fontSize = args[1];
  52230. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52231. operatorList.addDependency(loadedName);
  52232. operatorList.addOp(OPS.setFont, [
  52233. loadedName,
  52234. fontSize
  52235. ]);
  52236. }));
  52237. return;
  52238. case OPS.endInlineImage:
  52239. var cacheKey = args[0].cacheKey;
  52240. if (cacheKey) {
  52241. var cacheEntry = imageCache[cacheKey];
  52242. if (cacheEntry !== undefined) {
  52243. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52244. args = null;
  52245. continue;
  52246. }
  52247. }
  52248. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52249. args = null;
  52250. continue;
  52251. case OPS.showText:
  52252. args[0] = self.handleText(args[0], stateManager.state);
  52253. break;
  52254. case OPS.showSpacedText:
  52255. var arr = args[0];
  52256. var combinedGlyphs = [];
  52257. var arrLength = arr.length;
  52258. var state = stateManager.state;
  52259. for (i = 0; i < arrLength; ++i) {
  52260. var arrItem = arr[i];
  52261. if (isString(arrItem)) {
  52262. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52263. } else if (isNum(arrItem)) {
  52264. combinedGlyphs.push(arrItem);
  52265. }
  52266. }
  52267. args[0] = combinedGlyphs;
  52268. fn = OPS.showText;
  52269. break;
  52270. case OPS.nextLineShowText:
  52271. operatorList.addOp(OPS.nextLine);
  52272. args[0] = self.handleText(args[0], stateManager.state);
  52273. fn = OPS.showText;
  52274. break;
  52275. case OPS.nextLineSetSpacingShowText:
  52276. operatorList.addOp(OPS.nextLine);
  52277. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52278. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52279. args[0] = self.handleText(args[0], stateManager.state);
  52280. fn = OPS.showText;
  52281. break;
  52282. case OPS.setTextRenderingMode:
  52283. stateManager.state.textRenderingMode = args[0];
  52284. break;
  52285. case OPS.setFillColorSpace:
  52286. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52287. continue;
  52288. case OPS.setStrokeColorSpace:
  52289. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52290. continue;
  52291. case OPS.setFillColor:
  52292. cs = stateManager.state.fillColorSpace;
  52293. args = cs.getRgb(args, 0);
  52294. fn = OPS.setFillRGBColor;
  52295. break;
  52296. case OPS.setStrokeColor:
  52297. cs = stateManager.state.strokeColorSpace;
  52298. args = cs.getRgb(args, 0);
  52299. fn = OPS.setStrokeRGBColor;
  52300. break;
  52301. case OPS.setFillGray:
  52302. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52303. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52304. fn = OPS.setFillRGBColor;
  52305. break;
  52306. case OPS.setStrokeGray:
  52307. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52308. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52309. fn = OPS.setStrokeRGBColor;
  52310. break;
  52311. case OPS.setFillCMYKColor:
  52312. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52313. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52314. fn = OPS.setFillRGBColor;
  52315. break;
  52316. case OPS.setStrokeCMYKColor:
  52317. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52318. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52319. fn = OPS.setStrokeRGBColor;
  52320. break;
  52321. case OPS.setFillRGBColor:
  52322. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52323. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52324. break;
  52325. case OPS.setStrokeRGBColor:
  52326. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52327. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52328. break;
  52329. case OPS.setFillColorN:
  52330. cs = stateManager.state.fillColorSpace;
  52331. if (cs.name === 'Pattern') {
  52332. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52333. return;
  52334. }
  52335. args = cs.getRgb(args, 0);
  52336. fn = OPS.setFillRGBColor;
  52337. break;
  52338. case OPS.setStrokeColorN:
  52339. cs = stateManager.state.strokeColorSpace;
  52340. if (cs.name === 'Pattern') {
  52341. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52342. return;
  52343. }
  52344. args = cs.getRgb(args, 0);
  52345. fn = OPS.setStrokeRGBColor;
  52346. break;
  52347. case OPS.shadingFill:
  52348. var shadingRes = resources.get('Shading');
  52349. if (!shadingRes) {
  52350. error('No shading resource found');
  52351. }
  52352. var shading = shadingRes.get(args[0].name);
  52353. if (!shading) {
  52354. error('No shading object found');
  52355. }
  52356. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52357. var patternIR = shadingFill.getIR();
  52358. args = [patternIR];
  52359. fn = OPS.shadingFill;
  52360. break;
  52361. case OPS.setGState:
  52362. var dictName = args[0];
  52363. var extGState = resources.get('ExtGState');
  52364. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52365. break;
  52366. }
  52367. var gState = extGState.get(dictName.name);
  52368. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52369. return;
  52370. case OPS.moveTo:
  52371. case OPS.lineTo:
  52372. case OPS.curveTo:
  52373. case OPS.curveTo2:
  52374. case OPS.curveTo3:
  52375. case OPS.closePath:
  52376. self.buildPath(operatorList, fn, args);
  52377. continue;
  52378. case OPS.rectangle:
  52379. self.buildPath(operatorList, fn, args);
  52380. continue;
  52381. case OPS.markPoint:
  52382. case OPS.markPointProps:
  52383. case OPS.beginMarkedContent:
  52384. case OPS.beginMarkedContentProps:
  52385. case OPS.endMarkedContent:
  52386. case OPS.beginCompat:
  52387. case OPS.endCompat:
  52388. continue;
  52389. default:
  52390. if (args !== null) {
  52391. for (i = 0, ii = args.length; i < ii; i++) {
  52392. if (args[i] instanceof Dict) {
  52393. break;
  52394. }
  52395. }
  52396. if (i < ii) {
  52397. warn('getOperatorList - ignoring operator: ' + fn);
  52398. continue;
  52399. }
  52400. }
  52401. }
  52402. operatorList.addOp(fn, args);
  52403. }
  52404. if (stop) {
  52405. next(deferred);
  52406. return;
  52407. }
  52408. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52409. operatorList.addOp(OPS.restore, []);
  52410. }
  52411. resolve();
  52412. });
  52413. },
  52414. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52415. stateManager = stateManager || new StateManager(new TextState());
  52416. var WhitespaceRegexp = /\s/g;
  52417. var textContent = {
  52418. items: [],
  52419. styles: Object.create(null)
  52420. };
  52421. var textContentItem = {
  52422. initialized: false,
  52423. str: [],
  52424. width: 0,
  52425. height: 0,
  52426. vertical: false,
  52427. lastAdvanceWidth: 0,
  52428. lastAdvanceHeight: 0,
  52429. textAdvanceScale: 0,
  52430. spaceWidth: 0,
  52431. fakeSpaceMin: Infinity,
  52432. fakeMultiSpaceMin: Infinity,
  52433. fakeMultiSpaceMax: -0,
  52434. textRunBreakAllowed: false,
  52435. transform: null,
  52436. fontName: null
  52437. };
  52438. var SPACE_FACTOR = 0.3;
  52439. var MULTI_SPACE_FACTOR = 1.5;
  52440. var MULTI_SPACE_FACTOR_MAX = 4;
  52441. var self = this;
  52442. var xref = this.xref;
  52443. resources = xref.fetchIfRef(resources) || Dict.empty;
  52444. var xobjs = null;
  52445. var xobjsCache = Object.create(null);
  52446. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52447. var textState;
  52448. function ensureTextContentItem() {
  52449. if (textContentItem.initialized) {
  52450. return textContentItem;
  52451. }
  52452. var font = textState.font;
  52453. if (!(font.loadedName in textContent.styles)) {
  52454. textContent.styles[font.loadedName] = {
  52455. fontFamily: font.fallbackName,
  52456. ascent: font.ascent,
  52457. descent: font.descent,
  52458. vertical: font.vertical
  52459. };
  52460. }
  52461. textContentItem.fontName = font.loadedName;
  52462. var tsm = [
  52463. textState.fontSize * textState.textHScale,
  52464. 0,
  52465. 0,
  52466. textState.fontSize,
  52467. 0,
  52468. textState.textRise
  52469. ];
  52470. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52471. var glyphHeight = font.bbox[3] - font.bbox[1];
  52472. if (glyphHeight > 0) {
  52473. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52474. tsm[3] *= glyphHeight;
  52475. }
  52476. }
  52477. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52478. textContentItem.transform = trm;
  52479. if (!font.vertical) {
  52480. textContentItem.width = 0;
  52481. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52482. textContentItem.vertical = false;
  52483. } else {
  52484. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52485. textContentItem.height = 0;
  52486. textContentItem.vertical = true;
  52487. }
  52488. var a = textState.textLineMatrix[0];
  52489. var b = textState.textLineMatrix[1];
  52490. var scaleLineX = Math.sqrt(a * a + b * b);
  52491. a = textState.ctm[0];
  52492. b = textState.ctm[1];
  52493. var scaleCtmX = Math.sqrt(a * a + b * b);
  52494. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52495. textContentItem.lastAdvanceWidth = 0;
  52496. textContentItem.lastAdvanceHeight = 0;
  52497. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52498. if (spaceWidth) {
  52499. textContentItem.spaceWidth = spaceWidth;
  52500. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52501. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52502. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52503. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52504. } else {
  52505. textContentItem.spaceWidth = 0;
  52506. textContentItem.fakeSpaceMin = Infinity;
  52507. textContentItem.fakeMultiSpaceMin = Infinity;
  52508. textContentItem.fakeMultiSpaceMax = 0;
  52509. textContentItem.textRunBreakAllowed = false;
  52510. }
  52511. textContentItem.initialized = true;
  52512. return textContentItem;
  52513. }
  52514. function replaceWhitespace(str) {
  52515. var i = 0, ii = str.length, code;
  52516. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52517. i++;
  52518. }
  52519. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52520. }
  52521. function runBidiTransform(textChunk) {
  52522. var str = textChunk.str.join('');
  52523. var bidiResult = bidi(str, -1, textChunk.vertical);
  52524. return {
  52525. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52526. dir: bidiResult.dir,
  52527. width: textChunk.width,
  52528. height: textChunk.height,
  52529. transform: textChunk.transform,
  52530. fontName: textChunk.fontName
  52531. };
  52532. }
  52533. function handleSetFont(fontName, fontRef) {
  52534. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52535. textState.font = translated.font;
  52536. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52537. });
  52538. }
  52539. function buildTextContentItem(chars) {
  52540. var font = textState.font;
  52541. var textChunk = ensureTextContentItem();
  52542. var width = 0;
  52543. var height = 0;
  52544. var glyphs = font.charsToGlyphs(chars);
  52545. var defaultVMetrics = font.defaultVMetrics;
  52546. for (var i = 0; i < glyphs.length; i++) {
  52547. var glyph = glyphs[i];
  52548. var vMetricX = null;
  52549. var vMetricY = null;
  52550. var glyphWidth = null;
  52551. if (font.vertical) {
  52552. if (glyph.vmetric) {
  52553. glyphWidth = glyph.vmetric[0];
  52554. vMetricX = glyph.vmetric[1];
  52555. vMetricY = glyph.vmetric[2];
  52556. } else {
  52557. glyphWidth = glyph.width;
  52558. vMetricX = glyph.width * 0.5;
  52559. vMetricY = defaultVMetrics[2];
  52560. }
  52561. } else {
  52562. glyphWidth = glyph.width;
  52563. }
  52564. var glyphUnicode = glyph.unicode;
  52565. var NormalizedUnicodes = getNormalizedUnicodes();
  52566. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52567. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52568. }
  52569. glyphUnicode = reverseIfRtl(glyphUnicode);
  52570. var charSpacing = textState.charSpacing;
  52571. if (glyph.isSpace) {
  52572. var wordSpacing = textState.wordSpacing;
  52573. charSpacing += wordSpacing;
  52574. if (wordSpacing > 0) {
  52575. addFakeSpaces(wordSpacing, textChunk.str);
  52576. }
  52577. }
  52578. var tx = 0;
  52579. var ty = 0;
  52580. if (!font.vertical) {
  52581. var w0 = glyphWidth * textState.fontMatrix[0];
  52582. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52583. width += tx;
  52584. } else {
  52585. var w1 = glyphWidth * textState.fontMatrix[0];
  52586. ty = w1 * textState.fontSize + charSpacing;
  52587. height += ty;
  52588. }
  52589. textState.translateTextMatrix(tx, ty);
  52590. textChunk.str.push(glyphUnicode);
  52591. }
  52592. if (!font.vertical) {
  52593. textChunk.lastAdvanceWidth = width;
  52594. textChunk.width += width * textChunk.textAdvanceScale;
  52595. } else {
  52596. textChunk.lastAdvanceHeight = height;
  52597. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  52598. }
  52599. return textChunk;
  52600. }
  52601. function addFakeSpaces(width, strBuf) {
  52602. if (width < textContentItem.fakeSpaceMin) {
  52603. return;
  52604. }
  52605. if (width < textContentItem.fakeMultiSpaceMin) {
  52606. strBuf.push(' ');
  52607. return;
  52608. }
  52609. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52610. while (fakeSpaces-- > 0) {
  52611. strBuf.push(' ');
  52612. }
  52613. }
  52614. function flushTextContentItem() {
  52615. if (!textContentItem.initialized) {
  52616. return;
  52617. }
  52618. textContent.items.push(runBidiTransform(textContentItem));
  52619. textContentItem.initialized = false;
  52620. textContentItem.str.length = 0;
  52621. }
  52622. var timeSlotManager = new TimeSlotManager();
  52623. return new Promise(function promiseBody(resolve, reject) {
  52624. var next = function (promise) {
  52625. promise.then(function () {
  52626. try {
  52627. promiseBody(resolve, reject);
  52628. } catch (ex) {
  52629. reject(ex);
  52630. }
  52631. }, reject);
  52632. };
  52633. task.ensureNotTerminated();
  52634. timeSlotManager.reset();
  52635. var stop, operation = {}, args = [];
  52636. while (!(stop = timeSlotManager.check())) {
  52637. args.length = 0;
  52638. operation.args = args;
  52639. if (!preprocessor.read(operation)) {
  52640. break;
  52641. }
  52642. textState = stateManager.state;
  52643. var fn = operation.fn;
  52644. args = operation.args;
  52645. var advance, diff;
  52646. switch (fn | 0) {
  52647. case OPS.setFont:
  52648. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52649. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52650. break;
  52651. }
  52652. flushTextContentItem();
  52653. textState.fontName = fontNameArg;
  52654. textState.fontSize = fontSizeArg;
  52655. next(handleSetFont(fontNameArg, null));
  52656. return;
  52657. case OPS.setTextRise:
  52658. flushTextContentItem();
  52659. textState.textRise = args[0];
  52660. break;
  52661. case OPS.setHScale:
  52662. flushTextContentItem();
  52663. textState.textHScale = args[0] / 100;
  52664. break;
  52665. case OPS.setLeading:
  52666. flushTextContentItem();
  52667. textState.leading = args[0];
  52668. break;
  52669. case OPS.moveText:
  52670. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52671. advance = args[0] - args[1];
  52672. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52673. textState.translateTextLineMatrix(args[0], args[1]);
  52674. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52675. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52676. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52677. addFakeSpaces(diff, textContentItem.str);
  52678. break;
  52679. }
  52680. flushTextContentItem();
  52681. textState.translateTextLineMatrix(args[0], args[1]);
  52682. textState.textMatrix = textState.textLineMatrix.slice();
  52683. break;
  52684. case OPS.setLeadingMoveText:
  52685. flushTextContentItem();
  52686. textState.leading = -args[1];
  52687. textState.translateTextLineMatrix(args[0], args[1]);
  52688. textState.textMatrix = textState.textLineMatrix.slice();
  52689. break;
  52690. case OPS.nextLine:
  52691. flushTextContentItem();
  52692. textState.carriageReturn();
  52693. break;
  52694. case OPS.setTextMatrix:
  52695. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52696. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52697. textState.translateTextLineMatrix(advance.width, advance.height);
  52698. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52699. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52700. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52701. addFakeSpaces(diff, textContentItem.str);
  52702. break;
  52703. }
  52704. flushTextContentItem();
  52705. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52706. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52707. break;
  52708. case OPS.setCharSpacing:
  52709. textState.charSpacing = args[0];
  52710. break;
  52711. case OPS.setWordSpacing:
  52712. textState.wordSpacing = args[0];
  52713. break;
  52714. case OPS.beginText:
  52715. flushTextContentItem();
  52716. textState.textMatrix = IDENTITY_MATRIX.slice();
  52717. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52718. break;
  52719. case OPS.showSpacedText:
  52720. var items = args[0];
  52721. var offset;
  52722. for (var j = 0, jj = items.length; j < jj; j++) {
  52723. if (typeof items[j] === 'string') {
  52724. buildTextContentItem(items[j]);
  52725. } else if (isNum(items[j])) {
  52726. ensureTextContentItem();
  52727. advance = items[j] * textState.fontSize / 1000;
  52728. var breakTextRun = false;
  52729. if (textState.font.vertical) {
  52730. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  52731. textState.translateTextMatrix(0, advance);
  52732. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52733. if (!breakTextRun) {
  52734. textContentItem.height += offset;
  52735. }
  52736. } else {
  52737. advance = -advance;
  52738. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  52739. textState.translateTextMatrix(advance, 0);
  52740. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52741. if (!breakTextRun) {
  52742. textContentItem.width += offset;
  52743. }
  52744. }
  52745. if (breakTextRun) {
  52746. flushTextContentItem();
  52747. } else if (advance > 0) {
  52748. addFakeSpaces(advance, textContentItem.str);
  52749. }
  52750. }
  52751. }
  52752. break;
  52753. case OPS.showText:
  52754. buildTextContentItem(args[0]);
  52755. break;
  52756. case OPS.nextLineShowText:
  52757. flushTextContentItem();
  52758. textState.carriageReturn();
  52759. buildTextContentItem(args[0]);
  52760. break;
  52761. case OPS.nextLineSetSpacingShowText:
  52762. flushTextContentItem();
  52763. textState.wordSpacing = args[0];
  52764. textState.charSpacing = args[1];
  52765. textState.carriageReturn();
  52766. buildTextContentItem(args[2]);
  52767. break;
  52768. case OPS.paintXObject:
  52769. flushTextContentItem();
  52770. if (args[0].code) {
  52771. break;
  52772. }
  52773. if (!xobjs) {
  52774. xobjs = resources.get('XObject') || Dict.empty;
  52775. }
  52776. var name = args[0].name;
  52777. if (xobjsCache.key === name) {
  52778. if (xobjsCache.texts) {
  52779. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52780. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52781. }
  52782. break;
  52783. }
  52784. var xobj = xobjs.get(name);
  52785. if (!xobj) {
  52786. break;
  52787. }
  52788. assert(isStream(xobj), 'XObject should be a stream');
  52789. var type = xobj.dict.get('Subtype');
  52790. assert(isName(type), 'XObject should have a Name subtype');
  52791. if ('Form' !== type.name) {
  52792. xobjsCache.key = name;
  52793. xobjsCache.texts = null;
  52794. break;
  52795. }
  52796. stateManager.save();
  52797. var matrix = xobj.dict.getArray('Matrix');
  52798. if (isArray(matrix) && matrix.length === 6) {
  52799. stateManager.transform(matrix);
  52800. }
  52801. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52802. Util.appendToArray(textContent.items, formTextContent.items);
  52803. Util.extendObj(textContent.styles, formTextContent.styles);
  52804. stateManager.restore();
  52805. xobjsCache.key = name;
  52806. xobjsCache.texts = formTextContent;
  52807. }));
  52808. return;
  52809. case OPS.setGState:
  52810. flushTextContentItem();
  52811. var dictName = args[0];
  52812. var extGState = resources.get('ExtGState');
  52813. if (!isDict(extGState) || !isName(dictName)) {
  52814. break;
  52815. }
  52816. var gState = extGState.get(dictName.name);
  52817. if (!isDict(gState)) {
  52818. break;
  52819. }
  52820. var gStateFont = gState.get('Font');
  52821. if (gStateFont) {
  52822. textState.fontName = null;
  52823. textState.fontSize = gStateFont[1];
  52824. next(handleSetFont(null, gStateFont[0]));
  52825. return;
  52826. }
  52827. break;
  52828. }
  52829. }
  52830. if (stop) {
  52831. next(deferred);
  52832. return;
  52833. }
  52834. flushTextContentItem();
  52835. resolve(textContent);
  52836. });
  52837. },
  52838. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52839. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52840. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52841. if (properties.composite) {
  52842. var cidSystemInfo = dict.get('CIDSystemInfo');
  52843. if (isDict(cidSystemInfo)) {
  52844. properties.cidSystemInfo = {
  52845. registry: cidSystemInfo.get('Registry'),
  52846. ordering: cidSystemInfo.get('Ordering'),
  52847. supplement: cidSystemInfo.get('Supplement')
  52848. };
  52849. }
  52850. var cidToGidMap = dict.get('CIDToGIDMap');
  52851. if (isStream(cidToGidMap)) {
  52852. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52853. }
  52854. }
  52855. var differences = [];
  52856. var baseEncodingName = null;
  52857. var encoding;
  52858. if (dict.has('Encoding')) {
  52859. encoding = dict.get('Encoding');
  52860. if (isDict(encoding)) {
  52861. baseEncodingName = encoding.get('BaseEncoding');
  52862. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  52863. if (encoding.has('Differences')) {
  52864. var diffEncoding = encoding.get('Differences');
  52865. var index = 0;
  52866. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  52867. var data = xref.fetchIfRef(diffEncoding[j]);
  52868. if (isNum(data)) {
  52869. index = data;
  52870. } else if (isName(data)) {
  52871. differences[index++] = data.name;
  52872. } else {
  52873. error('Invalid entry in \'Differences\' array: ' + data);
  52874. }
  52875. }
  52876. }
  52877. } else if (isName(encoding)) {
  52878. baseEncodingName = encoding.name;
  52879. } else {
  52880. error('Encoding is not a Name nor a Dict');
  52881. }
  52882. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  52883. baseEncodingName = null;
  52884. }
  52885. }
  52886. if (baseEncodingName) {
  52887. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  52888. } else {
  52889. encoding = properties.type === 'TrueType' ? WinAnsiEncoding : StandardEncoding;
  52890. if (!!(properties.flags & FontFlags.Symbolic)) {
  52891. encoding = MacRomanEncoding;
  52892. if (!properties.file) {
  52893. if (/Symbol/i.test(properties.name)) {
  52894. encoding = SymbolSetEncoding;
  52895. } else if (/Dingbats/i.test(properties.name)) {
  52896. encoding = ZapfDingbatsEncoding;
  52897. }
  52898. }
  52899. }
  52900. properties.defaultEncoding = encoding;
  52901. }
  52902. properties.differences = differences;
  52903. properties.baseEncodingName = baseEncodingName;
  52904. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  52905. properties.dict = dict;
  52906. return toUnicodePromise.then(function (toUnicode) {
  52907. properties.toUnicode = toUnicode;
  52908. return this.buildToUnicode(properties);
  52909. }.bind(this)).then(function (toUnicode) {
  52910. properties.toUnicode = toUnicode;
  52911. return properties;
  52912. });
  52913. },
  52914. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  52915. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  52916. if (properties.hasIncludedToUnicodeMap) {
  52917. return Promise.resolve(properties.toUnicode);
  52918. }
  52919. var toUnicode, charcode, glyphName;
  52920. if (!properties.composite)
  52921. {
  52922. toUnicode = [];
  52923. var encoding = properties.defaultEncoding.slice();
  52924. var baseEncodingName = properties.baseEncodingName;
  52925. var differences = properties.differences;
  52926. for (charcode in differences) {
  52927. glyphName = differences[charcode];
  52928. if (glyphName === '.notdef') {
  52929. continue;
  52930. }
  52931. encoding[charcode] = glyphName;
  52932. }
  52933. var glyphsUnicodeMap = getGlyphsUnicode();
  52934. for (charcode in encoding) {
  52935. glyphName = encoding[charcode];
  52936. if (glyphName === '') {
  52937. continue;
  52938. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  52939. var code = 0;
  52940. switch (glyphName[0]) {
  52941. case 'G':
  52942. if (glyphName.length === 3) {
  52943. code = parseInt(glyphName.substr(1), 16);
  52944. }
  52945. break;
  52946. case 'g':
  52947. if (glyphName.length === 5) {
  52948. code = parseInt(glyphName.substr(1), 16);
  52949. }
  52950. break;
  52951. case 'C':
  52952. case 'c':
  52953. if (glyphName.length >= 3) {
  52954. code = +glyphName.substr(1);
  52955. }
  52956. break;
  52957. default:
  52958. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  52959. if (unicode !== -1) {
  52960. code = unicode;
  52961. }
  52962. }
  52963. if (code) {
  52964. if (baseEncodingName && code === +charcode) {
  52965. var baseEncoding = getEncoding(baseEncodingName);
  52966. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  52967. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52968. continue;
  52969. }
  52970. }
  52971. toUnicode[charcode] = String.fromCharCode(code);
  52972. }
  52973. continue;
  52974. }
  52975. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52976. }
  52977. return Promise.resolve(new ToUnicodeMap(toUnicode));
  52978. }
  52979. 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'))) {
  52980. var registry = properties.cidSystemInfo.registry;
  52981. var ordering = properties.cidSystemInfo.ordering;
  52982. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  52983. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  52984. var cMap = properties.cMap;
  52985. toUnicode = [];
  52986. cMap.forEach(function (charcode, cid) {
  52987. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  52988. var ucs2 = ucs2CMap.lookup(cid);
  52989. if (ucs2) {
  52990. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  52991. }
  52992. });
  52993. return new ToUnicodeMap(toUnicode);
  52994. });
  52995. }
  52996. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  52997. },
  52998. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  52999. var cmapObj = toUnicode;
  53000. if (isName(cmapObj)) {
  53001. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53002. if (cmap instanceof IdentityCMap) {
  53003. return new IdentityToUnicodeMap(0, 0xFFFF);
  53004. }
  53005. return new ToUnicodeMap(cmap.getMap());
  53006. });
  53007. } else if (isStream(cmapObj)) {
  53008. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53009. if (cmap instanceof IdentityCMap) {
  53010. return new IdentityToUnicodeMap(0, 0xFFFF);
  53011. }
  53012. var map = new Array(cmap.length);
  53013. cmap.forEach(function (charCode, token) {
  53014. var str = [];
  53015. for (var k = 0; k < token.length; k += 2) {
  53016. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53017. if ((w1 & 0xF800) !== 0xD800) {
  53018. str.push(w1);
  53019. continue;
  53020. }
  53021. k += 2;
  53022. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53023. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53024. }
  53025. map[charCode] = String.fromCharCode.apply(String, str);
  53026. });
  53027. return new ToUnicodeMap(map);
  53028. });
  53029. }
  53030. return Promise.resolve(null);
  53031. },
  53032. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53033. var glyphsData = cidToGidStream.getBytes();
  53034. var result = [];
  53035. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53036. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53037. if (glyphID === 0) {
  53038. continue;
  53039. }
  53040. var code = j >> 1;
  53041. result[code] = glyphID;
  53042. }
  53043. return result;
  53044. },
  53045. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53046. var glyphsWidths = [];
  53047. var defaultWidth = 0;
  53048. var glyphsVMetrics = [];
  53049. var defaultVMetrics;
  53050. var i, ii, j, jj, start, code, widths;
  53051. if (properties.composite) {
  53052. defaultWidth = dict.get('DW') || 1000;
  53053. widths = dict.get('W');
  53054. if (widths) {
  53055. for (i = 0, ii = widths.length; i < ii; i++) {
  53056. start = widths[i++];
  53057. code = xref.fetchIfRef(widths[i]);
  53058. if (isArray(code)) {
  53059. for (j = 0, jj = code.length; j < jj; j++) {
  53060. glyphsWidths[start++] = code[j];
  53061. }
  53062. } else {
  53063. var width = widths[++i];
  53064. for (j = start; j <= code; j++) {
  53065. glyphsWidths[j] = width;
  53066. }
  53067. }
  53068. }
  53069. }
  53070. if (properties.vertical) {
  53071. var vmetrics = dict.get('DW2') || [
  53072. 880,
  53073. -1000
  53074. ];
  53075. defaultVMetrics = [
  53076. vmetrics[1],
  53077. defaultWidth * 0.5,
  53078. vmetrics[0]
  53079. ];
  53080. vmetrics = dict.get('W2');
  53081. if (vmetrics) {
  53082. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53083. start = vmetrics[i++];
  53084. code = xref.fetchIfRef(vmetrics[i]);
  53085. if (isArray(code)) {
  53086. for (j = 0, jj = code.length; j < jj; j++) {
  53087. glyphsVMetrics[start++] = [
  53088. code[j++],
  53089. code[j++],
  53090. code[j]
  53091. ];
  53092. }
  53093. } else {
  53094. var vmetric = [
  53095. vmetrics[++i],
  53096. vmetrics[++i],
  53097. vmetrics[++i]
  53098. ];
  53099. for (j = start; j <= code; j++) {
  53100. glyphsVMetrics[j] = vmetric;
  53101. }
  53102. }
  53103. }
  53104. }
  53105. }
  53106. } else {
  53107. var firstChar = properties.firstChar;
  53108. widths = dict.get('Widths');
  53109. if (widths) {
  53110. j = firstChar;
  53111. for (i = 0, ii = widths.length; i < ii; i++) {
  53112. glyphsWidths[j++] = widths[i];
  53113. }
  53114. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53115. } else {
  53116. var baseFontName = dict.get('BaseFont');
  53117. if (isName(baseFontName)) {
  53118. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53119. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53120. defaultWidth = metrics.defaultWidth;
  53121. }
  53122. }
  53123. }
  53124. var isMonospace = true;
  53125. var firstWidth = defaultWidth;
  53126. for (var glyph in glyphsWidths) {
  53127. var glyphWidth = glyphsWidths[glyph];
  53128. if (!glyphWidth) {
  53129. continue;
  53130. }
  53131. if (!firstWidth) {
  53132. firstWidth = glyphWidth;
  53133. continue;
  53134. }
  53135. if (firstWidth !== glyphWidth) {
  53136. isMonospace = false;
  53137. break;
  53138. }
  53139. }
  53140. if (isMonospace) {
  53141. properties.flags |= FontFlags.FixedPitch;
  53142. }
  53143. properties.defaultWidth = defaultWidth;
  53144. properties.widths = glyphsWidths;
  53145. properties.defaultVMetrics = defaultVMetrics;
  53146. properties.vmetrics = glyphsVMetrics;
  53147. },
  53148. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53149. var fontNameWoStyle = baseFontName.split('-')[0];
  53150. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53151. },
  53152. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53153. var defaultWidth = 0;
  53154. var widths = [];
  53155. var monospace = false;
  53156. var stdFontMap = getStdFontMap();
  53157. var lookupName = stdFontMap[name] || name;
  53158. var Metrics = getMetrics();
  53159. if (!(lookupName in Metrics)) {
  53160. if (this.isSerifFont(name)) {
  53161. lookupName = 'Times-Roman';
  53162. } else {
  53163. lookupName = 'Helvetica';
  53164. }
  53165. }
  53166. var glyphWidths = Metrics[lookupName];
  53167. if (isNum(glyphWidths)) {
  53168. defaultWidth = glyphWidths;
  53169. monospace = true;
  53170. } else {
  53171. widths = glyphWidths();
  53172. }
  53173. return {
  53174. defaultWidth: defaultWidth,
  53175. monospace: monospace,
  53176. widths: widths
  53177. };
  53178. },
  53179. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53180. var widths = Object.create(null);
  53181. var differences = properties.differences;
  53182. var encoding = properties.defaultEncoding;
  53183. for (var charCode = 0; charCode < 256; charCode++) {
  53184. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53185. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53186. continue;
  53187. }
  53188. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53189. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53190. continue;
  53191. }
  53192. }
  53193. return widths;
  53194. },
  53195. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53196. var baseDict = dict;
  53197. var type = dict.get('Subtype');
  53198. assert(isName(type), 'invalid font Subtype');
  53199. var composite = false;
  53200. var uint8array;
  53201. if (type.name === 'Type0') {
  53202. var df = dict.get('DescendantFonts');
  53203. if (!df) {
  53204. error('Descendant fonts are not specified');
  53205. }
  53206. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53207. type = dict.get('Subtype');
  53208. assert(isName(type), 'invalid font Subtype');
  53209. composite = true;
  53210. }
  53211. var descriptor = dict.get('FontDescriptor');
  53212. if (descriptor) {
  53213. var hash = new MurmurHash3_64();
  53214. var encoding = baseDict.getRaw('Encoding');
  53215. if (isName(encoding)) {
  53216. hash.update(encoding.name);
  53217. } else if (isRef(encoding)) {
  53218. hash.update(encoding.toString());
  53219. } else if (isDict(encoding)) {
  53220. var keys = encoding.getKeys();
  53221. for (var i = 0, ii = keys.length; i < ii; i++) {
  53222. var entry = encoding.getRaw(keys[i]);
  53223. if (isName(entry)) {
  53224. hash.update(entry.name);
  53225. } else if (isRef(entry)) {
  53226. hash.update(entry.toString());
  53227. } else if (isArray(entry)) {
  53228. hash.update(entry.length.toString());
  53229. }
  53230. }
  53231. }
  53232. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53233. if (isStream(toUnicode)) {
  53234. var stream = toUnicode.str || toUnicode;
  53235. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53236. hash.update(uint8array);
  53237. } else if (isName(toUnicode)) {
  53238. hash.update(toUnicode.name);
  53239. }
  53240. var widths = dict.get('Widths') || baseDict.get('Widths');
  53241. if (widths) {
  53242. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53243. hash.update(uint8array);
  53244. }
  53245. }
  53246. return {
  53247. descriptor: descriptor,
  53248. dict: dict,
  53249. baseDict: baseDict,
  53250. composite: composite,
  53251. type: type.name,
  53252. hash: hash ? hash.hexdigest() : ''
  53253. };
  53254. },
  53255. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53256. var baseDict = preEvaluatedFont.baseDict;
  53257. var dict = preEvaluatedFont.dict;
  53258. var composite = preEvaluatedFont.composite;
  53259. var descriptor = preEvaluatedFont.descriptor;
  53260. var type = preEvaluatedFont.type;
  53261. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53262. var cMapOptions = this.options.cMapOptions;
  53263. var properties;
  53264. if (!descriptor) {
  53265. if (type === 'Type3') {
  53266. descriptor = new Dict(null);
  53267. descriptor.set('FontName', Name.get(type));
  53268. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53269. } else {
  53270. var baseFontName = dict.get('BaseFont');
  53271. if (!isName(baseFontName)) {
  53272. error('Base font is not specified');
  53273. }
  53274. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53275. var metrics = this.getBaseFontMetrics(baseFontName);
  53276. var fontNameWoStyle = baseFontName.split('-')[0];
  53277. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53278. properties = {
  53279. type: type,
  53280. name: baseFontName,
  53281. widths: metrics.widths,
  53282. defaultWidth: metrics.defaultWidth,
  53283. flags: flags,
  53284. firstChar: 0,
  53285. lastChar: maxCharIndex
  53286. };
  53287. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53288. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53289. return new Font(baseFontName, null, properties);
  53290. }.bind(this));
  53291. }
  53292. }
  53293. var firstChar = dict.get('FirstChar') || 0;
  53294. var lastChar = dict.get('LastChar') || maxCharIndex;
  53295. var fontName = descriptor.get('FontName');
  53296. var baseFont = dict.get('BaseFont');
  53297. if (isString(fontName)) {
  53298. fontName = Name.get(fontName);
  53299. }
  53300. if (isString(baseFont)) {
  53301. baseFont = Name.get(baseFont);
  53302. }
  53303. if (type !== 'Type3') {
  53304. var fontNameStr = fontName && fontName.name;
  53305. var baseFontStr = baseFont && baseFont.name;
  53306. if (fontNameStr !== baseFontStr) {
  53307. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53308. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53309. fontName = baseFont;
  53310. }
  53311. }
  53312. }
  53313. fontName = fontName || baseFont;
  53314. assert(isName(fontName), 'invalid font name');
  53315. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53316. if (fontFile) {
  53317. if (fontFile.dict) {
  53318. var subtype = fontFile.dict.get('Subtype');
  53319. if (subtype) {
  53320. subtype = subtype.name;
  53321. }
  53322. var length1 = fontFile.dict.get('Length1');
  53323. var length2 = fontFile.dict.get('Length2');
  53324. var length3 = fontFile.dict.get('Length3');
  53325. }
  53326. }
  53327. properties = {
  53328. type: type,
  53329. name: fontName.name,
  53330. subtype: subtype,
  53331. file: fontFile,
  53332. length1: length1,
  53333. length2: length2,
  53334. length3: length3,
  53335. loadedName: baseDict.loadedName,
  53336. composite: composite,
  53337. wideChars: composite,
  53338. fixedPitch: false,
  53339. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53340. firstChar: firstChar || 0,
  53341. lastChar: lastChar || maxCharIndex,
  53342. bbox: descriptor.getArray('FontBBox'),
  53343. ascent: descriptor.get('Ascent'),
  53344. descent: descriptor.get('Descent'),
  53345. xHeight: descriptor.get('XHeight'),
  53346. capHeight: descriptor.get('CapHeight'),
  53347. flags: descriptor.get('Flags'),
  53348. italicAngle: descriptor.get('ItalicAngle'),
  53349. coded: false
  53350. };
  53351. var cMapPromise;
  53352. if (composite) {
  53353. var cidEncoding = baseDict.get('Encoding');
  53354. if (isName(cidEncoding)) {
  53355. properties.cidEncoding = cidEncoding.name;
  53356. }
  53357. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53358. properties.cMap = cMap;
  53359. properties.vertical = properties.cMap.vertical;
  53360. });
  53361. } else {
  53362. cMapPromise = Promise.resolve(undefined);
  53363. }
  53364. return cMapPromise.then(function () {
  53365. return this.extractDataStructures(dict, baseDict, xref, properties);
  53366. }.bind(this)).then(function (properties) {
  53367. this.extractWidths(dict, xref, descriptor, properties);
  53368. if (type === 'Type3') {
  53369. properties.isType3Font = true;
  53370. }
  53371. return new Font(fontName.name, fontFile, properties);
  53372. }.bind(this));
  53373. }
  53374. };
  53375. return PartialEvaluator;
  53376. }();
  53377. var TranslatedFont = function TranslatedFontClosure() {
  53378. function TranslatedFont(loadedName, font, dict) {
  53379. this.loadedName = loadedName;
  53380. this.font = font;
  53381. this.dict = dict;
  53382. this.type3Loaded = null;
  53383. this.sent = false;
  53384. }
  53385. TranslatedFont.prototype = {
  53386. send: function (handler) {
  53387. if (this.sent) {
  53388. return;
  53389. }
  53390. var fontData = this.font.exportData();
  53391. handler.send('commonobj', [
  53392. this.loadedName,
  53393. 'Font',
  53394. fontData
  53395. ]);
  53396. this.sent = true;
  53397. },
  53398. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53399. assert(this.font.isType3Font);
  53400. if (this.type3Loaded) {
  53401. return this.type3Loaded;
  53402. }
  53403. var translatedFont = this.font;
  53404. var loadCharProcsPromise = Promise.resolve();
  53405. var charProcs = this.dict.get('CharProcs');
  53406. var fontResources = this.dict.get('Resources') || resources;
  53407. var charProcKeys = charProcs.getKeys();
  53408. var charProcOperatorList = Object.create(null);
  53409. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53410. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53411. var glyphStream = charProcs.get(key);
  53412. var operatorList = new OperatorList();
  53413. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53414. charProcOperatorList[key] = operatorList.getIR();
  53415. parentOperatorList.addDependencies(operatorList.dependencies);
  53416. }, function (reason) {
  53417. warn('Type3 font resource \"' + key + '\" is not available');
  53418. var operatorList = new OperatorList();
  53419. charProcOperatorList[key] = operatorList.getIR();
  53420. });
  53421. }.bind(this, charProcKeys[i]));
  53422. }
  53423. this.type3Loaded = loadCharProcsPromise.then(function () {
  53424. translatedFont.charProcOperatorList = charProcOperatorList;
  53425. });
  53426. return this.type3Loaded;
  53427. }
  53428. };
  53429. return TranslatedFont;
  53430. }();
  53431. var OperatorList = function OperatorListClosure() {
  53432. var CHUNK_SIZE = 1000;
  53433. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53434. function getTransfers(queue) {
  53435. var transfers = [];
  53436. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53437. for (var i = 0, ii = queue.length; i < ii; i++) {
  53438. switch (fnArray[i]) {
  53439. case OPS.paintInlineImageXObject:
  53440. case OPS.paintInlineImageXObjectGroup:
  53441. case OPS.paintImageMaskXObject:
  53442. var arg = argsArray[i][0];
  53443. if (!arg.cached) {
  53444. transfers.push(arg.data.buffer);
  53445. }
  53446. break;
  53447. }
  53448. }
  53449. return transfers;
  53450. }
  53451. function OperatorList(intent, messageHandler, pageIndex) {
  53452. this.messageHandler = messageHandler;
  53453. this.fnArray = [];
  53454. this.argsArray = [];
  53455. this.dependencies = Object.create(null);
  53456. this._totalLength = 0;
  53457. this.pageIndex = pageIndex;
  53458. this.intent = intent;
  53459. }
  53460. OperatorList.prototype = {
  53461. get length() {
  53462. return this.argsArray.length;
  53463. },
  53464. get totalLength() {
  53465. return this._totalLength + this.length;
  53466. },
  53467. addOp: function (fn, args) {
  53468. this.fnArray.push(fn);
  53469. this.argsArray.push(args);
  53470. if (this.messageHandler) {
  53471. if (this.fnArray.length >= CHUNK_SIZE) {
  53472. this.flush();
  53473. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53474. this.flush();
  53475. }
  53476. }
  53477. },
  53478. addDependency: function (dependency) {
  53479. if (dependency in this.dependencies) {
  53480. return;
  53481. }
  53482. this.dependencies[dependency] = true;
  53483. this.addOp(OPS.dependency, [dependency]);
  53484. },
  53485. addDependencies: function (dependencies) {
  53486. for (var key in dependencies) {
  53487. this.addDependency(key);
  53488. }
  53489. },
  53490. addOpList: function (opList) {
  53491. Util.extendObj(this.dependencies, opList.dependencies);
  53492. for (var i = 0, ii = opList.length; i < ii; i++) {
  53493. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53494. }
  53495. },
  53496. getIR: function () {
  53497. return {
  53498. fnArray: this.fnArray,
  53499. argsArray: this.argsArray,
  53500. length: this.length
  53501. };
  53502. },
  53503. flush: function (lastChunk) {
  53504. if (this.intent !== 'oplist') {
  53505. new QueueOptimizer().optimize(this);
  53506. }
  53507. var transfers = getTransfers(this);
  53508. var length = this.length;
  53509. this._totalLength += length;
  53510. this.messageHandler.send('RenderPageChunk', {
  53511. operatorList: {
  53512. fnArray: this.fnArray,
  53513. argsArray: this.argsArray,
  53514. lastChunk: lastChunk,
  53515. length: length
  53516. },
  53517. pageIndex: this.pageIndex,
  53518. intent: this.intent
  53519. }, transfers);
  53520. this.dependencies = Object.create(null);
  53521. this.fnArray.length = 0;
  53522. this.argsArray.length = 0;
  53523. }
  53524. };
  53525. return OperatorList;
  53526. }();
  53527. var StateManager = function StateManagerClosure() {
  53528. function StateManager(initialState) {
  53529. this.state = initialState;
  53530. this.stateStack = [];
  53531. }
  53532. StateManager.prototype = {
  53533. save: function () {
  53534. var old = this.state;
  53535. this.stateStack.push(this.state);
  53536. this.state = old.clone();
  53537. },
  53538. restore: function () {
  53539. var prev = this.stateStack.pop();
  53540. if (prev) {
  53541. this.state = prev;
  53542. }
  53543. },
  53544. transform: function (args) {
  53545. this.state.ctm = Util.transform(this.state.ctm, args);
  53546. }
  53547. };
  53548. return StateManager;
  53549. }();
  53550. var TextState = function TextStateClosure() {
  53551. function TextState() {
  53552. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53553. this.fontName = null;
  53554. this.fontSize = 0;
  53555. this.font = null;
  53556. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53557. this.textMatrix = IDENTITY_MATRIX.slice();
  53558. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53559. this.charSpacing = 0;
  53560. this.wordSpacing = 0;
  53561. this.leading = 0;
  53562. this.textHScale = 1;
  53563. this.textRise = 0;
  53564. }
  53565. TextState.prototype = {
  53566. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53567. var m = this.textMatrix;
  53568. m[0] = a;
  53569. m[1] = b;
  53570. m[2] = c;
  53571. m[3] = d;
  53572. m[4] = e;
  53573. m[5] = f;
  53574. },
  53575. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53576. var m = this.textLineMatrix;
  53577. m[0] = a;
  53578. m[1] = b;
  53579. m[2] = c;
  53580. m[3] = d;
  53581. m[4] = e;
  53582. m[5] = f;
  53583. },
  53584. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53585. var m = this.textMatrix;
  53586. m[4] = m[0] * x + m[2] * y + m[4];
  53587. m[5] = m[1] * x + m[3] * y + m[5];
  53588. },
  53589. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53590. var m = this.textLineMatrix;
  53591. m[4] = m[0] * x + m[2] * y + m[4];
  53592. m[5] = m[1] * x + m[3] * y + m[5];
  53593. },
  53594. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53595. var font = this.font;
  53596. if (!font) {
  53597. return null;
  53598. }
  53599. var m = this.textLineMatrix;
  53600. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53601. return null;
  53602. }
  53603. var txDiff = e - m[4], tyDiff = f - m[5];
  53604. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53605. return null;
  53606. }
  53607. var tx, ty, denominator = a * d - b * c;
  53608. if (font.vertical) {
  53609. tx = -tyDiff * c / denominator;
  53610. ty = tyDiff * a / denominator;
  53611. } else {
  53612. tx = txDiff * d / denominator;
  53613. ty = -txDiff * b / denominator;
  53614. }
  53615. return {
  53616. width: tx,
  53617. height: ty,
  53618. value: font.vertical ? ty : tx
  53619. };
  53620. },
  53621. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53622. var tsm = [
  53623. this.fontSize * this.textHScale,
  53624. 0,
  53625. 0,
  53626. this.fontSize,
  53627. 0,
  53628. this.textRise
  53629. ];
  53630. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53631. },
  53632. carriageReturn: function TextState_carriageReturn() {
  53633. this.translateTextLineMatrix(0, -this.leading);
  53634. this.textMatrix = this.textLineMatrix.slice();
  53635. },
  53636. clone: function TextState_clone() {
  53637. var clone = Object.create(this);
  53638. clone.textMatrix = this.textMatrix.slice();
  53639. clone.textLineMatrix = this.textLineMatrix.slice();
  53640. clone.fontMatrix = this.fontMatrix.slice();
  53641. return clone;
  53642. }
  53643. };
  53644. return TextState;
  53645. }();
  53646. var EvalState = function EvalStateClosure() {
  53647. function EvalState() {
  53648. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53649. this.font = null;
  53650. this.textRenderingMode = TextRenderingMode.FILL;
  53651. this.fillColorSpace = ColorSpace.singletons.gray;
  53652. this.strokeColorSpace = ColorSpace.singletons.gray;
  53653. }
  53654. EvalState.prototype = {
  53655. clone: function CanvasExtraState_clone() {
  53656. return Object.create(this);
  53657. }
  53658. };
  53659. return EvalState;
  53660. }();
  53661. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53662. var getOPMap = getLookupTableFactory(function (t) {
  53663. t['w'] = {
  53664. id: OPS.setLineWidth,
  53665. numArgs: 1,
  53666. variableArgs: false
  53667. };
  53668. t['J'] = {
  53669. id: OPS.setLineCap,
  53670. numArgs: 1,
  53671. variableArgs: false
  53672. };
  53673. t['j'] = {
  53674. id: OPS.setLineJoin,
  53675. numArgs: 1,
  53676. variableArgs: false
  53677. };
  53678. t['M'] = {
  53679. id: OPS.setMiterLimit,
  53680. numArgs: 1,
  53681. variableArgs: false
  53682. };
  53683. t['d'] = {
  53684. id: OPS.setDash,
  53685. numArgs: 2,
  53686. variableArgs: false
  53687. };
  53688. t['ri'] = {
  53689. id: OPS.setRenderingIntent,
  53690. numArgs: 1,
  53691. variableArgs: false
  53692. };
  53693. t['i'] = {
  53694. id: OPS.setFlatness,
  53695. numArgs: 1,
  53696. variableArgs: false
  53697. };
  53698. t['gs'] = {
  53699. id: OPS.setGState,
  53700. numArgs: 1,
  53701. variableArgs: false
  53702. };
  53703. t['q'] = {
  53704. id: OPS.save,
  53705. numArgs: 0,
  53706. variableArgs: false
  53707. };
  53708. t['Q'] = {
  53709. id: OPS.restore,
  53710. numArgs: 0,
  53711. variableArgs: false
  53712. };
  53713. t['cm'] = {
  53714. id: OPS.transform,
  53715. numArgs: 6,
  53716. variableArgs: false
  53717. };
  53718. t['m'] = {
  53719. id: OPS.moveTo,
  53720. numArgs: 2,
  53721. variableArgs: false
  53722. };
  53723. t['l'] = {
  53724. id: OPS.lineTo,
  53725. numArgs: 2,
  53726. variableArgs: false
  53727. };
  53728. t['c'] = {
  53729. id: OPS.curveTo,
  53730. numArgs: 6,
  53731. variableArgs: false
  53732. };
  53733. t['v'] = {
  53734. id: OPS.curveTo2,
  53735. numArgs: 4,
  53736. variableArgs: false
  53737. };
  53738. t['y'] = {
  53739. id: OPS.curveTo3,
  53740. numArgs: 4,
  53741. variableArgs: false
  53742. };
  53743. t['h'] = {
  53744. id: OPS.closePath,
  53745. numArgs: 0,
  53746. variableArgs: false
  53747. };
  53748. t['re'] = {
  53749. id: OPS.rectangle,
  53750. numArgs: 4,
  53751. variableArgs: false
  53752. };
  53753. t['S'] = {
  53754. id: OPS.stroke,
  53755. numArgs: 0,
  53756. variableArgs: false
  53757. };
  53758. t['s'] = {
  53759. id: OPS.closeStroke,
  53760. numArgs: 0,
  53761. variableArgs: false
  53762. };
  53763. t['f'] = {
  53764. id: OPS.fill,
  53765. numArgs: 0,
  53766. variableArgs: false
  53767. };
  53768. t['F'] = {
  53769. id: OPS.fill,
  53770. numArgs: 0,
  53771. variableArgs: false
  53772. };
  53773. t['f*'] = {
  53774. id: OPS.eoFill,
  53775. numArgs: 0,
  53776. variableArgs: false
  53777. };
  53778. t['B'] = {
  53779. id: OPS.fillStroke,
  53780. numArgs: 0,
  53781. variableArgs: false
  53782. };
  53783. t['B*'] = {
  53784. id: OPS.eoFillStroke,
  53785. numArgs: 0,
  53786. variableArgs: false
  53787. };
  53788. t['b'] = {
  53789. id: OPS.closeFillStroke,
  53790. numArgs: 0,
  53791. variableArgs: false
  53792. };
  53793. t['b*'] = {
  53794. id: OPS.closeEOFillStroke,
  53795. numArgs: 0,
  53796. variableArgs: false
  53797. };
  53798. t['n'] = {
  53799. id: OPS.endPath,
  53800. numArgs: 0,
  53801. variableArgs: false
  53802. };
  53803. t['W'] = {
  53804. id: OPS.clip,
  53805. numArgs: 0,
  53806. variableArgs: false
  53807. };
  53808. t['W*'] = {
  53809. id: OPS.eoClip,
  53810. numArgs: 0,
  53811. variableArgs: false
  53812. };
  53813. t['BT'] = {
  53814. id: OPS.beginText,
  53815. numArgs: 0,
  53816. variableArgs: false
  53817. };
  53818. t['ET'] = {
  53819. id: OPS.endText,
  53820. numArgs: 0,
  53821. variableArgs: false
  53822. };
  53823. t['Tc'] = {
  53824. id: OPS.setCharSpacing,
  53825. numArgs: 1,
  53826. variableArgs: false
  53827. };
  53828. t['Tw'] = {
  53829. id: OPS.setWordSpacing,
  53830. numArgs: 1,
  53831. variableArgs: false
  53832. };
  53833. t['Tz'] = {
  53834. id: OPS.setHScale,
  53835. numArgs: 1,
  53836. variableArgs: false
  53837. };
  53838. t['TL'] = {
  53839. id: OPS.setLeading,
  53840. numArgs: 1,
  53841. variableArgs: false
  53842. };
  53843. t['Tf'] = {
  53844. id: OPS.setFont,
  53845. numArgs: 2,
  53846. variableArgs: false
  53847. };
  53848. t['Tr'] = {
  53849. id: OPS.setTextRenderingMode,
  53850. numArgs: 1,
  53851. variableArgs: false
  53852. };
  53853. t['Ts'] = {
  53854. id: OPS.setTextRise,
  53855. numArgs: 1,
  53856. variableArgs: false
  53857. };
  53858. t['Td'] = {
  53859. id: OPS.moveText,
  53860. numArgs: 2,
  53861. variableArgs: false
  53862. };
  53863. t['TD'] = {
  53864. id: OPS.setLeadingMoveText,
  53865. numArgs: 2,
  53866. variableArgs: false
  53867. };
  53868. t['Tm'] = {
  53869. id: OPS.setTextMatrix,
  53870. numArgs: 6,
  53871. variableArgs: false
  53872. };
  53873. t['T*'] = {
  53874. id: OPS.nextLine,
  53875. numArgs: 0,
  53876. variableArgs: false
  53877. };
  53878. t['Tj'] = {
  53879. id: OPS.showText,
  53880. numArgs: 1,
  53881. variableArgs: false
  53882. };
  53883. t['TJ'] = {
  53884. id: OPS.showSpacedText,
  53885. numArgs: 1,
  53886. variableArgs: false
  53887. };
  53888. t['\''] = {
  53889. id: OPS.nextLineShowText,
  53890. numArgs: 1,
  53891. variableArgs: false
  53892. };
  53893. t['"'] = {
  53894. id: OPS.nextLineSetSpacingShowText,
  53895. numArgs: 3,
  53896. variableArgs: false
  53897. };
  53898. t['d0'] = {
  53899. id: OPS.setCharWidth,
  53900. numArgs: 2,
  53901. variableArgs: false
  53902. };
  53903. t['d1'] = {
  53904. id: OPS.setCharWidthAndBounds,
  53905. numArgs: 6,
  53906. variableArgs: false
  53907. };
  53908. t['CS'] = {
  53909. id: OPS.setStrokeColorSpace,
  53910. numArgs: 1,
  53911. variableArgs: false
  53912. };
  53913. t['cs'] = {
  53914. id: OPS.setFillColorSpace,
  53915. numArgs: 1,
  53916. variableArgs: false
  53917. };
  53918. t['SC'] = {
  53919. id: OPS.setStrokeColor,
  53920. numArgs: 4,
  53921. variableArgs: true
  53922. };
  53923. t['SCN'] = {
  53924. id: OPS.setStrokeColorN,
  53925. numArgs: 33,
  53926. variableArgs: true
  53927. };
  53928. t['sc'] = {
  53929. id: OPS.setFillColor,
  53930. numArgs: 4,
  53931. variableArgs: true
  53932. };
  53933. t['scn'] = {
  53934. id: OPS.setFillColorN,
  53935. numArgs: 33,
  53936. variableArgs: true
  53937. };
  53938. t['G'] = {
  53939. id: OPS.setStrokeGray,
  53940. numArgs: 1,
  53941. variableArgs: false
  53942. };
  53943. t['g'] = {
  53944. id: OPS.setFillGray,
  53945. numArgs: 1,
  53946. variableArgs: false
  53947. };
  53948. t['RG'] = {
  53949. id: OPS.setStrokeRGBColor,
  53950. numArgs: 3,
  53951. variableArgs: false
  53952. };
  53953. t['rg'] = {
  53954. id: OPS.setFillRGBColor,
  53955. numArgs: 3,
  53956. variableArgs: false
  53957. };
  53958. t['K'] = {
  53959. id: OPS.setStrokeCMYKColor,
  53960. numArgs: 4,
  53961. variableArgs: false
  53962. };
  53963. t['k'] = {
  53964. id: OPS.setFillCMYKColor,
  53965. numArgs: 4,
  53966. variableArgs: false
  53967. };
  53968. t['sh'] = {
  53969. id: OPS.shadingFill,
  53970. numArgs: 1,
  53971. variableArgs: false
  53972. };
  53973. t['BI'] = {
  53974. id: OPS.beginInlineImage,
  53975. numArgs: 0,
  53976. variableArgs: false
  53977. };
  53978. t['ID'] = {
  53979. id: OPS.beginImageData,
  53980. numArgs: 0,
  53981. variableArgs: false
  53982. };
  53983. t['EI'] = {
  53984. id: OPS.endInlineImage,
  53985. numArgs: 1,
  53986. variableArgs: false
  53987. };
  53988. t['Do'] = {
  53989. id: OPS.paintXObject,
  53990. numArgs: 1,
  53991. variableArgs: false
  53992. };
  53993. t['MP'] = {
  53994. id: OPS.markPoint,
  53995. numArgs: 1,
  53996. variableArgs: false
  53997. };
  53998. t['DP'] = {
  53999. id: OPS.markPointProps,
  54000. numArgs: 2,
  54001. variableArgs: false
  54002. };
  54003. t['BMC'] = {
  54004. id: OPS.beginMarkedContent,
  54005. numArgs: 1,
  54006. variableArgs: false
  54007. };
  54008. t['BDC'] = {
  54009. id: OPS.beginMarkedContentProps,
  54010. numArgs: 2,
  54011. variableArgs: false
  54012. };
  54013. t['EMC'] = {
  54014. id: OPS.endMarkedContent,
  54015. numArgs: 0,
  54016. variableArgs: false
  54017. };
  54018. t['BX'] = {
  54019. id: OPS.beginCompat,
  54020. numArgs: 0,
  54021. variableArgs: false
  54022. };
  54023. t['EX'] = {
  54024. id: OPS.endCompat,
  54025. numArgs: 0,
  54026. variableArgs: false
  54027. };
  54028. t['BM'] = null;
  54029. t['BD'] = null;
  54030. t['true'] = null;
  54031. t['fa'] = null;
  54032. t['fal'] = null;
  54033. t['fals'] = null;
  54034. t['false'] = null;
  54035. t['nu'] = null;
  54036. t['nul'] = null;
  54037. t['null'] = null;
  54038. });
  54039. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54040. this.opMap = getOPMap();
  54041. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54042. this.stateManager = stateManager;
  54043. this.nonProcessedArgs = [];
  54044. }
  54045. EvaluatorPreprocessor.prototype = {
  54046. get savedStatesDepth() {
  54047. return this.stateManager.stateStack.length;
  54048. },
  54049. read: function EvaluatorPreprocessor_read(operation) {
  54050. var args = operation.args;
  54051. while (true) {
  54052. var obj = this.parser.getObj();
  54053. if (isCmd(obj)) {
  54054. var cmd = obj.cmd;
  54055. var opSpec = this.opMap[cmd];
  54056. if (!opSpec) {
  54057. warn('Unknown command "' + cmd + '"');
  54058. continue;
  54059. }
  54060. var fn = opSpec.id;
  54061. var numArgs = opSpec.numArgs;
  54062. var argsLength = args !== null ? args.length : 0;
  54063. if (!opSpec.variableArgs) {
  54064. if (argsLength !== numArgs) {
  54065. var nonProcessedArgs = this.nonProcessedArgs;
  54066. while (argsLength > numArgs) {
  54067. nonProcessedArgs.push(args.shift());
  54068. argsLength--;
  54069. }
  54070. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54071. if (args === null) {
  54072. args = [];
  54073. }
  54074. args.unshift(nonProcessedArgs.pop());
  54075. argsLength++;
  54076. }
  54077. }
  54078. if (argsLength < numArgs) {
  54079. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54080. if (args !== null) {
  54081. args.length = 0;
  54082. }
  54083. continue;
  54084. }
  54085. } else if (argsLength > numArgs) {
  54086. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54087. }
  54088. this.preprocessCommand(fn, args);
  54089. operation.fn = fn;
  54090. operation.args = args;
  54091. return true;
  54092. } else {
  54093. if (isEOF(obj)) {
  54094. return false;
  54095. }
  54096. if (obj !== null) {
  54097. if (args === null) {
  54098. args = [];
  54099. }
  54100. args.push(obj);
  54101. assert(args.length <= 33, 'Too many arguments');
  54102. }
  54103. }
  54104. }
  54105. },
  54106. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54107. switch (fn | 0) {
  54108. case OPS.save:
  54109. this.stateManager.save();
  54110. break;
  54111. case OPS.restore:
  54112. this.stateManager.restore();
  54113. break;
  54114. case OPS.transform:
  54115. this.stateManager.transform(args);
  54116. break;
  54117. }
  54118. }
  54119. };
  54120. return EvaluatorPreprocessor;
  54121. }();
  54122. var QueueOptimizer = function QueueOptimizerClosure() {
  54123. function addState(parentState, pattern, fn) {
  54124. var state = parentState;
  54125. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54126. var item = pattern[i];
  54127. state = state[item] || (state[item] = []);
  54128. }
  54129. state[pattern[pattern.length - 1]] = fn;
  54130. }
  54131. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54132. var iFirstPIMXO = iFirstSave + 2;
  54133. for (var i = 0; i < count; i++) {
  54134. var arg = argsArray[iFirstPIMXO + 4 * i];
  54135. var imageMask = arg.length === 1 && arg[0];
  54136. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54137. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54138. continue;
  54139. }
  54140. break;
  54141. }
  54142. return count - i;
  54143. }
  54144. var InitialState = [];
  54145. addState(InitialState, [
  54146. OPS.save,
  54147. OPS.transform,
  54148. OPS.paintInlineImageXObject,
  54149. OPS.restore
  54150. ], function foundInlineImageGroup(context) {
  54151. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54152. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54153. var MAX_WIDTH = 1000;
  54154. var IMAGE_PADDING = 1;
  54155. var fnArray = context.fnArray, argsArray = context.argsArray;
  54156. var curr = context.iCurr;
  54157. var iFirstSave = curr - 3;
  54158. var iFirstTransform = curr - 2;
  54159. var iFirstPIIXO = curr - 1;
  54160. var i = iFirstSave + 4;
  54161. var ii = fnArray.length;
  54162. while (i + 3 < ii) {
  54163. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54164. break;
  54165. }
  54166. i += 4;
  54167. }
  54168. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54169. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54170. return i;
  54171. }
  54172. var maxX = 0;
  54173. var map = [], maxLineHeight = 0;
  54174. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54175. var q;
  54176. for (q = 0; q < count; q++) {
  54177. var transform = argsArray[iFirstTransform + (q << 2)];
  54178. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54179. if (currentX + img.width > MAX_WIDTH) {
  54180. maxX = Math.max(maxX, currentX);
  54181. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54182. currentX = 0;
  54183. maxLineHeight = 0;
  54184. }
  54185. map.push({
  54186. transform: transform,
  54187. x: currentX,
  54188. y: currentY,
  54189. w: img.width,
  54190. h: img.height
  54191. });
  54192. currentX += img.width + 2 * IMAGE_PADDING;
  54193. maxLineHeight = Math.max(maxLineHeight, img.height);
  54194. }
  54195. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54196. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54197. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54198. var imgRowSize = imgWidth << 2;
  54199. for (q = 0; q < count; q++) {
  54200. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54201. var rowSize = map[q].w << 2;
  54202. var dataOffset = 0;
  54203. var offset = map[q].x + map[q].y * imgWidth << 2;
  54204. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54205. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54206. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54207. dataOffset += rowSize;
  54208. offset += imgRowSize;
  54209. }
  54210. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54211. while (offset >= 0) {
  54212. data[offset - 4] = data[offset];
  54213. data[offset - 3] = data[offset + 1];
  54214. data[offset - 2] = data[offset + 2];
  54215. data[offset - 1] = data[offset + 3];
  54216. data[offset + rowSize] = data[offset + rowSize - 4];
  54217. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54218. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54219. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54220. offset -= imgRowSize;
  54221. }
  54222. }
  54223. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54224. argsArray.splice(iFirstSave, count * 4, [
  54225. {
  54226. width: imgWidth,
  54227. height: imgHeight,
  54228. kind: ImageKind.RGBA_32BPP,
  54229. data: imgData
  54230. },
  54231. map
  54232. ]);
  54233. return iFirstSave + 1;
  54234. });
  54235. addState(InitialState, [
  54236. OPS.save,
  54237. OPS.transform,
  54238. OPS.paintImageMaskXObject,
  54239. OPS.restore
  54240. ], function foundImageMaskGroup(context) {
  54241. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54242. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54243. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54244. var fnArray = context.fnArray, argsArray = context.argsArray;
  54245. var curr = context.iCurr;
  54246. var iFirstSave = curr - 3;
  54247. var iFirstTransform = curr - 2;
  54248. var iFirstPIMXO = curr - 1;
  54249. var i = iFirstSave + 4;
  54250. var ii = fnArray.length;
  54251. while (i + 3 < ii) {
  54252. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54253. break;
  54254. }
  54255. i += 4;
  54256. }
  54257. var count = (i - iFirstSave) / 4;
  54258. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54259. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54260. return i;
  54261. }
  54262. var q;
  54263. var isSameImage = false;
  54264. var iTransform, transformArgs;
  54265. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54266. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54267. isSameImage = true;
  54268. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54269. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54270. iTransform = iFirstTransform + 4;
  54271. var iPIMXO = iFirstPIMXO + 4;
  54272. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54273. transformArgs = argsArray[iTransform];
  54274. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54275. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54276. isSameImage = false;
  54277. } else {
  54278. count = q;
  54279. }
  54280. break;
  54281. }
  54282. }
  54283. }
  54284. if (isSameImage) {
  54285. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54286. var positions = new Float32Array(count * 2);
  54287. iTransform = iFirstTransform;
  54288. for (q = 0; q < count; q++, iTransform += 4) {
  54289. transformArgs = argsArray[iTransform];
  54290. positions[q << 1] = transformArgs[4];
  54291. positions[(q << 1) + 1] = transformArgs[5];
  54292. }
  54293. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54294. argsArray.splice(iFirstSave, count * 4, [
  54295. firstPIMXOArg0,
  54296. firstTransformArg0,
  54297. firstTransformArg3,
  54298. positions
  54299. ]);
  54300. } else {
  54301. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54302. var images = [];
  54303. for (q = 0; q < count; q++) {
  54304. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54305. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54306. images.push({
  54307. data: maskParams.data,
  54308. width: maskParams.width,
  54309. height: maskParams.height,
  54310. transform: transformArgs
  54311. });
  54312. }
  54313. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54314. argsArray.splice(iFirstSave, count * 4, [images]);
  54315. }
  54316. return iFirstSave + 1;
  54317. });
  54318. addState(InitialState, [
  54319. OPS.save,
  54320. OPS.transform,
  54321. OPS.paintImageXObject,
  54322. OPS.restore
  54323. ], function (context) {
  54324. var MIN_IMAGES_IN_BLOCK = 3;
  54325. var MAX_IMAGES_IN_BLOCK = 1000;
  54326. var fnArray = context.fnArray, argsArray = context.argsArray;
  54327. var curr = context.iCurr;
  54328. var iFirstSave = curr - 3;
  54329. var iFirstTransform = curr - 2;
  54330. var iFirstPIXO = curr - 1;
  54331. var iFirstRestore = curr;
  54332. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54333. return iFirstRestore + 1;
  54334. }
  54335. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54336. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54337. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54338. var i = iFirstSave + 4;
  54339. var ii = fnArray.length;
  54340. while (i + 3 < ii) {
  54341. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54342. break;
  54343. }
  54344. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54345. break;
  54346. }
  54347. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54348. break;
  54349. }
  54350. i += 4;
  54351. }
  54352. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54353. if (count < MIN_IMAGES_IN_BLOCK) {
  54354. return i;
  54355. }
  54356. var positions = new Float32Array(count * 2);
  54357. var iTransform = iFirstTransform;
  54358. for (var q = 0; q < count; q++, iTransform += 4) {
  54359. var transformArgs = argsArray[iTransform];
  54360. positions[q << 1] = transformArgs[4];
  54361. positions[(q << 1) + 1] = transformArgs[5];
  54362. }
  54363. var args = [
  54364. firstPIXOArg0,
  54365. firstTransformArg0,
  54366. firstTransformArg3,
  54367. positions
  54368. ];
  54369. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54370. argsArray.splice(iFirstSave, count * 4, args);
  54371. return iFirstSave + 1;
  54372. });
  54373. addState(InitialState, [
  54374. OPS.beginText,
  54375. OPS.setFont,
  54376. OPS.setTextMatrix,
  54377. OPS.showText,
  54378. OPS.endText
  54379. ], function (context) {
  54380. var MIN_CHARS_IN_BLOCK = 3;
  54381. var MAX_CHARS_IN_BLOCK = 1000;
  54382. var fnArray = context.fnArray, argsArray = context.argsArray;
  54383. var curr = context.iCurr;
  54384. var iFirstBeginText = curr - 4;
  54385. var iFirstSetFont = curr - 3;
  54386. var iFirstSetTextMatrix = curr - 2;
  54387. var iFirstShowText = curr - 1;
  54388. var iFirstEndText = curr;
  54389. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54390. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54391. var i = iFirstBeginText + 5;
  54392. var ii = fnArray.length;
  54393. while (i + 4 < ii) {
  54394. 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) {
  54395. break;
  54396. }
  54397. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54398. break;
  54399. }
  54400. i += 5;
  54401. }
  54402. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54403. if (count < MIN_CHARS_IN_BLOCK) {
  54404. return i;
  54405. }
  54406. var iFirst = iFirstBeginText;
  54407. 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) {
  54408. count++;
  54409. iFirst -= 5;
  54410. }
  54411. var iEndText = iFirst + 4;
  54412. for (var q = 1; q < count; q++) {
  54413. fnArray.splice(iEndText, 3);
  54414. argsArray.splice(iEndText, 3);
  54415. iEndText += 2;
  54416. }
  54417. return iEndText + 1;
  54418. });
  54419. function QueueOptimizer() {
  54420. }
  54421. QueueOptimizer.prototype = {
  54422. optimize: function QueueOptimizer_optimize(queue) {
  54423. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54424. var context = {
  54425. iCurr: 0,
  54426. fnArray: fnArray,
  54427. argsArray: argsArray
  54428. };
  54429. var state;
  54430. var i = 0, ii = fnArray.length;
  54431. while (i < ii) {
  54432. state = (state || InitialState)[fnArray[i]];
  54433. if (typeof state === 'function') {
  54434. context.iCurr = i;
  54435. i = state(context);
  54436. state = undefined;
  54437. ii = context.fnArray.length;
  54438. } else {
  54439. i++;
  54440. }
  54441. }
  54442. }
  54443. };
  54444. return QueueOptimizer;
  54445. }();
  54446. exports.OperatorList = OperatorList;
  54447. exports.PartialEvaluator = PartialEvaluator;
  54448. }));
  54449. (function (root, factory) {
  54450. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54451. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54452. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54453. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54454. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54455. var AnnotationType = sharedUtil.AnnotationType;
  54456. var OPS = sharedUtil.OPS;
  54457. var Util = sharedUtil.Util;
  54458. var isString = sharedUtil.isString;
  54459. var isArray = sharedUtil.isArray;
  54460. var isInt = sharedUtil.isInt;
  54461. var stringToBytes = sharedUtil.stringToBytes;
  54462. var stringToPDFString = sharedUtil.stringToPDFString;
  54463. var warn = sharedUtil.warn;
  54464. var Dict = corePrimitives.Dict;
  54465. var isDict = corePrimitives.isDict;
  54466. var isName = corePrimitives.isName;
  54467. var isRef = corePrimitives.isRef;
  54468. var Stream = coreStream.Stream;
  54469. var ColorSpace = coreColorSpace.ColorSpace;
  54470. var Catalog = coreObj.Catalog;
  54471. var ObjectLoader = coreObj.ObjectLoader;
  54472. var FileSpec = coreObj.FileSpec;
  54473. var OperatorList = coreEvaluator.OperatorList;
  54474. function AnnotationFactory() {
  54475. }
  54476. AnnotationFactory.prototype = {
  54477. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  54478. var dict = xref.fetchIfRef(ref);
  54479. if (!isDict(dict)) {
  54480. return;
  54481. }
  54482. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  54483. var subtype = dict.get('Subtype');
  54484. subtype = isName(subtype) ? subtype.name : null;
  54485. var parameters = {
  54486. xref: xref,
  54487. dict: dict,
  54488. ref: isRef(ref) ? ref : null,
  54489. subtype: subtype,
  54490. id: id,
  54491. pdfManager: pdfManager
  54492. };
  54493. switch (subtype) {
  54494. case 'Link':
  54495. return new LinkAnnotation(parameters);
  54496. case 'Text':
  54497. return new TextAnnotation(parameters);
  54498. case 'Widget':
  54499. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54500. fieldType = isName(fieldType) ? fieldType.name : null;
  54501. switch (fieldType) {
  54502. case 'Tx':
  54503. return new TextWidgetAnnotation(parameters);
  54504. case 'Ch':
  54505. return new ChoiceWidgetAnnotation(parameters);
  54506. }
  54507. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54508. return new WidgetAnnotation(parameters);
  54509. case 'Popup':
  54510. return new PopupAnnotation(parameters);
  54511. case 'Highlight':
  54512. return new HighlightAnnotation(parameters);
  54513. case 'Underline':
  54514. return new UnderlineAnnotation(parameters);
  54515. case 'Squiggly':
  54516. return new SquigglyAnnotation(parameters);
  54517. case 'StrikeOut':
  54518. return new StrikeOutAnnotation(parameters);
  54519. case 'FileAttachment':
  54520. return new FileAttachmentAnnotation(parameters);
  54521. default:
  54522. if (!subtype) {
  54523. warn('Annotation is missing the required /Subtype.');
  54524. } else {
  54525. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54526. }
  54527. return new Annotation(parameters);
  54528. }
  54529. }
  54530. };
  54531. var Annotation = function AnnotationClosure() {
  54532. function getTransformMatrix(rect, bbox, matrix) {
  54533. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54534. var minX = bounds[0];
  54535. var minY = bounds[1];
  54536. var maxX = bounds[2];
  54537. var maxY = bounds[3];
  54538. if (minX === maxX || minY === maxY) {
  54539. return [
  54540. 1,
  54541. 0,
  54542. 0,
  54543. 1,
  54544. rect[0],
  54545. rect[1]
  54546. ];
  54547. }
  54548. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54549. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54550. return [
  54551. xRatio,
  54552. 0,
  54553. 0,
  54554. yRatio,
  54555. rect[0] - minX * xRatio,
  54556. rect[1] - minY * yRatio
  54557. ];
  54558. }
  54559. function getDefaultAppearance(dict) {
  54560. var appearanceState = dict.get('AP');
  54561. if (!isDict(appearanceState)) {
  54562. return;
  54563. }
  54564. var appearance;
  54565. var appearances = appearanceState.get('N');
  54566. if (isDict(appearances)) {
  54567. var as = dict.get('AS');
  54568. if (as && appearances.has(as.name)) {
  54569. appearance = appearances.get(as.name);
  54570. }
  54571. } else {
  54572. appearance = appearances;
  54573. }
  54574. return appearance;
  54575. }
  54576. function Annotation(params) {
  54577. var dict = params.dict;
  54578. this.setFlags(dict.get('F'));
  54579. this.setRectangle(dict.getArray('Rect'));
  54580. this.setColor(dict.getArray('C'));
  54581. this.setBorderStyle(dict);
  54582. this.appearance = getDefaultAppearance(dict);
  54583. this.data = {};
  54584. this.data.id = params.id;
  54585. this.data.subtype = params.subtype;
  54586. this.data.annotationFlags = this.flags;
  54587. this.data.rect = this.rectangle;
  54588. this.data.color = this.color;
  54589. this.data.borderStyle = this.borderStyle;
  54590. this.data.hasAppearance = !!this.appearance;
  54591. }
  54592. Annotation.prototype = {
  54593. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54594. return !!(flags & flag);
  54595. },
  54596. _isViewable: function Annotation_isViewable(flags) {
  54597. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54598. },
  54599. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54600. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54601. },
  54602. get viewable() {
  54603. if (this.flags === 0) {
  54604. return true;
  54605. }
  54606. return this._isViewable(this.flags);
  54607. },
  54608. get printable() {
  54609. if (this.flags === 0) {
  54610. return false;
  54611. }
  54612. return this._isPrintable(this.flags);
  54613. },
  54614. setFlags: function Annotation_setFlags(flags) {
  54615. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54616. },
  54617. hasFlag: function Annotation_hasFlag(flag) {
  54618. return this._hasFlag(this.flags, flag);
  54619. },
  54620. setRectangle: function Annotation_setRectangle(rectangle) {
  54621. if (isArray(rectangle) && rectangle.length === 4) {
  54622. this.rectangle = Util.normalizeRect(rectangle);
  54623. } else {
  54624. this.rectangle = [
  54625. 0,
  54626. 0,
  54627. 0,
  54628. 0
  54629. ];
  54630. }
  54631. },
  54632. setColor: function Annotation_setColor(color) {
  54633. var rgbColor = new Uint8Array(3);
  54634. if (!isArray(color)) {
  54635. this.color = rgbColor;
  54636. return;
  54637. }
  54638. switch (color.length) {
  54639. case 0:
  54640. this.color = null;
  54641. break;
  54642. case 1:
  54643. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54644. this.color = rgbColor;
  54645. break;
  54646. case 3:
  54647. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54648. this.color = rgbColor;
  54649. break;
  54650. case 4:
  54651. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54652. this.color = rgbColor;
  54653. break;
  54654. default:
  54655. this.color = rgbColor;
  54656. break;
  54657. }
  54658. },
  54659. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54660. this.borderStyle = new AnnotationBorderStyle();
  54661. if (!isDict(borderStyle)) {
  54662. return;
  54663. }
  54664. if (borderStyle.has('BS')) {
  54665. var dict = borderStyle.get('BS');
  54666. var dictType = dict.get('Type');
  54667. if (!dictType || isName(dictType, 'Border')) {
  54668. this.borderStyle.setWidth(dict.get('W'));
  54669. this.borderStyle.setStyle(dict.get('S'));
  54670. this.borderStyle.setDashArray(dict.getArray('D'));
  54671. }
  54672. } else if (borderStyle.has('Border')) {
  54673. var array = borderStyle.getArray('Border');
  54674. if (isArray(array) && array.length >= 3) {
  54675. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54676. this.borderStyle.setVerticalCornerRadius(array[1]);
  54677. this.borderStyle.setWidth(array[2]);
  54678. if (array.length === 4) {
  54679. this.borderStyle.setDashArray(array[3]);
  54680. }
  54681. }
  54682. } else {
  54683. this.borderStyle.setWidth(0);
  54684. }
  54685. },
  54686. _preparePopup: function Annotation_preparePopup(dict) {
  54687. if (!dict.has('C')) {
  54688. this.data.color = null;
  54689. }
  54690. this.data.hasPopup = dict.has('Popup');
  54691. this.data.title = stringToPDFString(dict.get('T') || '');
  54692. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54693. },
  54694. loadResources: function Annotation_loadResources(keys) {
  54695. return new Promise(function (resolve, reject) {
  54696. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54697. if (!resources) {
  54698. resolve();
  54699. return;
  54700. }
  54701. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54702. objectLoader.load().then(function () {
  54703. resolve(resources);
  54704. }, reject);
  54705. }, reject);
  54706. }.bind(this));
  54707. },
  54708. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54709. if (!this.appearance) {
  54710. return Promise.resolve(new OperatorList());
  54711. }
  54712. var data = this.data;
  54713. var appearanceDict = this.appearance.dict;
  54714. var resourcesPromise = this.loadResources([
  54715. 'ExtGState',
  54716. 'ColorSpace',
  54717. 'Pattern',
  54718. 'Shading',
  54719. 'XObject',
  54720. 'Font'
  54721. ]);
  54722. var bbox = appearanceDict.getArray('BBox') || [
  54723. 0,
  54724. 0,
  54725. 1,
  54726. 1
  54727. ];
  54728. var matrix = appearanceDict.getArray('Matrix') || [
  54729. 1,
  54730. 0,
  54731. 0,
  54732. 1,
  54733. 0,
  54734. 0
  54735. ];
  54736. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54737. var self = this;
  54738. return resourcesPromise.then(function (resources) {
  54739. var opList = new OperatorList();
  54740. opList.addOp(OPS.beginAnnotation, [
  54741. data.rect,
  54742. transform,
  54743. matrix
  54744. ]);
  54745. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54746. opList.addOp(OPS.endAnnotation, []);
  54747. self.appearance.reset();
  54748. return opList;
  54749. });
  54750. });
  54751. }
  54752. };
  54753. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54754. var annotationPromises = [];
  54755. for (var i = 0, n = annotations.length; i < n; ++i) {
  54756. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54757. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54758. }
  54759. }
  54760. return Promise.all(annotationPromises).then(function (operatorLists) {
  54761. opList.addOp(OPS.beginAnnotations, []);
  54762. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54763. opList.addOpList(operatorLists[i]);
  54764. }
  54765. opList.addOp(OPS.endAnnotations, []);
  54766. });
  54767. };
  54768. return Annotation;
  54769. }();
  54770. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54771. function AnnotationBorderStyle() {
  54772. this.width = 1;
  54773. this.style = AnnotationBorderStyleType.SOLID;
  54774. this.dashArray = [3];
  54775. this.horizontalCornerRadius = 0;
  54776. this.verticalCornerRadius = 0;
  54777. }
  54778. AnnotationBorderStyle.prototype = {
  54779. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54780. if (width === (width | 0)) {
  54781. this.width = width;
  54782. }
  54783. },
  54784. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54785. if (!style) {
  54786. return;
  54787. }
  54788. switch (style.name) {
  54789. case 'S':
  54790. this.style = AnnotationBorderStyleType.SOLID;
  54791. break;
  54792. case 'D':
  54793. this.style = AnnotationBorderStyleType.DASHED;
  54794. break;
  54795. case 'B':
  54796. this.style = AnnotationBorderStyleType.BEVELED;
  54797. break;
  54798. case 'I':
  54799. this.style = AnnotationBorderStyleType.INSET;
  54800. break;
  54801. case 'U':
  54802. this.style = AnnotationBorderStyleType.UNDERLINE;
  54803. break;
  54804. default:
  54805. break;
  54806. }
  54807. },
  54808. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54809. if (isArray(dashArray) && dashArray.length > 0) {
  54810. var isValid = true;
  54811. var allZeros = true;
  54812. for (var i = 0, len = dashArray.length; i < len; i++) {
  54813. var element = dashArray[i];
  54814. var validNumber = +element >= 0;
  54815. if (!validNumber) {
  54816. isValid = false;
  54817. break;
  54818. } else if (element > 0) {
  54819. allZeros = false;
  54820. }
  54821. }
  54822. if (isValid && !allZeros) {
  54823. this.dashArray = dashArray;
  54824. } else {
  54825. this.width = 0;
  54826. }
  54827. } else if (dashArray) {
  54828. this.width = 0;
  54829. }
  54830. },
  54831. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54832. if (radius === (radius | 0)) {
  54833. this.horizontalCornerRadius = radius;
  54834. }
  54835. },
  54836. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54837. if (radius === (radius | 0)) {
  54838. this.verticalCornerRadius = radius;
  54839. }
  54840. }
  54841. };
  54842. return AnnotationBorderStyle;
  54843. }();
  54844. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54845. function WidgetAnnotation(params) {
  54846. Annotation.call(this, params);
  54847. var dict = params.dict;
  54848. var data = this.data;
  54849. data.annotationType = AnnotationType.WIDGET;
  54850. data.fieldName = this._constructFieldName(dict);
  54851. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  54852. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  54853. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  54854. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54855. data.fieldType = isName(fieldType) ? fieldType.name : null;
  54856. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  54857. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  54858. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  54859. data.fieldFlags = 0;
  54860. }
  54861. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  54862. if (data.fieldType === 'Sig') {
  54863. this.setFlags(AnnotationFlag.HIDDEN);
  54864. }
  54865. }
  54866. Util.inherit(WidgetAnnotation, Annotation, {
  54867. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  54868. if (!dict.has('T') && !dict.has('Parent')) {
  54869. warn('Unknown field name, falling back to empty field name.');
  54870. return '';
  54871. }
  54872. if (!dict.has('Parent')) {
  54873. return stringToPDFString(dict.get('T'));
  54874. }
  54875. var fieldName = [];
  54876. if (dict.has('T')) {
  54877. fieldName.unshift(stringToPDFString(dict.get('T')));
  54878. }
  54879. var loopDict = dict;
  54880. while (loopDict.has('Parent')) {
  54881. loopDict = loopDict.get('Parent');
  54882. if (loopDict.has('T')) {
  54883. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  54884. }
  54885. }
  54886. return fieldName.join('.');
  54887. },
  54888. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  54889. return !!(this.data.fieldFlags & flag);
  54890. }
  54891. });
  54892. return WidgetAnnotation;
  54893. }();
  54894. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  54895. function TextWidgetAnnotation(params) {
  54896. WidgetAnnotation.call(this, params);
  54897. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  54898. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  54899. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  54900. alignment = null;
  54901. }
  54902. this.data.textAlignment = alignment;
  54903. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  54904. if (!isInt(maximumLength) || maximumLength < 0) {
  54905. maximumLength = null;
  54906. }
  54907. this.data.maxLen = maximumLength;
  54908. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  54909. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  54910. }
  54911. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  54912. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54913. var operatorList = new OperatorList();
  54914. if (renderForms) {
  54915. return Promise.resolve(operatorList);
  54916. }
  54917. if (this.appearance) {
  54918. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54919. }
  54920. if (!this.data.defaultAppearance) {
  54921. return Promise.resolve(operatorList);
  54922. }
  54923. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  54924. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  54925. return operatorList;
  54926. });
  54927. }
  54928. });
  54929. return TextWidgetAnnotation;
  54930. }();
  54931. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  54932. function ChoiceWidgetAnnotation(params) {
  54933. WidgetAnnotation.call(this, params);
  54934. this.data.options = [];
  54935. var options = params.dict.getArray('Opt');
  54936. if (isArray(options)) {
  54937. for (var i = 0, ii = options.length; i < ii; i++) {
  54938. var option = options[i];
  54939. this.data.options[i] = {
  54940. exportValue: isArray(option) ? option[0] : option,
  54941. displayValue: isArray(option) ? option[1] : option
  54942. };
  54943. }
  54944. }
  54945. if (!isArray(this.data.fieldValue)) {
  54946. this.data.fieldValue = [this.data.fieldValue];
  54947. }
  54948. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  54949. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  54950. }
  54951. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  54952. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54953. var operatorList = new OperatorList();
  54954. if (renderForms) {
  54955. return Promise.resolve(operatorList);
  54956. }
  54957. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54958. }
  54959. });
  54960. return ChoiceWidgetAnnotation;
  54961. }();
  54962. var TextAnnotation = function TextAnnotationClosure() {
  54963. var DEFAULT_ICON_SIZE = 22;
  54964. function TextAnnotation(parameters) {
  54965. Annotation.call(this, parameters);
  54966. this.data.annotationType = AnnotationType.TEXT;
  54967. if (this.data.hasAppearance) {
  54968. this.data.name = 'NoIcon';
  54969. } else {
  54970. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  54971. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  54972. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  54973. }
  54974. this._preparePopup(parameters.dict);
  54975. }
  54976. Util.inherit(TextAnnotation, Annotation, {});
  54977. return TextAnnotation;
  54978. }();
  54979. var LinkAnnotation = function LinkAnnotationClosure() {
  54980. function LinkAnnotation(params) {
  54981. Annotation.call(this, params);
  54982. var data = this.data;
  54983. data.annotationType = AnnotationType.LINK;
  54984. Catalog.parseDestDictionary({
  54985. destDict: params.dict,
  54986. resultObj: data,
  54987. docBaseUrl: params.pdfManager.docBaseUrl
  54988. });
  54989. }
  54990. Util.inherit(LinkAnnotation, Annotation, {});
  54991. return LinkAnnotation;
  54992. }();
  54993. var PopupAnnotation = function PopupAnnotationClosure() {
  54994. function PopupAnnotation(parameters) {
  54995. Annotation.call(this, parameters);
  54996. this.data.annotationType = AnnotationType.POPUP;
  54997. var dict = parameters.dict;
  54998. var parentItem = dict.get('Parent');
  54999. if (!parentItem) {
  55000. warn('Popup annotation has a missing or invalid parent annotation.');
  55001. return;
  55002. }
  55003. this.data.parentId = dict.getRaw('Parent').toString();
  55004. this.data.title = stringToPDFString(parentItem.get('T') || '');
  55005. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  55006. if (!parentItem.has('C')) {
  55007. this.data.color = null;
  55008. } else {
  55009. this.setColor(parentItem.getArray('C'));
  55010. this.data.color = this.color;
  55011. }
  55012. if (!this.viewable) {
  55013. var parentFlags = parentItem.get('F');
  55014. if (this._isViewable(parentFlags)) {
  55015. this.setFlags(parentFlags);
  55016. }
  55017. }
  55018. }
  55019. Util.inherit(PopupAnnotation, Annotation, {});
  55020. return PopupAnnotation;
  55021. }();
  55022. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55023. function HighlightAnnotation(parameters) {
  55024. Annotation.call(this, parameters);
  55025. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55026. this._preparePopup(parameters.dict);
  55027. this.data.borderStyle.setWidth(0);
  55028. }
  55029. Util.inherit(HighlightAnnotation, Annotation, {});
  55030. return HighlightAnnotation;
  55031. }();
  55032. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55033. function UnderlineAnnotation(parameters) {
  55034. Annotation.call(this, parameters);
  55035. this.data.annotationType = AnnotationType.UNDERLINE;
  55036. this._preparePopup(parameters.dict);
  55037. this.data.borderStyle.setWidth(0);
  55038. }
  55039. Util.inherit(UnderlineAnnotation, Annotation, {});
  55040. return UnderlineAnnotation;
  55041. }();
  55042. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55043. function SquigglyAnnotation(parameters) {
  55044. Annotation.call(this, parameters);
  55045. this.data.annotationType = AnnotationType.SQUIGGLY;
  55046. this._preparePopup(parameters.dict);
  55047. this.data.borderStyle.setWidth(0);
  55048. }
  55049. Util.inherit(SquigglyAnnotation, Annotation, {});
  55050. return SquigglyAnnotation;
  55051. }();
  55052. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55053. function StrikeOutAnnotation(parameters) {
  55054. Annotation.call(this, parameters);
  55055. this.data.annotationType = AnnotationType.STRIKEOUT;
  55056. this._preparePopup(parameters.dict);
  55057. this.data.borderStyle.setWidth(0);
  55058. }
  55059. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55060. return StrikeOutAnnotation;
  55061. }();
  55062. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55063. function FileAttachmentAnnotation(parameters) {
  55064. Annotation.call(this, parameters);
  55065. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55066. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55067. this.data.file = file.serializable;
  55068. this._preparePopup(parameters.dict);
  55069. }
  55070. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55071. return FileAttachmentAnnotation;
  55072. }();
  55073. exports.Annotation = Annotation;
  55074. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55075. exports.AnnotationFactory = AnnotationFactory;
  55076. }));
  55077. (function (root, factory) {
  55078. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55079. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55080. var MissingDataException = sharedUtil.MissingDataException;
  55081. var Util = sharedUtil.Util;
  55082. var assert = sharedUtil.assert;
  55083. var error = sharedUtil.error;
  55084. var info = sharedUtil.info;
  55085. var isArray = sharedUtil.isArray;
  55086. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55087. var isNum = sharedUtil.isNum;
  55088. var isString = sharedUtil.isString;
  55089. var shadow = sharedUtil.shadow;
  55090. var stringToBytes = sharedUtil.stringToBytes;
  55091. var stringToPDFString = sharedUtil.stringToPDFString;
  55092. var warn = sharedUtil.warn;
  55093. var isSpace = sharedUtil.isSpace;
  55094. var Dict = corePrimitives.Dict;
  55095. var isDict = corePrimitives.isDict;
  55096. var isName = corePrimitives.isName;
  55097. var isStream = corePrimitives.isStream;
  55098. var NullStream = coreStream.NullStream;
  55099. var Stream = coreStream.Stream;
  55100. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55101. var Catalog = coreObj.Catalog;
  55102. var ObjectLoader = coreObj.ObjectLoader;
  55103. var XRef = coreObj.XRef;
  55104. var Linearization = coreParser.Linearization;
  55105. var calculateMD5 = coreCrypto.calculateMD5;
  55106. var OperatorList = coreEvaluator.OperatorList;
  55107. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55108. var Annotation = coreAnnotation.Annotation;
  55109. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55110. var Page = function PageClosure() {
  55111. var DEFAULT_USER_UNIT = 1.0;
  55112. var LETTER_SIZE_MEDIABOX = [
  55113. 0,
  55114. 0,
  55115. 612,
  55116. 792
  55117. ];
  55118. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55119. this.pdfManager = pdfManager;
  55120. this.pageIndex = pageIndex;
  55121. this.pageDict = pageDict;
  55122. this.xref = xref;
  55123. this.ref = ref;
  55124. this.fontCache = fontCache;
  55125. this.uniquePrefix = 'p' + this.pageIndex + '_';
  55126. this.idCounters = { obj: 0 };
  55127. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55128. this.resourcesPromise = null;
  55129. }
  55130. Page.prototype = {
  55131. getPageProp: function Page_getPageProp(key) {
  55132. return this.pageDict.get(key);
  55133. },
  55134. getInheritedPageProp: function Page_getInheritedPageProp(key) {
  55135. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55136. var MAX_LOOP_COUNT = 100;
  55137. while (dict) {
  55138. var value = dict.get(key);
  55139. if (value) {
  55140. if (!valueArray) {
  55141. valueArray = [];
  55142. }
  55143. valueArray.push(value);
  55144. }
  55145. if (++loopCount > MAX_LOOP_COUNT) {
  55146. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55147. break;
  55148. }
  55149. dict = dict.get('Parent');
  55150. }
  55151. if (!valueArray) {
  55152. return Dict.empty;
  55153. }
  55154. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55155. return valueArray[0];
  55156. }
  55157. return Dict.merge(this.xref, valueArray);
  55158. },
  55159. get content() {
  55160. return this.getPageProp('Contents');
  55161. },
  55162. get resources() {
  55163. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55164. },
  55165. get mediaBox() {
  55166. var obj = this.getInheritedPageProp('MediaBox');
  55167. if (!isArray(obj) || obj.length !== 4) {
  55168. obj = LETTER_SIZE_MEDIABOX;
  55169. }
  55170. return shadow(this, 'mediaBox', obj);
  55171. },
  55172. get userUnit() {
  55173. var obj = this.getPageProp('UserUnit');
  55174. if (!isNum(obj) || obj <= 0) {
  55175. obj = DEFAULT_USER_UNIT;
  55176. }
  55177. return shadow(this, 'userUnit', obj);
  55178. },
  55179. get view() {
  55180. var mediaBox = this.mediaBox;
  55181. var cropBox = this.getInheritedPageProp('CropBox');
  55182. if (!isArray(cropBox) || cropBox.length !== 4) {
  55183. return shadow(this, 'view', mediaBox);
  55184. }
  55185. cropBox = Util.intersect(cropBox, mediaBox);
  55186. if (!cropBox) {
  55187. return shadow(this, 'view', mediaBox);
  55188. }
  55189. return shadow(this, 'view', cropBox);
  55190. },
  55191. get rotate() {
  55192. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55193. if (rotate % 90 !== 0) {
  55194. rotate = 0;
  55195. } else if (rotate >= 360) {
  55196. rotate = rotate % 360;
  55197. } else if (rotate < 0) {
  55198. rotate = (rotate % 360 + 360) % 360;
  55199. }
  55200. return shadow(this, 'rotate', rotate);
  55201. },
  55202. getContentStream: function Page_getContentStream() {
  55203. var content = this.content;
  55204. var stream;
  55205. if (isArray(content)) {
  55206. var xref = this.xref;
  55207. var i, n = content.length;
  55208. var streams = [];
  55209. for (i = 0; i < n; ++i) {
  55210. streams.push(xref.fetchIfRef(content[i]));
  55211. }
  55212. stream = new StreamsSequenceStream(streams);
  55213. } else if (isStream(content)) {
  55214. stream = content;
  55215. } else {
  55216. stream = new NullStream();
  55217. }
  55218. return stream;
  55219. },
  55220. loadResources: function Page_loadResources(keys) {
  55221. if (!this.resourcesPromise) {
  55222. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55223. }
  55224. return this.resourcesPromise.then(function resourceSuccess() {
  55225. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55226. return objectLoader.load();
  55227. }.bind(this));
  55228. },
  55229. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55230. var self = this;
  55231. var pdfManager = this.pdfManager;
  55232. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55233. var resourcesPromise = this.loadResources([
  55234. 'ExtGState',
  55235. 'ColorSpace',
  55236. 'Pattern',
  55237. 'Shading',
  55238. 'XObject',
  55239. 'Font'
  55240. ]);
  55241. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  55242. var dataPromises = Promise.all([
  55243. contentStreamPromise,
  55244. resourcesPromise
  55245. ]);
  55246. var pageListPromise = dataPromises.then(function (data) {
  55247. var contentStream = data[0];
  55248. var opList = new OperatorList(intent, handler, self.pageIndex);
  55249. handler.send('StartRenderPage', {
  55250. transparency: partialEvaluator.hasBlendModes(self.resources),
  55251. pageIndex: self.pageIndex,
  55252. intent: intent
  55253. });
  55254. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55255. return opList;
  55256. });
  55257. });
  55258. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55259. return Promise.all([
  55260. pageListPromise,
  55261. annotationsPromise
  55262. ]).then(function (datas) {
  55263. var pageOpList = datas[0];
  55264. var annotations = datas[1];
  55265. if (annotations.length === 0) {
  55266. pageOpList.flush(true);
  55267. return pageOpList;
  55268. }
  55269. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55270. return annotationsReadyPromise.then(function () {
  55271. pageOpList.flush(true);
  55272. return pageOpList;
  55273. });
  55274. });
  55275. },
  55276. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55277. var handler = {
  55278. on: function nullHandlerOn() {
  55279. },
  55280. send: function nullHandlerSend() {
  55281. }
  55282. };
  55283. var self = this;
  55284. var pdfManager = this.pdfManager;
  55285. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55286. var resourcesPromise = this.loadResources([
  55287. 'ExtGState',
  55288. 'XObject',
  55289. 'Font'
  55290. ]);
  55291. var dataPromises = Promise.all([
  55292. contentStreamPromise,
  55293. resourcesPromise
  55294. ]);
  55295. return dataPromises.then(function (data) {
  55296. var contentStream = data[0];
  55297. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  55298. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55299. });
  55300. },
  55301. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55302. var annotations = this.annotations;
  55303. var annotationsData = [];
  55304. for (var i = 0, n = annotations.length; i < n; ++i) {
  55305. if (intent) {
  55306. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55307. continue;
  55308. }
  55309. }
  55310. annotationsData.push(annotations[i].data);
  55311. }
  55312. return annotationsData;
  55313. },
  55314. get annotations() {
  55315. var annotations = [];
  55316. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55317. var annotationFactory = new AnnotationFactory();
  55318. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55319. var annotationRef = annotationRefs[i];
  55320. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  55321. if (annotation) {
  55322. annotations.push(annotation);
  55323. }
  55324. }
  55325. return shadow(this, 'annotations', annotations);
  55326. }
  55327. };
  55328. return Page;
  55329. }();
  55330. var PDFDocument = function PDFDocumentClosure() {
  55331. var FINGERPRINT_FIRST_BYTES = 1024;
  55332. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55333. function PDFDocument(pdfManager, arg, password) {
  55334. if (isStream(arg)) {
  55335. init.call(this, pdfManager, arg, password);
  55336. } else if (isArrayBuffer(arg)) {
  55337. init.call(this, pdfManager, new Stream(arg), password);
  55338. } else {
  55339. error('PDFDocument: Unknown argument type');
  55340. }
  55341. }
  55342. function init(pdfManager, stream, password) {
  55343. assert(stream.length > 0, 'stream must have data');
  55344. this.pdfManager = pdfManager;
  55345. this.stream = stream;
  55346. var xref = new XRef(this.stream, password, pdfManager);
  55347. this.xref = xref;
  55348. }
  55349. function find(stream, needle, limit, backwards) {
  55350. var pos = stream.pos;
  55351. var end = stream.end;
  55352. var strBuf = [];
  55353. if (pos + limit > end) {
  55354. limit = end - pos;
  55355. }
  55356. for (var n = 0; n < limit; ++n) {
  55357. strBuf.push(String.fromCharCode(stream.getByte()));
  55358. }
  55359. var str = strBuf.join('');
  55360. stream.pos = pos;
  55361. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55362. if (index === -1) {
  55363. return false;
  55364. }
  55365. stream.pos += index;
  55366. return true;
  55367. }
  55368. var DocumentInfoValidators = {
  55369. get entries() {
  55370. return shadow(this, 'entries', {
  55371. Title: isString,
  55372. Author: isString,
  55373. Subject: isString,
  55374. Keywords: isString,
  55375. Creator: isString,
  55376. Producer: isString,
  55377. CreationDate: isString,
  55378. ModDate: isString,
  55379. Trapped: isName
  55380. });
  55381. }
  55382. };
  55383. PDFDocument.prototype = {
  55384. parse: function PDFDocument_parse(recoveryMode) {
  55385. this.setup(recoveryMode);
  55386. var version = this.catalog.catDict.get('Version');
  55387. if (isName(version)) {
  55388. this.pdfFormatVersion = version.name;
  55389. }
  55390. try {
  55391. this.acroForm = this.catalog.catDict.get('AcroForm');
  55392. if (this.acroForm) {
  55393. this.xfa = this.acroForm.get('XFA');
  55394. var fields = this.acroForm.get('Fields');
  55395. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55396. this.acroForm = null;
  55397. }
  55398. }
  55399. } catch (ex) {
  55400. info('Something wrong with AcroForm entry');
  55401. this.acroForm = null;
  55402. }
  55403. },
  55404. get linearization() {
  55405. var linearization = null;
  55406. if (this.stream.length) {
  55407. try {
  55408. linearization = Linearization.create(this.stream);
  55409. } catch (err) {
  55410. if (err instanceof MissingDataException) {
  55411. throw err;
  55412. }
  55413. info(err);
  55414. }
  55415. }
  55416. return shadow(this, 'linearization', linearization);
  55417. },
  55418. get startXRef() {
  55419. var stream = this.stream;
  55420. var startXRef = 0;
  55421. var linearization = this.linearization;
  55422. if (linearization) {
  55423. stream.reset();
  55424. if (find(stream, 'endobj', 1024)) {
  55425. startXRef = stream.pos + 6;
  55426. }
  55427. } else {
  55428. var step = 1024;
  55429. var found = false, pos = stream.end;
  55430. while (!found && pos > 0) {
  55431. pos -= step - 'startxref'.length;
  55432. if (pos < 0) {
  55433. pos = 0;
  55434. }
  55435. stream.pos = pos;
  55436. found = find(stream, 'startxref', step, true);
  55437. }
  55438. if (found) {
  55439. stream.skip(9);
  55440. var ch;
  55441. do {
  55442. ch = stream.getByte();
  55443. } while (isSpace(ch));
  55444. var str = '';
  55445. while (ch >= 0x20 && ch <= 0x39) {
  55446. str += String.fromCharCode(ch);
  55447. ch = stream.getByte();
  55448. }
  55449. startXRef = parseInt(str, 10);
  55450. if (isNaN(startXRef)) {
  55451. startXRef = 0;
  55452. }
  55453. }
  55454. }
  55455. return shadow(this, 'startXRef', startXRef);
  55456. },
  55457. get mainXRefEntriesOffset() {
  55458. var mainXRefEntriesOffset = 0;
  55459. var linearization = this.linearization;
  55460. if (linearization) {
  55461. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55462. }
  55463. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55464. },
  55465. checkHeader: function PDFDocument_checkHeader() {
  55466. var stream = this.stream;
  55467. stream.reset();
  55468. if (find(stream, '%PDF-', 1024)) {
  55469. stream.moveStart();
  55470. var MAX_VERSION_LENGTH = 12;
  55471. var version = '', ch;
  55472. while ((ch = stream.getByte()) > 0x20) {
  55473. if (version.length >= MAX_VERSION_LENGTH) {
  55474. break;
  55475. }
  55476. version += String.fromCharCode(ch);
  55477. }
  55478. if (!this.pdfFormatVersion) {
  55479. this.pdfFormatVersion = version.substring(5);
  55480. }
  55481. return;
  55482. }
  55483. },
  55484. parseStartXRef: function PDFDocument_parseStartXRef() {
  55485. var startXRef = this.startXRef;
  55486. this.xref.setStartXRef(startXRef);
  55487. },
  55488. setup: function PDFDocument_setup(recoveryMode) {
  55489. this.xref.parse(recoveryMode);
  55490. var self = this;
  55491. var pageFactory = {
  55492. createPage: function (pageIndex, dict, ref, fontCache) {
  55493. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55494. }
  55495. };
  55496. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55497. },
  55498. get numPages() {
  55499. var linearization = this.linearization;
  55500. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55501. return shadow(this, 'numPages', num);
  55502. },
  55503. get documentInfo() {
  55504. var docInfo = {
  55505. PDFFormatVersion: this.pdfFormatVersion,
  55506. IsAcroFormPresent: !!this.acroForm,
  55507. IsXFAPresent: !!this.xfa
  55508. };
  55509. var infoDict;
  55510. try {
  55511. infoDict = this.xref.trailer.get('Info');
  55512. } catch (err) {
  55513. info('The document information dictionary is invalid.');
  55514. }
  55515. if (infoDict) {
  55516. var validEntries = DocumentInfoValidators.entries;
  55517. for (var key in validEntries) {
  55518. if (infoDict.has(key)) {
  55519. var value = infoDict.get(key);
  55520. if (validEntries[key](value)) {
  55521. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55522. } else {
  55523. info('Bad value in document info for "' + key + '"');
  55524. }
  55525. }
  55526. }
  55527. }
  55528. return shadow(this, 'documentInfo', docInfo);
  55529. },
  55530. get fingerprint() {
  55531. var xref = this.xref, hash, fileID = '';
  55532. var idArray = xref.trailer.get('ID');
  55533. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55534. hash = stringToBytes(idArray[0]);
  55535. } else {
  55536. if (this.stream.ensureRange) {
  55537. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55538. }
  55539. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55540. }
  55541. for (var i = 0, n = hash.length; i < n; i++) {
  55542. var hex = hash[i].toString(16);
  55543. fileID += hex.length === 1 ? '0' + hex : hex;
  55544. }
  55545. return shadow(this, 'fingerprint', fileID);
  55546. },
  55547. getPage: function PDFDocument_getPage(pageIndex) {
  55548. return this.catalog.getPage(pageIndex);
  55549. },
  55550. cleanup: function PDFDocument_cleanup() {
  55551. return this.catalog.cleanup();
  55552. }
  55553. };
  55554. return PDFDocument;
  55555. }();
  55556. exports.Page = Page;
  55557. exports.PDFDocument = PDFDocument;
  55558. }));
  55559. (function (root, factory) {
  55560. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55561. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55562. var warn = sharedUtil.warn;
  55563. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55564. var shadow = sharedUtil.shadow;
  55565. var NotImplementedException = sharedUtil.NotImplementedException;
  55566. var MissingDataException = sharedUtil.MissingDataException;
  55567. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55568. var Util = sharedUtil.Util;
  55569. var Stream = coreStream.Stream;
  55570. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55571. var PDFDocument = coreDocument.PDFDocument;
  55572. var BasePdfManager = function BasePdfManagerClosure() {
  55573. function BasePdfManager() {
  55574. throw new Error('Cannot initialize BaseManagerManager');
  55575. }
  55576. BasePdfManager.prototype = {
  55577. get docId() {
  55578. return this._docId;
  55579. },
  55580. get docBaseUrl() {
  55581. var docBaseUrl = null;
  55582. if (this._docBaseUrl) {
  55583. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55584. if (absoluteUrl) {
  55585. docBaseUrl = absoluteUrl.href;
  55586. } else {
  55587. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55588. }
  55589. }
  55590. return shadow(this, 'docBaseUrl', docBaseUrl);
  55591. },
  55592. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55593. throw new NotImplementedException();
  55594. },
  55595. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55596. return this.ensure(this.pdfDocument, prop, args);
  55597. },
  55598. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55599. return this.ensure(this.pdfDocument.xref, prop, args);
  55600. },
  55601. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55602. return this.ensure(this.pdfDocument.catalog, prop, args);
  55603. },
  55604. getPage: function BasePdfManager_getPage(pageIndex) {
  55605. return this.pdfDocument.getPage(pageIndex);
  55606. },
  55607. cleanup: function BasePdfManager_cleanup() {
  55608. return this.pdfDocument.cleanup();
  55609. },
  55610. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55611. return new NotImplementedException();
  55612. },
  55613. requestRange: function BasePdfManager_requestRange(begin, end) {
  55614. return new NotImplementedException();
  55615. },
  55616. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55617. return new NotImplementedException();
  55618. },
  55619. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55620. return new NotImplementedException();
  55621. },
  55622. updatePassword: function BasePdfManager_updatePassword(password) {
  55623. this.pdfDocument.xref.password = this.password = password;
  55624. if (this._passwordChangedCapability) {
  55625. this._passwordChangedCapability.resolve();
  55626. }
  55627. },
  55628. passwordChanged: function BasePdfManager_passwordChanged() {
  55629. this._passwordChangedCapability = createPromiseCapability();
  55630. return this._passwordChangedCapability.promise;
  55631. },
  55632. terminate: function BasePdfManager_terminate() {
  55633. return new NotImplementedException();
  55634. }
  55635. };
  55636. return BasePdfManager;
  55637. }();
  55638. var LocalPdfManager = function LocalPdfManagerClosure() {
  55639. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55640. this._docId = docId;
  55641. this._docBaseUrl = docBaseUrl;
  55642. this.evaluatorOptions = evaluatorOptions;
  55643. var stream = new Stream(data);
  55644. this.pdfDocument = new PDFDocument(this, stream, password);
  55645. this._loadedStreamCapability = createPromiseCapability();
  55646. this._loadedStreamCapability.resolve(stream);
  55647. }
  55648. Util.inherit(LocalPdfManager, BasePdfManager, {
  55649. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55650. return new Promise(function (resolve, reject) {
  55651. try {
  55652. var value = obj[prop];
  55653. var result;
  55654. if (typeof value === 'function') {
  55655. result = value.apply(obj, args);
  55656. } else {
  55657. result = value;
  55658. }
  55659. resolve(result);
  55660. } catch (e) {
  55661. reject(e);
  55662. }
  55663. });
  55664. },
  55665. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55666. return Promise.resolve();
  55667. },
  55668. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55669. return;
  55670. },
  55671. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55672. return this._loadedStreamCapability.promise;
  55673. },
  55674. terminate: function LocalPdfManager_terminate() {
  55675. return;
  55676. }
  55677. });
  55678. return LocalPdfManager;
  55679. }();
  55680. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55681. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55682. this._docId = docId;
  55683. this._docBaseUrl = docBaseUrl;
  55684. this.msgHandler = args.msgHandler;
  55685. this.evaluatorOptions = evaluatorOptions;
  55686. var params = {
  55687. msgHandler: args.msgHandler,
  55688. url: args.url,
  55689. length: args.length,
  55690. disableAutoFetch: args.disableAutoFetch,
  55691. rangeChunkSize: args.rangeChunkSize
  55692. };
  55693. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55694. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  55695. }
  55696. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55697. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55698. var pdfManager = this;
  55699. return new Promise(function (resolve, reject) {
  55700. function ensureHelper() {
  55701. try {
  55702. var result;
  55703. var value = obj[prop];
  55704. if (typeof value === 'function') {
  55705. result = value.apply(obj, args);
  55706. } else {
  55707. result = value;
  55708. }
  55709. resolve(result);
  55710. } catch (e) {
  55711. if (!(e instanceof MissingDataException)) {
  55712. reject(e);
  55713. return;
  55714. }
  55715. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55716. }
  55717. }
  55718. ensureHelper();
  55719. });
  55720. },
  55721. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55722. return this.streamManager.requestRange(begin, end);
  55723. },
  55724. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55725. this.streamManager.requestAllChunks();
  55726. },
  55727. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55728. this.streamManager.onReceiveData({ chunk: chunk });
  55729. },
  55730. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55731. return this.streamManager.onLoadedStream();
  55732. },
  55733. terminate: function NetworkPdfManager_terminate() {
  55734. this.streamManager.abort();
  55735. }
  55736. });
  55737. return NetworkPdfManager;
  55738. }();
  55739. exports.LocalPdfManager = LocalPdfManager;
  55740. exports.NetworkPdfManager = NetworkPdfManager;
  55741. }));
  55742. (function (root, factory) {
  55743. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55744. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55745. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55746. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55747. var MessageHandler = sharedUtil.MessageHandler;
  55748. var MissingPDFException = sharedUtil.MissingPDFException;
  55749. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55750. var PasswordException = sharedUtil.PasswordException;
  55751. var PasswordResponses = sharedUtil.PasswordResponses;
  55752. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55753. var XRefParseException = sharedUtil.XRefParseException;
  55754. var arrayByteLength = sharedUtil.arrayByteLength;
  55755. var arraysToBytes = sharedUtil.arraysToBytes;
  55756. var assert = sharedUtil.assert;
  55757. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55758. var error = sharedUtil.error;
  55759. var info = sharedUtil.info;
  55760. var warn = sharedUtil.warn;
  55761. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55762. var Ref = corePrimitives.Ref;
  55763. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55764. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55765. var globalScope = sharedUtil.globalScope;
  55766. var WorkerTask = function WorkerTaskClosure() {
  55767. function WorkerTask(name) {
  55768. this.name = name;
  55769. this.terminated = false;
  55770. this._capability = createPromiseCapability();
  55771. }
  55772. WorkerTask.prototype = {
  55773. get finished() {
  55774. return this._capability.promise;
  55775. },
  55776. finish: function () {
  55777. this._capability.resolve();
  55778. },
  55779. terminate: function () {
  55780. this.terminated = true;
  55781. },
  55782. ensureNotTerminated: function () {
  55783. if (this.terminated) {
  55784. throw new Error('Worker task was terminated');
  55785. }
  55786. }
  55787. };
  55788. return WorkerTask;
  55789. }();
  55790. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  55791. function PDFWorkerStream(params, msgHandler) {
  55792. this._queuedChunks = [];
  55793. var initialData = params.initialData;
  55794. if (initialData && initialData.length > 0) {
  55795. this._queuedChunks.push(initialData);
  55796. }
  55797. this._msgHandler = msgHandler;
  55798. this._isRangeSupported = !params.disableRange;
  55799. this._isStreamingSupported = !params.disableStream;
  55800. this._contentLength = params.length;
  55801. this._fullRequestReader = null;
  55802. this._rangeReaders = [];
  55803. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  55804. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  55805. }
  55806. PDFWorkerStream.prototype = {
  55807. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  55808. if (args.begin === undefined) {
  55809. if (this._fullRequestReader) {
  55810. this._fullRequestReader._enqueue(args.chunk);
  55811. } else {
  55812. this._queuedChunks.push(args.chunk);
  55813. }
  55814. } else {
  55815. var found = this._rangeReaders.some(function (rangeReader) {
  55816. if (rangeReader._begin !== args.begin) {
  55817. return false;
  55818. }
  55819. rangeReader._enqueue(args.chunk);
  55820. return true;
  55821. });
  55822. assert(found);
  55823. }
  55824. },
  55825. _onProgress: function PDFWorkerStream_onProgress(evt) {
  55826. if (this._rangeReaders.length > 0) {
  55827. var firstReader = this._rangeReaders[0];
  55828. if (firstReader.onProgress) {
  55829. firstReader.onProgress({ loaded: evt.loaded });
  55830. }
  55831. }
  55832. },
  55833. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  55834. var i = this._rangeReaders.indexOf(reader);
  55835. if (i >= 0) {
  55836. this._rangeReaders.splice(i, 1);
  55837. }
  55838. },
  55839. getFullReader: function PDFWorkerStream_getFullReader() {
  55840. assert(!this._fullRequestReader);
  55841. var queuedChunks = this._queuedChunks;
  55842. this._queuedChunks = null;
  55843. return new PDFWorkerStreamReader(this, queuedChunks);
  55844. },
  55845. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  55846. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  55847. this._msgHandler.send('RequestDataRange', {
  55848. begin: begin,
  55849. end: end
  55850. });
  55851. this._rangeReaders.push(reader);
  55852. return reader;
  55853. },
  55854. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  55855. if (this._fullRequestReader) {
  55856. this._fullRequestReader.cancel(reason);
  55857. }
  55858. var readers = this._rangeReaders.slice(0);
  55859. readers.forEach(function (rangeReader) {
  55860. rangeReader.cancel(reason);
  55861. });
  55862. }
  55863. };
  55864. function PDFWorkerStreamReader(stream, queuedChunks) {
  55865. this._stream = stream;
  55866. this._done = false;
  55867. this._queuedChunks = queuedChunks || [];
  55868. this._requests = [];
  55869. this._headersReady = Promise.resolve();
  55870. stream._fullRequestReader = this;
  55871. this.onProgress = null;
  55872. }
  55873. PDFWorkerStreamReader.prototype = {
  55874. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  55875. if (this._done) {
  55876. return;
  55877. }
  55878. if (this._requests.length > 0) {
  55879. var requestCapability = this._requests.shift();
  55880. requestCapability.resolve({
  55881. value: chunk,
  55882. done: false
  55883. });
  55884. return;
  55885. }
  55886. this._queuedChunks.push(chunk);
  55887. },
  55888. get headersReady() {
  55889. return this._headersReady;
  55890. },
  55891. get isRangeSupported() {
  55892. return this._stream._isRangeSupported;
  55893. },
  55894. get isStreamingSupported() {
  55895. return this._stream._isStreamingSupported;
  55896. },
  55897. get contentLength() {
  55898. return this._stream._contentLength;
  55899. },
  55900. read: function PDFWorkerStreamReader_read() {
  55901. if (this._queuedChunks.length > 0) {
  55902. var chunk = this._queuedChunks.shift();
  55903. return Promise.resolve({
  55904. value: chunk,
  55905. done: false
  55906. });
  55907. }
  55908. if (this._done) {
  55909. return Promise.resolve({
  55910. value: undefined,
  55911. done: true
  55912. });
  55913. }
  55914. var requestCapability = createPromiseCapability();
  55915. this._requests.push(requestCapability);
  55916. return requestCapability.promise;
  55917. },
  55918. cancel: function PDFWorkerStreamReader_cancel(reason) {
  55919. this._done = true;
  55920. this._requests.forEach(function (requestCapability) {
  55921. requestCapability.resolve({
  55922. value: undefined,
  55923. done: true
  55924. });
  55925. });
  55926. this._requests = [];
  55927. }
  55928. };
  55929. function PDFWorkerStreamRangeReader(stream, begin, end) {
  55930. this._stream = stream;
  55931. this._begin = begin;
  55932. this._end = end;
  55933. this._queuedChunk = null;
  55934. this._requests = [];
  55935. this._done = false;
  55936. this.onProgress = null;
  55937. }
  55938. PDFWorkerStreamRangeReader.prototype = {
  55939. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  55940. if (this._done) {
  55941. return;
  55942. }
  55943. if (this._requests.length === 0) {
  55944. this._queuedChunk = chunk;
  55945. } else {
  55946. var requestsCapability = this._requests.shift();
  55947. requestsCapability.resolve({
  55948. value: chunk,
  55949. done: false
  55950. });
  55951. this._requests.forEach(function (requestCapability) {
  55952. requestCapability.resolve({
  55953. value: undefined,
  55954. done: true
  55955. });
  55956. });
  55957. this._requests = [];
  55958. }
  55959. this._done = true;
  55960. this._stream._removeRangeReader(this);
  55961. },
  55962. get isStreamingSupported() {
  55963. return false;
  55964. },
  55965. read: function PDFWorkerStreamRangeReader_read() {
  55966. if (this._queuedChunk) {
  55967. return Promise.resolve({
  55968. value: this._queuedChunk,
  55969. done: false
  55970. });
  55971. }
  55972. if (this._done) {
  55973. return Promise.resolve({
  55974. value: undefined,
  55975. done: true
  55976. });
  55977. }
  55978. var requestCapability = createPromiseCapability();
  55979. this._requests.push(requestCapability);
  55980. return requestCapability.promise;
  55981. },
  55982. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  55983. this._done = true;
  55984. this._requests.forEach(function (requestCapability) {
  55985. requestCapability.resolve({
  55986. value: undefined,
  55987. done: true
  55988. });
  55989. });
  55990. this._requests = [];
  55991. this._stream._removeRangeReader(this);
  55992. }
  55993. };
  55994. return PDFWorkerStream;
  55995. }();
  55996. var PDFNetworkStream;
  55997. function setPDFNetworkStreamClass(cls) {
  55998. PDFNetworkStream = cls;
  55999. }
  56000. var WorkerMessageHandler = {
  56001. setup: function wphSetup(handler, port) {
  56002. var testMessageProcessed = false;
  56003. handler.on('test', function wphSetupTest(data) {
  56004. if (testMessageProcessed) {
  56005. return;
  56006. }
  56007. testMessageProcessed = true;
  56008. if (!(data instanceof Uint8Array)) {
  56009. handler.send('test', 'main', false);
  56010. return;
  56011. }
  56012. var supportTransfers = data[0] === 255;
  56013. handler.postMessageTransfers = supportTransfers;
  56014. var xhr = new XMLHttpRequest();
  56015. var responseExists = 'response' in xhr;
  56016. try {
  56017. var dummy = xhr.responseType;
  56018. } catch (e) {
  56019. responseExists = false;
  56020. }
  56021. if (!responseExists) {
  56022. handler.send('test', false);
  56023. return;
  56024. }
  56025. handler.send('test', {
  56026. supportTypedArray: true,
  56027. supportTransfers: supportTransfers
  56028. });
  56029. });
  56030. handler.on('configure', function wphConfigure(data) {
  56031. setVerbosityLevel(data.verbosity);
  56032. });
  56033. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56034. return WorkerMessageHandler.createDocumentHandler(data, port);
  56035. });
  56036. },
  56037. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56038. var pdfManager;
  56039. var terminated = false;
  56040. var cancelXHRs = null;
  56041. var WorkerTasks = [];
  56042. var docId = docParams.docId;
  56043. var docBaseUrl = docParams.docBaseUrl;
  56044. var workerHandlerName = docParams.docId + '_worker';
  56045. var handler = new MessageHandler(workerHandlerName, docId, port);
  56046. handler.postMessageTransfers = docParams.postMessageTransfers;
  56047. function ensureNotTerminated() {
  56048. if (terminated) {
  56049. throw new Error('Worker was terminated');
  56050. }
  56051. }
  56052. function startWorkerTask(task) {
  56053. WorkerTasks.push(task);
  56054. }
  56055. function finishWorkerTask(task) {
  56056. task.finish();
  56057. var i = WorkerTasks.indexOf(task);
  56058. WorkerTasks.splice(i, 1);
  56059. }
  56060. function loadDocument(recoveryMode) {
  56061. var loadDocumentCapability = createPromiseCapability();
  56062. var parseSuccess = function parseSuccess() {
  56063. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56064. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56065. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56066. Promise.all([
  56067. numPagesPromise,
  56068. fingerprintPromise,
  56069. encryptedPromise
  56070. ]).then(function onDocReady(results) {
  56071. var doc = {
  56072. numPages: results[0],
  56073. fingerprint: results[1],
  56074. encrypted: !!results[2]
  56075. };
  56076. loadDocumentCapability.resolve(doc);
  56077. }, parseFailure);
  56078. };
  56079. var parseFailure = function parseFailure(e) {
  56080. loadDocumentCapability.reject(e);
  56081. };
  56082. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56083. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56084. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56085. }, parseFailure);
  56086. }, parseFailure);
  56087. return loadDocumentCapability.promise;
  56088. }
  56089. function getPdfManager(data, evaluatorOptions) {
  56090. var pdfManagerCapability = createPromiseCapability();
  56091. var pdfManager;
  56092. var source = data.source;
  56093. if (source.data) {
  56094. try {
  56095. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56096. pdfManagerCapability.resolve(pdfManager);
  56097. } catch (ex) {
  56098. pdfManagerCapability.reject(ex);
  56099. }
  56100. return pdfManagerCapability.promise;
  56101. }
  56102. var pdfStream;
  56103. try {
  56104. if (source.chunkedViewerLoading) {
  56105. pdfStream = new PDFWorkerStream(source, handler);
  56106. } else {
  56107. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56108. pdfStream = new PDFNetworkStream(data);
  56109. }
  56110. } catch (ex) {
  56111. pdfManagerCapability.reject(ex);
  56112. return pdfManagerCapability.promise;
  56113. }
  56114. var fullRequest = pdfStream.getFullReader();
  56115. fullRequest.headersReady.then(function () {
  56116. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56117. fullRequest.onProgress = function (evt) {
  56118. handler.send('DocProgress', {
  56119. loaded: evt.loaded,
  56120. total: evt.total
  56121. });
  56122. };
  56123. }
  56124. if (!fullRequest.isRangeSupported) {
  56125. return;
  56126. }
  56127. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56128. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56129. msgHandler: handler,
  56130. url: source.url,
  56131. password: source.password,
  56132. length: fullRequest.contentLength,
  56133. disableAutoFetch: disableAutoFetch,
  56134. rangeChunkSize: source.rangeChunkSize
  56135. }, evaluatorOptions, docBaseUrl);
  56136. pdfManagerCapability.resolve(pdfManager);
  56137. cancelXHRs = null;
  56138. }).catch(function (reason) {
  56139. pdfManagerCapability.reject(reason);
  56140. cancelXHRs = null;
  56141. });
  56142. var cachedChunks = [], loaded = 0;
  56143. var flushChunks = function () {
  56144. var pdfFile = arraysToBytes(cachedChunks);
  56145. if (source.length && pdfFile.length !== source.length) {
  56146. warn('reported HTTP length is different from actual');
  56147. }
  56148. try {
  56149. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56150. pdfManagerCapability.resolve(pdfManager);
  56151. } catch (ex) {
  56152. pdfManagerCapability.reject(ex);
  56153. }
  56154. cachedChunks = [];
  56155. };
  56156. var readPromise = new Promise(function (resolve, reject) {
  56157. var readChunk = function (chunk) {
  56158. try {
  56159. ensureNotTerminated();
  56160. if (chunk.done) {
  56161. if (!pdfManager) {
  56162. flushChunks();
  56163. }
  56164. cancelXHRs = null;
  56165. return;
  56166. }
  56167. var data = chunk.value;
  56168. loaded += arrayByteLength(data);
  56169. if (!fullRequest.isStreamingSupported) {
  56170. handler.send('DocProgress', {
  56171. loaded: loaded,
  56172. total: Math.max(loaded, fullRequest.contentLength || 0)
  56173. });
  56174. }
  56175. if (pdfManager) {
  56176. pdfManager.sendProgressiveData(data);
  56177. } else {
  56178. cachedChunks.push(data);
  56179. }
  56180. fullRequest.read().then(readChunk, reject);
  56181. } catch (e) {
  56182. reject(e);
  56183. }
  56184. };
  56185. fullRequest.read().then(readChunk, reject);
  56186. });
  56187. readPromise.catch(function (e) {
  56188. pdfManagerCapability.reject(e);
  56189. cancelXHRs = null;
  56190. });
  56191. cancelXHRs = function () {
  56192. pdfStream.cancelAllRequests('abort');
  56193. };
  56194. return pdfManagerCapability.promise;
  56195. }
  56196. var setupDoc = function (data) {
  56197. var onSuccess = function (doc) {
  56198. ensureNotTerminated();
  56199. handler.send('GetDoc', { pdfInfo: doc });
  56200. };
  56201. var onFailure = function (e) {
  56202. if (e instanceof PasswordException) {
  56203. if (e.code === PasswordResponses.NEED_PASSWORD) {
  56204. handler.send('NeedPassword', e);
  56205. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  56206. handler.send('IncorrectPassword', e);
  56207. }
  56208. } else if (e instanceof InvalidPDFException) {
  56209. handler.send('InvalidPDF', e);
  56210. } else if (e instanceof MissingPDFException) {
  56211. handler.send('MissingPDF', e);
  56212. } else if (e instanceof UnexpectedResponseException) {
  56213. handler.send('UnexpectedResponse', e);
  56214. } else {
  56215. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56216. }
  56217. };
  56218. ensureNotTerminated();
  56219. var cMapOptions = {
  56220. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56221. packed: data.cMapPacked === true
  56222. };
  56223. var evaluatorOptions = {
  56224. forceDataSchema: data.disableCreateObjectURL,
  56225. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56226. disableFontFace: data.disableFontFace,
  56227. cMapOptions: cMapOptions
  56228. };
  56229. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56230. if (terminated) {
  56231. newPdfManager.terminate();
  56232. throw new Error('Worker was terminated');
  56233. }
  56234. pdfManager = newPdfManager;
  56235. handler.send('PDFManagerReady', null);
  56236. pdfManager.onLoadedStream().then(function (stream) {
  56237. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56238. });
  56239. }).then(function pdfManagerReady() {
  56240. ensureNotTerminated();
  56241. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56242. ensureNotTerminated();
  56243. if (!(ex instanceof XRefParseException)) {
  56244. if (ex instanceof PasswordException) {
  56245. pdfManager.passwordChanged().then(pdfManagerReady);
  56246. }
  56247. onFailure(ex);
  56248. return;
  56249. }
  56250. pdfManager.requestLoadedStream();
  56251. pdfManager.onLoadedStream().then(function () {
  56252. ensureNotTerminated();
  56253. loadDocument(true).then(onSuccess, onFailure);
  56254. });
  56255. }, onFailure);
  56256. }, onFailure);
  56257. };
  56258. handler.on('GetPage', function wphSetupGetPage(data) {
  56259. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56260. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56261. var refPromise = pdfManager.ensure(page, 'ref');
  56262. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  56263. var viewPromise = pdfManager.ensure(page, 'view');
  56264. return Promise.all([
  56265. rotatePromise,
  56266. refPromise,
  56267. userUnitPromise,
  56268. viewPromise
  56269. ]).then(function (results) {
  56270. return {
  56271. rotate: results[0],
  56272. ref: results[1],
  56273. userUnit: results[2],
  56274. view: results[3]
  56275. };
  56276. });
  56277. });
  56278. });
  56279. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56280. var ref = new Ref(data.ref.num, data.ref.gen);
  56281. var catalog = pdfManager.pdfDocument.catalog;
  56282. return catalog.getPageIndex(ref);
  56283. });
  56284. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56285. return pdfManager.ensureCatalog('destinations');
  56286. });
  56287. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56288. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56289. });
  56290. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56291. return pdfManager.ensureCatalog('pageLabels');
  56292. });
  56293. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56294. return pdfManager.ensureCatalog('attachments');
  56295. });
  56296. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56297. return pdfManager.ensureCatalog('javaScript');
  56298. });
  56299. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56300. return pdfManager.ensureCatalog('documentOutline');
  56301. });
  56302. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56303. return Promise.all([
  56304. pdfManager.ensureDoc('documentInfo'),
  56305. pdfManager.ensureCatalog('metadata')
  56306. ]);
  56307. });
  56308. handler.on('GetData', function wphSetupGetData(data) {
  56309. pdfManager.requestLoadedStream();
  56310. return pdfManager.onLoadedStream().then(function (stream) {
  56311. return stream.bytes;
  56312. });
  56313. });
  56314. handler.on('GetStats', function wphSetupGetStats(data) {
  56315. return pdfManager.pdfDocument.xref.stats;
  56316. });
  56317. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  56318. pdfManager.updatePassword(data);
  56319. });
  56320. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56321. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56322. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56323. });
  56324. });
  56325. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56326. var pageIndex = data.pageIndex;
  56327. pdfManager.getPage(pageIndex).then(function (page) {
  56328. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56329. startWorkerTask(task);
  56330. var pageNum = pageIndex + 1;
  56331. var start = Date.now();
  56332. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56333. finishWorkerTask(task);
  56334. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56335. }, function (e) {
  56336. finishWorkerTask(task);
  56337. if (task.terminated) {
  56338. return;
  56339. }
  56340. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56341. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56342. var wrappedException;
  56343. if (typeof e === 'string') {
  56344. wrappedException = {
  56345. message: e,
  56346. stack: minimumStackMessage
  56347. };
  56348. } else if (typeof e === 'object') {
  56349. wrappedException = {
  56350. message: e.message || e.toString(),
  56351. stack: e.stack || minimumStackMessage
  56352. };
  56353. } else {
  56354. wrappedException = {
  56355. message: 'Unknown exception type: ' + typeof e,
  56356. stack: minimumStackMessage
  56357. };
  56358. }
  56359. handler.send('PageError', {
  56360. pageNum: pageNum,
  56361. error: wrappedException,
  56362. intent: data.intent
  56363. });
  56364. });
  56365. });
  56366. }, this);
  56367. handler.on('GetTextContent', function wphExtractText(data) {
  56368. var pageIndex = data.pageIndex;
  56369. var normalizeWhitespace = data.normalizeWhitespace;
  56370. var combineTextItems = data.combineTextItems;
  56371. return pdfManager.getPage(pageIndex).then(function (page) {
  56372. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56373. startWorkerTask(task);
  56374. var pageNum = pageIndex + 1;
  56375. var start = Date.now();
  56376. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56377. finishWorkerTask(task);
  56378. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56379. return textContent;
  56380. }, function (reason) {
  56381. finishWorkerTask(task);
  56382. if (task.terminated) {
  56383. return;
  56384. }
  56385. throw reason;
  56386. });
  56387. });
  56388. });
  56389. handler.on('Cleanup', function wphCleanup(data) {
  56390. return pdfManager.cleanup();
  56391. });
  56392. handler.on('Terminate', function wphTerminate(data) {
  56393. terminated = true;
  56394. if (pdfManager) {
  56395. pdfManager.terminate();
  56396. pdfManager = null;
  56397. }
  56398. if (cancelXHRs) {
  56399. cancelXHRs();
  56400. }
  56401. var waitOn = [];
  56402. WorkerTasks.forEach(function (task) {
  56403. waitOn.push(task.finished);
  56404. task.terminate();
  56405. });
  56406. return Promise.all(waitOn).then(function () {
  56407. handler.destroy();
  56408. handler = null;
  56409. });
  56410. });
  56411. handler.on('Ready', function wphReady(data) {
  56412. setupDoc(docParams);
  56413. docParams = null;
  56414. });
  56415. return workerHandlerName;
  56416. }
  56417. };
  56418. function initializeWorker() {
  56419. if (!('console' in globalScope)) {
  56420. var consoleTimer = {};
  56421. var workerConsole = {
  56422. log: function log() {
  56423. var args = Array.prototype.slice.call(arguments);
  56424. globalScope.postMessage({
  56425. targetName: 'main',
  56426. action: 'console_log',
  56427. data: args
  56428. });
  56429. },
  56430. error: function error() {
  56431. var args = Array.prototype.slice.call(arguments);
  56432. globalScope.postMessage({
  56433. targetName: 'main',
  56434. action: 'console_error',
  56435. data: args
  56436. });
  56437. throw 'pdf.js execution error';
  56438. },
  56439. time: function time(name) {
  56440. consoleTimer[name] = Date.now();
  56441. },
  56442. timeEnd: function timeEnd(name) {
  56443. var time = consoleTimer[name];
  56444. if (!time) {
  56445. error('Unknown timer name ' + name);
  56446. }
  56447. this.log('Timer:', name, Date.now() - time);
  56448. }
  56449. };
  56450. globalScope.console = workerConsole;
  56451. }
  56452. var handler = new MessageHandler('worker', 'main', self);
  56453. WorkerMessageHandler.setup(handler, self);
  56454. handler.send('ready', null);
  56455. }
  56456. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56457. initializeWorker();
  56458. }
  56459. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56460. exports.WorkerTask = WorkerTask;
  56461. exports.WorkerMessageHandler = WorkerMessageHandler;
  56462. }));
  56463. (function (root, factory) {
  56464. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56465. }(this, function (exports, sharedUtil, coreWorker) {
  56466. var OK_RESPONSE = 200;
  56467. var PARTIAL_CONTENT_RESPONSE = 206;
  56468. function NetworkManager(url, args) {
  56469. this.url = url;
  56470. args = args || {};
  56471. this.isHttp = /^https?:/i.test(url);
  56472. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56473. this.withCredentials = args.withCredentials || false;
  56474. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56475. return new XMLHttpRequest();
  56476. };
  56477. this.currXhrId = 0;
  56478. this.pendingRequests = Object.create(null);
  56479. this.loadedRequests = Object.create(null);
  56480. }
  56481. function getArrayBuffer(xhr) {
  56482. var data = xhr.response;
  56483. if (typeof data !== 'string') {
  56484. return data;
  56485. }
  56486. var length = data.length;
  56487. var array = new Uint8Array(length);
  56488. for (var i = 0; i < length; i++) {
  56489. array[i] = data.charCodeAt(i) & 0xFF;
  56490. }
  56491. return array.buffer;
  56492. }
  56493. var supportsMozChunked = function supportsMozChunkedClosure() {
  56494. try {
  56495. var x = new XMLHttpRequest();
  56496. x.open('GET', 'https://example.com');
  56497. x.responseType = 'moz-chunked-arraybuffer';
  56498. return x.responseType === 'moz-chunked-arraybuffer';
  56499. } catch (e) {
  56500. return false;
  56501. }
  56502. }();
  56503. NetworkManager.prototype = {
  56504. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56505. var args = {
  56506. begin: begin,
  56507. end: end
  56508. };
  56509. for (var prop in listeners) {
  56510. args[prop] = listeners[prop];
  56511. }
  56512. return this.request(args);
  56513. },
  56514. requestFull: function NetworkManager_requestFull(listeners) {
  56515. return this.request(listeners);
  56516. },
  56517. request: function NetworkManager_request(args) {
  56518. var xhr = this.getXhr();
  56519. var xhrId = this.currXhrId++;
  56520. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56521. xhr.open('GET', this.url);
  56522. xhr.withCredentials = this.withCredentials;
  56523. for (var property in this.httpHeaders) {
  56524. var value = this.httpHeaders[property];
  56525. if (typeof value === 'undefined') {
  56526. continue;
  56527. }
  56528. xhr.setRequestHeader(property, value);
  56529. }
  56530. if (this.isHttp && 'begin' in args && 'end' in args) {
  56531. var rangeStr = args.begin + '-' + (args.end - 1);
  56532. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56533. pendingRequest.expectedStatus = 206;
  56534. } else {
  56535. pendingRequest.expectedStatus = 200;
  56536. }
  56537. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56538. if (useMozChunkedLoading) {
  56539. xhr.responseType = 'moz-chunked-arraybuffer';
  56540. pendingRequest.onProgressiveData = args.onProgressiveData;
  56541. pendingRequest.mozChunked = true;
  56542. } else {
  56543. xhr.responseType = 'arraybuffer';
  56544. }
  56545. if (args.onError) {
  56546. xhr.onerror = function (evt) {
  56547. args.onError(xhr.status);
  56548. };
  56549. }
  56550. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56551. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56552. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56553. pendingRequest.onDone = args.onDone;
  56554. pendingRequest.onError = args.onError;
  56555. pendingRequest.onProgress = args.onProgress;
  56556. xhr.send(null);
  56557. return xhrId;
  56558. },
  56559. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56560. var pendingRequest = this.pendingRequests[xhrId];
  56561. if (!pendingRequest) {
  56562. return;
  56563. }
  56564. if (pendingRequest.mozChunked) {
  56565. var chunk = getArrayBuffer(pendingRequest.xhr);
  56566. pendingRequest.onProgressiveData(chunk);
  56567. }
  56568. var onProgress = pendingRequest.onProgress;
  56569. if (onProgress) {
  56570. onProgress(evt);
  56571. }
  56572. },
  56573. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56574. var pendingRequest = this.pendingRequests[xhrId];
  56575. if (!pendingRequest) {
  56576. return;
  56577. }
  56578. var xhr = pendingRequest.xhr;
  56579. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56580. pendingRequest.onHeadersReceived();
  56581. delete pendingRequest.onHeadersReceived;
  56582. }
  56583. if (xhr.readyState !== 4) {
  56584. return;
  56585. }
  56586. if (!(xhrId in this.pendingRequests)) {
  56587. return;
  56588. }
  56589. delete this.pendingRequests[xhrId];
  56590. if (xhr.status === 0 && this.isHttp) {
  56591. if (pendingRequest.onError) {
  56592. pendingRequest.onError(xhr.status);
  56593. }
  56594. return;
  56595. }
  56596. var xhrStatus = xhr.status || OK_RESPONSE;
  56597. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56598. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56599. if (pendingRequest.onError) {
  56600. pendingRequest.onError(xhr.status);
  56601. }
  56602. return;
  56603. }
  56604. this.loadedRequests[xhrId] = true;
  56605. var chunk = getArrayBuffer(xhr);
  56606. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56607. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56608. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56609. var begin = parseInt(matches[1], 10);
  56610. pendingRequest.onDone({
  56611. begin: begin,
  56612. chunk: chunk
  56613. });
  56614. } else if (pendingRequest.onProgressiveData) {
  56615. pendingRequest.onDone(null);
  56616. } else if (chunk) {
  56617. pendingRequest.onDone({
  56618. begin: 0,
  56619. chunk: chunk
  56620. });
  56621. } else if (pendingRequest.onError) {
  56622. pendingRequest.onError(xhr.status);
  56623. }
  56624. },
  56625. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56626. for (var xhrId in this.pendingRequests) {
  56627. return true;
  56628. }
  56629. return false;
  56630. },
  56631. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56632. return this.pendingRequests[xhrId].xhr;
  56633. },
  56634. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56635. return !!this.pendingRequests[xhrId].onProgressiveData;
  56636. },
  56637. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56638. return xhrId in this.pendingRequests;
  56639. },
  56640. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56641. return xhrId in this.loadedRequests;
  56642. },
  56643. abortAllRequests: function NetworkManager_abortAllRequests() {
  56644. for (var xhrId in this.pendingRequests) {
  56645. this.abortRequest(xhrId | 0);
  56646. }
  56647. },
  56648. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56649. var xhr = this.pendingRequests[xhrId].xhr;
  56650. delete this.pendingRequests[xhrId];
  56651. xhr.abort();
  56652. }
  56653. };
  56654. var assert = sharedUtil.assert;
  56655. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56656. var isInt = sharedUtil.isInt;
  56657. var MissingPDFException = sharedUtil.MissingPDFException;
  56658. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56659. function PDFNetworkStream(options) {
  56660. this._options = options;
  56661. var source = options.source;
  56662. this._manager = new NetworkManager(source.url, {
  56663. httpHeaders: source.httpHeaders,
  56664. withCredentials: source.withCredentials
  56665. });
  56666. this._rangeChunkSize = source.rangeChunkSize;
  56667. this._fullRequestReader = null;
  56668. this._rangeRequestReaders = [];
  56669. }
  56670. PDFNetworkStream.prototype = {
  56671. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56672. var i = this._rangeRequestReaders.indexOf(reader);
  56673. if (i >= 0) {
  56674. this._rangeRequestReaders.splice(i, 1);
  56675. }
  56676. },
  56677. getFullReader: function PDFNetworkStream_getFullReader() {
  56678. assert(!this._fullRequestReader);
  56679. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56680. return this._fullRequestReader;
  56681. },
  56682. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56683. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56684. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56685. this._rangeRequestReaders.push(reader);
  56686. return reader;
  56687. },
  56688. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56689. if (this._fullRequestReader) {
  56690. this._fullRequestReader.cancel(reason);
  56691. }
  56692. var readers = this._rangeRequestReaders.slice(0);
  56693. readers.forEach(function (reader) {
  56694. reader.cancel(reason);
  56695. });
  56696. }
  56697. };
  56698. function PDFNetworkStreamFullRequestReader(manager, options) {
  56699. this._manager = manager;
  56700. var source = options.source;
  56701. var args = {
  56702. onHeadersReceived: this._onHeadersReceived.bind(this),
  56703. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56704. onDone: this._onDone.bind(this),
  56705. onError: this._onError.bind(this),
  56706. onProgress: this._onProgress.bind(this)
  56707. };
  56708. this._url = source.url;
  56709. this._fullRequestId = manager.requestFull(args);
  56710. this._headersReceivedCapability = createPromiseCapability();
  56711. this._disableRange = options.disableRange || false;
  56712. this._contentLength = source.length;
  56713. this._rangeChunkSize = source.rangeChunkSize;
  56714. if (!this._rangeChunkSize && !this._disableRange) {
  56715. this._disableRange = true;
  56716. }
  56717. this._isStreamingSupported = false;
  56718. this._isRangeSupported = false;
  56719. this._cachedChunks = [];
  56720. this._requests = [];
  56721. this._done = false;
  56722. this._storedError = undefined;
  56723. this.onProgress = null;
  56724. }
  56725. PDFNetworkStreamFullRequestReader.prototype = {
  56726. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56727. if (this._disableRange) {
  56728. return false;
  56729. }
  56730. var networkManager = this._manager;
  56731. if (!networkManager.isHttp) {
  56732. return false;
  56733. }
  56734. var fullRequestXhrId = this._fullRequestId;
  56735. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56736. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56737. return false;
  56738. }
  56739. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56740. if (contentEncoding !== 'identity') {
  56741. return false;
  56742. }
  56743. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56744. length = parseInt(length, 10);
  56745. if (!isInt(length)) {
  56746. return false;
  56747. }
  56748. this._contentLength = length;
  56749. if (length <= 2 * this._rangeChunkSize) {
  56750. return false;
  56751. }
  56752. return true;
  56753. },
  56754. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56755. if (this._validateRangeRequestCapabilities()) {
  56756. this._isRangeSupported = true;
  56757. }
  56758. var networkManager = this._manager;
  56759. var fullRequestXhrId = this._fullRequestId;
  56760. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56761. this._isStreamingSupported = true;
  56762. } else if (this._isRangeSupported) {
  56763. networkManager.abortRequest(fullRequestXhrId);
  56764. }
  56765. this._headersReceivedCapability.resolve();
  56766. },
  56767. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56768. if (this._requests.length > 0) {
  56769. var requestCapability = this._requests.shift();
  56770. requestCapability.resolve({
  56771. value: chunk,
  56772. done: false
  56773. });
  56774. } else {
  56775. this._cachedChunks.push(chunk);
  56776. }
  56777. },
  56778. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56779. if (args) {
  56780. this._onProgressiveData(args.chunk);
  56781. }
  56782. this._done = true;
  56783. if (this._cachedChunks.length > 0) {
  56784. return;
  56785. }
  56786. this._requests.forEach(function (requestCapability) {
  56787. requestCapability.resolve({
  56788. value: undefined,
  56789. done: true
  56790. });
  56791. });
  56792. this._requests = [];
  56793. },
  56794. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  56795. var url = this._url;
  56796. var exception;
  56797. if (status === 404 || status === 0 && /^file:/.test(url)) {
  56798. exception = new MissingPDFException('Missing PDF "' + url + '".');
  56799. } else {
  56800. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  56801. }
  56802. this._storedError = exception;
  56803. this._headersReceivedCapability.reject(exception);
  56804. this._requests.forEach(function (requestCapability) {
  56805. requestCapability.reject(exception);
  56806. });
  56807. this._requests = [];
  56808. this._cachedChunks = [];
  56809. },
  56810. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  56811. if (this.onProgress) {
  56812. this.onProgress({
  56813. loaded: data.loaded,
  56814. total: data.lengthComputable ? data.total : this._contentLength
  56815. });
  56816. }
  56817. },
  56818. get isRangeSupported() {
  56819. return this._isRangeSupported;
  56820. },
  56821. get isStreamingSupported() {
  56822. return this._isStreamingSupported;
  56823. },
  56824. get contentLength() {
  56825. return this._contentLength;
  56826. },
  56827. get headersReady() {
  56828. return this._headersReceivedCapability.promise;
  56829. },
  56830. read: function PDFNetworkStreamFullRequestReader_read() {
  56831. if (this._storedError) {
  56832. return Promise.reject(this._storedError);
  56833. }
  56834. if (this._cachedChunks.length > 0) {
  56835. var chunk = this._cachedChunks.shift();
  56836. return Promise.resolve(chunk);
  56837. }
  56838. if (this._done) {
  56839. return Promise.resolve({
  56840. value: undefined,
  56841. done: true
  56842. });
  56843. }
  56844. var requestCapability = createPromiseCapability();
  56845. this._requests.push(requestCapability);
  56846. return requestCapability.promise;
  56847. },
  56848. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  56849. this._done = true;
  56850. this._headersReceivedCapability.reject(reason);
  56851. this._requests.forEach(function (requestCapability) {
  56852. requestCapability.resolve({
  56853. value: undefined,
  56854. done: true
  56855. });
  56856. });
  56857. this._requests = [];
  56858. if (this._manager.isPendingRequest(this._fullRequestId)) {
  56859. this._manager.abortRequest(this._fullRequestId);
  56860. }
  56861. this._fullRequestReader = null;
  56862. }
  56863. };
  56864. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  56865. this._manager = manager;
  56866. var args = {
  56867. onDone: this._onDone.bind(this),
  56868. onProgress: this._onProgress.bind(this)
  56869. };
  56870. this._requestId = manager.requestRange(begin, end, args);
  56871. this._requests = [];
  56872. this._queuedChunk = null;
  56873. this._done = false;
  56874. this.onProgress = null;
  56875. this.onClosed = null;
  56876. }
  56877. PDFNetworkStreamRangeRequestReader.prototype = {
  56878. _close: function PDFNetworkStreamRangeRequestReader_close() {
  56879. if (this.onClosed) {
  56880. this.onClosed(this);
  56881. }
  56882. },
  56883. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  56884. var chunk = data.chunk;
  56885. if (this._requests.length > 0) {
  56886. var requestCapability = this._requests.shift();
  56887. requestCapability.resolve({
  56888. value: chunk,
  56889. done: false
  56890. });
  56891. } else {
  56892. this._queuedChunk = chunk;
  56893. }
  56894. this._done = true;
  56895. this._requests.forEach(function (requestCapability) {
  56896. requestCapability.resolve({
  56897. value: undefined,
  56898. done: true
  56899. });
  56900. });
  56901. this._requests = [];
  56902. this._close();
  56903. },
  56904. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  56905. if (!this.isStreamingSupported && this.onProgress) {
  56906. this.onProgress({ loaded: evt.loaded });
  56907. }
  56908. },
  56909. get isStreamingSupported() {
  56910. return false;
  56911. },
  56912. read: function PDFNetworkStreamRangeRequestReader_read() {
  56913. if (this._queuedChunk !== null) {
  56914. var chunk = this._queuedChunk;
  56915. this._queuedChunk = null;
  56916. return Promise.resolve({
  56917. value: chunk,
  56918. done: false
  56919. });
  56920. }
  56921. if (this._done) {
  56922. return Promise.resolve({
  56923. value: undefined,
  56924. done: true
  56925. });
  56926. }
  56927. var requestCapability = createPromiseCapability();
  56928. this._requests.push(requestCapability);
  56929. return requestCapability.promise;
  56930. },
  56931. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  56932. this._done = true;
  56933. this._requests.forEach(function (requestCapability) {
  56934. requestCapability.resolve({
  56935. value: undefined,
  56936. done: true
  56937. });
  56938. });
  56939. this._requests = [];
  56940. if (this._manager.isPendingRequest(this._requestId)) {
  56941. this._manager.abortRequest(this._requestId);
  56942. }
  56943. this._close();
  56944. }
  56945. };
  56946. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  56947. exports.PDFNetworkStream = PDFNetworkStream;
  56948. exports.NetworkManager = NetworkManager;
  56949. }));
  56950. }.call(pdfjsLibs));
  56951. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  56952. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  56953. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  56954. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  56955. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  56956. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  56957. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  56958. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56959. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  56960. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  56961. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  56962. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  56963. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  56964. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  56965. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  56966. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56967. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  56968. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  56969. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  56970. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  56971. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  56972. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  56973. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56974. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  56975. }));