pdf.combined.js 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId])
  34. /******/ return installedModules[moduleId].exports;
  35. /******/
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // identity function for calling harmony imports with the correct context
  61. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  62. /******/
  63. /******/ // define getter function for harmony exports
  64. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  65. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  66. /******/ Object.defineProperty(exports, name, {
  67. /******/ configurable: false,
  68. /******/ enumerable: true,
  69. /******/ get: getter
  70. /******/ });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // getDefaultExport function for compatibility with non-harmony modules
  75. /******/ __w_pdfjs_require__.n = function(module) {
  76. /******/ var getter = module && module.__esModule ?
  77. /******/ function getDefault() { return module['default']; } :
  78. /******/ function getModuleExports() { return module; };
  79. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  80. /******/ return getter;
  81. /******/ };
  82. /******/
  83. /******/ // Object.prototype.hasOwnProperty.call
  84. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  85. /******/
  86. /******/ // __webpack_public_path__
  87. /******/ __w_pdfjs_require__.p = "";
  88. /******/
  89. /******/ // Load entry module and return exports
  90. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 48);
  91. /******/ })
  92. /************************************************************************/
  93. /******/ ([
  94. /* 0 */
  95. /***/ (function(module, exports, __w_pdfjs_require__) {
  96. "use strict";
  97. /* WEBPACK VAR INJECTION */(function(global) {
  98. var compatibility = __w_pdfjs_require__(47);
  99. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  100. var FONT_IDENTITY_MATRIX = [
  101. 0.001,
  102. 0,
  103. 0,
  104. 0.001,
  105. 0,
  106. 0
  107. ];
  108. var TextRenderingMode = {
  109. FILL: 0,
  110. STROKE: 1,
  111. FILL_STROKE: 2,
  112. INVISIBLE: 3,
  113. FILL_ADD_TO_PATH: 4,
  114. STROKE_ADD_TO_PATH: 5,
  115. FILL_STROKE_ADD_TO_PATH: 6,
  116. ADD_TO_PATH: 7,
  117. FILL_STROKE_MASK: 3,
  118. ADD_TO_PATH_FLAG: 4
  119. };
  120. var ImageKind = {
  121. GRAYSCALE_1BPP: 1,
  122. RGB_24BPP: 2,
  123. RGBA_32BPP: 3
  124. };
  125. var AnnotationType = {
  126. TEXT: 1,
  127. LINK: 2,
  128. FREETEXT: 3,
  129. LINE: 4,
  130. SQUARE: 5,
  131. CIRCLE: 6,
  132. POLYGON: 7,
  133. POLYLINE: 8,
  134. HIGHLIGHT: 9,
  135. UNDERLINE: 10,
  136. SQUIGGLY: 11,
  137. STRIKEOUT: 12,
  138. STAMP: 13,
  139. CARET: 14,
  140. INK: 15,
  141. POPUP: 16,
  142. FILEATTACHMENT: 17,
  143. SOUND: 18,
  144. MOVIE: 19,
  145. WIDGET: 20,
  146. SCREEN: 21,
  147. PRINTERMARK: 22,
  148. TRAPNET: 23,
  149. WATERMARK: 24,
  150. THREED: 25,
  151. REDACT: 26
  152. };
  153. var AnnotationFlag = {
  154. INVISIBLE: 0x01,
  155. HIDDEN: 0x02,
  156. PRINT: 0x04,
  157. NOZOOM: 0x08,
  158. NOROTATE: 0x10,
  159. NOVIEW: 0x20,
  160. READONLY: 0x40,
  161. LOCKED: 0x80,
  162. TOGGLENOVIEW: 0x100,
  163. LOCKEDCONTENTS: 0x200
  164. };
  165. var AnnotationFieldFlag = {
  166. READONLY: 0x0000001,
  167. REQUIRED: 0x0000002,
  168. NOEXPORT: 0x0000004,
  169. MULTILINE: 0x0001000,
  170. PASSWORD: 0x0002000,
  171. NOTOGGLETOOFF: 0x0004000,
  172. RADIO: 0x0008000,
  173. PUSHBUTTON: 0x0010000,
  174. COMBO: 0x0020000,
  175. EDIT: 0x0040000,
  176. SORT: 0x0080000,
  177. FILESELECT: 0x0100000,
  178. MULTISELECT: 0x0200000,
  179. DONOTSPELLCHECK: 0x0400000,
  180. DONOTSCROLL: 0x0800000,
  181. COMB: 0x1000000,
  182. RICHTEXT: 0x2000000,
  183. RADIOSINUNISON: 0x2000000,
  184. COMMITONSELCHANGE: 0x4000000
  185. };
  186. var AnnotationBorderStyleType = {
  187. SOLID: 1,
  188. DASHED: 2,
  189. BEVELED: 3,
  190. INSET: 4,
  191. UNDERLINE: 5
  192. };
  193. var StreamType = {
  194. UNKNOWN: 0,
  195. FLATE: 1,
  196. LZW: 2,
  197. DCT: 3,
  198. JPX: 4,
  199. JBIG: 5,
  200. A85: 6,
  201. AHX: 7,
  202. CCF: 8,
  203. RL: 9
  204. };
  205. var FontType = {
  206. UNKNOWN: 0,
  207. TYPE1: 1,
  208. TYPE1C: 2,
  209. CIDFONTTYPE0: 3,
  210. CIDFONTTYPE0C: 4,
  211. TRUETYPE: 5,
  212. CIDFONTTYPE2: 6,
  213. TYPE3: 7,
  214. OPENTYPE: 8,
  215. TYPE0: 9,
  216. MMTYPE1: 10
  217. };
  218. var VERBOSITY_LEVELS = {
  219. errors: 0,
  220. warnings: 1,
  221. infos: 5
  222. };
  223. var CMapCompressionType = {
  224. NONE: 0,
  225. BINARY: 1,
  226. STREAM: 2
  227. };
  228. var OPS = {
  229. dependency: 1,
  230. setLineWidth: 2,
  231. setLineCap: 3,
  232. setLineJoin: 4,
  233. setMiterLimit: 5,
  234. setDash: 6,
  235. setRenderingIntent: 7,
  236. setFlatness: 8,
  237. setGState: 9,
  238. save: 10,
  239. restore: 11,
  240. transform: 12,
  241. moveTo: 13,
  242. lineTo: 14,
  243. curveTo: 15,
  244. curveTo2: 16,
  245. curveTo3: 17,
  246. closePath: 18,
  247. rectangle: 19,
  248. stroke: 20,
  249. closeStroke: 21,
  250. fill: 22,
  251. eoFill: 23,
  252. fillStroke: 24,
  253. eoFillStroke: 25,
  254. closeFillStroke: 26,
  255. closeEOFillStroke: 27,
  256. endPath: 28,
  257. clip: 29,
  258. eoClip: 30,
  259. beginText: 31,
  260. endText: 32,
  261. setCharSpacing: 33,
  262. setWordSpacing: 34,
  263. setHScale: 35,
  264. setLeading: 36,
  265. setFont: 37,
  266. setTextRenderingMode: 38,
  267. setTextRise: 39,
  268. moveText: 40,
  269. setLeadingMoveText: 41,
  270. setTextMatrix: 42,
  271. nextLine: 43,
  272. showText: 44,
  273. showSpacedText: 45,
  274. nextLineShowText: 46,
  275. nextLineSetSpacingShowText: 47,
  276. setCharWidth: 48,
  277. setCharWidthAndBounds: 49,
  278. setStrokeColorSpace: 50,
  279. setFillColorSpace: 51,
  280. setStrokeColor: 52,
  281. setStrokeColorN: 53,
  282. setFillColor: 54,
  283. setFillColorN: 55,
  284. setStrokeGray: 56,
  285. setFillGray: 57,
  286. setStrokeRGBColor: 58,
  287. setFillRGBColor: 59,
  288. setStrokeCMYKColor: 60,
  289. setFillCMYKColor: 61,
  290. shadingFill: 62,
  291. beginInlineImage: 63,
  292. beginImageData: 64,
  293. endInlineImage: 65,
  294. paintXObject: 66,
  295. markPoint: 67,
  296. markPointProps: 68,
  297. beginMarkedContent: 69,
  298. beginMarkedContentProps: 70,
  299. endMarkedContent: 71,
  300. beginCompat: 72,
  301. endCompat: 73,
  302. paintFormXObjectBegin: 74,
  303. paintFormXObjectEnd: 75,
  304. beginGroup: 76,
  305. endGroup: 77,
  306. beginAnnotations: 78,
  307. endAnnotations: 79,
  308. beginAnnotation: 80,
  309. endAnnotation: 81,
  310. paintJpegXObject: 82,
  311. paintImageMaskXObject: 83,
  312. paintImageMaskXObjectGroup: 84,
  313. paintImageXObject: 85,
  314. paintInlineImageXObject: 86,
  315. paintInlineImageXObjectGroup: 87,
  316. paintImageXObjectRepeat: 88,
  317. paintImageMaskXObjectRepeat: 89,
  318. paintSolidColorImageMask: 90,
  319. constructPath: 91
  320. };
  321. var verbosity = VERBOSITY_LEVELS.warnings;
  322. function setVerbosityLevel(level) {
  323. verbosity = level;
  324. }
  325. function getVerbosityLevel() {
  326. return verbosity;
  327. }
  328. function info(msg) {
  329. if (verbosity >= VERBOSITY_LEVELS.infos) {
  330. console.log('Info: ' + msg);
  331. }
  332. }
  333. function warn(msg) {
  334. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  335. console.log('Warning: ' + msg);
  336. }
  337. }
  338. function deprecated(details) {
  339. console.log('Deprecated API usage: ' + details);
  340. }
  341. function error(msg) {
  342. if (verbosity >= VERBOSITY_LEVELS.errors) {
  343. console.log('Error: ' + msg);
  344. console.log(backtrace());
  345. }
  346. throw new Error(msg);
  347. }
  348. function backtrace() {
  349. try {
  350. throw new Error();
  351. } catch (e) {
  352. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  353. }
  354. }
  355. function assert(cond, msg) {
  356. if (!cond) {
  357. error(msg);
  358. }
  359. }
  360. var UNSUPPORTED_FEATURES = {
  361. unknown: 'unknown',
  362. forms: 'forms',
  363. javaScript: 'javaScript',
  364. smask: 'smask',
  365. shadingPattern: 'shadingPattern',
  366. font: 'font'
  367. };
  368. function isSameOrigin(baseUrl, otherUrl) {
  369. try {
  370. var base = new URL(baseUrl);
  371. if (!base.origin || base.origin === 'null') {
  372. return false;
  373. }
  374. } catch (e) {
  375. return false;
  376. }
  377. var other = new URL(otherUrl, base);
  378. return base.origin === other.origin;
  379. }
  380. function isValidProtocol(url) {
  381. if (!url) {
  382. return false;
  383. }
  384. switch (url.protocol) {
  385. case 'http:':
  386. case 'https:':
  387. case 'ftp:':
  388. case 'mailto:':
  389. case 'tel:':
  390. return true;
  391. default:
  392. return false;
  393. }
  394. }
  395. function createValidAbsoluteUrl(url, baseUrl) {
  396. if (!url) {
  397. return null;
  398. }
  399. try {
  400. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  401. if (isValidProtocol(absoluteUrl)) {
  402. return absoluteUrl;
  403. }
  404. } catch (ex) {
  405. }
  406. return null;
  407. }
  408. function shadow(obj, prop, value) {
  409. Object.defineProperty(obj, prop, {
  410. value: value,
  411. enumerable: true,
  412. configurable: true,
  413. writable: false
  414. });
  415. return value;
  416. }
  417. function getLookupTableFactory(initializer) {
  418. var lookup;
  419. return function () {
  420. if (initializer) {
  421. lookup = Object.create(null);
  422. initializer(lookup);
  423. initializer = null;
  424. }
  425. return lookup;
  426. };
  427. }
  428. var PasswordResponses = {
  429. NEED_PASSWORD: 1,
  430. INCORRECT_PASSWORD: 2
  431. };
  432. var PasswordException = function PasswordExceptionClosure() {
  433. function PasswordException(msg, code) {
  434. this.name = 'PasswordException';
  435. this.message = msg;
  436. this.code = code;
  437. }
  438. PasswordException.prototype = new Error();
  439. PasswordException.constructor = PasswordException;
  440. return PasswordException;
  441. }();
  442. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  443. function UnknownErrorException(msg, details) {
  444. this.name = 'UnknownErrorException';
  445. this.message = msg;
  446. this.details = details;
  447. }
  448. UnknownErrorException.prototype = new Error();
  449. UnknownErrorException.constructor = UnknownErrorException;
  450. return UnknownErrorException;
  451. }();
  452. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  453. function InvalidPDFException(msg) {
  454. this.name = 'InvalidPDFException';
  455. this.message = msg;
  456. }
  457. InvalidPDFException.prototype = new Error();
  458. InvalidPDFException.constructor = InvalidPDFException;
  459. return InvalidPDFException;
  460. }();
  461. var MissingPDFException = function MissingPDFExceptionClosure() {
  462. function MissingPDFException(msg) {
  463. this.name = 'MissingPDFException';
  464. this.message = msg;
  465. }
  466. MissingPDFException.prototype = new Error();
  467. MissingPDFException.constructor = MissingPDFException;
  468. return MissingPDFException;
  469. }();
  470. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  471. function UnexpectedResponseException(msg, status) {
  472. this.name = 'UnexpectedResponseException';
  473. this.message = msg;
  474. this.status = status;
  475. }
  476. UnexpectedResponseException.prototype = new Error();
  477. UnexpectedResponseException.constructor = UnexpectedResponseException;
  478. return UnexpectedResponseException;
  479. }();
  480. var NotImplementedException = function NotImplementedExceptionClosure() {
  481. function NotImplementedException(msg) {
  482. this.message = msg;
  483. }
  484. NotImplementedException.prototype = new Error();
  485. NotImplementedException.prototype.name = 'NotImplementedException';
  486. NotImplementedException.constructor = NotImplementedException;
  487. return NotImplementedException;
  488. }();
  489. var MissingDataException = function MissingDataExceptionClosure() {
  490. function MissingDataException(begin, end) {
  491. this.begin = begin;
  492. this.end = end;
  493. this.message = 'Missing data [' + begin + ', ' + end + ')';
  494. }
  495. MissingDataException.prototype = new Error();
  496. MissingDataException.prototype.name = 'MissingDataException';
  497. MissingDataException.constructor = MissingDataException;
  498. return MissingDataException;
  499. }();
  500. var XRefParseException = function XRefParseExceptionClosure() {
  501. function XRefParseException(msg) {
  502. this.message = msg;
  503. }
  504. XRefParseException.prototype = new Error();
  505. XRefParseException.prototype.name = 'XRefParseException';
  506. XRefParseException.constructor = XRefParseException;
  507. return XRefParseException;
  508. }();
  509. var NullCharactersRegExp = /\x00/g;
  510. function removeNullCharacters(str) {
  511. if (typeof str !== 'string') {
  512. warn('The argument for removeNullCharacters must be a string.');
  513. return str;
  514. }
  515. return str.replace(NullCharactersRegExp, '');
  516. }
  517. function bytesToString(bytes) {
  518. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  519. var length = bytes.length;
  520. var MAX_ARGUMENT_COUNT = 8192;
  521. if (length < MAX_ARGUMENT_COUNT) {
  522. return String.fromCharCode.apply(null, bytes);
  523. }
  524. var strBuf = [];
  525. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  526. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  527. var chunk = bytes.subarray(i, chunkEnd);
  528. strBuf.push(String.fromCharCode.apply(null, chunk));
  529. }
  530. return strBuf.join('');
  531. }
  532. function stringToBytes(str) {
  533. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  534. var length = str.length;
  535. var bytes = new Uint8Array(length);
  536. for (var i = 0; i < length; ++i) {
  537. bytes[i] = str.charCodeAt(i) & 0xFF;
  538. }
  539. return bytes;
  540. }
  541. function arrayByteLength(arr) {
  542. if (arr.length !== undefined) {
  543. return arr.length;
  544. }
  545. assert(arr.byteLength !== undefined);
  546. return arr.byteLength;
  547. }
  548. function arraysToBytes(arr) {
  549. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  550. return arr[0];
  551. }
  552. var resultLength = 0;
  553. var i, ii = arr.length;
  554. var item, itemLength;
  555. for (i = 0; i < ii; i++) {
  556. item = arr[i];
  557. itemLength = arrayByteLength(item);
  558. resultLength += itemLength;
  559. }
  560. var pos = 0;
  561. var data = new Uint8Array(resultLength);
  562. for (i = 0; i < ii; i++) {
  563. item = arr[i];
  564. if (!(item instanceof Uint8Array)) {
  565. if (typeof item === 'string') {
  566. item = stringToBytes(item);
  567. } else {
  568. item = new Uint8Array(item);
  569. }
  570. }
  571. itemLength = item.byteLength;
  572. data.set(item, pos);
  573. pos += itemLength;
  574. }
  575. return data;
  576. }
  577. function string32(value) {
  578. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  579. }
  580. function log2(x) {
  581. var n = 1, i = 0;
  582. while (x > n) {
  583. n <<= 1;
  584. i++;
  585. }
  586. return i;
  587. }
  588. function readInt8(data, start) {
  589. return data[start] << 24 >> 24;
  590. }
  591. function readUint16(data, offset) {
  592. return data[offset] << 8 | data[offset + 1];
  593. }
  594. function readUint32(data, offset) {
  595. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  596. }
  597. function isLittleEndian() {
  598. var buffer8 = new Uint8Array(2);
  599. buffer8[0] = 1;
  600. var buffer16 = new Uint16Array(buffer8.buffer);
  601. return buffer16[0] === 1;
  602. }
  603. function isEvalSupported() {
  604. try {
  605. new Function('');
  606. return true;
  607. } catch (e) {
  608. return false;
  609. }
  610. }
  611. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  612. function Uint32ArrayView(buffer, length) {
  613. this.buffer = buffer;
  614. this.byteLength = buffer.length;
  615. this.length = length === undefined ? this.byteLength >> 2 : length;
  616. ensureUint32ArrayViewProps(this.length);
  617. }
  618. Uint32ArrayView.prototype = Object.create(null);
  619. var uint32ArrayViewSetters = 0;
  620. function createUint32ArrayProp(index) {
  621. return {
  622. get: function () {
  623. var buffer = this.buffer, offset = index << 2;
  624. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  625. },
  626. set: function (value) {
  627. var buffer = this.buffer, offset = index << 2;
  628. buffer[offset] = value & 255;
  629. buffer[offset + 1] = value >> 8 & 255;
  630. buffer[offset + 2] = value >> 16 & 255;
  631. buffer[offset + 3] = value >>> 24 & 255;
  632. }
  633. };
  634. }
  635. function ensureUint32ArrayViewProps(length) {
  636. while (uint32ArrayViewSetters < length) {
  637. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  638. uint32ArrayViewSetters++;
  639. }
  640. }
  641. return Uint32ArrayView;
  642. }();
  643. exports.Uint32ArrayView = Uint32ArrayView;
  644. var IDENTITY_MATRIX = [
  645. 1,
  646. 0,
  647. 0,
  648. 1,
  649. 0,
  650. 0
  651. ];
  652. var Util = function UtilClosure() {
  653. function Util() {
  654. }
  655. var rgbBuf = [
  656. 'rgb(',
  657. 0,
  658. ',',
  659. 0,
  660. ',',
  661. 0,
  662. ')'
  663. ];
  664. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  665. rgbBuf[1] = r;
  666. rgbBuf[3] = g;
  667. rgbBuf[5] = b;
  668. return rgbBuf.join('');
  669. };
  670. Util.transform = function Util_transform(m1, m2) {
  671. return [
  672. m1[0] * m2[0] + m1[2] * m2[1],
  673. m1[1] * m2[0] + m1[3] * m2[1],
  674. m1[0] * m2[2] + m1[2] * m2[3],
  675. m1[1] * m2[2] + m1[3] * m2[3],
  676. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  677. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  678. ];
  679. };
  680. Util.applyTransform = function Util_applyTransform(p, m) {
  681. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  682. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  683. return [
  684. xt,
  685. yt
  686. ];
  687. };
  688. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  689. var d = m[0] * m[3] - m[1] * m[2];
  690. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  691. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  692. return [
  693. xt,
  694. yt
  695. ];
  696. };
  697. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  698. var p1 = Util.applyTransform(r, m);
  699. var p2 = Util.applyTransform(r.slice(2, 4), m);
  700. var p3 = Util.applyTransform([
  701. r[0],
  702. r[3]
  703. ], m);
  704. var p4 = Util.applyTransform([
  705. r[2],
  706. r[1]
  707. ], m);
  708. return [
  709. Math.min(p1[0], p2[0], p3[0], p4[0]),
  710. Math.min(p1[1], p2[1], p3[1], p4[1]),
  711. Math.max(p1[0], p2[0], p3[0], p4[0]),
  712. Math.max(p1[1], p2[1], p3[1], p4[1])
  713. ];
  714. };
  715. Util.inverseTransform = function Util_inverseTransform(m) {
  716. var d = m[0] * m[3] - m[1] * m[2];
  717. return [
  718. m[3] / d,
  719. -m[1] / d,
  720. -m[2] / d,
  721. m[0] / d,
  722. (m[2] * m[5] - m[4] * m[3]) / d,
  723. (m[4] * m[1] - m[5] * m[0]) / d
  724. ];
  725. };
  726. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  727. return [
  728. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  729. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  730. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  731. ];
  732. };
  733. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  734. var transpose = [
  735. m[0],
  736. m[2],
  737. m[1],
  738. m[3]
  739. ];
  740. var a = m[0] * transpose[0] + m[1] * transpose[2];
  741. var b = m[0] * transpose[1] + m[1] * transpose[3];
  742. var c = m[2] * transpose[0] + m[3] * transpose[2];
  743. var d = m[2] * transpose[1] + m[3] * transpose[3];
  744. var first = (a + d) / 2;
  745. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  746. var sx = first + second || 1;
  747. var sy = first - second || 1;
  748. return [
  749. Math.sqrt(sx),
  750. Math.sqrt(sy)
  751. ];
  752. };
  753. Util.normalizeRect = function Util_normalizeRect(rect) {
  754. var r = rect.slice(0);
  755. if (rect[0] > rect[2]) {
  756. r[0] = rect[2];
  757. r[2] = rect[0];
  758. }
  759. if (rect[1] > rect[3]) {
  760. r[1] = rect[3];
  761. r[3] = rect[1];
  762. }
  763. return r;
  764. };
  765. Util.intersect = function Util_intersect(rect1, rect2) {
  766. function compare(a, b) {
  767. return a - b;
  768. }
  769. var orderedX = [
  770. rect1[0],
  771. rect1[2],
  772. rect2[0],
  773. rect2[2]
  774. ].sort(compare), orderedY = [
  775. rect1[1],
  776. rect1[3],
  777. rect2[1],
  778. rect2[3]
  779. ].sort(compare), result = [];
  780. rect1 = Util.normalizeRect(rect1);
  781. rect2 = Util.normalizeRect(rect2);
  782. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  783. result[0] = orderedX[1];
  784. result[2] = orderedX[2];
  785. } else {
  786. return false;
  787. }
  788. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  789. result[1] = orderedY[1];
  790. result[3] = orderedY[2];
  791. } else {
  792. return false;
  793. }
  794. return result;
  795. };
  796. Util.sign = function Util_sign(num) {
  797. return num < 0 ? -1 : 1;
  798. };
  799. var ROMAN_NUMBER_MAP = [
  800. '',
  801. 'C',
  802. 'CC',
  803. 'CCC',
  804. 'CD',
  805. 'D',
  806. 'DC',
  807. 'DCC',
  808. 'DCCC',
  809. 'CM',
  810. '',
  811. 'X',
  812. 'XX',
  813. 'XXX',
  814. 'XL',
  815. 'L',
  816. 'LX',
  817. 'LXX',
  818. 'LXXX',
  819. 'XC',
  820. '',
  821. 'I',
  822. 'II',
  823. 'III',
  824. 'IV',
  825. 'V',
  826. 'VI',
  827. 'VII',
  828. 'VIII',
  829. 'IX'
  830. ];
  831. Util.toRoman = function Util_toRoman(number, lowerCase) {
  832. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  833. var pos, romanBuf = [];
  834. while (number >= 1000) {
  835. number -= 1000;
  836. romanBuf.push('M');
  837. }
  838. pos = number / 100 | 0;
  839. number %= 100;
  840. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  841. pos = number / 10 | 0;
  842. number %= 10;
  843. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  844. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  845. var romanStr = romanBuf.join('');
  846. return lowerCase ? romanStr.toLowerCase() : romanStr;
  847. };
  848. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  849. Array.prototype.push.apply(arr1, arr2);
  850. };
  851. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  852. Array.prototype.unshift.apply(arr1, arr2);
  853. };
  854. Util.extendObj = function extendObj(obj1, obj2) {
  855. for (var key in obj2) {
  856. obj1[key] = obj2[key];
  857. }
  858. };
  859. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  860. while (dict && !dict.has(name)) {
  861. dict = dict.get('Parent');
  862. }
  863. if (!dict) {
  864. return null;
  865. }
  866. return getArray ? dict.getArray(name) : dict.get(name);
  867. };
  868. Util.inherit = function Util_inherit(sub, base, prototype) {
  869. sub.prototype = Object.create(base.prototype);
  870. sub.prototype.constructor = sub;
  871. for (var prop in prototype) {
  872. sub.prototype[prop] = prototype[prop];
  873. }
  874. };
  875. Util.loadScript = function Util_loadScript(src, callback) {
  876. var script = document.createElement('script');
  877. var loaded = false;
  878. script.setAttribute('src', src);
  879. if (callback) {
  880. script.onload = function () {
  881. if (!loaded) {
  882. callback();
  883. }
  884. loaded = true;
  885. };
  886. }
  887. document.getElementsByTagName('head')[0].appendChild(script);
  888. };
  889. return Util;
  890. }();
  891. var PageViewport = function PageViewportClosure() {
  892. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  893. this.viewBox = viewBox;
  894. this.scale = scale;
  895. this.rotation = rotation;
  896. this.offsetX = offsetX;
  897. this.offsetY = offsetY;
  898. var centerX = (viewBox[2] + viewBox[0]) / 2;
  899. var centerY = (viewBox[3] + viewBox[1]) / 2;
  900. var rotateA, rotateB, rotateC, rotateD;
  901. rotation = rotation % 360;
  902. rotation = rotation < 0 ? rotation + 360 : rotation;
  903. switch (rotation) {
  904. case 180:
  905. rotateA = -1;
  906. rotateB = 0;
  907. rotateC = 0;
  908. rotateD = 1;
  909. break;
  910. case 90:
  911. rotateA = 0;
  912. rotateB = 1;
  913. rotateC = 1;
  914. rotateD = 0;
  915. break;
  916. case 270:
  917. rotateA = 0;
  918. rotateB = -1;
  919. rotateC = -1;
  920. rotateD = 0;
  921. break;
  922. default:
  923. rotateA = 1;
  924. rotateB = 0;
  925. rotateC = 0;
  926. rotateD = -1;
  927. break;
  928. }
  929. if (dontFlip) {
  930. rotateC = -rotateC;
  931. rotateD = -rotateD;
  932. }
  933. var offsetCanvasX, offsetCanvasY;
  934. var width, height;
  935. if (rotateA === 0) {
  936. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  937. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  938. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  939. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  940. } else {
  941. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  942. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  943. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  944. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  945. }
  946. this.transform = [
  947. rotateA * scale,
  948. rotateB * scale,
  949. rotateC * scale,
  950. rotateD * scale,
  951. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  952. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  953. ];
  954. this.width = width;
  955. this.height = height;
  956. this.fontScale = scale;
  957. }
  958. PageViewport.prototype = {
  959. clone: function PageViewPort_clone(args) {
  960. args = args || {};
  961. var scale = 'scale' in args ? args.scale : this.scale;
  962. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  963. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  964. },
  965. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  966. return Util.applyTransform([
  967. x,
  968. y
  969. ], this.transform);
  970. },
  971. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  972. var tl = Util.applyTransform([
  973. rect[0],
  974. rect[1]
  975. ], this.transform);
  976. var br = Util.applyTransform([
  977. rect[2],
  978. rect[3]
  979. ], this.transform);
  980. return [
  981. tl[0],
  982. tl[1],
  983. br[0],
  984. br[1]
  985. ];
  986. },
  987. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  988. return Util.applyInverseTransform([
  989. x,
  990. y
  991. ], this.transform);
  992. }
  993. };
  994. return PageViewport;
  995. }();
  996. var PDFStringTranslateTable = [
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0,
  1007. 0,
  1008. 0,
  1009. 0,
  1010. 0,
  1011. 0,
  1012. 0,
  1013. 0,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0x2D8,
  1022. 0x2C7,
  1023. 0x2C6,
  1024. 0x2D9,
  1025. 0x2DD,
  1026. 0x2DB,
  1027. 0x2DA,
  1028. 0x2DC,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0,
  1110. 0,
  1111. 0,
  1112. 0,
  1113. 0,
  1114. 0,
  1115. 0,
  1116. 0,
  1117. 0,
  1118. 0,
  1119. 0,
  1120. 0,
  1121. 0,
  1122. 0,
  1123. 0,
  1124. 0,
  1125. 0x2022,
  1126. 0x2020,
  1127. 0x2021,
  1128. 0x2026,
  1129. 0x2014,
  1130. 0x2013,
  1131. 0x192,
  1132. 0x2044,
  1133. 0x2039,
  1134. 0x203A,
  1135. 0x2212,
  1136. 0x2030,
  1137. 0x201E,
  1138. 0x201C,
  1139. 0x201D,
  1140. 0x2018,
  1141. 0x2019,
  1142. 0x201A,
  1143. 0x2122,
  1144. 0xFB01,
  1145. 0xFB02,
  1146. 0x141,
  1147. 0x152,
  1148. 0x160,
  1149. 0x178,
  1150. 0x17D,
  1151. 0x131,
  1152. 0x142,
  1153. 0x153,
  1154. 0x161,
  1155. 0x17E,
  1156. 0,
  1157. 0x20AC
  1158. ];
  1159. function stringToPDFString(str) {
  1160. var i, n = str.length, strBuf = [];
  1161. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1162. for (i = 2; i < n; i += 2) {
  1163. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1164. }
  1165. } else {
  1166. for (i = 0; i < n; ++i) {
  1167. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1168. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1169. }
  1170. }
  1171. return strBuf.join('');
  1172. }
  1173. function stringToUTF8String(str) {
  1174. return decodeURIComponent(escape(str));
  1175. }
  1176. function utf8StringToString(str) {
  1177. return unescape(encodeURIComponent(str));
  1178. }
  1179. function isEmptyObj(obj) {
  1180. for (var key in obj) {
  1181. return false;
  1182. }
  1183. return true;
  1184. }
  1185. function isBool(v) {
  1186. return typeof v === 'boolean';
  1187. }
  1188. function isInt(v) {
  1189. return typeof v === 'number' && (v | 0) === v;
  1190. }
  1191. function isNum(v) {
  1192. return typeof v === 'number';
  1193. }
  1194. function isString(v) {
  1195. return typeof v === 'string';
  1196. }
  1197. function isArray(v) {
  1198. return v instanceof Array;
  1199. }
  1200. function isArrayBuffer(v) {
  1201. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1202. }
  1203. function isSpace(ch) {
  1204. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1205. }
  1206. function isNodeJS() {
  1207. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1208. return typeof process === 'object' && process + '' === '[object process]';
  1209. }
  1210. return false;
  1211. }
  1212. function createPromiseCapability() {
  1213. var capability = {};
  1214. capability.promise = new Promise(function (resolve, reject) {
  1215. capability.resolve = resolve;
  1216. capability.reject = reject;
  1217. });
  1218. return capability;
  1219. }
  1220. var StatTimer = function StatTimerClosure() {
  1221. function rpad(str, pad, length) {
  1222. while (str.length < length) {
  1223. str += pad;
  1224. }
  1225. return str;
  1226. }
  1227. function StatTimer() {
  1228. this.started = Object.create(null);
  1229. this.times = [];
  1230. this.enabled = true;
  1231. }
  1232. StatTimer.prototype = {
  1233. time: function StatTimer_time(name) {
  1234. if (!this.enabled) {
  1235. return;
  1236. }
  1237. if (name in this.started) {
  1238. warn('Timer is already running for ' + name);
  1239. }
  1240. this.started[name] = Date.now();
  1241. },
  1242. timeEnd: function StatTimer_timeEnd(name) {
  1243. if (!this.enabled) {
  1244. return;
  1245. }
  1246. if (!(name in this.started)) {
  1247. warn('Timer has not been started for ' + name);
  1248. }
  1249. this.times.push({
  1250. 'name': name,
  1251. 'start': this.started[name],
  1252. 'end': Date.now()
  1253. });
  1254. delete this.started[name];
  1255. },
  1256. toString: function StatTimer_toString() {
  1257. var i, ii;
  1258. var times = this.times;
  1259. var out = '';
  1260. var longest = 0;
  1261. for (i = 0, ii = times.length; i < ii; ++i) {
  1262. var name = times[i]['name'];
  1263. if (name.length > longest) {
  1264. longest = name.length;
  1265. }
  1266. }
  1267. for (i = 0, ii = times.length; i < ii; ++i) {
  1268. var span = times[i];
  1269. var duration = span.end - span.start;
  1270. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1271. }
  1272. return out;
  1273. }
  1274. };
  1275. return StatTimer;
  1276. }();
  1277. var createBlob = function createBlob(data, contentType) {
  1278. if (typeof Blob !== 'undefined') {
  1279. return new Blob([data], { type: contentType });
  1280. }
  1281. warn('The "Blob" constructor is not supported.');
  1282. };
  1283. var createObjectURL = function createObjectURLClosure() {
  1284. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1285. return function createObjectURL(data, contentType, forceDataSchema) {
  1286. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1287. var blob = createBlob(data, contentType);
  1288. return URL.createObjectURL(blob);
  1289. }
  1290. var buffer = 'data:' + contentType + ';base64,';
  1291. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1292. var b1 = data[i] & 0xFF;
  1293. var b2 = data[i + 1] & 0xFF;
  1294. var b3 = data[i + 2] & 0xFF;
  1295. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1296. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1297. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1298. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1299. }
  1300. return buffer;
  1301. };
  1302. }();
  1303. function MessageHandler(sourceName, targetName, comObj) {
  1304. this.sourceName = sourceName;
  1305. this.targetName = targetName;
  1306. this.comObj = comObj;
  1307. this.callbackIndex = 1;
  1308. this.postMessageTransfers = true;
  1309. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1310. var ah = this.actionHandler = Object.create(null);
  1311. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1312. var data = event.data;
  1313. if (data.targetName !== this.sourceName) {
  1314. return;
  1315. }
  1316. if (data.isReply) {
  1317. var callbackId = data.callbackId;
  1318. if (data.callbackId in callbacksCapabilities) {
  1319. var callback = callbacksCapabilities[callbackId];
  1320. delete callbacksCapabilities[callbackId];
  1321. if ('error' in data) {
  1322. callback.reject(data.error);
  1323. } else {
  1324. callback.resolve(data.data);
  1325. }
  1326. } else {
  1327. error('Cannot resolve callback ' + callbackId);
  1328. }
  1329. } else if (data.action in ah) {
  1330. var action = ah[data.action];
  1331. if (data.callbackId) {
  1332. var sourceName = this.sourceName;
  1333. var targetName = data.sourceName;
  1334. Promise.resolve().then(function () {
  1335. return action[0].call(action[1], data.data);
  1336. }).then(function (result) {
  1337. comObj.postMessage({
  1338. sourceName: sourceName,
  1339. targetName: targetName,
  1340. isReply: true,
  1341. callbackId: data.callbackId,
  1342. data: result
  1343. });
  1344. }, function (reason) {
  1345. if (reason instanceof Error) {
  1346. reason = reason + '';
  1347. }
  1348. comObj.postMessage({
  1349. sourceName: sourceName,
  1350. targetName: targetName,
  1351. isReply: true,
  1352. callbackId: data.callbackId,
  1353. error: reason
  1354. });
  1355. });
  1356. } else {
  1357. action[0].call(action[1], data.data);
  1358. }
  1359. } else {
  1360. error('Unknown action from worker: ' + data.action);
  1361. }
  1362. }.bind(this);
  1363. comObj.addEventListener('message', this._onComObjOnMessage);
  1364. }
  1365. MessageHandler.prototype = {
  1366. on: function messageHandlerOn(actionName, handler, scope) {
  1367. var ah = this.actionHandler;
  1368. if (ah[actionName]) {
  1369. error('There is already an actionName called "' + actionName + '"');
  1370. }
  1371. ah[actionName] = [
  1372. handler,
  1373. scope
  1374. ];
  1375. },
  1376. send: function messageHandlerSend(actionName, data, transfers) {
  1377. var message = {
  1378. sourceName: this.sourceName,
  1379. targetName: this.targetName,
  1380. action: actionName,
  1381. data: data
  1382. };
  1383. this.postMessage(message, transfers);
  1384. },
  1385. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1386. var callbackId = this.callbackIndex++;
  1387. var message = {
  1388. sourceName: this.sourceName,
  1389. targetName: this.targetName,
  1390. action: actionName,
  1391. data: data,
  1392. callbackId: callbackId
  1393. };
  1394. var capability = createPromiseCapability();
  1395. this.callbacksCapabilities[callbackId] = capability;
  1396. try {
  1397. this.postMessage(message, transfers);
  1398. } catch (e) {
  1399. capability.reject(e);
  1400. }
  1401. return capability.promise;
  1402. },
  1403. postMessage: function (message, transfers) {
  1404. if (transfers && this.postMessageTransfers) {
  1405. this.comObj.postMessage(message, transfers);
  1406. } else {
  1407. this.comObj.postMessage(message);
  1408. }
  1409. },
  1410. destroy: function () {
  1411. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1412. }
  1413. };
  1414. function loadJpegStream(id, imageUrl, objs) {
  1415. var img = new Image();
  1416. img.onload = function loadJpegStream_onloadClosure() {
  1417. objs.resolve(id, img);
  1418. };
  1419. img.onerror = function loadJpegStream_onerrorClosure() {
  1420. objs.resolve(id, null);
  1421. warn('Error during JPEG image loading');
  1422. };
  1423. img.src = imageUrl;
  1424. }
  1425. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1426. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1427. exports.OPS = OPS;
  1428. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1429. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1430. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1431. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1432. exports.AnnotationFlag = AnnotationFlag;
  1433. exports.AnnotationType = AnnotationType;
  1434. exports.FontType = FontType;
  1435. exports.ImageKind = ImageKind;
  1436. exports.CMapCompressionType = CMapCompressionType;
  1437. exports.InvalidPDFException = InvalidPDFException;
  1438. exports.MessageHandler = MessageHandler;
  1439. exports.MissingDataException = MissingDataException;
  1440. exports.MissingPDFException = MissingPDFException;
  1441. exports.NotImplementedException = NotImplementedException;
  1442. exports.PageViewport = PageViewport;
  1443. exports.PasswordException = PasswordException;
  1444. exports.PasswordResponses = PasswordResponses;
  1445. exports.StatTimer = StatTimer;
  1446. exports.StreamType = StreamType;
  1447. exports.TextRenderingMode = TextRenderingMode;
  1448. exports.UnexpectedResponseException = UnexpectedResponseException;
  1449. exports.UnknownErrorException = UnknownErrorException;
  1450. exports.Util = Util;
  1451. exports.XRefParseException = XRefParseException;
  1452. exports.arrayByteLength = arrayByteLength;
  1453. exports.arraysToBytes = arraysToBytes;
  1454. exports.assert = assert;
  1455. exports.bytesToString = bytesToString;
  1456. exports.createBlob = createBlob;
  1457. exports.createPromiseCapability = createPromiseCapability;
  1458. exports.createObjectURL = createObjectURL;
  1459. exports.deprecated = deprecated;
  1460. exports.error = error;
  1461. exports.getLookupTableFactory = getLookupTableFactory;
  1462. exports.getVerbosityLevel = getVerbosityLevel;
  1463. exports.globalScope = globalScope;
  1464. exports.info = info;
  1465. exports.isArray = isArray;
  1466. exports.isArrayBuffer = isArrayBuffer;
  1467. exports.isBool = isBool;
  1468. exports.isEmptyObj = isEmptyObj;
  1469. exports.isInt = isInt;
  1470. exports.isNum = isNum;
  1471. exports.isString = isString;
  1472. exports.isSpace = isSpace;
  1473. exports.isNodeJS = isNodeJS;
  1474. exports.isSameOrigin = isSameOrigin;
  1475. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1476. exports.isLittleEndian = isLittleEndian;
  1477. exports.isEvalSupported = isEvalSupported;
  1478. exports.loadJpegStream = loadJpegStream;
  1479. exports.log2 = log2;
  1480. exports.readInt8 = readInt8;
  1481. exports.readUint16 = readUint16;
  1482. exports.readUint32 = readUint32;
  1483. exports.removeNullCharacters = removeNullCharacters;
  1484. exports.setVerbosityLevel = setVerbosityLevel;
  1485. exports.shadow = shadow;
  1486. exports.string32 = string32;
  1487. exports.stringToBytes = stringToBytes;
  1488. exports.stringToPDFString = stringToPDFString;
  1489. exports.stringToUTF8String = stringToUTF8String;
  1490. exports.utf8StringToString = utf8StringToString;
  1491. exports.warn = warn;
  1492. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  1493. /***/ }),
  1494. /* 1 */
  1495. /***/ (function(module, exports, __w_pdfjs_require__) {
  1496. "use strict";
  1497. var sharedUtil = __w_pdfjs_require__(0);
  1498. var isArray = sharedUtil.isArray;
  1499. var EOF = {};
  1500. var Name = function NameClosure() {
  1501. function Name(name) {
  1502. this.name = name;
  1503. }
  1504. Name.prototype = {};
  1505. var nameCache = Object.create(null);
  1506. Name.get = function Name_get(name) {
  1507. var nameValue = nameCache[name];
  1508. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1509. };
  1510. return Name;
  1511. }();
  1512. var Cmd = function CmdClosure() {
  1513. function Cmd(cmd) {
  1514. this.cmd = cmd;
  1515. }
  1516. Cmd.prototype = {};
  1517. var cmdCache = Object.create(null);
  1518. Cmd.get = function Cmd_get(cmd) {
  1519. var cmdValue = cmdCache[cmd];
  1520. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1521. };
  1522. return Cmd;
  1523. }();
  1524. var Dict = function DictClosure() {
  1525. var nonSerializable = function nonSerializableClosure() {
  1526. return nonSerializable;
  1527. };
  1528. function Dict(xref) {
  1529. this.map = Object.create(null);
  1530. this.xref = xref;
  1531. this.objId = null;
  1532. this.suppressEncryption = false;
  1533. this.__nonSerializable__ = nonSerializable;
  1534. }
  1535. Dict.prototype = {
  1536. assignXref: function Dict_assignXref(newXref) {
  1537. this.xref = newXref;
  1538. },
  1539. get: function Dict_get(key1, key2, key3) {
  1540. var value;
  1541. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1542. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1543. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1544. }
  1545. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1546. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1547. }
  1548. value = this.map[key3] || null;
  1549. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1550. },
  1551. getAsync: function Dict_getAsync(key1, key2, key3) {
  1552. var value;
  1553. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1554. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1555. if (xref) {
  1556. return xref.fetchIfRefAsync(value, suppressEncryption);
  1557. }
  1558. return Promise.resolve(value);
  1559. }
  1560. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1561. if (xref) {
  1562. return xref.fetchIfRefAsync(value, suppressEncryption);
  1563. }
  1564. return Promise.resolve(value);
  1565. }
  1566. value = this.map[key3] || null;
  1567. if (xref) {
  1568. return xref.fetchIfRefAsync(value, suppressEncryption);
  1569. }
  1570. return Promise.resolve(value);
  1571. },
  1572. getArray: function Dict_getArray(key1, key2, key3) {
  1573. var value = this.get(key1, key2, key3);
  1574. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1575. if (!isArray(value) || !xref) {
  1576. return value;
  1577. }
  1578. value = value.slice();
  1579. for (var i = 0, ii = value.length; i < ii; i++) {
  1580. if (!isRef(value[i])) {
  1581. continue;
  1582. }
  1583. value[i] = xref.fetch(value[i], suppressEncryption);
  1584. }
  1585. return value;
  1586. },
  1587. getRaw: function Dict_getRaw(key) {
  1588. return this.map[key];
  1589. },
  1590. getKeys: function Dict_getKeys() {
  1591. return Object.keys(this.map);
  1592. },
  1593. set: function Dict_set(key, value) {
  1594. this.map[key] = value;
  1595. },
  1596. has: function Dict_has(key) {
  1597. return key in this.map;
  1598. },
  1599. forEach: function Dict_forEach(callback) {
  1600. for (var key in this.map) {
  1601. callback(key, this.get(key));
  1602. }
  1603. }
  1604. };
  1605. Dict.empty = new Dict(null);
  1606. Dict.merge = function Dict_merge(xref, dictArray) {
  1607. var mergedDict = new Dict(xref);
  1608. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1609. var dict = dictArray[i];
  1610. if (!isDict(dict)) {
  1611. continue;
  1612. }
  1613. for (var keyName in dict.map) {
  1614. if (mergedDict.map[keyName]) {
  1615. continue;
  1616. }
  1617. mergedDict.map[keyName] = dict.map[keyName];
  1618. }
  1619. }
  1620. return mergedDict;
  1621. };
  1622. return Dict;
  1623. }();
  1624. var Ref = function RefClosure() {
  1625. function Ref(num, gen) {
  1626. this.num = num;
  1627. this.gen = gen;
  1628. }
  1629. Ref.prototype = {
  1630. toString: function Ref_toString() {
  1631. var str = this.num + 'R';
  1632. if (this.gen !== 0) {
  1633. str += this.gen;
  1634. }
  1635. return str;
  1636. }
  1637. };
  1638. return Ref;
  1639. }();
  1640. var RefSet = function RefSetClosure() {
  1641. function RefSet() {
  1642. this.dict = Object.create(null);
  1643. }
  1644. RefSet.prototype = {
  1645. has: function RefSet_has(ref) {
  1646. return ref.toString() in this.dict;
  1647. },
  1648. put: function RefSet_put(ref) {
  1649. this.dict[ref.toString()] = true;
  1650. },
  1651. remove: function RefSet_remove(ref) {
  1652. delete this.dict[ref.toString()];
  1653. }
  1654. };
  1655. return RefSet;
  1656. }();
  1657. var RefSetCache = function RefSetCacheClosure() {
  1658. function RefSetCache() {
  1659. this.dict = Object.create(null);
  1660. }
  1661. RefSetCache.prototype = {
  1662. get: function RefSetCache_get(ref) {
  1663. return this.dict[ref.toString()];
  1664. },
  1665. has: function RefSetCache_has(ref) {
  1666. return ref.toString() in this.dict;
  1667. },
  1668. put: function RefSetCache_put(ref, obj) {
  1669. this.dict[ref.toString()] = obj;
  1670. },
  1671. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1672. this.dict[ref.toString()] = this.get(aliasRef);
  1673. },
  1674. forEach: function RefSetCache_forEach(fn, thisArg) {
  1675. for (var i in this.dict) {
  1676. fn.call(thisArg, this.dict[i]);
  1677. }
  1678. },
  1679. clear: function RefSetCache_clear() {
  1680. this.dict = Object.create(null);
  1681. }
  1682. };
  1683. return RefSetCache;
  1684. }();
  1685. function isEOF(v) {
  1686. return v === EOF;
  1687. }
  1688. function isName(v, name) {
  1689. return v instanceof Name && (name === undefined || v.name === name);
  1690. }
  1691. function isCmd(v, cmd) {
  1692. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1693. }
  1694. function isDict(v, type) {
  1695. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1696. }
  1697. function isRef(v) {
  1698. return v instanceof Ref;
  1699. }
  1700. function isRefsEqual(v1, v2) {
  1701. return v1.num === v2.num && v1.gen === v2.gen;
  1702. }
  1703. function isStream(v) {
  1704. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  1705. }
  1706. exports.EOF = EOF;
  1707. exports.Cmd = Cmd;
  1708. exports.Dict = Dict;
  1709. exports.Name = Name;
  1710. exports.Ref = Ref;
  1711. exports.RefSet = RefSet;
  1712. exports.RefSetCache = RefSetCache;
  1713. exports.isEOF = isEOF;
  1714. exports.isCmd = isCmd;
  1715. exports.isDict = isDict;
  1716. exports.isName = isName;
  1717. exports.isRef = isRef;
  1718. exports.isRefsEqual = isRefsEqual;
  1719. exports.isStream = isStream;
  1720. /***/ }),
  1721. /* 2 */
  1722. /***/ (function(module, exports, __w_pdfjs_require__) {
  1723. "use strict";
  1724. var sharedUtil = __w_pdfjs_require__(0);
  1725. var corePrimitives = __w_pdfjs_require__(1);
  1726. var coreJbig2 = __w_pdfjs_require__(35);
  1727. var coreJpg = __w_pdfjs_require__(36);
  1728. var coreJpx = __w_pdfjs_require__(19);
  1729. var Util = sharedUtil.Util;
  1730. var error = sharedUtil.error;
  1731. var info = sharedUtil.info;
  1732. var isInt = sharedUtil.isInt;
  1733. var isArray = sharedUtil.isArray;
  1734. var createObjectURL = sharedUtil.createObjectURL;
  1735. var shadow = sharedUtil.shadow;
  1736. var isSpace = sharedUtil.isSpace;
  1737. var Dict = corePrimitives.Dict;
  1738. var isDict = corePrimitives.isDict;
  1739. var isStream = corePrimitives.isStream;
  1740. var Jbig2Image = coreJbig2.Jbig2Image;
  1741. var JpegImage = coreJpg.JpegImage;
  1742. var JpxImage = coreJpx.JpxImage;
  1743. var Stream = function StreamClosure() {
  1744. function Stream(arrayBuffer, start, length, dict) {
  1745. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1746. this.start = start || 0;
  1747. this.pos = this.start;
  1748. this.end = start + length || this.bytes.length;
  1749. this.dict = dict;
  1750. }
  1751. Stream.prototype = {
  1752. get length() {
  1753. return this.end - this.start;
  1754. },
  1755. get isEmpty() {
  1756. return this.length === 0;
  1757. },
  1758. getByte: function Stream_getByte() {
  1759. if (this.pos >= this.end) {
  1760. return -1;
  1761. }
  1762. return this.bytes[this.pos++];
  1763. },
  1764. getUint16: function Stream_getUint16() {
  1765. var b0 = this.getByte();
  1766. var b1 = this.getByte();
  1767. if (b0 === -1 || b1 === -1) {
  1768. return -1;
  1769. }
  1770. return (b0 << 8) + b1;
  1771. },
  1772. getInt32: function Stream_getInt32() {
  1773. var b0 = this.getByte();
  1774. var b1 = this.getByte();
  1775. var b2 = this.getByte();
  1776. var b3 = this.getByte();
  1777. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1778. },
  1779. getBytes: function Stream_getBytes(length) {
  1780. var bytes = this.bytes;
  1781. var pos = this.pos;
  1782. var strEnd = this.end;
  1783. if (!length) {
  1784. return bytes.subarray(pos, strEnd);
  1785. }
  1786. var end = pos + length;
  1787. if (end > strEnd) {
  1788. end = strEnd;
  1789. }
  1790. this.pos = end;
  1791. return bytes.subarray(pos, end);
  1792. },
  1793. peekByte: function Stream_peekByte() {
  1794. var peekedByte = this.getByte();
  1795. this.pos--;
  1796. return peekedByte;
  1797. },
  1798. peekBytes: function Stream_peekBytes(length) {
  1799. var bytes = this.getBytes(length);
  1800. this.pos -= bytes.length;
  1801. return bytes;
  1802. },
  1803. skip: function Stream_skip(n) {
  1804. if (!n) {
  1805. n = 1;
  1806. }
  1807. this.pos += n;
  1808. },
  1809. reset: function Stream_reset() {
  1810. this.pos = this.start;
  1811. },
  1812. moveStart: function Stream_moveStart() {
  1813. this.start = this.pos;
  1814. },
  1815. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1816. return new Stream(this.bytes.buffer, start, length, dict);
  1817. }
  1818. };
  1819. return Stream;
  1820. }();
  1821. var StringStream = function StringStreamClosure() {
  1822. function StringStream(str) {
  1823. var length = str.length;
  1824. var bytes = new Uint8Array(length);
  1825. for (var n = 0; n < length; ++n) {
  1826. bytes[n] = str.charCodeAt(n);
  1827. }
  1828. Stream.call(this, bytes);
  1829. }
  1830. StringStream.prototype = Stream.prototype;
  1831. return StringStream;
  1832. }();
  1833. var DecodeStream = function DecodeStreamClosure() {
  1834. var emptyBuffer = new Uint8Array(0);
  1835. function DecodeStream(maybeMinBufferLength) {
  1836. this.pos = 0;
  1837. this.bufferLength = 0;
  1838. this.eof = false;
  1839. this.buffer = emptyBuffer;
  1840. this.minBufferLength = 512;
  1841. if (maybeMinBufferLength) {
  1842. while (this.minBufferLength < maybeMinBufferLength) {
  1843. this.minBufferLength *= 2;
  1844. }
  1845. }
  1846. }
  1847. DecodeStream.prototype = {
  1848. get isEmpty() {
  1849. while (!this.eof && this.bufferLength === 0) {
  1850. this.readBlock();
  1851. }
  1852. return this.bufferLength === 0;
  1853. },
  1854. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1855. var buffer = this.buffer;
  1856. if (requested <= buffer.byteLength) {
  1857. return buffer;
  1858. }
  1859. var size = this.minBufferLength;
  1860. while (size < requested) {
  1861. size *= 2;
  1862. }
  1863. var buffer2 = new Uint8Array(size);
  1864. buffer2.set(buffer);
  1865. return this.buffer = buffer2;
  1866. },
  1867. getByte: function DecodeStream_getByte() {
  1868. var pos = this.pos;
  1869. while (this.bufferLength <= pos) {
  1870. if (this.eof) {
  1871. return -1;
  1872. }
  1873. this.readBlock();
  1874. }
  1875. return this.buffer[this.pos++];
  1876. },
  1877. getUint16: function DecodeStream_getUint16() {
  1878. var b0 = this.getByte();
  1879. var b1 = this.getByte();
  1880. if (b0 === -1 || b1 === -1) {
  1881. return -1;
  1882. }
  1883. return (b0 << 8) + b1;
  1884. },
  1885. getInt32: function DecodeStream_getInt32() {
  1886. var b0 = this.getByte();
  1887. var b1 = this.getByte();
  1888. var b2 = this.getByte();
  1889. var b3 = this.getByte();
  1890. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1891. },
  1892. getBytes: function DecodeStream_getBytes(length) {
  1893. var end, pos = this.pos;
  1894. if (length) {
  1895. this.ensureBuffer(pos + length);
  1896. end = pos + length;
  1897. while (!this.eof && this.bufferLength < end) {
  1898. this.readBlock();
  1899. }
  1900. var bufEnd = this.bufferLength;
  1901. if (end > bufEnd) {
  1902. end = bufEnd;
  1903. }
  1904. } else {
  1905. while (!this.eof) {
  1906. this.readBlock();
  1907. }
  1908. end = this.bufferLength;
  1909. }
  1910. this.pos = end;
  1911. return this.buffer.subarray(pos, end);
  1912. },
  1913. peekByte: function DecodeStream_peekByte() {
  1914. var peekedByte = this.getByte();
  1915. this.pos--;
  1916. return peekedByte;
  1917. },
  1918. peekBytes: function DecodeStream_peekBytes(length) {
  1919. var bytes = this.getBytes(length);
  1920. this.pos -= bytes.length;
  1921. return bytes;
  1922. },
  1923. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1924. var end = start + length;
  1925. while (this.bufferLength <= end && !this.eof) {
  1926. this.readBlock();
  1927. }
  1928. return new Stream(this.buffer, start, length, dict);
  1929. },
  1930. skip: function DecodeStream_skip(n) {
  1931. if (!n) {
  1932. n = 1;
  1933. }
  1934. this.pos += n;
  1935. },
  1936. reset: function DecodeStream_reset() {
  1937. this.pos = 0;
  1938. },
  1939. getBaseStreams: function DecodeStream_getBaseStreams() {
  1940. if (this.str && this.str.getBaseStreams) {
  1941. return this.str.getBaseStreams();
  1942. }
  1943. return [];
  1944. }
  1945. };
  1946. return DecodeStream;
  1947. }();
  1948. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1949. function StreamsSequenceStream(streams) {
  1950. this.streams = streams;
  1951. DecodeStream.call(this, null);
  1952. }
  1953. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1954. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1955. var streams = this.streams;
  1956. if (streams.length === 0) {
  1957. this.eof = true;
  1958. return;
  1959. }
  1960. var stream = streams.shift();
  1961. var chunk = stream.getBytes();
  1962. var bufferLength = this.bufferLength;
  1963. var newLength = bufferLength + chunk.length;
  1964. var buffer = this.ensureBuffer(newLength);
  1965. buffer.set(chunk, bufferLength);
  1966. this.bufferLength = newLength;
  1967. };
  1968. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1969. var baseStreams = [];
  1970. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1971. var stream = this.streams[i];
  1972. if (stream.getBaseStreams) {
  1973. Util.appendToArray(baseStreams, stream.getBaseStreams());
  1974. }
  1975. }
  1976. return baseStreams;
  1977. };
  1978. return StreamsSequenceStream;
  1979. }();
  1980. var FlateStream = function FlateStreamClosure() {
  1981. var codeLenCodeMap = new Int32Array([
  1982. 16,
  1983. 17,
  1984. 18,
  1985. 0,
  1986. 8,
  1987. 7,
  1988. 9,
  1989. 6,
  1990. 10,
  1991. 5,
  1992. 11,
  1993. 4,
  1994. 12,
  1995. 3,
  1996. 13,
  1997. 2,
  1998. 14,
  1999. 1,
  2000. 15
  2001. ]);
  2002. var lengthDecode = new Int32Array([
  2003. 0x00003,
  2004. 0x00004,
  2005. 0x00005,
  2006. 0x00006,
  2007. 0x00007,
  2008. 0x00008,
  2009. 0x00009,
  2010. 0x0000a,
  2011. 0x1000b,
  2012. 0x1000d,
  2013. 0x1000f,
  2014. 0x10011,
  2015. 0x20013,
  2016. 0x20017,
  2017. 0x2001b,
  2018. 0x2001f,
  2019. 0x30023,
  2020. 0x3002b,
  2021. 0x30033,
  2022. 0x3003b,
  2023. 0x40043,
  2024. 0x40053,
  2025. 0x40063,
  2026. 0x40073,
  2027. 0x50083,
  2028. 0x500a3,
  2029. 0x500c3,
  2030. 0x500e3,
  2031. 0x00102,
  2032. 0x00102,
  2033. 0x00102
  2034. ]);
  2035. var distDecode = new Int32Array([
  2036. 0x00001,
  2037. 0x00002,
  2038. 0x00003,
  2039. 0x00004,
  2040. 0x10005,
  2041. 0x10007,
  2042. 0x20009,
  2043. 0x2000d,
  2044. 0x30011,
  2045. 0x30019,
  2046. 0x40021,
  2047. 0x40031,
  2048. 0x50041,
  2049. 0x50061,
  2050. 0x60081,
  2051. 0x600c1,
  2052. 0x70101,
  2053. 0x70181,
  2054. 0x80201,
  2055. 0x80301,
  2056. 0x90401,
  2057. 0x90601,
  2058. 0xa0801,
  2059. 0xa0c01,
  2060. 0xb1001,
  2061. 0xb1801,
  2062. 0xc2001,
  2063. 0xc3001,
  2064. 0xd4001,
  2065. 0xd6001
  2066. ]);
  2067. var fixedLitCodeTab = [
  2068. new Int32Array([
  2069. 0x70100,
  2070. 0x80050,
  2071. 0x80010,
  2072. 0x80118,
  2073. 0x70110,
  2074. 0x80070,
  2075. 0x80030,
  2076. 0x900c0,
  2077. 0x70108,
  2078. 0x80060,
  2079. 0x80020,
  2080. 0x900a0,
  2081. 0x80000,
  2082. 0x80080,
  2083. 0x80040,
  2084. 0x900e0,
  2085. 0x70104,
  2086. 0x80058,
  2087. 0x80018,
  2088. 0x90090,
  2089. 0x70114,
  2090. 0x80078,
  2091. 0x80038,
  2092. 0x900d0,
  2093. 0x7010c,
  2094. 0x80068,
  2095. 0x80028,
  2096. 0x900b0,
  2097. 0x80008,
  2098. 0x80088,
  2099. 0x80048,
  2100. 0x900f0,
  2101. 0x70102,
  2102. 0x80054,
  2103. 0x80014,
  2104. 0x8011c,
  2105. 0x70112,
  2106. 0x80074,
  2107. 0x80034,
  2108. 0x900c8,
  2109. 0x7010a,
  2110. 0x80064,
  2111. 0x80024,
  2112. 0x900a8,
  2113. 0x80004,
  2114. 0x80084,
  2115. 0x80044,
  2116. 0x900e8,
  2117. 0x70106,
  2118. 0x8005c,
  2119. 0x8001c,
  2120. 0x90098,
  2121. 0x70116,
  2122. 0x8007c,
  2123. 0x8003c,
  2124. 0x900d8,
  2125. 0x7010e,
  2126. 0x8006c,
  2127. 0x8002c,
  2128. 0x900b8,
  2129. 0x8000c,
  2130. 0x8008c,
  2131. 0x8004c,
  2132. 0x900f8,
  2133. 0x70101,
  2134. 0x80052,
  2135. 0x80012,
  2136. 0x8011a,
  2137. 0x70111,
  2138. 0x80072,
  2139. 0x80032,
  2140. 0x900c4,
  2141. 0x70109,
  2142. 0x80062,
  2143. 0x80022,
  2144. 0x900a4,
  2145. 0x80002,
  2146. 0x80082,
  2147. 0x80042,
  2148. 0x900e4,
  2149. 0x70105,
  2150. 0x8005a,
  2151. 0x8001a,
  2152. 0x90094,
  2153. 0x70115,
  2154. 0x8007a,
  2155. 0x8003a,
  2156. 0x900d4,
  2157. 0x7010d,
  2158. 0x8006a,
  2159. 0x8002a,
  2160. 0x900b4,
  2161. 0x8000a,
  2162. 0x8008a,
  2163. 0x8004a,
  2164. 0x900f4,
  2165. 0x70103,
  2166. 0x80056,
  2167. 0x80016,
  2168. 0x8011e,
  2169. 0x70113,
  2170. 0x80076,
  2171. 0x80036,
  2172. 0x900cc,
  2173. 0x7010b,
  2174. 0x80066,
  2175. 0x80026,
  2176. 0x900ac,
  2177. 0x80006,
  2178. 0x80086,
  2179. 0x80046,
  2180. 0x900ec,
  2181. 0x70107,
  2182. 0x8005e,
  2183. 0x8001e,
  2184. 0x9009c,
  2185. 0x70117,
  2186. 0x8007e,
  2187. 0x8003e,
  2188. 0x900dc,
  2189. 0x7010f,
  2190. 0x8006e,
  2191. 0x8002e,
  2192. 0x900bc,
  2193. 0x8000e,
  2194. 0x8008e,
  2195. 0x8004e,
  2196. 0x900fc,
  2197. 0x70100,
  2198. 0x80051,
  2199. 0x80011,
  2200. 0x80119,
  2201. 0x70110,
  2202. 0x80071,
  2203. 0x80031,
  2204. 0x900c2,
  2205. 0x70108,
  2206. 0x80061,
  2207. 0x80021,
  2208. 0x900a2,
  2209. 0x80001,
  2210. 0x80081,
  2211. 0x80041,
  2212. 0x900e2,
  2213. 0x70104,
  2214. 0x80059,
  2215. 0x80019,
  2216. 0x90092,
  2217. 0x70114,
  2218. 0x80079,
  2219. 0x80039,
  2220. 0x900d2,
  2221. 0x7010c,
  2222. 0x80069,
  2223. 0x80029,
  2224. 0x900b2,
  2225. 0x80009,
  2226. 0x80089,
  2227. 0x80049,
  2228. 0x900f2,
  2229. 0x70102,
  2230. 0x80055,
  2231. 0x80015,
  2232. 0x8011d,
  2233. 0x70112,
  2234. 0x80075,
  2235. 0x80035,
  2236. 0x900ca,
  2237. 0x7010a,
  2238. 0x80065,
  2239. 0x80025,
  2240. 0x900aa,
  2241. 0x80005,
  2242. 0x80085,
  2243. 0x80045,
  2244. 0x900ea,
  2245. 0x70106,
  2246. 0x8005d,
  2247. 0x8001d,
  2248. 0x9009a,
  2249. 0x70116,
  2250. 0x8007d,
  2251. 0x8003d,
  2252. 0x900da,
  2253. 0x7010e,
  2254. 0x8006d,
  2255. 0x8002d,
  2256. 0x900ba,
  2257. 0x8000d,
  2258. 0x8008d,
  2259. 0x8004d,
  2260. 0x900fa,
  2261. 0x70101,
  2262. 0x80053,
  2263. 0x80013,
  2264. 0x8011b,
  2265. 0x70111,
  2266. 0x80073,
  2267. 0x80033,
  2268. 0x900c6,
  2269. 0x70109,
  2270. 0x80063,
  2271. 0x80023,
  2272. 0x900a6,
  2273. 0x80003,
  2274. 0x80083,
  2275. 0x80043,
  2276. 0x900e6,
  2277. 0x70105,
  2278. 0x8005b,
  2279. 0x8001b,
  2280. 0x90096,
  2281. 0x70115,
  2282. 0x8007b,
  2283. 0x8003b,
  2284. 0x900d6,
  2285. 0x7010d,
  2286. 0x8006b,
  2287. 0x8002b,
  2288. 0x900b6,
  2289. 0x8000b,
  2290. 0x8008b,
  2291. 0x8004b,
  2292. 0x900f6,
  2293. 0x70103,
  2294. 0x80057,
  2295. 0x80017,
  2296. 0x8011f,
  2297. 0x70113,
  2298. 0x80077,
  2299. 0x80037,
  2300. 0x900ce,
  2301. 0x7010b,
  2302. 0x80067,
  2303. 0x80027,
  2304. 0x900ae,
  2305. 0x80007,
  2306. 0x80087,
  2307. 0x80047,
  2308. 0x900ee,
  2309. 0x70107,
  2310. 0x8005f,
  2311. 0x8001f,
  2312. 0x9009e,
  2313. 0x70117,
  2314. 0x8007f,
  2315. 0x8003f,
  2316. 0x900de,
  2317. 0x7010f,
  2318. 0x8006f,
  2319. 0x8002f,
  2320. 0x900be,
  2321. 0x8000f,
  2322. 0x8008f,
  2323. 0x8004f,
  2324. 0x900fe,
  2325. 0x70100,
  2326. 0x80050,
  2327. 0x80010,
  2328. 0x80118,
  2329. 0x70110,
  2330. 0x80070,
  2331. 0x80030,
  2332. 0x900c1,
  2333. 0x70108,
  2334. 0x80060,
  2335. 0x80020,
  2336. 0x900a1,
  2337. 0x80000,
  2338. 0x80080,
  2339. 0x80040,
  2340. 0x900e1,
  2341. 0x70104,
  2342. 0x80058,
  2343. 0x80018,
  2344. 0x90091,
  2345. 0x70114,
  2346. 0x80078,
  2347. 0x80038,
  2348. 0x900d1,
  2349. 0x7010c,
  2350. 0x80068,
  2351. 0x80028,
  2352. 0x900b1,
  2353. 0x80008,
  2354. 0x80088,
  2355. 0x80048,
  2356. 0x900f1,
  2357. 0x70102,
  2358. 0x80054,
  2359. 0x80014,
  2360. 0x8011c,
  2361. 0x70112,
  2362. 0x80074,
  2363. 0x80034,
  2364. 0x900c9,
  2365. 0x7010a,
  2366. 0x80064,
  2367. 0x80024,
  2368. 0x900a9,
  2369. 0x80004,
  2370. 0x80084,
  2371. 0x80044,
  2372. 0x900e9,
  2373. 0x70106,
  2374. 0x8005c,
  2375. 0x8001c,
  2376. 0x90099,
  2377. 0x70116,
  2378. 0x8007c,
  2379. 0x8003c,
  2380. 0x900d9,
  2381. 0x7010e,
  2382. 0x8006c,
  2383. 0x8002c,
  2384. 0x900b9,
  2385. 0x8000c,
  2386. 0x8008c,
  2387. 0x8004c,
  2388. 0x900f9,
  2389. 0x70101,
  2390. 0x80052,
  2391. 0x80012,
  2392. 0x8011a,
  2393. 0x70111,
  2394. 0x80072,
  2395. 0x80032,
  2396. 0x900c5,
  2397. 0x70109,
  2398. 0x80062,
  2399. 0x80022,
  2400. 0x900a5,
  2401. 0x80002,
  2402. 0x80082,
  2403. 0x80042,
  2404. 0x900e5,
  2405. 0x70105,
  2406. 0x8005a,
  2407. 0x8001a,
  2408. 0x90095,
  2409. 0x70115,
  2410. 0x8007a,
  2411. 0x8003a,
  2412. 0x900d5,
  2413. 0x7010d,
  2414. 0x8006a,
  2415. 0x8002a,
  2416. 0x900b5,
  2417. 0x8000a,
  2418. 0x8008a,
  2419. 0x8004a,
  2420. 0x900f5,
  2421. 0x70103,
  2422. 0x80056,
  2423. 0x80016,
  2424. 0x8011e,
  2425. 0x70113,
  2426. 0x80076,
  2427. 0x80036,
  2428. 0x900cd,
  2429. 0x7010b,
  2430. 0x80066,
  2431. 0x80026,
  2432. 0x900ad,
  2433. 0x80006,
  2434. 0x80086,
  2435. 0x80046,
  2436. 0x900ed,
  2437. 0x70107,
  2438. 0x8005e,
  2439. 0x8001e,
  2440. 0x9009d,
  2441. 0x70117,
  2442. 0x8007e,
  2443. 0x8003e,
  2444. 0x900dd,
  2445. 0x7010f,
  2446. 0x8006e,
  2447. 0x8002e,
  2448. 0x900bd,
  2449. 0x8000e,
  2450. 0x8008e,
  2451. 0x8004e,
  2452. 0x900fd,
  2453. 0x70100,
  2454. 0x80051,
  2455. 0x80011,
  2456. 0x80119,
  2457. 0x70110,
  2458. 0x80071,
  2459. 0x80031,
  2460. 0x900c3,
  2461. 0x70108,
  2462. 0x80061,
  2463. 0x80021,
  2464. 0x900a3,
  2465. 0x80001,
  2466. 0x80081,
  2467. 0x80041,
  2468. 0x900e3,
  2469. 0x70104,
  2470. 0x80059,
  2471. 0x80019,
  2472. 0x90093,
  2473. 0x70114,
  2474. 0x80079,
  2475. 0x80039,
  2476. 0x900d3,
  2477. 0x7010c,
  2478. 0x80069,
  2479. 0x80029,
  2480. 0x900b3,
  2481. 0x80009,
  2482. 0x80089,
  2483. 0x80049,
  2484. 0x900f3,
  2485. 0x70102,
  2486. 0x80055,
  2487. 0x80015,
  2488. 0x8011d,
  2489. 0x70112,
  2490. 0x80075,
  2491. 0x80035,
  2492. 0x900cb,
  2493. 0x7010a,
  2494. 0x80065,
  2495. 0x80025,
  2496. 0x900ab,
  2497. 0x80005,
  2498. 0x80085,
  2499. 0x80045,
  2500. 0x900eb,
  2501. 0x70106,
  2502. 0x8005d,
  2503. 0x8001d,
  2504. 0x9009b,
  2505. 0x70116,
  2506. 0x8007d,
  2507. 0x8003d,
  2508. 0x900db,
  2509. 0x7010e,
  2510. 0x8006d,
  2511. 0x8002d,
  2512. 0x900bb,
  2513. 0x8000d,
  2514. 0x8008d,
  2515. 0x8004d,
  2516. 0x900fb,
  2517. 0x70101,
  2518. 0x80053,
  2519. 0x80013,
  2520. 0x8011b,
  2521. 0x70111,
  2522. 0x80073,
  2523. 0x80033,
  2524. 0x900c7,
  2525. 0x70109,
  2526. 0x80063,
  2527. 0x80023,
  2528. 0x900a7,
  2529. 0x80003,
  2530. 0x80083,
  2531. 0x80043,
  2532. 0x900e7,
  2533. 0x70105,
  2534. 0x8005b,
  2535. 0x8001b,
  2536. 0x90097,
  2537. 0x70115,
  2538. 0x8007b,
  2539. 0x8003b,
  2540. 0x900d7,
  2541. 0x7010d,
  2542. 0x8006b,
  2543. 0x8002b,
  2544. 0x900b7,
  2545. 0x8000b,
  2546. 0x8008b,
  2547. 0x8004b,
  2548. 0x900f7,
  2549. 0x70103,
  2550. 0x80057,
  2551. 0x80017,
  2552. 0x8011f,
  2553. 0x70113,
  2554. 0x80077,
  2555. 0x80037,
  2556. 0x900cf,
  2557. 0x7010b,
  2558. 0x80067,
  2559. 0x80027,
  2560. 0x900af,
  2561. 0x80007,
  2562. 0x80087,
  2563. 0x80047,
  2564. 0x900ef,
  2565. 0x70107,
  2566. 0x8005f,
  2567. 0x8001f,
  2568. 0x9009f,
  2569. 0x70117,
  2570. 0x8007f,
  2571. 0x8003f,
  2572. 0x900df,
  2573. 0x7010f,
  2574. 0x8006f,
  2575. 0x8002f,
  2576. 0x900bf,
  2577. 0x8000f,
  2578. 0x8008f,
  2579. 0x8004f,
  2580. 0x900ff
  2581. ]),
  2582. 9
  2583. ];
  2584. var fixedDistCodeTab = [
  2585. new Int32Array([
  2586. 0x50000,
  2587. 0x50010,
  2588. 0x50008,
  2589. 0x50018,
  2590. 0x50004,
  2591. 0x50014,
  2592. 0x5000c,
  2593. 0x5001c,
  2594. 0x50002,
  2595. 0x50012,
  2596. 0x5000a,
  2597. 0x5001a,
  2598. 0x50006,
  2599. 0x50016,
  2600. 0x5000e,
  2601. 0x00000,
  2602. 0x50001,
  2603. 0x50011,
  2604. 0x50009,
  2605. 0x50019,
  2606. 0x50005,
  2607. 0x50015,
  2608. 0x5000d,
  2609. 0x5001d,
  2610. 0x50003,
  2611. 0x50013,
  2612. 0x5000b,
  2613. 0x5001b,
  2614. 0x50007,
  2615. 0x50017,
  2616. 0x5000f,
  2617. 0x00000
  2618. ]),
  2619. 5
  2620. ];
  2621. function FlateStream(str, maybeLength) {
  2622. this.str = str;
  2623. this.dict = str.dict;
  2624. var cmf = str.getByte();
  2625. var flg = str.getByte();
  2626. if (cmf === -1 || flg === -1) {
  2627. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  2628. }
  2629. if ((cmf & 0x0f) !== 0x08) {
  2630. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  2631. }
  2632. if (((cmf << 8) + flg) % 31 !== 0) {
  2633. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  2634. }
  2635. if (flg & 0x20) {
  2636. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  2637. }
  2638. this.codeSize = 0;
  2639. this.codeBuf = 0;
  2640. DecodeStream.call(this, maybeLength);
  2641. }
  2642. FlateStream.prototype = Object.create(DecodeStream.prototype);
  2643. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  2644. var str = this.str;
  2645. var codeSize = this.codeSize;
  2646. var codeBuf = this.codeBuf;
  2647. var b;
  2648. while (codeSize < bits) {
  2649. if ((b = str.getByte()) === -1) {
  2650. error('Bad encoding in flate stream');
  2651. }
  2652. codeBuf |= b << codeSize;
  2653. codeSize += 8;
  2654. }
  2655. b = codeBuf & (1 << bits) - 1;
  2656. this.codeBuf = codeBuf >> bits;
  2657. this.codeSize = codeSize -= bits;
  2658. return b;
  2659. };
  2660. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2661. var str = this.str;
  2662. var codes = table[0];
  2663. var maxLen = table[1];
  2664. var codeSize = this.codeSize;
  2665. var codeBuf = this.codeBuf;
  2666. var b;
  2667. while (codeSize < maxLen) {
  2668. if ((b = str.getByte()) === -1) {
  2669. break;
  2670. }
  2671. codeBuf |= b << codeSize;
  2672. codeSize += 8;
  2673. }
  2674. var code = codes[codeBuf & (1 << maxLen) - 1];
  2675. var codeLen = code >> 16;
  2676. var codeVal = code & 0xffff;
  2677. if (codeLen < 1 || codeSize < codeLen) {
  2678. error('Bad encoding in flate stream');
  2679. }
  2680. this.codeBuf = codeBuf >> codeLen;
  2681. this.codeSize = codeSize - codeLen;
  2682. return codeVal;
  2683. };
  2684. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2685. var n = lengths.length;
  2686. var maxLen = 0;
  2687. var i;
  2688. for (i = 0; i < n; ++i) {
  2689. if (lengths[i] > maxLen) {
  2690. maxLen = lengths[i];
  2691. }
  2692. }
  2693. var size = 1 << maxLen;
  2694. var codes = new Int32Array(size);
  2695. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2696. for (var val = 0; val < n; ++val) {
  2697. if (lengths[val] === len) {
  2698. var code2 = 0;
  2699. var t = code;
  2700. for (i = 0; i < len; ++i) {
  2701. code2 = code2 << 1 | t & 1;
  2702. t >>= 1;
  2703. }
  2704. for (i = code2; i < size; i += skip) {
  2705. codes[i] = len << 16 | val;
  2706. }
  2707. ++code;
  2708. }
  2709. }
  2710. }
  2711. return [
  2712. codes,
  2713. maxLen
  2714. ];
  2715. };
  2716. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2717. var buffer, len;
  2718. var str = this.str;
  2719. var hdr = this.getBits(3);
  2720. if (hdr & 1) {
  2721. this.eof = true;
  2722. }
  2723. hdr >>= 1;
  2724. if (hdr === 0) {
  2725. var b;
  2726. if ((b = str.getByte()) === -1) {
  2727. error('Bad block header in flate stream');
  2728. }
  2729. var blockLen = b;
  2730. if ((b = str.getByte()) === -1) {
  2731. error('Bad block header in flate stream');
  2732. }
  2733. blockLen |= b << 8;
  2734. if ((b = str.getByte()) === -1) {
  2735. error('Bad block header in flate stream');
  2736. }
  2737. var check = b;
  2738. if ((b = str.getByte()) === -1) {
  2739. error('Bad block header in flate stream');
  2740. }
  2741. check |= b << 8;
  2742. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2743. error('Bad uncompressed block length in flate stream');
  2744. }
  2745. this.codeBuf = 0;
  2746. this.codeSize = 0;
  2747. var bufferLength = this.bufferLength;
  2748. buffer = this.ensureBuffer(bufferLength + blockLen);
  2749. var end = bufferLength + blockLen;
  2750. this.bufferLength = end;
  2751. if (blockLen === 0) {
  2752. if (str.peekByte() === -1) {
  2753. this.eof = true;
  2754. }
  2755. } else {
  2756. for (var n = bufferLength; n < end; ++n) {
  2757. if ((b = str.getByte()) === -1) {
  2758. this.eof = true;
  2759. break;
  2760. }
  2761. buffer[n] = b;
  2762. }
  2763. }
  2764. return;
  2765. }
  2766. var litCodeTable;
  2767. var distCodeTable;
  2768. if (hdr === 1) {
  2769. litCodeTable = fixedLitCodeTab;
  2770. distCodeTable = fixedDistCodeTab;
  2771. } else if (hdr === 2) {
  2772. var numLitCodes = this.getBits(5) + 257;
  2773. var numDistCodes = this.getBits(5) + 1;
  2774. var numCodeLenCodes = this.getBits(4) + 4;
  2775. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2776. var i;
  2777. for (i = 0; i < numCodeLenCodes; ++i) {
  2778. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2779. }
  2780. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2781. len = 0;
  2782. i = 0;
  2783. var codes = numLitCodes + numDistCodes;
  2784. var codeLengths = new Uint8Array(codes);
  2785. var bitsLength, bitsOffset, what;
  2786. while (i < codes) {
  2787. var code = this.getCode(codeLenCodeTab);
  2788. if (code === 16) {
  2789. bitsLength = 2;
  2790. bitsOffset = 3;
  2791. what = len;
  2792. } else if (code === 17) {
  2793. bitsLength = 3;
  2794. bitsOffset = 3;
  2795. what = len = 0;
  2796. } else if (code === 18) {
  2797. bitsLength = 7;
  2798. bitsOffset = 11;
  2799. what = len = 0;
  2800. } else {
  2801. codeLengths[i++] = len = code;
  2802. continue;
  2803. }
  2804. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2805. while (repeatLength-- > 0) {
  2806. codeLengths[i++] = what;
  2807. }
  2808. }
  2809. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2810. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2811. } else {
  2812. error('Unknown block type in flate stream');
  2813. }
  2814. buffer = this.buffer;
  2815. var limit = buffer ? buffer.length : 0;
  2816. var pos = this.bufferLength;
  2817. while (true) {
  2818. var code1 = this.getCode(litCodeTable);
  2819. if (code1 < 256) {
  2820. if (pos + 1 >= limit) {
  2821. buffer = this.ensureBuffer(pos + 1);
  2822. limit = buffer.length;
  2823. }
  2824. buffer[pos++] = code1;
  2825. continue;
  2826. }
  2827. if (code1 === 256) {
  2828. this.bufferLength = pos;
  2829. return;
  2830. }
  2831. code1 -= 257;
  2832. code1 = lengthDecode[code1];
  2833. var code2 = code1 >> 16;
  2834. if (code2 > 0) {
  2835. code2 = this.getBits(code2);
  2836. }
  2837. len = (code1 & 0xffff) + code2;
  2838. code1 = this.getCode(distCodeTable);
  2839. code1 = distDecode[code1];
  2840. code2 = code1 >> 16;
  2841. if (code2 > 0) {
  2842. code2 = this.getBits(code2);
  2843. }
  2844. var dist = (code1 & 0xffff) + code2;
  2845. if (pos + len >= limit) {
  2846. buffer = this.ensureBuffer(pos + len);
  2847. limit = buffer.length;
  2848. }
  2849. for (var k = 0; k < len; ++k, ++pos) {
  2850. buffer[pos] = buffer[pos - dist];
  2851. }
  2852. }
  2853. };
  2854. return FlateStream;
  2855. }();
  2856. var PredictorStream = function PredictorStreamClosure() {
  2857. function PredictorStream(str, maybeLength, params) {
  2858. if (!isDict(params)) {
  2859. return str;
  2860. }
  2861. var predictor = this.predictor = params.get('Predictor') || 1;
  2862. if (predictor <= 1) {
  2863. return str;
  2864. }
  2865. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2866. error('Unsupported predictor: ' + predictor);
  2867. }
  2868. if (predictor === 2) {
  2869. this.readBlock = this.readBlockTiff;
  2870. } else {
  2871. this.readBlock = this.readBlockPng;
  2872. }
  2873. this.str = str;
  2874. this.dict = str.dict;
  2875. var colors = this.colors = params.get('Colors') || 1;
  2876. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2877. var columns = this.columns = params.get('Columns') || 1;
  2878. this.pixBytes = colors * bits + 7 >> 3;
  2879. this.rowBytes = columns * colors * bits + 7 >> 3;
  2880. DecodeStream.call(this, maybeLength);
  2881. return this;
  2882. }
  2883. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2884. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2885. var rowBytes = this.rowBytes;
  2886. var bufferLength = this.bufferLength;
  2887. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2888. var bits = this.bits;
  2889. var colors = this.colors;
  2890. var rawBytes = this.str.getBytes(rowBytes);
  2891. this.eof = !rawBytes.length;
  2892. if (this.eof) {
  2893. return;
  2894. }
  2895. var inbuf = 0, outbuf = 0;
  2896. var inbits = 0, outbits = 0;
  2897. var pos = bufferLength;
  2898. var i;
  2899. if (bits === 1 && colors === 1) {
  2900. for (i = 0; i < rowBytes; ++i) {
  2901. var c = rawBytes[i] ^ inbuf;
  2902. c ^= c >> 1;
  2903. c ^= c >> 2;
  2904. c ^= c >> 4;
  2905. inbuf = (c & 1) << 7;
  2906. buffer[pos++] = c;
  2907. }
  2908. } else if (bits === 8) {
  2909. for (i = 0; i < colors; ++i) {
  2910. buffer[pos++] = rawBytes[i];
  2911. }
  2912. for (; i < rowBytes; ++i) {
  2913. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2914. pos++;
  2915. }
  2916. } else {
  2917. var compArray = new Uint8Array(colors + 1);
  2918. var bitMask = (1 << bits) - 1;
  2919. var j = 0, k = bufferLength;
  2920. var columns = this.columns;
  2921. for (i = 0; i < columns; ++i) {
  2922. for (var kk = 0; kk < colors; ++kk) {
  2923. if (inbits < bits) {
  2924. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2925. inbits += 8;
  2926. }
  2927. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2928. inbits -= bits;
  2929. outbuf = outbuf << bits | compArray[kk];
  2930. outbits += bits;
  2931. if (outbits >= 8) {
  2932. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2933. outbits -= 8;
  2934. }
  2935. }
  2936. }
  2937. if (outbits > 0) {
  2938. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2939. }
  2940. }
  2941. this.bufferLength += rowBytes;
  2942. };
  2943. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2944. var rowBytes = this.rowBytes;
  2945. var pixBytes = this.pixBytes;
  2946. var predictor = this.str.getByte();
  2947. var rawBytes = this.str.getBytes(rowBytes);
  2948. this.eof = !rawBytes.length;
  2949. if (this.eof) {
  2950. return;
  2951. }
  2952. var bufferLength = this.bufferLength;
  2953. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2954. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2955. if (prevRow.length === 0) {
  2956. prevRow = new Uint8Array(rowBytes);
  2957. }
  2958. var i, j = bufferLength, up, c;
  2959. switch (predictor) {
  2960. case 0:
  2961. for (i = 0; i < rowBytes; ++i) {
  2962. buffer[j++] = rawBytes[i];
  2963. }
  2964. break;
  2965. case 1:
  2966. for (i = 0; i < pixBytes; ++i) {
  2967. buffer[j++] = rawBytes[i];
  2968. }
  2969. for (; i < rowBytes; ++i) {
  2970. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2971. j++;
  2972. }
  2973. break;
  2974. case 2:
  2975. for (i = 0; i < rowBytes; ++i) {
  2976. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2977. }
  2978. break;
  2979. case 3:
  2980. for (i = 0; i < pixBytes; ++i) {
  2981. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2982. }
  2983. for (; i < rowBytes; ++i) {
  2984. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2985. j++;
  2986. }
  2987. break;
  2988. case 4:
  2989. for (i = 0; i < pixBytes; ++i) {
  2990. up = prevRow[i];
  2991. c = rawBytes[i];
  2992. buffer[j++] = up + c;
  2993. }
  2994. for (; i < rowBytes; ++i) {
  2995. up = prevRow[i];
  2996. var upLeft = prevRow[i - pixBytes];
  2997. var left = buffer[j - pixBytes];
  2998. var p = left + up - upLeft;
  2999. var pa = p - left;
  3000. if (pa < 0) {
  3001. pa = -pa;
  3002. }
  3003. var pb = p - up;
  3004. if (pb < 0) {
  3005. pb = -pb;
  3006. }
  3007. var pc = p - upLeft;
  3008. if (pc < 0) {
  3009. pc = -pc;
  3010. }
  3011. c = rawBytes[i];
  3012. if (pa <= pb && pa <= pc) {
  3013. buffer[j++] = left + c;
  3014. } else if (pb <= pc) {
  3015. buffer[j++] = up + c;
  3016. } else {
  3017. buffer[j++] = upLeft + c;
  3018. }
  3019. }
  3020. break;
  3021. default:
  3022. error('Unsupported predictor: ' + predictor);
  3023. }
  3024. this.bufferLength += rowBytes;
  3025. };
  3026. return PredictorStream;
  3027. }();
  3028. var JpegStream = function JpegStreamClosure() {
  3029. function JpegStream(stream, maybeLength, dict, params) {
  3030. var ch;
  3031. while ((ch = stream.getByte()) !== -1) {
  3032. if (ch === 0xFF) {
  3033. stream.skip(-1);
  3034. break;
  3035. }
  3036. }
  3037. this.stream = stream;
  3038. this.maybeLength = maybeLength;
  3039. this.dict = dict;
  3040. this.params = params;
  3041. DecodeStream.call(this, maybeLength);
  3042. }
  3043. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3044. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3045. get: function JpegStream_bytes() {
  3046. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3047. },
  3048. configurable: true
  3049. });
  3050. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3051. if (this.bufferLength) {
  3052. return;
  3053. }
  3054. var jpegImage = new JpegImage();
  3055. var decodeArr = this.dict.getArray('Decode', 'D');
  3056. if (this.forceRGB && isArray(decodeArr)) {
  3057. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3058. var decodeArrLength = decodeArr.length;
  3059. var transform = new Int32Array(decodeArrLength);
  3060. var transformNeeded = false;
  3061. var maxValue = (1 << bitsPerComponent) - 1;
  3062. for (var i = 0; i < decodeArrLength; i += 2) {
  3063. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3064. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3065. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3066. transformNeeded = true;
  3067. }
  3068. }
  3069. if (transformNeeded) {
  3070. jpegImage.decodeTransform = transform;
  3071. }
  3072. }
  3073. if (isDict(this.params)) {
  3074. var colorTransform = this.params.get('ColorTransform');
  3075. if (isInt(colorTransform)) {
  3076. jpegImage.colorTransform = colorTransform;
  3077. }
  3078. }
  3079. jpegImage.parse(this.bytes);
  3080. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3081. this.buffer = data;
  3082. this.bufferLength = data.length;
  3083. this.eof = true;
  3084. };
  3085. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3086. this.ensureBuffer();
  3087. return this.buffer;
  3088. };
  3089. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3090. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3091. };
  3092. return JpegStream;
  3093. }();
  3094. var JpxStream = function JpxStreamClosure() {
  3095. function JpxStream(stream, maybeLength, dict, params) {
  3096. this.stream = stream;
  3097. this.maybeLength = maybeLength;
  3098. this.dict = dict;
  3099. this.params = params;
  3100. DecodeStream.call(this, maybeLength);
  3101. }
  3102. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3103. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3104. get: function JpxStream_bytes() {
  3105. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3106. },
  3107. configurable: true
  3108. });
  3109. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3110. if (this.bufferLength) {
  3111. return;
  3112. }
  3113. var jpxImage = new JpxImage();
  3114. jpxImage.parse(this.bytes);
  3115. var width = jpxImage.width;
  3116. var height = jpxImage.height;
  3117. var componentsCount = jpxImage.componentsCount;
  3118. var tileCount = jpxImage.tiles.length;
  3119. if (tileCount === 1) {
  3120. this.buffer = jpxImage.tiles[0].items;
  3121. } else {
  3122. var data = new Uint8Array(width * height * componentsCount);
  3123. for (var k = 0; k < tileCount; k++) {
  3124. var tileComponents = jpxImage.tiles[k];
  3125. var tileWidth = tileComponents.width;
  3126. var tileHeight = tileComponents.height;
  3127. var tileLeft = tileComponents.left;
  3128. var tileTop = tileComponents.top;
  3129. var src = tileComponents.items;
  3130. var srcPosition = 0;
  3131. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3132. var imgRowSize = width * componentsCount;
  3133. var tileRowSize = tileWidth * componentsCount;
  3134. for (var j = 0; j < tileHeight; j++) {
  3135. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3136. data.set(rowBytes, dataPosition);
  3137. srcPosition += tileRowSize;
  3138. dataPosition += imgRowSize;
  3139. }
  3140. }
  3141. this.buffer = data;
  3142. }
  3143. this.bufferLength = this.buffer.length;
  3144. this.eof = true;
  3145. };
  3146. return JpxStream;
  3147. }();
  3148. var Jbig2Stream = function Jbig2StreamClosure() {
  3149. function Jbig2Stream(stream, maybeLength, dict, params) {
  3150. this.stream = stream;
  3151. this.maybeLength = maybeLength;
  3152. this.dict = dict;
  3153. this.params = params;
  3154. DecodeStream.call(this, maybeLength);
  3155. }
  3156. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3157. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3158. get: function Jbig2Stream_bytes() {
  3159. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3160. },
  3161. configurable: true
  3162. });
  3163. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3164. if (this.bufferLength) {
  3165. return;
  3166. }
  3167. var jbig2Image = new Jbig2Image();
  3168. var chunks = [];
  3169. if (isDict(this.params)) {
  3170. var globalsStream = this.params.get('JBIG2Globals');
  3171. if (isStream(globalsStream)) {
  3172. var globals = globalsStream.getBytes();
  3173. chunks.push({
  3174. data: globals,
  3175. start: 0,
  3176. end: globals.length
  3177. });
  3178. }
  3179. }
  3180. chunks.push({
  3181. data: this.bytes,
  3182. start: 0,
  3183. end: this.bytes.length
  3184. });
  3185. var data = jbig2Image.parseChunks(chunks);
  3186. var dataLength = data.length;
  3187. for (var i = 0; i < dataLength; i++) {
  3188. data[i] ^= 0xFF;
  3189. }
  3190. this.buffer = data;
  3191. this.bufferLength = dataLength;
  3192. this.eof = true;
  3193. };
  3194. return Jbig2Stream;
  3195. }();
  3196. var DecryptStream = function DecryptStreamClosure() {
  3197. function DecryptStream(str, maybeLength, decrypt) {
  3198. this.str = str;
  3199. this.dict = str.dict;
  3200. this.decrypt = decrypt;
  3201. this.nextChunk = null;
  3202. this.initialized = false;
  3203. DecodeStream.call(this, maybeLength);
  3204. }
  3205. var chunkSize = 512;
  3206. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  3207. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  3208. var chunk;
  3209. if (this.initialized) {
  3210. chunk = this.nextChunk;
  3211. } else {
  3212. chunk = this.str.getBytes(chunkSize);
  3213. this.initialized = true;
  3214. }
  3215. if (!chunk || chunk.length === 0) {
  3216. this.eof = true;
  3217. return;
  3218. }
  3219. this.nextChunk = this.str.getBytes(chunkSize);
  3220. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  3221. var decrypt = this.decrypt;
  3222. chunk = decrypt(chunk, !hasMoreData);
  3223. var bufferLength = this.bufferLength;
  3224. var i, n = chunk.length;
  3225. var buffer = this.ensureBuffer(bufferLength + n);
  3226. for (i = 0; i < n; i++) {
  3227. buffer[bufferLength++] = chunk[i];
  3228. }
  3229. this.bufferLength = bufferLength;
  3230. };
  3231. return DecryptStream;
  3232. }();
  3233. var Ascii85Stream = function Ascii85StreamClosure() {
  3234. function Ascii85Stream(str, maybeLength) {
  3235. this.str = str;
  3236. this.dict = str.dict;
  3237. this.input = new Uint8Array(5);
  3238. if (maybeLength) {
  3239. maybeLength = 0.8 * maybeLength;
  3240. }
  3241. DecodeStream.call(this, maybeLength);
  3242. }
  3243. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  3244. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  3245. var TILDA_CHAR = 0x7E;
  3246. var Z_LOWER_CHAR = 0x7A;
  3247. var EOF = -1;
  3248. var str = this.str;
  3249. var c = str.getByte();
  3250. while (isSpace(c)) {
  3251. c = str.getByte();
  3252. }
  3253. if (c === EOF || c === TILDA_CHAR) {
  3254. this.eof = true;
  3255. return;
  3256. }
  3257. var bufferLength = this.bufferLength, buffer;
  3258. var i;
  3259. if (c === Z_LOWER_CHAR) {
  3260. buffer = this.ensureBuffer(bufferLength + 4);
  3261. for (i = 0; i < 4; ++i) {
  3262. buffer[bufferLength + i] = 0;
  3263. }
  3264. this.bufferLength += 4;
  3265. } else {
  3266. var input = this.input;
  3267. input[0] = c;
  3268. for (i = 1; i < 5; ++i) {
  3269. c = str.getByte();
  3270. while (isSpace(c)) {
  3271. c = str.getByte();
  3272. }
  3273. input[i] = c;
  3274. if (c === EOF || c === TILDA_CHAR) {
  3275. break;
  3276. }
  3277. }
  3278. buffer = this.ensureBuffer(bufferLength + i - 1);
  3279. this.bufferLength += i - 1;
  3280. if (i < 5) {
  3281. for (; i < 5; ++i) {
  3282. input[i] = 0x21 + 84;
  3283. }
  3284. this.eof = true;
  3285. }
  3286. var t = 0;
  3287. for (i = 0; i < 5; ++i) {
  3288. t = t * 85 + (input[i] - 0x21);
  3289. }
  3290. for (i = 3; i >= 0; --i) {
  3291. buffer[bufferLength + i] = t & 0xFF;
  3292. t >>= 8;
  3293. }
  3294. }
  3295. };
  3296. return Ascii85Stream;
  3297. }();
  3298. var AsciiHexStream = function AsciiHexStreamClosure() {
  3299. function AsciiHexStream(str, maybeLength) {
  3300. this.str = str;
  3301. this.dict = str.dict;
  3302. this.firstDigit = -1;
  3303. if (maybeLength) {
  3304. maybeLength = 0.5 * maybeLength;
  3305. }
  3306. DecodeStream.call(this, maybeLength);
  3307. }
  3308. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  3309. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  3310. var UPSTREAM_BLOCK_SIZE = 8000;
  3311. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  3312. if (!bytes.length) {
  3313. this.eof = true;
  3314. return;
  3315. }
  3316. var maxDecodeLength = bytes.length + 1 >> 1;
  3317. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  3318. var bufferLength = this.bufferLength;
  3319. var firstDigit = this.firstDigit;
  3320. for (var i = 0, ii = bytes.length; i < ii; i++) {
  3321. var ch = bytes[i], digit;
  3322. if (ch >= 0x30 && ch <= 0x39) {
  3323. digit = ch & 0x0F;
  3324. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  3325. digit = (ch & 0x0F) + 9;
  3326. } else if (ch === 0x3E) {
  3327. this.eof = true;
  3328. break;
  3329. } else {
  3330. continue;
  3331. }
  3332. if (firstDigit < 0) {
  3333. firstDigit = digit;
  3334. } else {
  3335. buffer[bufferLength++] = firstDigit << 4 | digit;
  3336. firstDigit = -1;
  3337. }
  3338. }
  3339. if (firstDigit >= 0 && this.eof) {
  3340. buffer[bufferLength++] = firstDigit << 4;
  3341. firstDigit = -1;
  3342. }
  3343. this.firstDigit = firstDigit;
  3344. this.bufferLength = bufferLength;
  3345. };
  3346. return AsciiHexStream;
  3347. }();
  3348. var RunLengthStream = function RunLengthStreamClosure() {
  3349. function RunLengthStream(str, maybeLength) {
  3350. this.str = str;
  3351. this.dict = str.dict;
  3352. DecodeStream.call(this, maybeLength);
  3353. }
  3354. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  3355. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  3356. var repeatHeader = this.str.getBytes(2);
  3357. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  3358. this.eof = true;
  3359. return;
  3360. }
  3361. var buffer;
  3362. var bufferLength = this.bufferLength;
  3363. var n = repeatHeader[0];
  3364. if (n < 128) {
  3365. buffer = this.ensureBuffer(bufferLength + n + 1);
  3366. buffer[bufferLength++] = repeatHeader[1];
  3367. if (n > 0) {
  3368. var source = this.str.getBytes(n);
  3369. buffer.set(source, bufferLength);
  3370. bufferLength += n;
  3371. }
  3372. } else {
  3373. n = 257 - n;
  3374. var b = repeatHeader[1];
  3375. buffer = this.ensureBuffer(bufferLength + n + 1);
  3376. for (var i = 0; i < n; i++) {
  3377. buffer[bufferLength++] = b;
  3378. }
  3379. }
  3380. this.bufferLength = bufferLength;
  3381. };
  3382. return RunLengthStream;
  3383. }();
  3384. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  3385. var ccittEOL = -2;
  3386. var ccittEOF = -1;
  3387. var twoDimPass = 0;
  3388. var twoDimHoriz = 1;
  3389. var twoDimVert0 = 2;
  3390. var twoDimVertR1 = 3;
  3391. var twoDimVertL1 = 4;
  3392. var twoDimVertR2 = 5;
  3393. var twoDimVertL2 = 6;
  3394. var twoDimVertR3 = 7;
  3395. var twoDimVertL3 = 8;
  3396. var twoDimTable = [
  3397. [
  3398. -1,
  3399. -1
  3400. ],
  3401. [
  3402. -1,
  3403. -1
  3404. ],
  3405. [
  3406. 7,
  3407. twoDimVertL3
  3408. ],
  3409. [
  3410. 7,
  3411. twoDimVertR3
  3412. ],
  3413. [
  3414. 6,
  3415. twoDimVertL2
  3416. ],
  3417. [
  3418. 6,
  3419. twoDimVertL2
  3420. ],
  3421. [
  3422. 6,
  3423. twoDimVertR2
  3424. ],
  3425. [
  3426. 6,
  3427. twoDimVertR2
  3428. ],
  3429. [
  3430. 4,
  3431. twoDimPass
  3432. ],
  3433. [
  3434. 4,
  3435. twoDimPass
  3436. ],
  3437. [
  3438. 4,
  3439. twoDimPass
  3440. ],
  3441. [
  3442. 4,
  3443. twoDimPass
  3444. ],
  3445. [
  3446. 4,
  3447. twoDimPass
  3448. ],
  3449. [
  3450. 4,
  3451. twoDimPass
  3452. ],
  3453. [
  3454. 4,
  3455. twoDimPass
  3456. ],
  3457. [
  3458. 4,
  3459. twoDimPass
  3460. ],
  3461. [
  3462. 3,
  3463. twoDimHoriz
  3464. ],
  3465. [
  3466. 3,
  3467. twoDimHoriz
  3468. ],
  3469. [
  3470. 3,
  3471. twoDimHoriz
  3472. ],
  3473. [
  3474. 3,
  3475. twoDimHoriz
  3476. ],
  3477. [
  3478. 3,
  3479. twoDimHoriz
  3480. ],
  3481. [
  3482. 3,
  3483. twoDimHoriz
  3484. ],
  3485. [
  3486. 3,
  3487. twoDimHoriz
  3488. ],
  3489. [
  3490. 3,
  3491. twoDimHoriz
  3492. ],
  3493. [
  3494. 3,
  3495. twoDimHoriz
  3496. ],
  3497. [
  3498. 3,
  3499. twoDimHoriz
  3500. ],
  3501. [
  3502. 3,
  3503. twoDimHoriz
  3504. ],
  3505. [
  3506. 3,
  3507. twoDimHoriz
  3508. ],
  3509. [
  3510. 3,
  3511. twoDimHoriz
  3512. ],
  3513. [
  3514. 3,
  3515. twoDimHoriz
  3516. ],
  3517. [
  3518. 3,
  3519. twoDimHoriz
  3520. ],
  3521. [
  3522. 3,
  3523. twoDimHoriz
  3524. ],
  3525. [
  3526. 3,
  3527. twoDimVertL1
  3528. ],
  3529. [
  3530. 3,
  3531. twoDimVertL1
  3532. ],
  3533. [
  3534. 3,
  3535. twoDimVertL1
  3536. ],
  3537. [
  3538. 3,
  3539. twoDimVertL1
  3540. ],
  3541. [
  3542. 3,
  3543. twoDimVertL1
  3544. ],
  3545. [
  3546. 3,
  3547. twoDimVertL1
  3548. ],
  3549. [
  3550. 3,
  3551. twoDimVertL1
  3552. ],
  3553. [
  3554. 3,
  3555. twoDimVertL1
  3556. ],
  3557. [
  3558. 3,
  3559. twoDimVertL1
  3560. ],
  3561. [
  3562. 3,
  3563. twoDimVertL1
  3564. ],
  3565. [
  3566. 3,
  3567. twoDimVertL1
  3568. ],
  3569. [
  3570. 3,
  3571. twoDimVertL1
  3572. ],
  3573. [
  3574. 3,
  3575. twoDimVertL1
  3576. ],
  3577. [
  3578. 3,
  3579. twoDimVertL1
  3580. ],
  3581. [
  3582. 3,
  3583. twoDimVertL1
  3584. ],
  3585. [
  3586. 3,
  3587. twoDimVertL1
  3588. ],
  3589. [
  3590. 3,
  3591. twoDimVertR1
  3592. ],
  3593. [
  3594. 3,
  3595. twoDimVertR1
  3596. ],
  3597. [
  3598. 3,
  3599. twoDimVertR1
  3600. ],
  3601. [
  3602. 3,
  3603. twoDimVertR1
  3604. ],
  3605. [
  3606. 3,
  3607. twoDimVertR1
  3608. ],
  3609. [
  3610. 3,
  3611. twoDimVertR1
  3612. ],
  3613. [
  3614. 3,
  3615. twoDimVertR1
  3616. ],
  3617. [
  3618. 3,
  3619. twoDimVertR1
  3620. ],
  3621. [
  3622. 3,
  3623. twoDimVertR1
  3624. ],
  3625. [
  3626. 3,
  3627. twoDimVertR1
  3628. ],
  3629. [
  3630. 3,
  3631. twoDimVertR1
  3632. ],
  3633. [
  3634. 3,
  3635. twoDimVertR1
  3636. ],
  3637. [
  3638. 3,
  3639. twoDimVertR1
  3640. ],
  3641. [
  3642. 3,
  3643. twoDimVertR1
  3644. ],
  3645. [
  3646. 3,
  3647. twoDimVertR1
  3648. ],
  3649. [
  3650. 3,
  3651. twoDimVertR1
  3652. ],
  3653. [
  3654. 1,
  3655. twoDimVert0
  3656. ],
  3657. [
  3658. 1,
  3659. twoDimVert0
  3660. ],
  3661. [
  3662. 1,
  3663. twoDimVert0
  3664. ],
  3665. [
  3666. 1,
  3667. twoDimVert0
  3668. ],
  3669. [
  3670. 1,
  3671. twoDimVert0
  3672. ],
  3673. [
  3674. 1,
  3675. twoDimVert0
  3676. ],
  3677. [
  3678. 1,
  3679. twoDimVert0
  3680. ],
  3681. [
  3682. 1,
  3683. twoDimVert0
  3684. ],
  3685. [
  3686. 1,
  3687. twoDimVert0
  3688. ],
  3689. [
  3690. 1,
  3691. twoDimVert0
  3692. ],
  3693. [
  3694. 1,
  3695. twoDimVert0
  3696. ],
  3697. [
  3698. 1,
  3699. twoDimVert0
  3700. ],
  3701. [
  3702. 1,
  3703. twoDimVert0
  3704. ],
  3705. [
  3706. 1,
  3707. twoDimVert0
  3708. ],
  3709. [
  3710. 1,
  3711. twoDimVert0
  3712. ],
  3713. [
  3714. 1,
  3715. twoDimVert0
  3716. ],
  3717. [
  3718. 1,
  3719. twoDimVert0
  3720. ],
  3721. [
  3722. 1,
  3723. twoDimVert0
  3724. ],
  3725. [
  3726. 1,
  3727. twoDimVert0
  3728. ],
  3729. [
  3730. 1,
  3731. twoDimVert0
  3732. ],
  3733. [
  3734. 1,
  3735. twoDimVert0
  3736. ],
  3737. [
  3738. 1,
  3739. twoDimVert0
  3740. ],
  3741. [
  3742. 1,
  3743. twoDimVert0
  3744. ],
  3745. [
  3746. 1,
  3747. twoDimVert0
  3748. ],
  3749. [
  3750. 1,
  3751. twoDimVert0
  3752. ],
  3753. [
  3754. 1,
  3755. twoDimVert0
  3756. ],
  3757. [
  3758. 1,
  3759. twoDimVert0
  3760. ],
  3761. [
  3762. 1,
  3763. twoDimVert0
  3764. ],
  3765. [
  3766. 1,
  3767. twoDimVert0
  3768. ],
  3769. [
  3770. 1,
  3771. twoDimVert0
  3772. ],
  3773. [
  3774. 1,
  3775. twoDimVert0
  3776. ],
  3777. [
  3778. 1,
  3779. twoDimVert0
  3780. ],
  3781. [
  3782. 1,
  3783. twoDimVert0
  3784. ],
  3785. [
  3786. 1,
  3787. twoDimVert0
  3788. ],
  3789. [
  3790. 1,
  3791. twoDimVert0
  3792. ],
  3793. [
  3794. 1,
  3795. twoDimVert0
  3796. ],
  3797. [
  3798. 1,
  3799. twoDimVert0
  3800. ],
  3801. [
  3802. 1,
  3803. twoDimVert0
  3804. ],
  3805. [
  3806. 1,
  3807. twoDimVert0
  3808. ],
  3809. [
  3810. 1,
  3811. twoDimVert0
  3812. ],
  3813. [
  3814. 1,
  3815. twoDimVert0
  3816. ],
  3817. [
  3818. 1,
  3819. twoDimVert0
  3820. ],
  3821. [
  3822. 1,
  3823. twoDimVert0
  3824. ],
  3825. [
  3826. 1,
  3827. twoDimVert0
  3828. ],
  3829. [
  3830. 1,
  3831. twoDimVert0
  3832. ],
  3833. [
  3834. 1,
  3835. twoDimVert0
  3836. ],
  3837. [
  3838. 1,
  3839. twoDimVert0
  3840. ],
  3841. [
  3842. 1,
  3843. twoDimVert0
  3844. ],
  3845. [
  3846. 1,
  3847. twoDimVert0
  3848. ],
  3849. [
  3850. 1,
  3851. twoDimVert0
  3852. ],
  3853. [
  3854. 1,
  3855. twoDimVert0
  3856. ],
  3857. [
  3858. 1,
  3859. twoDimVert0
  3860. ],
  3861. [
  3862. 1,
  3863. twoDimVert0
  3864. ],
  3865. [
  3866. 1,
  3867. twoDimVert0
  3868. ],
  3869. [
  3870. 1,
  3871. twoDimVert0
  3872. ],
  3873. [
  3874. 1,
  3875. twoDimVert0
  3876. ],
  3877. [
  3878. 1,
  3879. twoDimVert0
  3880. ],
  3881. [
  3882. 1,
  3883. twoDimVert0
  3884. ],
  3885. [
  3886. 1,
  3887. twoDimVert0
  3888. ],
  3889. [
  3890. 1,
  3891. twoDimVert0
  3892. ],
  3893. [
  3894. 1,
  3895. twoDimVert0
  3896. ],
  3897. [
  3898. 1,
  3899. twoDimVert0
  3900. ],
  3901. [
  3902. 1,
  3903. twoDimVert0
  3904. ],
  3905. [
  3906. 1,
  3907. twoDimVert0
  3908. ]
  3909. ];
  3910. var whiteTable1 = [
  3911. [
  3912. -1,
  3913. -1
  3914. ],
  3915. [
  3916. 12,
  3917. ccittEOL
  3918. ],
  3919. [
  3920. -1,
  3921. -1
  3922. ],
  3923. [
  3924. -1,
  3925. -1
  3926. ],
  3927. [
  3928. -1,
  3929. -1
  3930. ],
  3931. [
  3932. -1,
  3933. -1
  3934. ],
  3935. [
  3936. -1,
  3937. -1
  3938. ],
  3939. [
  3940. -1,
  3941. -1
  3942. ],
  3943. [
  3944. -1,
  3945. -1
  3946. ],
  3947. [
  3948. -1,
  3949. -1
  3950. ],
  3951. [
  3952. -1,
  3953. -1
  3954. ],
  3955. [
  3956. -1,
  3957. -1
  3958. ],
  3959. [
  3960. -1,
  3961. -1
  3962. ],
  3963. [
  3964. -1,
  3965. -1
  3966. ],
  3967. [
  3968. -1,
  3969. -1
  3970. ],
  3971. [
  3972. -1,
  3973. -1
  3974. ],
  3975. [
  3976. 11,
  3977. 1792
  3978. ],
  3979. [
  3980. 11,
  3981. 1792
  3982. ],
  3983. [
  3984. 12,
  3985. 1984
  3986. ],
  3987. [
  3988. 12,
  3989. 2048
  3990. ],
  3991. [
  3992. 12,
  3993. 2112
  3994. ],
  3995. [
  3996. 12,
  3997. 2176
  3998. ],
  3999. [
  4000. 12,
  4001. 2240
  4002. ],
  4003. [
  4004. 12,
  4005. 2304
  4006. ],
  4007. [
  4008. 11,
  4009. 1856
  4010. ],
  4011. [
  4012. 11,
  4013. 1856
  4014. ],
  4015. [
  4016. 11,
  4017. 1920
  4018. ],
  4019. [
  4020. 11,
  4021. 1920
  4022. ],
  4023. [
  4024. 12,
  4025. 2368
  4026. ],
  4027. [
  4028. 12,
  4029. 2432
  4030. ],
  4031. [
  4032. 12,
  4033. 2496
  4034. ],
  4035. [
  4036. 12,
  4037. 2560
  4038. ]
  4039. ];
  4040. var whiteTable2 = [
  4041. [
  4042. -1,
  4043. -1
  4044. ],
  4045. [
  4046. -1,
  4047. -1
  4048. ],
  4049. [
  4050. -1,
  4051. -1
  4052. ],
  4053. [
  4054. -1,
  4055. -1
  4056. ],
  4057. [
  4058. 8,
  4059. 29
  4060. ],
  4061. [
  4062. 8,
  4063. 29
  4064. ],
  4065. [
  4066. 8,
  4067. 30
  4068. ],
  4069. [
  4070. 8,
  4071. 30
  4072. ],
  4073. [
  4074. 8,
  4075. 45
  4076. ],
  4077. [
  4078. 8,
  4079. 45
  4080. ],
  4081. [
  4082. 8,
  4083. 46
  4084. ],
  4085. [
  4086. 8,
  4087. 46
  4088. ],
  4089. [
  4090. 7,
  4091. 22
  4092. ],
  4093. [
  4094. 7,
  4095. 22
  4096. ],
  4097. [
  4098. 7,
  4099. 22
  4100. ],
  4101. [
  4102. 7,
  4103. 22
  4104. ],
  4105. [
  4106. 7,
  4107. 23
  4108. ],
  4109. [
  4110. 7,
  4111. 23
  4112. ],
  4113. [
  4114. 7,
  4115. 23
  4116. ],
  4117. [
  4118. 7,
  4119. 23
  4120. ],
  4121. [
  4122. 8,
  4123. 47
  4124. ],
  4125. [
  4126. 8,
  4127. 47
  4128. ],
  4129. [
  4130. 8,
  4131. 48
  4132. ],
  4133. [
  4134. 8,
  4135. 48
  4136. ],
  4137. [
  4138. 6,
  4139. 13
  4140. ],
  4141. [
  4142. 6,
  4143. 13
  4144. ],
  4145. [
  4146. 6,
  4147. 13
  4148. ],
  4149. [
  4150. 6,
  4151. 13
  4152. ],
  4153. [
  4154. 6,
  4155. 13
  4156. ],
  4157. [
  4158. 6,
  4159. 13
  4160. ],
  4161. [
  4162. 6,
  4163. 13
  4164. ],
  4165. [
  4166. 6,
  4167. 13
  4168. ],
  4169. [
  4170. 7,
  4171. 20
  4172. ],
  4173. [
  4174. 7,
  4175. 20
  4176. ],
  4177. [
  4178. 7,
  4179. 20
  4180. ],
  4181. [
  4182. 7,
  4183. 20
  4184. ],
  4185. [
  4186. 8,
  4187. 33
  4188. ],
  4189. [
  4190. 8,
  4191. 33
  4192. ],
  4193. [
  4194. 8,
  4195. 34
  4196. ],
  4197. [
  4198. 8,
  4199. 34
  4200. ],
  4201. [
  4202. 8,
  4203. 35
  4204. ],
  4205. [
  4206. 8,
  4207. 35
  4208. ],
  4209. [
  4210. 8,
  4211. 36
  4212. ],
  4213. [
  4214. 8,
  4215. 36
  4216. ],
  4217. [
  4218. 8,
  4219. 37
  4220. ],
  4221. [
  4222. 8,
  4223. 37
  4224. ],
  4225. [
  4226. 8,
  4227. 38
  4228. ],
  4229. [
  4230. 8,
  4231. 38
  4232. ],
  4233. [
  4234. 7,
  4235. 19
  4236. ],
  4237. [
  4238. 7,
  4239. 19
  4240. ],
  4241. [
  4242. 7,
  4243. 19
  4244. ],
  4245. [
  4246. 7,
  4247. 19
  4248. ],
  4249. [
  4250. 8,
  4251. 31
  4252. ],
  4253. [
  4254. 8,
  4255. 31
  4256. ],
  4257. [
  4258. 8,
  4259. 32
  4260. ],
  4261. [
  4262. 8,
  4263. 32
  4264. ],
  4265. [
  4266. 6,
  4267. 1
  4268. ],
  4269. [
  4270. 6,
  4271. 1
  4272. ],
  4273. [
  4274. 6,
  4275. 1
  4276. ],
  4277. [
  4278. 6,
  4279. 1
  4280. ],
  4281. [
  4282. 6,
  4283. 1
  4284. ],
  4285. [
  4286. 6,
  4287. 1
  4288. ],
  4289. [
  4290. 6,
  4291. 1
  4292. ],
  4293. [
  4294. 6,
  4295. 1
  4296. ],
  4297. [
  4298. 6,
  4299. 12
  4300. ],
  4301. [
  4302. 6,
  4303. 12
  4304. ],
  4305. [
  4306. 6,
  4307. 12
  4308. ],
  4309. [
  4310. 6,
  4311. 12
  4312. ],
  4313. [
  4314. 6,
  4315. 12
  4316. ],
  4317. [
  4318. 6,
  4319. 12
  4320. ],
  4321. [
  4322. 6,
  4323. 12
  4324. ],
  4325. [
  4326. 6,
  4327. 12
  4328. ],
  4329. [
  4330. 8,
  4331. 53
  4332. ],
  4333. [
  4334. 8,
  4335. 53
  4336. ],
  4337. [
  4338. 8,
  4339. 54
  4340. ],
  4341. [
  4342. 8,
  4343. 54
  4344. ],
  4345. [
  4346. 7,
  4347. 26
  4348. ],
  4349. [
  4350. 7,
  4351. 26
  4352. ],
  4353. [
  4354. 7,
  4355. 26
  4356. ],
  4357. [
  4358. 7,
  4359. 26
  4360. ],
  4361. [
  4362. 8,
  4363. 39
  4364. ],
  4365. [
  4366. 8,
  4367. 39
  4368. ],
  4369. [
  4370. 8,
  4371. 40
  4372. ],
  4373. [
  4374. 8,
  4375. 40
  4376. ],
  4377. [
  4378. 8,
  4379. 41
  4380. ],
  4381. [
  4382. 8,
  4383. 41
  4384. ],
  4385. [
  4386. 8,
  4387. 42
  4388. ],
  4389. [
  4390. 8,
  4391. 42
  4392. ],
  4393. [
  4394. 8,
  4395. 43
  4396. ],
  4397. [
  4398. 8,
  4399. 43
  4400. ],
  4401. [
  4402. 8,
  4403. 44
  4404. ],
  4405. [
  4406. 8,
  4407. 44
  4408. ],
  4409. [
  4410. 7,
  4411. 21
  4412. ],
  4413. [
  4414. 7,
  4415. 21
  4416. ],
  4417. [
  4418. 7,
  4419. 21
  4420. ],
  4421. [
  4422. 7,
  4423. 21
  4424. ],
  4425. [
  4426. 7,
  4427. 28
  4428. ],
  4429. [
  4430. 7,
  4431. 28
  4432. ],
  4433. [
  4434. 7,
  4435. 28
  4436. ],
  4437. [
  4438. 7,
  4439. 28
  4440. ],
  4441. [
  4442. 8,
  4443. 61
  4444. ],
  4445. [
  4446. 8,
  4447. 61
  4448. ],
  4449. [
  4450. 8,
  4451. 62
  4452. ],
  4453. [
  4454. 8,
  4455. 62
  4456. ],
  4457. [
  4458. 8,
  4459. 63
  4460. ],
  4461. [
  4462. 8,
  4463. 63
  4464. ],
  4465. [
  4466. 8,
  4467. 0
  4468. ],
  4469. [
  4470. 8,
  4471. 0
  4472. ],
  4473. [
  4474. 8,
  4475. 320
  4476. ],
  4477. [
  4478. 8,
  4479. 320
  4480. ],
  4481. [
  4482. 8,
  4483. 384
  4484. ],
  4485. [
  4486. 8,
  4487. 384
  4488. ],
  4489. [
  4490. 5,
  4491. 10
  4492. ],
  4493. [
  4494. 5,
  4495. 10
  4496. ],
  4497. [
  4498. 5,
  4499. 10
  4500. ],
  4501. [
  4502. 5,
  4503. 10
  4504. ],
  4505. [
  4506. 5,
  4507. 10
  4508. ],
  4509. [
  4510. 5,
  4511. 10
  4512. ],
  4513. [
  4514. 5,
  4515. 10
  4516. ],
  4517. [
  4518. 5,
  4519. 10
  4520. ],
  4521. [
  4522. 5,
  4523. 10
  4524. ],
  4525. [
  4526. 5,
  4527. 10
  4528. ],
  4529. [
  4530. 5,
  4531. 10
  4532. ],
  4533. [
  4534. 5,
  4535. 10
  4536. ],
  4537. [
  4538. 5,
  4539. 10
  4540. ],
  4541. [
  4542. 5,
  4543. 10
  4544. ],
  4545. [
  4546. 5,
  4547. 10
  4548. ],
  4549. [
  4550. 5,
  4551. 10
  4552. ],
  4553. [
  4554. 5,
  4555. 11
  4556. ],
  4557. [
  4558. 5,
  4559. 11
  4560. ],
  4561. [
  4562. 5,
  4563. 11
  4564. ],
  4565. [
  4566. 5,
  4567. 11
  4568. ],
  4569. [
  4570. 5,
  4571. 11
  4572. ],
  4573. [
  4574. 5,
  4575. 11
  4576. ],
  4577. [
  4578. 5,
  4579. 11
  4580. ],
  4581. [
  4582. 5,
  4583. 11
  4584. ],
  4585. [
  4586. 5,
  4587. 11
  4588. ],
  4589. [
  4590. 5,
  4591. 11
  4592. ],
  4593. [
  4594. 5,
  4595. 11
  4596. ],
  4597. [
  4598. 5,
  4599. 11
  4600. ],
  4601. [
  4602. 5,
  4603. 11
  4604. ],
  4605. [
  4606. 5,
  4607. 11
  4608. ],
  4609. [
  4610. 5,
  4611. 11
  4612. ],
  4613. [
  4614. 5,
  4615. 11
  4616. ],
  4617. [
  4618. 7,
  4619. 27
  4620. ],
  4621. [
  4622. 7,
  4623. 27
  4624. ],
  4625. [
  4626. 7,
  4627. 27
  4628. ],
  4629. [
  4630. 7,
  4631. 27
  4632. ],
  4633. [
  4634. 8,
  4635. 59
  4636. ],
  4637. [
  4638. 8,
  4639. 59
  4640. ],
  4641. [
  4642. 8,
  4643. 60
  4644. ],
  4645. [
  4646. 8,
  4647. 60
  4648. ],
  4649. [
  4650. 9,
  4651. 1472
  4652. ],
  4653. [
  4654. 9,
  4655. 1536
  4656. ],
  4657. [
  4658. 9,
  4659. 1600
  4660. ],
  4661. [
  4662. 9,
  4663. 1728
  4664. ],
  4665. [
  4666. 7,
  4667. 18
  4668. ],
  4669. [
  4670. 7,
  4671. 18
  4672. ],
  4673. [
  4674. 7,
  4675. 18
  4676. ],
  4677. [
  4678. 7,
  4679. 18
  4680. ],
  4681. [
  4682. 7,
  4683. 24
  4684. ],
  4685. [
  4686. 7,
  4687. 24
  4688. ],
  4689. [
  4690. 7,
  4691. 24
  4692. ],
  4693. [
  4694. 7,
  4695. 24
  4696. ],
  4697. [
  4698. 8,
  4699. 49
  4700. ],
  4701. [
  4702. 8,
  4703. 49
  4704. ],
  4705. [
  4706. 8,
  4707. 50
  4708. ],
  4709. [
  4710. 8,
  4711. 50
  4712. ],
  4713. [
  4714. 8,
  4715. 51
  4716. ],
  4717. [
  4718. 8,
  4719. 51
  4720. ],
  4721. [
  4722. 8,
  4723. 52
  4724. ],
  4725. [
  4726. 8,
  4727. 52
  4728. ],
  4729. [
  4730. 7,
  4731. 25
  4732. ],
  4733. [
  4734. 7,
  4735. 25
  4736. ],
  4737. [
  4738. 7,
  4739. 25
  4740. ],
  4741. [
  4742. 7,
  4743. 25
  4744. ],
  4745. [
  4746. 8,
  4747. 55
  4748. ],
  4749. [
  4750. 8,
  4751. 55
  4752. ],
  4753. [
  4754. 8,
  4755. 56
  4756. ],
  4757. [
  4758. 8,
  4759. 56
  4760. ],
  4761. [
  4762. 8,
  4763. 57
  4764. ],
  4765. [
  4766. 8,
  4767. 57
  4768. ],
  4769. [
  4770. 8,
  4771. 58
  4772. ],
  4773. [
  4774. 8,
  4775. 58
  4776. ],
  4777. [
  4778. 6,
  4779. 192
  4780. ],
  4781. [
  4782. 6,
  4783. 192
  4784. ],
  4785. [
  4786. 6,
  4787. 192
  4788. ],
  4789. [
  4790. 6,
  4791. 192
  4792. ],
  4793. [
  4794. 6,
  4795. 192
  4796. ],
  4797. [
  4798. 6,
  4799. 192
  4800. ],
  4801. [
  4802. 6,
  4803. 192
  4804. ],
  4805. [
  4806. 6,
  4807. 192
  4808. ],
  4809. [
  4810. 6,
  4811. 1664
  4812. ],
  4813. [
  4814. 6,
  4815. 1664
  4816. ],
  4817. [
  4818. 6,
  4819. 1664
  4820. ],
  4821. [
  4822. 6,
  4823. 1664
  4824. ],
  4825. [
  4826. 6,
  4827. 1664
  4828. ],
  4829. [
  4830. 6,
  4831. 1664
  4832. ],
  4833. [
  4834. 6,
  4835. 1664
  4836. ],
  4837. [
  4838. 6,
  4839. 1664
  4840. ],
  4841. [
  4842. 8,
  4843. 448
  4844. ],
  4845. [
  4846. 8,
  4847. 448
  4848. ],
  4849. [
  4850. 8,
  4851. 512
  4852. ],
  4853. [
  4854. 8,
  4855. 512
  4856. ],
  4857. [
  4858. 9,
  4859. 704
  4860. ],
  4861. [
  4862. 9,
  4863. 768
  4864. ],
  4865. [
  4866. 8,
  4867. 640
  4868. ],
  4869. [
  4870. 8,
  4871. 640
  4872. ],
  4873. [
  4874. 8,
  4875. 576
  4876. ],
  4877. [
  4878. 8,
  4879. 576
  4880. ],
  4881. [
  4882. 9,
  4883. 832
  4884. ],
  4885. [
  4886. 9,
  4887. 896
  4888. ],
  4889. [
  4890. 9,
  4891. 960
  4892. ],
  4893. [
  4894. 9,
  4895. 1024
  4896. ],
  4897. [
  4898. 9,
  4899. 1088
  4900. ],
  4901. [
  4902. 9,
  4903. 1152
  4904. ],
  4905. [
  4906. 9,
  4907. 1216
  4908. ],
  4909. [
  4910. 9,
  4911. 1280
  4912. ],
  4913. [
  4914. 9,
  4915. 1344
  4916. ],
  4917. [
  4918. 9,
  4919. 1408
  4920. ],
  4921. [
  4922. 7,
  4923. 256
  4924. ],
  4925. [
  4926. 7,
  4927. 256
  4928. ],
  4929. [
  4930. 7,
  4931. 256
  4932. ],
  4933. [
  4934. 7,
  4935. 256
  4936. ],
  4937. [
  4938. 4,
  4939. 2
  4940. ],
  4941. [
  4942. 4,
  4943. 2
  4944. ],
  4945. [
  4946. 4,
  4947. 2
  4948. ],
  4949. [
  4950. 4,
  4951. 2
  4952. ],
  4953. [
  4954. 4,
  4955. 2
  4956. ],
  4957. [
  4958. 4,
  4959. 2
  4960. ],
  4961. [
  4962. 4,
  4963. 2
  4964. ],
  4965. [
  4966. 4,
  4967. 2
  4968. ],
  4969. [
  4970. 4,
  4971. 2
  4972. ],
  4973. [
  4974. 4,
  4975. 2
  4976. ],
  4977. [
  4978. 4,
  4979. 2
  4980. ],
  4981. [
  4982. 4,
  4983. 2
  4984. ],
  4985. [
  4986. 4,
  4987. 2
  4988. ],
  4989. [
  4990. 4,
  4991. 2
  4992. ],
  4993. [
  4994. 4,
  4995. 2
  4996. ],
  4997. [
  4998. 4,
  4999. 2
  5000. ],
  5001. [
  5002. 4,
  5003. 2
  5004. ],
  5005. [
  5006. 4,
  5007. 2
  5008. ],
  5009. [
  5010. 4,
  5011. 2
  5012. ],
  5013. [
  5014. 4,
  5015. 2
  5016. ],
  5017. [
  5018. 4,
  5019. 2
  5020. ],
  5021. [
  5022. 4,
  5023. 2
  5024. ],
  5025. [
  5026. 4,
  5027. 2
  5028. ],
  5029. [
  5030. 4,
  5031. 2
  5032. ],
  5033. [
  5034. 4,
  5035. 2
  5036. ],
  5037. [
  5038. 4,
  5039. 2
  5040. ],
  5041. [
  5042. 4,
  5043. 2
  5044. ],
  5045. [
  5046. 4,
  5047. 2
  5048. ],
  5049. [
  5050. 4,
  5051. 2
  5052. ],
  5053. [
  5054. 4,
  5055. 2
  5056. ],
  5057. [
  5058. 4,
  5059. 2
  5060. ],
  5061. [
  5062. 4,
  5063. 2
  5064. ],
  5065. [
  5066. 4,
  5067. 3
  5068. ],
  5069. [
  5070. 4,
  5071. 3
  5072. ],
  5073. [
  5074. 4,
  5075. 3
  5076. ],
  5077. [
  5078. 4,
  5079. 3
  5080. ],
  5081. [
  5082. 4,
  5083. 3
  5084. ],
  5085. [
  5086. 4,
  5087. 3
  5088. ],
  5089. [
  5090. 4,
  5091. 3
  5092. ],
  5093. [
  5094. 4,
  5095. 3
  5096. ],
  5097. [
  5098. 4,
  5099. 3
  5100. ],
  5101. [
  5102. 4,
  5103. 3
  5104. ],
  5105. [
  5106. 4,
  5107. 3
  5108. ],
  5109. [
  5110. 4,
  5111. 3
  5112. ],
  5113. [
  5114. 4,
  5115. 3
  5116. ],
  5117. [
  5118. 4,
  5119. 3
  5120. ],
  5121. [
  5122. 4,
  5123. 3
  5124. ],
  5125. [
  5126. 4,
  5127. 3
  5128. ],
  5129. [
  5130. 4,
  5131. 3
  5132. ],
  5133. [
  5134. 4,
  5135. 3
  5136. ],
  5137. [
  5138. 4,
  5139. 3
  5140. ],
  5141. [
  5142. 4,
  5143. 3
  5144. ],
  5145. [
  5146. 4,
  5147. 3
  5148. ],
  5149. [
  5150. 4,
  5151. 3
  5152. ],
  5153. [
  5154. 4,
  5155. 3
  5156. ],
  5157. [
  5158. 4,
  5159. 3
  5160. ],
  5161. [
  5162. 4,
  5163. 3
  5164. ],
  5165. [
  5166. 4,
  5167. 3
  5168. ],
  5169. [
  5170. 4,
  5171. 3
  5172. ],
  5173. [
  5174. 4,
  5175. 3
  5176. ],
  5177. [
  5178. 4,
  5179. 3
  5180. ],
  5181. [
  5182. 4,
  5183. 3
  5184. ],
  5185. [
  5186. 4,
  5187. 3
  5188. ],
  5189. [
  5190. 4,
  5191. 3
  5192. ],
  5193. [
  5194. 5,
  5195. 128
  5196. ],
  5197. [
  5198. 5,
  5199. 128
  5200. ],
  5201. [
  5202. 5,
  5203. 128
  5204. ],
  5205. [
  5206. 5,
  5207. 128
  5208. ],
  5209. [
  5210. 5,
  5211. 128
  5212. ],
  5213. [
  5214. 5,
  5215. 128
  5216. ],
  5217. [
  5218. 5,
  5219. 128
  5220. ],
  5221. [
  5222. 5,
  5223. 128
  5224. ],
  5225. [
  5226. 5,
  5227. 128
  5228. ],
  5229. [
  5230. 5,
  5231. 128
  5232. ],
  5233. [
  5234. 5,
  5235. 128
  5236. ],
  5237. [
  5238. 5,
  5239. 128
  5240. ],
  5241. [
  5242. 5,
  5243. 128
  5244. ],
  5245. [
  5246. 5,
  5247. 128
  5248. ],
  5249. [
  5250. 5,
  5251. 128
  5252. ],
  5253. [
  5254. 5,
  5255. 128
  5256. ],
  5257. [
  5258. 5,
  5259. 8
  5260. ],
  5261. [
  5262. 5,
  5263. 8
  5264. ],
  5265. [
  5266. 5,
  5267. 8
  5268. ],
  5269. [
  5270. 5,
  5271. 8
  5272. ],
  5273. [
  5274. 5,
  5275. 8
  5276. ],
  5277. [
  5278. 5,
  5279. 8
  5280. ],
  5281. [
  5282. 5,
  5283. 8
  5284. ],
  5285. [
  5286. 5,
  5287. 8
  5288. ],
  5289. [
  5290. 5,
  5291. 8
  5292. ],
  5293. [
  5294. 5,
  5295. 8
  5296. ],
  5297. [
  5298. 5,
  5299. 8
  5300. ],
  5301. [
  5302. 5,
  5303. 8
  5304. ],
  5305. [
  5306. 5,
  5307. 8
  5308. ],
  5309. [
  5310. 5,
  5311. 8
  5312. ],
  5313. [
  5314. 5,
  5315. 8
  5316. ],
  5317. [
  5318. 5,
  5319. 8
  5320. ],
  5321. [
  5322. 5,
  5323. 9
  5324. ],
  5325. [
  5326. 5,
  5327. 9
  5328. ],
  5329. [
  5330. 5,
  5331. 9
  5332. ],
  5333. [
  5334. 5,
  5335. 9
  5336. ],
  5337. [
  5338. 5,
  5339. 9
  5340. ],
  5341. [
  5342. 5,
  5343. 9
  5344. ],
  5345. [
  5346. 5,
  5347. 9
  5348. ],
  5349. [
  5350. 5,
  5351. 9
  5352. ],
  5353. [
  5354. 5,
  5355. 9
  5356. ],
  5357. [
  5358. 5,
  5359. 9
  5360. ],
  5361. [
  5362. 5,
  5363. 9
  5364. ],
  5365. [
  5366. 5,
  5367. 9
  5368. ],
  5369. [
  5370. 5,
  5371. 9
  5372. ],
  5373. [
  5374. 5,
  5375. 9
  5376. ],
  5377. [
  5378. 5,
  5379. 9
  5380. ],
  5381. [
  5382. 5,
  5383. 9
  5384. ],
  5385. [
  5386. 6,
  5387. 16
  5388. ],
  5389. [
  5390. 6,
  5391. 16
  5392. ],
  5393. [
  5394. 6,
  5395. 16
  5396. ],
  5397. [
  5398. 6,
  5399. 16
  5400. ],
  5401. [
  5402. 6,
  5403. 16
  5404. ],
  5405. [
  5406. 6,
  5407. 16
  5408. ],
  5409. [
  5410. 6,
  5411. 16
  5412. ],
  5413. [
  5414. 6,
  5415. 16
  5416. ],
  5417. [
  5418. 6,
  5419. 17
  5420. ],
  5421. [
  5422. 6,
  5423. 17
  5424. ],
  5425. [
  5426. 6,
  5427. 17
  5428. ],
  5429. [
  5430. 6,
  5431. 17
  5432. ],
  5433. [
  5434. 6,
  5435. 17
  5436. ],
  5437. [
  5438. 6,
  5439. 17
  5440. ],
  5441. [
  5442. 6,
  5443. 17
  5444. ],
  5445. [
  5446. 6,
  5447. 17
  5448. ],
  5449. [
  5450. 4,
  5451. 4
  5452. ],
  5453. [
  5454. 4,
  5455. 4
  5456. ],
  5457. [
  5458. 4,
  5459. 4
  5460. ],
  5461. [
  5462. 4,
  5463. 4
  5464. ],
  5465. [
  5466. 4,
  5467. 4
  5468. ],
  5469. [
  5470. 4,
  5471. 4
  5472. ],
  5473. [
  5474. 4,
  5475. 4
  5476. ],
  5477. [
  5478. 4,
  5479. 4
  5480. ],
  5481. [
  5482. 4,
  5483. 4
  5484. ],
  5485. [
  5486. 4,
  5487. 4
  5488. ],
  5489. [
  5490. 4,
  5491. 4
  5492. ],
  5493. [
  5494. 4,
  5495. 4
  5496. ],
  5497. [
  5498. 4,
  5499. 4
  5500. ],
  5501. [
  5502. 4,
  5503. 4
  5504. ],
  5505. [
  5506. 4,
  5507. 4
  5508. ],
  5509. [
  5510. 4,
  5511. 4
  5512. ],
  5513. [
  5514. 4,
  5515. 4
  5516. ],
  5517. [
  5518. 4,
  5519. 4
  5520. ],
  5521. [
  5522. 4,
  5523. 4
  5524. ],
  5525. [
  5526. 4,
  5527. 4
  5528. ],
  5529. [
  5530. 4,
  5531. 4
  5532. ],
  5533. [
  5534. 4,
  5535. 4
  5536. ],
  5537. [
  5538. 4,
  5539. 4
  5540. ],
  5541. [
  5542. 4,
  5543. 4
  5544. ],
  5545. [
  5546. 4,
  5547. 4
  5548. ],
  5549. [
  5550. 4,
  5551. 4
  5552. ],
  5553. [
  5554. 4,
  5555. 4
  5556. ],
  5557. [
  5558. 4,
  5559. 4
  5560. ],
  5561. [
  5562. 4,
  5563. 4
  5564. ],
  5565. [
  5566. 4,
  5567. 4
  5568. ],
  5569. [
  5570. 4,
  5571. 4
  5572. ],
  5573. [
  5574. 4,
  5575. 4
  5576. ],
  5577. [
  5578. 4,
  5579. 5
  5580. ],
  5581. [
  5582. 4,
  5583. 5
  5584. ],
  5585. [
  5586. 4,
  5587. 5
  5588. ],
  5589. [
  5590. 4,
  5591. 5
  5592. ],
  5593. [
  5594. 4,
  5595. 5
  5596. ],
  5597. [
  5598. 4,
  5599. 5
  5600. ],
  5601. [
  5602. 4,
  5603. 5
  5604. ],
  5605. [
  5606. 4,
  5607. 5
  5608. ],
  5609. [
  5610. 4,
  5611. 5
  5612. ],
  5613. [
  5614. 4,
  5615. 5
  5616. ],
  5617. [
  5618. 4,
  5619. 5
  5620. ],
  5621. [
  5622. 4,
  5623. 5
  5624. ],
  5625. [
  5626. 4,
  5627. 5
  5628. ],
  5629. [
  5630. 4,
  5631. 5
  5632. ],
  5633. [
  5634. 4,
  5635. 5
  5636. ],
  5637. [
  5638. 4,
  5639. 5
  5640. ],
  5641. [
  5642. 4,
  5643. 5
  5644. ],
  5645. [
  5646. 4,
  5647. 5
  5648. ],
  5649. [
  5650. 4,
  5651. 5
  5652. ],
  5653. [
  5654. 4,
  5655. 5
  5656. ],
  5657. [
  5658. 4,
  5659. 5
  5660. ],
  5661. [
  5662. 4,
  5663. 5
  5664. ],
  5665. [
  5666. 4,
  5667. 5
  5668. ],
  5669. [
  5670. 4,
  5671. 5
  5672. ],
  5673. [
  5674. 4,
  5675. 5
  5676. ],
  5677. [
  5678. 4,
  5679. 5
  5680. ],
  5681. [
  5682. 4,
  5683. 5
  5684. ],
  5685. [
  5686. 4,
  5687. 5
  5688. ],
  5689. [
  5690. 4,
  5691. 5
  5692. ],
  5693. [
  5694. 4,
  5695. 5
  5696. ],
  5697. [
  5698. 4,
  5699. 5
  5700. ],
  5701. [
  5702. 4,
  5703. 5
  5704. ],
  5705. [
  5706. 6,
  5707. 14
  5708. ],
  5709. [
  5710. 6,
  5711. 14
  5712. ],
  5713. [
  5714. 6,
  5715. 14
  5716. ],
  5717. [
  5718. 6,
  5719. 14
  5720. ],
  5721. [
  5722. 6,
  5723. 14
  5724. ],
  5725. [
  5726. 6,
  5727. 14
  5728. ],
  5729. [
  5730. 6,
  5731. 14
  5732. ],
  5733. [
  5734. 6,
  5735. 14
  5736. ],
  5737. [
  5738. 6,
  5739. 15
  5740. ],
  5741. [
  5742. 6,
  5743. 15
  5744. ],
  5745. [
  5746. 6,
  5747. 15
  5748. ],
  5749. [
  5750. 6,
  5751. 15
  5752. ],
  5753. [
  5754. 6,
  5755. 15
  5756. ],
  5757. [
  5758. 6,
  5759. 15
  5760. ],
  5761. [
  5762. 6,
  5763. 15
  5764. ],
  5765. [
  5766. 6,
  5767. 15
  5768. ],
  5769. [
  5770. 5,
  5771. 64
  5772. ],
  5773. [
  5774. 5,
  5775. 64
  5776. ],
  5777. [
  5778. 5,
  5779. 64
  5780. ],
  5781. [
  5782. 5,
  5783. 64
  5784. ],
  5785. [
  5786. 5,
  5787. 64
  5788. ],
  5789. [
  5790. 5,
  5791. 64
  5792. ],
  5793. [
  5794. 5,
  5795. 64
  5796. ],
  5797. [
  5798. 5,
  5799. 64
  5800. ],
  5801. [
  5802. 5,
  5803. 64
  5804. ],
  5805. [
  5806. 5,
  5807. 64
  5808. ],
  5809. [
  5810. 5,
  5811. 64
  5812. ],
  5813. [
  5814. 5,
  5815. 64
  5816. ],
  5817. [
  5818. 5,
  5819. 64
  5820. ],
  5821. [
  5822. 5,
  5823. 64
  5824. ],
  5825. [
  5826. 5,
  5827. 64
  5828. ],
  5829. [
  5830. 5,
  5831. 64
  5832. ],
  5833. [
  5834. 4,
  5835. 6
  5836. ],
  5837. [
  5838. 4,
  5839. 6
  5840. ],
  5841. [
  5842. 4,
  5843. 6
  5844. ],
  5845. [
  5846. 4,
  5847. 6
  5848. ],
  5849. [
  5850. 4,
  5851. 6
  5852. ],
  5853. [
  5854. 4,
  5855. 6
  5856. ],
  5857. [
  5858. 4,
  5859. 6
  5860. ],
  5861. [
  5862. 4,
  5863. 6
  5864. ],
  5865. [
  5866. 4,
  5867. 6
  5868. ],
  5869. [
  5870. 4,
  5871. 6
  5872. ],
  5873. [
  5874. 4,
  5875. 6
  5876. ],
  5877. [
  5878. 4,
  5879. 6
  5880. ],
  5881. [
  5882. 4,
  5883. 6
  5884. ],
  5885. [
  5886. 4,
  5887. 6
  5888. ],
  5889. [
  5890. 4,
  5891. 6
  5892. ],
  5893. [
  5894. 4,
  5895. 6
  5896. ],
  5897. [
  5898. 4,
  5899. 6
  5900. ],
  5901. [
  5902. 4,
  5903. 6
  5904. ],
  5905. [
  5906. 4,
  5907. 6
  5908. ],
  5909. [
  5910. 4,
  5911. 6
  5912. ],
  5913. [
  5914. 4,
  5915. 6
  5916. ],
  5917. [
  5918. 4,
  5919. 6
  5920. ],
  5921. [
  5922. 4,
  5923. 6
  5924. ],
  5925. [
  5926. 4,
  5927. 6
  5928. ],
  5929. [
  5930. 4,
  5931. 6
  5932. ],
  5933. [
  5934. 4,
  5935. 6
  5936. ],
  5937. [
  5938. 4,
  5939. 6
  5940. ],
  5941. [
  5942. 4,
  5943. 6
  5944. ],
  5945. [
  5946. 4,
  5947. 6
  5948. ],
  5949. [
  5950. 4,
  5951. 6
  5952. ],
  5953. [
  5954. 4,
  5955. 6
  5956. ],
  5957. [
  5958. 4,
  5959. 6
  5960. ],
  5961. [
  5962. 4,
  5963. 7
  5964. ],
  5965. [
  5966. 4,
  5967. 7
  5968. ],
  5969. [
  5970. 4,
  5971. 7
  5972. ],
  5973. [
  5974. 4,
  5975. 7
  5976. ],
  5977. [
  5978. 4,
  5979. 7
  5980. ],
  5981. [
  5982. 4,
  5983. 7
  5984. ],
  5985. [
  5986. 4,
  5987. 7
  5988. ],
  5989. [
  5990. 4,
  5991. 7
  5992. ],
  5993. [
  5994. 4,
  5995. 7
  5996. ],
  5997. [
  5998. 4,
  5999. 7
  6000. ],
  6001. [
  6002. 4,
  6003. 7
  6004. ],
  6005. [
  6006. 4,
  6007. 7
  6008. ],
  6009. [
  6010. 4,
  6011. 7
  6012. ],
  6013. [
  6014. 4,
  6015. 7
  6016. ],
  6017. [
  6018. 4,
  6019. 7
  6020. ],
  6021. [
  6022. 4,
  6023. 7
  6024. ],
  6025. [
  6026. 4,
  6027. 7
  6028. ],
  6029. [
  6030. 4,
  6031. 7
  6032. ],
  6033. [
  6034. 4,
  6035. 7
  6036. ],
  6037. [
  6038. 4,
  6039. 7
  6040. ],
  6041. [
  6042. 4,
  6043. 7
  6044. ],
  6045. [
  6046. 4,
  6047. 7
  6048. ],
  6049. [
  6050. 4,
  6051. 7
  6052. ],
  6053. [
  6054. 4,
  6055. 7
  6056. ],
  6057. [
  6058. 4,
  6059. 7
  6060. ],
  6061. [
  6062. 4,
  6063. 7
  6064. ],
  6065. [
  6066. 4,
  6067. 7
  6068. ],
  6069. [
  6070. 4,
  6071. 7
  6072. ],
  6073. [
  6074. 4,
  6075. 7
  6076. ],
  6077. [
  6078. 4,
  6079. 7
  6080. ],
  6081. [
  6082. 4,
  6083. 7
  6084. ],
  6085. [
  6086. 4,
  6087. 7
  6088. ]
  6089. ];
  6090. var blackTable1 = [
  6091. [
  6092. -1,
  6093. -1
  6094. ],
  6095. [
  6096. -1,
  6097. -1
  6098. ],
  6099. [
  6100. 12,
  6101. ccittEOL
  6102. ],
  6103. [
  6104. 12,
  6105. ccittEOL
  6106. ],
  6107. [
  6108. -1,
  6109. -1
  6110. ],
  6111. [
  6112. -1,
  6113. -1
  6114. ],
  6115. [
  6116. -1,
  6117. -1
  6118. ],
  6119. [
  6120. -1,
  6121. -1
  6122. ],
  6123. [
  6124. -1,
  6125. -1
  6126. ],
  6127. [
  6128. -1,
  6129. -1
  6130. ],
  6131. [
  6132. -1,
  6133. -1
  6134. ],
  6135. [
  6136. -1,
  6137. -1
  6138. ],
  6139. [
  6140. -1,
  6141. -1
  6142. ],
  6143. [
  6144. -1,
  6145. -1
  6146. ],
  6147. [
  6148. -1,
  6149. -1
  6150. ],
  6151. [
  6152. -1,
  6153. -1
  6154. ],
  6155. [
  6156. -1,
  6157. -1
  6158. ],
  6159. [
  6160. -1,
  6161. -1
  6162. ],
  6163. [
  6164. -1,
  6165. -1
  6166. ],
  6167. [
  6168. -1,
  6169. -1
  6170. ],
  6171. [
  6172. -1,
  6173. -1
  6174. ],
  6175. [
  6176. -1,
  6177. -1
  6178. ],
  6179. [
  6180. -1,
  6181. -1
  6182. ],
  6183. [
  6184. -1,
  6185. -1
  6186. ],
  6187. [
  6188. -1,
  6189. -1
  6190. ],
  6191. [
  6192. -1,
  6193. -1
  6194. ],
  6195. [
  6196. -1,
  6197. -1
  6198. ],
  6199. [
  6200. -1,
  6201. -1
  6202. ],
  6203. [
  6204. -1,
  6205. -1
  6206. ],
  6207. [
  6208. -1,
  6209. -1
  6210. ],
  6211. [
  6212. -1,
  6213. -1
  6214. ],
  6215. [
  6216. -1,
  6217. -1
  6218. ],
  6219. [
  6220. 11,
  6221. 1792
  6222. ],
  6223. [
  6224. 11,
  6225. 1792
  6226. ],
  6227. [
  6228. 11,
  6229. 1792
  6230. ],
  6231. [
  6232. 11,
  6233. 1792
  6234. ],
  6235. [
  6236. 12,
  6237. 1984
  6238. ],
  6239. [
  6240. 12,
  6241. 1984
  6242. ],
  6243. [
  6244. 12,
  6245. 2048
  6246. ],
  6247. [
  6248. 12,
  6249. 2048
  6250. ],
  6251. [
  6252. 12,
  6253. 2112
  6254. ],
  6255. [
  6256. 12,
  6257. 2112
  6258. ],
  6259. [
  6260. 12,
  6261. 2176
  6262. ],
  6263. [
  6264. 12,
  6265. 2176
  6266. ],
  6267. [
  6268. 12,
  6269. 2240
  6270. ],
  6271. [
  6272. 12,
  6273. 2240
  6274. ],
  6275. [
  6276. 12,
  6277. 2304
  6278. ],
  6279. [
  6280. 12,
  6281. 2304
  6282. ],
  6283. [
  6284. 11,
  6285. 1856
  6286. ],
  6287. [
  6288. 11,
  6289. 1856
  6290. ],
  6291. [
  6292. 11,
  6293. 1856
  6294. ],
  6295. [
  6296. 11,
  6297. 1856
  6298. ],
  6299. [
  6300. 11,
  6301. 1920
  6302. ],
  6303. [
  6304. 11,
  6305. 1920
  6306. ],
  6307. [
  6308. 11,
  6309. 1920
  6310. ],
  6311. [
  6312. 11,
  6313. 1920
  6314. ],
  6315. [
  6316. 12,
  6317. 2368
  6318. ],
  6319. [
  6320. 12,
  6321. 2368
  6322. ],
  6323. [
  6324. 12,
  6325. 2432
  6326. ],
  6327. [
  6328. 12,
  6329. 2432
  6330. ],
  6331. [
  6332. 12,
  6333. 2496
  6334. ],
  6335. [
  6336. 12,
  6337. 2496
  6338. ],
  6339. [
  6340. 12,
  6341. 2560
  6342. ],
  6343. [
  6344. 12,
  6345. 2560
  6346. ],
  6347. [
  6348. 10,
  6349. 18
  6350. ],
  6351. [
  6352. 10,
  6353. 18
  6354. ],
  6355. [
  6356. 10,
  6357. 18
  6358. ],
  6359. [
  6360. 10,
  6361. 18
  6362. ],
  6363. [
  6364. 10,
  6365. 18
  6366. ],
  6367. [
  6368. 10,
  6369. 18
  6370. ],
  6371. [
  6372. 10,
  6373. 18
  6374. ],
  6375. [
  6376. 10,
  6377. 18
  6378. ],
  6379. [
  6380. 12,
  6381. 52
  6382. ],
  6383. [
  6384. 12,
  6385. 52
  6386. ],
  6387. [
  6388. 13,
  6389. 640
  6390. ],
  6391. [
  6392. 13,
  6393. 704
  6394. ],
  6395. [
  6396. 13,
  6397. 768
  6398. ],
  6399. [
  6400. 13,
  6401. 832
  6402. ],
  6403. [
  6404. 12,
  6405. 55
  6406. ],
  6407. [
  6408. 12,
  6409. 55
  6410. ],
  6411. [
  6412. 12,
  6413. 56
  6414. ],
  6415. [
  6416. 12,
  6417. 56
  6418. ],
  6419. [
  6420. 13,
  6421. 1280
  6422. ],
  6423. [
  6424. 13,
  6425. 1344
  6426. ],
  6427. [
  6428. 13,
  6429. 1408
  6430. ],
  6431. [
  6432. 13,
  6433. 1472
  6434. ],
  6435. [
  6436. 12,
  6437. 59
  6438. ],
  6439. [
  6440. 12,
  6441. 59
  6442. ],
  6443. [
  6444. 12,
  6445. 60
  6446. ],
  6447. [
  6448. 12,
  6449. 60
  6450. ],
  6451. [
  6452. 13,
  6453. 1536
  6454. ],
  6455. [
  6456. 13,
  6457. 1600
  6458. ],
  6459. [
  6460. 11,
  6461. 24
  6462. ],
  6463. [
  6464. 11,
  6465. 24
  6466. ],
  6467. [
  6468. 11,
  6469. 24
  6470. ],
  6471. [
  6472. 11,
  6473. 24
  6474. ],
  6475. [
  6476. 11,
  6477. 25
  6478. ],
  6479. [
  6480. 11,
  6481. 25
  6482. ],
  6483. [
  6484. 11,
  6485. 25
  6486. ],
  6487. [
  6488. 11,
  6489. 25
  6490. ],
  6491. [
  6492. 13,
  6493. 1664
  6494. ],
  6495. [
  6496. 13,
  6497. 1728
  6498. ],
  6499. [
  6500. 12,
  6501. 320
  6502. ],
  6503. [
  6504. 12,
  6505. 320
  6506. ],
  6507. [
  6508. 12,
  6509. 384
  6510. ],
  6511. [
  6512. 12,
  6513. 384
  6514. ],
  6515. [
  6516. 12,
  6517. 448
  6518. ],
  6519. [
  6520. 12,
  6521. 448
  6522. ],
  6523. [
  6524. 13,
  6525. 512
  6526. ],
  6527. [
  6528. 13,
  6529. 576
  6530. ],
  6531. [
  6532. 12,
  6533. 53
  6534. ],
  6535. [
  6536. 12,
  6537. 53
  6538. ],
  6539. [
  6540. 12,
  6541. 54
  6542. ],
  6543. [
  6544. 12,
  6545. 54
  6546. ],
  6547. [
  6548. 13,
  6549. 896
  6550. ],
  6551. [
  6552. 13,
  6553. 960
  6554. ],
  6555. [
  6556. 13,
  6557. 1024
  6558. ],
  6559. [
  6560. 13,
  6561. 1088
  6562. ],
  6563. [
  6564. 13,
  6565. 1152
  6566. ],
  6567. [
  6568. 13,
  6569. 1216
  6570. ],
  6571. [
  6572. 10,
  6573. 64
  6574. ],
  6575. [
  6576. 10,
  6577. 64
  6578. ],
  6579. [
  6580. 10,
  6581. 64
  6582. ],
  6583. [
  6584. 10,
  6585. 64
  6586. ],
  6587. [
  6588. 10,
  6589. 64
  6590. ],
  6591. [
  6592. 10,
  6593. 64
  6594. ],
  6595. [
  6596. 10,
  6597. 64
  6598. ],
  6599. [
  6600. 10,
  6601. 64
  6602. ]
  6603. ];
  6604. var blackTable2 = [
  6605. [
  6606. 8,
  6607. 13
  6608. ],
  6609. [
  6610. 8,
  6611. 13
  6612. ],
  6613. [
  6614. 8,
  6615. 13
  6616. ],
  6617. [
  6618. 8,
  6619. 13
  6620. ],
  6621. [
  6622. 8,
  6623. 13
  6624. ],
  6625. [
  6626. 8,
  6627. 13
  6628. ],
  6629. [
  6630. 8,
  6631. 13
  6632. ],
  6633. [
  6634. 8,
  6635. 13
  6636. ],
  6637. [
  6638. 8,
  6639. 13
  6640. ],
  6641. [
  6642. 8,
  6643. 13
  6644. ],
  6645. [
  6646. 8,
  6647. 13
  6648. ],
  6649. [
  6650. 8,
  6651. 13
  6652. ],
  6653. [
  6654. 8,
  6655. 13
  6656. ],
  6657. [
  6658. 8,
  6659. 13
  6660. ],
  6661. [
  6662. 8,
  6663. 13
  6664. ],
  6665. [
  6666. 8,
  6667. 13
  6668. ],
  6669. [
  6670. 11,
  6671. 23
  6672. ],
  6673. [
  6674. 11,
  6675. 23
  6676. ],
  6677. [
  6678. 12,
  6679. 50
  6680. ],
  6681. [
  6682. 12,
  6683. 51
  6684. ],
  6685. [
  6686. 12,
  6687. 44
  6688. ],
  6689. [
  6690. 12,
  6691. 45
  6692. ],
  6693. [
  6694. 12,
  6695. 46
  6696. ],
  6697. [
  6698. 12,
  6699. 47
  6700. ],
  6701. [
  6702. 12,
  6703. 57
  6704. ],
  6705. [
  6706. 12,
  6707. 58
  6708. ],
  6709. [
  6710. 12,
  6711. 61
  6712. ],
  6713. [
  6714. 12,
  6715. 256
  6716. ],
  6717. [
  6718. 10,
  6719. 16
  6720. ],
  6721. [
  6722. 10,
  6723. 16
  6724. ],
  6725. [
  6726. 10,
  6727. 16
  6728. ],
  6729. [
  6730. 10,
  6731. 16
  6732. ],
  6733. [
  6734. 10,
  6735. 17
  6736. ],
  6737. [
  6738. 10,
  6739. 17
  6740. ],
  6741. [
  6742. 10,
  6743. 17
  6744. ],
  6745. [
  6746. 10,
  6747. 17
  6748. ],
  6749. [
  6750. 12,
  6751. 48
  6752. ],
  6753. [
  6754. 12,
  6755. 49
  6756. ],
  6757. [
  6758. 12,
  6759. 62
  6760. ],
  6761. [
  6762. 12,
  6763. 63
  6764. ],
  6765. [
  6766. 12,
  6767. 30
  6768. ],
  6769. [
  6770. 12,
  6771. 31
  6772. ],
  6773. [
  6774. 12,
  6775. 32
  6776. ],
  6777. [
  6778. 12,
  6779. 33
  6780. ],
  6781. [
  6782. 12,
  6783. 40
  6784. ],
  6785. [
  6786. 12,
  6787. 41
  6788. ],
  6789. [
  6790. 11,
  6791. 22
  6792. ],
  6793. [
  6794. 11,
  6795. 22
  6796. ],
  6797. [
  6798. 8,
  6799. 14
  6800. ],
  6801. [
  6802. 8,
  6803. 14
  6804. ],
  6805. [
  6806. 8,
  6807. 14
  6808. ],
  6809. [
  6810. 8,
  6811. 14
  6812. ],
  6813. [
  6814. 8,
  6815. 14
  6816. ],
  6817. [
  6818. 8,
  6819. 14
  6820. ],
  6821. [
  6822. 8,
  6823. 14
  6824. ],
  6825. [
  6826. 8,
  6827. 14
  6828. ],
  6829. [
  6830. 8,
  6831. 14
  6832. ],
  6833. [
  6834. 8,
  6835. 14
  6836. ],
  6837. [
  6838. 8,
  6839. 14
  6840. ],
  6841. [
  6842. 8,
  6843. 14
  6844. ],
  6845. [
  6846. 8,
  6847. 14
  6848. ],
  6849. [
  6850. 8,
  6851. 14
  6852. ],
  6853. [
  6854. 8,
  6855. 14
  6856. ],
  6857. [
  6858. 8,
  6859. 14
  6860. ],
  6861. [
  6862. 7,
  6863. 10
  6864. ],
  6865. [
  6866. 7,
  6867. 10
  6868. ],
  6869. [
  6870. 7,
  6871. 10
  6872. ],
  6873. [
  6874. 7,
  6875. 10
  6876. ],
  6877. [
  6878. 7,
  6879. 10
  6880. ],
  6881. [
  6882. 7,
  6883. 10
  6884. ],
  6885. [
  6886. 7,
  6887. 10
  6888. ],
  6889. [
  6890. 7,
  6891. 10
  6892. ],
  6893. [
  6894. 7,
  6895. 10
  6896. ],
  6897. [
  6898. 7,
  6899. 10
  6900. ],
  6901. [
  6902. 7,
  6903. 10
  6904. ],
  6905. [
  6906. 7,
  6907. 10
  6908. ],
  6909. [
  6910. 7,
  6911. 10
  6912. ],
  6913. [
  6914. 7,
  6915. 10
  6916. ],
  6917. [
  6918. 7,
  6919. 10
  6920. ],
  6921. [
  6922. 7,
  6923. 10
  6924. ],
  6925. [
  6926. 7,
  6927. 10
  6928. ],
  6929. [
  6930. 7,
  6931. 10
  6932. ],
  6933. [
  6934. 7,
  6935. 10
  6936. ],
  6937. [
  6938. 7,
  6939. 10
  6940. ],
  6941. [
  6942. 7,
  6943. 10
  6944. ],
  6945. [
  6946. 7,
  6947. 10
  6948. ],
  6949. [
  6950. 7,
  6951. 10
  6952. ],
  6953. [
  6954. 7,
  6955. 10
  6956. ],
  6957. [
  6958. 7,
  6959. 10
  6960. ],
  6961. [
  6962. 7,
  6963. 10
  6964. ],
  6965. [
  6966. 7,
  6967. 10
  6968. ],
  6969. [
  6970. 7,
  6971. 10
  6972. ],
  6973. [
  6974. 7,
  6975. 10
  6976. ],
  6977. [
  6978. 7,
  6979. 10
  6980. ],
  6981. [
  6982. 7,
  6983. 10
  6984. ],
  6985. [
  6986. 7,
  6987. 10
  6988. ],
  6989. [
  6990. 7,
  6991. 11
  6992. ],
  6993. [
  6994. 7,
  6995. 11
  6996. ],
  6997. [
  6998. 7,
  6999. 11
  7000. ],
  7001. [
  7002. 7,
  7003. 11
  7004. ],
  7005. [
  7006. 7,
  7007. 11
  7008. ],
  7009. [
  7010. 7,
  7011. 11
  7012. ],
  7013. [
  7014. 7,
  7015. 11
  7016. ],
  7017. [
  7018. 7,
  7019. 11
  7020. ],
  7021. [
  7022. 7,
  7023. 11
  7024. ],
  7025. [
  7026. 7,
  7027. 11
  7028. ],
  7029. [
  7030. 7,
  7031. 11
  7032. ],
  7033. [
  7034. 7,
  7035. 11
  7036. ],
  7037. [
  7038. 7,
  7039. 11
  7040. ],
  7041. [
  7042. 7,
  7043. 11
  7044. ],
  7045. [
  7046. 7,
  7047. 11
  7048. ],
  7049. [
  7050. 7,
  7051. 11
  7052. ],
  7053. [
  7054. 7,
  7055. 11
  7056. ],
  7057. [
  7058. 7,
  7059. 11
  7060. ],
  7061. [
  7062. 7,
  7063. 11
  7064. ],
  7065. [
  7066. 7,
  7067. 11
  7068. ],
  7069. [
  7070. 7,
  7071. 11
  7072. ],
  7073. [
  7074. 7,
  7075. 11
  7076. ],
  7077. [
  7078. 7,
  7079. 11
  7080. ],
  7081. [
  7082. 7,
  7083. 11
  7084. ],
  7085. [
  7086. 7,
  7087. 11
  7088. ],
  7089. [
  7090. 7,
  7091. 11
  7092. ],
  7093. [
  7094. 7,
  7095. 11
  7096. ],
  7097. [
  7098. 7,
  7099. 11
  7100. ],
  7101. [
  7102. 7,
  7103. 11
  7104. ],
  7105. [
  7106. 7,
  7107. 11
  7108. ],
  7109. [
  7110. 7,
  7111. 11
  7112. ],
  7113. [
  7114. 7,
  7115. 11
  7116. ],
  7117. [
  7118. 9,
  7119. 15
  7120. ],
  7121. [
  7122. 9,
  7123. 15
  7124. ],
  7125. [
  7126. 9,
  7127. 15
  7128. ],
  7129. [
  7130. 9,
  7131. 15
  7132. ],
  7133. [
  7134. 9,
  7135. 15
  7136. ],
  7137. [
  7138. 9,
  7139. 15
  7140. ],
  7141. [
  7142. 9,
  7143. 15
  7144. ],
  7145. [
  7146. 9,
  7147. 15
  7148. ],
  7149. [
  7150. 12,
  7151. 128
  7152. ],
  7153. [
  7154. 12,
  7155. 192
  7156. ],
  7157. [
  7158. 12,
  7159. 26
  7160. ],
  7161. [
  7162. 12,
  7163. 27
  7164. ],
  7165. [
  7166. 12,
  7167. 28
  7168. ],
  7169. [
  7170. 12,
  7171. 29
  7172. ],
  7173. [
  7174. 11,
  7175. 19
  7176. ],
  7177. [
  7178. 11,
  7179. 19
  7180. ],
  7181. [
  7182. 11,
  7183. 20
  7184. ],
  7185. [
  7186. 11,
  7187. 20
  7188. ],
  7189. [
  7190. 12,
  7191. 34
  7192. ],
  7193. [
  7194. 12,
  7195. 35
  7196. ],
  7197. [
  7198. 12,
  7199. 36
  7200. ],
  7201. [
  7202. 12,
  7203. 37
  7204. ],
  7205. [
  7206. 12,
  7207. 38
  7208. ],
  7209. [
  7210. 12,
  7211. 39
  7212. ],
  7213. [
  7214. 11,
  7215. 21
  7216. ],
  7217. [
  7218. 11,
  7219. 21
  7220. ],
  7221. [
  7222. 12,
  7223. 42
  7224. ],
  7225. [
  7226. 12,
  7227. 43
  7228. ],
  7229. [
  7230. 10,
  7231. 0
  7232. ],
  7233. [
  7234. 10,
  7235. 0
  7236. ],
  7237. [
  7238. 10,
  7239. 0
  7240. ],
  7241. [
  7242. 10,
  7243. 0
  7244. ],
  7245. [
  7246. 7,
  7247. 12
  7248. ],
  7249. [
  7250. 7,
  7251. 12
  7252. ],
  7253. [
  7254. 7,
  7255. 12
  7256. ],
  7257. [
  7258. 7,
  7259. 12
  7260. ],
  7261. [
  7262. 7,
  7263. 12
  7264. ],
  7265. [
  7266. 7,
  7267. 12
  7268. ],
  7269. [
  7270. 7,
  7271. 12
  7272. ],
  7273. [
  7274. 7,
  7275. 12
  7276. ],
  7277. [
  7278. 7,
  7279. 12
  7280. ],
  7281. [
  7282. 7,
  7283. 12
  7284. ],
  7285. [
  7286. 7,
  7287. 12
  7288. ],
  7289. [
  7290. 7,
  7291. 12
  7292. ],
  7293. [
  7294. 7,
  7295. 12
  7296. ],
  7297. [
  7298. 7,
  7299. 12
  7300. ],
  7301. [
  7302. 7,
  7303. 12
  7304. ],
  7305. [
  7306. 7,
  7307. 12
  7308. ],
  7309. [
  7310. 7,
  7311. 12
  7312. ],
  7313. [
  7314. 7,
  7315. 12
  7316. ],
  7317. [
  7318. 7,
  7319. 12
  7320. ],
  7321. [
  7322. 7,
  7323. 12
  7324. ],
  7325. [
  7326. 7,
  7327. 12
  7328. ],
  7329. [
  7330. 7,
  7331. 12
  7332. ],
  7333. [
  7334. 7,
  7335. 12
  7336. ],
  7337. [
  7338. 7,
  7339. 12
  7340. ],
  7341. [
  7342. 7,
  7343. 12
  7344. ],
  7345. [
  7346. 7,
  7347. 12
  7348. ],
  7349. [
  7350. 7,
  7351. 12
  7352. ],
  7353. [
  7354. 7,
  7355. 12
  7356. ],
  7357. [
  7358. 7,
  7359. 12
  7360. ],
  7361. [
  7362. 7,
  7363. 12
  7364. ],
  7365. [
  7366. 7,
  7367. 12
  7368. ],
  7369. [
  7370. 7,
  7371. 12
  7372. ]
  7373. ];
  7374. var blackTable3 = [
  7375. [
  7376. -1,
  7377. -1
  7378. ],
  7379. [
  7380. -1,
  7381. -1
  7382. ],
  7383. [
  7384. -1,
  7385. -1
  7386. ],
  7387. [
  7388. -1,
  7389. -1
  7390. ],
  7391. [
  7392. 6,
  7393. 9
  7394. ],
  7395. [
  7396. 6,
  7397. 8
  7398. ],
  7399. [
  7400. 5,
  7401. 7
  7402. ],
  7403. [
  7404. 5,
  7405. 7
  7406. ],
  7407. [
  7408. 4,
  7409. 6
  7410. ],
  7411. [
  7412. 4,
  7413. 6
  7414. ],
  7415. [
  7416. 4,
  7417. 6
  7418. ],
  7419. [
  7420. 4,
  7421. 6
  7422. ],
  7423. [
  7424. 4,
  7425. 5
  7426. ],
  7427. [
  7428. 4,
  7429. 5
  7430. ],
  7431. [
  7432. 4,
  7433. 5
  7434. ],
  7435. [
  7436. 4,
  7437. 5
  7438. ],
  7439. [
  7440. 3,
  7441. 1
  7442. ],
  7443. [
  7444. 3,
  7445. 1
  7446. ],
  7447. [
  7448. 3,
  7449. 1
  7450. ],
  7451. [
  7452. 3,
  7453. 1
  7454. ],
  7455. [
  7456. 3,
  7457. 1
  7458. ],
  7459. [
  7460. 3,
  7461. 1
  7462. ],
  7463. [
  7464. 3,
  7465. 1
  7466. ],
  7467. [
  7468. 3,
  7469. 1
  7470. ],
  7471. [
  7472. 3,
  7473. 4
  7474. ],
  7475. [
  7476. 3,
  7477. 4
  7478. ],
  7479. [
  7480. 3,
  7481. 4
  7482. ],
  7483. [
  7484. 3,
  7485. 4
  7486. ],
  7487. [
  7488. 3,
  7489. 4
  7490. ],
  7491. [
  7492. 3,
  7493. 4
  7494. ],
  7495. [
  7496. 3,
  7497. 4
  7498. ],
  7499. [
  7500. 3,
  7501. 4
  7502. ],
  7503. [
  7504. 2,
  7505. 3
  7506. ],
  7507. [
  7508. 2,
  7509. 3
  7510. ],
  7511. [
  7512. 2,
  7513. 3
  7514. ],
  7515. [
  7516. 2,
  7517. 3
  7518. ],
  7519. [
  7520. 2,
  7521. 3
  7522. ],
  7523. [
  7524. 2,
  7525. 3
  7526. ],
  7527. [
  7528. 2,
  7529. 3
  7530. ],
  7531. [
  7532. 2,
  7533. 3
  7534. ],
  7535. [
  7536. 2,
  7537. 3
  7538. ],
  7539. [
  7540. 2,
  7541. 3
  7542. ],
  7543. [
  7544. 2,
  7545. 3
  7546. ],
  7547. [
  7548. 2,
  7549. 3
  7550. ],
  7551. [
  7552. 2,
  7553. 3
  7554. ],
  7555. [
  7556. 2,
  7557. 3
  7558. ],
  7559. [
  7560. 2,
  7561. 3
  7562. ],
  7563. [
  7564. 2,
  7565. 3
  7566. ],
  7567. [
  7568. 2,
  7569. 2
  7570. ],
  7571. [
  7572. 2,
  7573. 2
  7574. ],
  7575. [
  7576. 2,
  7577. 2
  7578. ],
  7579. [
  7580. 2,
  7581. 2
  7582. ],
  7583. [
  7584. 2,
  7585. 2
  7586. ],
  7587. [
  7588. 2,
  7589. 2
  7590. ],
  7591. [
  7592. 2,
  7593. 2
  7594. ],
  7595. [
  7596. 2,
  7597. 2
  7598. ],
  7599. [
  7600. 2,
  7601. 2
  7602. ],
  7603. [
  7604. 2,
  7605. 2
  7606. ],
  7607. [
  7608. 2,
  7609. 2
  7610. ],
  7611. [
  7612. 2,
  7613. 2
  7614. ],
  7615. [
  7616. 2,
  7617. 2
  7618. ],
  7619. [
  7620. 2,
  7621. 2
  7622. ],
  7623. [
  7624. 2,
  7625. 2
  7626. ],
  7627. [
  7628. 2,
  7629. 2
  7630. ]
  7631. ];
  7632. function CCITTFaxStream(str, maybeLength, params) {
  7633. this.str = str;
  7634. this.dict = str.dict;
  7635. params = params || Dict.empty;
  7636. this.encoding = params.get('K') || 0;
  7637. this.eoline = params.get('EndOfLine') || false;
  7638. this.byteAlign = params.get('EncodedByteAlign') || false;
  7639. this.columns = params.get('Columns') || 1728;
  7640. this.rows = params.get('Rows') || 0;
  7641. var eoblock = params.get('EndOfBlock');
  7642. if (eoblock === null || eoblock === undefined) {
  7643. eoblock = true;
  7644. }
  7645. this.eoblock = eoblock;
  7646. this.black = params.get('BlackIs1') || false;
  7647. this.codingLine = new Uint32Array(this.columns + 1);
  7648. this.refLine = new Uint32Array(this.columns + 2);
  7649. this.codingLine[0] = this.columns;
  7650. this.codingPos = 0;
  7651. this.row = 0;
  7652. this.nextLine2D = this.encoding < 0;
  7653. this.inputBits = 0;
  7654. this.inputBuf = 0;
  7655. this.outputBits = 0;
  7656. var code1;
  7657. while ((code1 = this.lookBits(12)) === 0) {
  7658. this.eatBits(1);
  7659. }
  7660. if (code1 === 1) {
  7661. this.eatBits(12);
  7662. }
  7663. if (this.encoding > 0) {
  7664. this.nextLine2D = !this.lookBits(1);
  7665. this.eatBits(1);
  7666. }
  7667. DecodeStream.call(this, maybeLength);
  7668. }
  7669. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  7670. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  7671. while (!this.eof) {
  7672. var c = this.lookChar();
  7673. this.ensureBuffer(this.bufferLength + 1);
  7674. this.buffer[this.bufferLength++] = c;
  7675. }
  7676. };
  7677. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  7678. var codingLine = this.codingLine;
  7679. var codingPos = this.codingPos;
  7680. if (a1 > codingLine[codingPos]) {
  7681. if (a1 > this.columns) {
  7682. info('row is wrong length');
  7683. this.err = true;
  7684. a1 = this.columns;
  7685. }
  7686. if (codingPos & 1 ^ blackPixels) {
  7687. ++codingPos;
  7688. }
  7689. codingLine[codingPos] = a1;
  7690. }
  7691. this.codingPos = codingPos;
  7692. };
  7693. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  7694. var codingLine = this.codingLine;
  7695. var codingPos = this.codingPos;
  7696. if (a1 > codingLine[codingPos]) {
  7697. if (a1 > this.columns) {
  7698. info('row is wrong length');
  7699. this.err = true;
  7700. a1 = this.columns;
  7701. }
  7702. if (codingPos & 1 ^ blackPixels) {
  7703. ++codingPos;
  7704. }
  7705. codingLine[codingPos] = a1;
  7706. } else if (a1 < codingLine[codingPos]) {
  7707. if (a1 < 0) {
  7708. info('invalid code');
  7709. this.err = true;
  7710. a1 = 0;
  7711. }
  7712. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7713. --codingPos;
  7714. }
  7715. codingLine[codingPos] = a1;
  7716. }
  7717. this.codingPos = codingPos;
  7718. };
  7719. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  7720. var refLine = this.refLine;
  7721. var codingLine = this.codingLine;
  7722. var columns = this.columns;
  7723. var refPos, blackPixels, bits, i;
  7724. if (this.outputBits === 0) {
  7725. if (this.eof) {
  7726. return null;
  7727. }
  7728. this.err = false;
  7729. var code1, code2, code3;
  7730. if (this.nextLine2D) {
  7731. for (i = 0; codingLine[i] < columns; ++i) {
  7732. refLine[i] = codingLine[i];
  7733. }
  7734. refLine[i++] = columns;
  7735. refLine[i] = columns;
  7736. codingLine[0] = 0;
  7737. this.codingPos = 0;
  7738. refPos = 0;
  7739. blackPixels = 0;
  7740. while (codingLine[this.codingPos] < columns) {
  7741. code1 = this.getTwoDimCode();
  7742. switch (code1) {
  7743. case twoDimPass:
  7744. this.addPixels(refLine[refPos + 1], blackPixels);
  7745. if (refLine[refPos + 1] < columns) {
  7746. refPos += 2;
  7747. }
  7748. break;
  7749. case twoDimHoriz:
  7750. code1 = code2 = 0;
  7751. if (blackPixels) {
  7752. do {
  7753. code1 += code3 = this.getBlackCode();
  7754. } while (code3 >= 64);
  7755. do {
  7756. code2 += code3 = this.getWhiteCode();
  7757. } while (code3 >= 64);
  7758. } else {
  7759. do {
  7760. code1 += code3 = this.getWhiteCode();
  7761. } while (code3 >= 64);
  7762. do {
  7763. code2 += code3 = this.getBlackCode();
  7764. } while (code3 >= 64);
  7765. }
  7766. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7767. if (codingLine[this.codingPos] < columns) {
  7768. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7769. }
  7770. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7771. refPos += 2;
  7772. }
  7773. break;
  7774. case twoDimVertR3:
  7775. this.addPixels(refLine[refPos] + 3, blackPixels);
  7776. blackPixels ^= 1;
  7777. if (codingLine[this.codingPos] < columns) {
  7778. ++refPos;
  7779. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7780. refPos += 2;
  7781. }
  7782. }
  7783. break;
  7784. case twoDimVertR2:
  7785. this.addPixels(refLine[refPos] + 2, blackPixels);
  7786. blackPixels ^= 1;
  7787. if (codingLine[this.codingPos] < columns) {
  7788. ++refPos;
  7789. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7790. refPos += 2;
  7791. }
  7792. }
  7793. break;
  7794. case twoDimVertR1:
  7795. this.addPixels(refLine[refPos] + 1, blackPixels);
  7796. blackPixels ^= 1;
  7797. if (codingLine[this.codingPos] < columns) {
  7798. ++refPos;
  7799. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7800. refPos += 2;
  7801. }
  7802. }
  7803. break;
  7804. case twoDimVert0:
  7805. this.addPixels(refLine[refPos], blackPixels);
  7806. blackPixels ^= 1;
  7807. if (codingLine[this.codingPos] < columns) {
  7808. ++refPos;
  7809. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7810. refPos += 2;
  7811. }
  7812. }
  7813. break;
  7814. case twoDimVertL3:
  7815. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7816. blackPixels ^= 1;
  7817. if (codingLine[this.codingPos] < columns) {
  7818. if (refPos > 0) {
  7819. --refPos;
  7820. } else {
  7821. ++refPos;
  7822. }
  7823. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7824. refPos += 2;
  7825. }
  7826. }
  7827. break;
  7828. case twoDimVertL2:
  7829. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7830. blackPixels ^= 1;
  7831. if (codingLine[this.codingPos] < columns) {
  7832. if (refPos > 0) {
  7833. --refPos;
  7834. } else {
  7835. ++refPos;
  7836. }
  7837. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7838. refPos += 2;
  7839. }
  7840. }
  7841. break;
  7842. case twoDimVertL1:
  7843. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7844. blackPixels ^= 1;
  7845. if (codingLine[this.codingPos] < columns) {
  7846. if (refPos > 0) {
  7847. --refPos;
  7848. } else {
  7849. ++refPos;
  7850. }
  7851. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7852. refPos += 2;
  7853. }
  7854. }
  7855. break;
  7856. case ccittEOF:
  7857. this.addPixels(columns, 0);
  7858. this.eof = true;
  7859. break;
  7860. default:
  7861. info('bad 2d code');
  7862. this.addPixels(columns, 0);
  7863. this.err = true;
  7864. }
  7865. }
  7866. } else {
  7867. codingLine[0] = 0;
  7868. this.codingPos = 0;
  7869. blackPixels = 0;
  7870. while (codingLine[this.codingPos] < columns) {
  7871. code1 = 0;
  7872. if (blackPixels) {
  7873. do {
  7874. code1 += code3 = this.getBlackCode();
  7875. } while (code3 >= 64);
  7876. } else {
  7877. do {
  7878. code1 += code3 = this.getWhiteCode();
  7879. } while (code3 >= 64);
  7880. }
  7881. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7882. blackPixels ^= 1;
  7883. }
  7884. }
  7885. var gotEOL = false;
  7886. if (this.byteAlign) {
  7887. this.inputBits &= ~7;
  7888. }
  7889. if (!this.eoblock && this.row === this.rows - 1) {
  7890. this.eof = true;
  7891. } else {
  7892. code1 = this.lookBits(12);
  7893. if (this.eoline) {
  7894. while (code1 !== ccittEOF && code1 !== 1) {
  7895. this.eatBits(1);
  7896. code1 = this.lookBits(12);
  7897. }
  7898. } else {
  7899. while (code1 === 0) {
  7900. this.eatBits(1);
  7901. code1 = this.lookBits(12);
  7902. }
  7903. }
  7904. if (code1 === 1) {
  7905. this.eatBits(12);
  7906. gotEOL = true;
  7907. } else if (code1 === ccittEOF) {
  7908. this.eof = true;
  7909. }
  7910. }
  7911. if (!this.eof && this.encoding > 0) {
  7912. this.nextLine2D = !this.lookBits(1);
  7913. this.eatBits(1);
  7914. }
  7915. if (this.eoblock && gotEOL && this.byteAlign) {
  7916. code1 = this.lookBits(12);
  7917. if (code1 === 1) {
  7918. this.eatBits(12);
  7919. if (this.encoding > 0) {
  7920. this.lookBits(1);
  7921. this.eatBits(1);
  7922. }
  7923. if (this.encoding >= 0) {
  7924. for (i = 0; i < 4; ++i) {
  7925. code1 = this.lookBits(12);
  7926. if (code1 !== 1) {
  7927. info('bad rtc code: ' + code1);
  7928. }
  7929. this.eatBits(12);
  7930. if (this.encoding > 0) {
  7931. this.lookBits(1);
  7932. this.eatBits(1);
  7933. }
  7934. }
  7935. }
  7936. this.eof = true;
  7937. }
  7938. } else if (this.err && this.eoline) {
  7939. while (true) {
  7940. code1 = this.lookBits(13);
  7941. if (code1 === ccittEOF) {
  7942. this.eof = true;
  7943. return null;
  7944. }
  7945. if (code1 >> 1 === 1) {
  7946. break;
  7947. }
  7948. this.eatBits(1);
  7949. }
  7950. this.eatBits(12);
  7951. if (this.encoding > 0) {
  7952. this.eatBits(1);
  7953. this.nextLine2D = !(code1 & 1);
  7954. }
  7955. }
  7956. if (codingLine[0] > 0) {
  7957. this.outputBits = codingLine[this.codingPos = 0];
  7958. } else {
  7959. this.outputBits = codingLine[this.codingPos = 1];
  7960. }
  7961. this.row++;
  7962. }
  7963. var c;
  7964. if (this.outputBits >= 8) {
  7965. c = this.codingPos & 1 ? 0 : 0xFF;
  7966. this.outputBits -= 8;
  7967. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7968. this.codingPos++;
  7969. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7970. }
  7971. } else {
  7972. bits = 8;
  7973. c = 0;
  7974. do {
  7975. if (this.outputBits > bits) {
  7976. c <<= bits;
  7977. if (!(this.codingPos & 1)) {
  7978. c |= 0xFF >> 8 - bits;
  7979. }
  7980. this.outputBits -= bits;
  7981. bits = 0;
  7982. } else {
  7983. c <<= this.outputBits;
  7984. if (!(this.codingPos & 1)) {
  7985. c |= 0xFF >> 8 - this.outputBits;
  7986. }
  7987. bits -= this.outputBits;
  7988. this.outputBits = 0;
  7989. if (codingLine[this.codingPos] < columns) {
  7990. this.codingPos++;
  7991. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7992. } else if (bits > 0) {
  7993. c <<= bits;
  7994. bits = 0;
  7995. }
  7996. }
  7997. } while (bits);
  7998. }
  7999. if (this.black) {
  8000. c ^= 0xFF;
  8001. }
  8002. return c;
  8003. };
  8004. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8005. var limitValue = limit || 0;
  8006. for (var i = start; i <= end; ++i) {
  8007. var code = this.lookBits(i);
  8008. if (code === ccittEOF) {
  8009. return [
  8010. true,
  8011. 1,
  8012. false
  8013. ];
  8014. }
  8015. if (i < end) {
  8016. code <<= end - i;
  8017. }
  8018. if (!limitValue || code >= limitValue) {
  8019. var p = table[code - limitValue];
  8020. if (p[0] === i) {
  8021. this.eatBits(i);
  8022. return [
  8023. true,
  8024. p[1],
  8025. true
  8026. ];
  8027. }
  8028. }
  8029. }
  8030. return [
  8031. false,
  8032. 0,
  8033. false
  8034. ];
  8035. };
  8036. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8037. var code = 0;
  8038. var p;
  8039. if (this.eoblock) {
  8040. code = this.lookBits(7);
  8041. p = twoDimTable[code];
  8042. if (p && p[0] > 0) {
  8043. this.eatBits(p[0]);
  8044. return p[1];
  8045. }
  8046. } else {
  8047. var result = this.findTableCode(1, 7, twoDimTable);
  8048. if (result[0] && result[2]) {
  8049. return result[1];
  8050. }
  8051. }
  8052. info('Bad two dim code');
  8053. return ccittEOF;
  8054. };
  8055. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8056. var code = 0;
  8057. var p;
  8058. if (this.eoblock) {
  8059. code = this.lookBits(12);
  8060. if (code === ccittEOF) {
  8061. return 1;
  8062. }
  8063. if (code >> 5 === 0) {
  8064. p = whiteTable1[code];
  8065. } else {
  8066. p = whiteTable2[code >> 3];
  8067. }
  8068. if (p[0] > 0) {
  8069. this.eatBits(p[0]);
  8070. return p[1];
  8071. }
  8072. } else {
  8073. var result = this.findTableCode(1, 9, whiteTable2);
  8074. if (result[0]) {
  8075. return result[1];
  8076. }
  8077. result = this.findTableCode(11, 12, whiteTable1);
  8078. if (result[0]) {
  8079. return result[1];
  8080. }
  8081. }
  8082. info('bad white code');
  8083. this.eatBits(1);
  8084. return 1;
  8085. };
  8086. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8087. var code, p;
  8088. if (this.eoblock) {
  8089. code = this.lookBits(13);
  8090. if (code === ccittEOF) {
  8091. return 1;
  8092. }
  8093. if (code >> 7 === 0) {
  8094. p = blackTable1[code];
  8095. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8096. p = blackTable2[(code >> 1) - 64];
  8097. } else {
  8098. p = blackTable3[code >> 7];
  8099. }
  8100. if (p[0] > 0) {
  8101. this.eatBits(p[0]);
  8102. return p[1];
  8103. }
  8104. } else {
  8105. var result = this.findTableCode(2, 6, blackTable3);
  8106. if (result[0]) {
  8107. return result[1];
  8108. }
  8109. result = this.findTableCode(7, 12, blackTable2, 64);
  8110. if (result[0]) {
  8111. return result[1];
  8112. }
  8113. result = this.findTableCode(10, 13, blackTable1);
  8114. if (result[0]) {
  8115. return result[1];
  8116. }
  8117. }
  8118. info('bad black code');
  8119. this.eatBits(1);
  8120. return 1;
  8121. };
  8122. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8123. var c;
  8124. while (this.inputBits < n) {
  8125. if ((c = this.str.getByte()) === -1) {
  8126. if (this.inputBits === 0) {
  8127. return ccittEOF;
  8128. }
  8129. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8130. }
  8131. this.inputBuf = this.inputBuf << 8 | c;
  8132. this.inputBits += 8;
  8133. }
  8134. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8135. };
  8136. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8137. if ((this.inputBits -= n) < 0) {
  8138. this.inputBits = 0;
  8139. }
  8140. };
  8141. return CCITTFaxStream;
  8142. }();
  8143. var LZWStream = function LZWStreamClosure() {
  8144. function LZWStream(str, maybeLength, earlyChange) {
  8145. this.str = str;
  8146. this.dict = str.dict;
  8147. this.cachedData = 0;
  8148. this.bitsCached = 0;
  8149. var maxLzwDictionarySize = 4096;
  8150. var lzwState = {
  8151. earlyChange: earlyChange,
  8152. codeLength: 9,
  8153. nextCode: 258,
  8154. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8155. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8156. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8157. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8158. currentSequenceLength: 0
  8159. };
  8160. for (var i = 0; i < 256; ++i) {
  8161. lzwState.dictionaryValues[i] = i;
  8162. lzwState.dictionaryLengths[i] = 1;
  8163. }
  8164. this.lzwState = lzwState;
  8165. DecodeStream.call(this, maybeLength);
  8166. }
  8167. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8168. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8169. var bitsCached = this.bitsCached;
  8170. var cachedData = this.cachedData;
  8171. while (bitsCached < n) {
  8172. var c = this.str.getByte();
  8173. if (c === -1) {
  8174. this.eof = true;
  8175. return null;
  8176. }
  8177. cachedData = cachedData << 8 | c;
  8178. bitsCached += 8;
  8179. }
  8180. this.bitsCached = bitsCached -= n;
  8181. this.cachedData = cachedData;
  8182. this.lastCode = null;
  8183. return cachedData >>> bitsCached & (1 << n) - 1;
  8184. };
  8185. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8186. var blockSize = 512;
  8187. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8188. var i, j, q;
  8189. var lzwState = this.lzwState;
  8190. if (!lzwState) {
  8191. return;
  8192. }
  8193. var earlyChange = lzwState.earlyChange;
  8194. var nextCode = lzwState.nextCode;
  8195. var dictionaryValues = lzwState.dictionaryValues;
  8196. var dictionaryLengths = lzwState.dictionaryLengths;
  8197. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  8198. var codeLength = lzwState.codeLength;
  8199. var prevCode = lzwState.prevCode;
  8200. var currentSequence = lzwState.currentSequence;
  8201. var currentSequenceLength = lzwState.currentSequenceLength;
  8202. var decodedLength = 0;
  8203. var currentBufferLength = this.bufferLength;
  8204. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8205. for (i = 0; i < blockSize; i++) {
  8206. var code = this.readBits(codeLength);
  8207. var hasPrev = currentSequenceLength > 0;
  8208. if (code < 256) {
  8209. currentSequence[0] = code;
  8210. currentSequenceLength = 1;
  8211. } else if (code >= 258) {
  8212. if (code < nextCode) {
  8213. currentSequenceLength = dictionaryLengths[code];
  8214. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  8215. currentSequence[j] = dictionaryValues[q];
  8216. q = dictionaryPrevCodes[q];
  8217. }
  8218. } else {
  8219. currentSequence[currentSequenceLength++] = currentSequence[0];
  8220. }
  8221. } else if (code === 256) {
  8222. codeLength = 9;
  8223. nextCode = 258;
  8224. currentSequenceLength = 0;
  8225. continue;
  8226. } else {
  8227. this.eof = true;
  8228. delete this.lzwState;
  8229. break;
  8230. }
  8231. if (hasPrev) {
  8232. dictionaryPrevCodes[nextCode] = prevCode;
  8233. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  8234. dictionaryValues[nextCode] = currentSequence[0];
  8235. nextCode++;
  8236. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  8237. }
  8238. prevCode = code;
  8239. decodedLength += currentSequenceLength;
  8240. if (estimatedDecodedSize < decodedLength) {
  8241. do {
  8242. estimatedDecodedSize += decodedSizeDelta;
  8243. } while (estimatedDecodedSize < decodedLength);
  8244. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8245. }
  8246. for (j = 0; j < currentSequenceLength; j++) {
  8247. buffer[currentBufferLength++] = currentSequence[j];
  8248. }
  8249. }
  8250. lzwState.nextCode = nextCode;
  8251. lzwState.codeLength = codeLength;
  8252. lzwState.prevCode = prevCode;
  8253. lzwState.currentSequenceLength = currentSequenceLength;
  8254. this.bufferLength = currentBufferLength;
  8255. };
  8256. return LZWStream;
  8257. }();
  8258. var NullStream = function NullStreamClosure() {
  8259. function NullStream() {
  8260. Stream.call(this, new Uint8Array(0));
  8261. }
  8262. NullStream.prototype = Stream.prototype;
  8263. return NullStream;
  8264. }();
  8265. exports.Ascii85Stream = Ascii85Stream;
  8266. exports.AsciiHexStream = AsciiHexStream;
  8267. exports.CCITTFaxStream = CCITTFaxStream;
  8268. exports.DecryptStream = DecryptStream;
  8269. exports.DecodeStream = DecodeStream;
  8270. exports.FlateStream = FlateStream;
  8271. exports.Jbig2Stream = Jbig2Stream;
  8272. exports.JpegStream = JpegStream;
  8273. exports.JpxStream = JpxStream;
  8274. exports.NullStream = NullStream;
  8275. exports.PredictorStream = PredictorStream;
  8276. exports.RunLengthStream = RunLengthStream;
  8277. exports.Stream = Stream;
  8278. exports.StreamsSequenceStream = StreamsSequenceStream;
  8279. exports.StringStream = StringStream;
  8280. exports.LZWStream = LZWStream;
  8281. /***/ }),
  8282. /* 3 */
  8283. /***/ (function(module, exports, __w_pdfjs_require__) {
  8284. "use strict";
  8285. var sharedUtil = __w_pdfjs_require__(0);
  8286. var assert = sharedUtil.assert;
  8287. var removeNullCharacters = sharedUtil.removeNullCharacters;
  8288. var warn = sharedUtil.warn;
  8289. var deprecated = sharedUtil.deprecated;
  8290. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  8291. var stringToBytes = sharedUtil.stringToBytes;
  8292. var CMapCompressionType = sharedUtil.CMapCompressionType;
  8293. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  8294. function DOMCanvasFactory() {
  8295. }
  8296. DOMCanvasFactory.prototype = {
  8297. create: function DOMCanvasFactory_create(width, height) {
  8298. assert(width > 0 && height > 0, 'invalid canvas size');
  8299. var canvas = document.createElement('canvas');
  8300. var context = canvas.getContext('2d');
  8301. canvas.width = width;
  8302. canvas.height = height;
  8303. return {
  8304. canvas: canvas,
  8305. context: context
  8306. };
  8307. },
  8308. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  8309. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8310. assert(width > 0 && height > 0, 'invalid canvas size');
  8311. canvasAndContextPair.canvas.width = width;
  8312. canvasAndContextPair.canvas.height = height;
  8313. },
  8314. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  8315. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8316. canvasAndContextPair.canvas.width = 0;
  8317. canvasAndContextPair.canvas.height = 0;
  8318. canvasAndContextPair.canvas = null;
  8319. canvasAndContextPair.context = null;
  8320. }
  8321. };
  8322. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  8323. function DOMCMapReaderFactory(params) {
  8324. this.baseUrl = params.baseUrl || null;
  8325. this.isCompressed = params.isCompressed || false;
  8326. }
  8327. DOMCMapReaderFactory.prototype = {
  8328. fetch: function (params) {
  8329. if (!params.name) {
  8330. return Promise.reject(new Error('CMap name must be specified.'));
  8331. }
  8332. return new Promise(function (resolve, reject) {
  8333. var url = this.baseUrl + params.name;
  8334. var request = new XMLHttpRequest();
  8335. if (this.isCompressed) {
  8336. url += '.bcmap';
  8337. request.responseType = 'arraybuffer';
  8338. }
  8339. request.onreadystatechange = function () {
  8340. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  8341. var data;
  8342. if (this.isCompressed && request.response) {
  8343. data = new Uint8Array(request.response);
  8344. } else if (!this.isCompressed && request.responseText) {
  8345. data = stringToBytes(request.responseText);
  8346. }
  8347. if (data) {
  8348. resolve({
  8349. cMapData: data,
  8350. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  8351. });
  8352. return;
  8353. }
  8354. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  8355. }
  8356. }.bind(this);
  8357. request.open('GET', url, true);
  8358. request.send(null);
  8359. }.bind(this));
  8360. }
  8361. };
  8362. return DOMCMapReaderFactory;
  8363. }();
  8364. var CustomStyle = function CustomStyleClosure() {
  8365. var prefixes = [
  8366. 'ms',
  8367. 'Moz',
  8368. 'Webkit',
  8369. 'O'
  8370. ];
  8371. var _cache = Object.create(null);
  8372. function CustomStyle() {
  8373. }
  8374. CustomStyle.getProp = function get(propName, element) {
  8375. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  8376. return _cache[propName];
  8377. }
  8378. element = element || document.documentElement;
  8379. var style = element.style, prefixed, uPropName;
  8380. if (typeof style[propName] === 'string') {
  8381. return _cache[propName] = propName;
  8382. }
  8383. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  8384. for (var i = 0, l = prefixes.length; i < l; i++) {
  8385. prefixed = prefixes[i] + uPropName;
  8386. if (typeof style[prefixed] === 'string') {
  8387. return _cache[propName] = prefixed;
  8388. }
  8389. }
  8390. return _cache[propName] = 'undefined';
  8391. };
  8392. CustomStyle.setProp = function set(propName, element, str) {
  8393. var prop = this.getProp(propName);
  8394. if (prop !== 'undefined') {
  8395. element.style[prop] = str;
  8396. }
  8397. };
  8398. return CustomStyle;
  8399. }();
  8400. var hasCanvasTypedArrays;
  8401. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  8402. var canvas = document.createElement('canvas');
  8403. canvas.width = canvas.height = 1;
  8404. var ctx = canvas.getContext('2d');
  8405. var imageData = ctx.createImageData(1, 1);
  8406. return typeof imageData.data.buffer !== 'undefined';
  8407. };
  8408. var LinkTarget = {
  8409. NONE: 0,
  8410. SELF: 1,
  8411. BLANK: 2,
  8412. PARENT: 3,
  8413. TOP: 4
  8414. };
  8415. var LinkTargetStringMap = [
  8416. '',
  8417. '_self',
  8418. '_blank',
  8419. '_parent',
  8420. '_top'
  8421. ];
  8422. function addLinkAttributes(link, params) {
  8423. var url = params && params.url;
  8424. link.href = link.title = url ? removeNullCharacters(url) : '';
  8425. if (url) {
  8426. var target = params.target;
  8427. if (typeof target === 'undefined') {
  8428. target = getDefaultSetting('externalLinkTarget');
  8429. }
  8430. link.target = LinkTargetStringMap[target];
  8431. var rel = params.rel;
  8432. if (typeof rel === 'undefined') {
  8433. rel = getDefaultSetting('externalLinkRel');
  8434. }
  8435. link.rel = rel;
  8436. }
  8437. }
  8438. function getFilenameFromUrl(url) {
  8439. var anchor = url.indexOf('#');
  8440. var query = url.indexOf('?');
  8441. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  8442. return url.substring(url.lastIndexOf('/', end) + 1, end);
  8443. }
  8444. function getDefaultSetting(id) {
  8445. var globalSettings = sharedUtil.globalScope.PDFJS;
  8446. switch (id) {
  8447. case 'pdfBug':
  8448. return globalSettings ? globalSettings.pdfBug : false;
  8449. case 'disableAutoFetch':
  8450. return globalSettings ? globalSettings.disableAutoFetch : false;
  8451. case 'disableStream':
  8452. return globalSettings ? globalSettings.disableStream : false;
  8453. case 'disableRange':
  8454. return globalSettings ? globalSettings.disableRange : false;
  8455. case 'disableFontFace':
  8456. return globalSettings ? globalSettings.disableFontFace : false;
  8457. case 'disableCreateObjectURL':
  8458. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  8459. case 'disableWebGL':
  8460. return globalSettings ? globalSettings.disableWebGL : true;
  8461. case 'cMapUrl':
  8462. return globalSettings ? globalSettings.cMapUrl : null;
  8463. case 'cMapPacked':
  8464. return globalSettings ? globalSettings.cMapPacked : false;
  8465. case 'postMessageTransfers':
  8466. return globalSettings ? globalSettings.postMessageTransfers : true;
  8467. case 'workerPort':
  8468. return globalSettings ? globalSettings.workerPort : null;
  8469. case 'workerSrc':
  8470. return globalSettings ? globalSettings.workerSrc : null;
  8471. case 'disableWorker':
  8472. return globalSettings ? globalSettings.disableWorker : false;
  8473. case 'maxImageSize':
  8474. return globalSettings ? globalSettings.maxImageSize : -1;
  8475. case 'imageResourcesPath':
  8476. return globalSettings ? globalSettings.imageResourcesPath : '';
  8477. case 'isEvalSupported':
  8478. return globalSettings ? globalSettings.isEvalSupported : true;
  8479. case 'externalLinkTarget':
  8480. if (!globalSettings) {
  8481. return LinkTarget.NONE;
  8482. }
  8483. switch (globalSettings.externalLinkTarget) {
  8484. case LinkTarget.NONE:
  8485. case LinkTarget.SELF:
  8486. case LinkTarget.BLANK:
  8487. case LinkTarget.PARENT:
  8488. case LinkTarget.TOP:
  8489. return globalSettings.externalLinkTarget;
  8490. }
  8491. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  8492. globalSettings.externalLinkTarget = LinkTarget.NONE;
  8493. return LinkTarget.NONE;
  8494. case 'externalLinkRel':
  8495. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  8496. case 'enableStats':
  8497. return !!(globalSettings && globalSettings.enableStats);
  8498. default:
  8499. throw new Error('Unknown default setting: ' + id);
  8500. }
  8501. }
  8502. function isExternalLinkTargetSet() {
  8503. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  8504. switch (externalLinkTarget) {
  8505. case LinkTarget.NONE:
  8506. return false;
  8507. case LinkTarget.SELF:
  8508. case LinkTarget.BLANK:
  8509. case LinkTarget.PARENT:
  8510. case LinkTarget.TOP:
  8511. return true;
  8512. }
  8513. }
  8514. function isValidUrl(url, allowRelative) {
  8515. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  8516. var baseUrl = allowRelative ? 'http://example.com' : null;
  8517. return createValidAbsoluteUrl(url, baseUrl) !== null;
  8518. }
  8519. exports.CustomStyle = CustomStyle;
  8520. exports.addLinkAttributes = addLinkAttributes;
  8521. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  8522. exports.isValidUrl = isValidUrl;
  8523. exports.getFilenameFromUrl = getFilenameFromUrl;
  8524. exports.LinkTarget = LinkTarget;
  8525. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  8526. exports.getDefaultSetting = getDefaultSetting;
  8527. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  8528. exports.DOMCanvasFactory = DOMCanvasFactory;
  8529. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  8530. /***/ }),
  8531. /* 4 */
  8532. /***/ (function(module, exports, __w_pdfjs_require__) {
  8533. "use strict";
  8534. var sharedUtil = __w_pdfjs_require__(0);
  8535. var corePrimitives = __w_pdfjs_require__(1);
  8536. var coreFunction = __w_pdfjs_require__(7);
  8537. var error = sharedUtil.error;
  8538. var info = sharedUtil.info;
  8539. var isArray = sharedUtil.isArray;
  8540. var isString = sharedUtil.isString;
  8541. var shadow = sharedUtil.shadow;
  8542. var warn = sharedUtil.warn;
  8543. var isDict = corePrimitives.isDict;
  8544. var isName = corePrimitives.isName;
  8545. var isStream = corePrimitives.isStream;
  8546. var PDFFunction = coreFunction.PDFFunction;
  8547. var ColorSpace = function ColorSpaceClosure() {
  8548. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  8549. var COMPONENTS = 3;
  8550. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  8551. var xRatio = w1 / w2;
  8552. var yRatio = h1 / h2;
  8553. var i, j, py, newIndex = 0, oldIndex;
  8554. var xScaled = new Uint16Array(w2);
  8555. var w1Scanline = w1 * COMPONENTS;
  8556. for (i = 0; i < w2; i++) {
  8557. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  8558. }
  8559. for (i = 0; i < h2; i++) {
  8560. py = Math.floor(i * yRatio) * w1Scanline;
  8561. for (j = 0; j < w2; j++) {
  8562. oldIndex = py + xScaled[j];
  8563. dest[newIndex++] = src[oldIndex++];
  8564. dest[newIndex++] = src[oldIndex++];
  8565. dest[newIndex++] = src[oldIndex++];
  8566. newIndex += alpha01;
  8567. }
  8568. }
  8569. }
  8570. function ColorSpace() {
  8571. error('should not call ColorSpace constructor');
  8572. }
  8573. ColorSpace.prototype = {
  8574. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  8575. var rgb = new Uint8Array(3);
  8576. this.getRgbItem(src, srcOffset, rgb, 0);
  8577. return rgb;
  8578. },
  8579. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  8580. error('Should not call ColorSpace.getRgbItem');
  8581. },
  8582. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8583. error('Should not call ColorSpace.getRgbBuffer');
  8584. },
  8585. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  8586. error('Should not call ColorSpace.getOutputLength');
  8587. },
  8588. isPassthrough: function ColorSpace_isPassthrough(bits) {
  8589. return false;
  8590. },
  8591. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  8592. var count = originalWidth * originalHeight;
  8593. var rgbBuf = null;
  8594. var numComponentColors = 1 << bpc;
  8595. var needsResizing = originalHeight !== height || originalWidth !== width;
  8596. var i, ii;
  8597. if (this.isPassthrough(bpc)) {
  8598. rgbBuf = comps;
  8599. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  8600. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  8601. var key;
  8602. for (i = 0; i < numComponentColors; i++) {
  8603. allColors[i] = i;
  8604. }
  8605. var colorMap = new Uint8Array(numComponentColors * 3);
  8606. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  8607. var destPos, rgbPos;
  8608. if (!needsResizing) {
  8609. destPos = 0;
  8610. for (i = 0; i < count; ++i) {
  8611. key = comps[i] * 3;
  8612. dest[destPos++] = colorMap[key];
  8613. dest[destPos++] = colorMap[key + 1];
  8614. dest[destPos++] = colorMap[key + 2];
  8615. destPos += alpha01;
  8616. }
  8617. } else {
  8618. rgbBuf = new Uint8Array(count * 3);
  8619. rgbPos = 0;
  8620. for (i = 0; i < count; ++i) {
  8621. key = comps[i] * 3;
  8622. rgbBuf[rgbPos++] = colorMap[key];
  8623. rgbBuf[rgbPos++] = colorMap[key + 1];
  8624. rgbBuf[rgbPos++] = colorMap[key + 2];
  8625. }
  8626. }
  8627. } else {
  8628. if (!needsResizing) {
  8629. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  8630. } else {
  8631. rgbBuf = new Uint8Array(count * 3);
  8632. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  8633. }
  8634. }
  8635. if (rgbBuf) {
  8636. if (needsResizing) {
  8637. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  8638. } else {
  8639. rgbPos = 0;
  8640. destPos = 0;
  8641. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  8642. dest[destPos++] = rgbBuf[rgbPos++];
  8643. dest[destPos++] = rgbBuf[rgbPos++];
  8644. dest[destPos++] = rgbBuf[rgbPos++];
  8645. destPos += alpha01;
  8646. }
  8647. }
  8648. }
  8649. },
  8650. usesZeroToOneRange: true
  8651. };
  8652. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  8653. var IR = ColorSpace.parseToIR(cs, xref, res);
  8654. if (IR instanceof AlternateCS) {
  8655. return IR;
  8656. }
  8657. return ColorSpace.fromIR(IR);
  8658. };
  8659. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  8660. var name = isArray(IR) ? IR[0] : IR;
  8661. var whitePoint, blackPoint, gamma;
  8662. switch (name) {
  8663. case 'DeviceGrayCS':
  8664. return this.singletons.gray;
  8665. case 'DeviceRgbCS':
  8666. return this.singletons.rgb;
  8667. case 'DeviceCmykCS':
  8668. return this.singletons.cmyk;
  8669. case 'CalGrayCS':
  8670. whitePoint = IR[1];
  8671. blackPoint = IR[2];
  8672. gamma = IR[3];
  8673. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8674. case 'CalRGBCS':
  8675. whitePoint = IR[1];
  8676. blackPoint = IR[2];
  8677. gamma = IR[3];
  8678. var matrix = IR[4];
  8679. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8680. case 'PatternCS':
  8681. var basePatternCS = IR[1];
  8682. if (basePatternCS) {
  8683. basePatternCS = ColorSpace.fromIR(basePatternCS);
  8684. }
  8685. return new PatternCS(basePatternCS);
  8686. case 'IndexedCS':
  8687. var baseIndexedCS = IR[1];
  8688. var hiVal = IR[2];
  8689. var lookup = IR[3];
  8690. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  8691. case 'AlternateCS':
  8692. var numComps = IR[1];
  8693. var alt = IR[2];
  8694. var tintFnIR = IR[3];
  8695. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  8696. case 'LabCS':
  8697. whitePoint = IR[1];
  8698. blackPoint = IR[2];
  8699. var range = IR[3];
  8700. return new LabCS(whitePoint, blackPoint, range);
  8701. default:
  8702. error('Unknown name ' + name);
  8703. }
  8704. return null;
  8705. };
  8706. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  8707. if (isName(cs)) {
  8708. var colorSpaces = res.get('ColorSpace');
  8709. if (isDict(colorSpaces)) {
  8710. var refcs = colorSpaces.get(cs.name);
  8711. if (refcs) {
  8712. cs = refcs;
  8713. }
  8714. }
  8715. }
  8716. cs = xref.fetchIfRef(cs);
  8717. if (isName(cs)) {
  8718. switch (cs.name) {
  8719. case 'DeviceGray':
  8720. case 'G':
  8721. return 'DeviceGrayCS';
  8722. case 'DeviceRGB':
  8723. case 'RGB':
  8724. return 'DeviceRgbCS';
  8725. case 'DeviceCMYK':
  8726. case 'CMYK':
  8727. return 'DeviceCmykCS';
  8728. case 'Pattern':
  8729. return [
  8730. 'PatternCS',
  8731. null
  8732. ];
  8733. default:
  8734. error('unrecognized colorspace ' + cs.name);
  8735. }
  8736. } else if (isArray(cs)) {
  8737. var mode = xref.fetchIfRef(cs[0]).name;
  8738. var numComps, params, alt, whitePoint, blackPoint, gamma;
  8739. switch (mode) {
  8740. case 'DeviceGray':
  8741. case 'G':
  8742. return 'DeviceGrayCS';
  8743. case 'DeviceRGB':
  8744. case 'RGB':
  8745. return 'DeviceRgbCS';
  8746. case 'DeviceCMYK':
  8747. case 'CMYK':
  8748. return 'DeviceCmykCS';
  8749. case 'CalGray':
  8750. params = xref.fetchIfRef(cs[1]);
  8751. whitePoint = params.getArray('WhitePoint');
  8752. blackPoint = params.getArray('BlackPoint');
  8753. gamma = params.get('Gamma');
  8754. return [
  8755. 'CalGrayCS',
  8756. whitePoint,
  8757. blackPoint,
  8758. gamma
  8759. ];
  8760. case 'CalRGB':
  8761. params = xref.fetchIfRef(cs[1]);
  8762. whitePoint = params.getArray('WhitePoint');
  8763. blackPoint = params.getArray('BlackPoint');
  8764. gamma = params.getArray('Gamma');
  8765. var matrix = params.getArray('Matrix');
  8766. return [
  8767. 'CalRGBCS',
  8768. whitePoint,
  8769. blackPoint,
  8770. gamma,
  8771. matrix
  8772. ];
  8773. case 'ICCBased':
  8774. var stream = xref.fetchIfRef(cs[1]);
  8775. var dict = stream.dict;
  8776. numComps = dict.get('N');
  8777. alt = dict.get('Alternate');
  8778. if (alt) {
  8779. var altIR = ColorSpace.parseToIR(alt, xref, res);
  8780. var altCS = ColorSpace.fromIR(altIR);
  8781. if (altCS.numComps === numComps) {
  8782. return altIR;
  8783. }
  8784. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  8785. }
  8786. if (numComps === 1) {
  8787. return 'DeviceGrayCS';
  8788. } else if (numComps === 3) {
  8789. return 'DeviceRgbCS';
  8790. } else if (numComps === 4) {
  8791. return 'DeviceCmykCS';
  8792. }
  8793. break;
  8794. case 'Pattern':
  8795. var basePatternCS = cs[1] || null;
  8796. if (basePatternCS) {
  8797. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  8798. }
  8799. return [
  8800. 'PatternCS',
  8801. basePatternCS
  8802. ];
  8803. case 'Indexed':
  8804. case 'I':
  8805. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  8806. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  8807. var lookup = xref.fetchIfRef(cs[3]);
  8808. if (isStream(lookup)) {
  8809. lookup = lookup.getBytes();
  8810. }
  8811. return [
  8812. 'IndexedCS',
  8813. baseIndexedCS,
  8814. hiVal,
  8815. lookup
  8816. ];
  8817. case 'Separation':
  8818. case 'DeviceN':
  8819. var name = xref.fetchIfRef(cs[1]);
  8820. numComps = isArray(name) ? name.length : 1;
  8821. alt = ColorSpace.parseToIR(cs[2], xref, res);
  8822. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  8823. return [
  8824. 'AlternateCS',
  8825. numComps,
  8826. alt,
  8827. tintFnIR
  8828. ];
  8829. case 'Lab':
  8830. params = xref.fetchIfRef(cs[1]);
  8831. whitePoint = params.getArray('WhitePoint');
  8832. blackPoint = params.getArray('BlackPoint');
  8833. var range = params.getArray('Range');
  8834. return [
  8835. 'LabCS',
  8836. whitePoint,
  8837. blackPoint,
  8838. range
  8839. ];
  8840. default:
  8841. error('unimplemented color space object "' + mode + '"');
  8842. }
  8843. } else {
  8844. error('unrecognized color space object: "' + cs + '"');
  8845. }
  8846. return null;
  8847. };
  8848. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  8849. if (!isArray(decode)) {
  8850. return true;
  8851. }
  8852. if (n * 2 !== decode.length) {
  8853. warn('The decode map is not the correct length');
  8854. return true;
  8855. }
  8856. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  8857. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8858. return false;
  8859. }
  8860. }
  8861. return true;
  8862. };
  8863. ColorSpace.singletons = {
  8864. get gray() {
  8865. return shadow(this, 'gray', new DeviceGrayCS());
  8866. },
  8867. get rgb() {
  8868. return shadow(this, 'rgb', new DeviceRgbCS());
  8869. },
  8870. get cmyk() {
  8871. return shadow(this, 'cmyk', new DeviceCmykCS());
  8872. }
  8873. };
  8874. return ColorSpace;
  8875. }();
  8876. var AlternateCS = function AlternateCSClosure() {
  8877. function AlternateCS(numComps, base, tintFn) {
  8878. this.name = 'Alternate';
  8879. this.numComps = numComps;
  8880. this.defaultColor = new Float32Array(numComps);
  8881. for (var i = 0; i < numComps; ++i) {
  8882. this.defaultColor[i] = 1;
  8883. }
  8884. this.base = base;
  8885. this.tintFn = tintFn;
  8886. this.tmpBuf = new Float32Array(base.numComps);
  8887. }
  8888. AlternateCS.prototype = {
  8889. getRgb: ColorSpace.prototype.getRgb,
  8890. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8891. var tmpBuf = this.tmpBuf;
  8892. this.tintFn(src, srcOffset, tmpBuf, 0);
  8893. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8894. },
  8895. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8896. var tintFn = this.tintFn;
  8897. var base = this.base;
  8898. var scale = 1 / ((1 << bits) - 1);
  8899. var baseNumComps = base.numComps;
  8900. var usesZeroToOneRange = base.usesZeroToOneRange;
  8901. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8902. var pos = isPassthrough ? destOffset : 0;
  8903. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  8904. var numComps = this.numComps;
  8905. var scaled = new Float32Array(numComps);
  8906. var tinted = new Float32Array(baseNumComps);
  8907. var i, j;
  8908. for (i = 0; i < count; i++) {
  8909. for (j = 0; j < numComps; j++) {
  8910. scaled[j] = src[srcOffset++] * scale;
  8911. }
  8912. tintFn(scaled, 0, tinted, 0);
  8913. if (usesZeroToOneRange) {
  8914. for (j = 0; j < baseNumComps; j++) {
  8915. baseBuf[pos++] = tinted[j] * 255;
  8916. }
  8917. } else {
  8918. base.getRgbItem(tinted, 0, baseBuf, pos);
  8919. pos += baseNumComps;
  8920. }
  8921. }
  8922. if (!isPassthrough) {
  8923. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8924. }
  8925. },
  8926. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  8927. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8928. },
  8929. isPassthrough: ColorSpace.prototype.isPassthrough,
  8930. fillRgb: ColorSpace.prototype.fillRgb,
  8931. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  8932. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8933. },
  8934. usesZeroToOneRange: true
  8935. };
  8936. return AlternateCS;
  8937. }();
  8938. var PatternCS = function PatternCSClosure() {
  8939. function PatternCS(baseCS) {
  8940. this.name = 'Pattern';
  8941. this.base = baseCS;
  8942. }
  8943. PatternCS.prototype = {};
  8944. return PatternCS;
  8945. }();
  8946. var IndexedCS = function IndexedCSClosure() {
  8947. function IndexedCS(base, highVal, lookup) {
  8948. this.name = 'Indexed';
  8949. this.numComps = 1;
  8950. this.defaultColor = new Uint8Array(this.numComps);
  8951. this.base = base;
  8952. this.highVal = highVal;
  8953. var baseNumComps = base.numComps;
  8954. var length = baseNumComps * highVal;
  8955. if (isStream(lookup)) {
  8956. this.lookup = new Uint8Array(length);
  8957. var bytes = lookup.getBytes(length);
  8958. this.lookup.set(bytes);
  8959. } else if (isString(lookup)) {
  8960. this.lookup = new Uint8Array(length);
  8961. for (var i = 0; i < length; ++i) {
  8962. this.lookup[i] = lookup.charCodeAt(i);
  8963. }
  8964. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  8965. this.lookup = lookup;
  8966. } else {
  8967. error('Unrecognized lookup table: ' + lookup);
  8968. }
  8969. }
  8970. IndexedCS.prototype = {
  8971. getRgb: ColorSpace.prototype.getRgb,
  8972. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8973. var numComps = this.base.numComps;
  8974. var start = src[srcOffset] * numComps;
  8975. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  8976. },
  8977. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8978. var base = this.base;
  8979. var numComps = base.numComps;
  8980. var outputDelta = base.getOutputLength(numComps, alpha01);
  8981. var lookup = this.lookup;
  8982. for (var i = 0; i < count; ++i) {
  8983. var lookupPos = src[srcOffset++] * numComps;
  8984. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8985. destOffset += outputDelta;
  8986. }
  8987. },
  8988. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  8989. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8990. },
  8991. isPassthrough: ColorSpace.prototype.isPassthrough,
  8992. fillRgb: ColorSpace.prototype.fillRgb,
  8993. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  8994. return true;
  8995. },
  8996. usesZeroToOneRange: true
  8997. };
  8998. return IndexedCS;
  8999. }();
  9000. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9001. function DeviceGrayCS() {
  9002. this.name = 'DeviceGray';
  9003. this.numComps = 1;
  9004. this.defaultColor = new Float32Array(this.numComps);
  9005. }
  9006. DeviceGrayCS.prototype = {
  9007. getRgb: ColorSpace.prototype.getRgb,
  9008. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9009. var c = src[srcOffset] * 255 | 0;
  9010. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9011. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9012. },
  9013. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9014. var scale = 255 / ((1 << bits) - 1);
  9015. var j = srcOffset, q = destOffset;
  9016. for (var i = 0; i < count; ++i) {
  9017. var c = scale * src[j++] | 0;
  9018. dest[q++] = c;
  9019. dest[q++] = c;
  9020. dest[q++] = c;
  9021. q += alpha01;
  9022. }
  9023. },
  9024. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9025. return inputLength * (3 + alpha01);
  9026. },
  9027. isPassthrough: ColorSpace.prototype.isPassthrough,
  9028. fillRgb: ColorSpace.prototype.fillRgb,
  9029. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9030. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9031. },
  9032. usesZeroToOneRange: true
  9033. };
  9034. return DeviceGrayCS;
  9035. }();
  9036. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9037. function DeviceRgbCS() {
  9038. this.name = 'DeviceRGB';
  9039. this.numComps = 3;
  9040. this.defaultColor = new Float32Array(this.numComps);
  9041. }
  9042. DeviceRgbCS.prototype = {
  9043. getRgb: ColorSpace.prototype.getRgb,
  9044. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9045. var r = src[srcOffset] * 255 | 0;
  9046. var g = src[srcOffset + 1] * 255 | 0;
  9047. var b = src[srcOffset + 2] * 255 | 0;
  9048. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9049. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9050. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9051. },
  9052. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9053. if (bits === 8 && alpha01 === 0) {
  9054. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9055. return;
  9056. }
  9057. var scale = 255 / ((1 << bits) - 1);
  9058. var j = srcOffset, q = destOffset;
  9059. for (var i = 0; i < count; ++i) {
  9060. dest[q++] = scale * src[j++] | 0;
  9061. dest[q++] = scale * src[j++] | 0;
  9062. dest[q++] = scale * src[j++] | 0;
  9063. q += alpha01;
  9064. }
  9065. },
  9066. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9067. return inputLength * (3 + alpha01) / 3 | 0;
  9068. },
  9069. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9070. return bits === 8;
  9071. },
  9072. fillRgb: ColorSpace.prototype.fillRgb,
  9073. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9074. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9075. },
  9076. usesZeroToOneRange: true
  9077. };
  9078. return DeviceRgbCS;
  9079. }();
  9080. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9081. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9082. var c = src[srcOffset + 0] * srcScale;
  9083. var m = src[srcOffset + 1] * srcScale;
  9084. var y = src[srcOffset + 2] * srcScale;
  9085. var k = src[srcOffset + 3] * srcScale;
  9086. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747) + 255 | 0;
  9087. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578) + 255 | 0;
  9088. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367) + 255 | 0;
  9089. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9090. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9091. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9092. }
  9093. function DeviceCmykCS() {
  9094. this.name = 'DeviceCMYK';
  9095. this.numComps = 4;
  9096. this.defaultColor = new Float32Array(this.numComps);
  9097. this.defaultColor[3] = 1;
  9098. }
  9099. DeviceCmykCS.prototype = {
  9100. getRgb: ColorSpace.prototype.getRgb,
  9101. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9102. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9103. },
  9104. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9105. var scale = 1 / ((1 << bits) - 1);
  9106. for (var i = 0; i < count; i++) {
  9107. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9108. srcOffset += 4;
  9109. destOffset += 3 + alpha01;
  9110. }
  9111. },
  9112. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9113. return inputLength / 4 * (3 + alpha01) | 0;
  9114. },
  9115. isPassthrough: ColorSpace.prototype.isPassthrough,
  9116. fillRgb: ColorSpace.prototype.fillRgb,
  9117. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9118. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9119. },
  9120. usesZeroToOneRange: true
  9121. };
  9122. return DeviceCmykCS;
  9123. }();
  9124. var CalGrayCS = function CalGrayCSClosure() {
  9125. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9126. this.name = 'CalGray';
  9127. this.numComps = 1;
  9128. this.defaultColor = new Float32Array(this.numComps);
  9129. if (!whitePoint) {
  9130. error('WhitePoint missing - required for color space CalGray');
  9131. }
  9132. blackPoint = blackPoint || [
  9133. 0,
  9134. 0,
  9135. 0
  9136. ];
  9137. gamma = gamma || 1;
  9138. this.XW = whitePoint[0];
  9139. this.YW = whitePoint[1];
  9140. this.ZW = whitePoint[2];
  9141. this.XB = blackPoint[0];
  9142. this.YB = blackPoint[1];
  9143. this.ZB = blackPoint[2];
  9144. this.G = gamma;
  9145. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9146. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9147. }
  9148. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9149. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9150. this.XB = this.YB = this.ZB = 0;
  9151. }
  9152. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9153. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9154. }
  9155. if (this.G < 1) {
  9156. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9157. this.G = 1;
  9158. }
  9159. }
  9160. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9161. var A = src[srcOffset] * scale;
  9162. var AG = Math.pow(A, cs.G);
  9163. var L = cs.YW * AG;
  9164. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9165. dest[destOffset] = val;
  9166. dest[destOffset + 1] = val;
  9167. dest[destOffset + 2] = val;
  9168. }
  9169. CalGrayCS.prototype = {
  9170. getRgb: ColorSpace.prototype.getRgb,
  9171. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9172. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9173. },
  9174. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9175. var scale = 1 / ((1 << bits) - 1);
  9176. for (var i = 0; i < count; ++i) {
  9177. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9178. srcOffset += 1;
  9179. destOffset += 3 + alpha01;
  9180. }
  9181. },
  9182. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9183. return inputLength * (3 + alpha01);
  9184. },
  9185. isPassthrough: ColorSpace.prototype.isPassthrough,
  9186. fillRgb: ColorSpace.prototype.fillRgb,
  9187. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9188. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9189. },
  9190. usesZeroToOneRange: true
  9191. };
  9192. return CalGrayCS;
  9193. }();
  9194. var CalRGBCS = function CalRGBCSClosure() {
  9195. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9196. 0.8951,
  9197. 0.2664,
  9198. -0.1614,
  9199. -0.7502,
  9200. 1.7135,
  9201. 0.0367,
  9202. 0.0389,
  9203. -0.0685,
  9204. 1.0296
  9205. ]);
  9206. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9207. 0.9869929,
  9208. -0.1470543,
  9209. 0.1599627,
  9210. 0.4323053,
  9211. 0.5183603,
  9212. 0.0492912,
  9213. -0.0085287,
  9214. 0.0400428,
  9215. 0.9684867
  9216. ]);
  9217. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9218. 3.2404542,
  9219. -1.5371385,
  9220. -0.4985314,
  9221. -0.9692660,
  9222. 1.8760108,
  9223. 0.0415560,
  9224. 0.0556434,
  9225. -0.2040259,
  9226. 1.0572252
  9227. ]);
  9228. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9229. 1,
  9230. 1,
  9231. 1
  9232. ]);
  9233. var tempNormalizeMatrix = new Float32Array(3);
  9234. var tempConvertMatrix1 = new Float32Array(3);
  9235. var tempConvertMatrix2 = new Float32Array(3);
  9236. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9237. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9238. this.name = 'CalRGB';
  9239. this.numComps = 3;
  9240. this.defaultColor = new Float32Array(this.numComps);
  9241. if (!whitePoint) {
  9242. error('WhitePoint missing - required for color space CalRGB');
  9243. }
  9244. blackPoint = blackPoint || new Float32Array(3);
  9245. gamma = gamma || new Float32Array([
  9246. 1,
  9247. 1,
  9248. 1
  9249. ]);
  9250. matrix = matrix || new Float32Array([
  9251. 1,
  9252. 0,
  9253. 0,
  9254. 0,
  9255. 1,
  9256. 0,
  9257. 0,
  9258. 0,
  9259. 1
  9260. ]);
  9261. var XW = whitePoint[0];
  9262. var YW = whitePoint[1];
  9263. var ZW = whitePoint[2];
  9264. this.whitePoint = whitePoint;
  9265. var XB = blackPoint[0];
  9266. var YB = blackPoint[1];
  9267. var ZB = blackPoint[2];
  9268. this.blackPoint = blackPoint;
  9269. this.GR = gamma[0];
  9270. this.GG = gamma[1];
  9271. this.GB = gamma[2];
  9272. this.MXA = matrix[0];
  9273. this.MYA = matrix[1];
  9274. this.MZA = matrix[2];
  9275. this.MXB = matrix[3];
  9276. this.MYB = matrix[4];
  9277. this.MZB = matrix[5];
  9278. this.MXC = matrix[6];
  9279. this.MYC = matrix[7];
  9280. this.MZC = matrix[8];
  9281. if (XW < 0 || ZW < 0 || YW !== 1) {
  9282. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9283. }
  9284. if (XB < 0 || YB < 0 || ZB < 0) {
  9285. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  9286. this.blackPoint = new Float32Array(3);
  9287. }
  9288. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  9289. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  9290. this.GR = this.GG = this.GB = 1;
  9291. }
  9292. if (this.MXA < 0 || this.MYA < 0 || this.MZA < 0 || this.MXB < 0 || this.MYB < 0 || this.MZB < 0 || this.MXC < 0 || this.MYC < 0 || this.MZC < 0) {
  9293. info('Invalid Matrix for ' + this.name + ' [' + this.MXA + ', ' + this.MYA + ', ' + this.MZA + this.MXB + ', ' + this.MYB + ', ' + this.MZB + this.MXC + ', ' + this.MYC + ', ' + this.MZC + '], falling back to default');
  9294. this.MXA = this.MYB = this.MZC = 1;
  9295. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  9296. }
  9297. }
  9298. function matrixProduct(a, b, result) {
  9299. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  9300. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  9301. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  9302. }
  9303. function convertToFlat(sourceWhitePoint, LMS, result) {
  9304. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  9305. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  9306. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  9307. }
  9308. function convertToD65(sourceWhitePoint, LMS, result) {
  9309. var D65X = 0.95047;
  9310. var D65Y = 1;
  9311. var D65Z = 1.08883;
  9312. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  9313. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  9314. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  9315. }
  9316. function sRGBTransferFunction(color) {
  9317. if (color <= 0.0031308) {
  9318. return adjustToRange(0, 1, 12.92 * color);
  9319. }
  9320. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  9321. }
  9322. function adjustToRange(min, max, value) {
  9323. return Math.max(min, Math.min(max, value));
  9324. }
  9325. function decodeL(L) {
  9326. if (L < 0) {
  9327. return -decodeL(-L);
  9328. }
  9329. if (L > 8.0) {
  9330. return Math.pow((L + 16) / 116, 3);
  9331. }
  9332. return L * DECODE_L_CONSTANT;
  9333. }
  9334. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  9335. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  9336. result[0] = XYZ_Flat[0];
  9337. result[1] = XYZ_Flat[1];
  9338. result[2] = XYZ_Flat[2];
  9339. return;
  9340. }
  9341. var zeroDecodeL = decodeL(0);
  9342. var X_DST = zeroDecodeL;
  9343. var X_SRC = decodeL(sourceBlackPoint[0]);
  9344. var Y_DST = zeroDecodeL;
  9345. var Y_SRC = decodeL(sourceBlackPoint[1]);
  9346. var Z_DST = zeroDecodeL;
  9347. var Z_SRC = decodeL(sourceBlackPoint[2]);
  9348. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  9349. var X_Offset = 1 - X_Scale;
  9350. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  9351. var Y_Offset = 1 - Y_Scale;
  9352. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  9353. var Z_Offset = 1 - Z_Scale;
  9354. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  9355. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  9356. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  9357. }
  9358. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  9359. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  9360. result[0] = XYZ_In[0];
  9361. result[1] = XYZ_In[1];
  9362. result[2] = XYZ_In[2];
  9363. return;
  9364. }
  9365. var LMS = result;
  9366. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9367. var LMS_Flat = tempNormalizeMatrix;
  9368. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  9369. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  9370. }
  9371. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  9372. var LMS = result;
  9373. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9374. var LMS_D65 = tempNormalizeMatrix;
  9375. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  9376. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  9377. }
  9378. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9379. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  9380. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  9381. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  9382. var AGR = Math.pow(A, cs.GR);
  9383. var BGG = Math.pow(B, cs.GG);
  9384. var CGB = Math.pow(C, cs.GB);
  9385. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  9386. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  9387. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  9388. var XYZ = tempConvertMatrix1;
  9389. XYZ[0] = X;
  9390. XYZ[1] = Y;
  9391. XYZ[2] = Z;
  9392. var XYZ_Flat = tempConvertMatrix2;
  9393. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  9394. var XYZ_Black = tempConvertMatrix1;
  9395. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  9396. var XYZ_D65 = tempConvertMatrix2;
  9397. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  9398. var SRGB = tempConvertMatrix1;
  9399. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  9400. var sR = sRGBTransferFunction(SRGB[0]);
  9401. var sG = sRGBTransferFunction(SRGB[1]);
  9402. var sB = sRGBTransferFunction(SRGB[2]);
  9403. dest[destOffset] = Math.round(sR * 255);
  9404. dest[destOffset + 1] = Math.round(sG * 255);
  9405. dest[destOffset + 2] = Math.round(sB * 255);
  9406. }
  9407. CalRGBCS.prototype = {
  9408. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  9409. var rgb = new Uint8Array(3);
  9410. this.getRgbItem(src, srcOffset, rgb, 0);
  9411. return rgb;
  9412. },
  9413. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9414. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9415. },
  9416. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9417. var scale = 1 / ((1 << bits) - 1);
  9418. for (var i = 0; i < count; ++i) {
  9419. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9420. srcOffset += 3;
  9421. destOffset += 3 + alpha01;
  9422. }
  9423. },
  9424. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  9425. return inputLength * (3 + alpha01) / 3 | 0;
  9426. },
  9427. isPassthrough: ColorSpace.prototype.isPassthrough,
  9428. fillRgb: ColorSpace.prototype.fillRgb,
  9429. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  9430. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9431. },
  9432. usesZeroToOneRange: true
  9433. };
  9434. return CalRGBCS;
  9435. }();
  9436. var LabCS = function LabCSClosure() {
  9437. function LabCS(whitePoint, blackPoint, range) {
  9438. this.name = 'Lab';
  9439. this.numComps = 3;
  9440. this.defaultColor = new Float32Array(this.numComps);
  9441. if (!whitePoint) {
  9442. error('WhitePoint missing - required for color space Lab');
  9443. }
  9444. blackPoint = blackPoint || [
  9445. 0,
  9446. 0,
  9447. 0
  9448. ];
  9449. range = range || [
  9450. -100,
  9451. 100,
  9452. -100,
  9453. 100
  9454. ];
  9455. this.XW = whitePoint[0];
  9456. this.YW = whitePoint[1];
  9457. this.ZW = whitePoint[2];
  9458. this.amin = range[0];
  9459. this.amax = range[1];
  9460. this.bmin = range[2];
  9461. this.bmax = range[3];
  9462. this.XB = blackPoint[0];
  9463. this.YB = blackPoint[1];
  9464. this.ZB = blackPoint[2];
  9465. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9466. error('Invalid WhitePoint components, no fallback available');
  9467. }
  9468. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9469. info('Invalid BlackPoint, falling back to default');
  9470. this.XB = this.YB = this.ZB = 0;
  9471. }
  9472. if (this.amin > this.amax || this.bmin > this.bmax) {
  9473. info('Invalid Range, falling back to defaults');
  9474. this.amin = -100;
  9475. this.amax = 100;
  9476. this.bmin = -100;
  9477. this.bmax = 100;
  9478. }
  9479. }
  9480. function fn_g(x) {
  9481. var result;
  9482. if (x >= 6 / 29) {
  9483. result = x * x * x;
  9484. } else {
  9485. result = 108 / 841 * (x - 4 / 29);
  9486. }
  9487. return result;
  9488. }
  9489. function decode(value, high1, low2, high2) {
  9490. return low2 + value * (high2 - low2) / high1;
  9491. }
  9492. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  9493. var Ls = src[srcOffset];
  9494. var as = src[srcOffset + 1];
  9495. var bs = src[srcOffset + 2];
  9496. if (maxVal !== false) {
  9497. Ls = decode(Ls, maxVal, 0, 100);
  9498. as = decode(as, maxVal, cs.amin, cs.amax);
  9499. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  9500. }
  9501. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  9502. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  9503. var M = (Ls + 16) / 116;
  9504. var L = M + as / 500;
  9505. var N = M - bs / 200;
  9506. var X = cs.XW * fn_g(L);
  9507. var Y = cs.YW * fn_g(M);
  9508. var Z = cs.ZW * fn_g(N);
  9509. var r, g, b;
  9510. if (cs.ZW < 1) {
  9511. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  9512. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  9513. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  9514. } else {
  9515. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  9516. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  9517. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  9518. }
  9519. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  9520. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  9521. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  9522. }
  9523. LabCS.prototype = {
  9524. getRgb: ColorSpace.prototype.getRgb,
  9525. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9526. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  9527. },
  9528. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9529. var maxVal = (1 << bits) - 1;
  9530. for (var i = 0; i < count; i++) {
  9531. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  9532. srcOffset += 3;
  9533. destOffset += 3 + alpha01;
  9534. }
  9535. },
  9536. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  9537. return inputLength * (3 + alpha01) / 3 | 0;
  9538. },
  9539. isPassthrough: ColorSpace.prototype.isPassthrough,
  9540. fillRgb: ColorSpace.prototype.fillRgb,
  9541. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  9542. return true;
  9543. },
  9544. usesZeroToOneRange: false
  9545. };
  9546. return LabCS;
  9547. }();
  9548. exports.ColorSpace = ColorSpace;
  9549. /***/ }),
  9550. /* 5 */
  9551. /***/ (function(module, exports, __w_pdfjs_require__) {
  9552. "use strict";
  9553. var ExpertEncoding = [
  9554. '',
  9555. '',
  9556. '',
  9557. '',
  9558. '',
  9559. '',
  9560. '',
  9561. '',
  9562. '',
  9563. '',
  9564. '',
  9565. '',
  9566. '',
  9567. '',
  9568. '',
  9569. '',
  9570. '',
  9571. '',
  9572. '',
  9573. '',
  9574. '',
  9575. '',
  9576. '',
  9577. '',
  9578. '',
  9579. '',
  9580. '',
  9581. '',
  9582. '',
  9583. '',
  9584. '',
  9585. '',
  9586. 'space',
  9587. 'exclamsmall',
  9588. 'Hungarumlautsmall',
  9589. '',
  9590. 'dollaroldstyle',
  9591. 'dollarsuperior',
  9592. 'ampersandsmall',
  9593. 'Acutesmall',
  9594. 'parenleftsuperior',
  9595. 'parenrightsuperior',
  9596. 'twodotenleader',
  9597. 'onedotenleader',
  9598. 'comma',
  9599. 'hyphen',
  9600. 'period',
  9601. 'fraction',
  9602. 'zerooldstyle',
  9603. 'oneoldstyle',
  9604. 'twooldstyle',
  9605. 'threeoldstyle',
  9606. 'fouroldstyle',
  9607. 'fiveoldstyle',
  9608. 'sixoldstyle',
  9609. 'sevenoldstyle',
  9610. 'eightoldstyle',
  9611. 'nineoldstyle',
  9612. 'colon',
  9613. 'semicolon',
  9614. 'commasuperior',
  9615. 'threequartersemdash',
  9616. 'periodsuperior',
  9617. 'questionsmall',
  9618. '',
  9619. 'asuperior',
  9620. 'bsuperior',
  9621. 'centsuperior',
  9622. 'dsuperior',
  9623. 'esuperior',
  9624. '',
  9625. '',
  9626. 'isuperior',
  9627. '',
  9628. '',
  9629. 'lsuperior',
  9630. 'msuperior',
  9631. 'nsuperior',
  9632. 'osuperior',
  9633. '',
  9634. '',
  9635. 'rsuperior',
  9636. 'ssuperior',
  9637. 'tsuperior',
  9638. '',
  9639. 'ff',
  9640. 'fi',
  9641. 'fl',
  9642. 'ffi',
  9643. 'ffl',
  9644. 'parenleftinferior',
  9645. '',
  9646. 'parenrightinferior',
  9647. 'Circumflexsmall',
  9648. 'hyphensuperior',
  9649. 'Gravesmall',
  9650. 'Asmall',
  9651. 'Bsmall',
  9652. 'Csmall',
  9653. 'Dsmall',
  9654. 'Esmall',
  9655. 'Fsmall',
  9656. 'Gsmall',
  9657. 'Hsmall',
  9658. 'Ismall',
  9659. 'Jsmall',
  9660. 'Ksmall',
  9661. 'Lsmall',
  9662. 'Msmall',
  9663. 'Nsmall',
  9664. 'Osmall',
  9665. 'Psmall',
  9666. 'Qsmall',
  9667. 'Rsmall',
  9668. 'Ssmall',
  9669. 'Tsmall',
  9670. 'Usmall',
  9671. 'Vsmall',
  9672. 'Wsmall',
  9673. 'Xsmall',
  9674. 'Ysmall',
  9675. 'Zsmall',
  9676. 'colonmonetary',
  9677. 'onefitted',
  9678. 'rupiah',
  9679. 'Tildesmall',
  9680. '',
  9681. '',
  9682. '',
  9683. '',
  9684. '',
  9685. '',
  9686. '',
  9687. '',
  9688. '',
  9689. '',
  9690. '',
  9691. '',
  9692. '',
  9693. '',
  9694. '',
  9695. '',
  9696. '',
  9697. '',
  9698. '',
  9699. '',
  9700. '',
  9701. '',
  9702. '',
  9703. '',
  9704. '',
  9705. '',
  9706. '',
  9707. '',
  9708. '',
  9709. '',
  9710. '',
  9711. '',
  9712. '',
  9713. '',
  9714. 'exclamdownsmall',
  9715. 'centoldstyle',
  9716. 'Lslashsmall',
  9717. '',
  9718. '',
  9719. 'Scaronsmall',
  9720. 'Zcaronsmall',
  9721. 'Dieresissmall',
  9722. 'Brevesmall',
  9723. 'Caronsmall',
  9724. '',
  9725. 'Dotaccentsmall',
  9726. '',
  9727. '',
  9728. 'Macronsmall',
  9729. '',
  9730. '',
  9731. 'figuredash',
  9732. 'hypheninferior',
  9733. '',
  9734. '',
  9735. 'Ogoneksmall',
  9736. 'Ringsmall',
  9737. 'Cedillasmall',
  9738. '',
  9739. '',
  9740. '',
  9741. 'onequarter',
  9742. 'onehalf',
  9743. 'threequarters',
  9744. 'questiondownsmall',
  9745. 'oneeighth',
  9746. 'threeeighths',
  9747. 'fiveeighths',
  9748. 'seveneighths',
  9749. 'onethird',
  9750. 'twothirds',
  9751. '',
  9752. '',
  9753. 'zerosuperior',
  9754. 'onesuperior',
  9755. 'twosuperior',
  9756. 'threesuperior',
  9757. 'foursuperior',
  9758. 'fivesuperior',
  9759. 'sixsuperior',
  9760. 'sevensuperior',
  9761. 'eightsuperior',
  9762. 'ninesuperior',
  9763. 'zeroinferior',
  9764. 'oneinferior',
  9765. 'twoinferior',
  9766. 'threeinferior',
  9767. 'fourinferior',
  9768. 'fiveinferior',
  9769. 'sixinferior',
  9770. 'seveninferior',
  9771. 'eightinferior',
  9772. 'nineinferior',
  9773. 'centinferior',
  9774. 'dollarinferior',
  9775. 'periodinferior',
  9776. 'commainferior',
  9777. 'Agravesmall',
  9778. 'Aacutesmall',
  9779. 'Acircumflexsmall',
  9780. 'Atildesmall',
  9781. 'Adieresissmall',
  9782. 'Aringsmall',
  9783. 'AEsmall',
  9784. 'Ccedillasmall',
  9785. 'Egravesmall',
  9786. 'Eacutesmall',
  9787. 'Ecircumflexsmall',
  9788. 'Edieresissmall',
  9789. 'Igravesmall',
  9790. 'Iacutesmall',
  9791. 'Icircumflexsmall',
  9792. 'Idieresissmall',
  9793. 'Ethsmall',
  9794. 'Ntildesmall',
  9795. 'Ogravesmall',
  9796. 'Oacutesmall',
  9797. 'Ocircumflexsmall',
  9798. 'Otildesmall',
  9799. 'Odieresissmall',
  9800. 'OEsmall',
  9801. 'Oslashsmall',
  9802. 'Ugravesmall',
  9803. 'Uacutesmall',
  9804. 'Ucircumflexsmall',
  9805. 'Udieresissmall',
  9806. 'Yacutesmall',
  9807. 'Thornsmall',
  9808. 'Ydieresissmall'
  9809. ];
  9810. var MacExpertEncoding = [
  9811. '',
  9812. '',
  9813. '',
  9814. '',
  9815. '',
  9816. '',
  9817. '',
  9818. '',
  9819. '',
  9820. '',
  9821. '',
  9822. '',
  9823. '',
  9824. '',
  9825. '',
  9826. '',
  9827. '',
  9828. '',
  9829. '',
  9830. '',
  9831. '',
  9832. '',
  9833. '',
  9834. '',
  9835. '',
  9836. '',
  9837. '',
  9838. '',
  9839. '',
  9840. '',
  9841. '',
  9842. '',
  9843. 'space',
  9844. 'exclamsmall',
  9845. 'Hungarumlautsmall',
  9846. 'centoldstyle',
  9847. 'dollaroldstyle',
  9848. 'dollarsuperior',
  9849. 'ampersandsmall',
  9850. 'Acutesmall',
  9851. 'parenleftsuperior',
  9852. 'parenrightsuperior',
  9853. 'twodotenleader',
  9854. 'onedotenleader',
  9855. 'comma',
  9856. 'hyphen',
  9857. 'period',
  9858. 'fraction',
  9859. 'zerooldstyle',
  9860. 'oneoldstyle',
  9861. 'twooldstyle',
  9862. 'threeoldstyle',
  9863. 'fouroldstyle',
  9864. 'fiveoldstyle',
  9865. 'sixoldstyle',
  9866. 'sevenoldstyle',
  9867. 'eightoldstyle',
  9868. 'nineoldstyle',
  9869. 'colon',
  9870. 'semicolon',
  9871. '',
  9872. 'threequartersemdash',
  9873. '',
  9874. 'questionsmall',
  9875. '',
  9876. '',
  9877. '',
  9878. '',
  9879. 'Ethsmall',
  9880. '',
  9881. '',
  9882. 'onequarter',
  9883. 'onehalf',
  9884. 'threequarters',
  9885. 'oneeighth',
  9886. 'threeeighths',
  9887. 'fiveeighths',
  9888. 'seveneighths',
  9889. 'onethird',
  9890. 'twothirds',
  9891. '',
  9892. '',
  9893. '',
  9894. '',
  9895. '',
  9896. '',
  9897. 'ff',
  9898. 'fi',
  9899. 'fl',
  9900. 'ffi',
  9901. 'ffl',
  9902. 'parenleftinferior',
  9903. '',
  9904. 'parenrightinferior',
  9905. 'Circumflexsmall',
  9906. 'hypheninferior',
  9907. 'Gravesmall',
  9908. 'Asmall',
  9909. 'Bsmall',
  9910. 'Csmall',
  9911. 'Dsmall',
  9912. 'Esmall',
  9913. 'Fsmall',
  9914. 'Gsmall',
  9915. 'Hsmall',
  9916. 'Ismall',
  9917. 'Jsmall',
  9918. 'Ksmall',
  9919. 'Lsmall',
  9920. 'Msmall',
  9921. 'Nsmall',
  9922. 'Osmall',
  9923. 'Psmall',
  9924. 'Qsmall',
  9925. 'Rsmall',
  9926. 'Ssmall',
  9927. 'Tsmall',
  9928. 'Usmall',
  9929. 'Vsmall',
  9930. 'Wsmall',
  9931. 'Xsmall',
  9932. 'Ysmall',
  9933. 'Zsmall',
  9934. 'colonmonetary',
  9935. 'onefitted',
  9936. 'rupiah',
  9937. 'Tildesmall',
  9938. '',
  9939. '',
  9940. 'asuperior',
  9941. 'centsuperior',
  9942. '',
  9943. '',
  9944. '',
  9945. '',
  9946. 'Aacutesmall',
  9947. 'Agravesmall',
  9948. 'Acircumflexsmall',
  9949. 'Adieresissmall',
  9950. 'Atildesmall',
  9951. 'Aringsmall',
  9952. 'Ccedillasmall',
  9953. 'Eacutesmall',
  9954. 'Egravesmall',
  9955. 'Ecircumflexsmall',
  9956. 'Edieresissmall',
  9957. 'Iacutesmall',
  9958. 'Igravesmall',
  9959. 'Icircumflexsmall',
  9960. 'Idieresissmall',
  9961. 'Ntildesmall',
  9962. 'Oacutesmall',
  9963. 'Ogravesmall',
  9964. 'Ocircumflexsmall',
  9965. 'Odieresissmall',
  9966. 'Otildesmall',
  9967. 'Uacutesmall',
  9968. 'Ugravesmall',
  9969. 'Ucircumflexsmall',
  9970. 'Udieresissmall',
  9971. '',
  9972. 'eightsuperior',
  9973. 'fourinferior',
  9974. 'threeinferior',
  9975. 'sixinferior',
  9976. 'eightinferior',
  9977. 'seveninferior',
  9978. 'Scaronsmall',
  9979. '',
  9980. 'centinferior',
  9981. 'twoinferior',
  9982. '',
  9983. 'Dieresissmall',
  9984. '',
  9985. 'Caronsmall',
  9986. 'osuperior',
  9987. 'fiveinferior',
  9988. '',
  9989. 'commainferior',
  9990. 'periodinferior',
  9991. 'Yacutesmall',
  9992. '',
  9993. 'dollarinferior',
  9994. '',
  9995. 'Thornsmall',
  9996. '',
  9997. 'nineinferior',
  9998. 'zeroinferior',
  9999. 'Zcaronsmall',
  10000. 'AEsmall',
  10001. 'Oslashsmall',
  10002. 'questiondownsmall',
  10003. 'oneinferior',
  10004. 'Lslashsmall',
  10005. '',
  10006. '',
  10007. '',
  10008. '',
  10009. '',
  10010. '',
  10011. 'Cedillasmall',
  10012. '',
  10013. '',
  10014. '',
  10015. '',
  10016. '',
  10017. 'OEsmall',
  10018. 'figuredash',
  10019. 'hyphensuperior',
  10020. '',
  10021. '',
  10022. '',
  10023. '',
  10024. 'exclamdownsmall',
  10025. '',
  10026. 'Ydieresissmall',
  10027. '',
  10028. 'onesuperior',
  10029. 'twosuperior',
  10030. 'threesuperior',
  10031. 'foursuperior',
  10032. 'fivesuperior',
  10033. 'sixsuperior',
  10034. 'sevensuperior',
  10035. 'ninesuperior',
  10036. 'zerosuperior',
  10037. '',
  10038. 'esuperior',
  10039. 'rsuperior',
  10040. 'tsuperior',
  10041. '',
  10042. '',
  10043. 'isuperior',
  10044. 'ssuperior',
  10045. 'dsuperior',
  10046. '',
  10047. '',
  10048. '',
  10049. '',
  10050. '',
  10051. 'lsuperior',
  10052. 'Ogoneksmall',
  10053. 'Brevesmall',
  10054. 'Macronsmall',
  10055. 'bsuperior',
  10056. 'nsuperior',
  10057. 'msuperior',
  10058. 'commasuperior',
  10059. 'periodsuperior',
  10060. 'Dotaccentsmall',
  10061. 'Ringsmall'
  10062. ];
  10063. var MacRomanEncoding = [
  10064. '',
  10065. '',
  10066. '',
  10067. '',
  10068. '',
  10069. '',
  10070. '',
  10071. '',
  10072. '',
  10073. '',
  10074. '',
  10075. '',
  10076. '',
  10077. '',
  10078. '',
  10079. '',
  10080. '',
  10081. '',
  10082. '',
  10083. '',
  10084. '',
  10085. '',
  10086. '',
  10087. '',
  10088. '',
  10089. '',
  10090. '',
  10091. '',
  10092. '',
  10093. '',
  10094. '',
  10095. '',
  10096. 'space',
  10097. 'exclam',
  10098. 'quotedbl',
  10099. 'numbersign',
  10100. 'dollar',
  10101. 'percent',
  10102. 'ampersand',
  10103. 'quotesingle',
  10104. 'parenleft',
  10105. 'parenright',
  10106. 'asterisk',
  10107. 'plus',
  10108. 'comma',
  10109. 'hyphen',
  10110. 'period',
  10111. 'slash',
  10112. 'zero',
  10113. 'one',
  10114. 'two',
  10115. 'three',
  10116. 'four',
  10117. 'five',
  10118. 'six',
  10119. 'seven',
  10120. 'eight',
  10121. 'nine',
  10122. 'colon',
  10123. 'semicolon',
  10124. 'less',
  10125. 'equal',
  10126. 'greater',
  10127. 'question',
  10128. 'at',
  10129. 'A',
  10130. 'B',
  10131. 'C',
  10132. 'D',
  10133. 'E',
  10134. 'F',
  10135. 'G',
  10136. 'H',
  10137. 'I',
  10138. 'J',
  10139. 'K',
  10140. 'L',
  10141. 'M',
  10142. 'N',
  10143. 'O',
  10144. 'P',
  10145. 'Q',
  10146. 'R',
  10147. 'S',
  10148. 'T',
  10149. 'U',
  10150. 'V',
  10151. 'W',
  10152. 'X',
  10153. 'Y',
  10154. 'Z',
  10155. 'bracketleft',
  10156. 'backslash',
  10157. 'bracketright',
  10158. 'asciicircum',
  10159. 'underscore',
  10160. 'grave',
  10161. 'a',
  10162. 'b',
  10163. 'c',
  10164. 'd',
  10165. 'e',
  10166. 'f',
  10167. 'g',
  10168. 'h',
  10169. 'i',
  10170. 'j',
  10171. 'k',
  10172. 'l',
  10173. 'm',
  10174. 'n',
  10175. 'o',
  10176. 'p',
  10177. 'q',
  10178. 'r',
  10179. 's',
  10180. 't',
  10181. 'u',
  10182. 'v',
  10183. 'w',
  10184. 'x',
  10185. 'y',
  10186. 'z',
  10187. 'braceleft',
  10188. 'bar',
  10189. 'braceright',
  10190. 'asciitilde',
  10191. '',
  10192. 'Adieresis',
  10193. 'Aring',
  10194. 'Ccedilla',
  10195. 'Eacute',
  10196. 'Ntilde',
  10197. 'Odieresis',
  10198. 'Udieresis',
  10199. 'aacute',
  10200. 'agrave',
  10201. 'acircumflex',
  10202. 'adieresis',
  10203. 'atilde',
  10204. 'aring',
  10205. 'ccedilla',
  10206. 'eacute',
  10207. 'egrave',
  10208. 'ecircumflex',
  10209. 'edieresis',
  10210. 'iacute',
  10211. 'igrave',
  10212. 'icircumflex',
  10213. 'idieresis',
  10214. 'ntilde',
  10215. 'oacute',
  10216. 'ograve',
  10217. 'ocircumflex',
  10218. 'odieresis',
  10219. 'otilde',
  10220. 'uacute',
  10221. 'ugrave',
  10222. 'ucircumflex',
  10223. 'udieresis',
  10224. 'dagger',
  10225. 'degree',
  10226. 'cent',
  10227. 'sterling',
  10228. 'section',
  10229. 'bullet',
  10230. 'paragraph',
  10231. 'germandbls',
  10232. 'registered',
  10233. 'copyright',
  10234. 'trademark',
  10235. 'acute',
  10236. 'dieresis',
  10237. 'notequal',
  10238. 'AE',
  10239. 'Oslash',
  10240. 'infinity',
  10241. 'plusminus',
  10242. 'lessequal',
  10243. 'greaterequal',
  10244. 'yen',
  10245. 'mu',
  10246. 'partialdiff',
  10247. 'summation',
  10248. 'product',
  10249. 'pi',
  10250. 'integral',
  10251. 'ordfeminine',
  10252. 'ordmasculine',
  10253. 'Omega',
  10254. 'ae',
  10255. 'oslash',
  10256. 'questiondown',
  10257. 'exclamdown',
  10258. 'logicalnot',
  10259. 'radical',
  10260. 'florin',
  10261. 'approxequal',
  10262. 'Delta',
  10263. 'guillemotleft',
  10264. 'guillemotright',
  10265. 'ellipsis',
  10266. 'space',
  10267. 'Agrave',
  10268. 'Atilde',
  10269. 'Otilde',
  10270. 'OE',
  10271. 'oe',
  10272. 'endash',
  10273. 'emdash',
  10274. 'quotedblleft',
  10275. 'quotedblright',
  10276. 'quoteleft',
  10277. 'quoteright',
  10278. 'divide',
  10279. 'lozenge',
  10280. 'ydieresis',
  10281. 'Ydieresis',
  10282. 'fraction',
  10283. 'currency',
  10284. 'guilsinglleft',
  10285. 'guilsinglright',
  10286. 'fi',
  10287. 'fl',
  10288. 'daggerdbl',
  10289. 'periodcentered',
  10290. 'quotesinglbase',
  10291. 'quotedblbase',
  10292. 'perthousand',
  10293. 'Acircumflex',
  10294. 'Ecircumflex',
  10295. 'Aacute',
  10296. 'Edieresis',
  10297. 'Egrave',
  10298. 'Iacute',
  10299. 'Icircumflex',
  10300. 'Idieresis',
  10301. 'Igrave',
  10302. 'Oacute',
  10303. 'Ocircumflex',
  10304. 'apple',
  10305. 'Ograve',
  10306. 'Uacute',
  10307. 'Ucircumflex',
  10308. 'Ugrave',
  10309. 'dotlessi',
  10310. 'circumflex',
  10311. 'tilde',
  10312. 'macron',
  10313. 'breve',
  10314. 'dotaccent',
  10315. 'ring',
  10316. 'cedilla',
  10317. 'hungarumlaut',
  10318. 'ogonek',
  10319. 'caron'
  10320. ];
  10321. var StandardEncoding = [
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. '',
  10338. '',
  10339. '',
  10340. '',
  10341. '',
  10342. '',
  10343. '',
  10344. '',
  10345. '',
  10346. '',
  10347. '',
  10348. '',
  10349. '',
  10350. '',
  10351. '',
  10352. '',
  10353. '',
  10354. 'space',
  10355. 'exclam',
  10356. 'quotedbl',
  10357. 'numbersign',
  10358. 'dollar',
  10359. 'percent',
  10360. 'ampersand',
  10361. 'quoteright',
  10362. 'parenleft',
  10363. 'parenright',
  10364. 'asterisk',
  10365. 'plus',
  10366. 'comma',
  10367. 'hyphen',
  10368. 'period',
  10369. 'slash',
  10370. 'zero',
  10371. 'one',
  10372. 'two',
  10373. 'three',
  10374. 'four',
  10375. 'five',
  10376. 'six',
  10377. 'seven',
  10378. 'eight',
  10379. 'nine',
  10380. 'colon',
  10381. 'semicolon',
  10382. 'less',
  10383. 'equal',
  10384. 'greater',
  10385. 'question',
  10386. 'at',
  10387. 'A',
  10388. 'B',
  10389. 'C',
  10390. 'D',
  10391. 'E',
  10392. 'F',
  10393. 'G',
  10394. 'H',
  10395. 'I',
  10396. 'J',
  10397. 'K',
  10398. 'L',
  10399. 'M',
  10400. 'N',
  10401. 'O',
  10402. 'P',
  10403. 'Q',
  10404. 'R',
  10405. 'S',
  10406. 'T',
  10407. 'U',
  10408. 'V',
  10409. 'W',
  10410. 'X',
  10411. 'Y',
  10412. 'Z',
  10413. 'bracketleft',
  10414. 'backslash',
  10415. 'bracketright',
  10416. 'asciicircum',
  10417. 'underscore',
  10418. 'quoteleft',
  10419. 'a',
  10420. 'b',
  10421. 'c',
  10422. 'd',
  10423. 'e',
  10424. 'f',
  10425. 'g',
  10426. 'h',
  10427. 'i',
  10428. 'j',
  10429. 'k',
  10430. 'l',
  10431. 'm',
  10432. 'n',
  10433. 'o',
  10434. 'p',
  10435. 'q',
  10436. 'r',
  10437. 's',
  10438. 't',
  10439. 'u',
  10440. 'v',
  10441. 'w',
  10442. 'x',
  10443. 'y',
  10444. 'z',
  10445. 'braceleft',
  10446. 'bar',
  10447. 'braceright',
  10448. 'asciitilde',
  10449. '',
  10450. '',
  10451. '',
  10452. '',
  10453. '',
  10454. '',
  10455. '',
  10456. '',
  10457. '',
  10458. '',
  10459. '',
  10460. '',
  10461. '',
  10462. '',
  10463. '',
  10464. '',
  10465. '',
  10466. '',
  10467. '',
  10468. '',
  10469. '',
  10470. '',
  10471. '',
  10472. '',
  10473. '',
  10474. '',
  10475. '',
  10476. '',
  10477. '',
  10478. '',
  10479. '',
  10480. '',
  10481. '',
  10482. '',
  10483. 'exclamdown',
  10484. 'cent',
  10485. 'sterling',
  10486. 'fraction',
  10487. 'yen',
  10488. 'florin',
  10489. 'section',
  10490. 'currency',
  10491. 'quotesingle',
  10492. 'quotedblleft',
  10493. 'guillemotleft',
  10494. 'guilsinglleft',
  10495. 'guilsinglright',
  10496. 'fi',
  10497. 'fl',
  10498. '',
  10499. 'endash',
  10500. 'dagger',
  10501. 'daggerdbl',
  10502. 'periodcentered',
  10503. '',
  10504. 'paragraph',
  10505. 'bullet',
  10506. 'quotesinglbase',
  10507. 'quotedblbase',
  10508. 'quotedblright',
  10509. 'guillemotright',
  10510. 'ellipsis',
  10511. 'perthousand',
  10512. '',
  10513. 'questiondown',
  10514. '',
  10515. 'grave',
  10516. 'acute',
  10517. 'circumflex',
  10518. 'tilde',
  10519. 'macron',
  10520. 'breve',
  10521. 'dotaccent',
  10522. 'dieresis',
  10523. '',
  10524. 'ring',
  10525. 'cedilla',
  10526. '',
  10527. 'hungarumlaut',
  10528. 'ogonek',
  10529. 'caron',
  10530. 'emdash',
  10531. '',
  10532. '',
  10533. '',
  10534. '',
  10535. '',
  10536. '',
  10537. '',
  10538. '',
  10539. '',
  10540. '',
  10541. '',
  10542. '',
  10543. '',
  10544. '',
  10545. '',
  10546. '',
  10547. 'AE',
  10548. '',
  10549. 'ordfeminine',
  10550. '',
  10551. '',
  10552. '',
  10553. '',
  10554. 'Lslash',
  10555. 'Oslash',
  10556. 'OE',
  10557. 'ordmasculine',
  10558. '',
  10559. '',
  10560. '',
  10561. '',
  10562. '',
  10563. 'ae',
  10564. '',
  10565. '',
  10566. '',
  10567. 'dotlessi',
  10568. '',
  10569. '',
  10570. 'lslash',
  10571. 'oslash',
  10572. 'oe',
  10573. 'germandbls'
  10574. ];
  10575. var WinAnsiEncoding = [
  10576. '',
  10577. '',
  10578. '',
  10579. '',
  10580. '',
  10581. '',
  10582. '',
  10583. '',
  10584. '',
  10585. '',
  10586. '',
  10587. '',
  10588. '',
  10589. '',
  10590. '',
  10591. '',
  10592. '',
  10593. '',
  10594. '',
  10595. '',
  10596. '',
  10597. '',
  10598. '',
  10599. '',
  10600. '',
  10601. '',
  10602. '',
  10603. '',
  10604. '',
  10605. '',
  10606. '',
  10607. '',
  10608. 'space',
  10609. 'exclam',
  10610. 'quotedbl',
  10611. 'numbersign',
  10612. 'dollar',
  10613. 'percent',
  10614. 'ampersand',
  10615. 'quotesingle',
  10616. 'parenleft',
  10617. 'parenright',
  10618. 'asterisk',
  10619. 'plus',
  10620. 'comma',
  10621. 'hyphen',
  10622. 'period',
  10623. 'slash',
  10624. 'zero',
  10625. 'one',
  10626. 'two',
  10627. 'three',
  10628. 'four',
  10629. 'five',
  10630. 'six',
  10631. 'seven',
  10632. 'eight',
  10633. 'nine',
  10634. 'colon',
  10635. 'semicolon',
  10636. 'less',
  10637. 'equal',
  10638. 'greater',
  10639. 'question',
  10640. 'at',
  10641. 'A',
  10642. 'B',
  10643. 'C',
  10644. 'D',
  10645. 'E',
  10646. 'F',
  10647. 'G',
  10648. 'H',
  10649. 'I',
  10650. 'J',
  10651. 'K',
  10652. 'L',
  10653. 'M',
  10654. 'N',
  10655. 'O',
  10656. 'P',
  10657. 'Q',
  10658. 'R',
  10659. 'S',
  10660. 'T',
  10661. 'U',
  10662. 'V',
  10663. 'W',
  10664. 'X',
  10665. 'Y',
  10666. 'Z',
  10667. 'bracketleft',
  10668. 'backslash',
  10669. 'bracketright',
  10670. 'asciicircum',
  10671. 'underscore',
  10672. 'grave',
  10673. 'a',
  10674. 'b',
  10675. 'c',
  10676. 'd',
  10677. 'e',
  10678. 'f',
  10679. 'g',
  10680. 'h',
  10681. 'i',
  10682. 'j',
  10683. 'k',
  10684. 'l',
  10685. 'm',
  10686. 'n',
  10687. 'o',
  10688. 'p',
  10689. 'q',
  10690. 'r',
  10691. 's',
  10692. 't',
  10693. 'u',
  10694. 'v',
  10695. 'w',
  10696. 'x',
  10697. 'y',
  10698. 'z',
  10699. 'braceleft',
  10700. 'bar',
  10701. 'braceright',
  10702. 'asciitilde',
  10703. 'bullet',
  10704. 'Euro',
  10705. 'bullet',
  10706. 'quotesinglbase',
  10707. 'florin',
  10708. 'quotedblbase',
  10709. 'ellipsis',
  10710. 'dagger',
  10711. 'daggerdbl',
  10712. 'circumflex',
  10713. 'perthousand',
  10714. 'Scaron',
  10715. 'guilsinglleft',
  10716. 'OE',
  10717. 'bullet',
  10718. 'Zcaron',
  10719. 'bullet',
  10720. 'bullet',
  10721. 'quoteleft',
  10722. 'quoteright',
  10723. 'quotedblleft',
  10724. 'quotedblright',
  10725. 'bullet',
  10726. 'endash',
  10727. 'emdash',
  10728. 'tilde',
  10729. 'trademark',
  10730. 'scaron',
  10731. 'guilsinglright',
  10732. 'oe',
  10733. 'bullet',
  10734. 'zcaron',
  10735. 'Ydieresis',
  10736. 'space',
  10737. 'exclamdown',
  10738. 'cent',
  10739. 'sterling',
  10740. 'currency',
  10741. 'yen',
  10742. 'brokenbar',
  10743. 'section',
  10744. 'dieresis',
  10745. 'copyright',
  10746. 'ordfeminine',
  10747. 'guillemotleft',
  10748. 'logicalnot',
  10749. 'hyphen',
  10750. 'registered',
  10751. 'macron',
  10752. 'degree',
  10753. 'plusminus',
  10754. 'twosuperior',
  10755. 'threesuperior',
  10756. 'acute',
  10757. 'mu',
  10758. 'paragraph',
  10759. 'periodcentered',
  10760. 'cedilla',
  10761. 'onesuperior',
  10762. 'ordmasculine',
  10763. 'guillemotright',
  10764. 'onequarter',
  10765. 'onehalf',
  10766. 'threequarters',
  10767. 'questiondown',
  10768. 'Agrave',
  10769. 'Aacute',
  10770. 'Acircumflex',
  10771. 'Atilde',
  10772. 'Adieresis',
  10773. 'Aring',
  10774. 'AE',
  10775. 'Ccedilla',
  10776. 'Egrave',
  10777. 'Eacute',
  10778. 'Ecircumflex',
  10779. 'Edieresis',
  10780. 'Igrave',
  10781. 'Iacute',
  10782. 'Icircumflex',
  10783. 'Idieresis',
  10784. 'Eth',
  10785. 'Ntilde',
  10786. 'Ograve',
  10787. 'Oacute',
  10788. 'Ocircumflex',
  10789. 'Otilde',
  10790. 'Odieresis',
  10791. 'multiply',
  10792. 'Oslash',
  10793. 'Ugrave',
  10794. 'Uacute',
  10795. 'Ucircumflex',
  10796. 'Udieresis',
  10797. 'Yacute',
  10798. 'Thorn',
  10799. 'germandbls',
  10800. 'agrave',
  10801. 'aacute',
  10802. 'acircumflex',
  10803. 'atilde',
  10804. 'adieresis',
  10805. 'aring',
  10806. 'ae',
  10807. 'ccedilla',
  10808. 'egrave',
  10809. 'eacute',
  10810. 'ecircumflex',
  10811. 'edieresis',
  10812. 'igrave',
  10813. 'iacute',
  10814. 'icircumflex',
  10815. 'idieresis',
  10816. 'eth',
  10817. 'ntilde',
  10818. 'ograve',
  10819. 'oacute',
  10820. 'ocircumflex',
  10821. 'otilde',
  10822. 'odieresis',
  10823. 'divide',
  10824. 'oslash',
  10825. 'ugrave',
  10826. 'uacute',
  10827. 'ucircumflex',
  10828. 'udieresis',
  10829. 'yacute',
  10830. 'thorn',
  10831. 'ydieresis'
  10832. ];
  10833. var SymbolSetEncoding = [
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. '',
  10850. '',
  10851. '',
  10852. '',
  10853. '',
  10854. '',
  10855. '',
  10856. '',
  10857. '',
  10858. '',
  10859. '',
  10860. '',
  10861. '',
  10862. '',
  10863. '',
  10864. '',
  10865. '',
  10866. 'space',
  10867. 'exclam',
  10868. 'universal',
  10869. 'numbersign',
  10870. 'existential',
  10871. 'percent',
  10872. 'ampersand',
  10873. 'suchthat',
  10874. 'parenleft',
  10875. 'parenright',
  10876. 'asteriskmath',
  10877. 'plus',
  10878. 'comma',
  10879. 'minus',
  10880. 'period',
  10881. 'slash',
  10882. 'zero',
  10883. 'one',
  10884. 'two',
  10885. 'three',
  10886. 'four',
  10887. 'five',
  10888. 'six',
  10889. 'seven',
  10890. 'eight',
  10891. 'nine',
  10892. 'colon',
  10893. 'semicolon',
  10894. 'less',
  10895. 'equal',
  10896. 'greater',
  10897. 'question',
  10898. 'congruent',
  10899. 'Alpha',
  10900. 'Beta',
  10901. 'Chi',
  10902. 'Delta',
  10903. 'Epsilon',
  10904. 'Phi',
  10905. 'Gamma',
  10906. 'Eta',
  10907. 'Iota',
  10908. 'theta1',
  10909. 'Kappa',
  10910. 'Lambda',
  10911. 'Mu',
  10912. 'Nu',
  10913. 'Omicron',
  10914. 'Pi',
  10915. 'Theta',
  10916. 'Rho',
  10917. 'Sigma',
  10918. 'Tau',
  10919. 'Upsilon',
  10920. 'sigma1',
  10921. 'Omega',
  10922. 'Xi',
  10923. 'Psi',
  10924. 'Zeta',
  10925. 'bracketleft',
  10926. 'therefore',
  10927. 'bracketright',
  10928. 'perpendicular',
  10929. 'underscore',
  10930. 'radicalex',
  10931. 'alpha',
  10932. 'beta',
  10933. 'chi',
  10934. 'delta',
  10935. 'epsilon',
  10936. 'phi',
  10937. 'gamma',
  10938. 'eta',
  10939. 'iota',
  10940. 'phi1',
  10941. 'kappa',
  10942. 'lambda',
  10943. 'mu',
  10944. 'nu',
  10945. 'omicron',
  10946. 'pi',
  10947. 'theta',
  10948. 'rho',
  10949. 'sigma',
  10950. 'tau',
  10951. 'upsilon',
  10952. 'omega1',
  10953. 'omega',
  10954. 'xi',
  10955. 'psi',
  10956. 'zeta',
  10957. 'braceleft',
  10958. 'bar',
  10959. 'braceright',
  10960. 'similar',
  10961. '',
  10962. '',
  10963. '',
  10964. '',
  10965. '',
  10966. '',
  10967. '',
  10968. '',
  10969. '',
  10970. '',
  10971. '',
  10972. '',
  10973. '',
  10974. '',
  10975. '',
  10976. '',
  10977. '',
  10978. '',
  10979. '',
  10980. '',
  10981. '',
  10982. '',
  10983. '',
  10984. '',
  10985. '',
  10986. '',
  10987. '',
  10988. '',
  10989. '',
  10990. '',
  10991. '',
  10992. '',
  10993. '',
  10994. 'Euro',
  10995. 'Upsilon1',
  10996. 'minute',
  10997. 'lessequal',
  10998. 'fraction',
  10999. 'infinity',
  11000. 'florin',
  11001. 'club',
  11002. 'diamond',
  11003. 'heart',
  11004. 'spade',
  11005. 'arrowboth',
  11006. 'arrowleft',
  11007. 'arrowup',
  11008. 'arrowright',
  11009. 'arrowdown',
  11010. 'degree',
  11011. 'plusminus',
  11012. 'second',
  11013. 'greaterequal',
  11014. 'multiply',
  11015. 'proportional',
  11016. 'partialdiff',
  11017. 'bullet',
  11018. 'divide',
  11019. 'notequal',
  11020. 'equivalence',
  11021. 'approxequal',
  11022. 'ellipsis',
  11023. 'arrowvertex',
  11024. 'arrowhorizex',
  11025. 'carriagereturn',
  11026. 'aleph',
  11027. 'Ifraktur',
  11028. 'Rfraktur',
  11029. 'weierstrass',
  11030. 'circlemultiply',
  11031. 'circleplus',
  11032. 'emptyset',
  11033. 'intersection',
  11034. 'union',
  11035. 'propersuperset',
  11036. 'reflexsuperset',
  11037. 'notsubset',
  11038. 'propersubset',
  11039. 'reflexsubset',
  11040. 'element',
  11041. 'notelement',
  11042. 'angle',
  11043. 'gradient',
  11044. 'registerserif',
  11045. 'copyrightserif',
  11046. 'trademarkserif',
  11047. 'product',
  11048. 'radical',
  11049. 'dotmath',
  11050. 'logicalnot',
  11051. 'logicaland',
  11052. 'logicalor',
  11053. 'arrowdblboth',
  11054. 'arrowdblleft',
  11055. 'arrowdblup',
  11056. 'arrowdblright',
  11057. 'arrowdbldown',
  11058. 'lozenge',
  11059. 'angleleft',
  11060. 'registersans',
  11061. 'copyrightsans',
  11062. 'trademarksans',
  11063. 'summation',
  11064. 'parenlefttp',
  11065. 'parenleftex',
  11066. 'parenleftbt',
  11067. 'bracketlefttp',
  11068. 'bracketleftex',
  11069. 'bracketleftbt',
  11070. 'bracelefttp',
  11071. 'braceleftmid',
  11072. 'braceleftbt',
  11073. 'braceex',
  11074. '',
  11075. 'angleright',
  11076. 'integral',
  11077. 'integraltp',
  11078. 'integralex',
  11079. 'integralbt',
  11080. 'parenrighttp',
  11081. 'parenrightex',
  11082. 'parenrightbt',
  11083. 'bracketrighttp',
  11084. 'bracketrightex',
  11085. 'bracketrightbt',
  11086. 'bracerighttp',
  11087. 'bracerightmid',
  11088. 'bracerightbt'
  11089. ];
  11090. var ZapfDingbatsEncoding = [
  11091. '',
  11092. '',
  11093. '',
  11094. '',
  11095. '',
  11096. '',
  11097. '',
  11098. '',
  11099. '',
  11100. '',
  11101. '',
  11102. '',
  11103. '',
  11104. '',
  11105. '',
  11106. '',
  11107. '',
  11108. '',
  11109. '',
  11110. '',
  11111. '',
  11112. '',
  11113. '',
  11114. '',
  11115. '',
  11116. '',
  11117. '',
  11118. '',
  11119. '',
  11120. '',
  11121. '',
  11122. '',
  11123. 'space',
  11124. 'a1',
  11125. 'a2',
  11126. 'a202',
  11127. 'a3',
  11128. 'a4',
  11129. 'a5',
  11130. 'a119',
  11131. 'a118',
  11132. 'a117',
  11133. 'a11',
  11134. 'a12',
  11135. 'a13',
  11136. 'a14',
  11137. 'a15',
  11138. 'a16',
  11139. 'a105',
  11140. 'a17',
  11141. 'a18',
  11142. 'a19',
  11143. 'a20',
  11144. 'a21',
  11145. 'a22',
  11146. 'a23',
  11147. 'a24',
  11148. 'a25',
  11149. 'a26',
  11150. 'a27',
  11151. 'a28',
  11152. 'a6',
  11153. 'a7',
  11154. 'a8',
  11155. 'a9',
  11156. 'a10',
  11157. 'a29',
  11158. 'a30',
  11159. 'a31',
  11160. 'a32',
  11161. 'a33',
  11162. 'a34',
  11163. 'a35',
  11164. 'a36',
  11165. 'a37',
  11166. 'a38',
  11167. 'a39',
  11168. 'a40',
  11169. 'a41',
  11170. 'a42',
  11171. 'a43',
  11172. 'a44',
  11173. 'a45',
  11174. 'a46',
  11175. 'a47',
  11176. 'a48',
  11177. 'a49',
  11178. 'a50',
  11179. 'a51',
  11180. 'a52',
  11181. 'a53',
  11182. 'a54',
  11183. 'a55',
  11184. 'a56',
  11185. 'a57',
  11186. 'a58',
  11187. 'a59',
  11188. 'a60',
  11189. 'a61',
  11190. 'a62',
  11191. 'a63',
  11192. 'a64',
  11193. 'a65',
  11194. 'a66',
  11195. 'a67',
  11196. 'a68',
  11197. 'a69',
  11198. 'a70',
  11199. 'a71',
  11200. 'a72',
  11201. 'a73',
  11202. 'a74',
  11203. 'a203',
  11204. 'a75',
  11205. 'a204',
  11206. 'a76',
  11207. 'a77',
  11208. 'a78',
  11209. 'a79',
  11210. 'a81',
  11211. 'a82',
  11212. 'a83',
  11213. 'a84',
  11214. 'a97',
  11215. 'a98',
  11216. 'a99',
  11217. 'a100',
  11218. '',
  11219. 'a89',
  11220. 'a90',
  11221. 'a93',
  11222. 'a94',
  11223. 'a91',
  11224. 'a92',
  11225. 'a205',
  11226. 'a85',
  11227. 'a206',
  11228. 'a86',
  11229. 'a87',
  11230. 'a88',
  11231. 'a95',
  11232. 'a96',
  11233. '',
  11234. '',
  11235. '',
  11236. '',
  11237. '',
  11238. '',
  11239. '',
  11240. '',
  11241. '',
  11242. '',
  11243. '',
  11244. '',
  11245. '',
  11246. '',
  11247. '',
  11248. '',
  11249. '',
  11250. '',
  11251. '',
  11252. 'a101',
  11253. 'a102',
  11254. 'a103',
  11255. 'a104',
  11256. 'a106',
  11257. 'a107',
  11258. 'a108',
  11259. 'a112',
  11260. 'a111',
  11261. 'a110',
  11262. 'a109',
  11263. 'a120',
  11264. 'a121',
  11265. 'a122',
  11266. 'a123',
  11267. 'a124',
  11268. 'a125',
  11269. 'a126',
  11270. 'a127',
  11271. 'a128',
  11272. 'a129',
  11273. 'a130',
  11274. 'a131',
  11275. 'a132',
  11276. 'a133',
  11277. 'a134',
  11278. 'a135',
  11279. 'a136',
  11280. 'a137',
  11281. 'a138',
  11282. 'a139',
  11283. 'a140',
  11284. 'a141',
  11285. 'a142',
  11286. 'a143',
  11287. 'a144',
  11288. 'a145',
  11289. 'a146',
  11290. 'a147',
  11291. 'a148',
  11292. 'a149',
  11293. 'a150',
  11294. 'a151',
  11295. 'a152',
  11296. 'a153',
  11297. 'a154',
  11298. 'a155',
  11299. 'a156',
  11300. 'a157',
  11301. 'a158',
  11302. 'a159',
  11303. 'a160',
  11304. 'a161',
  11305. 'a163',
  11306. 'a164',
  11307. 'a196',
  11308. 'a165',
  11309. 'a192',
  11310. 'a166',
  11311. 'a167',
  11312. 'a168',
  11313. 'a169',
  11314. 'a170',
  11315. 'a171',
  11316. 'a172',
  11317. 'a173',
  11318. 'a162',
  11319. 'a174',
  11320. 'a175',
  11321. 'a176',
  11322. 'a177',
  11323. 'a178',
  11324. 'a179',
  11325. 'a193',
  11326. 'a180',
  11327. 'a199',
  11328. 'a181',
  11329. 'a200',
  11330. 'a182',
  11331. '',
  11332. 'a201',
  11333. 'a183',
  11334. 'a184',
  11335. 'a197',
  11336. 'a185',
  11337. 'a194',
  11338. 'a198',
  11339. 'a186',
  11340. 'a195',
  11341. 'a187',
  11342. 'a188',
  11343. 'a189',
  11344. 'a190',
  11345. 'a191'
  11346. ];
  11347. function getEncoding(encodingName) {
  11348. switch (encodingName) {
  11349. case 'WinAnsiEncoding':
  11350. return WinAnsiEncoding;
  11351. case 'StandardEncoding':
  11352. return StandardEncoding;
  11353. case 'MacRomanEncoding':
  11354. return MacRomanEncoding;
  11355. case 'SymbolSetEncoding':
  11356. return SymbolSetEncoding;
  11357. case 'ZapfDingbatsEncoding':
  11358. return ZapfDingbatsEncoding;
  11359. case 'ExpertEncoding':
  11360. return ExpertEncoding;
  11361. case 'MacExpertEncoding':
  11362. return MacExpertEncoding;
  11363. default:
  11364. return null;
  11365. }
  11366. }
  11367. exports.WinAnsiEncoding = WinAnsiEncoding;
  11368. exports.StandardEncoding = StandardEncoding;
  11369. exports.MacRomanEncoding = MacRomanEncoding;
  11370. exports.SymbolSetEncoding = SymbolSetEncoding;
  11371. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  11372. exports.ExpertEncoding = ExpertEncoding;
  11373. exports.getEncoding = getEncoding;
  11374. /***/ }),
  11375. /* 6 */
  11376. /***/ (function(module, exports, __w_pdfjs_require__) {
  11377. "use strict";
  11378. var sharedUtil = __w_pdfjs_require__(0);
  11379. var corePrimitives = __w_pdfjs_require__(1);
  11380. var coreStream = __w_pdfjs_require__(2);
  11381. var MissingDataException = sharedUtil.MissingDataException;
  11382. var StreamType = sharedUtil.StreamType;
  11383. var assert = sharedUtil.assert;
  11384. var error = sharedUtil.error;
  11385. var info = sharedUtil.info;
  11386. var isArray = sharedUtil.isArray;
  11387. var isInt = sharedUtil.isInt;
  11388. var isNum = sharedUtil.isNum;
  11389. var isString = sharedUtil.isString;
  11390. var warn = sharedUtil.warn;
  11391. var EOF = corePrimitives.EOF;
  11392. var Cmd = corePrimitives.Cmd;
  11393. var Dict = corePrimitives.Dict;
  11394. var Name = corePrimitives.Name;
  11395. var Ref = corePrimitives.Ref;
  11396. var isEOF = corePrimitives.isEOF;
  11397. var isCmd = corePrimitives.isCmd;
  11398. var isDict = corePrimitives.isDict;
  11399. var isName = corePrimitives.isName;
  11400. var Ascii85Stream = coreStream.Ascii85Stream;
  11401. var AsciiHexStream = coreStream.AsciiHexStream;
  11402. var CCITTFaxStream = coreStream.CCITTFaxStream;
  11403. var FlateStream = coreStream.FlateStream;
  11404. var Jbig2Stream = coreStream.Jbig2Stream;
  11405. var JpegStream = coreStream.JpegStream;
  11406. var JpxStream = coreStream.JpxStream;
  11407. var LZWStream = coreStream.LZWStream;
  11408. var NullStream = coreStream.NullStream;
  11409. var PredictorStream = coreStream.PredictorStream;
  11410. var RunLengthStream = coreStream.RunLengthStream;
  11411. var MAX_LENGTH_TO_CACHE = 1000;
  11412. var Parser = function ParserClosure() {
  11413. function Parser(lexer, allowStreams, xref, recoveryMode) {
  11414. this.lexer = lexer;
  11415. this.allowStreams = allowStreams;
  11416. this.xref = xref;
  11417. this.recoveryMode = recoveryMode || false;
  11418. this.imageCache = Object.create(null);
  11419. this.refill();
  11420. }
  11421. Parser.prototype = {
  11422. refill: function Parser_refill() {
  11423. this.buf1 = this.lexer.getObj();
  11424. this.buf2 = this.lexer.getObj();
  11425. },
  11426. shift: function Parser_shift() {
  11427. if (isCmd(this.buf2, 'ID')) {
  11428. this.buf1 = this.buf2;
  11429. this.buf2 = null;
  11430. } else {
  11431. this.buf1 = this.buf2;
  11432. this.buf2 = this.lexer.getObj();
  11433. }
  11434. },
  11435. tryShift: function Parser_tryShift() {
  11436. try {
  11437. this.shift();
  11438. return true;
  11439. } catch (e) {
  11440. if (e instanceof MissingDataException) {
  11441. throw e;
  11442. }
  11443. return false;
  11444. }
  11445. },
  11446. getObj: function Parser_getObj(cipherTransform) {
  11447. var buf1 = this.buf1;
  11448. this.shift();
  11449. if (buf1 instanceof Cmd) {
  11450. switch (buf1.cmd) {
  11451. case 'BI':
  11452. return this.makeInlineImage(cipherTransform);
  11453. case '[':
  11454. var array = [];
  11455. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  11456. array.push(this.getObj(cipherTransform));
  11457. }
  11458. if (isEOF(this.buf1)) {
  11459. if (!this.recoveryMode) {
  11460. error('End of file inside array');
  11461. }
  11462. return array;
  11463. }
  11464. this.shift();
  11465. return array;
  11466. case '<<':
  11467. var dict = new Dict(this.xref);
  11468. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  11469. if (!isName(this.buf1)) {
  11470. info('Malformed dictionary: key must be a name object');
  11471. this.shift();
  11472. continue;
  11473. }
  11474. var key = this.buf1.name;
  11475. this.shift();
  11476. if (isEOF(this.buf1)) {
  11477. break;
  11478. }
  11479. dict.set(key, this.getObj(cipherTransform));
  11480. }
  11481. if (isEOF(this.buf1)) {
  11482. if (!this.recoveryMode) {
  11483. error('End of file inside dictionary');
  11484. }
  11485. return dict;
  11486. }
  11487. if (isCmd(this.buf2, 'stream')) {
  11488. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  11489. }
  11490. this.shift();
  11491. return dict;
  11492. default:
  11493. return buf1;
  11494. }
  11495. }
  11496. if (isInt(buf1)) {
  11497. var num = buf1;
  11498. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  11499. var ref = new Ref(num, this.buf1);
  11500. this.shift();
  11501. this.shift();
  11502. return ref;
  11503. }
  11504. return num;
  11505. }
  11506. if (isString(buf1)) {
  11507. var str = buf1;
  11508. if (cipherTransform) {
  11509. str = cipherTransform.decryptString(str);
  11510. }
  11511. return str;
  11512. }
  11513. return buf1;
  11514. },
  11515. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  11516. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  11517. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  11518. while ((ch = stream.getByte()) !== -1) {
  11519. if (state === 0) {
  11520. state = ch === E ? 1 : 0;
  11521. } else if (state === 1) {
  11522. state = ch === I ? 2 : 0;
  11523. } else {
  11524. assert(state === 2);
  11525. if (ch === SPACE || ch === LF || ch === CR) {
  11526. n = 5;
  11527. followingBytes = stream.peekBytes(n);
  11528. for (i = 0; i < n; i++) {
  11529. ch = followingBytes[i];
  11530. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  11531. state = 0;
  11532. break;
  11533. }
  11534. }
  11535. if (state === 2) {
  11536. break;
  11537. }
  11538. } else {
  11539. state = 0;
  11540. }
  11541. }
  11542. }
  11543. return stream.pos - 4 - startPos;
  11544. },
  11545. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  11546. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  11547. while ((b = stream.getByte()) !== -1) {
  11548. if (b !== 0xFF) {
  11549. continue;
  11550. }
  11551. switch (stream.getByte()) {
  11552. case 0x00:
  11553. break;
  11554. case 0xFF:
  11555. stream.skip(-1);
  11556. break;
  11557. case 0xD9:
  11558. foundEOI = true;
  11559. break;
  11560. case 0xC0:
  11561. case 0xC1:
  11562. case 0xC2:
  11563. case 0xC3:
  11564. case 0xC5:
  11565. case 0xC6:
  11566. case 0xC7:
  11567. case 0xC9:
  11568. case 0xCA:
  11569. case 0xCB:
  11570. case 0xCD:
  11571. case 0xCE:
  11572. case 0xCF:
  11573. case 0xC4:
  11574. case 0xCC:
  11575. case 0xDA:
  11576. case 0xDB:
  11577. case 0xDC:
  11578. case 0xDD:
  11579. case 0xDE:
  11580. case 0xDF:
  11581. case 0xE0:
  11582. case 0xE1:
  11583. case 0xE2:
  11584. case 0xE3:
  11585. case 0xE4:
  11586. case 0xE5:
  11587. case 0xE6:
  11588. case 0xE7:
  11589. case 0xE8:
  11590. case 0xE9:
  11591. case 0xEA:
  11592. case 0xEB:
  11593. case 0xEC:
  11594. case 0xED:
  11595. case 0xEE:
  11596. case 0xEF:
  11597. case 0xFE:
  11598. markerLength = stream.getUint16();
  11599. if (markerLength > 2) {
  11600. stream.skip(markerLength - 2);
  11601. } else {
  11602. stream.skip(-2);
  11603. }
  11604. break;
  11605. }
  11606. if (foundEOI) {
  11607. break;
  11608. }
  11609. }
  11610. length = stream.pos - startPos;
  11611. if (b === -1) {
  11612. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  11613. stream.skip(-length);
  11614. return this.findDefaultInlineStreamEnd(stream);
  11615. }
  11616. this.inlineStreamSkipEI(stream);
  11617. return length;
  11618. },
  11619. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  11620. var TILDE = 0x7E, GT = 0x3E;
  11621. var startPos = stream.pos, ch, length;
  11622. while ((ch = stream.getByte()) !== -1) {
  11623. if (ch === TILDE && stream.peekByte() === GT) {
  11624. stream.skip();
  11625. break;
  11626. }
  11627. }
  11628. length = stream.pos - startPos;
  11629. if (ch === -1) {
  11630. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11631. stream.skip(-length);
  11632. return this.findDefaultInlineStreamEnd(stream);
  11633. }
  11634. this.inlineStreamSkipEI(stream);
  11635. return length;
  11636. },
  11637. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  11638. var GT = 0x3E;
  11639. var startPos = stream.pos, ch, length;
  11640. while ((ch = stream.getByte()) !== -1) {
  11641. if (ch === GT) {
  11642. break;
  11643. }
  11644. }
  11645. length = stream.pos - startPos;
  11646. if (ch === -1) {
  11647. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11648. stream.skip(-length);
  11649. return this.findDefaultInlineStreamEnd(stream);
  11650. }
  11651. this.inlineStreamSkipEI(stream);
  11652. return length;
  11653. },
  11654. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  11655. var E = 0x45, I = 0x49;
  11656. var state = 0, ch;
  11657. while ((ch = stream.getByte()) !== -1) {
  11658. if (state === 0) {
  11659. state = ch === E ? 1 : 0;
  11660. } else if (state === 1) {
  11661. state = ch === I ? 2 : 0;
  11662. } else if (state === 2) {
  11663. break;
  11664. }
  11665. }
  11666. },
  11667. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  11668. var lexer = this.lexer;
  11669. var stream = lexer.stream;
  11670. var dict = new Dict(this.xref);
  11671. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  11672. if (!isName(this.buf1)) {
  11673. error('Dictionary key must be a name object');
  11674. }
  11675. var key = this.buf1.name;
  11676. this.shift();
  11677. if (isEOF(this.buf1)) {
  11678. break;
  11679. }
  11680. dict.set(key, this.getObj(cipherTransform));
  11681. }
  11682. var filter = dict.get('Filter', 'F'), filterName;
  11683. if (isName(filter)) {
  11684. filterName = filter.name;
  11685. } else if (isArray(filter)) {
  11686. var filterZero = this.xref.fetchIfRef(filter[0]);
  11687. if (isName(filterZero)) {
  11688. filterName = filterZero.name;
  11689. }
  11690. }
  11691. var startPos = stream.pos, length, i, ii;
  11692. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  11693. length = this.findDCTDecodeInlineStreamEnd(stream);
  11694. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  11695. length = this.findASCII85DecodeInlineStreamEnd(stream);
  11696. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  11697. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  11698. } else {
  11699. length = this.findDefaultInlineStreamEnd(stream);
  11700. }
  11701. var imageStream = stream.makeSubStream(startPos, length, dict);
  11702. var adler32;
  11703. if (length < MAX_LENGTH_TO_CACHE) {
  11704. var imageBytes = imageStream.getBytes();
  11705. imageStream.reset();
  11706. var a = 1;
  11707. var b = 0;
  11708. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  11709. a += imageBytes[i] & 0xff;
  11710. b += a;
  11711. }
  11712. adler32 = b % 65521 << 16 | a % 65521;
  11713. if (this.imageCache.adler32 === adler32) {
  11714. this.buf2 = Cmd.get('EI');
  11715. this.shift();
  11716. this.imageCache[adler32].reset();
  11717. return this.imageCache[adler32];
  11718. }
  11719. }
  11720. if (cipherTransform) {
  11721. imageStream = cipherTransform.createStream(imageStream, length);
  11722. }
  11723. imageStream = this.filter(imageStream, dict, length);
  11724. imageStream.dict = dict;
  11725. if (adler32 !== undefined) {
  11726. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  11727. this.imageCache[adler32] = imageStream;
  11728. }
  11729. this.buf2 = Cmd.get('EI');
  11730. this.shift();
  11731. return imageStream;
  11732. },
  11733. makeStream: function Parser_makeStream(dict, cipherTransform) {
  11734. var lexer = this.lexer;
  11735. var stream = lexer.stream;
  11736. lexer.skipToNextLine();
  11737. var pos = stream.pos - 1;
  11738. var length = dict.get('Length');
  11739. if (!isInt(length)) {
  11740. info('Bad ' + length + ' attribute in stream');
  11741. length = 0;
  11742. }
  11743. stream.pos = pos + length;
  11744. lexer.nextChar();
  11745. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  11746. this.shift();
  11747. } else {
  11748. stream.pos = pos;
  11749. var SCAN_BLOCK_SIZE = 2048;
  11750. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  11751. var ENDSTREAM_SIGNATURE = [
  11752. 0x65,
  11753. 0x6E,
  11754. 0x64,
  11755. 0x73,
  11756. 0x74,
  11757. 0x72,
  11758. 0x65,
  11759. 0x61,
  11760. 0x6D
  11761. ];
  11762. var skipped = 0, found = false, i, j;
  11763. while (stream.pos < stream.end) {
  11764. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  11765. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  11766. if (scanLength <= 0) {
  11767. break;
  11768. }
  11769. found = false;
  11770. i = 0;
  11771. while (i < scanLength) {
  11772. j = 0;
  11773. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  11774. j++;
  11775. }
  11776. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  11777. found = true;
  11778. break;
  11779. }
  11780. i++;
  11781. }
  11782. if (found) {
  11783. skipped += i;
  11784. stream.pos += i;
  11785. break;
  11786. }
  11787. skipped += scanLength;
  11788. stream.pos += scanLength;
  11789. }
  11790. if (!found) {
  11791. error('Missing endstream');
  11792. }
  11793. length = skipped;
  11794. lexer.nextChar();
  11795. this.shift();
  11796. this.shift();
  11797. }
  11798. this.shift();
  11799. stream = stream.makeSubStream(pos, length, dict);
  11800. if (cipherTransform) {
  11801. stream = cipherTransform.createStream(stream, length);
  11802. }
  11803. stream = this.filter(stream, dict, length);
  11804. stream.dict = dict;
  11805. return stream;
  11806. },
  11807. filter: function Parser_filter(stream, dict, length) {
  11808. var filter = dict.get('Filter', 'F');
  11809. var params = dict.get('DecodeParms', 'DP');
  11810. if (isName(filter)) {
  11811. if (isArray(params)) {
  11812. params = this.xref.fetchIfRef(params[0]);
  11813. }
  11814. return this.makeFilter(stream, filter.name, length, params);
  11815. }
  11816. var maybeLength = length;
  11817. if (isArray(filter)) {
  11818. var filterArray = filter;
  11819. var paramsArray = params;
  11820. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  11821. filter = this.xref.fetchIfRef(filterArray[i]);
  11822. if (!isName(filter)) {
  11823. error('Bad filter name: ' + filter);
  11824. }
  11825. params = null;
  11826. if (isArray(paramsArray) && i in paramsArray) {
  11827. params = this.xref.fetchIfRef(paramsArray[i]);
  11828. }
  11829. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  11830. maybeLength = null;
  11831. }
  11832. }
  11833. return stream;
  11834. },
  11835. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  11836. if (maybeLength === 0) {
  11837. warn('Empty "' + name + '" stream.');
  11838. return new NullStream(stream);
  11839. }
  11840. try {
  11841. var xrefStreamStats = this.xref.stats.streamTypes;
  11842. if (name === 'FlateDecode' || name === 'Fl') {
  11843. xrefStreamStats[StreamType.FLATE] = true;
  11844. if (params) {
  11845. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  11846. }
  11847. return new FlateStream(stream, maybeLength);
  11848. }
  11849. if (name === 'LZWDecode' || name === 'LZW') {
  11850. xrefStreamStats[StreamType.LZW] = true;
  11851. var earlyChange = 1;
  11852. if (params) {
  11853. if (params.has('EarlyChange')) {
  11854. earlyChange = params.get('EarlyChange');
  11855. }
  11856. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  11857. }
  11858. return new LZWStream(stream, maybeLength, earlyChange);
  11859. }
  11860. if (name === 'DCTDecode' || name === 'DCT') {
  11861. xrefStreamStats[StreamType.DCT] = true;
  11862. return new JpegStream(stream, maybeLength, stream.dict, params);
  11863. }
  11864. if (name === 'JPXDecode' || name === 'JPX') {
  11865. xrefStreamStats[StreamType.JPX] = true;
  11866. return new JpxStream(stream, maybeLength, stream.dict, params);
  11867. }
  11868. if (name === 'ASCII85Decode' || name === 'A85') {
  11869. xrefStreamStats[StreamType.A85] = true;
  11870. return new Ascii85Stream(stream, maybeLength);
  11871. }
  11872. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  11873. xrefStreamStats[StreamType.AHX] = true;
  11874. return new AsciiHexStream(stream, maybeLength);
  11875. }
  11876. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  11877. xrefStreamStats[StreamType.CCF] = true;
  11878. return new CCITTFaxStream(stream, maybeLength, params);
  11879. }
  11880. if (name === 'RunLengthDecode' || name === 'RL') {
  11881. xrefStreamStats[StreamType.RL] = true;
  11882. return new RunLengthStream(stream, maybeLength);
  11883. }
  11884. if (name === 'JBIG2Decode') {
  11885. xrefStreamStats[StreamType.JBIG] = true;
  11886. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  11887. }
  11888. warn('filter "' + name + '" not supported yet');
  11889. return stream;
  11890. } catch (ex) {
  11891. if (ex instanceof MissingDataException) {
  11892. throw ex;
  11893. }
  11894. warn('Invalid stream: \"' + ex + '\"');
  11895. return new NullStream(stream);
  11896. }
  11897. }
  11898. };
  11899. return Parser;
  11900. }();
  11901. var Lexer = function LexerClosure() {
  11902. function Lexer(stream, knownCommands) {
  11903. this.stream = stream;
  11904. this.nextChar();
  11905. this.strBuf = [];
  11906. this.knownCommands = knownCommands;
  11907. }
  11908. var specialChars = [
  11909. 1,
  11910. 0,
  11911. 0,
  11912. 0,
  11913. 0,
  11914. 0,
  11915. 0,
  11916. 0,
  11917. 0,
  11918. 1,
  11919. 1,
  11920. 0,
  11921. 1,
  11922. 1,
  11923. 0,
  11924. 0,
  11925. 0,
  11926. 0,
  11927. 0,
  11928. 0,
  11929. 0,
  11930. 0,
  11931. 0,
  11932. 0,
  11933. 0,
  11934. 0,
  11935. 0,
  11936. 0,
  11937. 0,
  11938. 0,
  11939. 0,
  11940. 0,
  11941. 1,
  11942. 0,
  11943. 0,
  11944. 0,
  11945. 0,
  11946. 2,
  11947. 0,
  11948. 0,
  11949. 2,
  11950. 2,
  11951. 0,
  11952. 0,
  11953. 0,
  11954. 0,
  11955. 0,
  11956. 2,
  11957. 0,
  11958. 0,
  11959. 0,
  11960. 0,
  11961. 0,
  11962. 0,
  11963. 0,
  11964. 0,
  11965. 0,
  11966. 0,
  11967. 0,
  11968. 0,
  11969. 2,
  11970. 0,
  11971. 2,
  11972. 0,
  11973. 0,
  11974. 0,
  11975. 0,
  11976. 0,
  11977. 0,
  11978. 0,
  11979. 0,
  11980. 0,
  11981. 0,
  11982. 0,
  11983. 0,
  11984. 0,
  11985. 0,
  11986. 0,
  11987. 0,
  11988. 0,
  11989. 0,
  11990. 0,
  11991. 0,
  11992. 0,
  11993. 0,
  11994. 0,
  11995. 0,
  11996. 0,
  11997. 0,
  11998. 0,
  11999. 0,
  12000. 2,
  12001. 0,
  12002. 2,
  12003. 0,
  12004. 0,
  12005. 0,
  12006. 0,
  12007. 0,
  12008. 0,
  12009. 0,
  12010. 0,
  12011. 0,
  12012. 0,
  12013. 0,
  12014. 0,
  12015. 0,
  12016. 0,
  12017. 0,
  12018. 0,
  12019. 0,
  12020. 0,
  12021. 0,
  12022. 0,
  12023. 0,
  12024. 0,
  12025. 0,
  12026. 0,
  12027. 0,
  12028. 0,
  12029. 0,
  12030. 0,
  12031. 0,
  12032. 2,
  12033. 0,
  12034. 2,
  12035. 0,
  12036. 0,
  12037. 0,
  12038. 0,
  12039. 0,
  12040. 0,
  12041. 0,
  12042. 0,
  12043. 0,
  12044. 0,
  12045. 0,
  12046. 0,
  12047. 0,
  12048. 0,
  12049. 0,
  12050. 0,
  12051. 0,
  12052. 0,
  12053. 0,
  12054. 0,
  12055. 0,
  12056. 0,
  12057. 0,
  12058. 0,
  12059. 0,
  12060. 0,
  12061. 0,
  12062. 0,
  12063. 0,
  12064. 0,
  12065. 0,
  12066. 0,
  12067. 0,
  12068. 0,
  12069. 0,
  12070. 0,
  12071. 0,
  12072. 0,
  12073. 0,
  12074. 0,
  12075. 0,
  12076. 0,
  12077. 0,
  12078. 0,
  12079. 0,
  12080. 0,
  12081. 0,
  12082. 0,
  12083. 0,
  12084. 0,
  12085. 0,
  12086. 0,
  12087. 0,
  12088. 0,
  12089. 0,
  12090. 0,
  12091. 0,
  12092. 0,
  12093. 0,
  12094. 0,
  12095. 0,
  12096. 0,
  12097. 0,
  12098. 0,
  12099. 0,
  12100. 0,
  12101. 0,
  12102. 0,
  12103. 0,
  12104. 0,
  12105. 0,
  12106. 0,
  12107. 0,
  12108. 0,
  12109. 0,
  12110. 0,
  12111. 0,
  12112. 0,
  12113. 0,
  12114. 0,
  12115. 0,
  12116. 0,
  12117. 0,
  12118. 0,
  12119. 0,
  12120. 0,
  12121. 0,
  12122. 0,
  12123. 0,
  12124. 0,
  12125. 0,
  12126. 0,
  12127. 0,
  12128. 0,
  12129. 0,
  12130. 0,
  12131. 0,
  12132. 0,
  12133. 0,
  12134. 0,
  12135. 0,
  12136. 0,
  12137. 0,
  12138. 0,
  12139. 0,
  12140. 0,
  12141. 0,
  12142. 0,
  12143. 0,
  12144. 0,
  12145. 0,
  12146. 0,
  12147. 0,
  12148. 0,
  12149. 0,
  12150. 0,
  12151. 0,
  12152. 0,
  12153. 0,
  12154. 0,
  12155. 0,
  12156. 0,
  12157. 0,
  12158. 0,
  12159. 0,
  12160. 0,
  12161. 0,
  12162. 0,
  12163. 0,
  12164. 0
  12165. ];
  12166. function toHexDigit(ch) {
  12167. if (ch >= 0x30 && ch <= 0x39) {
  12168. return ch & 0x0F;
  12169. }
  12170. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12171. return (ch & 0x0F) + 9;
  12172. }
  12173. return -1;
  12174. }
  12175. Lexer.prototype = {
  12176. nextChar: function Lexer_nextChar() {
  12177. return this.currentChar = this.stream.getByte();
  12178. },
  12179. peekChar: function Lexer_peekChar() {
  12180. return this.stream.peekByte();
  12181. },
  12182. getNumber: function Lexer_getNumber() {
  12183. var ch = this.currentChar;
  12184. var eNotation = false;
  12185. var divideBy = 0;
  12186. var sign = 1;
  12187. if (ch === 0x2D) {
  12188. sign = -1;
  12189. ch = this.nextChar();
  12190. if (ch === 0x2D) {
  12191. ch = this.nextChar();
  12192. }
  12193. } else if (ch === 0x2B) {
  12194. ch = this.nextChar();
  12195. }
  12196. if (ch === 0x2E) {
  12197. divideBy = 10;
  12198. ch = this.nextChar();
  12199. }
  12200. if (ch < 0x30 || ch > 0x39) {
  12201. error('Invalid number: ' + String.fromCharCode(ch));
  12202. return 0;
  12203. }
  12204. var baseValue = ch - 0x30;
  12205. var powerValue = 0;
  12206. var powerValueSign = 1;
  12207. while ((ch = this.nextChar()) >= 0) {
  12208. if (0x30 <= ch && ch <= 0x39) {
  12209. var currentDigit = ch - 0x30;
  12210. if (eNotation) {
  12211. powerValue = powerValue * 10 + currentDigit;
  12212. } else {
  12213. if (divideBy !== 0) {
  12214. divideBy *= 10;
  12215. }
  12216. baseValue = baseValue * 10 + currentDigit;
  12217. }
  12218. } else if (ch === 0x2E) {
  12219. if (divideBy === 0) {
  12220. divideBy = 1;
  12221. } else {
  12222. break;
  12223. }
  12224. } else if (ch === 0x2D) {
  12225. warn('Badly formatted number');
  12226. } else if (ch === 0x45 || ch === 0x65) {
  12227. ch = this.peekChar();
  12228. if (ch === 0x2B || ch === 0x2D) {
  12229. powerValueSign = ch === 0x2D ? -1 : 1;
  12230. this.nextChar();
  12231. } else if (ch < 0x30 || ch > 0x39) {
  12232. break;
  12233. }
  12234. eNotation = true;
  12235. } else {
  12236. break;
  12237. }
  12238. }
  12239. if (divideBy !== 0) {
  12240. baseValue /= divideBy;
  12241. }
  12242. if (eNotation) {
  12243. baseValue *= Math.pow(10, powerValueSign * powerValue);
  12244. }
  12245. return sign * baseValue;
  12246. },
  12247. getString: function Lexer_getString() {
  12248. var numParen = 1;
  12249. var done = false;
  12250. var strBuf = this.strBuf;
  12251. strBuf.length = 0;
  12252. var ch = this.nextChar();
  12253. while (true) {
  12254. var charBuffered = false;
  12255. switch (ch | 0) {
  12256. case -1:
  12257. warn('Unterminated string');
  12258. done = true;
  12259. break;
  12260. case 0x28:
  12261. ++numParen;
  12262. strBuf.push('(');
  12263. break;
  12264. case 0x29:
  12265. if (--numParen === 0) {
  12266. this.nextChar();
  12267. done = true;
  12268. } else {
  12269. strBuf.push(')');
  12270. }
  12271. break;
  12272. case 0x5C:
  12273. ch = this.nextChar();
  12274. switch (ch) {
  12275. case -1:
  12276. warn('Unterminated string');
  12277. done = true;
  12278. break;
  12279. case 0x6E:
  12280. strBuf.push('\n');
  12281. break;
  12282. case 0x72:
  12283. strBuf.push('\r');
  12284. break;
  12285. case 0x74:
  12286. strBuf.push('\t');
  12287. break;
  12288. case 0x62:
  12289. strBuf.push('\b');
  12290. break;
  12291. case 0x66:
  12292. strBuf.push('\f');
  12293. break;
  12294. case 0x5C:
  12295. case 0x28:
  12296. case 0x29:
  12297. strBuf.push(String.fromCharCode(ch));
  12298. break;
  12299. case 0x30:
  12300. case 0x31:
  12301. case 0x32:
  12302. case 0x33:
  12303. case 0x34:
  12304. case 0x35:
  12305. case 0x36:
  12306. case 0x37:
  12307. var x = ch & 0x0F;
  12308. ch = this.nextChar();
  12309. charBuffered = true;
  12310. if (ch >= 0x30 && ch <= 0x37) {
  12311. x = (x << 3) + (ch & 0x0F);
  12312. ch = this.nextChar();
  12313. if (ch >= 0x30 && ch <= 0x37) {
  12314. charBuffered = false;
  12315. x = (x << 3) + (ch & 0x0F);
  12316. }
  12317. }
  12318. strBuf.push(String.fromCharCode(x));
  12319. break;
  12320. case 0x0D:
  12321. if (this.peekChar() === 0x0A) {
  12322. this.nextChar();
  12323. }
  12324. break;
  12325. case 0x0A:
  12326. break;
  12327. default:
  12328. strBuf.push(String.fromCharCode(ch));
  12329. break;
  12330. }
  12331. break;
  12332. default:
  12333. strBuf.push(String.fromCharCode(ch));
  12334. break;
  12335. }
  12336. if (done) {
  12337. break;
  12338. }
  12339. if (!charBuffered) {
  12340. ch = this.nextChar();
  12341. }
  12342. }
  12343. return strBuf.join('');
  12344. },
  12345. getName: function Lexer_getName() {
  12346. var ch, previousCh;
  12347. var strBuf = this.strBuf;
  12348. strBuf.length = 0;
  12349. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12350. if (ch === 0x23) {
  12351. ch = this.nextChar();
  12352. if (specialChars[ch]) {
  12353. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  12354. strBuf.push('#');
  12355. break;
  12356. }
  12357. var x = toHexDigit(ch);
  12358. if (x !== -1) {
  12359. previousCh = ch;
  12360. ch = this.nextChar();
  12361. var x2 = toHexDigit(ch);
  12362. if (x2 === -1) {
  12363. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  12364. strBuf.push('#', String.fromCharCode(previousCh));
  12365. if (specialChars[ch]) {
  12366. break;
  12367. }
  12368. strBuf.push(String.fromCharCode(ch));
  12369. continue;
  12370. }
  12371. strBuf.push(String.fromCharCode(x << 4 | x2));
  12372. } else {
  12373. strBuf.push('#', String.fromCharCode(ch));
  12374. }
  12375. } else {
  12376. strBuf.push(String.fromCharCode(ch));
  12377. }
  12378. }
  12379. if (strBuf.length > 127) {
  12380. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  12381. }
  12382. return Name.get(strBuf.join(''));
  12383. },
  12384. getHexString: function Lexer_getHexString() {
  12385. var strBuf = this.strBuf;
  12386. strBuf.length = 0;
  12387. var ch = this.currentChar;
  12388. var isFirstHex = true;
  12389. var firstDigit;
  12390. var secondDigit;
  12391. while (true) {
  12392. if (ch < 0) {
  12393. warn('Unterminated hex string');
  12394. break;
  12395. } else if (ch === 0x3E) {
  12396. this.nextChar();
  12397. break;
  12398. } else if (specialChars[ch] === 1) {
  12399. ch = this.nextChar();
  12400. continue;
  12401. } else {
  12402. if (isFirstHex) {
  12403. firstDigit = toHexDigit(ch);
  12404. if (firstDigit === -1) {
  12405. warn('Ignoring invalid character "' + ch + '" in hex string');
  12406. ch = this.nextChar();
  12407. continue;
  12408. }
  12409. } else {
  12410. secondDigit = toHexDigit(ch);
  12411. if (secondDigit === -1) {
  12412. warn('Ignoring invalid character "' + ch + '" in hex string');
  12413. ch = this.nextChar();
  12414. continue;
  12415. }
  12416. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  12417. }
  12418. isFirstHex = !isFirstHex;
  12419. ch = this.nextChar();
  12420. }
  12421. }
  12422. return strBuf.join('');
  12423. },
  12424. getObj: function Lexer_getObj() {
  12425. var comment = false;
  12426. var ch = this.currentChar;
  12427. while (true) {
  12428. if (ch < 0) {
  12429. return EOF;
  12430. }
  12431. if (comment) {
  12432. if (ch === 0x0A || ch === 0x0D) {
  12433. comment = false;
  12434. }
  12435. } else if (ch === 0x25) {
  12436. comment = true;
  12437. } else if (specialChars[ch] !== 1) {
  12438. break;
  12439. }
  12440. ch = this.nextChar();
  12441. }
  12442. switch (ch | 0) {
  12443. case 0x30:
  12444. case 0x31:
  12445. case 0x32:
  12446. case 0x33:
  12447. case 0x34:
  12448. case 0x35:
  12449. case 0x36:
  12450. case 0x37:
  12451. case 0x38:
  12452. case 0x39:
  12453. case 0x2B:
  12454. case 0x2D:
  12455. case 0x2E:
  12456. return this.getNumber();
  12457. case 0x28:
  12458. return this.getString();
  12459. case 0x2F:
  12460. return this.getName();
  12461. case 0x5B:
  12462. this.nextChar();
  12463. return Cmd.get('[');
  12464. case 0x5D:
  12465. this.nextChar();
  12466. return Cmd.get(']');
  12467. case 0x3C:
  12468. ch = this.nextChar();
  12469. if (ch === 0x3C) {
  12470. this.nextChar();
  12471. return Cmd.get('<<');
  12472. }
  12473. return this.getHexString();
  12474. case 0x3E:
  12475. ch = this.nextChar();
  12476. if (ch === 0x3E) {
  12477. this.nextChar();
  12478. return Cmd.get('>>');
  12479. }
  12480. return Cmd.get('>');
  12481. case 0x7B:
  12482. this.nextChar();
  12483. return Cmd.get('{');
  12484. case 0x7D:
  12485. this.nextChar();
  12486. return Cmd.get('}');
  12487. case 0x29:
  12488. this.nextChar();
  12489. error('Illegal character: ' + ch);
  12490. break;
  12491. }
  12492. var str = String.fromCharCode(ch);
  12493. var knownCommands = this.knownCommands;
  12494. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12495. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12496. var possibleCommand = str + String.fromCharCode(ch);
  12497. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  12498. break;
  12499. }
  12500. if (str.length === 128) {
  12501. error('Command token too long: ' + str.length);
  12502. }
  12503. str = possibleCommand;
  12504. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12505. }
  12506. if (str === 'true') {
  12507. return true;
  12508. }
  12509. if (str === 'false') {
  12510. return false;
  12511. }
  12512. if (str === 'null') {
  12513. return null;
  12514. }
  12515. return Cmd.get(str);
  12516. },
  12517. skipToNextLine: function Lexer_skipToNextLine() {
  12518. var ch = this.currentChar;
  12519. while (ch >= 0) {
  12520. if (ch === 0x0D) {
  12521. ch = this.nextChar();
  12522. if (ch === 0x0A) {
  12523. this.nextChar();
  12524. }
  12525. break;
  12526. } else if (ch === 0x0A) {
  12527. this.nextChar();
  12528. break;
  12529. }
  12530. ch = this.nextChar();
  12531. }
  12532. }
  12533. };
  12534. return Lexer;
  12535. }();
  12536. var Linearization = {
  12537. create: function LinearizationCreate(stream) {
  12538. function getInt(name, allowZeroValue) {
  12539. var obj = linDict.get(name);
  12540. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  12541. return obj;
  12542. }
  12543. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  12544. }
  12545. function getHints() {
  12546. var hints = linDict.get('H'), hintsLength, item;
  12547. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  12548. for (var index = 0; index < hintsLength; index++) {
  12549. if (!(isInt(item = hints[index]) && item > 0)) {
  12550. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  12551. }
  12552. }
  12553. return hints;
  12554. }
  12555. throw new Error('Hint array in the linearization dictionary is invalid.');
  12556. }
  12557. var parser = new Parser(new Lexer(stream), false, null);
  12558. var obj1 = parser.getObj();
  12559. var obj2 = parser.getObj();
  12560. var obj3 = parser.getObj();
  12561. var linDict = parser.getObj();
  12562. var obj, length;
  12563. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  12564. return null;
  12565. } else if ((length = getInt('L')) !== stream.length) {
  12566. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  12567. }
  12568. return {
  12569. length: length,
  12570. hints: getHints(),
  12571. objectNumberFirst: getInt('O'),
  12572. endFirst: getInt('E'),
  12573. numPages: getInt('N'),
  12574. mainXRefEntriesOffset: getInt('T'),
  12575. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  12576. };
  12577. }
  12578. };
  12579. exports.Lexer = Lexer;
  12580. exports.Linearization = Linearization;
  12581. exports.Parser = Parser;
  12582. /***/ }),
  12583. /* 7 */
  12584. /***/ (function(module, exports, __w_pdfjs_require__) {
  12585. "use strict";
  12586. var sharedUtil = __w_pdfjs_require__(0);
  12587. var corePrimitives = __w_pdfjs_require__(1);
  12588. var corePsParser = __w_pdfjs_require__(42);
  12589. var error = sharedUtil.error;
  12590. var info = sharedUtil.info;
  12591. var isArray = sharedUtil.isArray;
  12592. var isBool = sharedUtil.isBool;
  12593. var isDict = corePrimitives.isDict;
  12594. var isStream = corePrimitives.isStream;
  12595. var PostScriptLexer = corePsParser.PostScriptLexer;
  12596. var PostScriptParser = corePsParser.PostScriptParser;
  12597. var PDFFunction = function PDFFunctionClosure() {
  12598. var CONSTRUCT_SAMPLED = 0;
  12599. var CONSTRUCT_INTERPOLATED = 2;
  12600. var CONSTRUCT_STICHED = 3;
  12601. var CONSTRUCT_POSTSCRIPT = 4;
  12602. return {
  12603. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  12604. var i, ii;
  12605. var length = 1;
  12606. for (i = 0, ii = size.length; i < ii; i++) {
  12607. length *= size[i];
  12608. }
  12609. length *= outputSize;
  12610. var array = new Array(length);
  12611. var codeSize = 0;
  12612. var codeBuf = 0;
  12613. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  12614. var strBytes = str.getBytes((length * bps + 7) / 8);
  12615. var strIdx = 0;
  12616. for (i = 0; i < length; i++) {
  12617. while (codeSize < bps) {
  12618. codeBuf <<= 8;
  12619. codeBuf |= strBytes[strIdx++];
  12620. codeSize += 8;
  12621. }
  12622. codeSize -= bps;
  12623. array[i] = (codeBuf >> codeSize) * sampleMul;
  12624. codeBuf &= (1 << codeSize) - 1;
  12625. }
  12626. return array;
  12627. },
  12628. getIR: function PDFFunction_getIR(xref, fn) {
  12629. var dict = fn.dict;
  12630. if (!dict) {
  12631. dict = fn;
  12632. }
  12633. var types = [
  12634. this.constructSampled,
  12635. null,
  12636. this.constructInterpolated,
  12637. this.constructStiched,
  12638. this.constructPostScript
  12639. ];
  12640. var typeNum = dict.get('FunctionType');
  12641. var typeFn = types[typeNum];
  12642. if (!typeFn) {
  12643. error('Unknown type of function');
  12644. }
  12645. return typeFn.call(this, fn, dict, xref);
  12646. },
  12647. fromIR: function PDFFunction_fromIR(IR) {
  12648. var type = IR[0];
  12649. switch (type) {
  12650. case CONSTRUCT_SAMPLED:
  12651. return this.constructSampledFromIR(IR);
  12652. case CONSTRUCT_INTERPOLATED:
  12653. return this.constructInterpolatedFromIR(IR);
  12654. case CONSTRUCT_STICHED:
  12655. return this.constructStichedFromIR(IR);
  12656. default:
  12657. return this.constructPostScriptFromIR(IR);
  12658. }
  12659. },
  12660. parse: function PDFFunction_parse(xref, fn) {
  12661. var IR = this.getIR(xref, fn);
  12662. return this.fromIR(IR);
  12663. },
  12664. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  12665. if (!isArray(fnObj)) {
  12666. return this.parse(xref, fnObj);
  12667. }
  12668. var fnArray = [];
  12669. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  12670. var obj = xref.fetchIfRef(fnObj[j]);
  12671. fnArray.push(PDFFunction.parse(xref, obj));
  12672. }
  12673. return function (src, srcOffset, dest, destOffset) {
  12674. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  12675. fnArray[i](src, srcOffset, dest, destOffset + i);
  12676. }
  12677. };
  12678. },
  12679. constructSampled: function PDFFunction_constructSampled(str, dict) {
  12680. function toMultiArray(arr) {
  12681. var inputLength = arr.length;
  12682. var out = [];
  12683. var index = 0;
  12684. for (var i = 0; i < inputLength; i += 2) {
  12685. out[index] = [
  12686. arr[i],
  12687. arr[i + 1]
  12688. ];
  12689. ++index;
  12690. }
  12691. return out;
  12692. }
  12693. var domain = dict.getArray('Domain');
  12694. var range = dict.getArray('Range');
  12695. if (!domain || !range) {
  12696. error('No domain or range');
  12697. }
  12698. var inputSize = domain.length / 2;
  12699. var outputSize = range.length / 2;
  12700. domain = toMultiArray(domain);
  12701. range = toMultiArray(range);
  12702. var size = dict.get('Size');
  12703. var bps = dict.get('BitsPerSample');
  12704. var order = dict.get('Order') || 1;
  12705. if (order !== 1) {
  12706. info('No support for cubic spline interpolation: ' + order);
  12707. }
  12708. var encode = dict.getArray('Encode');
  12709. if (!encode) {
  12710. encode = [];
  12711. for (var i = 0; i < inputSize; ++i) {
  12712. encode.push(0);
  12713. encode.push(size[i] - 1);
  12714. }
  12715. }
  12716. encode = toMultiArray(encode);
  12717. var decode = dict.getArray('Decode');
  12718. if (!decode) {
  12719. decode = range;
  12720. } else {
  12721. decode = toMultiArray(decode);
  12722. }
  12723. var samples = this.getSampleArray(size, outputSize, bps, str);
  12724. return [
  12725. CONSTRUCT_SAMPLED,
  12726. inputSize,
  12727. domain,
  12728. encode,
  12729. decode,
  12730. samples,
  12731. size,
  12732. outputSize,
  12733. Math.pow(2, bps) - 1,
  12734. range
  12735. ];
  12736. },
  12737. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  12738. function interpolate(x, xmin, xmax, ymin, ymax) {
  12739. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  12740. }
  12741. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  12742. var m = IR[1];
  12743. var domain = IR[2];
  12744. var encode = IR[3];
  12745. var decode = IR[4];
  12746. var samples = IR[5];
  12747. var size = IR[6];
  12748. var n = IR[7];
  12749. var range = IR[9];
  12750. var cubeVertices = 1 << m;
  12751. var cubeN = new Float64Array(cubeVertices);
  12752. var cubeVertex = new Uint32Array(cubeVertices);
  12753. var i, j;
  12754. for (j = 0; j < cubeVertices; j++) {
  12755. cubeN[j] = 1;
  12756. }
  12757. var k = n, pos = 1;
  12758. for (i = 0; i < m; ++i) {
  12759. var domain_2i = domain[i][0];
  12760. var domain_2i_1 = domain[i][1];
  12761. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  12762. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  12763. var size_i = size[i];
  12764. e = Math.min(Math.max(e, 0), size_i - 1);
  12765. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  12766. var n0 = e0 + 1 - e;
  12767. var n1 = e - e0;
  12768. var offset0 = e0 * k;
  12769. var offset1 = offset0 + k;
  12770. for (j = 0; j < cubeVertices; j++) {
  12771. if (j & pos) {
  12772. cubeN[j] *= n1;
  12773. cubeVertex[j] += offset1;
  12774. } else {
  12775. cubeN[j] *= n0;
  12776. cubeVertex[j] += offset0;
  12777. }
  12778. }
  12779. k *= size_i;
  12780. pos <<= 1;
  12781. }
  12782. for (j = 0; j < n; ++j) {
  12783. var rj = 0;
  12784. for (i = 0; i < cubeVertices; i++) {
  12785. rj += samples[cubeVertex[i] + j] * cubeN[i];
  12786. }
  12787. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  12788. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  12789. }
  12790. };
  12791. },
  12792. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  12793. var c0 = dict.getArray('C0') || [0];
  12794. var c1 = dict.getArray('C1') || [1];
  12795. var n = dict.get('N');
  12796. if (!isArray(c0) || !isArray(c1)) {
  12797. error('Illegal dictionary for interpolated function');
  12798. }
  12799. var length = c0.length;
  12800. var diff = [];
  12801. for (var i = 0; i < length; ++i) {
  12802. diff.push(c1[i] - c0[i]);
  12803. }
  12804. return [
  12805. CONSTRUCT_INTERPOLATED,
  12806. c0,
  12807. diff,
  12808. n
  12809. ];
  12810. },
  12811. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  12812. var c0 = IR[1];
  12813. var diff = IR[2];
  12814. var n = IR[3];
  12815. var length = diff.length;
  12816. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  12817. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  12818. for (var j = 0; j < length; ++j) {
  12819. dest[destOffset + j] = c0[j] + x * diff[j];
  12820. }
  12821. };
  12822. },
  12823. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  12824. var domain = dict.getArray('Domain');
  12825. if (!domain) {
  12826. error('No domain');
  12827. }
  12828. var inputSize = domain.length / 2;
  12829. if (inputSize !== 1) {
  12830. error('Bad domain for stiched function');
  12831. }
  12832. var fnRefs = dict.get('Functions');
  12833. var fns = [];
  12834. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  12835. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  12836. }
  12837. var bounds = dict.getArray('Bounds');
  12838. var encode = dict.getArray('Encode');
  12839. return [
  12840. CONSTRUCT_STICHED,
  12841. domain,
  12842. bounds,
  12843. encode,
  12844. fns
  12845. ];
  12846. },
  12847. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  12848. var domain = IR[1];
  12849. var bounds = IR[2];
  12850. var encode = IR[3];
  12851. var fnsIR = IR[4];
  12852. var fns = [];
  12853. var tmpBuf = new Float32Array(1);
  12854. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  12855. fns.push(PDFFunction.fromIR(fnsIR[i]));
  12856. }
  12857. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  12858. var clip = function constructStichedFromIRClip(v, min, max) {
  12859. if (v > max) {
  12860. v = max;
  12861. } else if (v < min) {
  12862. v = min;
  12863. }
  12864. return v;
  12865. };
  12866. var v = clip(src[srcOffset], domain[0], domain[1]);
  12867. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  12868. if (v < bounds[i]) {
  12869. break;
  12870. }
  12871. }
  12872. var dmin = domain[0];
  12873. if (i > 0) {
  12874. dmin = bounds[i - 1];
  12875. }
  12876. var dmax = domain[1];
  12877. if (i < bounds.length) {
  12878. dmax = bounds[i];
  12879. }
  12880. var rmin = encode[2 * i];
  12881. var rmax = encode[2 * i + 1];
  12882. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  12883. fns[i](tmpBuf, 0, dest, destOffset);
  12884. };
  12885. },
  12886. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  12887. var domain = dict.getArray('Domain');
  12888. var range = dict.getArray('Range');
  12889. if (!domain) {
  12890. error('No domain.');
  12891. }
  12892. if (!range) {
  12893. error('No range.');
  12894. }
  12895. var lexer = new PostScriptLexer(fn);
  12896. var parser = new PostScriptParser(lexer);
  12897. var code = parser.parse();
  12898. return [
  12899. CONSTRUCT_POSTSCRIPT,
  12900. domain,
  12901. range,
  12902. code
  12903. ];
  12904. },
  12905. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  12906. var domain = IR[1];
  12907. var range = IR[2];
  12908. var code = IR[3];
  12909. var compiled = new PostScriptCompiler().compile(code, domain, range);
  12910. if (compiled) {
  12911. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  12912. }
  12913. info('Unable to compile PS function');
  12914. var numOutputs = range.length >> 1;
  12915. var numInputs = domain.length >> 1;
  12916. var evaluator = new PostScriptEvaluator(code);
  12917. var cache = Object.create(null);
  12918. var MAX_CACHE_SIZE = 2048 * 4;
  12919. var cache_available = MAX_CACHE_SIZE;
  12920. var tmpBuf = new Float32Array(numInputs);
  12921. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  12922. var i, value;
  12923. var key = '';
  12924. var input = tmpBuf;
  12925. for (i = 0; i < numInputs; i++) {
  12926. value = src[srcOffset + i];
  12927. input[i] = value;
  12928. key += value + '_';
  12929. }
  12930. var cachedValue = cache[key];
  12931. if (cachedValue !== undefined) {
  12932. dest.set(cachedValue, destOffset);
  12933. return;
  12934. }
  12935. var output = new Float32Array(numOutputs);
  12936. var stack = evaluator.execute(input);
  12937. var stackIndex = stack.length - numOutputs;
  12938. for (i = 0; i < numOutputs; i++) {
  12939. value = stack[stackIndex + i];
  12940. var bound = range[i * 2];
  12941. if (value < bound) {
  12942. value = bound;
  12943. } else {
  12944. bound = range[i * 2 + 1];
  12945. if (value > bound) {
  12946. value = bound;
  12947. }
  12948. }
  12949. output[i] = value;
  12950. }
  12951. if (cache_available > 0) {
  12952. cache_available--;
  12953. cache[key] = output;
  12954. }
  12955. dest.set(output, destOffset);
  12956. };
  12957. }
  12958. };
  12959. }();
  12960. function isPDFFunction(v) {
  12961. var fnDict;
  12962. if (typeof v !== 'object') {
  12963. return false;
  12964. } else if (isDict(v)) {
  12965. fnDict = v;
  12966. } else if (isStream(v)) {
  12967. fnDict = v.dict;
  12968. } else {
  12969. return false;
  12970. }
  12971. return fnDict.has('FunctionType');
  12972. }
  12973. var PostScriptStack = function PostScriptStackClosure() {
  12974. var MAX_STACK_SIZE = 100;
  12975. function PostScriptStack(initialStack) {
  12976. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  12977. }
  12978. PostScriptStack.prototype = {
  12979. push: function PostScriptStack_push(value) {
  12980. if (this.stack.length >= MAX_STACK_SIZE) {
  12981. error('PostScript function stack overflow.');
  12982. }
  12983. this.stack.push(value);
  12984. },
  12985. pop: function PostScriptStack_pop() {
  12986. if (this.stack.length <= 0) {
  12987. error('PostScript function stack underflow.');
  12988. }
  12989. return this.stack.pop();
  12990. },
  12991. copy: function PostScriptStack_copy(n) {
  12992. if (this.stack.length + n >= MAX_STACK_SIZE) {
  12993. error('PostScript function stack overflow.');
  12994. }
  12995. var stack = this.stack;
  12996. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  12997. stack.push(stack[i]);
  12998. }
  12999. },
  13000. index: function PostScriptStack_index(n) {
  13001. this.push(this.stack[this.stack.length - n - 1]);
  13002. },
  13003. roll: function PostScriptStack_roll(n, p) {
  13004. var stack = this.stack;
  13005. var l = stack.length - n;
  13006. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13007. for (i = l, j = r; i < j; i++, j--) {
  13008. t = stack[i];
  13009. stack[i] = stack[j];
  13010. stack[j] = t;
  13011. }
  13012. for (i = l, j = c - 1; i < j; i++, j--) {
  13013. t = stack[i];
  13014. stack[i] = stack[j];
  13015. stack[j] = t;
  13016. }
  13017. for (i = c, j = r; i < j; i++, j--) {
  13018. t = stack[i];
  13019. stack[i] = stack[j];
  13020. stack[j] = t;
  13021. }
  13022. }
  13023. };
  13024. return PostScriptStack;
  13025. }();
  13026. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13027. function PostScriptEvaluator(operators) {
  13028. this.operators = operators;
  13029. }
  13030. PostScriptEvaluator.prototype = {
  13031. execute: function PostScriptEvaluator_execute(initialStack) {
  13032. var stack = new PostScriptStack(initialStack);
  13033. var counter = 0;
  13034. var operators = this.operators;
  13035. var length = operators.length;
  13036. var operator, a, b;
  13037. while (counter < length) {
  13038. operator = operators[counter++];
  13039. if (typeof operator === 'number') {
  13040. stack.push(operator);
  13041. continue;
  13042. }
  13043. switch (operator) {
  13044. case 'jz':
  13045. b = stack.pop();
  13046. a = stack.pop();
  13047. if (!a) {
  13048. counter = b;
  13049. }
  13050. break;
  13051. case 'j':
  13052. a = stack.pop();
  13053. counter = a;
  13054. break;
  13055. case 'abs':
  13056. a = stack.pop();
  13057. stack.push(Math.abs(a));
  13058. break;
  13059. case 'add':
  13060. b = stack.pop();
  13061. a = stack.pop();
  13062. stack.push(a + b);
  13063. break;
  13064. case 'and':
  13065. b = stack.pop();
  13066. a = stack.pop();
  13067. if (isBool(a) && isBool(b)) {
  13068. stack.push(a && b);
  13069. } else {
  13070. stack.push(a & b);
  13071. }
  13072. break;
  13073. case 'atan':
  13074. a = stack.pop();
  13075. stack.push(Math.atan(a));
  13076. break;
  13077. case 'bitshift':
  13078. b = stack.pop();
  13079. a = stack.pop();
  13080. if (a > 0) {
  13081. stack.push(a << b);
  13082. } else {
  13083. stack.push(a >> b);
  13084. }
  13085. break;
  13086. case 'ceiling':
  13087. a = stack.pop();
  13088. stack.push(Math.ceil(a));
  13089. break;
  13090. case 'copy':
  13091. a = stack.pop();
  13092. stack.copy(a);
  13093. break;
  13094. case 'cos':
  13095. a = stack.pop();
  13096. stack.push(Math.cos(a));
  13097. break;
  13098. case 'cvi':
  13099. a = stack.pop() | 0;
  13100. stack.push(a);
  13101. break;
  13102. case 'cvr':
  13103. break;
  13104. case 'div':
  13105. b = stack.pop();
  13106. a = stack.pop();
  13107. stack.push(a / b);
  13108. break;
  13109. case 'dup':
  13110. stack.copy(1);
  13111. break;
  13112. case 'eq':
  13113. b = stack.pop();
  13114. a = stack.pop();
  13115. stack.push(a === b);
  13116. break;
  13117. case 'exch':
  13118. stack.roll(2, 1);
  13119. break;
  13120. case 'exp':
  13121. b = stack.pop();
  13122. a = stack.pop();
  13123. stack.push(Math.pow(a, b));
  13124. break;
  13125. case 'false':
  13126. stack.push(false);
  13127. break;
  13128. case 'floor':
  13129. a = stack.pop();
  13130. stack.push(Math.floor(a));
  13131. break;
  13132. case 'ge':
  13133. b = stack.pop();
  13134. a = stack.pop();
  13135. stack.push(a >= b);
  13136. break;
  13137. case 'gt':
  13138. b = stack.pop();
  13139. a = stack.pop();
  13140. stack.push(a > b);
  13141. break;
  13142. case 'idiv':
  13143. b = stack.pop();
  13144. a = stack.pop();
  13145. stack.push(a / b | 0);
  13146. break;
  13147. case 'index':
  13148. a = stack.pop();
  13149. stack.index(a);
  13150. break;
  13151. case 'le':
  13152. b = stack.pop();
  13153. a = stack.pop();
  13154. stack.push(a <= b);
  13155. break;
  13156. case 'ln':
  13157. a = stack.pop();
  13158. stack.push(Math.log(a));
  13159. break;
  13160. case 'log':
  13161. a = stack.pop();
  13162. stack.push(Math.log(a) / Math.LN10);
  13163. break;
  13164. case 'lt':
  13165. b = stack.pop();
  13166. a = stack.pop();
  13167. stack.push(a < b);
  13168. break;
  13169. case 'mod':
  13170. b = stack.pop();
  13171. a = stack.pop();
  13172. stack.push(a % b);
  13173. break;
  13174. case 'mul':
  13175. b = stack.pop();
  13176. a = stack.pop();
  13177. stack.push(a * b);
  13178. break;
  13179. case 'ne':
  13180. b = stack.pop();
  13181. a = stack.pop();
  13182. stack.push(a !== b);
  13183. break;
  13184. case 'neg':
  13185. a = stack.pop();
  13186. stack.push(-a);
  13187. break;
  13188. case 'not':
  13189. a = stack.pop();
  13190. if (isBool(a)) {
  13191. stack.push(!a);
  13192. } else {
  13193. stack.push(~a);
  13194. }
  13195. break;
  13196. case 'or':
  13197. b = stack.pop();
  13198. a = stack.pop();
  13199. if (isBool(a) && isBool(b)) {
  13200. stack.push(a || b);
  13201. } else {
  13202. stack.push(a | b);
  13203. }
  13204. break;
  13205. case 'pop':
  13206. stack.pop();
  13207. break;
  13208. case 'roll':
  13209. b = stack.pop();
  13210. a = stack.pop();
  13211. stack.roll(a, b);
  13212. break;
  13213. case 'round':
  13214. a = stack.pop();
  13215. stack.push(Math.round(a));
  13216. break;
  13217. case 'sin':
  13218. a = stack.pop();
  13219. stack.push(Math.sin(a));
  13220. break;
  13221. case 'sqrt':
  13222. a = stack.pop();
  13223. stack.push(Math.sqrt(a));
  13224. break;
  13225. case 'sub':
  13226. b = stack.pop();
  13227. a = stack.pop();
  13228. stack.push(a - b);
  13229. break;
  13230. case 'true':
  13231. stack.push(true);
  13232. break;
  13233. case 'truncate':
  13234. a = stack.pop();
  13235. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13236. stack.push(a);
  13237. break;
  13238. case 'xor':
  13239. b = stack.pop();
  13240. a = stack.pop();
  13241. if (isBool(a) && isBool(b)) {
  13242. stack.push(a !== b);
  13243. } else {
  13244. stack.push(a ^ b);
  13245. }
  13246. break;
  13247. default:
  13248. error('Unknown operator ' + operator);
  13249. break;
  13250. }
  13251. }
  13252. return stack.stack;
  13253. }
  13254. };
  13255. return PostScriptEvaluator;
  13256. }();
  13257. var PostScriptCompiler = function PostScriptCompilerClosure() {
  13258. function AstNode(type) {
  13259. this.type = type;
  13260. }
  13261. AstNode.prototype.visit = function (visitor) {
  13262. throw new Error('abstract method');
  13263. };
  13264. function AstArgument(index, min, max) {
  13265. AstNode.call(this, 'args');
  13266. this.index = index;
  13267. this.min = min;
  13268. this.max = max;
  13269. }
  13270. AstArgument.prototype = Object.create(AstNode.prototype);
  13271. AstArgument.prototype.visit = function (visitor) {
  13272. visitor.visitArgument(this);
  13273. };
  13274. function AstLiteral(number) {
  13275. AstNode.call(this, 'literal');
  13276. this.number = number;
  13277. this.min = number;
  13278. this.max = number;
  13279. }
  13280. AstLiteral.prototype = Object.create(AstNode.prototype);
  13281. AstLiteral.prototype.visit = function (visitor) {
  13282. visitor.visitLiteral(this);
  13283. };
  13284. function AstBinaryOperation(op, arg1, arg2, min, max) {
  13285. AstNode.call(this, 'binary');
  13286. this.op = op;
  13287. this.arg1 = arg1;
  13288. this.arg2 = arg2;
  13289. this.min = min;
  13290. this.max = max;
  13291. }
  13292. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  13293. AstBinaryOperation.prototype.visit = function (visitor) {
  13294. visitor.visitBinaryOperation(this);
  13295. };
  13296. function AstMin(arg, max) {
  13297. AstNode.call(this, 'max');
  13298. this.arg = arg;
  13299. this.min = arg.min;
  13300. this.max = max;
  13301. }
  13302. AstMin.prototype = Object.create(AstNode.prototype);
  13303. AstMin.prototype.visit = function (visitor) {
  13304. visitor.visitMin(this);
  13305. };
  13306. function AstVariable(index, min, max) {
  13307. AstNode.call(this, 'var');
  13308. this.index = index;
  13309. this.min = min;
  13310. this.max = max;
  13311. }
  13312. AstVariable.prototype = Object.create(AstNode.prototype);
  13313. AstVariable.prototype.visit = function (visitor) {
  13314. visitor.visitVariable(this);
  13315. };
  13316. function AstVariableDefinition(variable, arg) {
  13317. AstNode.call(this, 'definition');
  13318. this.variable = variable;
  13319. this.arg = arg;
  13320. }
  13321. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  13322. AstVariableDefinition.prototype.visit = function (visitor) {
  13323. visitor.visitVariableDefinition(this);
  13324. };
  13325. function ExpressionBuilderVisitor() {
  13326. this.parts = [];
  13327. }
  13328. ExpressionBuilderVisitor.prototype = {
  13329. visitArgument: function (arg) {
  13330. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  13331. },
  13332. visitVariable: function (variable) {
  13333. this.parts.push('v', variable.index);
  13334. },
  13335. visitLiteral: function (literal) {
  13336. this.parts.push(literal.number);
  13337. },
  13338. visitBinaryOperation: function (operation) {
  13339. this.parts.push('(');
  13340. operation.arg1.visit(this);
  13341. this.parts.push(' ', operation.op, ' ');
  13342. operation.arg2.visit(this);
  13343. this.parts.push(')');
  13344. },
  13345. visitVariableDefinition: function (definition) {
  13346. this.parts.push('var ');
  13347. definition.variable.visit(this);
  13348. this.parts.push(' = ');
  13349. definition.arg.visit(this);
  13350. this.parts.push(';');
  13351. },
  13352. visitMin: function (max) {
  13353. this.parts.push('Math.min(');
  13354. max.arg.visit(this);
  13355. this.parts.push(', ', max.max, ')');
  13356. },
  13357. toString: function () {
  13358. return this.parts.join('');
  13359. }
  13360. };
  13361. function buildAddOperation(num1, num2) {
  13362. if (num2.type === 'literal' && num2.number === 0) {
  13363. return num1;
  13364. }
  13365. if (num1.type === 'literal' && num1.number === 0) {
  13366. return num2;
  13367. }
  13368. if (num2.type === 'literal' && num1.type === 'literal') {
  13369. return new AstLiteral(num1.number + num2.number);
  13370. }
  13371. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  13372. }
  13373. function buildMulOperation(num1, num2) {
  13374. if (num2.type === 'literal') {
  13375. if (num2.number === 0) {
  13376. return new AstLiteral(0);
  13377. } else if (num2.number === 1) {
  13378. return num1;
  13379. } else if (num1.type === 'literal') {
  13380. return new AstLiteral(num1.number * num2.number);
  13381. }
  13382. }
  13383. if (num1.type === 'literal') {
  13384. if (num1.number === 0) {
  13385. return new AstLiteral(0);
  13386. } else if (num1.number === 1) {
  13387. return num2;
  13388. }
  13389. }
  13390. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13391. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13392. return new AstBinaryOperation('*', num1, num2, min, max);
  13393. }
  13394. function buildSubOperation(num1, num2) {
  13395. if (num2.type === 'literal') {
  13396. if (num2.number === 0) {
  13397. return num1;
  13398. } else if (num1.type === 'literal') {
  13399. return new AstLiteral(num1.number - num2.number);
  13400. }
  13401. }
  13402. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  13403. return num2.arg2;
  13404. }
  13405. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  13406. }
  13407. function buildMinOperation(num1, max) {
  13408. if (num1.min >= max) {
  13409. return new AstLiteral(max);
  13410. } else if (num1.max <= max) {
  13411. return num1;
  13412. }
  13413. return new AstMin(num1, max);
  13414. }
  13415. function PostScriptCompiler() {
  13416. }
  13417. PostScriptCompiler.prototype = {
  13418. compile: function PostScriptCompiler_compile(code, domain, range) {
  13419. var stack = [];
  13420. var i, ii;
  13421. var instructions = [];
  13422. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  13423. var lastRegister = 0;
  13424. var n, j;
  13425. var num1, num2, ast1, ast2, tmpVar, item;
  13426. for (i = 0; i < inputSize; i++) {
  13427. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  13428. }
  13429. for (i = 0, ii = code.length; i < ii; i++) {
  13430. item = code[i];
  13431. if (typeof item === 'number') {
  13432. stack.push(new AstLiteral(item));
  13433. continue;
  13434. }
  13435. switch (item) {
  13436. case 'add':
  13437. if (stack.length < 2) {
  13438. return null;
  13439. }
  13440. num2 = stack.pop();
  13441. num1 = stack.pop();
  13442. stack.push(buildAddOperation(num1, num2));
  13443. break;
  13444. case 'cvr':
  13445. if (stack.length < 1) {
  13446. return null;
  13447. }
  13448. break;
  13449. case 'mul':
  13450. if (stack.length < 2) {
  13451. return null;
  13452. }
  13453. num2 = stack.pop();
  13454. num1 = stack.pop();
  13455. stack.push(buildMulOperation(num1, num2));
  13456. break;
  13457. case 'sub':
  13458. if (stack.length < 2) {
  13459. return null;
  13460. }
  13461. num2 = stack.pop();
  13462. num1 = stack.pop();
  13463. stack.push(buildSubOperation(num1, num2));
  13464. break;
  13465. case 'exch':
  13466. if (stack.length < 2) {
  13467. return null;
  13468. }
  13469. ast1 = stack.pop();
  13470. ast2 = stack.pop();
  13471. stack.push(ast1, ast2);
  13472. break;
  13473. case 'pop':
  13474. if (stack.length < 1) {
  13475. return null;
  13476. }
  13477. stack.pop();
  13478. break;
  13479. case 'index':
  13480. if (stack.length < 1) {
  13481. return null;
  13482. }
  13483. num1 = stack.pop();
  13484. if (num1.type !== 'literal') {
  13485. return null;
  13486. }
  13487. n = num1.number;
  13488. if (n < 0 || (n | 0) !== n || stack.length < n) {
  13489. return null;
  13490. }
  13491. ast1 = stack[stack.length - n - 1];
  13492. if (ast1.type === 'literal' || ast1.type === 'var') {
  13493. stack.push(ast1);
  13494. break;
  13495. }
  13496. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13497. stack[stack.length - n - 1] = tmpVar;
  13498. stack.push(tmpVar);
  13499. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13500. break;
  13501. case 'dup':
  13502. if (stack.length < 1) {
  13503. return null;
  13504. }
  13505. if (typeof code[i + 1] === 'number' && code[i + 2] === 'gt' && code[i + 3] === i + 7 && code[i + 4] === 'jz' && code[i + 5] === 'pop' && code[i + 6] === code[i + 1]) {
  13506. num1 = stack.pop();
  13507. stack.push(buildMinOperation(num1, code[i + 1]));
  13508. i += 6;
  13509. break;
  13510. }
  13511. ast1 = stack[stack.length - 1];
  13512. if (ast1.type === 'literal' || ast1.type === 'var') {
  13513. stack.push(ast1);
  13514. break;
  13515. }
  13516. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13517. stack[stack.length - 1] = tmpVar;
  13518. stack.push(tmpVar);
  13519. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13520. break;
  13521. case 'roll':
  13522. if (stack.length < 2) {
  13523. return null;
  13524. }
  13525. num2 = stack.pop();
  13526. num1 = stack.pop();
  13527. if (num2.type !== 'literal' || num1.type !== 'literal') {
  13528. return null;
  13529. }
  13530. j = num2.number;
  13531. n = num1.number;
  13532. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  13533. return null;
  13534. }
  13535. j = (j % n + n) % n;
  13536. if (j === 0) {
  13537. break;
  13538. }
  13539. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  13540. break;
  13541. default:
  13542. return null;
  13543. }
  13544. }
  13545. if (stack.length !== outputSize) {
  13546. return null;
  13547. }
  13548. var result = [];
  13549. instructions.forEach(function (instruction) {
  13550. var statementBuilder = new ExpressionBuilderVisitor();
  13551. instruction.visit(statementBuilder);
  13552. result.push(statementBuilder.toString());
  13553. });
  13554. stack.forEach(function (expr, i) {
  13555. var statementBuilder = new ExpressionBuilderVisitor();
  13556. expr.visit(statementBuilder);
  13557. var min = range[i * 2], max = range[i * 2 + 1];
  13558. var out = [statementBuilder.toString()];
  13559. if (min > expr.min) {
  13560. out.unshift('Math.max(', min, ', ');
  13561. out.push(')');
  13562. }
  13563. if (max < expr.max) {
  13564. out.unshift('Math.min(', max, ', ');
  13565. out.push(')');
  13566. }
  13567. out.unshift('dest[destOffset + ', i, '] = ');
  13568. out.push(';');
  13569. result.push(out.join(''));
  13570. });
  13571. return result.join('\n');
  13572. }
  13573. };
  13574. return PostScriptCompiler;
  13575. }();
  13576. exports.isPDFFunction = isPDFFunction;
  13577. exports.PDFFunction = PDFFunction;
  13578. exports.PostScriptEvaluator = PostScriptEvaluator;
  13579. exports.PostScriptCompiler = PostScriptCompiler;
  13580. /***/ }),
  13581. /* 8 */
  13582. /***/ (function(module, exports, __w_pdfjs_require__) {
  13583. "use strict";
  13584. var sharedUtil = __w_pdfjs_require__(0);
  13585. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  13586. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  13587. t['A'] = 0x0041;
  13588. t['AE'] = 0x00C6;
  13589. t['AEacute'] = 0x01FC;
  13590. t['AEmacron'] = 0x01E2;
  13591. t['AEsmall'] = 0xF7E6;
  13592. t['Aacute'] = 0x00C1;
  13593. t['Aacutesmall'] = 0xF7E1;
  13594. t['Abreve'] = 0x0102;
  13595. t['Abreveacute'] = 0x1EAE;
  13596. t['Abrevecyrillic'] = 0x04D0;
  13597. t['Abrevedotbelow'] = 0x1EB6;
  13598. t['Abrevegrave'] = 0x1EB0;
  13599. t['Abrevehookabove'] = 0x1EB2;
  13600. t['Abrevetilde'] = 0x1EB4;
  13601. t['Acaron'] = 0x01CD;
  13602. t['Acircle'] = 0x24B6;
  13603. t['Acircumflex'] = 0x00C2;
  13604. t['Acircumflexacute'] = 0x1EA4;
  13605. t['Acircumflexdotbelow'] = 0x1EAC;
  13606. t['Acircumflexgrave'] = 0x1EA6;
  13607. t['Acircumflexhookabove'] = 0x1EA8;
  13608. t['Acircumflexsmall'] = 0xF7E2;
  13609. t['Acircumflextilde'] = 0x1EAA;
  13610. t['Acute'] = 0xF6C9;
  13611. t['Acutesmall'] = 0xF7B4;
  13612. t['Acyrillic'] = 0x0410;
  13613. t['Adblgrave'] = 0x0200;
  13614. t['Adieresis'] = 0x00C4;
  13615. t['Adieresiscyrillic'] = 0x04D2;
  13616. t['Adieresismacron'] = 0x01DE;
  13617. t['Adieresissmall'] = 0xF7E4;
  13618. t['Adotbelow'] = 0x1EA0;
  13619. t['Adotmacron'] = 0x01E0;
  13620. t['Agrave'] = 0x00C0;
  13621. t['Agravesmall'] = 0xF7E0;
  13622. t['Ahookabove'] = 0x1EA2;
  13623. t['Aiecyrillic'] = 0x04D4;
  13624. t['Ainvertedbreve'] = 0x0202;
  13625. t['Alpha'] = 0x0391;
  13626. t['Alphatonos'] = 0x0386;
  13627. t['Amacron'] = 0x0100;
  13628. t['Amonospace'] = 0xFF21;
  13629. t['Aogonek'] = 0x0104;
  13630. t['Aring'] = 0x00C5;
  13631. t['Aringacute'] = 0x01FA;
  13632. t['Aringbelow'] = 0x1E00;
  13633. t['Aringsmall'] = 0xF7E5;
  13634. t['Asmall'] = 0xF761;
  13635. t['Atilde'] = 0x00C3;
  13636. t['Atildesmall'] = 0xF7E3;
  13637. t['Aybarmenian'] = 0x0531;
  13638. t['B'] = 0x0042;
  13639. t['Bcircle'] = 0x24B7;
  13640. t['Bdotaccent'] = 0x1E02;
  13641. t['Bdotbelow'] = 0x1E04;
  13642. t['Becyrillic'] = 0x0411;
  13643. t['Benarmenian'] = 0x0532;
  13644. t['Beta'] = 0x0392;
  13645. t['Bhook'] = 0x0181;
  13646. t['Blinebelow'] = 0x1E06;
  13647. t['Bmonospace'] = 0xFF22;
  13648. t['Brevesmall'] = 0xF6F4;
  13649. t['Bsmall'] = 0xF762;
  13650. t['Btopbar'] = 0x0182;
  13651. t['C'] = 0x0043;
  13652. t['Caarmenian'] = 0x053E;
  13653. t['Cacute'] = 0x0106;
  13654. t['Caron'] = 0xF6CA;
  13655. t['Caronsmall'] = 0xF6F5;
  13656. t['Ccaron'] = 0x010C;
  13657. t['Ccedilla'] = 0x00C7;
  13658. t['Ccedillaacute'] = 0x1E08;
  13659. t['Ccedillasmall'] = 0xF7E7;
  13660. t['Ccircle'] = 0x24B8;
  13661. t['Ccircumflex'] = 0x0108;
  13662. t['Cdot'] = 0x010A;
  13663. t['Cdotaccent'] = 0x010A;
  13664. t['Cedillasmall'] = 0xF7B8;
  13665. t['Chaarmenian'] = 0x0549;
  13666. t['Cheabkhasiancyrillic'] = 0x04BC;
  13667. t['Checyrillic'] = 0x0427;
  13668. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  13669. t['Chedescendercyrillic'] = 0x04B6;
  13670. t['Chedieresiscyrillic'] = 0x04F4;
  13671. t['Cheharmenian'] = 0x0543;
  13672. t['Chekhakassiancyrillic'] = 0x04CB;
  13673. t['Cheverticalstrokecyrillic'] = 0x04B8;
  13674. t['Chi'] = 0x03A7;
  13675. t['Chook'] = 0x0187;
  13676. t['Circumflexsmall'] = 0xF6F6;
  13677. t['Cmonospace'] = 0xFF23;
  13678. t['Coarmenian'] = 0x0551;
  13679. t['Csmall'] = 0xF763;
  13680. t['D'] = 0x0044;
  13681. t['DZ'] = 0x01F1;
  13682. t['DZcaron'] = 0x01C4;
  13683. t['Daarmenian'] = 0x0534;
  13684. t['Dafrican'] = 0x0189;
  13685. t['Dcaron'] = 0x010E;
  13686. t['Dcedilla'] = 0x1E10;
  13687. t['Dcircle'] = 0x24B9;
  13688. t['Dcircumflexbelow'] = 0x1E12;
  13689. t['Dcroat'] = 0x0110;
  13690. t['Ddotaccent'] = 0x1E0A;
  13691. t['Ddotbelow'] = 0x1E0C;
  13692. t['Decyrillic'] = 0x0414;
  13693. t['Deicoptic'] = 0x03EE;
  13694. t['Delta'] = 0x2206;
  13695. t['Deltagreek'] = 0x0394;
  13696. t['Dhook'] = 0x018A;
  13697. t['Dieresis'] = 0xF6CB;
  13698. t['DieresisAcute'] = 0xF6CC;
  13699. t['DieresisGrave'] = 0xF6CD;
  13700. t['Dieresissmall'] = 0xF7A8;
  13701. t['Digammagreek'] = 0x03DC;
  13702. t['Djecyrillic'] = 0x0402;
  13703. t['Dlinebelow'] = 0x1E0E;
  13704. t['Dmonospace'] = 0xFF24;
  13705. t['Dotaccentsmall'] = 0xF6F7;
  13706. t['Dslash'] = 0x0110;
  13707. t['Dsmall'] = 0xF764;
  13708. t['Dtopbar'] = 0x018B;
  13709. t['Dz'] = 0x01F2;
  13710. t['Dzcaron'] = 0x01C5;
  13711. t['Dzeabkhasiancyrillic'] = 0x04E0;
  13712. t['Dzecyrillic'] = 0x0405;
  13713. t['Dzhecyrillic'] = 0x040F;
  13714. t['E'] = 0x0045;
  13715. t['Eacute'] = 0x00C9;
  13716. t['Eacutesmall'] = 0xF7E9;
  13717. t['Ebreve'] = 0x0114;
  13718. t['Ecaron'] = 0x011A;
  13719. t['Ecedillabreve'] = 0x1E1C;
  13720. t['Echarmenian'] = 0x0535;
  13721. t['Ecircle'] = 0x24BA;
  13722. t['Ecircumflex'] = 0x00CA;
  13723. t['Ecircumflexacute'] = 0x1EBE;
  13724. t['Ecircumflexbelow'] = 0x1E18;
  13725. t['Ecircumflexdotbelow'] = 0x1EC6;
  13726. t['Ecircumflexgrave'] = 0x1EC0;
  13727. t['Ecircumflexhookabove'] = 0x1EC2;
  13728. t['Ecircumflexsmall'] = 0xF7EA;
  13729. t['Ecircumflextilde'] = 0x1EC4;
  13730. t['Ecyrillic'] = 0x0404;
  13731. t['Edblgrave'] = 0x0204;
  13732. t['Edieresis'] = 0x00CB;
  13733. t['Edieresissmall'] = 0xF7EB;
  13734. t['Edot'] = 0x0116;
  13735. t['Edotaccent'] = 0x0116;
  13736. t['Edotbelow'] = 0x1EB8;
  13737. t['Efcyrillic'] = 0x0424;
  13738. t['Egrave'] = 0x00C8;
  13739. t['Egravesmall'] = 0xF7E8;
  13740. t['Eharmenian'] = 0x0537;
  13741. t['Ehookabove'] = 0x1EBA;
  13742. t['Eightroman'] = 0x2167;
  13743. t['Einvertedbreve'] = 0x0206;
  13744. t['Eiotifiedcyrillic'] = 0x0464;
  13745. t['Elcyrillic'] = 0x041B;
  13746. t['Elevenroman'] = 0x216A;
  13747. t['Emacron'] = 0x0112;
  13748. t['Emacronacute'] = 0x1E16;
  13749. t['Emacrongrave'] = 0x1E14;
  13750. t['Emcyrillic'] = 0x041C;
  13751. t['Emonospace'] = 0xFF25;
  13752. t['Encyrillic'] = 0x041D;
  13753. t['Endescendercyrillic'] = 0x04A2;
  13754. t['Eng'] = 0x014A;
  13755. t['Enghecyrillic'] = 0x04A4;
  13756. t['Enhookcyrillic'] = 0x04C7;
  13757. t['Eogonek'] = 0x0118;
  13758. t['Eopen'] = 0x0190;
  13759. t['Epsilon'] = 0x0395;
  13760. t['Epsilontonos'] = 0x0388;
  13761. t['Ercyrillic'] = 0x0420;
  13762. t['Ereversed'] = 0x018E;
  13763. t['Ereversedcyrillic'] = 0x042D;
  13764. t['Escyrillic'] = 0x0421;
  13765. t['Esdescendercyrillic'] = 0x04AA;
  13766. t['Esh'] = 0x01A9;
  13767. t['Esmall'] = 0xF765;
  13768. t['Eta'] = 0x0397;
  13769. t['Etarmenian'] = 0x0538;
  13770. t['Etatonos'] = 0x0389;
  13771. t['Eth'] = 0x00D0;
  13772. t['Ethsmall'] = 0xF7F0;
  13773. t['Etilde'] = 0x1EBC;
  13774. t['Etildebelow'] = 0x1E1A;
  13775. t['Euro'] = 0x20AC;
  13776. t['Ezh'] = 0x01B7;
  13777. t['Ezhcaron'] = 0x01EE;
  13778. t['Ezhreversed'] = 0x01B8;
  13779. t['F'] = 0x0046;
  13780. t['Fcircle'] = 0x24BB;
  13781. t['Fdotaccent'] = 0x1E1E;
  13782. t['Feharmenian'] = 0x0556;
  13783. t['Feicoptic'] = 0x03E4;
  13784. t['Fhook'] = 0x0191;
  13785. t['Fitacyrillic'] = 0x0472;
  13786. t['Fiveroman'] = 0x2164;
  13787. t['Fmonospace'] = 0xFF26;
  13788. t['Fourroman'] = 0x2163;
  13789. t['Fsmall'] = 0xF766;
  13790. t['G'] = 0x0047;
  13791. t['GBsquare'] = 0x3387;
  13792. t['Gacute'] = 0x01F4;
  13793. t['Gamma'] = 0x0393;
  13794. t['Gammaafrican'] = 0x0194;
  13795. t['Gangiacoptic'] = 0x03EA;
  13796. t['Gbreve'] = 0x011E;
  13797. t['Gcaron'] = 0x01E6;
  13798. t['Gcedilla'] = 0x0122;
  13799. t['Gcircle'] = 0x24BC;
  13800. t['Gcircumflex'] = 0x011C;
  13801. t['Gcommaaccent'] = 0x0122;
  13802. t['Gdot'] = 0x0120;
  13803. t['Gdotaccent'] = 0x0120;
  13804. t['Gecyrillic'] = 0x0413;
  13805. t['Ghadarmenian'] = 0x0542;
  13806. t['Ghemiddlehookcyrillic'] = 0x0494;
  13807. t['Ghestrokecyrillic'] = 0x0492;
  13808. t['Gheupturncyrillic'] = 0x0490;
  13809. t['Ghook'] = 0x0193;
  13810. t['Gimarmenian'] = 0x0533;
  13811. t['Gjecyrillic'] = 0x0403;
  13812. t['Gmacron'] = 0x1E20;
  13813. t['Gmonospace'] = 0xFF27;
  13814. t['Grave'] = 0xF6CE;
  13815. t['Gravesmall'] = 0xF760;
  13816. t['Gsmall'] = 0xF767;
  13817. t['Gsmallhook'] = 0x029B;
  13818. t['Gstroke'] = 0x01E4;
  13819. t['H'] = 0x0048;
  13820. t['H18533'] = 0x25CF;
  13821. t['H18543'] = 0x25AA;
  13822. t['H18551'] = 0x25AB;
  13823. t['H22073'] = 0x25A1;
  13824. t['HPsquare'] = 0x33CB;
  13825. t['Haabkhasiancyrillic'] = 0x04A8;
  13826. t['Hadescendercyrillic'] = 0x04B2;
  13827. t['Hardsigncyrillic'] = 0x042A;
  13828. t['Hbar'] = 0x0126;
  13829. t['Hbrevebelow'] = 0x1E2A;
  13830. t['Hcedilla'] = 0x1E28;
  13831. t['Hcircle'] = 0x24BD;
  13832. t['Hcircumflex'] = 0x0124;
  13833. t['Hdieresis'] = 0x1E26;
  13834. t['Hdotaccent'] = 0x1E22;
  13835. t['Hdotbelow'] = 0x1E24;
  13836. t['Hmonospace'] = 0xFF28;
  13837. t['Hoarmenian'] = 0x0540;
  13838. t['Horicoptic'] = 0x03E8;
  13839. t['Hsmall'] = 0xF768;
  13840. t['Hungarumlaut'] = 0xF6CF;
  13841. t['Hungarumlautsmall'] = 0xF6F8;
  13842. t['Hzsquare'] = 0x3390;
  13843. t['I'] = 0x0049;
  13844. t['IAcyrillic'] = 0x042F;
  13845. t['IJ'] = 0x0132;
  13846. t['IUcyrillic'] = 0x042E;
  13847. t['Iacute'] = 0x00CD;
  13848. t['Iacutesmall'] = 0xF7ED;
  13849. t['Ibreve'] = 0x012C;
  13850. t['Icaron'] = 0x01CF;
  13851. t['Icircle'] = 0x24BE;
  13852. t['Icircumflex'] = 0x00CE;
  13853. t['Icircumflexsmall'] = 0xF7EE;
  13854. t['Icyrillic'] = 0x0406;
  13855. t['Idblgrave'] = 0x0208;
  13856. t['Idieresis'] = 0x00CF;
  13857. t['Idieresisacute'] = 0x1E2E;
  13858. t['Idieresiscyrillic'] = 0x04E4;
  13859. t['Idieresissmall'] = 0xF7EF;
  13860. t['Idot'] = 0x0130;
  13861. t['Idotaccent'] = 0x0130;
  13862. t['Idotbelow'] = 0x1ECA;
  13863. t['Iebrevecyrillic'] = 0x04D6;
  13864. t['Iecyrillic'] = 0x0415;
  13865. t['Ifraktur'] = 0x2111;
  13866. t['Igrave'] = 0x00CC;
  13867. t['Igravesmall'] = 0xF7EC;
  13868. t['Ihookabove'] = 0x1EC8;
  13869. t['Iicyrillic'] = 0x0418;
  13870. t['Iinvertedbreve'] = 0x020A;
  13871. t['Iishortcyrillic'] = 0x0419;
  13872. t['Imacron'] = 0x012A;
  13873. t['Imacroncyrillic'] = 0x04E2;
  13874. t['Imonospace'] = 0xFF29;
  13875. t['Iniarmenian'] = 0x053B;
  13876. t['Iocyrillic'] = 0x0401;
  13877. t['Iogonek'] = 0x012E;
  13878. t['Iota'] = 0x0399;
  13879. t['Iotaafrican'] = 0x0196;
  13880. t['Iotadieresis'] = 0x03AA;
  13881. t['Iotatonos'] = 0x038A;
  13882. t['Ismall'] = 0xF769;
  13883. t['Istroke'] = 0x0197;
  13884. t['Itilde'] = 0x0128;
  13885. t['Itildebelow'] = 0x1E2C;
  13886. t['Izhitsacyrillic'] = 0x0474;
  13887. t['Izhitsadblgravecyrillic'] = 0x0476;
  13888. t['J'] = 0x004A;
  13889. t['Jaarmenian'] = 0x0541;
  13890. t['Jcircle'] = 0x24BF;
  13891. t['Jcircumflex'] = 0x0134;
  13892. t['Jecyrillic'] = 0x0408;
  13893. t['Jheharmenian'] = 0x054B;
  13894. t['Jmonospace'] = 0xFF2A;
  13895. t['Jsmall'] = 0xF76A;
  13896. t['K'] = 0x004B;
  13897. t['KBsquare'] = 0x3385;
  13898. t['KKsquare'] = 0x33CD;
  13899. t['Kabashkircyrillic'] = 0x04A0;
  13900. t['Kacute'] = 0x1E30;
  13901. t['Kacyrillic'] = 0x041A;
  13902. t['Kadescendercyrillic'] = 0x049A;
  13903. t['Kahookcyrillic'] = 0x04C3;
  13904. t['Kappa'] = 0x039A;
  13905. t['Kastrokecyrillic'] = 0x049E;
  13906. t['Kaverticalstrokecyrillic'] = 0x049C;
  13907. t['Kcaron'] = 0x01E8;
  13908. t['Kcedilla'] = 0x0136;
  13909. t['Kcircle'] = 0x24C0;
  13910. t['Kcommaaccent'] = 0x0136;
  13911. t['Kdotbelow'] = 0x1E32;
  13912. t['Keharmenian'] = 0x0554;
  13913. t['Kenarmenian'] = 0x053F;
  13914. t['Khacyrillic'] = 0x0425;
  13915. t['Kheicoptic'] = 0x03E6;
  13916. t['Khook'] = 0x0198;
  13917. t['Kjecyrillic'] = 0x040C;
  13918. t['Klinebelow'] = 0x1E34;
  13919. t['Kmonospace'] = 0xFF2B;
  13920. t['Koppacyrillic'] = 0x0480;
  13921. t['Koppagreek'] = 0x03DE;
  13922. t['Ksicyrillic'] = 0x046E;
  13923. t['Ksmall'] = 0xF76B;
  13924. t['L'] = 0x004C;
  13925. t['LJ'] = 0x01C7;
  13926. t['LL'] = 0xF6BF;
  13927. t['Lacute'] = 0x0139;
  13928. t['Lambda'] = 0x039B;
  13929. t['Lcaron'] = 0x013D;
  13930. t['Lcedilla'] = 0x013B;
  13931. t['Lcircle'] = 0x24C1;
  13932. t['Lcircumflexbelow'] = 0x1E3C;
  13933. t['Lcommaaccent'] = 0x013B;
  13934. t['Ldot'] = 0x013F;
  13935. t['Ldotaccent'] = 0x013F;
  13936. t['Ldotbelow'] = 0x1E36;
  13937. t['Ldotbelowmacron'] = 0x1E38;
  13938. t['Liwnarmenian'] = 0x053C;
  13939. t['Lj'] = 0x01C8;
  13940. t['Ljecyrillic'] = 0x0409;
  13941. t['Llinebelow'] = 0x1E3A;
  13942. t['Lmonospace'] = 0xFF2C;
  13943. t['Lslash'] = 0x0141;
  13944. t['Lslashsmall'] = 0xF6F9;
  13945. t['Lsmall'] = 0xF76C;
  13946. t['M'] = 0x004D;
  13947. t['MBsquare'] = 0x3386;
  13948. t['Macron'] = 0xF6D0;
  13949. t['Macronsmall'] = 0xF7AF;
  13950. t['Macute'] = 0x1E3E;
  13951. t['Mcircle'] = 0x24C2;
  13952. t['Mdotaccent'] = 0x1E40;
  13953. t['Mdotbelow'] = 0x1E42;
  13954. t['Menarmenian'] = 0x0544;
  13955. t['Mmonospace'] = 0xFF2D;
  13956. t['Msmall'] = 0xF76D;
  13957. t['Mturned'] = 0x019C;
  13958. t['Mu'] = 0x039C;
  13959. t['N'] = 0x004E;
  13960. t['NJ'] = 0x01CA;
  13961. t['Nacute'] = 0x0143;
  13962. t['Ncaron'] = 0x0147;
  13963. t['Ncedilla'] = 0x0145;
  13964. t['Ncircle'] = 0x24C3;
  13965. t['Ncircumflexbelow'] = 0x1E4A;
  13966. t['Ncommaaccent'] = 0x0145;
  13967. t['Ndotaccent'] = 0x1E44;
  13968. t['Ndotbelow'] = 0x1E46;
  13969. t['Nhookleft'] = 0x019D;
  13970. t['Nineroman'] = 0x2168;
  13971. t['Nj'] = 0x01CB;
  13972. t['Njecyrillic'] = 0x040A;
  13973. t['Nlinebelow'] = 0x1E48;
  13974. t['Nmonospace'] = 0xFF2E;
  13975. t['Nowarmenian'] = 0x0546;
  13976. t['Nsmall'] = 0xF76E;
  13977. t['Ntilde'] = 0x00D1;
  13978. t['Ntildesmall'] = 0xF7F1;
  13979. t['Nu'] = 0x039D;
  13980. t['O'] = 0x004F;
  13981. t['OE'] = 0x0152;
  13982. t['OEsmall'] = 0xF6FA;
  13983. t['Oacute'] = 0x00D3;
  13984. t['Oacutesmall'] = 0xF7F3;
  13985. t['Obarredcyrillic'] = 0x04E8;
  13986. t['Obarreddieresiscyrillic'] = 0x04EA;
  13987. t['Obreve'] = 0x014E;
  13988. t['Ocaron'] = 0x01D1;
  13989. t['Ocenteredtilde'] = 0x019F;
  13990. t['Ocircle'] = 0x24C4;
  13991. t['Ocircumflex'] = 0x00D4;
  13992. t['Ocircumflexacute'] = 0x1ED0;
  13993. t['Ocircumflexdotbelow'] = 0x1ED8;
  13994. t['Ocircumflexgrave'] = 0x1ED2;
  13995. t['Ocircumflexhookabove'] = 0x1ED4;
  13996. t['Ocircumflexsmall'] = 0xF7F4;
  13997. t['Ocircumflextilde'] = 0x1ED6;
  13998. t['Ocyrillic'] = 0x041E;
  13999. t['Odblacute'] = 0x0150;
  14000. t['Odblgrave'] = 0x020C;
  14001. t['Odieresis'] = 0x00D6;
  14002. t['Odieresiscyrillic'] = 0x04E6;
  14003. t['Odieresissmall'] = 0xF7F6;
  14004. t['Odotbelow'] = 0x1ECC;
  14005. t['Ogoneksmall'] = 0xF6FB;
  14006. t['Ograve'] = 0x00D2;
  14007. t['Ogravesmall'] = 0xF7F2;
  14008. t['Oharmenian'] = 0x0555;
  14009. t['Ohm'] = 0x2126;
  14010. t['Ohookabove'] = 0x1ECE;
  14011. t['Ohorn'] = 0x01A0;
  14012. t['Ohornacute'] = 0x1EDA;
  14013. t['Ohorndotbelow'] = 0x1EE2;
  14014. t['Ohorngrave'] = 0x1EDC;
  14015. t['Ohornhookabove'] = 0x1EDE;
  14016. t['Ohorntilde'] = 0x1EE0;
  14017. t['Ohungarumlaut'] = 0x0150;
  14018. t['Oi'] = 0x01A2;
  14019. t['Oinvertedbreve'] = 0x020E;
  14020. t['Omacron'] = 0x014C;
  14021. t['Omacronacute'] = 0x1E52;
  14022. t['Omacrongrave'] = 0x1E50;
  14023. t['Omega'] = 0x2126;
  14024. t['Omegacyrillic'] = 0x0460;
  14025. t['Omegagreek'] = 0x03A9;
  14026. t['Omegaroundcyrillic'] = 0x047A;
  14027. t['Omegatitlocyrillic'] = 0x047C;
  14028. t['Omegatonos'] = 0x038F;
  14029. t['Omicron'] = 0x039F;
  14030. t['Omicrontonos'] = 0x038C;
  14031. t['Omonospace'] = 0xFF2F;
  14032. t['Oneroman'] = 0x2160;
  14033. t['Oogonek'] = 0x01EA;
  14034. t['Oogonekmacron'] = 0x01EC;
  14035. t['Oopen'] = 0x0186;
  14036. t['Oslash'] = 0x00D8;
  14037. t['Oslashacute'] = 0x01FE;
  14038. t['Oslashsmall'] = 0xF7F8;
  14039. t['Osmall'] = 0xF76F;
  14040. t['Ostrokeacute'] = 0x01FE;
  14041. t['Otcyrillic'] = 0x047E;
  14042. t['Otilde'] = 0x00D5;
  14043. t['Otildeacute'] = 0x1E4C;
  14044. t['Otildedieresis'] = 0x1E4E;
  14045. t['Otildesmall'] = 0xF7F5;
  14046. t['P'] = 0x0050;
  14047. t['Pacute'] = 0x1E54;
  14048. t['Pcircle'] = 0x24C5;
  14049. t['Pdotaccent'] = 0x1E56;
  14050. t['Pecyrillic'] = 0x041F;
  14051. t['Peharmenian'] = 0x054A;
  14052. t['Pemiddlehookcyrillic'] = 0x04A6;
  14053. t['Phi'] = 0x03A6;
  14054. t['Phook'] = 0x01A4;
  14055. t['Pi'] = 0x03A0;
  14056. t['Piwrarmenian'] = 0x0553;
  14057. t['Pmonospace'] = 0xFF30;
  14058. t['Psi'] = 0x03A8;
  14059. t['Psicyrillic'] = 0x0470;
  14060. t['Psmall'] = 0xF770;
  14061. t['Q'] = 0x0051;
  14062. t['Qcircle'] = 0x24C6;
  14063. t['Qmonospace'] = 0xFF31;
  14064. t['Qsmall'] = 0xF771;
  14065. t['R'] = 0x0052;
  14066. t['Raarmenian'] = 0x054C;
  14067. t['Racute'] = 0x0154;
  14068. t['Rcaron'] = 0x0158;
  14069. t['Rcedilla'] = 0x0156;
  14070. t['Rcircle'] = 0x24C7;
  14071. t['Rcommaaccent'] = 0x0156;
  14072. t['Rdblgrave'] = 0x0210;
  14073. t['Rdotaccent'] = 0x1E58;
  14074. t['Rdotbelow'] = 0x1E5A;
  14075. t['Rdotbelowmacron'] = 0x1E5C;
  14076. t['Reharmenian'] = 0x0550;
  14077. t['Rfraktur'] = 0x211C;
  14078. t['Rho'] = 0x03A1;
  14079. t['Ringsmall'] = 0xF6FC;
  14080. t['Rinvertedbreve'] = 0x0212;
  14081. t['Rlinebelow'] = 0x1E5E;
  14082. t['Rmonospace'] = 0xFF32;
  14083. t['Rsmall'] = 0xF772;
  14084. t['Rsmallinverted'] = 0x0281;
  14085. t['Rsmallinvertedsuperior'] = 0x02B6;
  14086. t['S'] = 0x0053;
  14087. t['SF010000'] = 0x250C;
  14088. t['SF020000'] = 0x2514;
  14089. t['SF030000'] = 0x2510;
  14090. t['SF040000'] = 0x2518;
  14091. t['SF050000'] = 0x253C;
  14092. t['SF060000'] = 0x252C;
  14093. t['SF070000'] = 0x2534;
  14094. t['SF080000'] = 0x251C;
  14095. t['SF090000'] = 0x2524;
  14096. t['SF100000'] = 0x2500;
  14097. t['SF110000'] = 0x2502;
  14098. t['SF190000'] = 0x2561;
  14099. t['SF200000'] = 0x2562;
  14100. t['SF210000'] = 0x2556;
  14101. t['SF220000'] = 0x2555;
  14102. t['SF230000'] = 0x2563;
  14103. t['SF240000'] = 0x2551;
  14104. t['SF250000'] = 0x2557;
  14105. t['SF260000'] = 0x255D;
  14106. t['SF270000'] = 0x255C;
  14107. t['SF280000'] = 0x255B;
  14108. t['SF360000'] = 0x255E;
  14109. t['SF370000'] = 0x255F;
  14110. t['SF380000'] = 0x255A;
  14111. t['SF390000'] = 0x2554;
  14112. t['SF400000'] = 0x2569;
  14113. t['SF410000'] = 0x2566;
  14114. t['SF420000'] = 0x2560;
  14115. t['SF430000'] = 0x2550;
  14116. t['SF440000'] = 0x256C;
  14117. t['SF450000'] = 0x2567;
  14118. t['SF460000'] = 0x2568;
  14119. t['SF470000'] = 0x2564;
  14120. t['SF480000'] = 0x2565;
  14121. t['SF490000'] = 0x2559;
  14122. t['SF500000'] = 0x2558;
  14123. t['SF510000'] = 0x2552;
  14124. t['SF520000'] = 0x2553;
  14125. t['SF530000'] = 0x256B;
  14126. t['SF540000'] = 0x256A;
  14127. t['Sacute'] = 0x015A;
  14128. t['Sacutedotaccent'] = 0x1E64;
  14129. t['Sampigreek'] = 0x03E0;
  14130. t['Scaron'] = 0x0160;
  14131. t['Scarondotaccent'] = 0x1E66;
  14132. t['Scaronsmall'] = 0xF6FD;
  14133. t['Scedilla'] = 0x015E;
  14134. t['Schwa'] = 0x018F;
  14135. t['Schwacyrillic'] = 0x04D8;
  14136. t['Schwadieresiscyrillic'] = 0x04DA;
  14137. t['Scircle'] = 0x24C8;
  14138. t['Scircumflex'] = 0x015C;
  14139. t['Scommaaccent'] = 0x0218;
  14140. t['Sdotaccent'] = 0x1E60;
  14141. t['Sdotbelow'] = 0x1E62;
  14142. t['Sdotbelowdotaccent'] = 0x1E68;
  14143. t['Seharmenian'] = 0x054D;
  14144. t['Sevenroman'] = 0x2166;
  14145. t['Shaarmenian'] = 0x0547;
  14146. t['Shacyrillic'] = 0x0428;
  14147. t['Shchacyrillic'] = 0x0429;
  14148. t['Sheicoptic'] = 0x03E2;
  14149. t['Shhacyrillic'] = 0x04BA;
  14150. t['Shimacoptic'] = 0x03EC;
  14151. t['Sigma'] = 0x03A3;
  14152. t['Sixroman'] = 0x2165;
  14153. t['Smonospace'] = 0xFF33;
  14154. t['Softsigncyrillic'] = 0x042C;
  14155. t['Ssmall'] = 0xF773;
  14156. t['Stigmagreek'] = 0x03DA;
  14157. t['T'] = 0x0054;
  14158. t['Tau'] = 0x03A4;
  14159. t['Tbar'] = 0x0166;
  14160. t['Tcaron'] = 0x0164;
  14161. t['Tcedilla'] = 0x0162;
  14162. t['Tcircle'] = 0x24C9;
  14163. t['Tcircumflexbelow'] = 0x1E70;
  14164. t['Tcommaaccent'] = 0x0162;
  14165. t['Tdotaccent'] = 0x1E6A;
  14166. t['Tdotbelow'] = 0x1E6C;
  14167. t['Tecyrillic'] = 0x0422;
  14168. t['Tedescendercyrillic'] = 0x04AC;
  14169. t['Tenroman'] = 0x2169;
  14170. t['Tetsecyrillic'] = 0x04B4;
  14171. t['Theta'] = 0x0398;
  14172. t['Thook'] = 0x01AC;
  14173. t['Thorn'] = 0x00DE;
  14174. t['Thornsmall'] = 0xF7FE;
  14175. t['Threeroman'] = 0x2162;
  14176. t['Tildesmall'] = 0xF6FE;
  14177. t['Tiwnarmenian'] = 0x054F;
  14178. t['Tlinebelow'] = 0x1E6E;
  14179. t['Tmonospace'] = 0xFF34;
  14180. t['Toarmenian'] = 0x0539;
  14181. t['Tonefive'] = 0x01BC;
  14182. t['Tonesix'] = 0x0184;
  14183. t['Tonetwo'] = 0x01A7;
  14184. t['Tretroflexhook'] = 0x01AE;
  14185. t['Tsecyrillic'] = 0x0426;
  14186. t['Tshecyrillic'] = 0x040B;
  14187. t['Tsmall'] = 0xF774;
  14188. t['Twelveroman'] = 0x216B;
  14189. t['Tworoman'] = 0x2161;
  14190. t['U'] = 0x0055;
  14191. t['Uacute'] = 0x00DA;
  14192. t['Uacutesmall'] = 0xF7FA;
  14193. t['Ubreve'] = 0x016C;
  14194. t['Ucaron'] = 0x01D3;
  14195. t['Ucircle'] = 0x24CA;
  14196. t['Ucircumflex'] = 0x00DB;
  14197. t['Ucircumflexbelow'] = 0x1E76;
  14198. t['Ucircumflexsmall'] = 0xF7FB;
  14199. t['Ucyrillic'] = 0x0423;
  14200. t['Udblacute'] = 0x0170;
  14201. t['Udblgrave'] = 0x0214;
  14202. t['Udieresis'] = 0x00DC;
  14203. t['Udieresisacute'] = 0x01D7;
  14204. t['Udieresisbelow'] = 0x1E72;
  14205. t['Udieresiscaron'] = 0x01D9;
  14206. t['Udieresiscyrillic'] = 0x04F0;
  14207. t['Udieresisgrave'] = 0x01DB;
  14208. t['Udieresismacron'] = 0x01D5;
  14209. t['Udieresissmall'] = 0xF7FC;
  14210. t['Udotbelow'] = 0x1EE4;
  14211. t['Ugrave'] = 0x00D9;
  14212. t['Ugravesmall'] = 0xF7F9;
  14213. t['Uhookabove'] = 0x1EE6;
  14214. t['Uhorn'] = 0x01AF;
  14215. t['Uhornacute'] = 0x1EE8;
  14216. t['Uhorndotbelow'] = 0x1EF0;
  14217. t['Uhorngrave'] = 0x1EEA;
  14218. t['Uhornhookabove'] = 0x1EEC;
  14219. t['Uhorntilde'] = 0x1EEE;
  14220. t['Uhungarumlaut'] = 0x0170;
  14221. t['Uhungarumlautcyrillic'] = 0x04F2;
  14222. t['Uinvertedbreve'] = 0x0216;
  14223. t['Ukcyrillic'] = 0x0478;
  14224. t['Umacron'] = 0x016A;
  14225. t['Umacroncyrillic'] = 0x04EE;
  14226. t['Umacrondieresis'] = 0x1E7A;
  14227. t['Umonospace'] = 0xFF35;
  14228. t['Uogonek'] = 0x0172;
  14229. t['Upsilon'] = 0x03A5;
  14230. t['Upsilon1'] = 0x03D2;
  14231. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14232. t['Upsilonafrican'] = 0x01B1;
  14233. t['Upsilondieresis'] = 0x03AB;
  14234. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14235. t['Upsilonhooksymbol'] = 0x03D2;
  14236. t['Upsilontonos'] = 0x038E;
  14237. t['Uring'] = 0x016E;
  14238. t['Ushortcyrillic'] = 0x040E;
  14239. t['Usmall'] = 0xF775;
  14240. t['Ustraightcyrillic'] = 0x04AE;
  14241. t['Ustraightstrokecyrillic'] = 0x04B0;
  14242. t['Utilde'] = 0x0168;
  14243. t['Utildeacute'] = 0x1E78;
  14244. t['Utildebelow'] = 0x1E74;
  14245. t['V'] = 0x0056;
  14246. t['Vcircle'] = 0x24CB;
  14247. t['Vdotbelow'] = 0x1E7E;
  14248. t['Vecyrillic'] = 0x0412;
  14249. t['Vewarmenian'] = 0x054E;
  14250. t['Vhook'] = 0x01B2;
  14251. t['Vmonospace'] = 0xFF36;
  14252. t['Voarmenian'] = 0x0548;
  14253. t['Vsmall'] = 0xF776;
  14254. t['Vtilde'] = 0x1E7C;
  14255. t['W'] = 0x0057;
  14256. t['Wacute'] = 0x1E82;
  14257. t['Wcircle'] = 0x24CC;
  14258. t['Wcircumflex'] = 0x0174;
  14259. t['Wdieresis'] = 0x1E84;
  14260. t['Wdotaccent'] = 0x1E86;
  14261. t['Wdotbelow'] = 0x1E88;
  14262. t['Wgrave'] = 0x1E80;
  14263. t['Wmonospace'] = 0xFF37;
  14264. t['Wsmall'] = 0xF777;
  14265. t['X'] = 0x0058;
  14266. t['Xcircle'] = 0x24CD;
  14267. t['Xdieresis'] = 0x1E8C;
  14268. t['Xdotaccent'] = 0x1E8A;
  14269. t['Xeharmenian'] = 0x053D;
  14270. t['Xi'] = 0x039E;
  14271. t['Xmonospace'] = 0xFF38;
  14272. t['Xsmall'] = 0xF778;
  14273. t['Y'] = 0x0059;
  14274. t['Yacute'] = 0x00DD;
  14275. t['Yacutesmall'] = 0xF7FD;
  14276. t['Yatcyrillic'] = 0x0462;
  14277. t['Ycircle'] = 0x24CE;
  14278. t['Ycircumflex'] = 0x0176;
  14279. t['Ydieresis'] = 0x0178;
  14280. t['Ydieresissmall'] = 0xF7FF;
  14281. t['Ydotaccent'] = 0x1E8E;
  14282. t['Ydotbelow'] = 0x1EF4;
  14283. t['Yericyrillic'] = 0x042B;
  14284. t['Yerudieresiscyrillic'] = 0x04F8;
  14285. t['Ygrave'] = 0x1EF2;
  14286. t['Yhook'] = 0x01B3;
  14287. t['Yhookabove'] = 0x1EF6;
  14288. t['Yiarmenian'] = 0x0545;
  14289. t['Yicyrillic'] = 0x0407;
  14290. t['Yiwnarmenian'] = 0x0552;
  14291. t['Ymonospace'] = 0xFF39;
  14292. t['Ysmall'] = 0xF779;
  14293. t['Ytilde'] = 0x1EF8;
  14294. t['Yusbigcyrillic'] = 0x046A;
  14295. t['Yusbigiotifiedcyrillic'] = 0x046C;
  14296. t['Yuslittlecyrillic'] = 0x0466;
  14297. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  14298. t['Z'] = 0x005A;
  14299. t['Zaarmenian'] = 0x0536;
  14300. t['Zacute'] = 0x0179;
  14301. t['Zcaron'] = 0x017D;
  14302. t['Zcaronsmall'] = 0xF6FF;
  14303. t['Zcircle'] = 0x24CF;
  14304. t['Zcircumflex'] = 0x1E90;
  14305. t['Zdot'] = 0x017B;
  14306. t['Zdotaccent'] = 0x017B;
  14307. t['Zdotbelow'] = 0x1E92;
  14308. t['Zecyrillic'] = 0x0417;
  14309. t['Zedescendercyrillic'] = 0x0498;
  14310. t['Zedieresiscyrillic'] = 0x04DE;
  14311. t['Zeta'] = 0x0396;
  14312. t['Zhearmenian'] = 0x053A;
  14313. t['Zhebrevecyrillic'] = 0x04C1;
  14314. t['Zhecyrillic'] = 0x0416;
  14315. t['Zhedescendercyrillic'] = 0x0496;
  14316. t['Zhedieresiscyrillic'] = 0x04DC;
  14317. t['Zlinebelow'] = 0x1E94;
  14318. t['Zmonospace'] = 0xFF3A;
  14319. t['Zsmall'] = 0xF77A;
  14320. t['Zstroke'] = 0x01B5;
  14321. t['a'] = 0x0061;
  14322. t['aabengali'] = 0x0986;
  14323. t['aacute'] = 0x00E1;
  14324. t['aadeva'] = 0x0906;
  14325. t['aagujarati'] = 0x0A86;
  14326. t['aagurmukhi'] = 0x0A06;
  14327. t['aamatragurmukhi'] = 0x0A3E;
  14328. t['aarusquare'] = 0x3303;
  14329. t['aavowelsignbengali'] = 0x09BE;
  14330. t['aavowelsigndeva'] = 0x093E;
  14331. t['aavowelsigngujarati'] = 0x0ABE;
  14332. t['abbreviationmarkarmenian'] = 0x055F;
  14333. t['abbreviationsigndeva'] = 0x0970;
  14334. t['abengali'] = 0x0985;
  14335. t['abopomofo'] = 0x311A;
  14336. t['abreve'] = 0x0103;
  14337. t['abreveacute'] = 0x1EAF;
  14338. t['abrevecyrillic'] = 0x04D1;
  14339. t['abrevedotbelow'] = 0x1EB7;
  14340. t['abrevegrave'] = 0x1EB1;
  14341. t['abrevehookabove'] = 0x1EB3;
  14342. t['abrevetilde'] = 0x1EB5;
  14343. t['acaron'] = 0x01CE;
  14344. t['acircle'] = 0x24D0;
  14345. t['acircumflex'] = 0x00E2;
  14346. t['acircumflexacute'] = 0x1EA5;
  14347. t['acircumflexdotbelow'] = 0x1EAD;
  14348. t['acircumflexgrave'] = 0x1EA7;
  14349. t['acircumflexhookabove'] = 0x1EA9;
  14350. t['acircumflextilde'] = 0x1EAB;
  14351. t['acute'] = 0x00B4;
  14352. t['acutebelowcmb'] = 0x0317;
  14353. t['acutecmb'] = 0x0301;
  14354. t['acutecomb'] = 0x0301;
  14355. t['acutedeva'] = 0x0954;
  14356. t['acutelowmod'] = 0x02CF;
  14357. t['acutetonecmb'] = 0x0341;
  14358. t['acyrillic'] = 0x0430;
  14359. t['adblgrave'] = 0x0201;
  14360. t['addakgurmukhi'] = 0x0A71;
  14361. t['adeva'] = 0x0905;
  14362. t['adieresis'] = 0x00E4;
  14363. t['adieresiscyrillic'] = 0x04D3;
  14364. t['adieresismacron'] = 0x01DF;
  14365. t['adotbelow'] = 0x1EA1;
  14366. t['adotmacron'] = 0x01E1;
  14367. t['ae'] = 0x00E6;
  14368. t['aeacute'] = 0x01FD;
  14369. t['aekorean'] = 0x3150;
  14370. t['aemacron'] = 0x01E3;
  14371. t['afii00208'] = 0x2015;
  14372. t['afii08941'] = 0x20A4;
  14373. t['afii10017'] = 0x0410;
  14374. t['afii10018'] = 0x0411;
  14375. t['afii10019'] = 0x0412;
  14376. t['afii10020'] = 0x0413;
  14377. t['afii10021'] = 0x0414;
  14378. t['afii10022'] = 0x0415;
  14379. t['afii10023'] = 0x0401;
  14380. t['afii10024'] = 0x0416;
  14381. t['afii10025'] = 0x0417;
  14382. t['afii10026'] = 0x0418;
  14383. t['afii10027'] = 0x0419;
  14384. t['afii10028'] = 0x041A;
  14385. t['afii10029'] = 0x041B;
  14386. t['afii10030'] = 0x041C;
  14387. t['afii10031'] = 0x041D;
  14388. t['afii10032'] = 0x041E;
  14389. t['afii10033'] = 0x041F;
  14390. t['afii10034'] = 0x0420;
  14391. t['afii10035'] = 0x0421;
  14392. t['afii10036'] = 0x0422;
  14393. t['afii10037'] = 0x0423;
  14394. t['afii10038'] = 0x0424;
  14395. t['afii10039'] = 0x0425;
  14396. t['afii10040'] = 0x0426;
  14397. t['afii10041'] = 0x0427;
  14398. t['afii10042'] = 0x0428;
  14399. t['afii10043'] = 0x0429;
  14400. t['afii10044'] = 0x042A;
  14401. t['afii10045'] = 0x042B;
  14402. t['afii10046'] = 0x042C;
  14403. t['afii10047'] = 0x042D;
  14404. t['afii10048'] = 0x042E;
  14405. t['afii10049'] = 0x042F;
  14406. t['afii10050'] = 0x0490;
  14407. t['afii10051'] = 0x0402;
  14408. t['afii10052'] = 0x0403;
  14409. t['afii10053'] = 0x0404;
  14410. t['afii10054'] = 0x0405;
  14411. t['afii10055'] = 0x0406;
  14412. t['afii10056'] = 0x0407;
  14413. t['afii10057'] = 0x0408;
  14414. t['afii10058'] = 0x0409;
  14415. t['afii10059'] = 0x040A;
  14416. t['afii10060'] = 0x040B;
  14417. t['afii10061'] = 0x040C;
  14418. t['afii10062'] = 0x040E;
  14419. t['afii10063'] = 0xF6C4;
  14420. t['afii10064'] = 0xF6C5;
  14421. t['afii10065'] = 0x0430;
  14422. t['afii10066'] = 0x0431;
  14423. t['afii10067'] = 0x0432;
  14424. t['afii10068'] = 0x0433;
  14425. t['afii10069'] = 0x0434;
  14426. t['afii10070'] = 0x0435;
  14427. t['afii10071'] = 0x0451;
  14428. t['afii10072'] = 0x0436;
  14429. t['afii10073'] = 0x0437;
  14430. t['afii10074'] = 0x0438;
  14431. t['afii10075'] = 0x0439;
  14432. t['afii10076'] = 0x043A;
  14433. t['afii10077'] = 0x043B;
  14434. t['afii10078'] = 0x043C;
  14435. t['afii10079'] = 0x043D;
  14436. t['afii10080'] = 0x043E;
  14437. t['afii10081'] = 0x043F;
  14438. t['afii10082'] = 0x0440;
  14439. t['afii10083'] = 0x0441;
  14440. t['afii10084'] = 0x0442;
  14441. t['afii10085'] = 0x0443;
  14442. t['afii10086'] = 0x0444;
  14443. t['afii10087'] = 0x0445;
  14444. t['afii10088'] = 0x0446;
  14445. t['afii10089'] = 0x0447;
  14446. t['afii10090'] = 0x0448;
  14447. t['afii10091'] = 0x0449;
  14448. t['afii10092'] = 0x044A;
  14449. t['afii10093'] = 0x044B;
  14450. t['afii10094'] = 0x044C;
  14451. t['afii10095'] = 0x044D;
  14452. t['afii10096'] = 0x044E;
  14453. t['afii10097'] = 0x044F;
  14454. t['afii10098'] = 0x0491;
  14455. t['afii10099'] = 0x0452;
  14456. t['afii10100'] = 0x0453;
  14457. t['afii10101'] = 0x0454;
  14458. t['afii10102'] = 0x0455;
  14459. t['afii10103'] = 0x0456;
  14460. t['afii10104'] = 0x0457;
  14461. t['afii10105'] = 0x0458;
  14462. t['afii10106'] = 0x0459;
  14463. t['afii10107'] = 0x045A;
  14464. t['afii10108'] = 0x045B;
  14465. t['afii10109'] = 0x045C;
  14466. t['afii10110'] = 0x045E;
  14467. t['afii10145'] = 0x040F;
  14468. t['afii10146'] = 0x0462;
  14469. t['afii10147'] = 0x0472;
  14470. t['afii10148'] = 0x0474;
  14471. t['afii10192'] = 0xF6C6;
  14472. t['afii10193'] = 0x045F;
  14473. t['afii10194'] = 0x0463;
  14474. t['afii10195'] = 0x0473;
  14475. t['afii10196'] = 0x0475;
  14476. t['afii10831'] = 0xF6C7;
  14477. t['afii10832'] = 0xF6C8;
  14478. t['afii10846'] = 0x04D9;
  14479. t['afii299'] = 0x200E;
  14480. t['afii300'] = 0x200F;
  14481. t['afii301'] = 0x200D;
  14482. t['afii57381'] = 0x066A;
  14483. t['afii57388'] = 0x060C;
  14484. t['afii57392'] = 0x0660;
  14485. t['afii57393'] = 0x0661;
  14486. t['afii57394'] = 0x0662;
  14487. t['afii57395'] = 0x0663;
  14488. t['afii57396'] = 0x0664;
  14489. t['afii57397'] = 0x0665;
  14490. t['afii57398'] = 0x0666;
  14491. t['afii57399'] = 0x0667;
  14492. t['afii57400'] = 0x0668;
  14493. t['afii57401'] = 0x0669;
  14494. t['afii57403'] = 0x061B;
  14495. t['afii57407'] = 0x061F;
  14496. t['afii57409'] = 0x0621;
  14497. t['afii57410'] = 0x0622;
  14498. t['afii57411'] = 0x0623;
  14499. t['afii57412'] = 0x0624;
  14500. t['afii57413'] = 0x0625;
  14501. t['afii57414'] = 0x0626;
  14502. t['afii57415'] = 0x0627;
  14503. t['afii57416'] = 0x0628;
  14504. t['afii57417'] = 0x0629;
  14505. t['afii57418'] = 0x062A;
  14506. t['afii57419'] = 0x062B;
  14507. t['afii57420'] = 0x062C;
  14508. t['afii57421'] = 0x062D;
  14509. t['afii57422'] = 0x062E;
  14510. t['afii57423'] = 0x062F;
  14511. t['afii57424'] = 0x0630;
  14512. t['afii57425'] = 0x0631;
  14513. t['afii57426'] = 0x0632;
  14514. t['afii57427'] = 0x0633;
  14515. t['afii57428'] = 0x0634;
  14516. t['afii57429'] = 0x0635;
  14517. t['afii57430'] = 0x0636;
  14518. t['afii57431'] = 0x0637;
  14519. t['afii57432'] = 0x0638;
  14520. t['afii57433'] = 0x0639;
  14521. t['afii57434'] = 0x063A;
  14522. t['afii57440'] = 0x0640;
  14523. t['afii57441'] = 0x0641;
  14524. t['afii57442'] = 0x0642;
  14525. t['afii57443'] = 0x0643;
  14526. t['afii57444'] = 0x0644;
  14527. t['afii57445'] = 0x0645;
  14528. t['afii57446'] = 0x0646;
  14529. t['afii57448'] = 0x0648;
  14530. t['afii57449'] = 0x0649;
  14531. t['afii57450'] = 0x064A;
  14532. t['afii57451'] = 0x064B;
  14533. t['afii57452'] = 0x064C;
  14534. t['afii57453'] = 0x064D;
  14535. t['afii57454'] = 0x064E;
  14536. t['afii57455'] = 0x064F;
  14537. t['afii57456'] = 0x0650;
  14538. t['afii57457'] = 0x0651;
  14539. t['afii57458'] = 0x0652;
  14540. t['afii57470'] = 0x0647;
  14541. t['afii57505'] = 0x06A4;
  14542. t['afii57506'] = 0x067E;
  14543. t['afii57507'] = 0x0686;
  14544. t['afii57508'] = 0x0698;
  14545. t['afii57509'] = 0x06AF;
  14546. t['afii57511'] = 0x0679;
  14547. t['afii57512'] = 0x0688;
  14548. t['afii57513'] = 0x0691;
  14549. t['afii57514'] = 0x06BA;
  14550. t['afii57519'] = 0x06D2;
  14551. t['afii57534'] = 0x06D5;
  14552. t['afii57636'] = 0x20AA;
  14553. t['afii57645'] = 0x05BE;
  14554. t['afii57658'] = 0x05C3;
  14555. t['afii57664'] = 0x05D0;
  14556. t['afii57665'] = 0x05D1;
  14557. t['afii57666'] = 0x05D2;
  14558. t['afii57667'] = 0x05D3;
  14559. t['afii57668'] = 0x05D4;
  14560. t['afii57669'] = 0x05D5;
  14561. t['afii57670'] = 0x05D6;
  14562. t['afii57671'] = 0x05D7;
  14563. t['afii57672'] = 0x05D8;
  14564. t['afii57673'] = 0x05D9;
  14565. t['afii57674'] = 0x05DA;
  14566. t['afii57675'] = 0x05DB;
  14567. t['afii57676'] = 0x05DC;
  14568. t['afii57677'] = 0x05DD;
  14569. t['afii57678'] = 0x05DE;
  14570. t['afii57679'] = 0x05DF;
  14571. t['afii57680'] = 0x05E0;
  14572. t['afii57681'] = 0x05E1;
  14573. t['afii57682'] = 0x05E2;
  14574. t['afii57683'] = 0x05E3;
  14575. t['afii57684'] = 0x05E4;
  14576. t['afii57685'] = 0x05E5;
  14577. t['afii57686'] = 0x05E6;
  14578. t['afii57687'] = 0x05E7;
  14579. t['afii57688'] = 0x05E8;
  14580. t['afii57689'] = 0x05E9;
  14581. t['afii57690'] = 0x05EA;
  14582. t['afii57694'] = 0xFB2A;
  14583. t['afii57695'] = 0xFB2B;
  14584. t['afii57700'] = 0xFB4B;
  14585. t['afii57705'] = 0xFB1F;
  14586. t['afii57716'] = 0x05F0;
  14587. t['afii57717'] = 0x05F1;
  14588. t['afii57718'] = 0x05F2;
  14589. t['afii57723'] = 0xFB35;
  14590. t['afii57793'] = 0x05B4;
  14591. t['afii57794'] = 0x05B5;
  14592. t['afii57795'] = 0x05B6;
  14593. t['afii57796'] = 0x05BB;
  14594. t['afii57797'] = 0x05B8;
  14595. t['afii57798'] = 0x05B7;
  14596. t['afii57799'] = 0x05B0;
  14597. t['afii57800'] = 0x05B2;
  14598. t['afii57801'] = 0x05B1;
  14599. t['afii57802'] = 0x05B3;
  14600. t['afii57803'] = 0x05C2;
  14601. t['afii57804'] = 0x05C1;
  14602. t['afii57806'] = 0x05B9;
  14603. t['afii57807'] = 0x05BC;
  14604. t['afii57839'] = 0x05BD;
  14605. t['afii57841'] = 0x05BF;
  14606. t['afii57842'] = 0x05C0;
  14607. t['afii57929'] = 0x02BC;
  14608. t['afii61248'] = 0x2105;
  14609. t['afii61289'] = 0x2113;
  14610. t['afii61352'] = 0x2116;
  14611. t['afii61573'] = 0x202C;
  14612. t['afii61574'] = 0x202D;
  14613. t['afii61575'] = 0x202E;
  14614. t['afii61664'] = 0x200C;
  14615. t['afii63167'] = 0x066D;
  14616. t['afii64937'] = 0x02BD;
  14617. t['agrave'] = 0x00E0;
  14618. t['agujarati'] = 0x0A85;
  14619. t['agurmukhi'] = 0x0A05;
  14620. t['ahiragana'] = 0x3042;
  14621. t['ahookabove'] = 0x1EA3;
  14622. t['aibengali'] = 0x0990;
  14623. t['aibopomofo'] = 0x311E;
  14624. t['aideva'] = 0x0910;
  14625. t['aiecyrillic'] = 0x04D5;
  14626. t['aigujarati'] = 0x0A90;
  14627. t['aigurmukhi'] = 0x0A10;
  14628. t['aimatragurmukhi'] = 0x0A48;
  14629. t['ainarabic'] = 0x0639;
  14630. t['ainfinalarabic'] = 0xFECA;
  14631. t['aininitialarabic'] = 0xFECB;
  14632. t['ainmedialarabic'] = 0xFECC;
  14633. t['ainvertedbreve'] = 0x0203;
  14634. t['aivowelsignbengali'] = 0x09C8;
  14635. t['aivowelsigndeva'] = 0x0948;
  14636. t['aivowelsigngujarati'] = 0x0AC8;
  14637. t['akatakana'] = 0x30A2;
  14638. t['akatakanahalfwidth'] = 0xFF71;
  14639. t['akorean'] = 0x314F;
  14640. t['alef'] = 0x05D0;
  14641. t['alefarabic'] = 0x0627;
  14642. t['alefdageshhebrew'] = 0xFB30;
  14643. t['aleffinalarabic'] = 0xFE8E;
  14644. t['alefhamzaabovearabic'] = 0x0623;
  14645. t['alefhamzaabovefinalarabic'] = 0xFE84;
  14646. t['alefhamzabelowarabic'] = 0x0625;
  14647. t['alefhamzabelowfinalarabic'] = 0xFE88;
  14648. t['alefhebrew'] = 0x05D0;
  14649. t['aleflamedhebrew'] = 0xFB4F;
  14650. t['alefmaddaabovearabic'] = 0x0622;
  14651. t['alefmaddaabovefinalarabic'] = 0xFE82;
  14652. t['alefmaksuraarabic'] = 0x0649;
  14653. t['alefmaksurafinalarabic'] = 0xFEF0;
  14654. t['alefmaksurainitialarabic'] = 0xFEF3;
  14655. t['alefmaksuramedialarabic'] = 0xFEF4;
  14656. t['alefpatahhebrew'] = 0xFB2E;
  14657. t['alefqamatshebrew'] = 0xFB2F;
  14658. t['aleph'] = 0x2135;
  14659. t['allequal'] = 0x224C;
  14660. t['alpha'] = 0x03B1;
  14661. t['alphatonos'] = 0x03AC;
  14662. t['amacron'] = 0x0101;
  14663. t['amonospace'] = 0xFF41;
  14664. t['ampersand'] = 0x0026;
  14665. t['ampersandmonospace'] = 0xFF06;
  14666. t['ampersandsmall'] = 0xF726;
  14667. t['amsquare'] = 0x33C2;
  14668. t['anbopomofo'] = 0x3122;
  14669. t['angbopomofo'] = 0x3124;
  14670. t['angbracketleft'] = 0x3008;
  14671. t['angbracketright'] = 0x3009;
  14672. t['angkhankhuthai'] = 0x0E5A;
  14673. t['angle'] = 0x2220;
  14674. t['anglebracketleft'] = 0x3008;
  14675. t['anglebracketleftvertical'] = 0xFE3F;
  14676. t['anglebracketright'] = 0x3009;
  14677. t['anglebracketrightvertical'] = 0xFE40;
  14678. t['angleleft'] = 0x2329;
  14679. t['angleright'] = 0x232A;
  14680. t['angstrom'] = 0x212B;
  14681. t['anoteleia'] = 0x0387;
  14682. t['anudattadeva'] = 0x0952;
  14683. t['anusvarabengali'] = 0x0982;
  14684. t['anusvaradeva'] = 0x0902;
  14685. t['anusvaragujarati'] = 0x0A82;
  14686. t['aogonek'] = 0x0105;
  14687. t['apaatosquare'] = 0x3300;
  14688. t['aparen'] = 0x249C;
  14689. t['apostrophearmenian'] = 0x055A;
  14690. t['apostrophemod'] = 0x02BC;
  14691. t['apple'] = 0xF8FF;
  14692. t['approaches'] = 0x2250;
  14693. t['approxequal'] = 0x2248;
  14694. t['approxequalorimage'] = 0x2252;
  14695. t['approximatelyequal'] = 0x2245;
  14696. t['araeaekorean'] = 0x318E;
  14697. t['araeakorean'] = 0x318D;
  14698. t['arc'] = 0x2312;
  14699. t['arighthalfring'] = 0x1E9A;
  14700. t['aring'] = 0x00E5;
  14701. t['aringacute'] = 0x01FB;
  14702. t['aringbelow'] = 0x1E01;
  14703. t['arrowboth'] = 0x2194;
  14704. t['arrowdashdown'] = 0x21E3;
  14705. t['arrowdashleft'] = 0x21E0;
  14706. t['arrowdashright'] = 0x21E2;
  14707. t['arrowdashup'] = 0x21E1;
  14708. t['arrowdblboth'] = 0x21D4;
  14709. t['arrowdbldown'] = 0x21D3;
  14710. t['arrowdblleft'] = 0x21D0;
  14711. t['arrowdblright'] = 0x21D2;
  14712. t['arrowdblup'] = 0x21D1;
  14713. t['arrowdown'] = 0x2193;
  14714. t['arrowdownleft'] = 0x2199;
  14715. t['arrowdownright'] = 0x2198;
  14716. t['arrowdownwhite'] = 0x21E9;
  14717. t['arrowheaddownmod'] = 0x02C5;
  14718. t['arrowheadleftmod'] = 0x02C2;
  14719. t['arrowheadrightmod'] = 0x02C3;
  14720. t['arrowheadupmod'] = 0x02C4;
  14721. t['arrowhorizex'] = 0xF8E7;
  14722. t['arrowleft'] = 0x2190;
  14723. t['arrowleftdbl'] = 0x21D0;
  14724. t['arrowleftdblstroke'] = 0x21CD;
  14725. t['arrowleftoverright'] = 0x21C6;
  14726. t['arrowleftwhite'] = 0x21E6;
  14727. t['arrowright'] = 0x2192;
  14728. t['arrowrightdblstroke'] = 0x21CF;
  14729. t['arrowrightheavy'] = 0x279E;
  14730. t['arrowrightoverleft'] = 0x21C4;
  14731. t['arrowrightwhite'] = 0x21E8;
  14732. t['arrowtableft'] = 0x21E4;
  14733. t['arrowtabright'] = 0x21E5;
  14734. t['arrowup'] = 0x2191;
  14735. t['arrowupdn'] = 0x2195;
  14736. t['arrowupdnbse'] = 0x21A8;
  14737. t['arrowupdownbase'] = 0x21A8;
  14738. t['arrowupleft'] = 0x2196;
  14739. t['arrowupleftofdown'] = 0x21C5;
  14740. t['arrowupright'] = 0x2197;
  14741. t['arrowupwhite'] = 0x21E7;
  14742. t['arrowvertex'] = 0xF8E6;
  14743. t['asciicircum'] = 0x005E;
  14744. t['asciicircummonospace'] = 0xFF3E;
  14745. t['asciitilde'] = 0x007E;
  14746. t['asciitildemonospace'] = 0xFF5E;
  14747. t['ascript'] = 0x0251;
  14748. t['ascriptturned'] = 0x0252;
  14749. t['asmallhiragana'] = 0x3041;
  14750. t['asmallkatakana'] = 0x30A1;
  14751. t['asmallkatakanahalfwidth'] = 0xFF67;
  14752. t['asterisk'] = 0x002A;
  14753. t['asteriskaltonearabic'] = 0x066D;
  14754. t['asteriskarabic'] = 0x066D;
  14755. t['asteriskmath'] = 0x2217;
  14756. t['asteriskmonospace'] = 0xFF0A;
  14757. t['asterisksmall'] = 0xFE61;
  14758. t['asterism'] = 0x2042;
  14759. t['asuperior'] = 0xF6E9;
  14760. t['asymptoticallyequal'] = 0x2243;
  14761. t['at'] = 0x0040;
  14762. t['atilde'] = 0x00E3;
  14763. t['atmonospace'] = 0xFF20;
  14764. t['atsmall'] = 0xFE6B;
  14765. t['aturned'] = 0x0250;
  14766. t['aubengali'] = 0x0994;
  14767. t['aubopomofo'] = 0x3120;
  14768. t['audeva'] = 0x0914;
  14769. t['augujarati'] = 0x0A94;
  14770. t['augurmukhi'] = 0x0A14;
  14771. t['aulengthmarkbengali'] = 0x09D7;
  14772. t['aumatragurmukhi'] = 0x0A4C;
  14773. t['auvowelsignbengali'] = 0x09CC;
  14774. t['auvowelsigndeva'] = 0x094C;
  14775. t['auvowelsigngujarati'] = 0x0ACC;
  14776. t['avagrahadeva'] = 0x093D;
  14777. t['aybarmenian'] = 0x0561;
  14778. t['ayin'] = 0x05E2;
  14779. t['ayinaltonehebrew'] = 0xFB20;
  14780. t['ayinhebrew'] = 0x05E2;
  14781. t['b'] = 0x0062;
  14782. t['babengali'] = 0x09AC;
  14783. t['backslash'] = 0x005C;
  14784. t['backslashmonospace'] = 0xFF3C;
  14785. t['badeva'] = 0x092C;
  14786. t['bagujarati'] = 0x0AAC;
  14787. t['bagurmukhi'] = 0x0A2C;
  14788. t['bahiragana'] = 0x3070;
  14789. t['bahtthai'] = 0x0E3F;
  14790. t['bakatakana'] = 0x30D0;
  14791. t['bar'] = 0x007C;
  14792. t['barmonospace'] = 0xFF5C;
  14793. t['bbopomofo'] = 0x3105;
  14794. t['bcircle'] = 0x24D1;
  14795. t['bdotaccent'] = 0x1E03;
  14796. t['bdotbelow'] = 0x1E05;
  14797. t['beamedsixteenthnotes'] = 0x266C;
  14798. t['because'] = 0x2235;
  14799. t['becyrillic'] = 0x0431;
  14800. t['beharabic'] = 0x0628;
  14801. t['behfinalarabic'] = 0xFE90;
  14802. t['behinitialarabic'] = 0xFE91;
  14803. t['behiragana'] = 0x3079;
  14804. t['behmedialarabic'] = 0xFE92;
  14805. t['behmeeminitialarabic'] = 0xFC9F;
  14806. t['behmeemisolatedarabic'] = 0xFC08;
  14807. t['behnoonfinalarabic'] = 0xFC6D;
  14808. t['bekatakana'] = 0x30D9;
  14809. t['benarmenian'] = 0x0562;
  14810. t['bet'] = 0x05D1;
  14811. t['beta'] = 0x03B2;
  14812. t['betasymbolgreek'] = 0x03D0;
  14813. t['betdagesh'] = 0xFB31;
  14814. t['betdageshhebrew'] = 0xFB31;
  14815. t['bethebrew'] = 0x05D1;
  14816. t['betrafehebrew'] = 0xFB4C;
  14817. t['bhabengali'] = 0x09AD;
  14818. t['bhadeva'] = 0x092D;
  14819. t['bhagujarati'] = 0x0AAD;
  14820. t['bhagurmukhi'] = 0x0A2D;
  14821. t['bhook'] = 0x0253;
  14822. t['bihiragana'] = 0x3073;
  14823. t['bikatakana'] = 0x30D3;
  14824. t['bilabialclick'] = 0x0298;
  14825. t['bindigurmukhi'] = 0x0A02;
  14826. t['birusquare'] = 0x3331;
  14827. t['blackcircle'] = 0x25CF;
  14828. t['blackdiamond'] = 0x25C6;
  14829. t['blackdownpointingtriangle'] = 0x25BC;
  14830. t['blackleftpointingpointer'] = 0x25C4;
  14831. t['blackleftpointingtriangle'] = 0x25C0;
  14832. t['blacklenticularbracketleft'] = 0x3010;
  14833. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  14834. t['blacklenticularbracketright'] = 0x3011;
  14835. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  14836. t['blacklowerlefttriangle'] = 0x25E3;
  14837. t['blacklowerrighttriangle'] = 0x25E2;
  14838. t['blackrectangle'] = 0x25AC;
  14839. t['blackrightpointingpointer'] = 0x25BA;
  14840. t['blackrightpointingtriangle'] = 0x25B6;
  14841. t['blacksmallsquare'] = 0x25AA;
  14842. t['blacksmilingface'] = 0x263B;
  14843. t['blacksquare'] = 0x25A0;
  14844. t['blackstar'] = 0x2605;
  14845. t['blackupperlefttriangle'] = 0x25E4;
  14846. t['blackupperrighttriangle'] = 0x25E5;
  14847. t['blackuppointingsmalltriangle'] = 0x25B4;
  14848. t['blackuppointingtriangle'] = 0x25B2;
  14849. t['blank'] = 0x2423;
  14850. t['blinebelow'] = 0x1E07;
  14851. t['block'] = 0x2588;
  14852. t['bmonospace'] = 0xFF42;
  14853. t['bobaimaithai'] = 0x0E1A;
  14854. t['bohiragana'] = 0x307C;
  14855. t['bokatakana'] = 0x30DC;
  14856. t['bparen'] = 0x249D;
  14857. t['bqsquare'] = 0x33C3;
  14858. t['braceex'] = 0xF8F4;
  14859. t['braceleft'] = 0x007B;
  14860. t['braceleftbt'] = 0xF8F3;
  14861. t['braceleftmid'] = 0xF8F2;
  14862. t['braceleftmonospace'] = 0xFF5B;
  14863. t['braceleftsmall'] = 0xFE5B;
  14864. t['bracelefttp'] = 0xF8F1;
  14865. t['braceleftvertical'] = 0xFE37;
  14866. t['braceright'] = 0x007D;
  14867. t['bracerightbt'] = 0xF8FE;
  14868. t['bracerightmid'] = 0xF8FD;
  14869. t['bracerightmonospace'] = 0xFF5D;
  14870. t['bracerightsmall'] = 0xFE5C;
  14871. t['bracerighttp'] = 0xF8FC;
  14872. t['bracerightvertical'] = 0xFE38;
  14873. t['bracketleft'] = 0x005B;
  14874. t['bracketleftbt'] = 0xF8F0;
  14875. t['bracketleftex'] = 0xF8EF;
  14876. t['bracketleftmonospace'] = 0xFF3B;
  14877. t['bracketlefttp'] = 0xF8EE;
  14878. t['bracketright'] = 0x005D;
  14879. t['bracketrightbt'] = 0xF8FB;
  14880. t['bracketrightex'] = 0xF8FA;
  14881. t['bracketrightmonospace'] = 0xFF3D;
  14882. t['bracketrighttp'] = 0xF8F9;
  14883. t['breve'] = 0x02D8;
  14884. t['brevebelowcmb'] = 0x032E;
  14885. t['brevecmb'] = 0x0306;
  14886. t['breveinvertedbelowcmb'] = 0x032F;
  14887. t['breveinvertedcmb'] = 0x0311;
  14888. t['breveinverteddoublecmb'] = 0x0361;
  14889. t['bridgebelowcmb'] = 0x032A;
  14890. t['bridgeinvertedbelowcmb'] = 0x033A;
  14891. t['brokenbar'] = 0x00A6;
  14892. t['bstroke'] = 0x0180;
  14893. t['bsuperior'] = 0xF6EA;
  14894. t['btopbar'] = 0x0183;
  14895. t['buhiragana'] = 0x3076;
  14896. t['bukatakana'] = 0x30D6;
  14897. t['bullet'] = 0x2022;
  14898. t['bulletinverse'] = 0x25D8;
  14899. t['bulletoperator'] = 0x2219;
  14900. t['bullseye'] = 0x25CE;
  14901. t['c'] = 0x0063;
  14902. t['caarmenian'] = 0x056E;
  14903. t['cabengali'] = 0x099A;
  14904. t['cacute'] = 0x0107;
  14905. t['cadeva'] = 0x091A;
  14906. t['cagujarati'] = 0x0A9A;
  14907. t['cagurmukhi'] = 0x0A1A;
  14908. t['calsquare'] = 0x3388;
  14909. t['candrabindubengali'] = 0x0981;
  14910. t['candrabinducmb'] = 0x0310;
  14911. t['candrabindudeva'] = 0x0901;
  14912. t['candrabindugujarati'] = 0x0A81;
  14913. t['capslock'] = 0x21EA;
  14914. t['careof'] = 0x2105;
  14915. t['caron'] = 0x02C7;
  14916. t['caronbelowcmb'] = 0x032C;
  14917. t['caroncmb'] = 0x030C;
  14918. t['carriagereturn'] = 0x21B5;
  14919. t['cbopomofo'] = 0x3118;
  14920. t['ccaron'] = 0x010D;
  14921. t['ccedilla'] = 0x00E7;
  14922. t['ccedillaacute'] = 0x1E09;
  14923. t['ccircle'] = 0x24D2;
  14924. t['ccircumflex'] = 0x0109;
  14925. t['ccurl'] = 0x0255;
  14926. t['cdot'] = 0x010B;
  14927. t['cdotaccent'] = 0x010B;
  14928. t['cdsquare'] = 0x33C5;
  14929. t['cedilla'] = 0x00B8;
  14930. t['cedillacmb'] = 0x0327;
  14931. t['cent'] = 0x00A2;
  14932. t['centigrade'] = 0x2103;
  14933. t['centinferior'] = 0xF6DF;
  14934. t['centmonospace'] = 0xFFE0;
  14935. t['centoldstyle'] = 0xF7A2;
  14936. t['centsuperior'] = 0xF6E0;
  14937. t['chaarmenian'] = 0x0579;
  14938. t['chabengali'] = 0x099B;
  14939. t['chadeva'] = 0x091B;
  14940. t['chagujarati'] = 0x0A9B;
  14941. t['chagurmukhi'] = 0x0A1B;
  14942. t['chbopomofo'] = 0x3114;
  14943. t['cheabkhasiancyrillic'] = 0x04BD;
  14944. t['checkmark'] = 0x2713;
  14945. t['checyrillic'] = 0x0447;
  14946. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  14947. t['chedescendercyrillic'] = 0x04B7;
  14948. t['chedieresiscyrillic'] = 0x04F5;
  14949. t['cheharmenian'] = 0x0573;
  14950. t['chekhakassiancyrillic'] = 0x04CC;
  14951. t['cheverticalstrokecyrillic'] = 0x04B9;
  14952. t['chi'] = 0x03C7;
  14953. t['chieuchacirclekorean'] = 0x3277;
  14954. t['chieuchaparenkorean'] = 0x3217;
  14955. t['chieuchcirclekorean'] = 0x3269;
  14956. t['chieuchkorean'] = 0x314A;
  14957. t['chieuchparenkorean'] = 0x3209;
  14958. t['chochangthai'] = 0x0E0A;
  14959. t['chochanthai'] = 0x0E08;
  14960. t['chochingthai'] = 0x0E09;
  14961. t['chochoethai'] = 0x0E0C;
  14962. t['chook'] = 0x0188;
  14963. t['cieucacirclekorean'] = 0x3276;
  14964. t['cieucaparenkorean'] = 0x3216;
  14965. t['cieuccirclekorean'] = 0x3268;
  14966. t['cieuckorean'] = 0x3148;
  14967. t['cieucparenkorean'] = 0x3208;
  14968. t['cieucuparenkorean'] = 0x321C;
  14969. t['circle'] = 0x25CB;
  14970. t['circlecopyrt'] = 0x00A9;
  14971. t['circlemultiply'] = 0x2297;
  14972. t['circleot'] = 0x2299;
  14973. t['circleplus'] = 0x2295;
  14974. t['circlepostalmark'] = 0x3036;
  14975. t['circlewithlefthalfblack'] = 0x25D0;
  14976. t['circlewithrighthalfblack'] = 0x25D1;
  14977. t['circumflex'] = 0x02C6;
  14978. t['circumflexbelowcmb'] = 0x032D;
  14979. t['circumflexcmb'] = 0x0302;
  14980. t['clear'] = 0x2327;
  14981. t['clickalveolar'] = 0x01C2;
  14982. t['clickdental'] = 0x01C0;
  14983. t['clicklateral'] = 0x01C1;
  14984. t['clickretroflex'] = 0x01C3;
  14985. t['club'] = 0x2663;
  14986. t['clubsuitblack'] = 0x2663;
  14987. t['clubsuitwhite'] = 0x2667;
  14988. t['cmcubedsquare'] = 0x33A4;
  14989. t['cmonospace'] = 0xFF43;
  14990. t['cmsquaredsquare'] = 0x33A0;
  14991. t['coarmenian'] = 0x0581;
  14992. t['colon'] = 0x003A;
  14993. t['colonmonetary'] = 0x20A1;
  14994. t['colonmonospace'] = 0xFF1A;
  14995. t['colonsign'] = 0x20A1;
  14996. t['colonsmall'] = 0xFE55;
  14997. t['colontriangularhalfmod'] = 0x02D1;
  14998. t['colontriangularmod'] = 0x02D0;
  14999. t['comma'] = 0x002C;
  15000. t['commaabovecmb'] = 0x0313;
  15001. t['commaaboverightcmb'] = 0x0315;
  15002. t['commaaccent'] = 0xF6C3;
  15003. t['commaarabic'] = 0x060C;
  15004. t['commaarmenian'] = 0x055D;
  15005. t['commainferior'] = 0xF6E1;
  15006. t['commamonospace'] = 0xFF0C;
  15007. t['commareversedabovecmb'] = 0x0314;
  15008. t['commareversedmod'] = 0x02BD;
  15009. t['commasmall'] = 0xFE50;
  15010. t['commasuperior'] = 0xF6E2;
  15011. t['commaturnedabovecmb'] = 0x0312;
  15012. t['commaturnedmod'] = 0x02BB;
  15013. t['compass'] = 0x263C;
  15014. t['congruent'] = 0x2245;
  15015. t['contourintegral'] = 0x222E;
  15016. t['control'] = 0x2303;
  15017. t['controlACK'] = 0x0006;
  15018. t['controlBEL'] = 0x0007;
  15019. t['controlBS'] = 0x0008;
  15020. t['controlCAN'] = 0x0018;
  15021. t['controlCR'] = 0x000D;
  15022. t['controlDC1'] = 0x0011;
  15023. t['controlDC2'] = 0x0012;
  15024. t['controlDC3'] = 0x0013;
  15025. t['controlDC4'] = 0x0014;
  15026. t['controlDEL'] = 0x007F;
  15027. t['controlDLE'] = 0x0010;
  15028. t['controlEM'] = 0x0019;
  15029. t['controlENQ'] = 0x0005;
  15030. t['controlEOT'] = 0x0004;
  15031. t['controlESC'] = 0x001B;
  15032. t['controlETB'] = 0x0017;
  15033. t['controlETX'] = 0x0003;
  15034. t['controlFF'] = 0x000C;
  15035. t['controlFS'] = 0x001C;
  15036. t['controlGS'] = 0x001D;
  15037. t['controlHT'] = 0x0009;
  15038. t['controlLF'] = 0x000A;
  15039. t['controlNAK'] = 0x0015;
  15040. t['controlNULL'] = 0x0000;
  15041. t['controlRS'] = 0x001E;
  15042. t['controlSI'] = 0x000F;
  15043. t['controlSO'] = 0x000E;
  15044. t['controlSOT'] = 0x0002;
  15045. t['controlSTX'] = 0x0001;
  15046. t['controlSUB'] = 0x001A;
  15047. t['controlSYN'] = 0x0016;
  15048. t['controlUS'] = 0x001F;
  15049. t['controlVT'] = 0x000B;
  15050. t['copyright'] = 0x00A9;
  15051. t['copyrightsans'] = 0xF8E9;
  15052. t['copyrightserif'] = 0xF6D9;
  15053. t['cornerbracketleft'] = 0x300C;
  15054. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15055. t['cornerbracketleftvertical'] = 0xFE41;
  15056. t['cornerbracketright'] = 0x300D;
  15057. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15058. t['cornerbracketrightvertical'] = 0xFE42;
  15059. t['corporationsquare'] = 0x337F;
  15060. t['cosquare'] = 0x33C7;
  15061. t['coverkgsquare'] = 0x33C6;
  15062. t['cparen'] = 0x249E;
  15063. t['cruzeiro'] = 0x20A2;
  15064. t['cstretched'] = 0x0297;
  15065. t['curlyand'] = 0x22CF;
  15066. t['curlyor'] = 0x22CE;
  15067. t['currency'] = 0x00A4;
  15068. t['cyrBreve'] = 0xF6D1;
  15069. t['cyrFlex'] = 0xF6D2;
  15070. t['cyrbreve'] = 0xF6D4;
  15071. t['cyrflex'] = 0xF6D5;
  15072. t['d'] = 0x0064;
  15073. t['daarmenian'] = 0x0564;
  15074. t['dabengali'] = 0x09A6;
  15075. t['dadarabic'] = 0x0636;
  15076. t['dadeva'] = 0x0926;
  15077. t['dadfinalarabic'] = 0xFEBE;
  15078. t['dadinitialarabic'] = 0xFEBF;
  15079. t['dadmedialarabic'] = 0xFEC0;
  15080. t['dagesh'] = 0x05BC;
  15081. t['dageshhebrew'] = 0x05BC;
  15082. t['dagger'] = 0x2020;
  15083. t['daggerdbl'] = 0x2021;
  15084. t['dagujarati'] = 0x0AA6;
  15085. t['dagurmukhi'] = 0x0A26;
  15086. t['dahiragana'] = 0x3060;
  15087. t['dakatakana'] = 0x30C0;
  15088. t['dalarabic'] = 0x062F;
  15089. t['dalet'] = 0x05D3;
  15090. t['daletdagesh'] = 0xFB33;
  15091. t['daletdageshhebrew'] = 0xFB33;
  15092. t['dalethebrew'] = 0x05D3;
  15093. t['dalfinalarabic'] = 0xFEAA;
  15094. t['dammaarabic'] = 0x064F;
  15095. t['dammalowarabic'] = 0x064F;
  15096. t['dammatanaltonearabic'] = 0x064C;
  15097. t['dammatanarabic'] = 0x064C;
  15098. t['danda'] = 0x0964;
  15099. t['dargahebrew'] = 0x05A7;
  15100. t['dargalefthebrew'] = 0x05A7;
  15101. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15102. t['dblGrave'] = 0xF6D3;
  15103. t['dblanglebracketleft'] = 0x300A;
  15104. t['dblanglebracketleftvertical'] = 0xFE3D;
  15105. t['dblanglebracketright'] = 0x300B;
  15106. t['dblanglebracketrightvertical'] = 0xFE3E;
  15107. t['dblarchinvertedbelowcmb'] = 0x032B;
  15108. t['dblarrowleft'] = 0x21D4;
  15109. t['dblarrowright'] = 0x21D2;
  15110. t['dbldanda'] = 0x0965;
  15111. t['dblgrave'] = 0xF6D6;
  15112. t['dblgravecmb'] = 0x030F;
  15113. t['dblintegral'] = 0x222C;
  15114. t['dbllowline'] = 0x2017;
  15115. t['dbllowlinecmb'] = 0x0333;
  15116. t['dbloverlinecmb'] = 0x033F;
  15117. t['dblprimemod'] = 0x02BA;
  15118. t['dblverticalbar'] = 0x2016;
  15119. t['dblverticallineabovecmb'] = 0x030E;
  15120. t['dbopomofo'] = 0x3109;
  15121. t['dbsquare'] = 0x33C8;
  15122. t['dcaron'] = 0x010F;
  15123. t['dcedilla'] = 0x1E11;
  15124. t['dcircle'] = 0x24D3;
  15125. t['dcircumflexbelow'] = 0x1E13;
  15126. t['dcroat'] = 0x0111;
  15127. t['ddabengali'] = 0x09A1;
  15128. t['ddadeva'] = 0x0921;
  15129. t['ddagujarati'] = 0x0AA1;
  15130. t['ddagurmukhi'] = 0x0A21;
  15131. t['ddalarabic'] = 0x0688;
  15132. t['ddalfinalarabic'] = 0xFB89;
  15133. t['dddhadeva'] = 0x095C;
  15134. t['ddhabengali'] = 0x09A2;
  15135. t['ddhadeva'] = 0x0922;
  15136. t['ddhagujarati'] = 0x0AA2;
  15137. t['ddhagurmukhi'] = 0x0A22;
  15138. t['ddotaccent'] = 0x1E0B;
  15139. t['ddotbelow'] = 0x1E0D;
  15140. t['decimalseparatorarabic'] = 0x066B;
  15141. t['decimalseparatorpersian'] = 0x066B;
  15142. t['decyrillic'] = 0x0434;
  15143. t['degree'] = 0x00B0;
  15144. t['dehihebrew'] = 0x05AD;
  15145. t['dehiragana'] = 0x3067;
  15146. t['deicoptic'] = 0x03EF;
  15147. t['dekatakana'] = 0x30C7;
  15148. t['deleteleft'] = 0x232B;
  15149. t['deleteright'] = 0x2326;
  15150. t['delta'] = 0x03B4;
  15151. t['deltaturned'] = 0x018D;
  15152. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15153. t['dezh'] = 0x02A4;
  15154. t['dhabengali'] = 0x09A7;
  15155. t['dhadeva'] = 0x0927;
  15156. t['dhagujarati'] = 0x0AA7;
  15157. t['dhagurmukhi'] = 0x0A27;
  15158. t['dhook'] = 0x0257;
  15159. t['dialytikatonos'] = 0x0385;
  15160. t['dialytikatonoscmb'] = 0x0344;
  15161. t['diamond'] = 0x2666;
  15162. t['diamondsuitwhite'] = 0x2662;
  15163. t['dieresis'] = 0x00A8;
  15164. t['dieresisacute'] = 0xF6D7;
  15165. t['dieresisbelowcmb'] = 0x0324;
  15166. t['dieresiscmb'] = 0x0308;
  15167. t['dieresisgrave'] = 0xF6D8;
  15168. t['dieresistonos'] = 0x0385;
  15169. t['dihiragana'] = 0x3062;
  15170. t['dikatakana'] = 0x30C2;
  15171. t['dittomark'] = 0x3003;
  15172. t['divide'] = 0x00F7;
  15173. t['divides'] = 0x2223;
  15174. t['divisionslash'] = 0x2215;
  15175. t['djecyrillic'] = 0x0452;
  15176. t['dkshade'] = 0x2593;
  15177. t['dlinebelow'] = 0x1E0F;
  15178. t['dlsquare'] = 0x3397;
  15179. t['dmacron'] = 0x0111;
  15180. t['dmonospace'] = 0xFF44;
  15181. t['dnblock'] = 0x2584;
  15182. t['dochadathai'] = 0x0E0E;
  15183. t['dodekthai'] = 0x0E14;
  15184. t['dohiragana'] = 0x3069;
  15185. t['dokatakana'] = 0x30C9;
  15186. t['dollar'] = 0x0024;
  15187. t['dollarinferior'] = 0xF6E3;
  15188. t['dollarmonospace'] = 0xFF04;
  15189. t['dollaroldstyle'] = 0xF724;
  15190. t['dollarsmall'] = 0xFE69;
  15191. t['dollarsuperior'] = 0xF6E4;
  15192. t['dong'] = 0x20AB;
  15193. t['dorusquare'] = 0x3326;
  15194. t['dotaccent'] = 0x02D9;
  15195. t['dotaccentcmb'] = 0x0307;
  15196. t['dotbelowcmb'] = 0x0323;
  15197. t['dotbelowcomb'] = 0x0323;
  15198. t['dotkatakana'] = 0x30FB;
  15199. t['dotlessi'] = 0x0131;
  15200. t['dotlessj'] = 0xF6BE;
  15201. t['dotlessjstrokehook'] = 0x0284;
  15202. t['dotmath'] = 0x22C5;
  15203. t['dottedcircle'] = 0x25CC;
  15204. t['doubleyodpatah'] = 0xFB1F;
  15205. t['doubleyodpatahhebrew'] = 0xFB1F;
  15206. t['downtackbelowcmb'] = 0x031E;
  15207. t['downtackmod'] = 0x02D5;
  15208. t['dparen'] = 0x249F;
  15209. t['dsuperior'] = 0xF6EB;
  15210. t['dtail'] = 0x0256;
  15211. t['dtopbar'] = 0x018C;
  15212. t['duhiragana'] = 0x3065;
  15213. t['dukatakana'] = 0x30C5;
  15214. t['dz'] = 0x01F3;
  15215. t['dzaltone'] = 0x02A3;
  15216. t['dzcaron'] = 0x01C6;
  15217. t['dzcurl'] = 0x02A5;
  15218. t['dzeabkhasiancyrillic'] = 0x04E1;
  15219. t['dzecyrillic'] = 0x0455;
  15220. t['dzhecyrillic'] = 0x045F;
  15221. t['e'] = 0x0065;
  15222. t['eacute'] = 0x00E9;
  15223. t['earth'] = 0x2641;
  15224. t['ebengali'] = 0x098F;
  15225. t['ebopomofo'] = 0x311C;
  15226. t['ebreve'] = 0x0115;
  15227. t['ecandradeva'] = 0x090D;
  15228. t['ecandragujarati'] = 0x0A8D;
  15229. t['ecandravowelsigndeva'] = 0x0945;
  15230. t['ecandravowelsigngujarati'] = 0x0AC5;
  15231. t['ecaron'] = 0x011B;
  15232. t['ecedillabreve'] = 0x1E1D;
  15233. t['echarmenian'] = 0x0565;
  15234. t['echyiwnarmenian'] = 0x0587;
  15235. t['ecircle'] = 0x24D4;
  15236. t['ecircumflex'] = 0x00EA;
  15237. t['ecircumflexacute'] = 0x1EBF;
  15238. t['ecircumflexbelow'] = 0x1E19;
  15239. t['ecircumflexdotbelow'] = 0x1EC7;
  15240. t['ecircumflexgrave'] = 0x1EC1;
  15241. t['ecircumflexhookabove'] = 0x1EC3;
  15242. t['ecircumflextilde'] = 0x1EC5;
  15243. t['ecyrillic'] = 0x0454;
  15244. t['edblgrave'] = 0x0205;
  15245. t['edeva'] = 0x090F;
  15246. t['edieresis'] = 0x00EB;
  15247. t['edot'] = 0x0117;
  15248. t['edotaccent'] = 0x0117;
  15249. t['edotbelow'] = 0x1EB9;
  15250. t['eegurmukhi'] = 0x0A0F;
  15251. t['eematragurmukhi'] = 0x0A47;
  15252. t['efcyrillic'] = 0x0444;
  15253. t['egrave'] = 0x00E8;
  15254. t['egujarati'] = 0x0A8F;
  15255. t['eharmenian'] = 0x0567;
  15256. t['ehbopomofo'] = 0x311D;
  15257. t['ehiragana'] = 0x3048;
  15258. t['ehookabove'] = 0x1EBB;
  15259. t['eibopomofo'] = 0x311F;
  15260. t['eight'] = 0x0038;
  15261. t['eightarabic'] = 0x0668;
  15262. t['eightbengali'] = 0x09EE;
  15263. t['eightcircle'] = 0x2467;
  15264. t['eightcircleinversesansserif'] = 0x2791;
  15265. t['eightdeva'] = 0x096E;
  15266. t['eighteencircle'] = 0x2471;
  15267. t['eighteenparen'] = 0x2485;
  15268. t['eighteenperiod'] = 0x2499;
  15269. t['eightgujarati'] = 0x0AEE;
  15270. t['eightgurmukhi'] = 0x0A6E;
  15271. t['eighthackarabic'] = 0x0668;
  15272. t['eighthangzhou'] = 0x3028;
  15273. t['eighthnotebeamed'] = 0x266B;
  15274. t['eightideographicparen'] = 0x3227;
  15275. t['eightinferior'] = 0x2088;
  15276. t['eightmonospace'] = 0xFF18;
  15277. t['eightoldstyle'] = 0xF738;
  15278. t['eightparen'] = 0x247B;
  15279. t['eightperiod'] = 0x248F;
  15280. t['eightpersian'] = 0x06F8;
  15281. t['eightroman'] = 0x2177;
  15282. t['eightsuperior'] = 0x2078;
  15283. t['eightthai'] = 0x0E58;
  15284. t['einvertedbreve'] = 0x0207;
  15285. t['eiotifiedcyrillic'] = 0x0465;
  15286. t['ekatakana'] = 0x30A8;
  15287. t['ekatakanahalfwidth'] = 0xFF74;
  15288. t['ekonkargurmukhi'] = 0x0A74;
  15289. t['ekorean'] = 0x3154;
  15290. t['elcyrillic'] = 0x043B;
  15291. t['element'] = 0x2208;
  15292. t['elevencircle'] = 0x246A;
  15293. t['elevenparen'] = 0x247E;
  15294. t['elevenperiod'] = 0x2492;
  15295. t['elevenroman'] = 0x217A;
  15296. t['ellipsis'] = 0x2026;
  15297. t['ellipsisvertical'] = 0x22EE;
  15298. t['emacron'] = 0x0113;
  15299. t['emacronacute'] = 0x1E17;
  15300. t['emacrongrave'] = 0x1E15;
  15301. t['emcyrillic'] = 0x043C;
  15302. t['emdash'] = 0x2014;
  15303. t['emdashvertical'] = 0xFE31;
  15304. t['emonospace'] = 0xFF45;
  15305. t['emphasismarkarmenian'] = 0x055B;
  15306. t['emptyset'] = 0x2205;
  15307. t['enbopomofo'] = 0x3123;
  15308. t['encyrillic'] = 0x043D;
  15309. t['endash'] = 0x2013;
  15310. t['endashvertical'] = 0xFE32;
  15311. t['endescendercyrillic'] = 0x04A3;
  15312. t['eng'] = 0x014B;
  15313. t['engbopomofo'] = 0x3125;
  15314. t['enghecyrillic'] = 0x04A5;
  15315. t['enhookcyrillic'] = 0x04C8;
  15316. t['enspace'] = 0x2002;
  15317. t['eogonek'] = 0x0119;
  15318. t['eokorean'] = 0x3153;
  15319. t['eopen'] = 0x025B;
  15320. t['eopenclosed'] = 0x029A;
  15321. t['eopenreversed'] = 0x025C;
  15322. t['eopenreversedclosed'] = 0x025E;
  15323. t['eopenreversedhook'] = 0x025D;
  15324. t['eparen'] = 0x24A0;
  15325. t['epsilon'] = 0x03B5;
  15326. t['epsilontonos'] = 0x03AD;
  15327. t['equal'] = 0x003D;
  15328. t['equalmonospace'] = 0xFF1D;
  15329. t['equalsmall'] = 0xFE66;
  15330. t['equalsuperior'] = 0x207C;
  15331. t['equivalence'] = 0x2261;
  15332. t['erbopomofo'] = 0x3126;
  15333. t['ercyrillic'] = 0x0440;
  15334. t['ereversed'] = 0x0258;
  15335. t['ereversedcyrillic'] = 0x044D;
  15336. t['escyrillic'] = 0x0441;
  15337. t['esdescendercyrillic'] = 0x04AB;
  15338. t['esh'] = 0x0283;
  15339. t['eshcurl'] = 0x0286;
  15340. t['eshortdeva'] = 0x090E;
  15341. t['eshortvowelsigndeva'] = 0x0946;
  15342. t['eshreversedloop'] = 0x01AA;
  15343. t['eshsquatreversed'] = 0x0285;
  15344. t['esmallhiragana'] = 0x3047;
  15345. t['esmallkatakana'] = 0x30A7;
  15346. t['esmallkatakanahalfwidth'] = 0xFF6A;
  15347. t['estimated'] = 0x212E;
  15348. t['esuperior'] = 0xF6EC;
  15349. t['eta'] = 0x03B7;
  15350. t['etarmenian'] = 0x0568;
  15351. t['etatonos'] = 0x03AE;
  15352. t['eth'] = 0x00F0;
  15353. t['etilde'] = 0x1EBD;
  15354. t['etildebelow'] = 0x1E1B;
  15355. t['etnahtafoukhhebrew'] = 0x0591;
  15356. t['etnahtafoukhlefthebrew'] = 0x0591;
  15357. t['etnahtahebrew'] = 0x0591;
  15358. t['etnahtalefthebrew'] = 0x0591;
  15359. t['eturned'] = 0x01DD;
  15360. t['eukorean'] = 0x3161;
  15361. t['euro'] = 0x20AC;
  15362. t['evowelsignbengali'] = 0x09C7;
  15363. t['evowelsigndeva'] = 0x0947;
  15364. t['evowelsigngujarati'] = 0x0AC7;
  15365. t['exclam'] = 0x0021;
  15366. t['exclamarmenian'] = 0x055C;
  15367. t['exclamdbl'] = 0x203C;
  15368. t['exclamdown'] = 0x00A1;
  15369. t['exclamdownsmall'] = 0xF7A1;
  15370. t['exclammonospace'] = 0xFF01;
  15371. t['exclamsmall'] = 0xF721;
  15372. t['existential'] = 0x2203;
  15373. t['ezh'] = 0x0292;
  15374. t['ezhcaron'] = 0x01EF;
  15375. t['ezhcurl'] = 0x0293;
  15376. t['ezhreversed'] = 0x01B9;
  15377. t['ezhtail'] = 0x01BA;
  15378. t['f'] = 0x0066;
  15379. t['fadeva'] = 0x095E;
  15380. t['fagurmukhi'] = 0x0A5E;
  15381. t['fahrenheit'] = 0x2109;
  15382. t['fathaarabic'] = 0x064E;
  15383. t['fathalowarabic'] = 0x064E;
  15384. t['fathatanarabic'] = 0x064B;
  15385. t['fbopomofo'] = 0x3108;
  15386. t['fcircle'] = 0x24D5;
  15387. t['fdotaccent'] = 0x1E1F;
  15388. t['feharabic'] = 0x0641;
  15389. t['feharmenian'] = 0x0586;
  15390. t['fehfinalarabic'] = 0xFED2;
  15391. t['fehinitialarabic'] = 0xFED3;
  15392. t['fehmedialarabic'] = 0xFED4;
  15393. t['feicoptic'] = 0x03E5;
  15394. t['female'] = 0x2640;
  15395. t['ff'] = 0xFB00;
  15396. t['ffi'] = 0xFB03;
  15397. t['ffl'] = 0xFB04;
  15398. t['fi'] = 0xFB01;
  15399. t['fifteencircle'] = 0x246E;
  15400. t['fifteenparen'] = 0x2482;
  15401. t['fifteenperiod'] = 0x2496;
  15402. t['figuredash'] = 0x2012;
  15403. t['filledbox'] = 0x25A0;
  15404. t['filledrect'] = 0x25AC;
  15405. t['finalkaf'] = 0x05DA;
  15406. t['finalkafdagesh'] = 0xFB3A;
  15407. t['finalkafdageshhebrew'] = 0xFB3A;
  15408. t['finalkafhebrew'] = 0x05DA;
  15409. t['finalmem'] = 0x05DD;
  15410. t['finalmemhebrew'] = 0x05DD;
  15411. t['finalnun'] = 0x05DF;
  15412. t['finalnunhebrew'] = 0x05DF;
  15413. t['finalpe'] = 0x05E3;
  15414. t['finalpehebrew'] = 0x05E3;
  15415. t['finaltsadi'] = 0x05E5;
  15416. t['finaltsadihebrew'] = 0x05E5;
  15417. t['firsttonechinese'] = 0x02C9;
  15418. t['fisheye'] = 0x25C9;
  15419. t['fitacyrillic'] = 0x0473;
  15420. t['five'] = 0x0035;
  15421. t['fivearabic'] = 0x0665;
  15422. t['fivebengali'] = 0x09EB;
  15423. t['fivecircle'] = 0x2464;
  15424. t['fivecircleinversesansserif'] = 0x278E;
  15425. t['fivedeva'] = 0x096B;
  15426. t['fiveeighths'] = 0x215D;
  15427. t['fivegujarati'] = 0x0AEB;
  15428. t['fivegurmukhi'] = 0x0A6B;
  15429. t['fivehackarabic'] = 0x0665;
  15430. t['fivehangzhou'] = 0x3025;
  15431. t['fiveideographicparen'] = 0x3224;
  15432. t['fiveinferior'] = 0x2085;
  15433. t['fivemonospace'] = 0xFF15;
  15434. t['fiveoldstyle'] = 0xF735;
  15435. t['fiveparen'] = 0x2478;
  15436. t['fiveperiod'] = 0x248C;
  15437. t['fivepersian'] = 0x06F5;
  15438. t['fiveroman'] = 0x2174;
  15439. t['fivesuperior'] = 0x2075;
  15440. t['fivethai'] = 0x0E55;
  15441. t['fl'] = 0xFB02;
  15442. t['florin'] = 0x0192;
  15443. t['fmonospace'] = 0xFF46;
  15444. t['fmsquare'] = 0x3399;
  15445. t['fofanthai'] = 0x0E1F;
  15446. t['fofathai'] = 0x0E1D;
  15447. t['fongmanthai'] = 0x0E4F;
  15448. t['forall'] = 0x2200;
  15449. t['four'] = 0x0034;
  15450. t['fourarabic'] = 0x0664;
  15451. t['fourbengali'] = 0x09EA;
  15452. t['fourcircle'] = 0x2463;
  15453. t['fourcircleinversesansserif'] = 0x278D;
  15454. t['fourdeva'] = 0x096A;
  15455. t['fourgujarati'] = 0x0AEA;
  15456. t['fourgurmukhi'] = 0x0A6A;
  15457. t['fourhackarabic'] = 0x0664;
  15458. t['fourhangzhou'] = 0x3024;
  15459. t['fourideographicparen'] = 0x3223;
  15460. t['fourinferior'] = 0x2084;
  15461. t['fourmonospace'] = 0xFF14;
  15462. t['fournumeratorbengali'] = 0x09F7;
  15463. t['fouroldstyle'] = 0xF734;
  15464. t['fourparen'] = 0x2477;
  15465. t['fourperiod'] = 0x248B;
  15466. t['fourpersian'] = 0x06F4;
  15467. t['fourroman'] = 0x2173;
  15468. t['foursuperior'] = 0x2074;
  15469. t['fourteencircle'] = 0x246D;
  15470. t['fourteenparen'] = 0x2481;
  15471. t['fourteenperiod'] = 0x2495;
  15472. t['fourthai'] = 0x0E54;
  15473. t['fourthtonechinese'] = 0x02CB;
  15474. t['fparen'] = 0x24A1;
  15475. t['fraction'] = 0x2044;
  15476. t['franc'] = 0x20A3;
  15477. t['g'] = 0x0067;
  15478. t['gabengali'] = 0x0997;
  15479. t['gacute'] = 0x01F5;
  15480. t['gadeva'] = 0x0917;
  15481. t['gafarabic'] = 0x06AF;
  15482. t['gaffinalarabic'] = 0xFB93;
  15483. t['gafinitialarabic'] = 0xFB94;
  15484. t['gafmedialarabic'] = 0xFB95;
  15485. t['gagujarati'] = 0x0A97;
  15486. t['gagurmukhi'] = 0x0A17;
  15487. t['gahiragana'] = 0x304C;
  15488. t['gakatakana'] = 0x30AC;
  15489. t['gamma'] = 0x03B3;
  15490. t['gammalatinsmall'] = 0x0263;
  15491. t['gammasuperior'] = 0x02E0;
  15492. t['gangiacoptic'] = 0x03EB;
  15493. t['gbopomofo'] = 0x310D;
  15494. t['gbreve'] = 0x011F;
  15495. t['gcaron'] = 0x01E7;
  15496. t['gcedilla'] = 0x0123;
  15497. t['gcircle'] = 0x24D6;
  15498. t['gcircumflex'] = 0x011D;
  15499. t['gcommaaccent'] = 0x0123;
  15500. t['gdot'] = 0x0121;
  15501. t['gdotaccent'] = 0x0121;
  15502. t['gecyrillic'] = 0x0433;
  15503. t['gehiragana'] = 0x3052;
  15504. t['gekatakana'] = 0x30B2;
  15505. t['geometricallyequal'] = 0x2251;
  15506. t['gereshaccenthebrew'] = 0x059C;
  15507. t['gereshhebrew'] = 0x05F3;
  15508. t['gereshmuqdamhebrew'] = 0x059D;
  15509. t['germandbls'] = 0x00DF;
  15510. t['gershayimaccenthebrew'] = 0x059E;
  15511. t['gershayimhebrew'] = 0x05F4;
  15512. t['getamark'] = 0x3013;
  15513. t['ghabengali'] = 0x0998;
  15514. t['ghadarmenian'] = 0x0572;
  15515. t['ghadeva'] = 0x0918;
  15516. t['ghagujarati'] = 0x0A98;
  15517. t['ghagurmukhi'] = 0x0A18;
  15518. t['ghainarabic'] = 0x063A;
  15519. t['ghainfinalarabic'] = 0xFECE;
  15520. t['ghaininitialarabic'] = 0xFECF;
  15521. t['ghainmedialarabic'] = 0xFED0;
  15522. t['ghemiddlehookcyrillic'] = 0x0495;
  15523. t['ghestrokecyrillic'] = 0x0493;
  15524. t['gheupturncyrillic'] = 0x0491;
  15525. t['ghhadeva'] = 0x095A;
  15526. t['ghhagurmukhi'] = 0x0A5A;
  15527. t['ghook'] = 0x0260;
  15528. t['ghzsquare'] = 0x3393;
  15529. t['gihiragana'] = 0x304E;
  15530. t['gikatakana'] = 0x30AE;
  15531. t['gimarmenian'] = 0x0563;
  15532. t['gimel'] = 0x05D2;
  15533. t['gimeldagesh'] = 0xFB32;
  15534. t['gimeldageshhebrew'] = 0xFB32;
  15535. t['gimelhebrew'] = 0x05D2;
  15536. t['gjecyrillic'] = 0x0453;
  15537. t['glottalinvertedstroke'] = 0x01BE;
  15538. t['glottalstop'] = 0x0294;
  15539. t['glottalstopinverted'] = 0x0296;
  15540. t['glottalstopmod'] = 0x02C0;
  15541. t['glottalstopreversed'] = 0x0295;
  15542. t['glottalstopreversedmod'] = 0x02C1;
  15543. t['glottalstopreversedsuperior'] = 0x02E4;
  15544. t['glottalstopstroke'] = 0x02A1;
  15545. t['glottalstopstrokereversed'] = 0x02A2;
  15546. t['gmacron'] = 0x1E21;
  15547. t['gmonospace'] = 0xFF47;
  15548. t['gohiragana'] = 0x3054;
  15549. t['gokatakana'] = 0x30B4;
  15550. t['gparen'] = 0x24A2;
  15551. t['gpasquare'] = 0x33AC;
  15552. t['gradient'] = 0x2207;
  15553. t['grave'] = 0x0060;
  15554. t['gravebelowcmb'] = 0x0316;
  15555. t['gravecmb'] = 0x0300;
  15556. t['gravecomb'] = 0x0300;
  15557. t['gravedeva'] = 0x0953;
  15558. t['gravelowmod'] = 0x02CE;
  15559. t['gravemonospace'] = 0xFF40;
  15560. t['gravetonecmb'] = 0x0340;
  15561. t['greater'] = 0x003E;
  15562. t['greaterequal'] = 0x2265;
  15563. t['greaterequalorless'] = 0x22DB;
  15564. t['greatermonospace'] = 0xFF1E;
  15565. t['greaterorequivalent'] = 0x2273;
  15566. t['greaterorless'] = 0x2277;
  15567. t['greateroverequal'] = 0x2267;
  15568. t['greatersmall'] = 0xFE65;
  15569. t['gscript'] = 0x0261;
  15570. t['gstroke'] = 0x01E5;
  15571. t['guhiragana'] = 0x3050;
  15572. t['guillemotleft'] = 0x00AB;
  15573. t['guillemotright'] = 0x00BB;
  15574. t['guilsinglleft'] = 0x2039;
  15575. t['guilsinglright'] = 0x203A;
  15576. t['gukatakana'] = 0x30B0;
  15577. t['guramusquare'] = 0x3318;
  15578. t['gysquare'] = 0x33C9;
  15579. t['h'] = 0x0068;
  15580. t['haabkhasiancyrillic'] = 0x04A9;
  15581. t['haaltonearabic'] = 0x06C1;
  15582. t['habengali'] = 0x09B9;
  15583. t['hadescendercyrillic'] = 0x04B3;
  15584. t['hadeva'] = 0x0939;
  15585. t['hagujarati'] = 0x0AB9;
  15586. t['hagurmukhi'] = 0x0A39;
  15587. t['haharabic'] = 0x062D;
  15588. t['hahfinalarabic'] = 0xFEA2;
  15589. t['hahinitialarabic'] = 0xFEA3;
  15590. t['hahiragana'] = 0x306F;
  15591. t['hahmedialarabic'] = 0xFEA4;
  15592. t['haitusquare'] = 0x332A;
  15593. t['hakatakana'] = 0x30CF;
  15594. t['hakatakanahalfwidth'] = 0xFF8A;
  15595. t['halantgurmukhi'] = 0x0A4D;
  15596. t['hamzaarabic'] = 0x0621;
  15597. t['hamzalowarabic'] = 0x0621;
  15598. t['hangulfiller'] = 0x3164;
  15599. t['hardsigncyrillic'] = 0x044A;
  15600. t['harpoonleftbarbup'] = 0x21BC;
  15601. t['harpoonrightbarbup'] = 0x21C0;
  15602. t['hasquare'] = 0x33CA;
  15603. t['hatafpatah'] = 0x05B2;
  15604. t['hatafpatah16'] = 0x05B2;
  15605. t['hatafpatah23'] = 0x05B2;
  15606. t['hatafpatah2f'] = 0x05B2;
  15607. t['hatafpatahhebrew'] = 0x05B2;
  15608. t['hatafpatahnarrowhebrew'] = 0x05B2;
  15609. t['hatafpatahquarterhebrew'] = 0x05B2;
  15610. t['hatafpatahwidehebrew'] = 0x05B2;
  15611. t['hatafqamats'] = 0x05B3;
  15612. t['hatafqamats1b'] = 0x05B3;
  15613. t['hatafqamats28'] = 0x05B3;
  15614. t['hatafqamats34'] = 0x05B3;
  15615. t['hatafqamatshebrew'] = 0x05B3;
  15616. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  15617. t['hatafqamatsquarterhebrew'] = 0x05B3;
  15618. t['hatafqamatswidehebrew'] = 0x05B3;
  15619. t['hatafsegol'] = 0x05B1;
  15620. t['hatafsegol17'] = 0x05B1;
  15621. t['hatafsegol24'] = 0x05B1;
  15622. t['hatafsegol30'] = 0x05B1;
  15623. t['hatafsegolhebrew'] = 0x05B1;
  15624. t['hatafsegolnarrowhebrew'] = 0x05B1;
  15625. t['hatafsegolquarterhebrew'] = 0x05B1;
  15626. t['hatafsegolwidehebrew'] = 0x05B1;
  15627. t['hbar'] = 0x0127;
  15628. t['hbopomofo'] = 0x310F;
  15629. t['hbrevebelow'] = 0x1E2B;
  15630. t['hcedilla'] = 0x1E29;
  15631. t['hcircle'] = 0x24D7;
  15632. t['hcircumflex'] = 0x0125;
  15633. t['hdieresis'] = 0x1E27;
  15634. t['hdotaccent'] = 0x1E23;
  15635. t['hdotbelow'] = 0x1E25;
  15636. t['he'] = 0x05D4;
  15637. t['heart'] = 0x2665;
  15638. t['heartsuitblack'] = 0x2665;
  15639. t['heartsuitwhite'] = 0x2661;
  15640. t['hedagesh'] = 0xFB34;
  15641. t['hedageshhebrew'] = 0xFB34;
  15642. t['hehaltonearabic'] = 0x06C1;
  15643. t['heharabic'] = 0x0647;
  15644. t['hehebrew'] = 0x05D4;
  15645. t['hehfinalaltonearabic'] = 0xFBA7;
  15646. t['hehfinalalttwoarabic'] = 0xFEEA;
  15647. t['hehfinalarabic'] = 0xFEEA;
  15648. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  15649. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  15650. t['hehinitialaltonearabic'] = 0xFBA8;
  15651. t['hehinitialarabic'] = 0xFEEB;
  15652. t['hehiragana'] = 0x3078;
  15653. t['hehmedialaltonearabic'] = 0xFBA9;
  15654. t['hehmedialarabic'] = 0xFEEC;
  15655. t['heiseierasquare'] = 0x337B;
  15656. t['hekatakana'] = 0x30D8;
  15657. t['hekatakanahalfwidth'] = 0xFF8D;
  15658. t['hekutaarusquare'] = 0x3336;
  15659. t['henghook'] = 0x0267;
  15660. t['herutusquare'] = 0x3339;
  15661. t['het'] = 0x05D7;
  15662. t['hethebrew'] = 0x05D7;
  15663. t['hhook'] = 0x0266;
  15664. t['hhooksuperior'] = 0x02B1;
  15665. t['hieuhacirclekorean'] = 0x327B;
  15666. t['hieuhaparenkorean'] = 0x321B;
  15667. t['hieuhcirclekorean'] = 0x326D;
  15668. t['hieuhkorean'] = 0x314E;
  15669. t['hieuhparenkorean'] = 0x320D;
  15670. t['hihiragana'] = 0x3072;
  15671. t['hikatakana'] = 0x30D2;
  15672. t['hikatakanahalfwidth'] = 0xFF8B;
  15673. t['hiriq'] = 0x05B4;
  15674. t['hiriq14'] = 0x05B4;
  15675. t['hiriq21'] = 0x05B4;
  15676. t['hiriq2d'] = 0x05B4;
  15677. t['hiriqhebrew'] = 0x05B4;
  15678. t['hiriqnarrowhebrew'] = 0x05B4;
  15679. t['hiriqquarterhebrew'] = 0x05B4;
  15680. t['hiriqwidehebrew'] = 0x05B4;
  15681. t['hlinebelow'] = 0x1E96;
  15682. t['hmonospace'] = 0xFF48;
  15683. t['hoarmenian'] = 0x0570;
  15684. t['hohipthai'] = 0x0E2B;
  15685. t['hohiragana'] = 0x307B;
  15686. t['hokatakana'] = 0x30DB;
  15687. t['hokatakanahalfwidth'] = 0xFF8E;
  15688. t['holam'] = 0x05B9;
  15689. t['holam19'] = 0x05B9;
  15690. t['holam26'] = 0x05B9;
  15691. t['holam32'] = 0x05B9;
  15692. t['holamhebrew'] = 0x05B9;
  15693. t['holamnarrowhebrew'] = 0x05B9;
  15694. t['holamquarterhebrew'] = 0x05B9;
  15695. t['holamwidehebrew'] = 0x05B9;
  15696. t['honokhukthai'] = 0x0E2E;
  15697. t['hookabovecomb'] = 0x0309;
  15698. t['hookcmb'] = 0x0309;
  15699. t['hookpalatalizedbelowcmb'] = 0x0321;
  15700. t['hookretroflexbelowcmb'] = 0x0322;
  15701. t['hoonsquare'] = 0x3342;
  15702. t['horicoptic'] = 0x03E9;
  15703. t['horizontalbar'] = 0x2015;
  15704. t['horncmb'] = 0x031B;
  15705. t['hotsprings'] = 0x2668;
  15706. t['house'] = 0x2302;
  15707. t['hparen'] = 0x24A3;
  15708. t['hsuperior'] = 0x02B0;
  15709. t['hturned'] = 0x0265;
  15710. t['huhiragana'] = 0x3075;
  15711. t['huiitosquare'] = 0x3333;
  15712. t['hukatakana'] = 0x30D5;
  15713. t['hukatakanahalfwidth'] = 0xFF8C;
  15714. t['hungarumlaut'] = 0x02DD;
  15715. t['hungarumlautcmb'] = 0x030B;
  15716. t['hv'] = 0x0195;
  15717. t['hyphen'] = 0x002D;
  15718. t['hypheninferior'] = 0xF6E5;
  15719. t['hyphenmonospace'] = 0xFF0D;
  15720. t['hyphensmall'] = 0xFE63;
  15721. t['hyphensuperior'] = 0xF6E6;
  15722. t['hyphentwo'] = 0x2010;
  15723. t['i'] = 0x0069;
  15724. t['iacute'] = 0x00ED;
  15725. t['iacyrillic'] = 0x044F;
  15726. t['ibengali'] = 0x0987;
  15727. t['ibopomofo'] = 0x3127;
  15728. t['ibreve'] = 0x012D;
  15729. t['icaron'] = 0x01D0;
  15730. t['icircle'] = 0x24D8;
  15731. t['icircumflex'] = 0x00EE;
  15732. t['icyrillic'] = 0x0456;
  15733. t['idblgrave'] = 0x0209;
  15734. t['ideographearthcircle'] = 0x328F;
  15735. t['ideographfirecircle'] = 0x328B;
  15736. t['ideographicallianceparen'] = 0x323F;
  15737. t['ideographiccallparen'] = 0x323A;
  15738. t['ideographiccentrecircle'] = 0x32A5;
  15739. t['ideographicclose'] = 0x3006;
  15740. t['ideographiccomma'] = 0x3001;
  15741. t['ideographiccommaleft'] = 0xFF64;
  15742. t['ideographiccongratulationparen'] = 0x3237;
  15743. t['ideographiccorrectcircle'] = 0x32A3;
  15744. t['ideographicearthparen'] = 0x322F;
  15745. t['ideographicenterpriseparen'] = 0x323D;
  15746. t['ideographicexcellentcircle'] = 0x329D;
  15747. t['ideographicfestivalparen'] = 0x3240;
  15748. t['ideographicfinancialcircle'] = 0x3296;
  15749. t['ideographicfinancialparen'] = 0x3236;
  15750. t['ideographicfireparen'] = 0x322B;
  15751. t['ideographichaveparen'] = 0x3232;
  15752. t['ideographichighcircle'] = 0x32A4;
  15753. t['ideographiciterationmark'] = 0x3005;
  15754. t['ideographiclaborcircle'] = 0x3298;
  15755. t['ideographiclaborparen'] = 0x3238;
  15756. t['ideographicleftcircle'] = 0x32A7;
  15757. t['ideographiclowcircle'] = 0x32A6;
  15758. t['ideographicmedicinecircle'] = 0x32A9;
  15759. t['ideographicmetalparen'] = 0x322E;
  15760. t['ideographicmoonparen'] = 0x322A;
  15761. t['ideographicnameparen'] = 0x3234;
  15762. t['ideographicperiod'] = 0x3002;
  15763. t['ideographicprintcircle'] = 0x329E;
  15764. t['ideographicreachparen'] = 0x3243;
  15765. t['ideographicrepresentparen'] = 0x3239;
  15766. t['ideographicresourceparen'] = 0x323E;
  15767. t['ideographicrightcircle'] = 0x32A8;
  15768. t['ideographicsecretcircle'] = 0x3299;
  15769. t['ideographicselfparen'] = 0x3242;
  15770. t['ideographicsocietyparen'] = 0x3233;
  15771. t['ideographicspace'] = 0x3000;
  15772. t['ideographicspecialparen'] = 0x3235;
  15773. t['ideographicstockparen'] = 0x3231;
  15774. t['ideographicstudyparen'] = 0x323B;
  15775. t['ideographicsunparen'] = 0x3230;
  15776. t['ideographicsuperviseparen'] = 0x323C;
  15777. t['ideographicwaterparen'] = 0x322C;
  15778. t['ideographicwoodparen'] = 0x322D;
  15779. t['ideographiczero'] = 0x3007;
  15780. t['ideographmetalcircle'] = 0x328E;
  15781. t['ideographmooncircle'] = 0x328A;
  15782. t['ideographnamecircle'] = 0x3294;
  15783. t['ideographsuncircle'] = 0x3290;
  15784. t['ideographwatercircle'] = 0x328C;
  15785. t['ideographwoodcircle'] = 0x328D;
  15786. t['ideva'] = 0x0907;
  15787. t['idieresis'] = 0x00EF;
  15788. t['idieresisacute'] = 0x1E2F;
  15789. t['idieresiscyrillic'] = 0x04E5;
  15790. t['idotbelow'] = 0x1ECB;
  15791. t['iebrevecyrillic'] = 0x04D7;
  15792. t['iecyrillic'] = 0x0435;
  15793. t['ieungacirclekorean'] = 0x3275;
  15794. t['ieungaparenkorean'] = 0x3215;
  15795. t['ieungcirclekorean'] = 0x3267;
  15796. t['ieungkorean'] = 0x3147;
  15797. t['ieungparenkorean'] = 0x3207;
  15798. t['igrave'] = 0x00EC;
  15799. t['igujarati'] = 0x0A87;
  15800. t['igurmukhi'] = 0x0A07;
  15801. t['ihiragana'] = 0x3044;
  15802. t['ihookabove'] = 0x1EC9;
  15803. t['iibengali'] = 0x0988;
  15804. t['iicyrillic'] = 0x0438;
  15805. t['iideva'] = 0x0908;
  15806. t['iigujarati'] = 0x0A88;
  15807. t['iigurmukhi'] = 0x0A08;
  15808. t['iimatragurmukhi'] = 0x0A40;
  15809. t['iinvertedbreve'] = 0x020B;
  15810. t['iishortcyrillic'] = 0x0439;
  15811. t['iivowelsignbengali'] = 0x09C0;
  15812. t['iivowelsigndeva'] = 0x0940;
  15813. t['iivowelsigngujarati'] = 0x0AC0;
  15814. t['ij'] = 0x0133;
  15815. t['ikatakana'] = 0x30A4;
  15816. t['ikatakanahalfwidth'] = 0xFF72;
  15817. t['ikorean'] = 0x3163;
  15818. t['ilde'] = 0x02DC;
  15819. t['iluyhebrew'] = 0x05AC;
  15820. t['imacron'] = 0x012B;
  15821. t['imacroncyrillic'] = 0x04E3;
  15822. t['imageorapproximatelyequal'] = 0x2253;
  15823. t['imatragurmukhi'] = 0x0A3F;
  15824. t['imonospace'] = 0xFF49;
  15825. t['increment'] = 0x2206;
  15826. t['infinity'] = 0x221E;
  15827. t['iniarmenian'] = 0x056B;
  15828. t['integral'] = 0x222B;
  15829. t['integralbottom'] = 0x2321;
  15830. t['integralbt'] = 0x2321;
  15831. t['integralex'] = 0xF8F5;
  15832. t['integraltop'] = 0x2320;
  15833. t['integraltp'] = 0x2320;
  15834. t['intersection'] = 0x2229;
  15835. t['intisquare'] = 0x3305;
  15836. t['invbullet'] = 0x25D8;
  15837. t['invcircle'] = 0x25D9;
  15838. t['invsmileface'] = 0x263B;
  15839. t['iocyrillic'] = 0x0451;
  15840. t['iogonek'] = 0x012F;
  15841. t['iota'] = 0x03B9;
  15842. t['iotadieresis'] = 0x03CA;
  15843. t['iotadieresistonos'] = 0x0390;
  15844. t['iotalatin'] = 0x0269;
  15845. t['iotatonos'] = 0x03AF;
  15846. t['iparen'] = 0x24A4;
  15847. t['irigurmukhi'] = 0x0A72;
  15848. t['ismallhiragana'] = 0x3043;
  15849. t['ismallkatakana'] = 0x30A3;
  15850. t['ismallkatakanahalfwidth'] = 0xFF68;
  15851. t['issharbengali'] = 0x09FA;
  15852. t['istroke'] = 0x0268;
  15853. t['isuperior'] = 0xF6ED;
  15854. t['iterationhiragana'] = 0x309D;
  15855. t['iterationkatakana'] = 0x30FD;
  15856. t['itilde'] = 0x0129;
  15857. t['itildebelow'] = 0x1E2D;
  15858. t['iubopomofo'] = 0x3129;
  15859. t['iucyrillic'] = 0x044E;
  15860. t['ivowelsignbengali'] = 0x09BF;
  15861. t['ivowelsigndeva'] = 0x093F;
  15862. t['ivowelsigngujarati'] = 0x0ABF;
  15863. t['izhitsacyrillic'] = 0x0475;
  15864. t['izhitsadblgravecyrillic'] = 0x0477;
  15865. t['j'] = 0x006A;
  15866. t['jaarmenian'] = 0x0571;
  15867. t['jabengali'] = 0x099C;
  15868. t['jadeva'] = 0x091C;
  15869. t['jagujarati'] = 0x0A9C;
  15870. t['jagurmukhi'] = 0x0A1C;
  15871. t['jbopomofo'] = 0x3110;
  15872. t['jcaron'] = 0x01F0;
  15873. t['jcircle'] = 0x24D9;
  15874. t['jcircumflex'] = 0x0135;
  15875. t['jcrossedtail'] = 0x029D;
  15876. t['jdotlessstroke'] = 0x025F;
  15877. t['jecyrillic'] = 0x0458;
  15878. t['jeemarabic'] = 0x062C;
  15879. t['jeemfinalarabic'] = 0xFE9E;
  15880. t['jeeminitialarabic'] = 0xFE9F;
  15881. t['jeemmedialarabic'] = 0xFEA0;
  15882. t['jeharabic'] = 0x0698;
  15883. t['jehfinalarabic'] = 0xFB8B;
  15884. t['jhabengali'] = 0x099D;
  15885. t['jhadeva'] = 0x091D;
  15886. t['jhagujarati'] = 0x0A9D;
  15887. t['jhagurmukhi'] = 0x0A1D;
  15888. t['jheharmenian'] = 0x057B;
  15889. t['jis'] = 0x3004;
  15890. t['jmonospace'] = 0xFF4A;
  15891. t['jparen'] = 0x24A5;
  15892. t['jsuperior'] = 0x02B2;
  15893. t['k'] = 0x006B;
  15894. t['kabashkircyrillic'] = 0x04A1;
  15895. t['kabengali'] = 0x0995;
  15896. t['kacute'] = 0x1E31;
  15897. t['kacyrillic'] = 0x043A;
  15898. t['kadescendercyrillic'] = 0x049B;
  15899. t['kadeva'] = 0x0915;
  15900. t['kaf'] = 0x05DB;
  15901. t['kafarabic'] = 0x0643;
  15902. t['kafdagesh'] = 0xFB3B;
  15903. t['kafdageshhebrew'] = 0xFB3B;
  15904. t['kaffinalarabic'] = 0xFEDA;
  15905. t['kafhebrew'] = 0x05DB;
  15906. t['kafinitialarabic'] = 0xFEDB;
  15907. t['kafmedialarabic'] = 0xFEDC;
  15908. t['kafrafehebrew'] = 0xFB4D;
  15909. t['kagujarati'] = 0x0A95;
  15910. t['kagurmukhi'] = 0x0A15;
  15911. t['kahiragana'] = 0x304B;
  15912. t['kahookcyrillic'] = 0x04C4;
  15913. t['kakatakana'] = 0x30AB;
  15914. t['kakatakanahalfwidth'] = 0xFF76;
  15915. t['kappa'] = 0x03BA;
  15916. t['kappasymbolgreek'] = 0x03F0;
  15917. t['kapyeounmieumkorean'] = 0x3171;
  15918. t['kapyeounphieuphkorean'] = 0x3184;
  15919. t['kapyeounpieupkorean'] = 0x3178;
  15920. t['kapyeounssangpieupkorean'] = 0x3179;
  15921. t['karoriisquare'] = 0x330D;
  15922. t['kashidaautoarabic'] = 0x0640;
  15923. t['kashidaautonosidebearingarabic'] = 0x0640;
  15924. t['kasmallkatakana'] = 0x30F5;
  15925. t['kasquare'] = 0x3384;
  15926. t['kasraarabic'] = 0x0650;
  15927. t['kasratanarabic'] = 0x064D;
  15928. t['kastrokecyrillic'] = 0x049F;
  15929. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  15930. t['kaverticalstrokecyrillic'] = 0x049D;
  15931. t['kbopomofo'] = 0x310E;
  15932. t['kcalsquare'] = 0x3389;
  15933. t['kcaron'] = 0x01E9;
  15934. t['kcedilla'] = 0x0137;
  15935. t['kcircle'] = 0x24DA;
  15936. t['kcommaaccent'] = 0x0137;
  15937. t['kdotbelow'] = 0x1E33;
  15938. t['keharmenian'] = 0x0584;
  15939. t['kehiragana'] = 0x3051;
  15940. t['kekatakana'] = 0x30B1;
  15941. t['kekatakanahalfwidth'] = 0xFF79;
  15942. t['kenarmenian'] = 0x056F;
  15943. t['kesmallkatakana'] = 0x30F6;
  15944. t['kgreenlandic'] = 0x0138;
  15945. t['khabengali'] = 0x0996;
  15946. t['khacyrillic'] = 0x0445;
  15947. t['khadeva'] = 0x0916;
  15948. t['khagujarati'] = 0x0A96;
  15949. t['khagurmukhi'] = 0x0A16;
  15950. t['khaharabic'] = 0x062E;
  15951. t['khahfinalarabic'] = 0xFEA6;
  15952. t['khahinitialarabic'] = 0xFEA7;
  15953. t['khahmedialarabic'] = 0xFEA8;
  15954. t['kheicoptic'] = 0x03E7;
  15955. t['khhadeva'] = 0x0959;
  15956. t['khhagurmukhi'] = 0x0A59;
  15957. t['khieukhacirclekorean'] = 0x3278;
  15958. t['khieukhaparenkorean'] = 0x3218;
  15959. t['khieukhcirclekorean'] = 0x326A;
  15960. t['khieukhkorean'] = 0x314B;
  15961. t['khieukhparenkorean'] = 0x320A;
  15962. t['khokhaithai'] = 0x0E02;
  15963. t['khokhonthai'] = 0x0E05;
  15964. t['khokhuatthai'] = 0x0E03;
  15965. t['khokhwaithai'] = 0x0E04;
  15966. t['khomutthai'] = 0x0E5B;
  15967. t['khook'] = 0x0199;
  15968. t['khorakhangthai'] = 0x0E06;
  15969. t['khzsquare'] = 0x3391;
  15970. t['kihiragana'] = 0x304D;
  15971. t['kikatakana'] = 0x30AD;
  15972. t['kikatakanahalfwidth'] = 0xFF77;
  15973. t['kiroguramusquare'] = 0x3315;
  15974. t['kiromeetorusquare'] = 0x3316;
  15975. t['kirosquare'] = 0x3314;
  15976. t['kiyeokacirclekorean'] = 0x326E;
  15977. t['kiyeokaparenkorean'] = 0x320E;
  15978. t['kiyeokcirclekorean'] = 0x3260;
  15979. t['kiyeokkorean'] = 0x3131;
  15980. t['kiyeokparenkorean'] = 0x3200;
  15981. t['kiyeoksioskorean'] = 0x3133;
  15982. t['kjecyrillic'] = 0x045C;
  15983. t['klinebelow'] = 0x1E35;
  15984. t['klsquare'] = 0x3398;
  15985. t['kmcubedsquare'] = 0x33A6;
  15986. t['kmonospace'] = 0xFF4B;
  15987. t['kmsquaredsquare'] = 0x33A2;
  15988. t['kohiragana'] = 0x3053;
  15989. t['kohmsquare'] = 0x33C0;
  15990. t['kokaithai'] = 0x0E01;
  15991. t['kokatakana'] = 0x30B3;
  15992. t['kokatakanahalfwidth'] = 0xFF7A;
  15993. t['kooposquare'] = 0x331E;
  15994. t['koppacyrillic'] = 0x0481;
  15995. t['koreanstandardsymbol'] = 0x327F;
  15996. t['koroniscmb'] = 0x0343;
  15997. t['kparen'] = 0x24A6;
  15998. t['kpasquare'] = 0x33AA;
  15999. t['ksicyrillic'] = 0x046F;
  16000. t['ktsquare'] = 0x33CF;
  16001. t['kturned'] = 0x029E;
  16002. t['kuhiragana'] = 0x304F;
  16003. t['kukatakana'] = 0x30AF;
  16004. t['kukatakanahalfwidth'] = 0xFF78;
  16005. t['kvsquare'] = 0x33B8;
  16006. t['kwsquare'] = 0x33BE;
  16007. t['l'] = 0x006C;
  16008. t['labengali'] = 0x09B2;
  16009. t['lacute'] = 0x013A;
  16010. t['ladeva'] = 0x0932;
  16011. t['lagujarati'] = 0x0AB2;
  16012. t['lagurmukhi'] = 0x0A32;
  16013. t['lakkhangyaothai'] = 0x0E45;
  16014. t['lamaleffinalarabic'] = 0xFEFC;
  16015. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16016. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16017. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16018. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16019. t['lamalefisolatedarabic'] = 0xFEFB;
  16020. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16021. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16022. t['lamarabic'] = 0x0644;
  16023. t['lambda'] = 0x03BB;
  16024. t['lambdastroke'] = 0x019B;
  16025. t['lamed'] = 0x05DC;
  16026. t['lameddagesh'] = 0xFB3C;
  16027. t['lameddageshhebrew'] = 0xFB3C;
  16028. t['lamedhebrew'] = 0x05DC;
  16029. t['lamfinalarabic'] = 0xFEDE;
  16030. t['lamhahinitialarabic'] = 0xFCCA;
  16031. t['laminitialarabic'] = 0xFEDF;
  16032. t['lamjeeminitialarabic'] = 0xFCC9;
  16033. t['lamkhahinitialarabic'] = 0xFCCB;
  16034. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16035. t['lammedialarabic'] = 0xFEE0;
  16036. t['lammeemhahinitialarabic'] = 0xFD88;
  16037. t['lammeeminitialarabic'] = 0xFCCC;
  16038. t['largecircle'] = 0x25EF;
  16039. t['lbar'] = 0x019A;
  16040. t['lbelt'] = 0x026C;
  16041. t['lbopomofo'] = 0x310C;
  16042. t['lcaron'] = 0x013E;
  16043. t['lcedilla'] = 0x013C;
  16044. t['lcircle'] = 0x24DB;
  16045. t['lcircumflexbelow'] = 0x1E3D;
  16046. t['lcommaaccent'] = 0x013C;
  16047. t['ldot'] = 0x0140;
  16048. t['ldotaccent'] = 0x0140;
  16049. t['ldotbelow'] = 0x1E37;
  16050. t['ldotbelowmacron'] = 0x1E39;
  16051. t['leftangleabovecmb'] = 0x031A;
  16052. t['lefttackbelowcmb'] = 0x0318;
  16053. t['less'] = 0x003C;
  16054. t['lessequal'] = 0x2264;
  16055. t['lessequalorgreater'] = 0x22DA;
  16056. t['lessmonospace'] = 0xFF1C;
  16057. t['lessorequivalent'] = 0x2272;
  16058. t['lessorgreater'] = 0x2276;
  16059. t['lessoverequal'] = 0x2266;
  16060. t['lesssmall'] = 0xFE64;
  16061. t['lezh'] = 0x026E;
  16062. t['lfblock'] = 0x258C;
  16063. t['lhookretroflex'] = 0x026D;
  16064. t['lira'] = 0x20A4;
  16065. t['liwnarmenian'] = 0x056C;
  16066. t['lj'] = 0x01C9;
  16067. t['ljecyrillic'] = 0x0459;
  16068. t['ll'] = 0xF6C0;
  16069. t['lladeva'] = 0x0933;
  16070. t['llagujarati'] = 0x0AB3;
  16071. t['llinebelow'] = 0x1E3B;
  16072. t['llladeva'] = 0x0934;
  16073. t['llvocalicbengali'] = 0x09E1;
  16074. t['llvocalicdeva'] = 0x0961;
  16075. t['llvocalicvowelsignbengali'] = 0x09E3;
  16076. t['llvocalicvowelsigndeva'] = 0x0963;
  16077. t['lmiddletilde'] = 0x026B;
  16078. t['lmonospace'] = 0xFF4C;
  16079. t['lmsquare'] = 0x33D0;
  16080. t['lochulathai'] = 0x0E2C;
  16081. t['logicaland'] = 0x2227;
  16082. t['logicalnot'] = 0x00AC;
  16083. t['logicalnotreversed'] = 0x2310;
  16084. t['logicalor'] = 0x2228;
  16085. t['lolingthai'] = 0x0E25;
  16086. t['longs'] = 0x017F;
  16087. t['lowlinecenterline'] = 0xFE4E;
  16088. t['lowlinecmb'] = 0x0332;
  16089. t['lowlinedashed'] = 0xFE4D;
  16090. t['lozenge'] = 0x25CA;
  16091. t['lparen'] = 0x24A7;
  16092. t['lslash'] = 0x0142;
  16093. t['lsquare'] = 0x2113;
  16094. t['lsuperior'] = 0xF6EE;
  16095. t['ltshade'] = 0x2591;
  16096. t['luthai'] = 0x0E26;
  16097. t['lvocalicbengali'] = 0x098C;
  16098. t['lvocalicdeva'] = 0x090C;
  16099. t['lvocalicvowelsignbengali'] = 0x09E2;
  16100. t['lvocalicvowelsigndeva'] = 0x0962;
  16101. t['lxsquare'] = 0x33D3;
  16102. t['m'] = 0x006D;
  16103. t['mabengali'] = 0x09AE;
  16104. t['macron'] = 0x00AF;
  16105. t['macronbelowcmb'] = 0x0331;
  16106. t['macroncmb'] = 0x0304;
  16107. t['macronlowmod'] = 0x02CD;
  16108. t['macronmonospace'] = 0xFFE3;
  16109. t['macute'] = 0x1E3F;
  16110. t['madeva'] = 0x092E;
  16111. t['magujarati'] = 0x0AAE;
  16112. t['magurmukhi'] = 0x0A2E;
  16113. t['mahapakhhebrew'] = 0x05A4;
  16114. t['mahapakhlefthebrew'] = 0x05A4;
  16115. t['mahiragana'] = 0x307E;
  16116. t['maichattawalowleftthai'] = 0xF895;
  16117. t['maichattawalowrightthai'] = 0xF894;
  16118. t['maichattawathai'] = 0x0E4B;
  16119. t['maichattawaupperleftthai'] = 0xF893;
  16120. t['maieklowleftthai'] = 0xF88C;
  16121. t['maieklowrightthai'] = 0xF88B;
  16122. t['maiekthai'] = 0x0E48;
  16123. t['maiekupperleftthai'] = 0xF88A;
  16124. t['maihanakatleftthai'] = 0xF884;
  16125. t['maihanakatthai'] = 0x0E31;
  16126. t['maitaikhuleftthai'] = 0xF889;
  16127. t['maitaikhuthai'] = 0x0E47;
  16128. t['maitholowleftthai'] = 0xF88F;
  16129. t['maitholowrightthai'] = 0xF88E;
  16130. t['maithothai'] = 0x0E49;
  16131. t['maithoupperleftthai'] = 0xF88D;
  16132. t['maitrilowleftthai'] = 0xF892;
  16133. t['maitrilowrightthai'] = 0xF891;
  16134. t['maitrithai'] = 0x0E4A;
  16135. t['maitriupperleftthai'] = 0xF890;
  16136. t['maiyamokthai'] = 0x0E46;
  16137. t['makatakana'] = 0x30DE;
  16138. t['makatakanahalfwidth'] = 0xFF8F;
  16139. t['male'] = 0x2642;
  16140. t['mansyonsquare'] = 0x3347;
  16141. t['maqafhebrew'] = 0x05BE;
  16142. t['mars'] = 0x2642;
  16143. t['masoracirclehebrew'] = 0x05AF;
  16144. t['masquare'] = 0x3383;
  16145. t['mbopomofo'] = 0x3107;
  16146. t['mbsquare'] = 0x33D4;
  16147. t['mcircle'] = 0x24DC;
  16148. t['mcubedsquare'] = 0x33A5;
  16149. t['mdotaccent'] = 0x1E41;
  16150. t['mdotbelow'] = 0x1E43;
  16151. t['meemarabic'] = 0x0645;
  16152. t['meemfinalarabic'] = 0xFEE2;
  16153. t['meeminitialarabic'] = 0xFEE3;
  16154. t['meemmedialarabic'] = 0xFEE4;
  16155. t['meemmeeminitialarabic'] = 0xFCD1;
  16156. t['meemmeemisolatedarabic'] = 0xFC48;
  16157. t['meetorusquare'] = 0x334D;
  16158. t['mehiragana'] = 0x3081;
  16159. t['meizierasquare'] = 0x337E;
  16160. t['mekatakana'] = 0x30E1;
  16161. t['mekatakanahalfwidth'] = 0xFF92;
  16162. t['mem'] = 0x05DE;
  16163. t['memdagesh'] = 0xFB3E;
  16164. t['memdageshhebrew'] = 0xFB3E;
  16165. t['memhebrew'] = 0x05DE;
  16166. t['menarmenian'] = 0x0574;
  16167. t['merkhahebrew'] = 0x05A5;
  16168. t['merkhakefulahebrew'] = 0x05A6;
  16169. t['merkhakefulalefthebrew'] = 0x05A6;
  16170. t['merkhalefthebrew'] = 0x05A5;
  16171. t['mhook'] = 0x0271;
  16172. t['mhzsquare'] = 0x3392;
  16173. t['middledotkatakanahalfwidth'] = 0xFF65;
  16174. t['middot'] = 0x00B7;
  16175. t['mieumacirclekorean'] = 0x3272;
  16176. t['mieumaparenkorean'] = 0x3212;
  16177. t['mieumcirclekorean'] = 0x3264;
  16178. t['mieumkorean'] = 0x3141;
  16179. t['mieumpansioskorean'] = 0x3170;
  16180. t['mieumparenkorean'] = 0x3204;
  16181. t['mieumpieupkorean'] = 0x316E;
  16182. t['mieumsioskorean'] = 0x316F;
  16183. t['mihiragana'] = 0x307F;
  16184. t['mikatakana'] = 0x30DF;
  16185. t['mikatakanahalfwidth'] = 0xFF90;
  16186. t['minus'] = 0x2212;
  16187. t['minusbelowcmb'] = 0x0320;
  16188. t['minuscircle'] = 0x2296;
  16189. t['minusmod'] = 0x02D7;
  16190. t['minusplus'] = 0x2213;
  16191. t['minute'] = 0x2032;
  16192. t['miribaarusquare'] = 0x334A;
  16193. t['mirisquare'] = 0x3349;
  16194. t['mlonglegturned'] = 0x0270;
  16195. t['mlsquare'] = 0x3396;
  16196. t['mmcubedsquare'] = 0x33A3;
  16197. t['mmonospace'] = 0xFF4D;
  16198. t['mmsquaredsquare'] = 0x339F;
  16199. t['mohiragana'] = 0x3082;
  16200. t['mohmsquare'] = 0x33C1;
  16201. t['mokatakana'] = 0x30E2;
  16202. t['mokatakanahalfwidth'] = 0xFF93;
  16203. t['molsquare'] = 0x33D6;
  16204. t['momathai'] = 0x0E21;
  16205. t['moverssquare'] = 0x33A7;
  16206. t['moverssquaredsquare'] = 0x33A8;
  16207. t['mparen'] = 0x24A8;
  16208. t['mpasquare'] = 0x33AB;
  16209. t['mssquare'] = 0x33B3;
  16210. t['msuperior'] = 0xF6EF;
  16211. t['mturned'] = 0x026F;
  16212. t['mu'] = 0x00B5;
  16213. t['mu1'] = 0x00B5;
  16214. t['muasquare'] = 0x3382;
  16215. t['muchgreater'] = 0x226B;
  16216. t['muchless'] = 0x226A;
  16217. t['mufsquare'] = 0x338C;
  16218. t['mugreek'] = 0x03BC;
  16219. t['mugsquare'] = 0x338D;
  16220. t['muhiragana'] = 0x3080;
  16221. t['mukatakana'] = 0x30E0;
  16222. t['mukatakanahalfwidth'] = 0xFF91;
  16223. t['mulsquare'] = 0x3395;
  16224. t['multiply'] = 0x00D7;
  16225. t['mumsquare'] = 0x339B;
  16226. t['munahhebrew'] = 0x05A3;
  16227. t['munahlefthebrew'] = 0x05A3;
  16228. t['musicalnote'] = 0x266A;
  16229. t['musicalnotedbl'] = 0x266B;
  16230. t['musicflatsign'] = 0x266D;
  16231. t['musicsharpsign'] = 0x266F;
  16232. t['mussquare'] = 0x33B2;
  16233. t['muvsquare'] = 0x33B6;
  16234. t['muwsquare'] = 0x33BC;
  16235. t['mvmegasquare'] = 0x33B9;
  16236. t['mvsquare'] = 0x33B7;
  16237. t['mwmegasquare'] = 0x33BF;
  16238. t['mwsquare'] = 0x33BD;
  16239. t['n'] = 0x006E;
  16240. t['nabengali'] = 0x09A8;
  16241. t['nabla'] = 0x2207;
  16242. t['nacute'] = 0x0144;
  16243. t['nadeva'] = 0x0928;
  16244. t['nagujarati'] = 0x0AA8;
  16245. t['nagurmukhi'] = 0x0A28;
  16246. t['nahiragana'] = 0x306A;
  16247. t['nakatakana'] = 0x30CA;
  16248. t['nakatakanahalfwidth'] = 0xFF85;
  16249. t['napostrophe'] = 0x0149;
  16250. t['nasquare'] = 0x3381;
  16251. t['nbopomofo'] = 0x310B;
  16252. t['nbspace'] = 0x00A0;
  16253. t['ncaron'] = 0x0148;
  16254. t['ncedilla'] = 0x0146;
  16255. t['ncircle'] = 0x24DD;
  16256. t['ncircumflexbelow'] = 0x1E4B;
  16257. t['ncommaaccent'] = 0x0146;
  16258. t['ndotaccent'] = 0x1E45;
  16259. t['ndotbelow'] = 0x1E47;
  16260. t['nehiragana'] = 0x306D;
  16261. t['nekatakana'] = 0x30CD;
  16262. t['nekatakanahalfwidth'] = 0xFF88;
  16263. t['newsheqelsign'] = 0x20AA;
  16264. t['nfsquare'] = 0x338B;
  16265. t['ngabengali'] = 0x0999;
  16266. t['ngadeva'] = 0x0919;
  16267. t['ngagujarati'] = 0x0A99;
  16268. t['ngagurmukhi'] = 0x0A19;
  16269. t['ngonguthai'] = 0x0E07;
  16270. t['nhiragana'] = 0x3093;
  16271. t['nhookleft'] = 0x0272;
  16272. t['nhookretroflex'] = 0x0273;
  16273. t['nieunacirclekorean'] = 0x326F;
  16274. t['nieunaparenkorean'] = 0x320F;
  16275. t['nieuncieuckorean'] = 0x3135;
  16276. t['nieuncirclekorean'] = 0x3261;
  16277. t['nieunhieuhkorean'] = 0x3136;
  16278. t['nieunkorean'] = 0x3134;
  16279. t['nieunpansioskorean'] = 0x3168;
  16280. t['nieunparenkorean'] = 0x3201;
  16281. t['nieunsioskorean'] = 0x3167;
  16282. t['nieuntikeutkorean'] = 0x3166;
  16283. t['nihiragana'] = 0x306B;
  16284. t['nikatakana'] = 0x30CB;
  16285. t['nikatakanahalfwidth'] = 0xFF86;
  16286. t['nikhahitleftthai'] = 0xF899;
  16287. t['nikhahitthai'] = 0x0E4D;
  16288. t['nine'] = 0x0039;
  16289. t['ninearabic'] = 0x0669;
  16290. t['ninebengali'] = 0x09EF;
  16291. t['ninecircle'] = 0x2468;
  16292. t['ninecircleinversesansserif'] = 0x2792;
  16293. t['ninedeva'] = 0x096F;
  16294. t['ninegujarati'] = 0x0AEF;
  16295. t['ninegurmukhi'] = 0x0A6F;
  16296. t['ninehackarabic'] = 0x0669;
  16297. t['ninehangzhou'] = 0x3029;
  16298. t['nineideographicparen'] = 0x3228;
  16299. t['nineinferior'] = 0x2089;
  16300. t['ninemonospace'] = 0xFF19;
  16301. t['nineoldstyle'] = 0xF739;
  16302. t['nineparen'] = 0x247C;
  16303. t['nineperiod'] = 0x2490;
  16304. t['ninepersian'] = 0x06F9;
  16305. t['nineroman'] = 0x2178;
  16306. t['ninesuperior'] = 0x2079;
  16307. t['nineteencircle'] = 0x2472;
  16308. t['nineteenparen'] = 0x2486;
  16309. t['nineteenperiod'] = 0x249A;
  16310. t['ninethai'] = 0x0E59;
  16311. t['nj'] = 0x01CC;
  16312. t['njecyrillic'] = 0x045A;
  16313. t['nkatakana'] = 0x30F3;
  16314. t['nkatakanahalfwidth'] = 0xFF9D;
  16315. t['nlegrightlong'] = 0x019E;
  16316. t['nlinebelow'] = 0x1E49;
  16317. t['nmonospace'] = 0xFF4E;
  16318. t['nmsquare'] = 0x339A;
  16319. t['nnabengali'] = 0x09A3;
  16320. t['nnadeva'] = 0x0923;
  16321. t['nnagujarati'] = 0x0AA3;
  16322. t['nnagurmukhi'] = 0x0A23;
  16323. t['nnnadeva'] = 0x0929;
  16324. t['nohiragana'] = 0x306E;
  16325. t['nokatakana'] = 0x30CE;
  16326. t['nokatakanahalfwidth'] = 0xFF89;
  16327. t['nonbreakingspace'] = 0x00A0;
  16328. t['nonenthai'] = 0x0E13;
  16329. t['nonuthai'] = 0x0E19;
  16330. t['noonarabic'] = 0x0646;
  16331. t['noonfinalarabic'] = 0xFEE6;
  16332. t['noonghunnaarabic'] = 0x06BA;
  16333. t['noonghunnafinalarabic'] = 0xFB9F;
  16334. t['nooninitialarabic'] = 0xFEE7;
  16335. t['noonjeeminitialarabic'] = 0xFCD2;
  16336. t['noonjeemisolatedarabic'] = 0xFC4B;
  16337. t['noonmedialarabic'] = 0xFEE8;
  16338. t['noonmeeminitialarabic'] = 0xFCD5;
  16339. t['noonmeemisolatedarabic'] = 0xFC4E;
  16340. t['noonnoonfinalarabic'] = 0xFC8D;
  16341. t['notcontains'] = 0x220C;
  16342. t['notelement'] = 0x2209;
  16343. t['notelementof'] = 0x2209;
  16344. t['notequal'] = 0x2260;
  16345. t['notgreater'] = 0x226F;
  16346. t['notgreaternorequal'] = 0x2271;
  16347. t['notgreaternorless'] = 0x2279;
  16348. t['notidentical'] = 0x2262;
  16349. t['notless'] = 0x226E;
  16350. t['notlessnorequal'] = 0x2270;
  16351. t['notparallel'] = 0x2226;
  16352. t['notprecedes'] = 0x2280;
  16353. t['notsubset'] = 0x2284;
  16354. t['notsucceeds'] = 0x2281;
  16355. t['notsuperset'] = 0x2285;
  16356. t['nowarmenian'] = 0x0576;
  16357. t['nparen'] = 0x24A9;
  16358. t['nssquare'] = 0x33B1;
  16359. t['nsuperior'] = 0x207F;
  16360. t['ntilde'] = 0x00F1;
  16361. t['nu'] = 0x03BD;
  16362. t['nuhiragana'] = 0x306C;
  16363. t['nukatakana'] = 0x30CC;
  16364. t['nukatakanahalfwidth'] = 0xFF87;
  16365. t['nuktabengali'] = 0x09BC;
  16366. t['nuktadeva'] = 0x093C;
  16367. t['nuktagujarati'] = 0x0ABC;
  16368. t['nuktagurmukhi'] = 0x0A3C;
  16369. t['numbersign'] = 0x0023;
  16370. t['numbersignmonospace'] = 0xFF03;
  16371. t['numbersignsmall'] = 0xFE5F;
  16372. t['numeralsigngreek'] = 0x0374;
  16373. t['numeralsignlowergreek'] = 0x0375;
  16374. t['numero'] = 0x2116;
  16375. t['nun'] = 0x05E0;
  16376. t['nundagesh'] = 0xFB40;
  16377. t['nundageshhebrew'] = 0xFB40;
  16378. t['nunhebrew'] = 0x05E0;
  16379. t['nvsquare'] = 0x33B5;
  16380. t['nwsquare'] = 0x33BB;
  16381. t['nyabengali'] = 0x099E;
  16382. t['nyadeva'] = 0x091E;
  16383. t['nyagujarati'] = 0x0A9E;
  16384. t['nyagurmukhi'] = 0x0A1E;
  16385. t['o'] = 0x006F;
  16386. t['oacute'] = 0x00F3;
  16387. t['oangthai'] = 0x0E2D;
  16388. t['obarred'] = 0x0275;
  16389. t['obarredcyrillic'] = 0x04E9;
  16390. t['obarreddieresiscyrillic'] = 0x04EB;
  16391. t['obengali'] = 0x0993;
  16392. t['obopomofo'] = 0x311B;
  16393. t['obreve'] = 0x014F;
  16394. t['ocandradeva'] = 0x0911;
  16395. t['ocandragujarati'] = 0x0A91;
  16396. t['ocandravowelsigndeva'] = 0x0949;
  16397. t['ocandravowelsigngujarati'] = 0x0AC9;
  16398. t['ocaron'] = 0x01D2;
  16399. t['ocircle'] = 0x24DE;
  16400. t['ocircumflex'] = 0x00F4;
  16401. t['ocircumflexacute'] = 0x1ED1;
  16402. t['ocircumflexdotbelow'] = 0x1ED9;
  16403. t['ocircumflexgrave'] = 0x1ED3;
  16404. t['ocircumflexhookabove'] = 0x1ED5;
  16405. t['ocircumflextilde'] = 0x1ED7;
  16406. t['ocyrillic'] = 0x043E;
  16407. t['odblacute'] = 0x0151;
  16408. t['odblgrave'] = 0x020D;
  16409. t['odeva'] = 0x0913;
  16410. t['odieresis'] = 0x00F6;
  16411. t['odieresiscyrillic'] = 0x04E7;
  16412. t['odotbelow'] = 0x1ECD;
  16413. t['oe'] = 0x0153;
  16414. t['oekorean'] = 0x315A;
  16415. t['ogonek'] = 0x02DB;
  16416. t['ogonekcmb'] = 0x0328;
  16417. t['ograve'] = 0x00F2;
  16418. t['ogujarati'] = 0x0A93;
  16419. t['oharmenian'] = 0x0585;
  16420. t['ohiragana'] = 0x304A;
  16421. t['ohookabove'] = 0x1ECF;
  16422. t['ohorn'] = 0x01A1;
  16423. t['ohornacute'] = 0x1EDB;
  16424. t['ohorndotbelow'] = 0x1EE3;
  16425. t['ohorngrave'] = 0x1EDD;
  16426. t['ohornhookabove'] = 0x1EDF;
  16427. t['ohorntilde'] = 0x1EE1;
  16428. t['ohungarumlaut'] = 0x0151;
  16429. t['oi'] = 0x01A3;
  16430. t['oinvertedbreve'] = 0x020F;
  16431. t['okatakana'] = 0x30AA;
  16432. t['okatakanahalfwidth'] = 0xFF75;
  16433. t['okorean'] = 0x3157;
  16434. t['olehebrew'] = 0x05AB;
  16435. t['omacron'] = 0x014D;
  16436. t['omacronacute'] = 0x1E53;
  16437. t['omacrongrave'] = 0x1E51;
  16438. t['omdeva'] = 0x0950;
  16439. t['omega'] = 0x03C9;
  16440. t['omega1'] = 0x03D6;
  16441. t['omegacyrillic'] = 0x0461;
  16442. t['omegalatinclosed'] = 0x0277;
  16443. t['omegaroundcyrillic'] = 0x047B;
  16444. t['omegatitlocyrillic'] = 0x047D;
  16445. t['omegatonos'] = 0x03CE;
  16446. t['omgujarati'] = 0x0AD0;
  16447. t['omicron'] = 0x03BF;
  16448. t['omicrontonos'] = 0x03CC;
  16449. t['omonospace'] = 0xFF4F;
  16450. t['one'] = 0x0031;
  16451. t['onearabic'] = 0x0661;
  16452. t['onebengali'] = 0x09E7;
  16453. t['onecircle'] = 0x2460;
  16454. t['onecircleinversesansserif'] = 0x278A;
  16455. t['onedeva'] = 0x0967;
  16456. t['onedotenleader'] = 0x2024;
  16457. t['oneeighth'] = 0x215B;
  16458. t['onefitted'] = 0xF6DC;
  16459. t['onegujarati'] = 0x0AE7;
  16460. t['onegurmukhi'] = 0x0A67;
  16461. t['onehackarabic'] = 0x0661;
  16462. t['onehalf'] = 0x00BD;
  16463. t['onehangzhou'] = 0x3021;
  16464. t['oneideographicparen'] = 0x3220;
  16465. t['oneinferior'] = 0x2081;
  16466. t['onemonospace'] = 0xFF11;
  16467. t['onenumeratorbengali'] = 0x09F4;
  16468. t['oneoldstyle'] = 0xF731;
  16469. t['oneparen'] = 0x2474;
  16470. t['oneperiod'] = 0x2488;
  16471. t['onepersian'] = 0x06F1;
  16472. t['onequarter'] = 0x00BC;
  16473. t['oneroman'] = 0x2170;
  16474. t['onesuperior'] = 0x00B9;
  16475. t['onethai'] = 0x0E51;
  16476. t['onethird'] = 0x2153;
  16477. t['oogonek'] = 0x01EB;
  16478. t['oogonekmacron'] = 0x01ED;
  16479. t['oogurmukhi'] = 0x0A13;
  16480. t['oomatragurmukhi'] = 0x0A4B;
  16481. t['oopen'] = 0x0254;
  16482. t['oparen'] = 0x24AA;
  16483. t['openbullet'] = 0x25E6;
  16484. t['option'] = 0x2325;
  16485. t['ordfeminine'] = 0x00AA;
  16486. t['ordmasculine'] = 0x00BA;
  16487. t['orthogonal'] = 0x221F;
  16488. t['oshortdeva'] = 0x0912;
  16489. t['oshortvowelsigndeva'] = 0x094A;
  16490. t['oslash'] = 0x00F8;
  16491. t['oslashacute'] = 0x01FF;
  16492. t['osmallhiragana'] = 0x3049;
  16493. t['osmallkatakana'] = 0x30A9;
  16494. t['osmallkatakanahalfwidth'] = 0xFF6B;
  16495. t['ostrokeacute'] = 0x01FF;
  16496. t['osuperior'] = 0xF6F0;
  16497. t['otcyrillic'] = 0x047F;
  16498. t['otilde'] = 0x00F5;
  16499. t['otildeacute'] = 0x1E4D;
  16500. t['otildedieresis'] = 0x1E4F;
  16501. t['oubopomofo'] = 0x3121;
  16502. t['overline'] = 0x203E;
  16503. t['overlinecenterline'] = 0xFE4A;
  16504. t['overlinecmb'] = 0x0305;
  16505. t['overlinedashed'] = 0xFE49;
  16506. t['overlinedblwavy'] = 0xFE4C;
  16507. t['overlinewavy'] = 0xFE4B;
  16508. t['overscore'] = 0x00AF;
  16509. t['ovowelsignbengali'] = 0x09CB;
  16510. t['ovowelsigndeva'] = 0x094B;
  16511. t['ovowelsigngujarati'] = 0x0ACB;
  16512. t['p'] = 0x0070;
  16513. t['paampssquare'] = 0x3380;
  16514. t['paasentosquare'] = 0x332B;
  16515. t['pabengali'] = 0x09AA;
  16516. t['pacute'] = 0x1E55;
  16517. t['padeva'] = 0x092A;
  16518. t['pagedown'] = 0x21DF;
  16519. t['pageup'] = 0x21DE;
  16520. t['pagujarati'] = 0x0AAA;
  16521. t['pagurmukhi'] = 0x0A2A;
  16522. t['pahiragana'] = 0x3071;
  16523. t['paiyannoithai'] = 0x0E2F;
  16524. t['pakatakana'] = 0x30D1;
  16525. t['palatalizationcyrilliccmb'] = 0x0484;
  16526. t['palochkacyrillic'] = 0x04C0;
  16527. t['pansioskorean'] = 0x317F;
  16528. t['paragraph'] = 0x00B6;
  16529. t['parallel'] = 0x2225;
  16530. t['parenleft'] = 0x0028;
  16531. t['parenleftaltonearabic'] = 0xFD3E;
  16532. t['parenleftbt'] = 0xF8ED;
  16533. t['parenleftex'] = 0xF8EC;
  16534. t['parenleftinferior'] = 0x208D;
  16535. t['parenleftmonospace'] = 0xFF08;
  16536. t['parenleftsmall'] = 0xFE59;
  16537. t['parenleftsuperior'] = 0x207D;
  16538. t['parenlefttp'] = 0xF8EB;
  16539. t['parenleftvertical'] = 0xFE35;
  16540. t['parenright'] = 0x0029;
  16541. t['parenrightaltonearabic'] = 0xFD3F;
  16542. t['parenrightbt'] = 0xF8F8;
  16543. t['parenrightex'] = 0xF8F7;
  16544. t['parenrightinferior'] = 0x208E;
  16545. t['parenrightmonospace'] = 0xFF09;
  16546. t['parenrightsmall'] = 0xFE5A;
  16547. t['parenrightsuperior'] = 0x207E;
  16548. t['parenrighttp'] = 0xF8F6;
  16549. t['parenrightvertical'] = 0xFE36;
  16550. t['partialdiff'] = 0x2202;
  16551. t['paseqhebrew'] = 0x05C0;
  16552. t['pashtahebrew'] = 0x0599;
  16553. t['pasquare'] = 0x33A9;
  16554. t['patah'] = 0x05B7;
  16555. t['patah11'] = 0x05B7;
  16556. t['patah1d'] = 0x05B7;
  16557. t['patah2a'] = 0x05B7;
  16558. t['patahhebrew'] = 0x05B7;
  16559. t['patahnarrowhebrew'] = 0x05B7;
  16560. t['patahquarterhebrew'] = 0x05B7;
  16561. t['patahwidehebrew'] = 0x05B7;
  16562. t['pazerhebrew'] = 0x05A1;
  16563. t['pbopomofo'] = 0x3106;
  16564. t['pcircle'] = 0x24DF;
  16565. t['pdotaccent'] = 0x1E57;
  16566. t['pe'] = 0x05E4;
  16567. t['pecyrillic'] = 0x043F;
  16568. t['pedagesh'] = 0xFB44;
  16569. t['pedageshhebrew'] = 0xFB44;
  16570. t['peezisquare'] = 0x333B;
  16571. t['pefinaldageshhebrew'] = 0xFB43;
  16572. t['peharabic'] = 0x067E;
  16573. t['peharmenian'] = 0x057A;
  16574. t['pehebrew'] = 0x05E4;
  16575. t['pehfinalarabic'] = 0xFB57;
  16576. t['pehinitialarabic'] = 0xFB58;
  16577. t['pehiragana'] = 0x307A;
  16578. t['pehmedialarabic'] = 0xFB59;
  16579. t['pekatakana'] = 0x30DA;
  16580. t['pemiddlehookcyrillic'] = 0x04A7;
  16581. t['perafehebrew'] = 0xFB4E;
  16582. t['percent'] = 0x0025;
  16583. t['percentarabic'] = 0x066A;
  16584. t['percentmonospace'] = 0xFF05;
  16585. t['percentsmall'] = 0xFE6A;
  16586. t['period'] = 0x002E;
  16587. t['periodarmenian'] = 0x0589;
  16588. t['periodcentered'] = 0x00B7;
  16589. t['periodhalfwidth'] = 0xFF61;
  16590. t['periodinferior'] = 0xF6E7;
  16591. t['periodmonospace'] = 0xFF0E;
  16592. t['periodsmall'] = 0xFE52;
  16593. t['periodsuperior'] = 0xF6E8;
  16594. t['perispomenigreekcmb'] = 0x0342;
  16595. t['perpendicular'] = 0x22A5;
  16596. t['perthousand'] = 0x2030;
  16597. t['peseta'] = 0x20A7;
  16598. t['pfsquare'] = 0x338A;
  16599. t['phabengali'] = 0x09AB;
  16600. t['phadeva'] = 0x092B;
  16601. t['phagujarati'] = 0x0AAB;
  16602. t['phagurmukhi'] = 0x0A2B;
  16603. t['phi'] = 0x03C6;
  16604. t['phi1'] = 0x03D5;
  16605. t['phieuphacirclekorean'] = 0x327A;
  16606. t['phieuphaparenkorean'] = 0x321A;
  16607. t['phieuphcirclekorean'] = 0x326C;
  16608. t['phieuphkorean'] = 0x314D;
  16609. t['phieuphparenkorean'] = 0x320C;
  16610. t['philatin'] = 0x0278;
  16611. t['phinthuthai'] = 0x0E3A;
  16612. t['phisymbolgreek'] = 0x03D5;
  16613. t['phook'] = 0x01A5;
  16614. t['phophanthai'] = 0x0E1E;
  16615. t['phophungthai'] = 0x0E1C;
  16616. t['phosamphaothai'] = 0x0E20;
  16617. t['pi'] = 0x03C0;
  16618. t['pieupacirclekorean'] = 0x3273;
  16619. t['pieupaparenkorean'] = 0x3213;
  16620. t['pieupcieuckorean'] = 0x3176;
  16621. t['pieupcirclekorean'] = 0x3265;
  16622. t['pieupkiyeokkorean'] = 0x3172;
  16623. t['pieupkorean'] = 0x3142;
  16624. t['pieupparenkorean'] = 0x3205;
  16625. t['pieupsioskiyeokkorean'] = 0x3174;
  16626. t['pieupsioskorean'] = 0x3144;
  16627. t['pieupsiostikeutkorean'] = 0x3175;
  16628. t['pieupthieuthkorean'] = 0x3177;
  16629. t['pieuptikeutkorean'] = 0x3173;
  16630. t['pihiragana'] = 0x3074;
  16631. t['pikatakana'] = 0x30D4;
  16632. t['pisymbolgreek'] = 0x03D6;
  16633. t['piwrarmenian'] = 0x0583;
  16634. t['plus'] = 0x002B;
  16635. t['plusbelowcmb'] = 0x031F;
  16636. t['pluscircle'] = 0x2295;
  16637. t['plusminus'] = 0x00B1;
  16638. t['plusmod'] = 0x02D6;
  16639. t['plusmonospace'] = 0xFF0B;
  16640. t['plussmall'] = 0xFE62;
  16641. t['plussuperior'] = 0x207A;
  16642. t['pmonospace'] = 0xFF50;
  16643. t['pmsquare'] = 0x33D8;
  16644. t['pohiragana'] = 0x307D;
  16645. t['pointingindexdownwhite'] = 0x261F;
  16646. t['pointingindexleftwhite'] = 0x261C;
  16647. t['pointingindexrightwhite'] = 0x261E;
  16648. t['pointingindexupwhite'] = 0x261D;
  16649. t['pokatakana'] = 0x30DD;
  16650. t['poplathai'] = 0x0E1B;
  16651. t['postalmark'] = 0x3012;
  16652. t['postalmarkface'] = 0x3020;
  16653. t['pparen'] = 0x24AB;
  16654. t['precedes'] = 0x227A;
  16655. t['prescription'] = 0x211E;
  16656. t['primemod'] = 0x02B9;
  16657. t['primereversed'] = 0x2035;
  16658. t['product'] = 0x220F;
  16659. t['projective'] = 0x2305;
  16660. t['prolongedkana'] = 0x30FC;
  16661. t['propellor'] = 0x2318;
  16662. t['propersubset'] = 0x2282;
  16663. t['propersuperset'] = 0x2283;
  16664. t['proportion'] = 0x2237;
  16665. t['proportional'] = 0x221D;
  16666. t['psi'] = 0x03C8;
  16667. t['psicyrillic'] = 0x0471;
  16668. t['psilipneumatacyrilliccmb'] = 0x0486;
  16669. t['pssquare'] = 0x33B0;
  16670. t['puhiragana'] = 0x3077;
  16671. t['pukatakana'] = 0x30D7;
  16672. t['pvsquare'] = 0x33B4;
  16673. t['pwsquare'] = 0x33BA;
  16674. t['q'] = 0x0071;
  16675. t['qadeva'] = 0x0958;
  16676. t['qadmahebrew'] = 0x05A8;
  16677. t['qafarabic'] = 0x0642;
  16678. t['qaffinalarabic'] = 0xFED6;
  16679. t['qafinitialarabic'] = 0xFED7;
  16680. t['qafmedialarabic'] = 0xFED8;
  16681. t['qamats'] = 0x05B8;
  16682. t['qamats10'] = 0x05B8;
  16683. t['qamats1a'] = 0x05B8;
  16684. t['qamats1c'] = 0x05B8;
  16685. t['qamats27'] = 0x05B8;
  16686. t['qamats29'] = 0x05B8;
  16687. t['qamats33'] = 0x05B8;
  16688. t['qamatsde'] = 0x05B8;
  16689. t['qamatshebrew'] = 0x05B8;
  16690. t['qamatsnarrowhebrew'] = 0x05B8;
  16691. t['qamatsqatanhebrew'] = 0x05B8;
  16692. t['qamatsqatannarrowhebrew'] = 0x05B8;
  16693. t['qamatsqatanquarterhebrew'] = 0x05B8;
  16694. t['qamatsqatanwidehebrew'] = 0x05B8;
  16695. t['qamatsquarterhebrew'] = 0x05B8;
  16696. t['qamatswidehebrew'] = 0x05B8;
  16697. t['qarneyparahebrew'] = 0x059F;
  16698. t['qbopomofo'] = 0x3111;
  16699. t['qcircle'] = 0x24E0;
  16700. t['qhook'] = 0x02A0;
  16701. t['qmonospace'] = 0xFF51;
  16702. t['qof'] = 0x05E7;
  16703. t['qofdagesh'] = 0xFB47;
  16704. t['qofdageshhebrew'] = 0xFB47;
  16705. t['qofhebrew'] = 0x05E7;
  16706. t['qparen'] = 0x24AC;
  16707. t['quarternote'] = 0x2669;
  16708. t['qubuts'] = 0x05BB;
  16709. t['qubuts18'] = 0x05BB;
  16710. t['qubuts25'] = 0x05BB;
  16711. t['qubuts31'] = 0x05BB;
  16712. t['qubutshebrew'] = 0x05BB;
  16713. t['qubutsnarrowhebrew'] = 0x05BB;
  16714. t['qubutsquarterhebrew'] = 0x05BB;
  16715. t['qubutswidehebrew'] = 0x05BB;
  16716. t['question'] = 0x003F;
  16717. t['questionarabic'] = 0x061F;
  16718. t['questionarmenian'] = 0x055E;
  16719. t['questiondown'] = 0x00BF;
  16720. t['questiondownsmall'] = 0xF7BF;
  16721. t['questiongreek'] = 0x037E;
  16722. t['questionmonospace'] = 0xFF1F;
  16723. t['questionsmall'] = 0xF73F;
  16724. t['quotedbl'] = 0x0022;
  16725. t['quotedblbase'] = 0x201E;
  16726. t['quotedblleft'] = 0x201C;
  16727. t['quotedblmonospace'] = 0xFF02;
  16728. t['quotedblprime'] = 0x301E;
  16729. t['quotedblprimereversed'] = 0x301D;
  16730. t['quotedblright'] = 0x201D;
  16731. t['quoteleft'] = 0x2018;
  16732. t['quoteleftreversed'] = 0x201B;
  16733. t['quotereversed'] = 0x201B;
  16734. t['quoteright'] = 0x2019;
  16735. t['quoterightn'] = 0x0149;
  16736. t['quotesinglbase'] = 0x201A;
  16737. t['quotesingle'] = 0x0027;
  16738. t['quotesinglemonospace'] = 0xFF07;
  16739. t['r'] = 0x0072;
  16740. t['raarmenian'] = 0x057C;
  16741. t['rabengali'] = 0x09B0;
  16742. t['racute'] = 0x0155;
  16743. t['radeva'] = 0x0930;
  16744. t['radical'] = 0x221A;
  16745. t['radicalex'] = 0xF8E5;
  16746. t['radoverssquare'] = 0x33AE;
  16747. t['radoverssquaredsquare'] = 0x33AF;
  16748. t['radsquare'] = 0x33AD;
  16749. t['rafe'] = 0x05BF;
  16750. t['rafehebrew'] = 0x05BF;
  16751. t['ragujarati'] = 0x0AB0;
  16752. t['ragurmukhi'] = 0x0A30;
  16753. t['rahiragana'] = 0x3089;
  16754. t['rakatakana'] = 0x30E9;
  16755. t['rakatakanahalfwidth'] = 0xFF97;
  16756. t['ralowerdiagonalbengali'] = 0x09F1;
  16757. t['ramiddlediagonalbengali'] = 0x09F0;
  16758. t['ramshorn'] = 0x0264;
  16759. t['ratio'] = 0x2236;
  16760. t['rbopomofo'] = 0x3116;
  16761. t['rcaron'] = 0x0159;
  16762. t['rcedilla'] = 0x0157;
  16763. t['rcircle'] = 0x24E1;
  16764. t['rcommaaccent'] = 0x0157;
  16765. t['rdblgrave'] = 0x0211;
  16766. t['rdotaccent'] = 0x1E59;
  16767. t['rdotbelow'] = 0x1E5B;
  16768. t['rdotbelowmacron'] = 0x1E5D;
  16769. t['referencemark'] = 0x203B;
  16770. t['reflexsubset'] = 0x2286;
  16771. t['reflexsuperset'] = 0x2287;
  16772. t['registered'] = 0x00AE;
  16773. t['registersans'] = 0xF8E8;
  16774. t['registerserif'] = 0xF6DA;
  16775. t['reharabic'] = 0x0631;
  16776. t['reharmenian'] = 0x0580;
  16777. t['rehfinalarabic'] = 0xFEAE;
  16778. t['rehiragana'] = 0x308C;
  16779. t['rekatakana'] = 0x30EC;
  16780. t['rekatakanahalfwidth'] = 0xFF9A;
  16781. t['resh'] = 0x05E8;
  16782. t['reshdageshhebrew'] = 0xFB48;
  16783. t['reshhebrew'] = 0x05E8;
  16784. t['reversedtilde'] = 0x223D;
  16785. t['reviahebrew'] = 0x0597;
  16786. t['reviamugrashhebrew'] = 0x0597;
  16787. t['revlogicalnot'] = 0x2310;
  16788. t['rfishhook'] = 0x027E;
  16789. t['rfishhookreversed'] = 0x027F;
  16790. t['rhabengali'] = 0x09DD;
  16791. t['rhadeva'] = 0x095D;
  16792. t['rho'] = 0x03C1;
  16793. t['rhook'] = 0x027D;
  16794. t['rhookturned'] = 0x027B;
  16795. t['rhookturnedsuperior'] = 0x02B5;
  16796. t['rhosymbolgreek'] = 0x03F1;
  16797. t['rhotichookmod'] = 0x02DE;
  16798. t['rieulacirclekorean'] = 0x3271;
  16799. t['rieulaparenkorean'] = 0x3211;
  16800. t['rieulcirclekorean'] = 0x3263;
  16801. t['rieulhieuhkorean'] = 0x3140;
  16802. t['rieulkiyeokkorean'] = 0x313A;
  16803. t['rieulkiyeoksioskorean'] = 0x3169;
  16804. t['rieulkorean'] = 0x3139;
  16805. t['rieulmieumkorean'] = 0x313B;
  16806. t['rieulpansioskorean'] = 0x316C;
  16807. t['rieulparenkorean'] = 0x3203;
  16808. t['rieulphieuphkorean'] = 0x313F;
  16809. t['rieulpieupkorean'] = 0x313C;
  16810. t['rieulpieupsioskorean'] = 0x316B;
  16811. t['rieulsioskorean'] = 0x313D;
  16812. t['rieulthieuthkorean'] = 0x313E;
  16813. t['rieultikeutkorean'] = 0x316A;
  16814. t['rieulyeorinhieuhkorean'] = 0x316D;
  16815. t['rightangle'] = 0x221F;
  16816. t['righttackbelowcmb'] = 0x0319;
  16817. t['righttriangle'] = 0x22BF;
  16818. t['rihiragana'] = 0x308A;
  16819. t['rikatakana'] = 0x30EA;
  16820. t['rikatakanahalfwidth'] = 0xFF98;
  16821. t['ring'] = 0x02DA;
  16822. t['ringbelowcmb'] = 0x0325;
  16823. t['ringcmb'] = 0x030A;
  16824. t['ringhalfleft'] = 0x02BF;
  16825. t['ringhalfleftarmenian'] = 0x0559;
  16826. t['ringhalfleftbelowcmb'] = 0x031C;
  16827. t['ringhalfleftcentered'] = 0x02D3;
  16828. t['ringhalfright'] = 0x02BE;
  16829. t['ringhalfrightbelowcmb'] = 0x0339;
  16830. t['ringhalfrightcentered'] = 0x02D2;
  16831. t['rinvertedbreve'] = 0x0213;
  16832. t['rittorusquare'] = 0x3351;
  16833. t['rlinebelow'] = 0x1E5F;
  16834. t['rlongleg'] = 0x027C;
  16835. t['rlonglegturned'] = 0x027A;
  16836. t['rmonospace'] = 0xFF52;
  16837. t['rohiragana'] = 0x308D;
  16838. t['rokatakana'] = 0x30ED;
  16839. t['rokatakanahalfwidth'] = 0xFF9B;
  16840. t['roruathai'] = 0x0E23;
  16841. t['rparen'] = 0x24AD;
  16842. t['rrabengali'] = 0x09DC;
  16843. t['rradeva'] = 0x0931;
  16844. t['rragurmukhi'] = 0x0A5C;
  16845. t['rreharabic'] = 0x0691;
  16846. t['rrehfinalarabic'] = 0xFB8D;
  16847. t['rrvocalicbengali'] = 0x09E0;
  16848. t['rrvocalicdeva'] = 0x0960;
  16849. t['rrvocalicgujarati'] = 0x0AE0;
  16850. t['rrvocalicvowelsignbengali'] = 0x09C4;
  16851. t['rrvocalicvowelsigndeva'] = 0x0944;
  16852. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  16853. t['rsuperior'] = 0xF6F1;
  16854. t['rtblock'] = 0x2590;
  16855. t['rturned'] = 0x0279;
  16856. t['rturnedsuperior'] = 0x02B4;
  16857. t['ruhiragana'] = 0x308B;
  16858. t['rukatakana'] = 0x30EB;
  16859. t['rukatakanahalfwidth'] = 0xFF99;
  16860. t['rupeemarkbengali'] = 0x09F2;
  16861. t['rupeesignbengali'] = 0x09F3;
  16862. t['rupiah'] = 0xF6DD;
  16863. t['ruthai'] = 0x0E24;
  16864. t['rvocalicbengali'] = 0x098B;
  16865. t['rvocalicdeva'] = 0x090B;
  16866. t['rvocalicgujarati'] = 0x0A8B;
  16867. t['rvocalicvowelsignbengali'] = 0x09C3;
  16868. t['rvocalicvowelsigndeva'] = 0x0943;
  16869. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  16870. t['s'] = 0x0073;
  16871. t['sabengali'] = 0x09B8;
  16872. t['sacute'] = 0x015B;
  16873. t['sacutedotaccent'] = 0x1E65;
  16874. t['sadarabic'] = 0x0635;
  16875. t['sadeva'] = 0x0938;
  16876. t['sadfinalarabic'] = 0xFEBA;
  16877. t['sadinitialarabic'] = 0xFEBB;
  16878. t['sadmedialarabic'] = 0xFEBC;
  16879. t['sagujarati'] = 0x0AB8;
  16880. t['sagurmukhi'] = 0x0A38;
  16881. t['sahiragana'] = 0x3055;
  16882. t['sakatakana'] = 0x30B5;
  16883. t['sakatakanahalfwidth'] = 0xFF7B;
  16884. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  16885. t['samekh'] = 0x05E1;
  16886. t['samekhdagesh'] = 0xFB41;
  16887. t['samekhdageshhebrew'] = 0xFB41;
  16888. t['samekhhebrew'] = 0x05E1;
  16889. t['saraaathai'] = 0x0E32;
  16890. t['saraaethai'] = 0x0E41;
  16891. t['saraaimaimalaithai'] = 0x0E44;
  16892. t['saraaimaimuanthai'] = 0x0E43;
  16893. t['saraamthai'] = 0x0E33;
  16894. t['saraathai'] = 0x0E30;
  16895. t['saraethai'] = 0x0E40;
  16896. t['saraiileftthai'] = 0xF886;
  16897. t['saraiithai'] = 0x0E35;
  16898. t['saraileftthai'] = 0xF885;
  16899. t['saraithai'] = 0x0E34;
  16900. t['saraothai'] = 0x0E42;
  16901. t['saraueeleftthai'] = 0xF888;
  16902. t['saraueethai'] = 0x0E37;
  16903. t['saraueleftthai'] = 0xF887;
  16904. t['sarauethai'] = 0x0E36;
  16905. t['sarauthai'] = 0x0E38;
  16906. t['sarauuthai'] = 0x0E39;
  16907. t['sbopomofo'] = 0x3119;
  16908. t['scaron'] = 0x0161;
  16909. t['scarondotaccent'] = 0x1E67;
  16910. t['scedilla'] = 0x015F;
  16911. t['schwa'] = 0x0259;
  16912. t['schwacyrillic'] = 0x04D9;
  16913. t['schwadieresiscyrillic'] = 0x04DB;
  16914. t['schwahook'] = 0x025A;
  16915. t['scircle'] = 0x24E2;
  16916. t['scircumflex'] = 0x015D;
  16917. t['scommaaccent'] = 0x0219;
  16918. t['sdotaccent'] = 0x1E61;
  16919. t['sdotbelow'] = 0x1E63;
  16920. t['sdotbelowdotaccent'] = 0x1E69;
  16921. t['seagullbelowcmb'] = 0x033C;
  16922. t['second'] = 0x2033;
  16923. t['secondtonechinese'] = 0x02CA;
  16924. t['section'] = 0x00A7;
  16925. t['seenarabic'] = 0x0633;
  16926. t['seenfinalarabic'] = 0xFEB2;
  16927. t['seeninitialarabic'] = 0xFEB3;
  16928. t['seenmedialarabic'] = 0xFEB4;
  16929. t['segol'] = 0x05B6;
  16930. t['segol13'] = 0x05B6;
  16931. t['segol1f'] = 0x05B6;
  16932. t['segol2c'] = 0x05B6;
  16933. t['segolhebrew'] = 0x05B6;
  16934. t['segolnarrowhebrew'] = 0x05B6;
  16935. t['segolquarterhebrew'] = 0x05B6;
  16936. t['segoltahebrew'] = 0x0592;
  16937. t['segolwidehebrew'] = 0x05B6;
  16938. t['seharmenian'] = 0x057D;
  16939. t['sehiragana'] = 0x305B;
  16940. t['sekatakana'] = 0x30BB;
  16941. t['sekatakanahalfwidth'] = 0xFF7E;
  16942. t['semicolon'] = 0x003B;
  16943. t['semicolonarabic'] = 0x061B;
  16944. t['semicolonmonospace'] = 0xFF1B;
  16945. t['semicolonsmall'] = 0xFE54;
  16946. t['semivoicedmarkkana'] = 0x309C;
  16947. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  16948. t['sentisquare'] = 0x3322;
  16949. t['sentosquare'] = 0x3323;
  16950. t['seven'] = 0x0037;
  16951. t['sevenarabic'] = 0x0667;
  16952. t['sevenbengali'] = 0x09ED;
  16953. t['sevencircle'] = 0x2466;
  16954. t['sevencircleinversesansserif'] = 0x2790;
  16955. t['sevendeva'] = 0x096D;
  16956. t['seveneighths'] = 0x215E;
  16957. t['sevengujarati'] = 0x0AED;
  16958. t['sevengurmukhi'] = 0x0A6D;
  16959. t['sevenhackarabic'] = 0x0667;
  16960. t['sevenhangzhou'] = 0x3027;
  16961. t['sevenideographicparen'] = 0x3226;
  16962. t['seveninferior'] = 0x2087;
  16963. t['sevenmonospace'] = 0xFF17;
  16964. t['sevenoldstyle'] = 0xF737;
  16965. t['sevenparen'] = 0x247A;
  16966. t['sevenperiod'] = 0x248E;
  16967. t['sevenpersian'] = 0x06F7;
  16968. t['sevenroman'] = 0x2176;
  16969. t['sevensuperior'] = 0x2077;
  16970. t['seventeencircle'] = 0x2470;
  16971. t['seventeenparen'] = 0x2484;
  16972. t['seventeenperiod'] = 0x2498;
  16973. t['seventhai'] = 0x0E57;
  16974. t['sfthyphen'] = 0x00AD;
  16975. t['shaarmenian'] = 0x0577;
  16976. t['shabengali'] = 0x09B6;
  16977. t['shacyrillic'] = 0x0448;
  16978. t['shaddaarabic'] = 0x0651;
  16979. t['shaddadammaarabic'] = 0xFC61;
  16980. t['shaddadammatanarabic'] = 0xFC5E;
  16981. t['shaddafathaarabic'] = 0xFC60;
  16982. t['shaddakasraarabic'] = 0xFC62;
  16983. t['shaddakasratanarabic'] = 0xFC5F;
  16984. t['shade'] = 0x2592;
  16985. t['shadedark'] = 0x2593;
  16986. t['shadelight'] = 0x2591;
  16987. t['shademedium'] = 0x2592;
  16988. t['shadeva'] = 0x0936;
  16989. t['shagujarati'] = 0x0AB6;
  16990. t['shagurmukhi'] = 0x0A36;
  16991. t['shalshelethebrew'] = 0x0593;
  16992. t['shbopomofo'] = 0x3115;
  16993. t['shchacyrillic'] = 0x0449;
  16994. t['sheenarabic'] = 0x0634;
  16995. t['sheenfinalarabic'] = 0xFEB6;
  16996. t['sheeninitialarabic'] = 0xFEB7;
  16997. t['sheenmedialarabic'] = 0xFEB8;
  16998. t['sheicoptic'] = 0x03E3;
  16999. t['sheqel'] = 0x20AA;
  17000. t['sheqelhebrew'] = 0x20AA;
  17001. t['sheva'] = 0x05B0;
  17002. t['sheva115'] = 0x05B0;
  17003. t['sheva15'] = 0x05B0;
  17004. t['sheva22'] = 0x05B0;
  17005. t['sheva2e'] = 0x05B0;
  17006. t['shevahebrew'] = 0x05B0;
  17007. t['shevanarrowhebrew'] = 0x05B0;
  17008. t['shevaquarterhebrew'] = 0x05B0;
  17009. t['shevawidehebrew'] = 0x05B0;
  17010. t['shhacyrillic'] = 0x04BB;
  17011. t['shimacoptic'] = 0x03ED;
  17012. t['shin'] = 0x05E9;
  17013. t['shindagesh'] = 0xFB49;
  17014. t['shindageshhebrew'] = 0xFB49;
  17015. t['shindageshshindot'] = 0xFB2C;
  17016. t['shindageshshindothebrew'] = 0xFB2C;
  17017. t['shindageshsindot'] = 0xFB2D;
  17018. t['shindageshsindothebrew'] = 0xFB2D;
  17019. t['shindothebrew'] = 0x05C1;
  17020. t['shinhebrew'] = 0x05E9;
  17021. t['shinshindot'] = 0xFB2A;
  17022. t['shinshindothebrew'] = 0xFB2A;
  17023. t['shinsindot'] = 0xFB2B;
  17024. t['shinsindothebrew'] = 0xFB2B;
  17025. t['shook'] = 0x0282;
  17026. t['sigma'] = 0x03C3;
  17027. t['sigma1'] = 0x03C2;
  17028. t['sigmafinal'] = 0x03C2;
  17029. t['sigmalunatesymbolgreek'] = 0x03F2;
  17030. t['sihiragana'] = 0x3057;
  17031. t['sikatakana'] = 0x30B7;
  17032. t['sikatakanahalfwidth'] = 0xFF7C;
  17033. t['siluqhebrew'] = 0x05BD;
  17034. t['siluqlefthebrew'] = 0x05BD;
  17035. t['similar'] = 0x223C;
  17036. t['sindothebrew'] = 0x05C2;
  17037. t['siosacirclekorean'] = 0x3274;
  17038. t['siosaparenkorean'] = 0x3214;
  17039. t['sioscieuckorean'] = 0x317E;
  17040. t['sioscirclekorean'] = 0x3266;
  17041. t['sioskiyeokkorean'] = 0x317A;
  17042. t['sioskorean'] = 0x3145;
  17043. t['siosnieunkorean'] = 0x317B;
  17044. t['siosparenkorean'] = 0x3206;
  17045. t['siospieupkorean'] = 0x317D;
  17046. t['siostikeutkorean'] = 0x317C;
  17047. t['six'] = 0x0036;
  17048. t['sixarabic'] = 0x0666;
  17049. t['sixbengali'] = 0x09EC;
  17050. t['sixcircle'] = 0x2465;
  17051. t['sixcircleinversesansserif'] = 0x278F;
  17052. t['sixdeva'] = 0x096C;
  17053. t['sixgujarati'] = 0x0AEC;
  17054. t['sixgurmukhi'] = 0x0A6C;
  17055. t['sixhackarabic'] = 0x0666;
  17056. t['sixhangzhou'] = 0x3026;
  17057. t['sixideographicparen'] = 0x3225;
  17058. t['sixinferior'] = 0x2086;
  17059. t['sixmonospace'] = 0xFF16;
  17060. t['sixoldstyle'] = 0xF736;
  17061. t['sixparen'] = 0x2479;
  17062. t['sixperiod'] = 0x248D;
  17063. t['sixpersian'] = 0x06F6;
  17064. t['sixroman'] = 0x2175;
  17065. t['sixsuperior'] = 0x2076;
  17066. t['sixteencircle'] = 0x246F;
  17067. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17068. t['sixteenparen'] = 0x2483;
  17069. t['sixteenperiod'] = 0x2497;
  17070. t['sixthai'] = 0x0E56;
  17071. t['slash'] = 0x002F;
  17072. t['slashmonospace'] = 0xFF0F;
  17073. t['slong'] = 0x017F;
  17074. t['slongdotaccent'] = 0x1E9B;
  17075. t['smileface'] = 0x263A;
  17076. t['smonospace'] = 0xFF53;
  17077. t['sofpasuqhebrew'] = 0x05C3;
  17078. t['softhyphen'] = 0x00AD;
  17079. t['softsigncyrillic'] = 0x044C;
  17080. t['sohiragana'] = 0x305D;
  17081. t['sokatakana'] = 0x30BD;
  17082. t['sokatakanahalfwidth'] = 0xFF7F;
  17083. t['soliduslongoverlaycmb'] = 0x0338;
  17084. t['solidusshortoverlaycmb'] = 0x0337;
  17085. t['sorusithai'] = 0x0E29;
  17086. t['sosalathai'] = 0x0E28;
  17087. t['sosothai'] = 0x0E0B;
  17088. t['sosuathai'] = 0x0E2A;
  17089. t['space'] = 0x0020;
  17090. t['spacehackarabic'] = 0x0020;
  17091. t['spade'] = 0x2660;
  17092. t['spadesuitblack'] = 0x2660;
  17093. t['spadesuitwhite'] = 0x2664;
  17094. t['sparen'] = 0x24AE;
  17095. t['squarebelowcmb'] = 0x033B;
  17096. t['squarecc'] = 0x33C4;
  17097. t['squarecm'] = 0x339D;
  17098. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17099. t['squarehorizontalfill'] = 0x25A4;
  17100. t['squarekg'] = 0x338F;
  17101. t['squarekm'] = 0x339E;
  17102. t['squarekmcapital'] = 0x33CE;
  17103. t['squareln'] = 0x33D1;
  17104. t['squarelog'] = 0x33D2;
  17105. t['squaremg'] = 0x338E;
  17106. t['squaremil'] = 0x33D5;
  17107. t['squaremm'] = 0x339C;
  17108. t['squaremsquared'] = 0x33A1;
  17109. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17110. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17111. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17112. t['squareverticalfill'] = 0x25A5;
  17113. t['squarewhitewithsmallblack'] = 0x25A3;
  17114. t['srsquare'] = 0x33DB;
  17115. t['ssabengali'] = 0x09B7;
  17116. t['ssadeva'] = 0x0937;
  17117. t['ssagujarati'] = 0x0AB7;
  17118. t['ssangcieuckorean'] = 0x3149;
  17119. t['ssanghieuhkorean'] = 0x3185;
  17120. t['ssangieungkorean'] = 0x3180;
  17121. t['ssangkiyeokkorean'] = 0x3132;
  17122. t['ssangnieunkorean'] = 0x3165;
  17123. t['ssangpieupkorean'] = 0x3143;
  17124. t['ssangsioskorean'] = 0x3146;
  17125. t['ssangtikeutkorean'] = 0x3138;
  17126. t['ssuperior'] = 0xF6F2;
  17127. t['sterling'] = 0x00A3;
  17128. t['sterlingmonospace'] = 0xFFE1;
  17129. t['strokelongoverlaycmb'] = 0x0336;
  17130. t['strokeshortoverlaycmb'] = 0x0335;
  17131. t['subset'] = 0x2282;
  17132. t['subsetnotequal'] = 0x228A;
  17133. t['subsetorequal'] = 0x2286;
  17134. t['succeeds'] = 0x227B;
  17135. t['suchthat'] = 0x220B;
  17136. t['suhiragana'] = 0x3059;
  17137. t['sukatakana'] = 0x30B9;
  17138. t['sukatakanahalfwidth'] = 0xFF7D;
  17139. t['sukunarabic'] = 0x0652;
  17140. t['summation'] = 0x2211;
  17141. t['sun'] = 0x263C;
  17142. t['superset'] = 0x2283;
  17143. t['supersetnotequal'] = 0x228B;
  17144. t['supersetorequal'] = 0x2287;
  17145. t['svsquare'] = 0x33DC;
  17146. t['syouwaerasquare'] = 0x337C;
  17147. t['t'] = 0x0074;
  17148. t['tabengali'] = 0x09A4;
  17149. t['tackdown'] = 0x22A4;
  17150. t['tackleft'] = 0x22A3;
  17151. t['tadeva'] = 0x0924;
  17152. t['tagujarati'] = 0x0AA4;
  17153. t['tagurmukhi'] = 0x0A24;
  17154. t['taharabic'] = 0x0637;
  17155. t['tahfinalarabic'] = 0xFEC2;
  17156. t['tahinitialarabic'] = 0xFEC3;
  17157. t['tahiragana'] = 0x305F;
  17158. t['tahmedialarabic'] = 0xFEC4;
  17159. t['taisyouerasquare'] = 0x337D;
  17160. t['takatakana'] = 0x30BF;
  17161. t['takatakanahalfwidth'] = 0xFF80;
  17162. t['tatweelarabic'] = 0x0640;
  17163. t['tau'] = 0x03C4;
  17164. t['tav'] = 0x05EA;
  17165. t['tavdages'] = 0xFB4A;
  17166. t['tavdagesh'] = 0xFB4A;
  17167. t['tavdageshhebrew'] = 0xFB4A;
  17168. t['tavhebrew'] = 0x05EA;
  17169. t['tbar'] = 0x0167;
  17170. t['tbopomofo'] = 0x310A;
  17171. t['tcaron'] = 0x0165;
  17172. t['tccurl'] = 0x02A8;
  17173. t['tcedilla'] = 0x0163;
  17174. t['tcheharabic'] = 0x0686;
  17175. t['tchehfinalarabic'] = 0xFB7B;
  17176. t['tchehinitialarabic'] = 0xFB7C;
  17177. t['tchehmedialarabic'] = 0xFB7D;
  17178. t['tcircle'] = 0x24E3;
  17179. t['tcircumflexbelow'] = 0x1E71;
  17180. t['tcommaaccent'] = 0x0163;
  17181. t['tdieresis'] = 0x1E97;
  17182. t['tdotaccent'] = 0x1E6B;
  17183. t['tdotbelow'] = 0x1E6D;
  17184. t['tecyrillic'] = 0x0442;
  17185. t['tedescendercyrillic'] = 0x04AD;
  17186. t['teharabic'] = 0x062A;
  17187. t['tehfinalarabic'] = 0xFE96;
  17188. t['tehhahinitialarabic'] = 0xFCA2;
  17189. t['tehhahisolatedarabic'] = 0xFC0C;
  17190. t['tehinitialarabic'] = 0xFE97;
  17191. t['tehiragana'] = 0x3066;
  17192. t['tehjeeminitialarabic'] = 0xFCA1;
  17193. t['tehjeemisolatedarabic'] = 0xFC0B;
  17194. t['tehmarbutaarabic'] = 0x0629;
  17195. t['tehmarbutafinalarabic'] = 0xFE94;
  17196. t['tehmedialarabic'] = 0xFE98;
  17197. t['tehmeeminitialarabic'] = 0xFCA4;
  17198. t['tehmeemisolatedarabic'] = 0xFC0E;
  17199. t['tehnoonfinalarabic'] = 0xFC73;
  17200. t['tekatakana'] = 0x30C6;
  17201. t['tekatakanahalfwidth'] = 0xFF83;
  17202. t['telephone'] = 0x2121;
  17203. t['telephoneblack'] = 0x260E;
  17204. t['telishagedolahebrew'] = 0x05A0;
  17205. t['telishaqetanahebrew'] = 0x05A9;
  17206. t['tencircle'] = 0x2469;
  17207. t['tenideographicparen'] = 0x3229;
  17208. t['tenparen'] = 0x247D;
  17209. t['tenperiod'] = 0x2491;
  17210. t['tenroman'] = 0x2179;
  17211. t['tesh'] = 0x02A7;
  17212. t['tet'] = 0x05D8;
  17213. t['tetdagesh'] = 0xFB38;
  17214. t['tetdageshhebrew'] = 0xFB38;
  17215. t['tethebrew'] = 0x05D8;
  17216. t['tetsecyrillic'] = 0x04B5;
  17217. t['tevirhebrew'] = 0x059B;
  17218. t['tevirlefthebrew'] = 0x059B;
  17219. t['thabengali'] = 0x09A5;
  17220. t['thadeva'] = 0x0925;
  17221. t['thagujarati'] = 0x0AA5;
  17222. t['thagurmukhi'] = 0x0A25;
  17223. t['thalarabic'] = 0x0630;
  17224. t['thalfinalarabic'] = 0xFEAC;
  17225. t['thanthakhatlowleftthai'] = 0xF898;
  17226. t['thanthakhatlowrightthai'] = 0xF897;
  17227. t['thanthakhatthai'] = 0x0E4C;
  17228. t['thanthakhatupperleftthai'] = 0xF896;
  17229. t['theharabic'] = 0x062B;
  17230. t['thehfinalarabic'] = 0xFE9A;
  17231. t['thehinitialarabic'] = 0xFE9B;
  17232. t['thehmedialarabic'] = 0xFE9C;
  17233. t['thereexists'] = 0x2203;
  17234. t['therefore'] = 0x2234;
  17235. t['theta'] = 0x03B8;
  17236. t['theta1'] = 0x03D1;
  17237. t['thetasymbolgreek'] = 0x03D1;
  17238. t['thieuthacirclekorean'] = 0x3279;
  17239. t['thieuthaparenkorean'] = 0x3219;
  17240. t['thieuthcirclekorean'] = 0x326B;
  17241. t['thieuthkorean'] = 0x314C;
  17242. t['thieuthparenkorean'] = 0x320B;
  17243. t['thirteencircle'] = 0x246C;
  17244. t['thirteenparen'] = 0x2480;
  17245. t['thirteenperiod'] = 0x2494;
  17246. t['thonangmonthothai'] = 0x0E11;
  17247. t['thook'] = 0x01AD;
  17248. t['thophuthaothai'] = 0x0E12;
  17249. t['thorn'] = 0x00FE;
  17250. t['thothahanthai'] = 0x0E17;
  17251. t['thothanthai'] = 0x0E10;
  17252. t['thothongthai'] = 0x0E18;
  17253. t['thothungthai'] = 0x0E16;
  17254. t['thousandcyrillic'] = 0x0482;
  17255. t['thousandsseparatorarabic'] = 0x066C;
  17256. t['thousandsseparatorpersian'] = 0x066C;
  17257. t['three'] = 0x0033;
  17258. t['threearabic'] = 0x0663;
  17259. t['threebengali'] = 0x09E9;
  17260. t['threecircle'] = 0x2462;
  17261. t['threecircleinversesansserif'] = 0x278C;
  17262. t['threedeva'] = 0x0969;
  17263. t['threeeighths'] = 0x215C;
  17264. t['threegujarati'] = 0x0AE9;
  17265. t['threegurmukhi'] = 0x0A69;
  17266. t['threehackarabic'] = 0x0663;
  17267. t['threehangzhou'] = 0x3023;
  17268. t['threeideographicparen'] = 0x3222;
  17269. t['threeinferior'] = 0x2083;
  17270. t['threemonospace'] = 0xFF13;
  17271. t['threenumeratorbengali'] = 0x09F6;
  17272. t['threeoldstyle'] = 0xF733;
  17273. t['threeparen'] = 0x2476;
  17274. t['threeperiod'] = 0x248A;
  17275. t['threepersian'] = 0x06F3;
  17276. t['threequarters'] = 0x00BE;
  17277. t['threequartersemdash'] = 0xF6DE;
  17278. t['threeroman'] = 0x2172;
  17279. t['threesuperior'] = 0x00B3;
  17280. t['threethai'] = 0x0E53;
  17281. t['thzsquare'] = 0x3394;
  17282. t['tihiragana'] = 0x3061;
  17283. t['tikatakana'] = 0x30C1;
  17284. t['tikatakanahalfwidth'] = 0xFF81;
  17285. t['tikeutacirclekorean'] = 0x3270;
  17286. t['tikeutaparenkorean'] = 0x3210;
  17287. t['tikeutcirclekorean'] = 0x3262;
  17288. t['tikeutkorean'] = 0x3137;
  17289. t['tikeutparenkorean'] = 0x3202;
  17290. t['tilde'] = 0x02DC;
  17291. t['tildebelowcmb'] = 0x0330;
  17292. t['tildecmb'] = 0x0303;
  17293. t['tildecomb'] = 0x0303;
  17294. t['tildedoublecmb'] = 0x0360;
  17295. t['tildeoperator'] = 0x223C;
  17296. t['tildeoverlaycmb'] = 0x0334;
  17297. t['tildeverticalcmb'] = 0x033E;
  17298. t['timescircle'] = 0x2297;
  17299. t['tipehahebrew'] = 0x0596;
  17300. t['tipehalefthebrew'] = 0x0596;
  17301. t['tippigurmukhi'] = 0x0A70;
  17302. t['titlocyrilliccmb'] = 0x0483;
  17303. t['tiwnarmenian'] = 0x057F;
  17304. t['tlinebelow'] = 0x1E6F;
  17305. t['tmonospace'] = 0xFF54;
  17306. t['toarmenian'] = 0x0569;
  17307. t['tohiragana'] = 0x3068;
  17308. t['tokatakana'] = 0x30C8;
  17309. t['tokatakanahalfwidth'] = 0xFF84;
  17310. t['tonebarextrahighmod'] = 0x02E5;
  17311. t['tonebarextralowmod'] = 0x02E9;
  17312. t['tonebarhighmod'] = 0x02E6;
  17313. t['tonebarlowmod'] = 0x02E8;
  17314. t['tonebarmidmod'] = 0x02E7;
  17315. t['tonefive'] = 0x01BD;
  17316. t['tonesix'] = 0x0185;
  17317. t['tonetwo'] = 0x01A8;
  17318. t['tonos'] = 0x0384;
  17319. t['tonsquare'] = 0x3327;
  17320. t['topatakthai'] = 0x0E0F;
  17321. t['tortoiseshellbracketleft'] = 0x3014;
  17322. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  17323. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  17324. t['tortoiseshellbracketright'] = 0x3015;
  17325. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  17326. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  17327. t['totaothai'] = 0x0E15;
  17328. t['tpalatalhook'] = 0x01AB;
  17329. t['tparen'] = 0x24AF;
  17330. t['trademark'] = 0x2122;
  17331. t['trademarksans'] = 0xF8EA;
  17332. t['trademarkserif'] = 0xF6DB;
  17333. t['tretroflexhook'] = 0x0288;
  17334. t['triagdn'] = 0x25BC;
  17335. t['triaglf'] = 0x25C4;
  17336. t['triagrt'] = 0x25BA;
  17337. t['triagup'] = 0x25B2;
  17338. t['ts'] = 0x02A6;
  17339. t['tsadi'] = 0x05E6;
  17340. t['tsadidagesh'] = 0xFB46;
  17341. t['tsadidageshhebrew'] = 0xFB46;
  17342. t['tsadihebrew'] = 0x05E6;
  17343. t['tsecyrillic'] = 0x0446;
  17344. t['tsere'] = 0x05B5;
  17345. t['tsere12'] = 0x05B5;
  17346. t['tsere1e'] = 0x05B5;
  17347. t['tsere2b'] = 0x05B5;
  17348. t['tserehebrew'] = 0x05B5;
  17349. t['tserenarrowhebrew'] = 0x05B5;
  17350. t['tserequarterhebrew'] = 0x05B5;
  17351. t['tserewidehebrew'] = 0x05B5;
  17352. t['tshecyrillic'] = 0x045B;
  17353. t['tsuperior'] = 0xF6F3;
  17354. t['ttabengali'] = 0x099F;
  17355. t['ttadeva'] = 0x091F;
  17356. t['ttagujarati'] = 0x0A9F;
  17357. t['ttagurmukhi'] = 0x0A1F;
  17358. t['tteharabic'] = 0x0679;
  17359. t['ttehfinalarabic'] = 0xFB67;
  17360. t['ttehinitialarabic'] = 0xFB68;
  17361. t['ttehmedialarabic'] = 0xFB69;
  17362. t['tthabengali'] = 0x09A0;
  17363. t['tthadeva'] = 0x0920;
  17364. t['tthagujarati'] = 0x0AA0;
  17365. t['tthagurmukhi'] = 0x0A20;
  17366. t['tturned'] = 0x0287;
  17367. t['tuhiragana'] = 0x3064;
  17368. t['tukatakana'] = 0x30C4;
  17369. t['tukatakanahalfwidth'] = 0xFF82;
  17370. t['tusmallhiragana'] = 0x3063;
  17371. t['tusmallkatakana'] = 0x30C3;
  17372. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  17373. t['twelvecircle'] = 0x246B;
  17374. t['twelveparen'] = 0x247F;
  17375. t['twelveperiod'] = 0x2493;
  17376. t['twelveroman'] = 0x217B;
  17377. t['twentycircle'] = 0x2473;
  17378. t['twentyhangzhou'] = 0x5344;
  17379. t['twentyparen'] = 0x2487;
  17380. t['twentyperiod'] = 0x249B;
  17381. t['two'] = 0x0032;
  17382. t['twoarabic'] = 0x0662;
  17383. t['twobengali'] = 0x09E8;
  17384. t['twocircle'] = 0x2461;
  17385. t['twocircleinversesansserif'] = 0x278B;
  17386. t['twodeva'] = 0x0968;
  17387. t['twodotenleader'] = 0x2025;
  17388. t['twodotleader'] = 0x2025;
  17389. t['twodotleadervertical'] = 0xFE30;
  17390. t['twogujarati'] = 0x0AE8;
  17391. t['twogurmukhi'] = 0x0A68;
  17392. t['twohackarabic'] = 0x0662;
  17393. t['twohangzhou'] = 0x3022;
  17394. t['twoideographicparen'] = 0x3221;
  17395. t['twoinferior'] = 0x2082;
  17396. t['twomonospace'] = 0xFF12;
  17397. t['twonumeratorbengali'] = 0x09F5;
  17398. t['twooldstyle'] = 0xF732;
  17399. t['twoparen'] = 0x2475;
  17400. t['twoperiod'] = 0x2489;
  17401. t['twopersian'] = 0x06F2;
  17402. t['tworoman'] = 0x2171;
  17403. t['twostroke'] = 0x01BB;
  17404. t['twosuperior'] = 0x00B2;
  17405. t['twothai'] = 0x0E52;
  17406. t['twothirds'] = 0x2154;
  17407. t['u'] = 0x0075;
  17408. t['uacute'] = 0x00FA;
  17409. t['ubar'] = 0x0289;
  17410. t['ubengali'] = 0x0989;
  17411. t['ubopomofo'] = 0x3128;
  17412. t['ubreve'] = 0x016D;
  17413. t['ucaron'] = 0x01D4;
  17414. t['ucircle'] = 0x24E4;
  17415. t['ucircumflex'] = 0x00FB;
  17416. t['ucircumflexbelow'] = 0x1E77;
  17417. t['ucyrillic'] = 0x0443;
  17418. t['udattadeva'] = 0x0951;
  17419. t['udblacute'] = 0x0171;
  17420. t['udblgrave'] = 0x0215;
  17421. t['udeva'] = 0x0909;
  17422. t['udieresis'] = 0x00FC;
  17423. t['udieresisacute'] = 0x01D8;
  17424. t['udieresisbelow'] = 0x1E73;
  17425. t['udieresiscaron'] = 0x01DA;
  17426. t['udieresiscyrillic'] = 0x04F1;
  17427. t['udieresisgrave'] = 0x01DC;
  17428. t['udieresismacron'] = 0x01D6;
  17429. t['udotbelow'] = 0x1EE5;
  17430. t['ugrave'] = 0x00F9;
  17431. t['ugujarati'] = 0x0A89;
  17432. t['ugurmukhi'] = 0x0A09;
  17433. t['uhiragana'] = 0x3046;
  17434. t['uhookabove'] = 0x1EE7;
  17435. t['uhorn'] = 0x01B0;
  17436. t['uhornacute'] = 0x1EE9;
  17437. t['uhorndotbelow'] = 0x1EF1;
  17438. t['uhorngrave'] = 0x1EEB;
  17439. t['uhornhookabove'] = 0x1EED;
  17440. t['uhorntilde'] = 0x1EEF;
  17441. t['uhungarumlaut'] = 0x0171;
  17442. t['uhungarumlautcyrillic'] = 0x04F3;
  17443. t['uinvertedbreve'] = 0x0217;
  17444. t['ukatakana'] = 0x30A6;
  17445. t['ukatakanahalfwidth'] = 0xFF73;
  17446. t['ukcyrillic'] = 0x0479;
  17447. t['ukorean'] = 0x315C;
  17448. t['umacron'] = 0x016B;
  17449. t['umacroncyrillic'] = 0x04EF;
  17450. t['umacrondieresis'] = 0x1E7B;
  17451. t['umatragurmukhi'] = 0x0A41;
  17452. t['umonospace'] = 0xFF55;
  17453. t['underscore'] = 0x005F;
  17454. t['underscoredbl'] = 0x2017;
  17455. t['underscoremonospace'] = 0xFF3F;
  17456. t['underscorevertical'] = 0xFE33;
  17457. t['underscorewavy'] = 0xFE4F;
  17458. t['union'] = 0x222A;
  17459. t['universal'] = 0x2200;
  17460. t['uogonek'] = 0x0173;
  17461. t['uparen'] = 0x24B0;
  17462. t['upblock'] = 0x2580;
  17463. t['upperdothebrew'] = 0x05C4;
  17464. t['upsilon'] = 0x03C5;
  17465. t['upsilondieresis'] = 0x03CB;
  17466. t['upsilondieresistonos'] = 0x03B0;
  17467. t['upsilonlatin'] = 0x028A;
  17468. t['upsilontonos'] = 0x03CD;
  17469. t['uptackbelowcmb'] = 0x031D;
  17470. t['uptackmod'] = 0x02D4;
  17471. t['uragurmukhi'] = 0x0A73;
  17472. t['uring'] = 0x016F;
  17473. t['ushortcyrillic'] = 0x045E;
  17474. t['usmallhiragana'] = 0x3045;
  17475. t['usmallkatakana'] = 0x30A5;
  17476. t['usmallkatakanahalfwidth'] = 0xFF69;
  17477. t['ustraightcyrillic'] = 0x04AF;
  17478. t['ustraightstrokecyrillic'] = 0x04B1;
  17479. t['utilde'] = 0x0169;
  17480. t['utildeacute'] = 0x1E79;
  17481. t['utildebelow'] = 0x1E75;
  17482. t['uubengali'] = 0x098A;
  17483. t['uudeva'] = 0x090A;
  17484. t['uugujarati'] = 0x0A8A;
  17485. t['uugurmukhi'] = 0x0A0A;
  17486. t['uumatragurmukhi'] = 0x0A42;
  17487. t['uuvowelsignbengali'] = 0x09C2;
  17488. t['uuvowelsigndeva'] = 0x0942;
  17489. t['uuvowelsigngujarati'] = 0x0AC2;
  17490. t['uvowelsignbengali'] = 0x09C1;
  17491. t['uvowelsigndeva'] = 0x0941;
  17492. t['uvowelsigngujarati'] = 0x0AC1;
  17493. t['v'] = 0x0076;
  17494. t['vadeva'] = 0x0935;
  17495. t['vagujarati'] = 0x0AB5;
  17496. t['vagurmukhi'] = 0x0A35;
  17497. t['vakatakana'] = 0x30F7;
  17498. t['vav'] = 0x05D5;
  17499. t['vavdagesh'] = 0xFB35;
  17500. t['vavdagesh65'] = 0xFB35;
  17501. t['vavdageshhebrew'] = 0xFB35;
  17502. t['vavhebrew'] = 0x05D5;
  17503. t['vavholam'] = 0xFB4B;
  17504. t['vavholamhebrew'] = 0xFB4B;
  17505. t['vavvavhebrew'] = 0x05F0;
  17506. t['vavyodhebrew'] = 0x05F1;
  17507. t['vcircle'] = 0x24E5;
  17508. t['vdotbelow'] = 0x1E7F;
  17509. t['vecyrillic'] = 0x0432;
  17510. t['veharabic'] = 0x06A4;
  17511. t['vehfinalarabic'] = 0xFB6B;
  17512. t['vehinitialarabic'] = 0xFB6C;
  17513. t['vehmedialarabic'] = 0xFB6D;
  17514. t['vekatakana'] = 0x30F9;
  17515. t['venus'] = 0x2640;
  17516. t['verticalbar'] = 0x007C;
  17517. t['verticallineabovecmb'] = 0x030D;
  17518. t['verticallinebelowcmb'] = 0x0329;
  17519. t['verticallinelowmod'] = 0x02CC;
  17520. t['verticallinemod'] = 0x02C8;
  17521. t['vewarmenian'] = 0x057E;
  17522. t['vhook'] = 0x028B;
  17523. t['vikatakana'] = 0x30F8;
  17524. t['viramabengali'] = 0x09CD;
  17525. t['viramadeva'] = 0x094D;
  17526. t['viramagujarati'] = 0x0ACD;
  17527. t['visargabengali'] = 0x0983;
  17528. t['visargadeva'] = 0x0903;
  17529. t['visargagujarati'] = 0x0A83;
  17530. t['vmonospace'] = 0xFF56;
  17531. t['voarmenian'] = 0x0578;
  17532. t['voicediterationhiragana'] = 0x309E;
  17533. t['voicediterationkatakana'] = 0x30FE;
  17534. t['voicedmarkkana'] = 0x309B;
  17535. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  17536. t['vokatakana'] = 0x30FA;
  17537. t['vparen'] = 0x24B1;
  17538. t['vtilde'] = 0x1E7D;
  17539. t['vturned'] = 0x028C;
  17540. t['vuhiragana'] = 0x3094;
  17541. t['vukatakana'] = 0x30F4;
  17542. t['w'] = 0x0077;
  17543. t['wacute'] = 0x1E83;
  17544. t['waekorean'] = 0x3159;
  17545. t['wahiragana'] = 0x308F;
  17546. t['wakatakana'] = 0x30EF;
  17547. t['wakatakanahalfwidth'] = 0xFF9C;
  17548. t['wakorean'] = 0x3158;
  17549. t['wasmallhiragana'] = 0x308E;
  17550. t['wasmallkatakana'] = 0x30EE;
  17551. t['wattosquare'] = 0x3357;
  17552. t['wavedash'] = 0x301C;
  17553. t['wavyunderscorevertical'] = 0xFE34;
  17554. t['wawarabic'] = 0x0648;
  17555. t['wawfinalarabic'] = 0xFEEE;
  17556. t['wawhamzaabovearabic'] = 0x0624;
  17557. t['wawhamzaabovefinalarabic'] = 0xFE86;
  17558. t['wbsquare'] = 0x33DD;
  17559. t['wcircle'] = 0x24E6;
  17560. t['wcircumflex'] = 0x0175;
  17561. t['wdieresis'] = 0x1E85;
  17562. t['wdotaccent'] = 0x1E87;
  17563. t['wdotbelow'] = 0x1E89;
  17564. t['wehiragana'] = 0x3091;
  17565. t['weierstrass'] = 0x2118;
  17566. t['wekatakana'] = 0x30F1;
  17567. t['wekorean'] = 0x315E;
  17568. t['weokorean'] = 0x315D;
  17569. t['wgrave'] = 0x1E81;
  17570. t['whitebullet'] = 0x25E6;
  17571. t['whitecircle'] = 0x25CB;
  17572. t['whitecircleinverse'] = 0x25D9;
  17573. t['whitecornerbracketleft'] = 0x300E;
  17574. t['whitecornerbracketleftvertical'] = 0xFE43;
  17575. t['whitecornerbracketright'] = 0x300F;
  17576. t['whitecornerbracketrightvertical'] = 0xFE44;
  17577. t['whitediamond'] = 0x25C7;
  17578. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  17579. t['whitedownpointingsmalltriangle'] = 0x25BF;
  17580. t['whitedownpointingtriangle'] = 0x25BD;
  17581. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  17582. t['whiteleftpointingtriangle'] = 0x25C1;
  17583. t['whitelenticularbracketleft'] = 0x3016;
  17584. t['whitelenticularbracketright'] = 0x3017;
  17585. t['whiterightpointingsmalltriangle'] = 0x25B9;
  17586. t['whiterightpointingtriangle'] = 0x25B7;
  17587. t['whitesmallsquare'] = 0x25AB;
  17588. t['whitesmilingface'] = 0x263A;
  17589. t['whitesquare'] = 0x25A1;
  17590. t['whitestar'] = 0x2606;
  17591. t['whitetelephone'] = 0x260F;
  17592. t['whitetortoiseshellbracketleft'] = 0x3018;
  17593. t['whitetortoiseshellbracketright'] = 0x3019;
  17594. t['whiteuppointingsmalltriangle'] = 0x25B5;
  17595. t['whiteuppointingtriangle'] = 0x25B3;
  17596. t['wihiragana'] = 0x3090;
  17597. t['wikatakana'] = 0x30F0;
  17598. t['wikorean'] = 0x315F;
  17599. t['wmonospace'] = 0xFF57;
  17600. t['wohiragana'] = 0x3092;
  17601. t['wokatakana'] = 0x30F2;
  17602. t['wokatakanahalfwidth'] = 0xFF66;
  17603. t['won'] = 0x20A9;
  17604. t['wonmonospace'] = 0xFFE6;
  17605. t['wowaenthai'] = 0x0E27;
  17606. t['wparen'] = 0x24B2;
  17607. t['wring'] = 0x1E98;
  17608. t['wsuperior'] = 0x02B7;
  17609. t['wturned'] = 0x028D;
  17610. t['wynn'] = 0x01BF;
  17611. t['x'] = 0x0078;
  17612. t['xabovecmb'] = 0x033D;
  17613. t['xbopomofo'] = 0x3112;
  17614. t['xcircle'] = 0x24E7;
  17615. t['xdieresis'] = 0x1E8D;
  17616. t['xdotaccent'] = 0x1E8B;
  17617. t['xeharmenian'] = 0x056D;
  17618. t['xi'] = 0x03BE;
  17619. t['xmonospace'] = 0xFF58;
  17620. t['xparen'] = 0x24B3;
  17621. t['xsuperior'] = 0x02E3;
  17622. t['y'] = 0x0079;
  17623. t['yaadosquare'] = 0x334E;
  17624. t['yabengali'] = 0x09AF;
  17625. t['yacute'] = 0x00FD;
  17626. t['yadeva'] = 0x092F;
  17627. t['yaekorean'] = 0x3152;
  17628. t['yagujarati'] = 0x0AAF;
  17629. t['yagurmukhi'] = 0x0A2F;
  17630. t['yahiragana'] = 0x3084;
  17631. t['yakatakana'] = 0x30E4;
  17632. t['yakatakanahalfwidth'] = 0xFF94;
  17633. t['yakorean'] = 0x3151;
  17634. t['yamakkanthai'] = 0x0E4E;
  17635. t['yasmallhiragana'] = 0x3083;
  17636. t['yasmallkatakana'] = 0x30E3;
  17637. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  17638. t['yatcyrillic'] = 0x0463;
  17639. t['ycircle'] = 0x24E8;
  17640. t['ycircumflex'] = 0x0177;
  17641. t['ydieresis'] = 0x00FF;
  17642. t['ydotaccent'] = 0x1E8F;
  17643. t['ydotbelow'] = 0x1EF5;
  17644. t['yeharabic'] = 0x064A;
  17645. t['yehbarreearabic'] = 0x06D2;
  17646. t['yehbarreefinalarabic'] = 0xFBAF;
  17647. t['yehfinalarabic'] = 0xFEF2;
  17648. t['yehhamzaabovearabic'] = 0x0626;
  17649. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  17650. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  17651. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  17652. t['yehinitialarabic'] = 0xFEF3;
  17653. t['yehmedialarabic'] = 0xFEF4;
  17654. t['yehmeeminitialarabic'] = 0xFCDD;
  17655. t['yehmeemisolatedarabic'] = 0xFC58;
  17656. t['yehnoonfinalarabic'] = 0xFC94;
  17657. t['yehthreedotsbelowarabic'] = 0x06D1;
  17658. t['yekorean'] = 0x3156;
  17659. t['yen'] = 0x00A5;
  17660. t['yenmonospace'] = 0xFFE5;
  17661. t['yeokorean'] = 0x3155;
  17662. t['yeorinhieuhkorean'] = 0x3186;
  17663. t['yerahbenyomohebrew'] = 0x05AA;
  17664. t['yerahbenyomolefthebrew'] = 0x05AA;
  17665. t['yericyrillic'] = 0x044B;
  17666. t['yerudieresiscyrillic'] = 0x04F9;
  17667. t['yesieungkorean'] = 0x3181;
  17668. t['yesieungpansioskorean'] = 0x3183;
  17669. t['yesieungsioskorean'] = 0x3182;
  17670. t['yetivhebrew'] = 0x059A;
  17671. t['ygrave'] = 0x1EF3;
  17672. t['yhook'] = 0x01B4;
  17673. t['yhookabove'] = 0x1EF7;
  17674. t['yiarmenian'] = 0x0575;
  17675. t['yicyrillic'] = 0x0457;
  17676. t['yikorean'] = 0x3162;
  17677. t['yinyang'] = 0x262F;
  17678. t['yiwnarmenian'] = 0x0582;
  17679. t['ymonospace'] = 0xFF59;
  17680. t['yod'] = 0x05D9;
  17681. t['yoddagesh'] = 0xFB39;
  17682. t['yoddageshhebrew'] = 0xFB39;
  17683. t['yodhebrew'] = 0x05D9;
  17684. t['yodyodhebrew'] = 0x05F2;
  17685. t['yodyodpatahhebrew'] = 0xFB1F;
  17686. t['yohiragana'] = 0x3088;
  17687. t['yoikorean'] = 0x3189;
  17688. t['yokatakana'] = 0x30E8;
  17689. t['yokatakanahalfwidth'] = 0xFF96;
  17690. t['yokorean'] = 0x315B;
  17691. t['yosmallhiragana'] = 0x3087;
  17692. t['yosmallkatakana'] = 0x30E7;
  17693. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  17694. t['yotgreek'] = 0x03F3;
  17695. t['yoyaekorean'] = 0x3188;
  17696. t['yoyakorean'] = 0x3187;
  17697. t['yoyakthai'] = 0x0E22;
  17698. t['yoyingthai'] = 0x0E0D;
  17699. t['yparen'] = 0x24B4;
  17700. t['ypogegrammeni'] = 0x037A;
  17701. t['ypogegrammenigreekcmb'] = 0x0345;
  17702. t['yr'] = 0x01A6;
  17703. t['yring'] = 0x1E99;
  17704. t['ysuperior'] = 0x02B8;
  17705. t['ytilde'] = 0x1EF9;
  17706. t['yturned'] = 0x028E;
  17707. t['yuhiragana'] = 0x3086;
  17708. t['yuikorean'] = 0x318C;
  17709. t['yukatakana'] = 0x30E6;
  17710. t['yukatakanahalfwidth'] = 0xFF95;
  17711. t['yukorean'] = 0x3160;
  17712. t['yusbigcyrillic'] = 0x046B;
  17713. t['yusbigiotifiedcyrillic'] = 0x046D;
  17714. t['yuslittlecyrillic'] = 0x0467;
  17715. t['yuslittleiotifiedcyrillic'] = 0x0469;
  17716. t['yusmallhiragana'] = 0x3085;
  17717. t['yusmallkatakana'] = 0x30E5;
  17718. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  17719. t['yuyekorean'] = 0x318B;
  17720. t['yuyeokorean'] = 0x318A;
  17721. t['yyabengali'] = 0x09DF;
  17722. t['yyadeva'] = 0x095F;
  17723. t['z'] = 0x007A;
  17724. t['zaarmenian'] = 0x0566;
  17725. t['zacute'] = 0x017A;
  17726. t['zadeva'] = 0x095B;
  17727. t['zagurmukhi'] = 0x0A5B;
  17728. t['zaharabic'] = 0x0638;
  17729. t['zahfinalarabic'] = 0xFEC6;
  17730. t['zahinitialarabic'] = 0xFEC7;
  17731. t['zahiragana'] = 0x3056;
  17732. t['zahmedialarabic'] = 0xFEC8;
  17733. t['zainarabic'] = 0x0632;
  17734. t['zainfinalarabic'] = 0xFEB0;
  17735. t['zakatakana'] = 0x30B6;
  17736. t['zaqefgadolhebrew'] = 0x0595;
  17737. t['zaqefqatanhebrew'] = 0x0594;
  17738. t['zarqahebrew'] = 0x0598;
  17739. t['zayin'] = 0x05D6;
  17740. t['zayindagesh'] = 0xFB36;
  17741. t['zayindageshhebrew'] = 0xFB36;
  17742. t['zayinhebrew'] = 0x05D6;
  17743. t['zbopomofo'] = 0x3117;
  17744. t['zcaron'] = 0x017E;
  17745. t['zcircle'] = 0x24E9;
  17746. t['zcircumflex'] = 0x1E91;
  17747. t['zcurl'] = 0x0291;
  17748. t['zdot'] = 0x017C;
  17749. t['zdotaccent'] = 0x017C;
  17750. t['zdotbelow'] = 0x1E93;
  17751. t['zecyrillic'] = 0x0437;
  17752. t['zedescendercyrillic'] = 0x0499;
  17753. t['zedieresiscyrillic'] = 0x04DF;
  17754. t['zehiragana'] = 0x305C;
  17755. t['zekatakana'] = 0x30BC;
  17756. t['zero'] = 0x0030;
  17757. t['zeroarabic'] = 0x0660;
  17758. t['zerobengali'] = 0x09E6;
  17759. t['zerodeva'] = 0x0966;
  17760. t['zerogujarati'] = 0x0AE6;
  17761. t['zerogurmukhi'] = 0x0A66;
  17762. t['zerohackarabic'] = 0x0660;
  17763. t['zeroinferior'] = 0x2080;
  17764. t['zeromonospace'] = 0xFF10;
  17765. t['zerooldstyle'] = 0xF730;
  17766. t['zeropersian'] = 0x06F0;
  17767. t['zerosuperior'] = 0x2070;
  17768. t['zerothai'] = 0x0E50;
  17769. t['zerowidthjoiner'] = 0xFEFF;
  17770. t['zerowidthnonjoiner'] = 0x200C;
  17771. t['zerowidthspace'] = 0x200B;
  17772. t['zeta'] = 0x03B6;
  17773. t['zhbopomofo'] = 0x3113;
  17774. t['zhearmenian'] = 0x056A;
  17775. t['zhebrevecyrillic'] = 0x04C2;
  17776. t['zhecyrillic'] = 0x0436;
  17777. t['zhedescendercyrillic'] = 0x0497;
  17778. t['zhedieresiscyrillic'] = 0x04DD;
  17779. t['zihiragana'] = 0x3058;
  17780. t['zikatakana'] = 0x30B8;
  17781. t['zinorhebrew'] = 0x05AE;
  17782. t['zlinebelow'] = 0x1E95;
  17783. t['zmonospace'] = 0xFF5A;
  17784. t['zohiragana'] = 0x305E;
  17785. t['zokatakana'] = 0x30BE;
  17786. t['zparen'] = 0x24B5;
  17787. t['zretroflexhook'] = 0x0290;
  17788. t['zstroke'] = 0x01B6;
  17789. t['zuhiragana'] = 0x305A;
  17790. t['zukatakana'] = 0x30BA;
  17791. t['.notdef'] = 0x0000;
  17792. t['angbracketleftbig'] = 0x2329;
  17793. t['angbracketleftBig'] = 0x2329;
  17794. t['angbracketleftbigg'] = 0x2329;
  17795. t['angbracketleftBigg'] = 0x2329;
  17796. t['angbracketrightBig'] = 0x232A;
  17797. t['angbracketrightbig'] = 0x232A;
  17798. t['angbracketrightBigg'] = 0x232A;
  17799. t['angbracketrightbigg'] = 0x232A;
  17800. t['arrowhookleft'] = 0x21AA;
  17801. t['arrowhookright'] = 0x21A9;
  17802. t['arrowlefttophalf'] = 0x21BC;
  17803. t['arrowleftbothalf'] = 0x21BD;
  17804. t['arrownortheast'] = 0x2197;
  17805. t['arrownorthwest'] = 0x2196;
  17806. t['arrowrighttophalf'] = 0x21C0;
  17807. t['arrowrightbothalf'] = 0x21C1;
  17808. t['arrowsoutheast'] = 0x2198;
  17809. t['arrowsouthwest'] = 0x2199;
  17810. t['backslashbig'] = 0x2216;
  17811. t['backslashBig'] = 0x2216;
  17812. t['backslashBigg'] = 0x2216;
  17813. t['backslashbigg'] = 0x2216;
  17814. t['bardbl'] = 0x2016;
  17815. t['bracehtipdownleft'] = 0xFE37;
  17816. t['bracehtipdownright'] = 0xFE37;
  17817. t['bracehtipupleft'] = 0xFE38;
  17818. t['bracehtipupright'] = 0xFE38;
  17819. t['braceleftBig'] = 0x007B;
  17820. t['braceleftbig'] = 0x007B;
  17821. t['braceleftbigg'] = 0x007B;
  17822. t['braceleftBigg'] = 0x007B;
  17823. t['bracerightBig'] = 0x007D;
  17824. t['bracerightbig'] = 0x007D;
  17825. t['bracerightbigg'] = 0x007D;
  17826. t['bracerightBigg'] = 0x007D;
  17827. t['bracketleftbig'] = 0x005B;
  17828. t['bracketleftBig'] = 0x005B;
  17829. t['bracketleftbigg'] = 0x005B;
  17830. t['bracketleftBigg'] = 0x005B;
  17831. t['bracketrightBig'] = 0x005D;
  17832. t['bracketrightbig'] = 0x005D;
  17833. t['bracketrightbigg'] = 0x005D;
  17834. t['bracketrightBigg'] = 0x005D;
  17835. t['ceilingleftbig'] = 0x2308;
  17836. t['ceilingleftBig'] = 0x2308;
  17837. t['ceilingleftBigg'] = 0x2308;
  17838. t['ceilingleftbigg'] = 0x2308;
  17839. t['ceilingrightbig'] = 0x2309;
  17840. t['ceilingrightBig'] = 0x2309;
  17841. t['ceilingrightbigg'] = 0x2309;
  17842. t['ceilingrightBigg'] = 0x2309;
  17843. t['circledotdisplay'] = 0x2299;
  17844. t['circledottext'] = 0x2299;
  17845. t['circlemultiplydisplay'] = 0x2297;
  17846. t['circlemultiplytext'] = 0x2297;
  17847. t['circleplusdisplay'] = 0x2295;
  17848. t['circleplustext'] = 0x2295;
  17849. t['contintegraldisplay'] = 0x222E;
  17850. t['contintegraltext'] = 0x222E;
  17851. t['coproductdisplay'] = 0x2210;
  17852. t['coproducttext'] = 0x2210;
  17853. t['floorleftBig'] = 0x230A;
  17854. t['floorleftbig'] = 0x230A;
  17855. t['floorleftbigg'] = 0x230A;
  17856. t['floorleftBigg'] = 0x230A;
  17857. t['floorrightbig'] = 0x230B;
  17858. t['floorrightBig'] = 0x230B;
  17859. t['floorrightBigg'] = 0x230B;
  17860. t['floorrightbigg'] = 0x230B;
  17861. t['hatwide'] = 0x0302;
  17862. t['hatwider'] = 0x0302;
  17863. t['hatwidest'] = 0x0302;
  17864. t['intercal'] = 0x1D40;
  17865. t['integraldisplay'] = 0x222B;
  17866. t['integraltext'] = 0x222B;
  17867. t['intersectiondisplay'] = 0x22C2;
  17868. t['intersectiontext'] = 0x22C2;
  17869. t['logicalanddisplay'] = 0x2227;
  17870. t['logicalandtext'] = 0x2227;
  17871. t['logicalordisplay'] = 0x2228;
  17872. t['logicalortext'] = 0x2228;
  17873. t['parenleftBig'] = 0x0028;
  17874. t['parenleftbig'] = 0x0028;
  17875. t['parenleftBigg'] = 0x0028;
  17876. t['parenleftbigg'] = 0x0028;
  17877. t['parenrightBig'] = 0x0029;
  17878. t['parenrightbig'] = 0x0029;
  17879. t['parenrightBigg'] = 0x0029;
  17880. t['parenrightbigg'] = 0x0029;
  17881. t['prime'] = 0x2032;
  17882. t['productdisplay'] = 0x220F;
  17883. t['producttext'] = 0x220F;
  17884. t['radicalbig'] = 0x221A;
  17885. t['radicalBig'] = 0x221A;
  17886. t['radicalBigg'] = 0x221A;
  17887. t['radicalbigg'] = 0x221A;
  17888. t['radicalbt'] = 0x221A;
  17889. t['radicaltp'] = 0x221A;
  17890. t['radicalvertex'] = 0x221A;
  17891. t['slashbig'] = 0x002F;
  17892. t['slashBig'] = 0x002F;
  17893. t['slashBigg'] = 0x002F;
  17894. t['slashbigg'] = 0x002F;
  17895. t['summationdisplay'] = 0x2211;
  17896. t['summationtext'] = 0x2211;
  17897. t['tildewide'] = 0x02DC;
  17898. t['tildewider'] = 0x02DC;
  17899. t['tildewidest'] = 0x02DC;
  17900. t['uniondisplay'] = 0x22C3;
  17901. t['unionmultidisplay'] = 0x228E;
  17902. t['unionmultitext'] = 0x228E;
  17903. t['unionsqdisplay'] = 0x2294;
  17904. t['unionsqtext'] = 0x2294;
  17905. t['uniontext'] = 0x22C3;
  17906. t['vextenddouble'] = 0x2225;
  17907. t['vextendsingle'] = 0x2223;
  17908. });
  17909. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  17910. t['space'] = 0x0020;
  17911. t['a1'] = 0x2701;
  17912. t['a2'] = 0x2702;
  17913. t['a202'] = 0x2703;
  17914. t['a3'] = 0x2704;
  17915. t['a4'] = 0x260E;
  17916. t['a5'] = 0x2706;
  17917. t['a119'] = 0x2707;
  17918. t['a118'] = 0x2708;
  17919. t['a117'] = 0x2709;
  17920. t['a11'] = 0x261B;
  17921. t['a12'] = 0x261E;
  17922. t['a13'] = 0x270C;
  17923. t['a14'] = 0x270D;
  17924. t['a15'] = 0x270E;
  17925. t['a16'] = 0x270F;
  17926. t['a105'] = 0x2710;
  17927. t['a17'] = 0x2711;
  17928. t['a18'] = 0x2712;
  17929. t['a19'] = 0x2713;
  17930. t['a20'] = 0x2714;
  17931. t['a21'] = 0x2715;
  17932. t['a22'] = 0x2716;
  17933. t['a23'] = 0x2717;
  17934. t['a24'] = 0x2718;
  17935. t['a25'] = 0x2719;
  17936. t['a26'] = 0x271A;
  17937. t['a27'] = 0x271B;
  17938. t['a28'] = 0x271C;
  17939. t['a6'] = 0x271D;
  17940. t['a7'] = 0x271E;
  17941. t['a8'] = 0x271F;
  17942. t['a9'] = 0x2720;
  17943. t['a10'] = 0x2721;
  17944. t['a29'] = 0x2722;
  17945. t['a30'] = 0x2723;
  17946. t['a31'] = 0x2724;
  17947. t['a32'] = 0x2725;
  17948. t['a33'] = 0x2726;
  17949. t['a34'] = 0x2727;
  17950. t['a35'] = 0x2605;
  17951. t['a36'] = 0x2729;
  17952. t['a37'] = 0x272A;
  17953. t['a38'] = 0x272B;
  17954. t['a39'] = 0x272C;
  17955. t['a40'] = 0x272D;
  17956. t['a41'] = 0x272E;
  17957. t['a42'] = 0x272F;
  17958. t['a43'] = 0x2730;
  17959. t['a44'] = 0x2731;
  17960. t['a45'] = 0x2732;
  17961. t['a46'] = 0x2733;
  17962. t['a47'] = 0x2734;
  17963. t['a48'] = 0x2735;
  17964. t['a49'] = 0x2736;
  17965. t['a50'] = 0x2737;
  17966. t['a51'] = 0x2738;
  17967. t['a52'] = 0x2739;
  17968. t['a53'] = 0x273A;
  17969. t['a54'] = 0x273B;
  17970. t['a55'] = 0x273C;
  17971. t['a56'] = 0x273D;
  17972. t['a57'] = 0x273E;
  17973. t['a58'] = 0x273F;
  17974. t['a59'] = 0x2740;
  17975. t['a60'] = 0x2741;
  17976. t['a61'] = 0x2742;
  17977. t['a62'] = 0x2743;
  17978. t['a63'] = 0x2744;
  17979. t['a64'] = 0x2745;
  17980. t['a65'] = 0x2746;
  17981. t['a66'] = 0x2747;
  17982. t['a67'] = 0x2748;
  17983. t['a68'] = 0x2749;
  17984. t['a69'] = 0x274A;
  17985. t['a70'] = 0x274B;
  17986. t['a71'] = 0x25CF;
  17987. t['a72'] = 0x274D;
  17988. t['a73'] = 0x25A0;
  17989. t['a74'] = 0x274F;
  17990. t['a203'] = 0x2750;
  17991. t['a75'] = 0x2751;
  17992. t['a204'] = 0x2752;
  17993. t['a76'] = 0x25B2;
  17994. t['a77'] = 0x25BC;
  17995. t['a78'] = 0x25C6;
  17996. t['a79'] = 0x2756;
  17997. t['a81'] = 0x25D7;
  17998. t['a82'] = 0x2758;
  17999. t['a83'] = 0x2759;
  18000. t['a84'] = 0x275A;
  18001. t['a97'] = 0x275B;
  18002. t['a98'] = 0x275C;
  18003. t['a99'] = 0x275D;
  18004. t['a100'] = 0x275E;
  18005. t['a101'] = 0x2761;
  18006. t['a102'] = 0x2762;
  18007. t['a103'] = 0x2763;
  18008. t['a104'] = 0x2764;
  18009. t['a106'] = 0x2765;
  18010. t['a107'] = 0x2766;
  18011. t['a108'] = 0x2767;
  18012. t['a112'] = 0x2663;
  18013. t['a111'] = 0x2666;
  18014. t['a110'] = 0x2665;
  18015. t['a109'] = 0x2660;
  18016. t['a120'] = 0x2460;
  18017. t['a121'] = 0x2461;
  18018. t['a122'] = 0x2462;
  18019. t['a123'] = 0x2463;
  18020. t['a124'] = 0x2464;
  18021. t['a125'] = 0x2465;
  18022. t['a126'] = 0x2466;
  18023. t['a127'] = 0x2467;
  18024. t['a128'] = 0x2468;
  18025. t['a129'] = 0x2469;
  18026. t['a130'] = 0x2776;
  18027. t['a131'] = 0x2777;
  18028. t['a132'] = 0x2778;
  18029. t['a133'] = 0x2779;
  18030. t['a134'] = 0x277A;
  18031. t['a135'] = 0x277B;
  18032. t['a136'] = 0x277C;
  18033. t['a137'] = 0x277D;
  18034. t['a138'] = 0x277E;
  18035. t['a139'] = 0x277F;
  18036. t['a140'] = 0x2780;
  18037. t['a141'] = 0x2781;
  18038. t['a142'] = 0x2782;
  18039. t['a143'] = 0x2783;
  18040. t['a144'] = 0x2784;
  18041. t['a145'] = 0x2785;
  18042. t['a146'] = 0x2786;
  18043. t['a147'] = 0x2787;
  18044. t['a148'] = 0x2788;
  18045. t['a149'] = 0x2789;
  18046. t['a150'] = 0x278A;
  18047. t['a151'] = 0x278B;
  18048. t['a152'] = 0x278C;
  18049. t['a153'] = 0x278D;
  18050. t['a154'] = 0x278E;
  18051. t['a155'] = 0x278F;
  18052. t['a156'] = 0x2790;
  18053. t['a157'] = 0x2791;
  18054. t['a158'] = 0x2792;
  18055. t['a159'] = 0x2793;
  18056. t['a160'] = 0x2794;
  18057. t['a161'] = 0x2192;
  18058. t['a163'] = 0x2194;
  18059. t['a164'] = 0x2195;
  18060. t['a196'] = 0x2798;
  18061. t['a165'] = 0x2799;
  18062. t['a192'] = 0x279A;
  18063. t['a166'] = 0x279B;
  18064. t['a167'] = 0x279C;
  18065. t['a168'] = 0x279D;
  18066. t['a169'] = 0x279E;
  18067. t['a170'] = 0x279F;
  18068. t['a171'] = 0x27A0;
  18069. t['a172'] = 0x27A1;
  18070. t['a173'] = 0x27A2;
  18071. t['a162'] = 0x27A3;
  18072. t['a174'] = 0x27A4;
  18073. t['a175'] = 0x27A5;
  18074. t['a176'] = 0x27A6;
  18075. t['a177'] = 0x27A7;
  18076. t['a178'] = 0x27A8;
  18077. t['a179'] = 0x27A9;
  18078. t['a193'] = 0x27AA;
  18079. t['a180'] = 0x27AB;
  18080. t['a199'] = 0x27AC;
  18081. t['a181'] = 0x27AD;
  18082. t['a200'] = 0x27AE;
  18083. t['a182'] = 0x27AF;
  18084. t['a201'] = 0x27B1;
  18085. t['a183'] = 0x27B2;
  18086. t['a184'] = 0x27B3;
  18087. t['a197'] = 0x27B4;
  18088. t['a185'] = 0x27B5;
  18089. t['a194'] = 0x27B6;
  18090. t['a198'] = 0x27B7;
  18091. t['a186'] = 0x27B8;
  18092. t['a195'] = 0x27B9;
  18093. t['a187'] = 0x27BA;
  18094. t['a188'] = 0x27BB;
  18095. t['a189'] = 0x27BC;
  18096. t['a190'] = 0x27BD;
  18097. t['a191'] = 0x27BE;
  18098. t['a89'] = 0x2768;
  18099. t['a90'] = 0x2769;
  18100. t['a93'] = 0x276A;
  18101. t['a94'] = 0x276B;
  18102. t['a91'] = 0x276C;
  18103. t['a92'] = 0x276D;
  18104. t['a205'] = 0x276E;
  18105. t['a85'] = 0x276F;
  18106. t['a206'] = 0x2770;
  18107. t['a86'] = 0x2771;
  18108. t['a87'] = 0x2772;
  18109. t['a88'] = 0x2773;
  18110. t['a95'] = 0x2774;
  18111. t['a96'] = 0x2775;
  18112. t['.notdef'] = 0x0000;
  18113. });
  18114. exports.getGlyphsUnicode = getGlyphsUnicode;
  18115. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18116. /***/ }),
  18117. /* 9 */
  18118. /***/ (function(module, exports, __w_pdfjs_require__) {
  18119. "use strict";
  18120. var sharedUtil = __w_pdfjs_require__(0);
  18121. var displayDOMUtils = __w_pdfjs_require__(3);
  18122. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18123. var AnnotationType = sharedUtil.AnnotationType;
  18124. var stringToPDFString = sharedUtil.stringToPDFString;
  18125. var Util = sharedUtil.Util;
  18126. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18127. var LinkTarget = displayDOMUtils.LinkTarget;
  18128. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18129. var warn = sharedUtil.warn;
  18130. var CustomStyle = displayDOMUtils.CustomStyle;
  18131. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18132. function AnnotationElementFactory() {
  18133. }
  18134. AnnotationElementFactory.prototype = {
  18135. create: function AnnotationElementFactory_create(parameters) {
  18136. var subtype = parameters.data.annotationType;
  18137. switch (subtype) {
  18138. case AnnotationType.LINK:
  18139. return new LinkAnnotationElement(parameters);
  18140. case AnnotationType.TEXT:
  18141. return new TextAnnotationElement(parameters);
  18142. case AnnotationType.WIDGET:
  18143. var fieldType = parameters.data.fieldType;
  18144. switch (fieldType) {
  18145. case 'Tx':
  18146. return new TextWidgetAnnotationElement(parameters);
  18147. case 'Btn':
  18148. if (parameters.data.radioButton) {
  18149. return new RadioButtonWidgetAnnotationElement(parameters);
  18150. } else if (parameters.data.checkBox) {
  18151. return new CheckboxWidgetAnnotationElement(parameters);
  18152. }
  18153. warn('Unimplemented button widget annotation: pushbutton');
  18154. break;
  18155. case 'Ch':
  18156. return new ChoiceWidgetAnnotationElement(parameters);
  18157. }
  18158. return new WidgetAnnotationElement(parameters);
  18159. case AnnotationType.POPUP:
  18160. return new PopupAnnotationElement(parameters);
  18161. case AnnotationType.HIGHLIGHT:
  18162. return new HighlightAnnotationElement(parameters);
  18163. case AnnotationType.UNDERLINE:
  18164. return new UnderlineAnnotationElement(parameters);
  18165. case AnnotationType.SQUIGGLY:
  18166. return new SquigglyAnnotationElement(parameters);
  18167. case AnnotationType.STRIKEOUT:
  18168. return new StrikeOutAnnotationElement(parameters);
  18169. case AnnotationType.FILEATTACHMENT:
  18170. return new FileAttachmentAnnotationElement(parameters);
  18171. default:
  18172. return new AnnotationElement(parameters);
  18173. }
  18174. }
  18175. };
  18176. var AnnotationElement = function AnnotationElementClosure() {
  18177. function AnnotationElement(parameters, isRenderable) {
  18178. this.isRenderable = isRenderable || false;
  18179. this.data = parameters.data;
  18180. this.layer = parameters.layer;
  18181. this.page = parameters.page;
  18182. this.viewport = parameters.viewport;
  18183. this.linkService = parameters.linkService;
  18184. this.downloadManager = parameters.downloadManager;
  18185. this.imageResourcesPath = parameters.imageResourcesPath;
  18186. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18187. if (isRenderable) {
  18188. this.container = this._createContainer();
  18189. }
  18190. }
  18191. AnnotationElement.prototype = {
  18192. _createContainer: function AnnotationElement_createContainer() {
  18193. var data = this.data, page = this.page, viewport = this.viewport;
  18194. var container = document.createElement('section');
  18195. var width = data.rect[2] - data.rect[0];
  18196. var height = data.rect[3] - data.rect[1];
  18197. container.setAttribute('data-annotation-id', data.id);
  18198. var rect = Util.normalizeRect([
  18199. data.rect[0],
  18200. page.view[3] - data.rect[1] + page.view[1],
  18201. data.rect[2],
  18202. page.view[3] - data.rect[3] + page.view[1]
  18203. ]);
  18204. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18205. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18206. if (data.borderStyle.width > 0) {
  18207. container.style.borderWidth = data.borderStyle.width + 'px';
  18208. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18209. width = width - 2 * data.borderStyle.width;
  18210. height = height - 2 * data.borderStyle.width;
  18211. }
  18212. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18213. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18214. if (horizontalRadius > 0 || verticalRadius > 0) {
  18215. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18216. CustomStyle.setProp('borderRadius', container, radius);
  18217. }
  18218. switch (data.borderStyle.style) {
  18219. case AnnotationBorderStyleType.SOLID:
  18220. container.style.borderStyle = 'solid';
  18221. break;
  18222. case AnnotationBorderStyleType.DASHED:
  18223. container.style.borderStyle = 'dashed';
  18224. break;
  18225. case AnnotationBorderStyleType.BEVELED:
  18226. warn('Unimplemented border style: beveled');
  18227. break;
  18228. case AnnotationBorderStyleType.INSET:
  18229. warn('Unimplemented border style: inset');
  18230. break;
  18231. case AnnotationBorderStyleType.UNDERLINE:
  18232. container.style.borderBottomStyle = 'solid';
  18233. break;
  18234. default:
  18235. break;
  18236. }
  18237. if (data.color) {
  18238. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18239. } else {
  18240. container.style.borderWidth = 0;
  18241. }
  18242. }
  18243. container.style.left = rect[0] + 'px';
  18244. container.style.top = rect[1] + 'px';
  18245. container.style.width = width + 'px';
  18246. container.style.height = height + 'px';
  18247. return container;
  18248. },
  18249. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  18250. if (!trigger) {
  18251. trigger = document.createElement('div');
  18252. trigger.style.height = container.style.height;
  18253. trigger.style.width = container.style.width;
  18254. container.appendChild(trigger);
  18255. }
  18256. var popupElement = new PopupElement({
  18257. container: container,
  18258. trigger: trigger,
  18259. color: data.color,
  18260. title: data.title,
  18261. contents: data.contents,
  18262. hideWrapper: true
  18263. });
  18264. var popup = popupElement.render();
  18265. popup.style.left = container.style.width;
  18266. container.appendChild(popup);
  18267. },
  18268. render: function AnnotationElement_render() {
  18269. throw new Error('Abstract method AnnotationElement.render called');
  18270. }
  18271. };
  18272. return AnnotationElement;
  18273. }();
  18274. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  18275. function LinkAnnotationElement(parameters) {
  18276. AnnotationElement.call(this, parameters, true);
  18277. }
  18278. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  18279. render: function LinkAnnotationElement_render() {
  18280. this.container.className = 'linkAnnotation';
  18281. var link = document.createElement('a');
  18282. addLinkAttributes(link, {
  18283. url: this.data.url,
  18284. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  18285. });
  18286. if (!this.data.url) {
  18287. if (this.data.action) {
  18288. this._bindNamedAction(link, this.data.action);
  18289. } else {
  18290. this._bindLink(link, this.data.dest);
  18291. }
  18292. }
  18293. this.container.appendChild(link);
  18294. return this.container;
  18295. },
  18296. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  18297. var self = this;
  18298. link.href = this.linkService.getDestinationHash(destination);
  18299. link.onclick = function () {
  18300. if (destination) {
  18301. self.linkService.navigateTo(destination);
  18302. }
  18303. return false;
  18304. };
  18305. if (destination) {
  18306. link.className = 'internalLink';
  18307. }
  18308. },
  18309. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  18310. var self = this;
  18311. link.href = this.linkService.getAnchorUrl('');
  18312. link.onclick = function () {
  18313. self.linkService.executeNamedAction(action);
  18314. return false;
  18315. };
  18316. link.className = 'internalLink';
  18317. }
  18318. });
  18319. return LinkAnnotationElement;
  18320. }();
  18321. var TextAnnotationElement = function TextAnnotationElementClosure() {
  18322. function TextAnnotationElement(parameters) {
  18323. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18324. AnnotationElement.call(this, parameters, isRenderable);
  18325. }
  18326. Util.inherit(TextAnnotationElement, AnnotationElement, {
  18327. render: function TextAnnotationElement_render() {
  18328. this.container.className = 'textAnnotation';
  18329. var image = document.createElement('img');
  18330. image.style.height = this.container.style.height;
  18331. image.style.width = this.container.style.width;
  18332. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  18333. image.alt = '[{{type}} Annotation]';
  18334. image.dataset.l10nId = 'text_annotation_type';
  18335. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  18336. if (!this.data.hasPopup) {
  18337. this._createPopup(this.container, image, this.data);
  18338. }
  18339. this.container.appendChild(image);
  18340. return this.container;
  18341. }
  18342. });
  18343. return TextAnnotationElement;
  18344. }();
  18345. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  18346. function WidgetAnnotationElement(parameters, isRenderable) {
  18347. AnnotationElement.call(this, parameters, isRenderable);
  18348. }
  18349. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  18350. render: function WidgetAnnotationElement_render() {
  18351. return this.container;
  18352. }
  18353. });
  18354. return WidgetAnnotationElement;
  18355. }();
  18356. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  18357. var TEXT_ALIGNMENT = [
  18358. 'left',
  18359. 'center',
  18360. 'right'
  18361. ];
  18362. function TextWidgetAnnotationElement(parameters) {
  18363. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18364. WidgetAnnotationElement.call(this, parameters, isRenderable);
  18365. }
  18366. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  18367. render: function TextWidgetAnnotationElement_render() {
  18368. this.container.className = 'textWidgetAnnotation';
  18369. var element = null;
  18370. if (this.renderInteractiveForms) {
  18371. if (this.data.multiLine) {
  18372. element = document.createElement('textarea');
  18373. element.textContent = this.data.fieldValue;
  18374. } else {
  18375. element = document.createElement('input');
  18376. element.type = 'text';
  18377. element.setAttribute('value', this.data.fieldValue);
  18378. }
  18379. element.disabled = this.data.readOnly;
  18380. if (this.data.maxLen !== null) {
  18381. element.maxLength = this.data.maxLen;
  18382. }
  18383. if (this.data.comb) {
  18384. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18385. var combWidth = fieldWidth / this.data.maxLen;
  18386. element.classList.add('comb');
  18387. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  18388. }
  18389. } else {
  18390. element = document.createElement('div');
  18391. element.textContent = this.data.fieldValue;
  18392. element.style.verticalAlign = 'middle';
  18393. element.style.display = 'table-cell';
  18394. var font = null;
  18395. if (this.data.fontRefName) {
  18396. font = this.page.commonObjs.getData(this.data.fontRefName);
  18397. }
  18398. this._setTextStyle(element, font);
  18399. }
  18400. if (this.data.textAlignment !== null) {
  18401. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18402. }
  18403. this.container.appendChild(element);
  18404. return this.container;
  18405. },
  18406. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  18407. var style = element.style;
  18408. style.fontSize = this.data.fontSize + 'px';
  18409. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  18410. if (!font) {
  18411. return;
  18412. }
  18413. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  18414. style.fontStyle = font.italic ? 'italic' : 'normal';
  18415. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  18416. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  18417. style.fontFamily = fontFamily + fallbackName;
  18418. }
  18419. });
  18420. return TextWidgetAnnotationElement;
  18421. }();
  18422. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  18423. function CheckboxWidgetAnnotationElement(parameters) {
  18424. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18425. }
  18426. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  18427. render: function CheckboxWidgetAnnotationElement_render() {
  18428. this.container.className = 'buttonWidgetAnnotation checkBox';
  18429. var element = document.createElement('input');
  18430. element.disabled = this.data.readOnly;
  18431. element.type = 'checkbox';
  18432. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  18433. element.setAttribute('checked', true);
  18434. }
  18435. this.container.appendChild(element);
  18436. return this.container;
  18437. }
  18438. });
  18439. return CheckboxWidgetAnnotationElement;
  18440. }();
  18441. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  18442. function RadioButtonWidgetAnnotationElement(parameters) {
  18443. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18444. }
  18445. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  18446. render: function RadioButtonWidgetAnnotationElement_render() {
  18447. this.container.className = 'buttonWidgetAnnotation radioButton';
  18448. var element = document.createElement('input');
  18449. element.disabled = this.data.readOnly;
  18450. element.type = 'radio';
  18451. element.name = this.data.fieldName;
  18452. if (this.data.fieldValue === this.data.buttonValue) {
  18453. element.setAttribute('checked', true);
  18454. }
  18455. this.container.appendChild(element);
  18456. return this.container;
  18457. }
  18458. });
  18459. return RadioButtonWidgetAnnotationElement;
  18460. }();
  18461. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  18462. function ChoiceWidgetAnnotationElement(parameters) {
  18463. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18464. }
  18465. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  18466. render: function ChoiceWidgetAnnotationElement_render() {
  18467. this.container.className = 'choiceWidgetAnnotation';
  18468. var selectElement = document.createElement('select');
  18469. selectElement.disabled = this.data.readOnly;
  18470. if (!this.data.combo) {
  18471. selectElement.size = this.data.options.length;
  18472. if (this.data.multiSelect) {
  18473. selectElement.multiple = true;
  18474. }
  18475. }
  18476. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  18477. var option = this.data.options[i];
  18478. var optionElement = document.createElement('option');
  18479. optionElement.textContent = option.displayValue;
  18480. optionElement.value = option.exportValue;
  18481. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  18482. optionElement.setAttribute('selected', true);
  18483. }
  18484. selectElement.appendChild(optionElement);
  18485. }
  18486. this.container.appendChild(selectElement);
  18487. return this.container;
  18488. }
  18489. });
  18490. return ChoiceWidgetAnnotationElement;
  18491. }();
  18492. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  18493. function PopupAnnotationElement(parameters) {
  18494. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18495. AnnotationElement.call(this, parameters, isRenderable);
  18496. }
  18497. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  18498. render: function PopupAnnotationElement_render() {
  18499. this.container.className = 'popupAnnotation';
  18500. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  18501. var parentElement = this.layer.querySelector(selector);
  18502. if (!parentElement) {
  18503. return this.container;
  18504. }
  18505. var popup = new PopupElement({
  18506. container: this.container,
  18507. trigger: parentElement,
  18508. color: this.data.color,
  18509. title: this.data.title,
  18510. contents: this.data.contents
  18511. });
  18512. var parentLeft = parseFloat(parentElement.style.left);
  18513. var parentWidth = parseFloat(parentElement.style.width);
  18514. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  18515. this.container.style.left = parentLeft + parentWidth + 'px';
  18516. this.container.appendChild(popup.render());
  18517. return this.container;
  18518. }
  18519. });
  18520. return PopupAnnotationElement;
  18521. }();
  18522. var PopupElement = function PopupElementClosure() {
  18523. var BACKGROUND_ENLIGHT = 0.7;
  18524. function PopupElement(parameters) {
  18525. this.container = parameters.container;
  18526. this.trigger = parameters.trigger;
  18527. this.color = parameters.color;
  18528. this.title = parameters.title;
  18529. this.contents = parameters.contents;
  18530. this.hideWrapper = parameters.hideWrapper || false;
  18531. this.pinned = false;
  18532. }
  18533. PopupElement.prototype = {
  18534. render: function PopupElement_render() {
  18535. var wrapper = document.createElement('div');
  18536. wrapper.className = 'popupWrapper';
  18537. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18538. this.hideElement.setAttribute('hidden', true);
  18539. var popup = document.createElement('div');
  18540. popup.className = 'popup';
  18541. var color = this.color;
  18542. if (color) {
  18543. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18544. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18545. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18546. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  18547. }
  18548. var contents = this._formatContents(this.contents);
  18549. var title = document.createElement('h1');
  18550. title.textContent = this.title;
  18551. this.trigger.addEventListener('click', this._toggle.bind(this));
  18552. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  18553. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  18554. popup.addEventListener('click', this._hide.bind(this, true));
  18555. popup.appendChild(title);
  18556. popup.appendChild(contents);
  18557. wrapper.appendChild(popup);
  18558. return wrapper;
  18559. },
  18560. _formatContents: function PopupElement_formatContents(contents) {
  18561. var p = document.createElement('p');
  18562. var lines = contents.split(/(?:\r\n?|\n)/);
  18563. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18564. var line = lines[i];
  18565. p.appendChild(document.createTextNode(line));
  18566. if (i < ii - 1) {
  18567. p.appendChild(document.createElement('br'));
  18568. }
  18569. }
  18570. return p;
  18571. },
  18572. _toggle: function PopupElement_toggle() {
  18573. if (this.pinned) {
  18574. this._hide(true);
  18575. } else {
  18576. this._show(true);
  18577. }
  18578. },
  18579. _show: function PopupElement_show(pin) {
  18580. if (pin) {
  18581. this.pinned = true;
  18582. }
  18583. if (this.hideElement.hasAttribute('hidden')) {
  18584. this.hideElement.removeAttribute('hidden');
  18585. this.container.style.zIndex += 1;
  18586. }
  18587. },
  18588. _hide: function PopupElement_hide(unpin) {
  18589. if (unpin) {
  18590. this.pinned = false;
  18591. }
  18592. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  18593. this.hideElement.setAttribute('hidden', true);
  18594. this.container.style.zIndex -= 1;
  18595. }
  18596. }
  18597. };
  18598. return PopupElement;
  18599. }();
  18600. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  18601. function HighlightAnnotationElement(parameters) {
  18602. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18603. AnnotationElement.call(this, parameters, isRenderable);
  18604. }
  18605. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  18606. render: function HighlightAnnotationElement_render() {
  18607. this.container.className = 'highlightAnnotation';
  18608. if (!this.data.hasPopup) {
  18609. this._createPopup(this.container, null, this.data);
  18610. }
  18611. return this.container;
  18612. }
  18613. });
  18614. return HighlightAnnotationElement;
  18615. }();
  18616. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  18617. function UnderlineAnnotationElement(parameters) {
  18618. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18619. AnnotationElement.call(this, parameters, isRenderable);
  18620. }
  18621. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  18622. render: function UnderlineAnnotationElement_render() {
  18623. this.container.className = 'underlineAnnotation';
  18624. if (!this.data.hasPopup) {
  18625. this._createPopup(this.container, null, this.data);
  18626. }
  18627. return this.container;
  18628. }
  18629. });
  18630. return UnderlineAnnotationElement;
  18631. }();
  18632. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  18633. function SquigglyAnnotationElement(parameters) {
  18634. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18635. AnnotationElement.call(this, parameters, isRenderable);
  18636. }
  18637. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  18638. render: function SquigglyAnnotationElement_render() {
  18639. this.container.className = 'squigglyAnnotation';
  18640. if (!this.data.hasPopup) {
  18641. this._createPopup(this.container, null, this.data);
  18642. }
  18643. return this.container;
  18644. }
  18645. });
  18646. return SquigglyAnnotationElement;
  18647. }();
  18648. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  18649. function StrikeOutAnnotationElement(parameters) {
  18650. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18651. AnnotationElement.call(this, parameters, isRenderable);
  18652. }
  18653. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  18654. render: function StrikeOutAnnotationElement_render() {
  18655. this.container.className = 'strikeoutAnnotation';
  18656. if (!this.data.hasPopup) {
  18657. this._createPopup(this.container, null, this.data);
  18658. }
  18659. return this.container;
  18660. }
  18661. });
  18662. return StrikeOutAnnotationElement;
  18663. }();
  18664. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  18665. function FileAttachmentAnnotationElement(parameters) {
  18666. AnnotationElement.call(this, parameters, true);
  18667. var file = this.data.file;
  18668. this.filename = getFilenameFromUrl(file.filename);
  18669. this.content = file.content;
  18670. this.linkService.onFileAttachmentAnnotation({
  18671. id: stringToPDFString(file.filename),
  18672. filename: file.filename,
  18673. content: file.content
  18674. });
  18675. }
  18676. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  18677. render: function FileAttachmentAnnotationElement_render() {
  18678. this.container.className = 'fileAttachmentAnnotation';
  18679. var trigger = document.createElement('div');
  18680. trigger.style.height = this.container.style.height;
  18681. trigger.style.width = this.container.style.width;
  18682. trigger.addEventListener('dblclick', this._download.bind(this));
  18683. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  18684. this._createPopup(this.container, trigger, this.data);
  18685. }
  18686. this.container.appendChild(trigger);
  18687. return this.container;
  18688. },
  18689. _download: function FileAttachmentAnnotationElement_download() {
  18690. if (!this.downloadManager) {
  18691. warn('Download cannot be started due to unavailable download manager');
  18692. return;
  18693. }
  18694. this.downloadManager.downloadData(this.content, this.filename, '');
  18695. }
  18696. });
  18697. return FileAttachmentAnnotationElement;
  18698. }();
  18699. var AnnotationLayer = function AnnotationLayerClosure() {
  18700. return {
  18701. render: function AnnotationLayer_render(parameters) {
  18702. var annotationElementFactory = new AnnotationElementFactory();
  18703. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18704. var data = parameters.annotations[i];
  18705. if (!data) {
  18706. continue;
  18707. }
  18708. var element = annotationElementFactory.create({
  18709. data: data,
  18710. layer: parameters.div,
  18711. page: parameters.page,
  18712. viewport: parameters.viewport,
  18713. linkService: parameters.linkService,
  18714. downloadManager: parameters.downloadManager,
  18715. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  18716. renderInteractiveForms: parameters.renderInteractiveForms || false
  18717. });
  18718. if (element.isRenderable) {
  18719. parameters.div.appendChild(element.render());
  18720. }
  18721. }
  18722. },
  18723. update: function AnnotationLayer_update(parameters) {
  18724. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18725. var data = parameters.annotations[i];
  18726. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  18727. if (element) {
  18728. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  18729. }
  18730. }
  18731. parameters.div.removeAttribute('hidden');
  18732. }
  18733. };
  18734. }();
  18735. exports.AnnotationLayer = AnnotationLayer;
  18736. /***/ }),
  18737. /* 10 */
  18738. /***/ (function(module, exports, __w_pdfjs_require__) {
  18739. "use strict";
  18740. var sharedUtil = __w_pdfjs_require__(0);
  18741. var displayFontLoader = __w_pdfjs_require__(45);
  18742. var displayCanvas = __w_pdfjs_require__(44);
  18743. var displayMetadata = __w_pdfjs_require__(24);
  18744. var displayDOMUtils = __w_pdfjs_require__(3);
  18745. var amdRequire;
  18746. var InvalidPDFException = sharedUtil.InvalidPDFException;
  18747. var MessageHandler = sharedUtil.MessageHandler;
  18748. var MissingPDFException = sharedUtil.MissingPDFException;
  18749. var PageViewport = sharedUtil.PageViewport;
  18750. var PasswordException = sharedUtil.PasswordException;
  18751. var StatTimer = sharedUtil.StatTimer;
  18752. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  18753. var UnknownErrorException = sharedUtil.UnknownErrorException;
  18754. var Util = sharedUtil.Util;
  18755. var createPromiseCapability = sharedUtil.createPromiseCapability;
  18756. var error = sharedUtil.error;
  18757. var deprecated = sharedUtil.deprecated;
  18758. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  18759. var info = sharedUtil.info;
  18760. var isInt = sharedUtil.isInt;
  18761. var isArray = sharedUtil.isArray;
  18762. var isArrayBuffer = sharedUtil.isArrayBuffer;
  18763. var isSameOrigin = sharedUtil.isSameOrigin;
  18764. var loadJpegStream = sharedUtil.loadJpegStream;
  18765. var stringToBytes = sharedUtil.stringToBytes;
  18766. var globalScope = sharedUtil.globalScope;
  18767. var warn = sharedUtil.warn;
  18768. var FontFaceObject = displayFontLoader.FontFaceObject;
  18769. var FontLoader = displayFontLoader.FontLoader;
  18770. var CanvasGraphics = displayCanvas.CanvasGraphics;
  18771. var Metadata = displayMetadata.Metadata;
  18772. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18773. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  18774. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  18775. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  18776. var isWorkerDisabled = false;
  18777. var workerSrc;
  18778. var isPostMessageTransfersDisabled = false;
  18779. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  18780. var fakeWorkerFilesLoader = null;
  18781. var useRequireEnsure = false;
  18782. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  18783. var task = new PDFDocumentLoadingTask();
  18784. if (arguments.length > 1) {
  18785. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  18786. }
  18787. if (pdfDataRangeTransport) {
  18788. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  18789. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  18790. pdfDataRangeTransport.length = src.length;
  18791. pdfDataRangeTransport.initialData = src.initialData;
  18792. if (!pdfDataRangeTransport.abort) {
  18793. pdfDataRangeTransport.abort = function () {
  18794. };
  18795. }
  18796. }
  18797. src = Object.create(src);
  18798. src.range = pdfDataRangeTransport;
  18799. }
  18800. task.onPassword = passwordCallback || null;
  18801. task.onProgress = progressCallback || null;
  18802. var source;
  18803. if (typeof src === 'string') {
  18804. source = { url: src };
  18805. } else if (isArrayBuffer(src)) {
  18806. source = { data: src };
  18807. } else if (src instanceof PDFDataRangeTransport) {
  18808. source = { range: src };
  18809. } else {
  18810. if (typeof src !== 'object') {
  18811. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  18812. }
  18813. if (!src.url && !src.data && !src.range) {
  18814. error('Invalid parameter object: need either .data, .range or .url');
  18815. }
  18816. source = src;
  18817. }
  18818. var params = {};
  18819. var rangeTransport = null;
  18820. var worker = null;
  18821. for (var key in source) {
  18822. if (key === 'url' && typeof window !== 'undefined') {
  18823. params[key] = new URL(source[key], window.location).href;
  18824. continue;
  18825. } else if (key === 'range') {
  18826. rangeTransport = source[key];
  18827. continue;
  18828. } else if (key === 'worker') {
  18829. worker = source[key];
  18830. continue;
  18831. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  18832. var pdfBytes = source[key];
  18833. if (typeof pdfBytes === 'string') {
  18834. params[key] = stringToBytes(pdfBytes);
  18835. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  18836. params[key] = new Uint8Array(pdfBytes);
  18837. } else if (isArrayBuffer(pdfBytes)) {
  18838. params[key] = new Uint8Array(pdfBytes);
  18839. } else {
  18840. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  18841. }
  18842. continue;
  18843. }
  18844. params[key] = source[key];
  18845. }
  18846. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  18847. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  18848. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  18849. if (!worker) {
  18850. var workerPort = getDefaultSetting('workerPort');
  18851. worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
  18852. task._worker = worker;
  18853. }
  18854. var docId = task.docId;
  18855. worker.promise.then(function () {
  18856. if (task.destroyed) {
  18857. throw new Error('Loading aborted');
  18858. }
  18859. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  18860. if (task.destroyed) {
  18861. throw new Error('Loading aborted');
  18862. }
  18863. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  18864. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  18865. task._transport = transport;
  18866. messageHandler.send('Ready', null);
  18867. });
  18868. }).catch(task._capability.reject);
  18869. return task;
  18870. }
  18871. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  18872. if (worker.destroyed) {
  18873. return Promise.reject(new Error('Worker was destroyed'));
  18874. }
  18875. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  18876. source.disableStream = getDefaultSetting('disableStream');
  18877. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  18878. if (pdfDataRangeTransport) {
  18879. source.length = pdfDataRangeTransport.length;
  18880. source.initialData = pdfDataRangeTransport.initialData;
  18881. }
  18882. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  18883. docId: docId,
  18884. source: source,
  18885. disableRange: getDefaultSetting('disableRange'),
  18886. maxImageSize: getDefaultSetting('maxImageSize'),
  18887. disableFontFace: getDefaultSetting('disableFontFace'),
  18888. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  18889. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  18890. docBaseUrl: source.docBaseUrl,
  18891. disableNativeImageDecoder: source.disableNativeImageDecoder
  18892. }).then(function (workerId) {
  18893. if (worker.destroyed) {
  18894. throw new Error('Worker was destroyed');
  18895. }
  18896. return workerId;
  18897. });
  18898. }
  18899. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  18900. var nextDocumentId = 0;
  18901. function PDFDocumentLoadingTask() {
  18902. this._capability = createPromiseCapability();
  18903. this._transport = null;
  18904. this._worker = null;
  18905. this.docId = 'd' + nextDocumentId++;
  18906. this.destroyed = false;
  18907. this.onPassword = null;
  18908. this.onProgress = null;
  18909. this.onUnsupportedFeature = null;
  18910. }
  18911. PDFDocumentLoadingTask.prototype = {
  18912. get promise() {
  18913. return this._capability.promise;
  18914. },
  18915. destroy: function () {
  18916. this.destroyed = true;
  18917. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  18918. return transportDestroyed.then(function () {
  18919. this._transport = null;
  18920. if (this._worker) {
  18921. this._worker.destroy();
  18922. this._worker = null;
  18923. }
  18924. }.bind(this));
  18925. },
  18926. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  18927. return this.promise.then.apply(this.promise, arguments);
  18928. }
  18929. };
  18930. return PDFDocumentLoadingTask;
  18931. }();
  18932. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  18933. function PDFDataRangeTransport(length, initialData) {
  18934. this.length = length;
  18935. this.initialData = initialData;
  18936. this._rangeListeners = [];
  18937. this._progressListeners = [];
  18938. this._progressiveReadListeners = [];
  18939. this._readyCapability = createPromiseCapability();
  18940. }
  18941. PDFDataRangeTransport.prototype = {
  18942. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  18943. this._rangeListeners.push(listener);
  18944. },
  18945. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  18946. this._progressListeners.push(listener);
  18947. },
  18948. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  18949. this._progressiveReadListeners.push(listener);
  18950. },
  18951. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  18952. var listeners = this._rangeListeners;
  18953. for (var i = 0, n = listeners.length; i < n; ++i) {
  18954. listeners[i](begin, chunk);
  18955. }
  18956. },
  18957. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  18958. this._readyCapability.promise.then(function () {
  18959. var listeners = this._progressListeners;
  18960. for (var i = 0, n = listeners.length; i < n; ++i) {
  18961. listeners[i](loaded);
  18962. }
  18963. }.bind(this));
  18964. },
  18965. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  18966. this._readyCapability.promise.then(function () {
  18967. var listeners = this._progressiveReadListeners;
  18968. for (var i = 0, n = listeners.length; i < n; ++i) {
  18969. listeners[i](chunk);
  18970. }
  18971. }.bind(this));
  18972. },
  18973. transportReady: function PDFDataRangeTransport_transportReady() {
  18974. this._readyCapability.resolve();
  18975. },
  18976. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  18977. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  18978. },
  18979. abort: function PDFDataRangeTransport_abort() {
  18980. }
  18981. };
  18982. return PDFDataRangeTransport;
  18983. }();
  18984. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  18985. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  18986. this.pdfInfo = pdfInfo;
  18987. this.transport = transport;
  18988. this.loadingTask = loadingTask;
  18989. }
  18990. PDFDocumentProxy.prototype = {
  18991. get numPages() {
  18992. return this.pdfInfo.numPages;
  18993. },
  18994. get fingerprint() {
  18995. return this.pdfInfo.fingerprint;
  18996. },
  18997. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  18998. return this.transport.getPage(pageNumber);
  18999. },
  19000. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19001. return this.transport.getPageIndex(ref);
  19002. },
  19003. getDestinations: function PDFDocumentProxy_getDestinations() {
  19004. return this.transport.getDestinations();
  19005. },
  19006. getDestination: function PDFDocumentProxy_getDestination(id) {
  19007. return this.transport.getDestination(id);
  19008. },
  19009. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19010. return this.transport.getPageLabels();
  19011. },
  19012. getAttachments: function PDFDocumentProxy_getAttachments() {
  19013. return this.transport.getAttachments();
  19014. },
  19015. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19016. return this.transport.getJavaScript();
  19017. },
  19018. getOutline: function PDFDocumentProxy_getOutline() {
  19019. return this.transport.getOutline();
  19020. },
  19021. getMetadata: function PDFDocumentProxy_getMetadata() {
  19022. return this.transport.getMetadata();
  19023. },
  19024. getData: function PDFDocumentProxy_getData() {
  19025. return this.transport.getData();
  19026. },
  19027. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19028. return this.transport.downloadInfoCapability.promise;
  19029. },
  19030. getStats: function PDFDocumentProxy_getStats() {
  19031. return this.transport.getStats();
  19032. },
  19033. cleanup: function PDFDocumentProxy_cleanup() {
  19034. this.transport.startCleanup();
  19035. },
  19036. destroy: function PDFDocumentProxy_destroy() {
  19037. return this.loadingTask.destroy();
  19038. }
  19039. };
  19040. return PDFDocumentProxy;
  19041. }();
  19042. var PDFPageProxy = function PDFPageProxyClosure() {
  19043. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19044. this.pageIndex = pageIndex;
  19045. this.pageInfo = pageInfo;
  19046. this.transport = transport;
  19047. this.stats = new StatTimer();
  19048. this.stats.enabled = getDefaultSetting('enableStats');
  19049. this.commonObjs = transport.commonObjs;
  19050. this.objs = new PDFObjects();
  19051. this.cleanupAfterRender = false;
  19052. this.pendingCleanup = false;
  19053. this.intentStates = Object.create(null);
  19054. this.destroyed = false;
  19055. }
  19056. PDFPageProxy.prototype = {
  19057. get pageNumber() {
  19058. return this.pageIndex + 1;
  19059. },
  19060. get rotate() {
  19061. return this.pageInfo.rotate;
  19062. },
  19063. get ref() {
  19064. return this.pageInfo.ref;
  19065. },
  19066. get userUnit() {
  19067. return this.pageInfo.userUnit;
  19068. },
  19069. get view() {
  19070. return this.pageInfo.view;
  19071. },
  19072. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19073. if (arguments.length < 2) {
  19074. rotate = this.rotate;
  19075. }
  19076. return new PageViewport(this.view, scale, rotate, 0, 0);
  19077. },
  19078. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19079. var intent = params && params.intent || null;
  19080. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19081. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19082. this.annotationsIntent = intent;
  19083. }
  19084. return this.annotationsPromise;
  19085. },
  19086. render: function PDFPageProxy_render(params) {
  19087. var stats = this.stats;
  19088. stats.time('Overall');
  19089. this.pendingCleanup = false;
  19090. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19091. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19092. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19093. if (!this.intentStates[renderingIntent]) {
  19094. this.intentStates[renderingIntent] = Object.create(null);
  19095. }
  19096. var intentState = this.intentStates[renderingIntent];
  19097. if (!intentState.displayReadyCapability) {
  19098. intentState.receivingOperatorList = true;
  19099. intentState.displayReadyCapability = createPromiseCapability();
  19100. intentState.operatorList = {
  19101. fnArray: [],
  19102. argsArray: [],
  19103. lastChunk: false
  19104. };
  19105. this.stats.time('Page Request');
  19106. this.transport.messageHandler.send('RenderPageRequest', {
  19107. pageIndex: this.pageNumber - 1,
  19108. intent: renderingIntent,
  19109. renderInteractiveForms: renderInteractiveForms
  19110. });
  19111. }
  19112. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19113. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19114. if (!intentState.renderTasks) {
  19115. intentState.renderTasks = [];
  19116. }
  19117. intentState.renderTasks.push(internalRenderTask);
  19118. var renderTask = internalRenderTask.task;
  19119. if (params.continueCallback) {
  19120. deprecated('render is used with continueCallback parameter');
  19121. renderTask.onContinue = params.continueCallback;
  19122. }
  19123. var self = this;
  19124. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19125. if (self.pendingCleanup) {
  19126. complete();
  19127. return;
  19128. }
  19129. stats.time('Rendering');
  19130. internalRenderTask.initializeGraphics(transparency);
  19131. internalRenderTask.operatorListChanged();
  19132. }, function pageDisplayReadPromiseError(reason) {
  19133. complete(reason);
  19134. });
  19135. function complete(error) {
  19136. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19137. if (i >= 0) {
  19138. intentState.renderTasks.splice(i, 1);
  19139. }
  19140. if (self.cleanupAfterRender) {
  19141. self.pendingCleanup = true;
  19142. }
  19143. self._tryCleanup();
  19144. if (error) {
  19145. internalRenderTask.capability.reject(error);
  19146. } else {
  19147. internalRenderTask.capability.resolve();
  19148. }
  19149. stats.timeEnd('Rendering');
  19150. stats.timeEnd('Overall');
  19151. }
  19152. return renderTask;
  19153. },
  19154. getOperatorList: function PDFPageProxy_getOperatorList() {
  19155. function operatorListChanged() {
  19156. if (intentState.operatorList.lastChunk) {
  19157. intentState.opListReadCapability.resolve(intentState.operatorList);
  19158. var i = intentState.renderTasks.indexOf(opListTask);
  19159. if (i >= 0) {
  19160. intentState.renderTasks.splice(i, 1);
  19161. }
  19162. }
  19163. }
  19164. var renderingIntent = 'oplist';
  19165. if (!this.intentStates[renderingIntent]) {
  19166. this.intentStates[renderingIntent] = Object.create(null);
  19167. }
  19168. var intentState = this.intentStates[renderingIntent];
  19169. var opListTask;
  19170. if (!intentState.opListReadCapability) {
  19171. opListTask = {};
  19172. opListTask.operatorListChanged = operatorListChanged;
  19173. intentState.receivingOperatorList = true;
  19174. intentState.opListReadCapability = createPromiseCapability();
  19175. intentState.renderTasks = [];
  19176. intentState.renderTasks.push(opListTask);
  19177. intentState.operatorList = {
  19178. fnArray: [],
  19179. argsArray: [],
  19180. lastChunk: false
  19181. };
  19182. this.transport.messageHandler.send('RenderPageRequest', {
  19183. pageIndex: this.pageIndex,
  19184. intent: renderingIntent
  19185. });
  19186. }
  19187. return intentState.opListReadCapability.promise;
  19188. },
  19189. getTextContent: function PDFPageProxy_getTextContent(params) {
  19190. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19191. pageIndex: this.pageNumber - 1,
  19192. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19193. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19194. });
  19195. },
  19196. _destroy: function PDFPageProxy_destroy() {
  19197. this.destroyed = true;
  19198. this.transport.pageCache[this.pageIndex] = null;
  19199. var waitOn = [];
  19200. Object.keys(this.intentStates).forEach(function (intent) {
  19201. if (intent === 'oplist') {
  19202. return;
  19203. }
  19204. var intentState = this.intentStates[intent];
  19205. intentState.renderTasks.forEach(function (renderTask) {
  19206. var renderCompleted = renderTask.capability.promise.catch(function () {
  19207. });
  19208. waitOn.push(renderCompleted);
  19209. renderTask.cancel();
  19210. });
  19211. }, this);
  19212. this.objs.clear();
  19213. this.annotationsPromise = null;
  19214. this.pendingCleanup = false;
  19215. return Promise.all(waitOn);
  19216. },
  19217. destroy: function () {
  19218. deprecated('page destroy method, use cleanup() instead');
  19219. this.cleanup();
  19220. },
  19221. cleanup: function PDFPageProxy_cleanup() {
  19222. this.pendingCleanup = true;
  19223. this._tryCleanup();
  19224. },
  19225. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19226. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19227. var intentState = this.intentStates[intent];
  19228. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19229. }, this)) {
  19230. return;
  19231. }
  19232. Object.keys(this.intentStates).forEach(function (intent) {
  19233. delete this.intentStates[intent];
  19234. }, this);
  19235. this.objs.clear();
  19236. this.annotationsPromise = null;
  19237. this.pendingCleanup = false;
  19238. },
  19239. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19240. var intentState = this.intentStates[intent];
  19241. if (intentState.displayReadyCapability) {
  19242. intentState.displayReadyCapability.resolve(transparency);
  19243. }
  19244. },
  19245. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  19246. var intentState = this.intentStates[intent];
  19247. var i, ii;
  19248. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  19249. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  19250. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  19251. }
  19252. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  19253. for (i = 0; i < intentState.renderTasks.length; i++) {
  19254. intentState.renderTasks[i].operatorListChanged();
  19255. }
  19256. if (operatorListChunk.lastChunk) {
  19257. intentState.receivingOperatorList = false;
  19258. this._tryCleanup();
  19259. }
  19260. }
  19261. };
  19262. return PDFPageProxy;
  19263. }();
  19264. var PDFWorker = function PDFWorkerClosure() {
  19265. var nextFakeWorkerId = 0;
  19266. function getWorkerSrc() {
  19267. if (typeof workerSrc !== 'undefined') {
  19268. return workerSrc;
  19269. }
  19270. if (getDefaultSetting('workerSrc')) {
  19271. return getDefaultSetting('workerSrc');
  19272. }
  19273. if (pdfjsFilePath) {
  19274. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  19275. }
  19276. error('No PDFJS.workerSrc specified');
  19277. }
  19278. var fakeWorkerFilesLoadedCapability;
  19279. function setupFakeWorkerGlobal() {
  19280. var WorkerMessageHandler;
  19281. if (fakeWorkerFilesLoadedCapability) {
  19282. return fakeWorkerFilesLoadedCapability.promise;
  19283. }
  19284. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  19285. var pdfjsCoreWorker = __w_pdfjs_require__(23);
  19286. __w_pdfjs_require__(39);
  19287. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  19288. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  19289. return fakeWorkerFilesLoadedCapability.promise;
  19290. }
  19291. function FakeWorkerPort(defer) {
  19292. this._listeners = [];
  19293. this._defer = defer;
  19294. this._deferred = Promise.resolve(undefined);
  19295. }
  19296. FakeWorkerPort.prototype = {
  19297. postMessage: function (obj, transfers) {
  19298. function cloneValue(value) {
  19299. if (typeof value !== 'object' || value === null) {
  19300. return value;
  19301. }
  19302. if (cloned.has(value)) {
  19303. return cloned.get(value);
  19304. }
  19305. var result;
  19306. var buffer;
  19307. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  19308. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  19309. if (value === buffer) {
  19310. result = value;
  19311. } else if (transferable) {
  19312. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  19313. } else {
  19314. result = new value.constructor(value);
  19315. }
  19316. cloned.set(value, result);
  19317. return result;
  19318. }
  19319. result = isArray(value) ? [] : {};
  19320. cloned.set(value, result);
  19321. for (var i in value) {
  19322. var desc, p = value;
  19323. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  19324. p = Object.getPrototypeOf(p);
  19325. }
  19326. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  19327. continue;
  19328. }
  19329. result[i] = cloneValue(desc.value);
  19330. }
  19331. return result;
  19332. }
  19333. if (!this._defer) {
  19334. this._listeners.forEach(function (listener) {
  19335. listener.call(this, { data: obj });
  19336. }, this);
  19337. return;
  19338. }
  19339. var cloned = new WeakMap();
  19340. var e = { data: cloneValue(obj) };
  19341. this._deferred.then(function () {
  19342. this._listeners.forEach(function (listener) {
  19343. listener.call(this, e);
  19344. }, this);
  19345. }.bind(this));
  19346. },
  19347. addEventListener: function (name, listener) {
  19348. this._listeners.push(listener);
  19349. },
  19350. removeEventListener: function (name, listener) {
  19351. var i = this._listeners.indexOf(listener);
  19352. this._listeners.splice(i, 1);
  19353. },
  19354. terminate: function () {
  19355. this._listeners = [];
  19356. }
  19357. };
  19358. function createCDNWrapper(url) {
  19359. var wrapper = 'importScripts(\'' + url + '\');';
  19360. return URL.createObjectURL(new Blob([wrapper]));
  19361. }
  19362. function PDFWorker(name, port) {
  19363. this.name = name;
  19364. this.destroyed = false;
  19365. this._readyCapability = createPromiseCapability();
  19366. this._port = null;
  19367. this._webWorker = null;
  19368. this._messageHandler = null;
  19369. if (port) {
  19370. this._initializeFromPort(port);
  19371. return;
  19372. }
  19373. this._initialize();
  19374. }
  19375. PDFWorker.prototype = {
  19376. get promise() {
  19377. return this._readyCapability.promise;
  19378. },
  19379. get port() {
  19380. return this._port;
  19381. },
  19382. get messageHandler() {
  19383. return this._messageHandler;
  19384. },
  19385. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  19386. this._port = port;
  19387. this._messageHandler = new MessageHandler('main', 'worker', port);
  19388. this._messageHandler.on('ready', function () {
  19389. });
  19390. this._readyCapability.resolve();
  19391. },
  19392. _initialize: function PDFWorker_initialize() {
  19393. this._setupFakeWorker();
  19394. },
  19395. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  19396. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  19397. warn('Setting up fake worker.');
  19398. isWorkerDisabled = true;
  19399. }
  19400. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  19401. if (this.destroyed) {
  19402. this._readyCapability.reject(new Error('Worker was destroyed'));
  19403. return;
  19404. }
  19405. var isTypedArraysPresent = Uint8Array !== Float32Array;
  19406. var port = new FakeWorkerPort(isTypedArraysPresent);
  19407. this._port = port;
  19408. var id = 'fake' + nextFakeWorkerId++;
  19409. var workerHandler = new MessageHandler(id + '_worker', id, port);
  19410. WorkerMessageHandler.setup(workerHandler, port);
  19411. var messageHandler = new MessageHandler(id, id + '_worker', port);
  19412. this._messageHandler = messageHandler;
  19413. this._readyCapability.resolve();
  19414. }.bind(this));
  19415. },
  19416. destroy: function PDFWorker_destroy() {
  19417. this.destroyed = true;
  19418. if (this._webWorker) {
  19419. this._webWorker.terminate();
  19420. this._webWorker = null;
  19421. }
  19422. this._port = null;
  19423. if (this._messageHandler) {
  19424. this._messageHandler.destroy();
  19425. this._messageHandler = null;
  19426. }
  19427. }
  19428. };
  19429. return PDFWorker;
  19430. }();
  19431. var WorkerTransport = function WorkerTransportClosure() {
  19432. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  19433. this.messageHandler = messageHandler;
  19434. this.loadingTask = loadingTask;
  19435. this.pdfDataRangeTransport = pdfDataRangeTransport;
  19436. this.commonObjs = new PDFObjects();
  19437. this.fontLoader = new FontLoader(loadingTask.docId);
  19438. this.CMapReaderFactory = new CMapReaderFactory({
  19439. baseUrl: getDefaultSetting('cMapUrl'),
  19440. isCompressed: getDefaultSetting('cMapPacked')
  19441. });
  19442. this.destroyed = false;
  19443. this.destroyCapability = null;
  19444. this._passwordCapability = null;
  19445. this.pageCache = [];
  19446. this.pagePromises = [];
  19447. this.downloadInfoCapability = createPromiseCapability();
  19448. this.setupMessageHandler();
  19449. }
  19450. WorkerTransport.prototype = {
  19451. destroy: function WorkerTransport_destroy() {
  19452. if (this.destroyCapability) {
  19453. return this.destroyCapability.promise;
  19454. }
  19455. this.destroyed = true;
  19456. this.destroyCapability = createPromiseCapability();
  19457. if (this._passwordCapability) {
  19458. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  19459. }
  19460. var waitOn = [];
  19461. this.pageCache.forEach(function (page) {
  19462. if (page) {
  19463. waitOn.push(page._destroy());
  19464. }
  19465. });
  19466. this.pageCache = [];
  19467. this.pagePromises = [];
  19468. var self = this;
  19469. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  19470. waitOn.push(terminated);
  19471. Promise.all(waitOn).then(function () {
  19472. self.fontLoader.clear();
  19473. if (self.pdfDataRangeTransport) {
  19474. self.pdfDataRangeTransport.abort();
  19475. self.pdfDataRangeTransport = null;
  19476. }
  19477. if (self.messageHandler) {
  19478. self.messageHandler.destroy();
  19479. self.messageHandler = null;
  19480. }
  19481. self.destroyCapability.resolve();
  19482. }, this.destroyCapability.reject);
  19483. return this.destroyCapability.promise;
  19484. },
  19485. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  19486. var messageHandler = this.messageHandler;
  19487. var loadingTask = this.loadingTask;
  19488. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  19489. if (pdfDataRangeTransport) {
  19490. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  19491. messageHandler.send('OnDataRange', {
  19492. begin: begin,
  19493. chunk: chunk
  19494. });
  19495. });
  19496. pdfDataRangeTransport.addProgressListener(function (loaded) {
  19497. messageHandler.send('OnDataProgress', { loaded: loaded });
  19498. });
  19499. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  19500. messageHandler.send('OnDataRange', { chunk: chunk });
  19501. });
  19502. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  19503. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  19504. }, this);
  19505. }
  19506. messageHandler.on('GetDoc', function transportDoc(data) {
  19507. var pdfInfo = data.pdfInfo;
  19508. this.numPages = data.pdfInfo.numPages;
  19509. var loadingTask = this.loadingTask;
  19510. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  19511. this.pdfDocument = pdfDocument;
  19512. loadingTask._capability.resolve(pdfDocument);
  19513. }, this);
  19514. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  19515. this._passwordCapability = createPromiseCapability();
  19516. if (loadingTask.onPassword) {
  19517. var updatePassword = function (password) {
  19518. this._passwordCapability.resolve({ password: password });
  19519. }.bind(this);
  19520. loadingTask.onPassword(updatePassword, exception.code);
  19521. } else {
  19522. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  19523. }
  19524. return this._passwordCapability.promise;
  19525. }, this);
  19526. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  19527. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  19528. }, this);
  19529. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  19530. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  19531. }, this);
  19532. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  19533. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  19534. }, this);
  19535. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  19536. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  19537. }, this);
  19538. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  19539. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  19540. }, this);
  19541. messageHandler.on('DataLoaded', function transportPage(data) {
  19542. this.downloadInfoCapability.resolve(data);
  19543. }, this);
  19544. messageHandler.on('PDFManagerReady', function transportPage(data) {
  19545. if (this.pdfDataRangeTransport) {
  19546. this.pdfDataRangeTransport.transportReady();
  19547. }
  19548. }, this);
  19549. messageHandler.on('StartRenderPage', function transportRender(data) {
  19550. if (this.destroyed) {
  19551. return;
  19552. }
  19553. var page = this.pageCache[data.pageIndex];
  19554. page.stats.timeEnd('Page Request');
  19555. page._startRenderPage(data.transparency, data.intent);
  19556. }, this);
  19557. messageHandler.on('RenderPageChunk', function transportRender(data) {
  19558. if (this.destroyed) {
  19559. return;
  19560. }
  19561. var page = this.pageCache[data.pageIndex];
  19562. page._renderPageChunk(data.operatorList, data.intent);
  19563. }, this);
  19564. messageHandler.on('commonobj', function transportObj(data) {
  19565. if (this.destroyed) {
  19566. return;
  19567. }
  19568. var id = data[0];
  19569. var type = data[1];
  19570. if (this.commonObjs.hasData(id)) {
  19571. return;
  19572. }
  19573. switch (type) {
  19574. case 'Font':
  19575. var exportedData = data[2];
  19576. if ('error' in exportedData) {
  19577. var exportedError = exportedData.error;
  19578. warn('Error during font loading: ' + exportedError);
  19579. this.commonObjs.resolve(id, exportedError);
  19580. break;
  19581. }
  19582. var fontRegistry = null;
  19583. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  19584. fontRegistry = {
  19585. registerFont: function (font, url) {
  19586. globalScope['FontInspector'].fontAdded(font, url);
  19587. }
  19588. };
  19589. }
  19590. var font = new FontFaceObject(exportedData, {
  19591. isEvalSuported: getDefaultSetting('isEvalSupported'),
  19592. disableFontFace: getDefaultSetting('disableFontFace'),
  19593. fontRegistry: fontRegistry
  19594. });
  19595. this.fontLoader.bind([font], function fontReady(fontObjs) {
  19596. this.commonObjs.resolve(id, font);
  19597. }.bind(this));
  19598. break;
  19599. case 'FontPath':
  19600. this.commonObjs.resolve(id, data[2]);
  19601. break;
  19602. default:
  19603. error('Got unknown common object type ' + type);
  19604. }
  19605. }, this);
  19606. messageHandler.on('obj', function transportObj(data) {
  19607. if (this.destroyed) {
  19608. return;
  19609. }
  19610. var id = data[0];
  19611. var pageIndex = data[1];
  19612. var type = data[2];
  19613. var pageProxy = this.pageCache[pageIndex];
  19614. var imageData;
  19615. if (pageProxy.objs.hasData(id)) {
  19616. return;
  19617. }
  19618. switch (type) {
  19619. case 'JpegStream':
  19620. imageData = data[3];
  19621. loadJpegStream(id, imageData, pageProxy.objs);
  19622. break;
  19623. case 'Image':
  19624. imageData = data[3];
  19625. pageProxy.objs.resolve(id, imageData);
  19626. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  19627. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  19628. pageProxy.cleanupAfterRender = true;
  19629. }
  19630. break;
  19631. default:
  19632. error('Got unknown object type ' + type);
  19633. }
  19634. }, this);
  19635. messageHandler.on('DocProgress', function transportDocProgress(data) {
  19636. if (this.destroyed) {
  19637. return;
  19638. }
  19639. var loadingTask = this.loadingTask;
  19640. if (loadingTask.onProgress) {
  19641. loadingTask.onProgress({
  19642. loaded: data.loaded,
  19643. total: data.total
  19644. });
  19645. }
  19646. }, this);
  19647. messageHandler.on('PageError', function transportError(data) {
  19648. if (this.destroyed) {
  19649. return;
  19650. }
  19651. var page = this.pageCache[data.pageNum - 1];
  19652. var intentState = page.intentStates[data.intent];
  19653. if (intentState.displayReadyCapability) {
  19654. intentState.displayReadyCapability.reject(data.error);
  19655. } else {
  19656. error(data.error);
  19657. }
  19658. if (intentState.operatorList) {
  19659. intentState.operatorList.lastChunk = true;
  19660. for (var i = 0; i < intentState.renderTasks.length; i++) {
  19661. intentState.renderTasks[i].operatorListChanged();
  19662. }
  19663. }
  19664. }, this);
  19665. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  19666. if (this.destroyed) {
  19667. return;
  19668. }
  19669. var featureId = data.featureId;
  19670. var loadingTask = this.loadingTask;
  19671. if (loadingTask.onUnsupportedFeature) {
  19672. loadingTask.onUnsupportedFeature(featureId);
  19673. }
  19674. _UnsupportedManager.notify(featureId);
  19675. }, this);
  19676. messageHandler.on('JpegDecode', function (data) {
  19677. if (this.destroyed) {
  19678. return Promise.reject(new Error('Worker was destroyed'));
  19679. }
  19680. if (typeof document === 'undefined') {
  19681. return Promise.reject(new Error('"document" is not defined.'));
  19682. }
  19683. var imageUrl = data[0];
  19684. var components = data[1];
  19685. if (components !== 3 && components !== 1) {
  19686. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  19687. }
  19688. return new Promise(function (resolve, reject) {
  19689. var img = new Image();
  19690. img.onload = function () {
  19691. var width = img.width;
  19692. var height = img.height;
  19693. var size = width * height;
  19694. var rgbaLength = size * 4;
  19695. var buf = new Uint8Array(size * components);
  19696. var tmpCanvas = document.createElement('canvas');
  19697. tmpCanvas.width = width;
  19698. tmpCanvas.height = height;
  19699. var tmpCtx = tmpCanvas.getContext('2d');
  19700. tmpCtx.drawImage(img, 0, 0);
  19701. var data = tmpCtx.getImageData(0, 0, width, height).data;
  19702. var i, j;
  19703. if (components === 3) {
  19704. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  19705. buf[j] = data[i];
  19706. buf[j + 1] = data[i + 1];
  19707. buf[j + 2] = data[i + 2];
  19708. }
  19709. } else if (components === 1) {
  19710. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  19711. buf[j] = data[i];
  19712. }
  19713. }
  19714. resolve({
  19715. data: buf,
  19716. width: width,
  19717. height: height
  19718. });
  19719. };
  19720. img.onerror = function () {
  19721. reject(new Error('JpegDecode failed to load image'));
  19722. };
  19723. img.src = imageUrl;
  19724. });
  19725. }, this);
  19726. messageHandler.on('FetchBuiltInCMap', function (data) {
  19727. if (this.destroyed) {
  19728. return Promise.reject(new Error('Worker was destroyed'));
  19729. }
  19730. return this.CMapReaderFactory.fetch({ name: data.name });
  19731. }, this);
  19732. },
  19733. getData: function WorkerTransport_getData() {
  19734. return this.messageHandler.sendWithPromise('GetData', null);
  19735. },
  19736. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  19737. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  19738. return Promise.reject(new Error('Invalid page request'));
  19739. }
  19740. var pageIndex = pageNumber - 1;
  19741. if (pageIndex in this.pagePromises) {
  19742. return this.pagePromises[pageIndex];
  19743. }
  19744. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  19745. if (this.destroyed) {
  19746. throw new Error('Transport destroyed');
  19747. }
  19748. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  19749. this.pageCache[pageIndex] = page;
  19750. return page;
  19751. }.bind(this));
  19752. this.pagePromises[pageIndex] = promise;
  19753. return promise;
  19754. },
  19755. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  19756. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  19757. return Promise.reject(new Error(reason));
  19758. });
  19759. },
  19760. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  19761. return this.messageHandler.sendWithPromise('GetAnnotations', {
  19762. pageIndex: pageIndex,
  19763. intent: intent
  19764. });
  19765. },
  19766. getDestinations: function WorkerTransport_getDestinations() {
  19767. return this.messageHandler.sendWithPromise('GetDestinations', null);
  19768. },
  19769. getDestination: function WorkerTransport_getDestination(id) {
  19770. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  19771. },
  19772. getPageLabels: function WorkerTransport_getPageLabels() {
  19773. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  19774. },
  19775. getAttachments: function WorkerTransport_getAttachments() {
  19776. return this.messageHandler.sendWithPromise('GetAttachments', null);
  19777. },
  19778. getJavaScript: function WorkerTransport_getJavaScript() {
  19779. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  19780. },
  19781. getOutline: function WorkerTransport_getOutline() {
  19782. return this.messageHandler.sendWithPromise('GetOutline', null);
  19783. },
  19784. getMetadata: function WorkerTransport_getMetadata() {
  19785. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  19786. return {
  19787. info: results[0],
  19788. metadata: results[1] ? new Metadata(results[1]) : null
  19789. };
  19790. });
  19791. },
  19792. getStats: function WorkerTransport_getStats() {
  19793. return this.messageHandler.sendWithPromise('GetStats', null);
  19794. },
  19795. startCleanup: function WorkerTransport_startCleanup() {
  19796. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  19797. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  19798. var page = this.pageCache[i];
  19799. if (page) {
  19800. page.cleanup();
  19801. }
  19802. }
  19803. this.commonObjs.clear();
  19804. this.fontLoader.clear();
  19805. }.bind(this));
  19806. }
  19807. };
  19808. return WorkerTransport;
  19809. }();
  19810. var PDFObjects = function PDFObjectsClosure() {
  19811. function PDFObjects() {
  19812. this.objs = Object.create(null);
  19813. }
  19814. PDFObjects.prototype = {
  19815. ensureObj: function PDFObjects_ensureObj(objId) {
  19816. if (this.objs[objId]) {
  19817. return this.objs[objId];
  19818. }
  19819. var obj = {
  19820. capability: createPromiseCapability(),
  19821. data: null,
  19822. resolved: false
  19823. };
  19824. this.objs[objId] = obj;
  19825. return obj;
  19826. },
  19827. get: function PDFObjects_get(objId, callback) {
  19828. if (callback) {
  19829. this.ensureObj(objId).capability.promise.then(callback);
  19830. return null;
  19831. }
  19832. var obj = this.objs[objId];
  19833. if (!obj || !obj.resolved) {
  19834. error('Requesting object that isn\'t resolved yet ' + objId);
  19835. }
  19836. return obj.data;
  19837. },
  19838. resolve: function PDFObjects_resolve(objId, data) {
  19839. var obj = this.ensureObj(objId);
  19840. obj.resolved = true;
  19841. obj.data = data;
  19842. obj.capability.resolve(data);
  19843. },
  19844. isResolved: function PDFObjects_isResolved(objId) {
  19845. var objs = this.objs;
  19846. if (!objs[objId]) {
  19847. return false;
  19848. }
  19849. return objs[objId].resolved;
  19850. },
  19851. hasData: function PDFObjects_hasData(objId) {
  19852. return this.isResolved(objId);
  19853. },
  19854. getData: function PDFObjects_getData(objId) {
  19855. var objs = this.objs;
  19856. if (!objs[objId] || !objs[objId].resolved) {
  19857. return null;
  19858. }
  19859. return objs[objId].data;
  19860. },
  19861. clear: function PDFObjects_clear() {
  19862. this.objs = Object.create(null);
  19863. }
  19864. };
  19865. return PDFObjects;
  19866. }();
  19867. var RenderTask = function RenderTaskClosure() {
  19868. function RenderTask(internalRenderTask) {
  19869. this._internalRenderTask = internalRenderTask;
  19870. this.onContinue = null;
  19871. }
  19872. RenderTask.prototype = {
  19873. get promise() {
  19874. return this._internalRenderTask.capability.promise;
  19875. },
  19876. cancel: function RenderTask_cancel() {
  19877. this._internalRenderTask.cancel();
  19878. },
  19879. then: function RenderTask_then(onFulfilled, onRejected) {
  19880. return this.promise.then.apply(this.promise, arguments);
  19881. }
  19882. };
  19883. return RenderTask;
  19884. }();
  19885. var InternalRenderTask = function InternalRenderTaskClosure() {
  19886. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  19887. this.callback = callback;
  19888. this.params = params;
  19889. this.objs = objs;
  19890. this.commonObjs = commonObjs;
  19891. this.operatorListIdx = null;
  19892. this.operatorList = operatorList;
  19893. this.pageNumber = pageNumber;
  19894. this.canvasFactory = canvasFactory;
  19895. this.running = false;
  19896. this.graphicsReadyCallback = null;
  19897. this.graphicsReady = false;
  19898. this.useRequestAnimationFrame = false;
  19899. this.cancelled = false;
  19900. this.capability = createPromiseCapability();
  19901. this.task = new RenderTask(this);
  19902. this._continueBound = this._continue.bind(this);
  19903. this._scheduleNextBound = this._scheduleNext.bind(this);
  19904. this._nextBound = this._next.bind(this);
  19905. }
  19906. InternalRenderTask.prototype = {
  19907. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  19908. if (this.cancelled) {
  19909. return;
  19910. }
  19911. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  19912. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  19913. this.stepper.init(this.operatorList);
  19914. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  19915. }
  19916. var params = this.params;
  19917. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  19918. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  19919. this.operatorListIdx = 0;
  19920. this.graphicsReady = true;
  19921. if (this.graphicsReadyCallback) {
  19922. this.graphicsReadyCallback();
  19923. }
  19924. },
  19925. cancel: function InternalRenderTask_cancel() {
  19926. this.running = false;
  19927. this.cancelled = true;
  19928. this.callback('cancelled');
  19929. },
  19930. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  19931. if (!this.graphicsReady) {
  19932. if (!this.graphicsReadyCallback) {
  19933. this.graphicsReadyCallback = this._continueBound;
  19934. }
  19935. return;
  19936. }
  19937. if (this.stepper) {
  19938. this.stepper.updateOperatorList(this.operatorList);
  19939. }
  19940. if (this.running) {
  19941. return;
  19942. }
  19943. this._continue();
  19944. },
  19945. _continue: function InternalRenderTask__continue() {
  19946. this.running = true;
  19947. if (this.cancelled) {
  19948. return;
  19949. }
  19950. if (this.task.onContinue) {
  19951. this.task.onContinue(this._scheduleNextBound);
  19952. } else {
  19953. this._scheduleNext();
  19954. }
  19955. },
  19956. _scheduleNext: function InternalRenderTask__scheduleNext() {
  19957. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  19958. window.requestAnimationFrame(this._nextBound);
  19959. } else {
  19960. Promise.resolve(undefined).then(this._nextBound);
  19961. }
  19962. },
  19963. _next: function InternalRenderTask__next() {
  19964. if (this.cancelled) {
  19965. return;
  19966. }
  19967. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  19968. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  19969. this.running = false;
  19970. if (this.operatorList.lastChunk) {
  19971. this.gfx.endDrawing();
  19972. this.callback();
  19973. }
  19974. }
  19975. }
  19976. };
  19977. return InternalRenderTask;
  19978. }();
  19979. var _UnsupportedManager = function UnsupportedManagerClosure() {
  19980. var listeners = [];
  19981. return {
  19982. listen: function (cb) {
  19983. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  19984. listeners.push(cb);
  19985. },
  19986. notify: function (featureId) {
  19987. for (var i = 0, ii = listeners.length; i < ii; i++) {
  19988. listeners[i](featureId);
  19989. }
  19990. }
  19991. };
  19992. }();
  19993. exports.version = '1.7.361';
  19994. exports.build = '224613a5';
  19995. exports.getDocument = getDocument;
  19996. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  19997. exports.PDFWorker = PDFWorker;
  19998. exports.PDFDocumentProxy = PDFDocumentProxy;
  19999. exports.PDFPageProxy = PDFPageProxy;
  20000. exports._UnsupportedManager = _UnsupportedManager;
  20001. /***/ }),
  20002. /* 11 */
  20003. /***/ (function(module, exports, __w_pdfjs_require__) {
  20004. "use strict";
  20005. var sharedUtil = __w_pdfjs_require__(0);
  20006. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20007. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20008. var ImageKind = sharedUtil.ImageKind;
  20009. var OPS = sharedUtil.OPS;
  20010. var Util = sharedUtil.Util;
  20011. var isNum = sharedUtil.isNum;
  20012. var isArray = sharedUtil.isArray;
  20013. var warn = sharedUtil.warn;
  20014. var createObjectURL = sharedUtil.createObjectURL;
  20015. var SVG_DEFAULTS = {
  20016. fontStyle: 'normal',
  20017. fontWeight: 'normal',
  20018. fillColor: '#000000'
  20019. };
  20020. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20021. var PNG_HEADER = new Uint8Array([
  20022. 0x89,
  20023. 0x50,
  20024. 0x4e,
  20025. 0x47,
  20026. 0x0d,
  20027. 0x0a,
  20028. 0x1a,
  20029. 0x0a
  20030. ]);
  20031. var CHUNK_WRAPPER_SIZE = 12;
  20032. var crcTable = new Int32Array(256);
  20033. for (var i = 0; i < 256; i++) {
  20034. var c = i;
  20035. for (var h = 0; h < 8; h++) {
  20036. if (c & 1) {
  20037. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20038. } else {
  20039. c = c >> 1 & 0x7fffffff;
  20040. }
  20041. }
  20042. crcTable[i] = c;
  20043. }
  20044. function crc32(data, start, end) {
  20045. var crc = -1;
  20046. for (var i = start; i < end; i++) {
  20047. var a = (crc ^ data[i]) & 0xff;
  20048. var b = crcTable[a];
  20049. crc = crc >>> 8 ^ b;
  20050. }
  20051. return crc ^ -1;
  20052. }
  20053. function writePngChunk(type, body, data, offset) {
  20054. var p = offset;
  20055. var len = body.length;
  20056. data[p] = len >> 24 & 0xff;
  20057. data[p + 1] = len >> 16 & 0xff;
  20058. data[p + 2] = len >> 8 & 0xff;
  20059. data[p + 3] = len & 0xff;
  20060. p += 4;
  20061. data[p] = type.charCodeAt(0) & 0xff;
  20062. data[p + 1] = type.charCodeAt(1) & 0xff;
  20063. data[p + 2] = type.charCodeAt(2) & 0xff;
  20064. data[p + 3] = type.charCodeAt(3) & 0xff;
  20065. p += 4;
  20066. data.set(body, p);
  20067. p += body.length;
  20068. var crc = crc32(data, offset + 4, p);
  20069. data[p] = crc >> 24 & 0xff;
  20070. data[p + 1] = crc >> 16 & 0xff;
  20071. data[p + 2] = crc >> 8 & 0xff;
  20072. data[p + 3] = crc & 0xff;
  20073. }
  20074. function adler32(data, start, end) {
  20075. var a = 1;
  20076. var b = 0;
  20077. for (var i = start; i < end; ++i) {
  20078. a = (a + (data[i] & 0xff)) % 65521;
  20079. b = (b + a) % 65521;
  20080. }
  20081. return b << 16 | a;
  20082. }
  20083. function encode(imgData, kind, forceDataSchema) {
  20084. var width = imgData.width;
  20085. var height = imgData.height;
  20086. var bitDepth, colorType, lineSize;
  20087. var bytes = imgData.data;
  20088. switch (kind) {
  20089. case ImageKind.GRAYSCALE_1BPP:
  20090. colorType = 0;
  20091. bitDepth = 1;
  20092. lineSize = width + 7 >> 3;
  20093. break;
  20094. case ImageKind.RGB_24BPP:
  20095. colorType = 2;
  20096. bitDepth = 8;
  20097. lineSize = width * 3;
  20098. break;
  20099. case ImageKind.RGBA_32BPP:
  20100. colorType = 6;
  20101. bitDepth = 8;
  20102. lineSize = width * 4;
  20103. break;
  20104. default:
  20105. throw new Error('invalid format');
  20106. }
  20107. var literals = new Uint8Array((1 + lineSize) * height);
  20108. var offsetLiterals = 0, offsetBytes = 0;
  20109. var y, i;
  20110. for (y = 0; y < height; ++y) {
  20111. literals[offsetLiterals++] = 0;
  20112. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20113. offsetBytes += lineSize;
  20114. offsetLiterals += lineSize;
  20115. }
  20116. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20117. offsetLiterals = 0;
  20118. for (y = 0; y < height; y++) {
  20119. offsetLiterals++;
  20120. for (i = 0; i < lineSize; i++) {
  20121. literals[offsetLiterals++] ^= 0xFF;
  20122. }
  20123. }
  20124. }
  20125. var ihdr = new Uint8Array([
  20126. width >> 24 & 0xff,
  20127. width >> 16 & 0xff,
  20128. width >> 8 & 0xff,
  20129. width & 0xff,
  20130. height >> 24 & 0xff,
  20131. height >> 16 & 0xff,
  20132. height >> 8 & 0xff,
  20133. height & 0xff,
  20134. bitDepth,
  20135. colorType,
  20136. 0x00,
  20137. 0x00,
  20138. 0x00
  20139. ]);
  20140. var len = literals.length;
  20141. var maxBlockLength = 0xFFFF;
  20142. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20143. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20144. var pi = 0;
  20145. idat[pi++] = 0x78;
  20146. idat[pi++] = 0x9c;
  20147. var pos = 0;
  20148. while (len > maxBlockLength) {
  20149. idat[pi++] = 0x00;
  20150. idat[pi++] = 0xff;
  20151. idat[pi++] = 0xff;
  20152. idat[pi++] = 0x00;
  20153. idat[pi++] = 0x00;
  20154. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20155. pi += maxBlockLength;
  20156. pos += maxBlockLength;
  20157. len -= maxBlockLength;
  20158. }
  20159. idat[pi++] = 0x01;
  20160. idat[pi++] = len & 0xff;
  20161. idat[pi++] = len >> 8 & 0xff;
  20162. idat[pi++] = ~len & 0xffff & 0xff;
  20163. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20164. idat.set(literals.subarray(pos), pi);
  20165. pi += literals.length - pos;
  20166. var adler = adler32(literals, 0, literals.length);
  20167. idat[pi++] = adler >> 24 & 0xff;
  20168. idat[pi++] = adler >> 16 & 0xff;
  20169. idat[pi++] = adler >> 8 & 0xff;
  20170. idat[pi++] = adler & 0xff;
  20171. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20172. var data = new Uint8Array(pngLength);
  20173. var offset = 0;
  20174. data.set(PNG_HEADER, offset);
  20175. offset += PNG_HEADER.length;
  20176. writePngChunk('IHDR', ihdr, data, offset);
  20177. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20178. writePngChunk('IDATA', idat, data, offset);
  20179. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20180. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20181. return createObjectURL(data, 'image/png', forceDataSchema);
  20182. }
  20183. return function convertImgDataToPng(imgData, forceDataSchema) {
  20184. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20185. return encode(imgData, kind, forceDataSchema);
  20186. };
  20187. }();
  20188. var SVGExtraState = function SVGExtraStateClosure() {
  20189. function SVGExtraState() {
  20190. this.fontSizeScale = 1;
  20191. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20192. this.fontSize = 0;
  20193. this.textMatrix = IDENTITY_MATRIX;
  20194. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20195. this.leading = 0;
  20196. this.x = 0;
  20197. this.y = 0;
  20198. this.lineX = 0;
  20199. this.lineY = 0;
  20200. this.charSpacing = 0;
  20201. this.wordSpacing = 0;
  20202. this.textHScale = 1;
  20203. this.textRise = 0;
  20204. this.fillColor = SVG_DEFAULTS.fillColor;
  20205. this.strokeColor = '#000000';
  20206. this.fillAlpha = 1;
  20207. this.strokeAlpha = 1;
  20208. this.lineWidth = 1;
  20209. this.lineJoin = '';
  20210. this.lineCap = '';
  20211. this.miterLimit = 0;
  20212. this.dashArray = [];
  20213. this.dashPhase = 0;
  20214. this.dependencies = [];
  20215. this.activeClipUrl = null;
  20216. this.clipGroup = null;
  20217. this.maskId = '';
  20218. }
  20219. SVGExtraState.prototype = {
  20220. clone: function SVGExtraState_clone() {
  20221. return Object.create(this);
  20222. },
  20223. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20224. this.x = x;
  20225. this.y = y;
  20226. }
  20227. };
  20228. return SVGExtraState;
  20229. }();
  20230. var SVGGraphics = function SVGGraphicsClosure() {
  20231. function opListToTree(opList) {
  20232. var opTree = [];
  20233. var tmp = [];
  20234. var opListLen = opList.length;
  20235. for (var x = 0; x < opListLen; x++) {
  20236. if (opList[x].fn === 'save') {
  20237. opTree.push({
  20238. 'fnId': 92,
  20239. 'fn': 'group',
  20240. 'items': []
  20241. });
  20242. tmp.push(opTree);
  20243. opTree = opTree[opTree.length - 1].items;
  20244. continue;
  20245. }
  20246. if (opList[x].fn === 'restore') {
  20247. opTree = tmp.pop();
  20248. } else {
  20249. opTree.push(opList[x]);
  20250. }
  20251. }
  20252. return opTree;
  20253. }
  20254. function pf(value) {
  20255. if (value === (value | 0)) {
  20256. return value.toString();
  20257. }
  20258. var s = value.toFixed(10);
  20259. var i = s.length - 1;
  20260. if (s[i] !== '0') {
  20261. return s;
  20262. }
  20263. do {
  20264. i--;
  20265. } while (s[i] === '0');
  20266. return s.substr(0, s[i] === '.' ? i : i + 1);
  20267. }
  20268. function pm(m) {
  20269. if (m[4] === 0 && m[5] === 0) {
  20270. if (m[1] === 0 && m[2] === 0) {
  20271. if (m[0] === 1 && m[3] === 1) {
  20272. return '';
  20273. }
  20274. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  20275. }
  20276. if (m[0] === m[3] && m[1] === -m[2]) {
  20277. var a = Math.acos(m[0]) * 180 / Math.PI;
  20278. return 'rotate(' + pf(a) + ')';
  20279. }
  20280. } else {
  20281. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20282. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20283. }
  20284. }
  20285. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20286. }
  20287. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  20288. this.current = new SVGExtraState();
  20289. this.transformMatrix = IDENTITY_MATRIX;
  20290. this.transformStack = [];
  20291. this.extraStack = [];
  20292. this.commonObjs = commonObjs;
  20293. this.objs = objs;
  20294. this.pendingEOFill = false;
  20295. this.embedFonts = false;
  20296. this.embeddedFonts = Object.create(null);
  20297. this.cssStyle = null;
  20298. this.forceDataSchema = !!forceDataSchema;
  20299. }
  20300. var NS = 'http://www.w3.org/2000/svg';
  20301. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  20302. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  20303. var LINE_CAP_STYLES = [
  20304. 'butt',
  20305. 'round',
  20306. 'square'
  20307. ];
  20308. var LINE_JOIN_STYLES = [
  20309. 'miter',
  20310. 'round',
  20311. 'bevel'
  20312. ];
  20313. var clipCount = 0;
  20314. var maskCount = 0;
  20315. SVGGraphics.prototype = {
  20316. save: function SVGGraphics_save() {
  20317. this.transformStack.push(this.transformMatrix);
  20318. var old = this.current;
  20319. this.extraStack.push(old);
  20320. this.current = old.clone();
  20321. },
  20322. restore: function SVGGraphics_restore() {
  20323. this.transformMatrix = this.transformStack.pop();
  20324. this.current = this.extraStack.pop();
  20325. this.tgrp = null;
  20326. },
  20327. group: function SVGGraphics_group(items) {
  20328. this.save();
  20329. this.executeOpTree(items);
  20330. this.restore();
  20331. },
  20332. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  20333. var fnArray = operatorList.fnArray;
  20334. var fnArrayLen = fnArray.length;
  20335. var argsArray = operatorList.argsArray;
  20336. var self = this;
  20337. for (var i = 0; i < fnArrayLen; i++) {
  20338. if (OPS.dependency === fnArray[i]) {
  20339. var deps = argsArray[i];
  20340. for (var n = 0, nn = deps.length; n < nn; n++) {
  20341. var obj = deps[n];
  20342. var common = obj.substring(0, 2) === 'g_';
  20343. var promise;
  20344. if (common) {
  20345. promise = new Promise(function (resolve) {
  20346. self.commonObjs.get(obj, resolve);
  20347. });
  20348. } else {
  20349. promise = new Promise(function (resolve) {
  20350. self.objs.get(obj, resolve);
  20351. });
  20352. }
  20353. this.current.dependencies.push(promise);
  20354. }
  20355. }
  20356. }
  20357. return Promise.all(this.current.dependencies);
  20358. },
  20359. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  20360. var transformMatrix = [
  20361. a,
  20362. b,
  20363. c,
  20364. d,
  20365. e,
  20366. f
  20367. ];
  20368. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  20369. this.tgrp = null;
  20370. },
  20371. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  20372. this.viewport = viewport;
  20373. var svgElement = this._initialize(viewport);
  20374. return this.loadDependencies(operatorList).then(function () {
  20375. this.transformMatrix = IDENTITY_MATRIX;
  20376. var opTree = this.convertOpList(operatorList);
  20377. this.executeOpTree(opTree);
  20378. return svgElement;
  20379. }.bind(this));
  20380. },
  20381. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  20382. var argsArray = operatorList.argsArray;
  20383. var fnArray = operatorList.fnArray;
  20384. var fnArrayLen = fnArray.length;
  20385. var REVOPS = [];
  20386. var opList = [];
  20387. for (var op in OPS) {
  20388. REVOPS[OPS[op]] = op;
  20389. }
  20390. for (var x = 0; x < fnArrayLen; x++) {
  20391. var fnId = fnArray[x];
  20392. opList.push({
  20393. 'fnId': fnId,
  20394. 'fn': REVOPS[fnId],
  20395. 'args': argsArray[x]
  20396. });
  20397. }
  20398. return opListToTree(opList);
  20399. },
  20400. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  20401. var opTreeLen = opTree.length;
  20402. for (var x = 0; x < opTreeLen; x++) {
  20403. var fn = opTree[x].fn;
  20404. var fnId = opTree[x].fnId;
  20405. var args = opTree[x].args;
  20406. switch (fnId | 0) {
  20407. case OPS.beginText:
  20408. this.beginText();
  20409. break;
  20410. case OPS.setLeading:
  20411. this.setLeading(args);
  20412. break;
  20413. case OPS.setLeadingMoveText:
  20414. this.setLeadingMoveText(args[0], args[1]);
  20415. break;
  20416. case OPS.setFont:
  20417. this.setFont(args);
  20418. break;
  20419. case OPS.showText:
  20420. this.showText(args[0]);
  20421. break;
  20422. case OPS.showSpacedText:
  20423. this.showText(args[0]);
  20424. break;
  20425. case OPS.endText:
  20426. this.endText();
  20427. break;
  20428. case OPS.moveText:
  20429. this.moveText(args[0], args[1]);
  20430. break;
  20431. case OPS.setCharSpacing:
  20432. this.setCharSpacing(args[0]);
  20433. break;
  20434. case OPS.setWordSpacing:
  20435. this.setWordSpacing(args[0]);
  20436. break;
  20437. case OPS.setHScale:
  20438. this.setHScale(args[0]);
  20439. break;
  20440. case OPS.setTextMatrix:
  20441. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20442. break;
  20443. case OPS.setLineWidth:
  20444. this.setLineWidth(args[0]);
  20445. break;
  20446. case OPS.setLineJoin:
  20447. this.setLineJoin(args[0]);
  20448. break;
  20449. case OPS.setLineCap:
  20450. this.setLineCap(args[0]);
  20451. break;
  20452. case OPS.setMiterLimit:
  20453. this.setMiterLimit(args[0]);
  20454. break;
  20455. case OPS.setFillRGBColor:
  20456. this.setFillRGBColor(args[0], args[1], args[2]);
  20457. break;
  20458. case OPS.setStrokeRGBColor:
  20459. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20460. break;
  20461. case OPS.setDash:
  20462. this.setDash(args[0], args[1]);
  20463. break;
  20464. case OPS.setGState:
  20465. this.setGState(args[0]);
  20466. break;
  20467. case OPS.fill:
  20468. this.fill();
  20469. break;
  20470. case OPS.eoFill:
  20471. this.eoFill();
  20472. break;
  20473. case OPS.stroke:
  20474. this.stroke();
  20475. break;
  20476. case OPS.fillStroke:
  20477. this.fillStroke();
  20478. break;
  20479. case OPS.eoFillStroke:
  20480. this.eoFillStroke();
  20481. break;
  20482. case OPS.clip:
  20483. this.clip('nonzero');
  20484. break;
  20485. case OPS.eoClip:
  20486. this.clip('evenodd');
  20487. break;
  20488. case OPS.paintSolidColorImageMask:
  20489. this.paintSolidColorImageMask();
  20490. break;
  20491. case OPS.paintJpegXObject:
  20492. this.paintJpegXObject(args[0], args[1], args[2]);
  20493. break;
  20494. case OPS.paintImageXObject:
  20495. this.paintImageXObject(args[0]);
  20496. break;
  20497. case OPS.paintInlineImageXObject:
  20498. this.paintInlineImageXObject(args[0]);
  20499. break;
  20500. case OPS.paintImageMaskXObject:
  20501. this.paintImageMaskXObject(args[0]);
  20502. break;
  20503. case OPS.paintFormXObjectBegin:
  20504. this.paintFormXObjectBegin(args[0], args[1]);
  20505. break;
  20506. case OPS.paintFormXObjectEnd:
  20507. this.paintFormXObjectEnd();
  20508. break;
  20509. case OPS.closePath:
  20510. this.closePath();
  20511. break;
  20512. case OPS.closeStroke:
  20513. this.closeStroke();
  20514. break;
  20515. case OPS.closeFillStroke:
  20516. this.closeFillStroke();
  20517. break;
  20518. case OPS.nextLine:
  20519. this.nextLine();
  20520. break;
  20521. case OPS.transform:
  20522. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20523. break;
  20524. case OPS.constructPath:
  20525. this.constructPath(args[0], args[1]);
  20526. break;
  20527. case OPS.endPath:
  20528. this.endPath();
  20529. break;
  20530. case 92:
  20531. this.group(opTree[x].items);
  20532. break;
  20533. default:
  20534. warn('Unimplemented operator ' + fn);
  20535. break;
  20536. }
  20537. }
  20538. },
  20539. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  20540. this.current.wordSpacing = wordSpacing;
  20541. },
  20542. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  20543. this.current.charSpacing = charSpacing;
  20544. },
  20545. nextLine: function SVGGraphics_nextLine() {
  20546. this.moveText(0, this.current.leading);
  20547. },
  20548. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  20549. var current = this.current;
  20550. this.current.textMatrix = this.current.lineMatrix = [
  20551. a,
  20552. b,
  20553. c,
  20554. d,
  20555. e,
  20556. f
  20557. ];
  20558. this.current.x = this.current.lineX = 0;
  20559. this.current.y = this.current.lineY = 0;
  20560. current.xcoords = [];
  20561. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20562. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20563. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20564. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20565. current.txtElement = document.createElementNS(NS, 'svg:text');
  20566. current.txtElement.appendChild(current.tspan);
  20567. },
  20568. beginText: function SVGGraphics_beginText() {
  20569. this.current.x = this.current.lineX = 0;
  20570. this.current.y = this.current.lineY = 0;
  20571. this.current.textMatrix = IDENTITY_MATRIX;
  20572. this.current.lineMatrix = IDENTITY_MATRIX;
  20573. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20574. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  20575. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  20576. this.current.xcoords = [];
  20577. },
  20578. moveText: function SVGGraphics_moveText(x, y) {
  20579. var current = this.current;
  20580. this.current.x = this.current.lineX += x;
  20581. this.current.y = this.current.lineY += y;
  20582. current.xcoords = [];
  20583. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20584. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20585. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20586. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20587. },
  20588. showText: function SVGGraphics_showText(glyphs) {
  20589. var current = this.current;
  20590. var font = current.font;
  20591. var fontSize = current.fontSize;
  20592. if (fontSize === 0) {
  20593. return;
  20594. }
  20595. var charSpacing = current.charSpacing;
  20596. var wordSpacing = current.wordSpacing;
  20597. var fontDirection = current.fontDirection;
  20598. var textHScale = current.textHScale * fontDirection;
  20599. var glyphsLength = glyphs.length;
  20600. var vertical = font.vertical;
  20601. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20602. var x = 0, i;
  20603. for (i = 0; i < glyphsLength; ++i) {
  20604. var glyph = glyphs[i];
  20605. if (glyph === null) {
  20606. x += fontDirection * wordSpacing;
  20607. continue;
  20608. } else if (isNum(glyph)) {
  20609. x += -glyph * fontSize * 0.001;
  20610. continue;
  20611. }
  20612. current.xcoords.push(current.x + x * textHScale);
  20613. var width = glyph.width;
  20614. var character = glyph.fontChar;
  20615. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  20616. x += charWidth;
  20617. current.tspan.textContent += character;
  20618. }
  20619. if (vertical) {
  20620. current.y -= x * textHScale;
  20621. } else {
  20622. current.x += x * textHScale;
  20623. }
  20624. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  20625. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20626. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20627. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20628. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20629. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  20630. }
  20631. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20632. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  20633. }
  20634. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20635. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  20636. }
  20637. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  20638. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  20639. current.txtElement.appendChild(current.tspan);
  20640. current.txtgrp.appendChild(current.txtElement);
  20641. this._ensureTransformGroup().appendChild(current.txtElement);
  20642. },
  20643. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  20644. this.setLeading(-y);
  20645. this.moveText(x, y);
  20646. },
  20647. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  20648. if (!this.cssStyle) {
  20649. this.cssStyle = document.createElementNS(NS, 'svg:style');
  20650. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  20651. this.defs.appendChild(this.cssStyle);
  20652. }
  20653. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20654. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  20655. },
  20656. setFont: function SVGGraphics_setFont(details) {
  20657. var current = this.current;
  20658. var fontObj = this.commonObjs.get(details[0]);
  20659. var size = details[1];
  20660. this.current.font = fontObj;
  20661. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  20662. this.addFontStyle(fontObj);
  20663. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20664. }
  20665. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  20666. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  20667. var italic = fontObj.italic ? 'italic' : 'normal';
  20668. if (size < 0) {
  20669. size = -size;
  20670. current.fontDirection = -1;
  20671. } else {
  20672. current.fontDirection = 1;
  20673. }
  20674. current.fontSize = size;
  20675. current.fontFamily = fontObj.loadedName;
  20676. current.fontWeight = bold;
  20677. current.fontStyle = italic;
  20678. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20679. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20680. current.xcoords = [];
  20681. },
  20682. endText: function SVGGraphics_endText() {
  20683. },
  20684. setLineWidth: function SVGGraphics_setLineWidth(width) {
  20685. this.current.lineWidth = width;
  20686. },
  20687. setLineCap: function SVGGraphics_setLineCap(style) {
  20688. this.current.lineCap = LINE_CAP_STYLES[style];
  20689. },
  20690. setLineJoin: function SVGGraphics_setLineJoin(style) {
  20691. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20692. },
  20693. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  20694. this.current.miterLimit = limit;
  20695. },
  20696. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  20697. var color = Util.makeCssRgb(r, g, b);
  20698. this.current.strokeColor = color;
  20699. },
  20700. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  20701. var color = Util.makeCssRgb(r, g, b);
  20702. this.current.fillColor = color;
  20703. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20704. this.current.xcoords = [];
  20705. },
  20706. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  20707. this.current.dashArray = dashArray;
  20708. this.current.dashPhase = dashPhase;
  20709. },
  20710. constructPath: function SVGGraphics_constructPath(ops, args) {
  20711. var current = this.current;
  20712. var x = current.x, y = current.y;
  20713. current.path = document.createElementNS(NS, 'svg:path');
  20714. var d = [];
  20715. var opLength = ops.length;
  20716. for (var i = 0, j = 0; i < opLength; i++) {
  20717. switch (ops[i] | 0) {
  20718. case OPS.rectangle:
  20719. x = args[j++];
  20720. y = args[j++];
  20721. var width = args[j++];
  20722. var height = args[j++];
  20723. var xw = x + width;
  20724. var yh = y + height;
  20725. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  20726. break;
  20727. case OPS.moveTo:
  20728. x = args[j++];
  20729. y = args[j++];
  20730. d.push('M', pf(x), pf(y));
  20731. break;
  20732. case OPS.lineTo:
  20733. x = args[j++];
  20734. y = args[j++];
  20735. d.push('L', pf(x), pf(y));
  20736. break;
  20737. case OPS.curveTo:
  20738. x = args[j + 4];
  20739. y = args[j + 5];
  20740. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  20741. j += 6;
  20742. break;
  20743. case OPS.curveTo2:
  20744. x = args[j + 2];
  20745. y = args[j + 3];
  20746. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  20747. j += 4;
  20748. break;
  20749. case OPS.curveTo3:
  20750. x = args[j + 2];
  20751. y = args[j + 3];
  20752. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  20753. j += 4;
  20754. break;
  20755. case OPS.closePath:
  20756. d.push('Z');
  20757. break;
  20758. }
  20759. }
  20760. current.path.setAttributeNS(null, 'd', d.join(' '));
  20761. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  20762. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  20763. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  20764. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  20765. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  20766. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  20767. current.path.setAttributeNS(null, 'fill', 'none');
  20768. this._ensureTransformGroup().appendChild(current.path);
  20769. current.element = current.path;
  20770. current.setCurrentPoint(x, y);
  20771. },
  20772. endPath: function SVGGraphics_endPath() {
  20773. },
  20774. clip: function SVGGraphics_clip(type) {
  20775. var current = this.current;
  20776. var clipId = 'clippath' + clipCount;
  20777. clipCount++;
  20778. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  20779. clipPath.setAttributeNS(null, 'id', clipId);
  20780. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20781. var clipElement = current.element.cloneNode();
  20782. if (type === 'evenodd') {
  20783. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  20784. } else {
  20785. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  20786. }
  20787. clipPath.appendChild(clipElement);
  20788. this.defs.appendChild(clipPath);
  20789. if (current.activeClipUrl) {
  20790. current.clipGroup = null;
  20791. this.extraStack.forEach(function (prev) {
  20792. prev.clipGroup = null;
  20793. });
  20794. }
  20795. current.activeClipUrl = 'url(#' + clipId + ')';
  20796. this.tgrp = null;
  20797. },
  20798. closePath: function SVGGraphics_closePath() {
  20799. var current = this.current;
  20800. var d = current.path.getAttributeNS(null, 'd');
  20801. d += 'Z';
  20802. current.path.setAttributeNS(null, 'd', d);
  20803. },
  20804. setLeading: function SVGGraphics_setLeading(leading) {
  20805. this.current.leading = -leading;
  20806. },
  20807. setTextRise: function SVGGraphics_setTextRise(textRise) {
  20808. this.current.textRise = textRise;
  20809. },
  20810. setHScale: function SVGGraphics_setHScale(scale) {
  20811. this.current.textHScale = scale / 100;
  20812. },
  20813. setGState: function SVGGraphics_setGState(states) {
  20814. for (var i = 0, ii = states.length; i < ii; i++) {
  20815. var state = states[i];
  20816. var key = state[0];
  20817. var value = state[1];
  20818. switch (key) {
  20819. case 'LW':
  20820. this.setLineWidth(value);
  20821. break;
  20822. case 'LC':
  20823. this.setLineCap(value);
  20824. break;
  20825. case 'LJ':
  20826. this.setLineJoin(value);
  20827. break;
  20828. case 'ML':
  20829. this.setMiterLimit(value);
  20830. break;
  20831. case 'D':
  20832. this.setDash(value[0], value[1]);
  20833. break;
  20834. case 'Font':
  20835. this.setFont(value);
  20836. break;
  20837. default:
  20838. warn('Unimplemented graphic state ' + key);
  20839. break;
  20840. }
  20841. }
  20842. },
  20843. fill: function SVGGraphics_fill() {
  20844. var current = this.current;
  20845. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20846. },
  20847. stroke: function SVGGraphics_stroke() {
  20848. var current = this.current;
  20849. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  20850. current.element.setAttributeNS(null, 'fill', 'none');
  20851. },
  20852. eoFill: function SVGGraphics_eoFill() {
  20853. var current = this.current;
  20854. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20855. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20856. },
  20857. fillStroke: function SVGGraphics_fillStroke() {
  20858. this.stroke();
  20859. this.fill();
  20860. },
  20861. eoFillStroke: function SVGGraphics_eoFillStroke() {
  20862. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20863. this.fillStroke();
  20864. },
  20865. closeStroke: function SVGGraphics_closeStroke() {
  20866. this.closePath();
  20867. this.stroke();
  20868. },
  20869. closeFillStroke: function SVGGraphics_closeFillStroke() {
  20870. this.closePath();
  20871. this.fillStroke();
  20872. },
  20873. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  20874. var current = this.current;
  20875. var rect = document.createElementNS(NS, 'svg:rect');
  20876. rect.setAttributeNS(null, 'x', '0');
  20877. rect.setAttributeNS(null, 'y', '0');
  20878. rect.setAttributeNS(null, 'width', '1px');
  20879. rect.setAttributeNS(null, 'height', '1px');
  20880. rect.setAttributeNS(null, 'fill', current.fillColor);
  20881. this._ensureTransformGroup().appendChild(rect);
  20882. },
  20883. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  20884. var imgObj = this.objs.get(objId);
  20885. var imgEl = document.createElementNS(NS, 'svg:image');
  20886. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  20887. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  20888. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  20889. imgEl.setAttributeNS(null, 'x', '0');
  20890. imgEl.setAttributeNS(null, 'y', pf(-h));
  20891. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  20892. this._ensureTransformGroup().appendChild(imgEl);
  20893. },
  20894. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  20895. var imgData = this.objs.get(objId);
  20896. if (!imgData) {
  20897. warn('Dependent image isn\'t ready yet');
  20898. return;
  20899. }
  20900. this.paintInlineImageXObject(imgData);
  20901. },
  20902. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  20903. var width = imgData.width;
  20904. var height = imgData.height;
  20905. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  20906. var cliprect = document.createElementNS(NS, 'svg:rect');
  20907. cliprect.setAttributeNS(null, 'x', '0');
  20908. cliprect.setAttributeNS(null, 'y', '0');
  20909. cliprect.setAttributeNS(null, 'width', pf(width));
  20910. cliprect.setAttributeNS(null, 'height', pf(height));
  20911. this.current.element = cliprect;
  20912. this.clip('nonzero');
  20913. var imgEl = document.createElementNS(NS, 'svg:image');
  20914. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  20915. imgEl.setAttributeNS(null, 'x', '0');
  20916. imgEl.setAttributeNS(null, 'y', pf(-height));
  20917. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  20918. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  20919. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  20920. if (mask) {
  20921. mask.appendChild(imgEl);
  20922. } else {
  20923. this._ensureTransformGroup().appendChild(imgEl);
  20924. }
  20925. },
  20926. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  20927. var current = this.current;
  20928. var width = imgData.width;
  20929. var height = imgData.height;
  20930. var fillColor = current.fillColor;
  20931. current.maskId = 'mask' + maskCount++;
  20932. var mask = document.createElementNS(NS, 'svg:mask');
  20933. mask.setAttributeNS(null, 'id', current.maskId);
  20934. var rect = document.createElementNS(NS, 'svg:rect');
  20935. rect.setAttributeNS(null, 'x', '0');
  20936. rect.setAttributeNS(null, 'y', '0');
  20937. rect.setAttributeNS(null, 'width', pf(width));
  20938. rect.setAttributeNS(null, 'height', pf(height));
  20939. rect.setAttributeNS(null, 'fill', fillColor);
  20940. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  20941. this.defs.appendChild(mask);
  20942. this._ensureTransformGroup().appendChild(rect);
  20943. this.paintInlineImageXObject(imgData, mask);
  20944. },
  20945. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  20946. if (isArray(matrix) && matrix.length === 6) {
  20947. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  20948. }
  20949. if (isArray(bbox) && bbox.length === 4) {
  20950. var width = bbox[2] - bbox[0];
  20951. var height = bbox[3] - bbox[1];
  20952. var cliprect = document.createElementNS(NS, 'svg:rect');
  20953. cliprect.setAttributeNS(null, 'x', bbox[0]);
  20954. cliprect.setAttributeNS(null, 'y', bbox[1]);
  20955. cliprect.setAttributeNS(null, 'width', pf(width));
  20956. cliprect.setAttributeNS(null, 'height', pf(height));
  20957. this.current.element = cliprect;
  20958. this.clip('nonzero');
  20959. this.endPath();
  20960. }
  20961. },
  20962. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  20963. },
  20964. _initialize: function SVGGraphics_initialize(viewport) {
  20965. var svg = document.createElementNS(NS, 'svg:svg');
  20966. svg.setAttributeNS(null, 'version', '1.1');
  20967. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  20968. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  20969. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  20970. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  20971. var definitions = document.createElementNS(NS, 'svg:defs');
  20972. svg.appendChild(definitions);
  20973. this.defs = definitions;
  20974. var rootGroup = document.createElementNS(NS, 'svg:g');
  20975. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  20976. svg.appendChild(rootGroup);
  20977. this.svg = rootGroup;
  20978. return svg;
  20979. },
  20980. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  20981. if (!this.current.clipGroup) {
  20982. var clipGroup = document.createElementNS(NS, 'svg:g');
  20983. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  20984. this.svg.appendChild(clipGroup);
  20985. this.current.clipGroup = clipGroup;
  20986. }
  20987. return this.current.clipGroup;
  20988. },
  20989. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  20990. if (!this.tgrp) {
  20991. this.tgrp = document.createElementNS(NS, 'svg:g');
  20992. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20993. if (this.current.activeClipUrl) {
  20994. this._ensureClipGroup().appendChild(this.tgrp);
  20995. } else {
  20996. this.svg.appendChild(this.tgrp);
  20997. }
  20998. }
  20999. return this.tgrp;
  21000. }
  21001. };
  21002. return SVGGraphics;
  21003. }();
  21004. exports.SVGGraphics = SVGGraphics;
  21005. /***/ }),
  21006. /* 12 */
  21007. /***/ (function(module, exports, __w_pdfjs_require__) {
  21008. "use strict";
  21009. var sharedUtil = __w_pdfjs_require__(0);
  21010. var displayDOMUtils = __w_pdfjs_require__(3);
  21011. var Util = sharedUtil.Util;
  21012. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21013. var CustomStyle = displayDOMUtils.CustomStyle;
  21014. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21015. var renderTextLayer = function renderTextLayerClosure() {
  21016. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21017. var NonWhitespaceRegexp = /\S/;
  21018. function isAllWhitespace(str) {
  21019. return !NonWhitespaceRegexp.test(str);
  21020. }
  21021. var styleBuf = [
  21022. 'left: ',
  21023. 0,
  21024. 'px; top: ',
  21025. 0,
  21026. 'px; font-size: ',
  21027. 0,
  21028. 'px; font-family: ',
  21029. '',
  21030. ';'
  21031. ];
  21032. function appendText(task, geom, styles) {
  21033. var textDiv = document.createElement('div');
  21034. var textDivProperties = {
  21035. style: null,
  21036. angle: 0,
  21037. canvasWidth: 0,
  21038. isWhitespace: false,
  21039. originalTransform: null,
  21040. paddingBottom: 0,
  21041. paddingLeft: 0,
  21042. paddingRight: 0,
  21043. paddingTop: 0,
  21044. scale: 1
  21045. };
  21046. task._textDivs.push(textDiv);
  21047. if (isAllWhitespace(geom.str)) {
  21048. textDivProperties.isWhitespace = true;
  21049. task._textDivProperties.set(textDiv, textDivProperties);
  21050. return;
  21051. }
  21052. var tx = Util.transform(task._viewport.transform, geom.transform);
  21053. var angle = Math.atan2(tx[1], tx[0]);
  21054. var style = styles[geom.fontName];
  21055. if (style.vertical) {
  21056. angle += Math.PI / 2;
  21057. }
  21058. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21059. var fontAscent = fontHeight;
  21060. if (style.ascent) {
  21061. fontAscent = style.ascent * fontAscent;
  21062. } else if (style.descent) {
  21063. fontAscent = (1 + style.descent) * fontAscent;
  21064. }
  21065. var left;
  21066. var top;
  21067. if (angle === 0) {
  21068. left = tx[4];
  21069. top = tx[5] - fontAscent;
  21070. } else {
  21071. left = tx[4] + fontAscent * Math.sin(angle);
  21072. top = tx[5] - fontAscent * Math.cos(angle);
  21073. }
  21074. styleBuf[1] = left;
  21075. styleBuf[3] = top;
  21076. styleBuf[5] = fontHeight;
  21077. styleBuf[7] = style.fontFamily;
  21078. textDivProperties.style = styleBuf.join('');
  21079. textDiv.setAttribute('style', textDivProperties.style);
  21080. textDiv.textContent = geom.str;
  21081. if (getDefaultSetting('pdfBug')) {
  21082. textDiv.dataset.fontName = geom.fontName;
  21083. }
  21084. if (angle !== 0) {
  21085. textDivProperties.angle = angle * (180 / Math.PI);
  21086. }
  21087. if (geom.str.length > 1) {
  21088. if (style.vertical) {
  21089. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21090. } else {
  21091. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21092. }
  21093. }
  21094. task._textDivProperties.set(textDiv, textDivProperties);
  21095. if (task._enhanceTextSelection) {
  21096. var angleCos = 1, angleSin = 0;
  21097. if (angle !== 0) {
  21098. angleCos = Math.cos(angle);
  21099. angleSin = Math.sin(angle);
  21100. }
  21101. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21102. var divHeight = fontHeight;
  21103. var m, b;
  21104. if (angle !== 0) {
  21105. m = [
  21106. angleCos,
  21107. angleSin,
  21108. -angleSin,
  21109. angleCos,
  21110. left,
  21111. top
  21112. ];
  21113. b = Util.getAxialAlignedBoundingBox([
  21114. 0,
  21115. 0,
  21116. divWidth,
  21117. divHeight
  21118. ], m);
  21119. } else {
  21120. b = [
  21121. left,
  21122. top,
  21123. left + divWidth,
  21124. top + divHeight
  21125. ];
  21126. }
  21127. task._bounds.push({
  21128. left: b[0],
  21129. top: b[1],
  21130. right: b[2],
  21131. bottom: b[3],
  21132. div: textDiv,
  21133. size: [
  21134. divWidth,
  21135. divHeight
  21136. ],
  21137. m: m
  21138. });
  21139. }
  21140. }
  21141. function render(task) {
  21142. if (task._canceled) {
  21143. return;
  21144. }
  21145. var textLayerFrag = task._container;
  21146. var textDivs = task._textDivs;
  21147. var capability = task._capability;
  21148. var textDivsLength = textDivs.length;
  21149. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21150. task._renderingDone = true;
  21151. capability.resolve();
  21152. return;
  21153. }
  21154. var canvas = document.createElement('canvas');
  21155. var ctx = canvas.getContext('2d', { alpha: false });
  21156. var lastFontSize;
  21157. var lastFontFamily;
  21158. for (var i = 0; i < textDivsLength; i++) {
  21159. var textDiv = textDivs[i];
  21160. var textDivProperties = task._textDivProperties.get(textDiv);
  21161. if (textDivProperties.isWhitespace) {
  21162. continue;
  21163. }
  21164. var fontSize = textDiv.style.fontSize;
  21165. var fontFamily = textDiv.style.fontFamily;
  21166. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21167. ctx.font = fontSize + ' ' + fontFamily;
  21168. lastFontSize = fontSize;
  21169. lastFontFamily = fontFamily;
  21170. }
  21171. var width = ctx.measureText(textDiv.textContent).width;
  21172. textLayerFrag.appendChild(textDiv);
  21173. var transform = '';
  21174. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21175. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21176. transform = 'scaleX(' + textDivProperties.scale + ')';
  21177. }
  21178. if (textDivProperties.angle !== 0) {
  21179. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21180. }
  21181. if (transform !== '') {
  21182. textDivProperties.originalTransform = transform;
  21183. CustomStyle.setProp('transform', textDiv, transform);
  21184. }
  21185. task._textDivProperties.set(textDiv, textDivProperties);
  21186. }
  21187. task._renderingDone = true;
  21188. capability.resolve();
  21189. }
  21190. function expand(task) {
  21191. var bounds = task._bounds;
  21192. var viewport = task._viewport;
  21193. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21194. for (var i = 0; i < expanded.length; i++) {
  21195. var div = bounds[i].div;
  21196. var divProperties = task._textDivProperties.get(div);
  21197. if (divProperties.angle === 0) {
  21198. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21199. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21200. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21201. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21202. task._textDivProperties.set(div, divProperties);
  21203. continue;
  21204. }
  21205. var e = expanded[i], b = bounds[i];
  21206. var m = b.m, c = m[0], s = m[1];
  21207. var points = [
  21208. [
  21209. 0,
  21210. 0
  21211. ],
  21212. [
  21213. 0,
  21214. b.size[1]
  21215. ],
  21216. [
  21217. b.size[0],
  21218. 0
  21219. ],
  21220. b.size
  21221. ];
  21222. var ts = new Float64Array(64);
  21223. points.forEach(function (p, i) {
  21224. var t = Util.applyTransform(p, m);
  21225. ts[i + 0] = c && (e.left - t[0]) / c;
  21226. ts[i + 4] = s && (e.top - t[1]) / s;
  21227. ts[i + 8] = c && (e.right - t[0]) / c;
  21228. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21229. ts[i + 16] = s && (e.left - t[0]) / -s;
  21230. ts[i + 20] = c && (e.top - t[1]) / c;
  21231. ts[i + 24] = s && (e.right - t[0]) / -s;
  21232. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21233. ts[i + 32] = c && (e.left - t[0]) / -c;
  21234. ts[i + 36] = s && (e.top - t[1]) / -s;
  21235. ts[i + 40] = c && (e.right - t[0]) / -c;
  21236. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21237. ts[i + 48] = s && (e.left - t[0]) / s;
  21238. ts[i + 52] = c && (e.top - t[1]) / -c;
  21239. ts[i + 56] = s && (e.right - t[0]) / s;
  21240. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21241. });
  21242. var findPositiveMin = function (ts, offset, count) {
  21243. var result = 0;
  21244. for (var i = 0; i < count; i++) {
  21245. var t = ts[offset++];
  21246. if (t > 0) {
  21247. result = result ? Math.min(t, result) : t;
  21248. }
  21249. }
  21250. return result;
  21251. };
  21252. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21253. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21254. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21255. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21256. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21257. task._textDivProperties.set(div, divProperties);
  21258. }
  21259. }
  21260. function expandBounds(width, height, boxes) {
  21261. var bounds = boxes.map(function (box, i) {
  21262. return {
  21263. x1: box.left,
  21264. y1: box.top,
  21265. x2: box.right,
  21266. y2: box.bottom,
  21267. index: i,
  21268. x1New: undefined,
  21269. x2New: undefined
  21270. };
  21271. });
  21272. expandBoundsLTR(width, bounds);
  21273. var expanded = new Array(boxes.length);
  21274. bounds.forEach(function (b) {
  21275. var i = b.index;
  21276. expanded[i] = {
  21277. left: b.x1New,
  21278. top: 0,
  21279. right: b.x2New,
  21280. bottom: 0
  21281. };
  21282. });
  21283. boxes.map(function (box, i) {
  21284. var e = expanded[i], b = bounds[i];
  21285. b.x1 = box.top;
  21286. b.y1 = width - e.right;
  21287. b.x2 = box.bottom;
  21288. b.y2 = width - e.left;
  21289. b.index = i;
  21290. b.x1New = undefined;
  21291. b.x2New = undefined;
  21292. });
  21293. expandBoundsLTR(height, bounds);
  21294. bounds.forEach(function (b) {
  21295. var i = b.index;
  21296. expanded[i].top = b.x1New;
  21297. expanded[i].bottom = b.x2New;
  21298. });
  21299. return expanded;
  21300. }
  21301. function expandBoundsLTR(width, bounds) {
  21302. bounds.sort(function (a, b) {
  21303. return a.x1 - b.x1 || a.index - b.index;
  21304. });
  21305. var fakeBoundary = {
  21306. x1: -Infinity,
  21307. y1: -Infinity,
  21308. x2: 0,
  21309. y2: Infinity,
  21310. index: -1,
  21311. x1New: 0,
  21312. x2New: 0
  21313. };
  21314. var horizon = [{
  21315. start: -Infinity,
  21316. end: Infinity,
  21317. boundary: fakeBoundary
  21318. }];
  21319. bounds.forEach(function (boundary) {
  21320. var i = 0;
  21321. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  21322. i++;
  21323. }
  21324. var j = horizon.length - 1;
  21325. while (j >= 0 && horizon[j].start >= boundary.y2) {
  21326. j--;
  21327. }
  21328. var horizonPart, affectedBoundary;
  21329. var q, k, maxXNew = -Infinity;
  21330. for (q = i; q <= j; q++) {
  21331. horizonPart = horizon[q];
  21332. affectedBoundary = horizonPart.boundary;
  21333. var xNew;
  21334. if (affectedBoundary.x2 > boundary.x1) {
  21335. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  21336. } else if (affectedBoundary.x2New === undefined) {
  21337. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  21338. } else {
  21339. xNew = affectedBoundary.x2New;
  21340. }
  21341. if (xNew > maxXNew) {
  21342. maxXNew = xNew;
  21343. }
  21344. }
  21345. boundary.x1New = maxXNew;
  21346. for (q = i; q <= j; q++) {
  21347. horizonPart = horizon[q];
  21348. affectedBoundary = horizonPart.boundary;
  21349. if (affectedBoundary.x2New === undefined) {
  21350. if (affectedBoundary.x2 > boundary.x1) {
  21351. if (affectedBoundary.index > boundary.index) {
  21352. affectedBoundary.x2New = affectedBoundary.x2;
  21353. }
  21354. } else {
  21355. affectedBoundary.x2New = maxXNew;
  21356. }
  21357. } else if (affectedBoundary.x2New > maxXNew) {
  21358. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  21359. }
  21360. }
  21361. var changedHorizon = [], lastBoundary = null;
  21362. for (q = i; q <= j; q++) {
  21363. horizonPart = horizon[q];
  21364. affectedBoundary = horizonPart.boundary;
  21365. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  21366. if (lastBoundary === useBoundary) {
  21367. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  21368. } else {
  21369. changedHorizon.push({
  21370. start: horizonPart.start,
  21371. end: horizonPart.end,
  21372. boundary: useBoundary
  21373. });
  21374. lastBoundary = useBoundary;
  21375. }
  21376. }
  21377. if (horizon[i].start < boundary.y1) {
  21378. changedHorizon[0].start = boundary.y1;
  21379. changedHorizon.unshift({
  21380. start: horizon[i].start,
  21381. end: boundary.y1,
  21382. boundary: horizon[i].boundary
  21383. });
  21384. }
  21385. if (boundary.y2 < horizon[j].end) {
  21386. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  21387. changedHorizon.push({
  21388. start: boundary.y2,
  21389. end: horizon[j].end,
  21390. boundary: horizon[j].boundary
  21391. });
  21392. }
  21393. for (q = i; q <= j; q++) {
  21394. horizonPart = horizon[q];
  21395. affectedBoundary = horizonPart.boundary;
  21396. if (affectedBoundary.x2New !== undefined) {
  21397. continue;
  21398. }
  21399. var used = false;
  21400. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  21401. used = horizon[k].boundary === affectedBoundary;
  21402. }
  21403. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  21404. used = horizon[k].boundary === affectedBoundary;
  21405. }
  21406. for (k = 0; !used && k < changedHorizon.length; k++) {
  21407. used = changedHorizon[k].boundary === affectedBoundary;
  21408. }
  21409. if (!used) {
  21410. affectedBoundary.x2New = maxXNew;
  21411. }
  21412. }
  21413. Array.prototype.splice.apply(horizon, [
  21414. i,
  21415. j - i + 1
  21416. ].concat(changedHorizon));
  21417. });
  21418. horizon.forEach(function (horizonPart) {
  21419. var affectedBoundary = horizonPart.boundary;
  21420. if (affectedBoundary.x2New === undefined) {
  21421. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  21422. }
  21423. });
  21424. }
  21425. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  21426. this._textContent = textContent;
  21427. this._container = container;
  21428. this._viewport = viewport;
  21429. this._textDivs = textDivs || [];
  21430. this._textDivProperties = new WeakMap();
  21431. this._renderingDone = false;
  21432. this._canceled = false;
  21433. this._capability = createPromiseCapability();
  21434. this._renderTimer = null;
  21435. this._bounds = [];
  21436. this._enhanceTextSelection = !!enhanceTextSelection;
  21437. }
  21438. TextLayerRenderTask.prototype = {
  21439. get promise() {
  21440. return this._capability.promise;
  21441. },
  21442. cancel: function TextLayer_cancel() {
  21443. this._canceled = true;
  21444. if (this._renderTimer !== null) {
  21445. clearTimeout(this._renderTimer);
  21446. this._renderTimer = null;
  21447. }
  21448. this._capability.reject('canceled');
  21449. },
  21450. _render: function TextLayer_render(timeout) {
  21451. var textItems = this._textContent.items;
  21452. var textStyles = this._textContent.styles;
  21453. for (var i = 0, len = textItems.length; i < len; i++) {
  21454. appendText(this, textItems[i], textStyles);
  21455. }
  21456. if (!timeout) {
  21457. render(this);
  21458. } else {
  21459. var self = this;
  21460. this._renderTimer = setTimeout(function () {
  21461. render(self);
  21462. self._renderTimer = null;
  21463. }, timeout);
  21464. }
  21465. },
  21466. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  21467. if (!this._enhanceTextSelection || !this._renderingDone) {
  21468. return;
  21469. }
  21470. if (this._bounds !== null) {
  21471. expand(this);
  21472. this._bounds = null;
  21473. }
  21474. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  21475. var div = this._textDivs[i];
  21476. var divProperties = this._textDivProperties.get(div);
  21477. if (divProperties.isWhitespace) {
  21478. continue;
  21479. }
  21480. if (expandDivs) {
  21481. var transform = '', padding = '';
  21482. if (divProperties.scale !== 1) {
  21483. transform = 'scaleX(' + divProperties.scale + ')';
  21484. }
  21485. if (divProperties.angle !== 0) {
  21486. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  21487. }
  21488. if (divProperties.paddingLeft !== 0) {
  21489. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  21490. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  21491. }
  21492. if (divProperties.paddingTop !== 0) {
  21493. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  21494. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  21495. }
  21496. if (divProperties.paddingRight !== 0) {
  21497. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  21498. }
  21499. if (divProperties.paddingBottom !== 0) {
  21500. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  21501. }
  21502. if (padding !== '') {
  21503. div.setAttribute('style', divProperties.style + padding);
  21504. }
  21505. if (transform !== '') {
  21506. CustomStyle.setProp('transform', div, transform);
  21507. }
  21508. } else {
  21509. div.style.padding = 0;
  21510. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  21511. }
  21512. }
  21513. }
  21514. };
  21515. function renderTextLayer(renderParameters) {
  21516. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  21517. task._render(renderParameters.timeout);
  21518. return task;
  21519. }
  21520. return renderTextLayer;
  21521. }();
  21522. exports.renderTextLayer = renderTextLayer;
  21523. /***/ }),
  21524. /* 13 */
  21525. /***/ (function(module, exports) {
  21526. var g;
  21527. g = function () {
  21528. return this;
  21529. }();
  21530. try {
  21531. g = g || Function("return this")() || (1, eval)("this");
  21532. } catch (e) {
  21533. if (typeof window === "object")
  21534. g = window;
  21535. }
  21536. module.exports = g;
  21537. /***/ }),
  21538. /* 14 */
  21539. /***/ (function(module, exports, __w_pdfjs_require__) {
  21540. "use strict";
  21541. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  21542. var QeTable = [
  21543. {
  21544. qe: 0x5601,
  21545. nmps: 1,
  21546. nlps: 1,
  21547. switchFlag: 1
  21548. },
  21549. {
  21550. qe: 0x3401,
  21551. nmps: 2,
  21552. nlps: 6,
  21553. switchFlag: 0
  21554. },
  21555. {
  21556. qe: 0x1801,
  21557. nmps: 3,
  21558. nlps: 9,
  21559. switchFlag: 0
  21560. },
  21561. {
  21562. qe: 0x0AC1,
  21563. nmps: 4,
  21564. nlps: 12,
  21565. switchFlag: 0
  21566. },
  21567. {
  21568. qe: 0x0521,
  21569. nmps: 5,
  21570. nlps: 29,
  21571. switchFlag: 0
  21572. },
  21573. {
  21574. qe: 0x0221,
  21575. nmps: 38,
  21576. nlps: 33,
  21577. switchFlag: 0
  21578. },
  21579. {
  21580. qe: 0x5601,
  21581. nmps: 7,
  21582. nlps: 6,
  21583. switchFlag: 1
  21584. },
  21585. {
  21586. qe: 0x5401,
  21587. nmps: 8,
  21588. nlps: 14,
  21589. switchFlag: 0
  21590. },
  21591. {
  21592. qe: 0x4801,
  21593. nmps: 9,
  21594. nlps: 14,
  21595. switchFlag: 0
  21596. },
  21597. {
  21598. qe: 0x3801,
  21599. nmps: 10,
  21600. nlps: 14,
  21601. switchFlag: 0
  21602. },
  21603. {
  21604. qe: 0x3001,
  21605. nmps: 11,
  21606. nlps: 17,
  21607. switchFlag: 0
  21608. },
  21609. {
  21610. qe: 0x2401,
  21611. nmps: 12,
  21612. nlps: 18,
  21613. switchFlag: 0
  21614. },
  21615. {
  21616. qe: 0x1C01,
  21617. nmps: 13,
  21618. nlps: 20,
  21619. switchFlag: 0
  21620. },
  21621. {
  21622. qe: 0x1601,
  21623. nmps: 29,
  21624. nlps: 21,
  21625. switchFlag: 0
  21626. },
  21627. {
  21628. qe: 0x5601,
  21629. nmps: 15,
  21630. nlps: 14,
  21631. switchFlag: 1
  21632. },
  21633. {
  21634. qe: 0x5401,
  21635. nmps: 16,
  21636. nlps: 14,
  21637. switchFlag: 0
  21638. },
  21639. {
  21640. qe: 0x5101,
  21641. nmps: 17,
  21642. nlps: 15,
  21643. switchFlag: 0
  21644. },
  21645. {
  21646. qe: 0x4801,
  21647. nmps: 18,
  21648. nlps: 16,
  21649. switchFlag: 0
  21650. },
  21651. {
  21652. qe: 0x3801,
  21653. nmps: 19,
  21654. nlps: 17,
  21655. switchFlag: 0
  21656. },
  21657. {
  21658. qe: 0x3401,
  21659. nmps: 20,
  21660. nlps: 18,
  21661. switchFlag: 0
  21662. },
  21663. {
  21664. qe: 0x3001,
  21665. nmps: 21,
  21666. nlps: 19,
  21667. switchFlag: 0
  21668. },
  21669. {
  21670. qe: 0x2801,
  21671. nmps: 22,
  21672. nlps: 19,
  21673. switchFlag: 0
  21674. },
  21675. {
  21676. qe: 0x2401,
  21677. nmps: 23,
  21678. nlps: 20,
  21679. switchFlag: 0
  21680. },
  21681. {
  21682. qe: 0x2201,
  21683. nmps: 24,
  21684. nlps: 21,
  21685. switchFlag: 0
  21686. },
  21687. {
  21688. qe: 0x1C01,
  21689. nmps: 25,
  21690. nlps: 22,
  21691. switchFlag: 0
  21692. },
  21693. {
  21694. qe: 0x1801,
  21695. nmps: 26,
  21696. nlps: 23,
  21697. switchFlag: 0
  21698. },
  21699. {
  21700. qe: 0x1601,
  21701. nmps: 27,
  21702. nlps: 24,
  21703. switchFlag: 0
  21704. },
  21705. {
  21706. qe: 0x1401,
  21707. nmps: 28,
  21708. nlps: 25,
  21709. switchFlag: 0
  21710. },
  21711. {
  21712. qe: 0x1201,
  21713. nmps: 29,
  21714. nlps: 26,
  21715. switchFlag: 0
  21716. },
  21717. {
  21718. qe: 0x1101,
  21719. nmps: 30,
  21720. nlps: 27,
  21721. switchFlag: 0
  21722. },
  21723. {
  21724. qe: 0x0AC1,
  21725. nmps: 31,
  21726. nlps: 28,
  21727. switchFlag: 0
  21728. },
  21729. {
  21730. qe: 0x09C1,
  21731. nmps: 32,
  21732. nlps: 29,
  21733. switchFlag: 0
  21734. },
  21735. {
  21736. qe: 0x08A1,
  21737. nmps: 33,
  21738. nlps: 30,
  21739. switchFlag: 0
  21740. },
  21741. {
  21742. qe: 0x0521,
  21743. nmps: 34,
  21744. nlps: 31,
  21745. switchFlag: 0
  21746. },
  21747. {
  21748. qe: 0x0441,
  21749. nmps: 35,
  21750. nlps: 32,
  21751. switchFlag: 0
  21752. },
  21753. {
  21754. qe: 0x02A1,
  21755. nmps: 36,
  21756. nlps: 33,
  21757. switchFlag: 0
  21758. },
  21759. {
  21760. qe: 0x0221,
  21761. nmps: 37,
  21762. nlps: 34,
  21763. switchFlag: 0
  21764. },
  21765. {
  21766. qe: 0x0141,
  21767. nmps: 38,
  21768. nlps: 35,
  21769. switchFlag: 0
  21770. },
  21771. {
  21772. qe: 0x0111,
  21773. nmps: 39,
  21774. nlps: 36,
  21775. switchFlag: 0
  21776. },
  21777. {
  21778. qe: 0x0085,
  21779. nmps: 40,
  21780. nlps: 37,
  21781. switchFlag: 0
  21782. },
  21783. {
  21784. qe: 0x0049,
  21785. nmps: 41,
  21786. nlps: 38,
  21787. switchFlag: 0
  21788. },
  21789. {
  21790. qe: 0x0025,
  21791. nmps: 42,
  21792. nlps: 39,
  21793. switchFlag: 0
  21794. },
  21795. {
  21796. qe: 0x0015,
  21797. nmps: 43,
  21798. nlps: 40,
  21799. switchFlag: 0
  21800. },
  21801. {
  21802. qe: 0x0009,
  21803. nmps: 44,
  21804. nlps: 41,
  21805. switchFlag: 0
  21806. },
  21807. {
  21808. qe: 0x0005,
  21809. nmps: 45,
  21810. nlps: 42,
  21811. switchFlag: 0
  21812. },
  21813. {
  21814. qe: 0x0001,
  21815. nmps: 45,
  21816. nlps: 43,
  21817. switchFlag: 0
  21818. },
  21819. {
  21820. qe: 0x5601,
  21821. nmps: 46,
  21822. nlps: 46,
  21823. switchFlag: 0
  21824. }
  21825. ];
  21826. function ArithmeticDecoder(data, start, end) {
  21827. this.data = data;
  21828. this.bp = start;
  21829. this.dataEnd = end;
  21830. this.chigh = data[start];
  21831. this.clow = 0;
  21832. this.byteIn();
  21833. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  21834. this.clow = this.clow << 7 & 0xFFFF;
  21835. this.ct -= 7;
  21836. this.a = 0x8000;
  21837. }
  21838. ArithmeticDecoder.prototype = {
  21839. byteIn: function ArithmeticDecoder_byteIn() {
  21840. var data = this.data;
  21841. var bp = this.bp;
  21842. if (data[bp] === 0xFF) {
  21843. var b1 = data[bp + 1];
  21844. if (b1 > 0x8F) {
  21845. this.clow += 0xFF00;
  21846. this.ct = 8;
  21847. } else {
  21848. bp++;
  21849. this.clow += data[bp] << 9;
  21850. this.ct = 7;
  21851. this.bp = bp;
  21852. }
  21853. } else {
  21854. bp++;
  21855. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  21856. this.ct = 8;
  21857. this.bp = bp;
  21858. }
  21859. if (this.clow > 0xFFFF) {
  21860. this.chigh += this.clow >> 16;
  21861. this.clow &= 0xFFFF;
  21862. }
  21863. },
  21864. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  21865. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  21866. var qeTableIcx = QeTable[cx_index];
  21867. var qeIcx = qeTableIcx.qe;
  21868. var d;
  21869. var a = this.a - qeIcx;
  21870. if (this.chigh < qeIcx) {
  21871. if (a < qeIcx) {
  21872. a = qeIcx;
  21873. d = cx_mps;
  21874. cx_index = qeTableIcx.nmps;
  21875. } else {
  21876. a = qeIcx;
  21877. d = 1 ^ cx_mps;
  21878. if (qeTableIcx.switchFlag === 1) {
  21879. cx_mps = d;
  21880. }
  21881. cx_index = qeTableIcx.nlps;
  21882. }
  21883. } else {
  21884. this.chigh -= qeIcx;
  21885. if ((a & 0x8000) !== 0) {
  21886. this.a = a;
  21887. return cx_mps;
  21888. }
  21889. if (a < qeIcx) {
  21890. d = 1 ^ cx_mps;
  21891. if (qeTableIcx.switchFlag === 1) {
  21892. cx_mps = d;
  21893. }
  21894. cx_index = qeTableIcx.nlps;
  21895. } else {
  21896. d = cx_mps;
  21897. cx_index = qeTableIcx.nmps;
  21898. }
  21899. }
  21900. do {
  21901. if (this.ct === 0) {
  21902. this.byteIn();
  21903. }
  21904. a <<= 1;
  21905. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  21906. this.clow = this.clow << 1 & 0xFFFF;
  21907. this.ct--;
  21908. } while ((a & 0x8000) === 0);
  21909. this.a = a;
  21910. contexts[pos] = cx_index << 1 | cx_mps;
  21911. return d;
  21912. }
  21913. };
  21914. return ArithmeticDecoder;
  21915. }();
  21916. exports.ArithmeticDecoder = ArithmeticDecoder;
  21917. /***/ }),
  21918. /* 15 */
  21919. /***/ (function(module, exports, __w_pdfjs_require__) {
  21920. "use strict";
  21921. var sharedUtil = __w_pdfjs_require__(0);
  21922. var coreCharsets = __w_pdfjs_require__(29);
  21923. var coreEncodings = __w_pdfjs_require__(5);
  21924. var error = sharedUtil.error;
  21925. var info = sharedUtil.info;
  21926. var bytesToString = sharedUtil.bytesToString;
  21927. var warn = sharedUtil.warn;
  21928. var isArray = sharedUtil.isArray;
  21929. var Util = sharedUtil.Util;
  21930. var stringToBytes = sharedUtil.stringToBytes;
  21931. var assert = sharedUtil.assert;
  21932. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  21933. var ExpertCharset = coreCharsets.ExpertCharset;
  21934. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  21935. var StandardEncoding = coreEncodings.StandardEncoding;
  21936. var ExpertEncoding = coreEncodings.ExpertEncoding;
  21937. var MAX_SUBR_NESTING = 10;
  21938. var CFFStandardStrings = [
  21939. '.notdef',
  21940. 'space',
  21941. 'exclam',
  21942. 'quotedbl',
  21943. 'numbersign',
  21944. 'dollar',
  21945. 'percent',
  21946. 'ampersand',
  21947. 'quoteright',
  21948. 'parenleft',
  21949. 'parenright',
  21950. 'asterisk',
  21951. 'plus',
  21952. 'comma',
  21953. 'hyphen',
  21954. 'period',
  21955. 'slash',
  21956. 'zero',
  21957. 'one',
  21958. 'two',
  21959. 'three',
  21960. 'four',
  21961. 'five',
  21962. 'six',
  21963. 'seven',
  21964. 'eight',
  21965. 'nine',
  21966. 'colon',
  21967. 'semicolon',
  21968. 'less',
  21969. 'equal',
  21970. 'greater',
  21971. 'question',
  21972. 'at',
  21973. 'A',
  21974. 'B',
  21975. 'C',
  21976. 'D',
  21977. 'E',
  21978. 'F',
  21979. 'G',
  21980. 'H',
  21981. 'I',
  21982. 'J',
  21983. 'K',
  21984. 'L',
  21985. 'M',
  21986. 'N',
  21987. 'O',
  21988. 'P',
  21989. 'Q',
  21990. 'R',
  21991. 'S',
  21992. 'T',
  21993. 'U',
  21994. 'V',
  21995. 'W',
  21996. 'X',
  21997. 'Y',
  21998. 'Z',
  21999. 'bracketleft',
  22000. 'backslash',
  22001. 'bracketright',
  22002. 'asciicircum',
  22003. 'underscore',
  22004. 'quoteleft',
  22005. 'a',
  22006. 'b',
  22007. 'c',
  22008. 'd',
  22009. 'e',
  22010. 'f',
  22011. 'g',
  22012. 'h',
  22013. 'i',
  22014. 'j',
  22015. 'k',
  22016. 'l',
  22017. 'm',
  22018. 'n',
  22019. 'o',
  22020. 'p',
  22021. 'q',
  22022. 'r',
  22023. 's',
  22024. 't',
  22025. 'u',
  22026. 'v',
  22027. 'w',
  22028. 'x',
  22029. 'y',
  22030. 'z',
  22031. 'braceleft',
  22032. 'bar',
  22033. 'braceright',
  22034. 'asciitilde',
  22035. 'exclamdown',
  22036. 'cent',
  22037. 'sterling',
  22038. 'fraction',
  22039. 'yen',
  22040. 'florin',
  22041. 'section',
  22042. 'currency',
  22043. 'quotesingle',
  22044. 'quotedblleft',
  22045. 'guillemotleft',
  22046. 'guilsinglleft',
  22047. 'guilsinglright',
  22048. 'fi',
  22049. 'fl',
  22050. 'endash',
  22051. 'dagger',
  22052. 'daggerdbl',
  22053. 'periodcentered',
  22054. 'paragraph',
  22055. 'bullet',
  22056. 'quotesinglbase',
  22057. 'quotedblbase',
  22058. 'quotedblright',
  22059. 'guillemotright',
  22060. 'ellipsis',
  22061. 'perthousand',
  22062. 'questiondown',
  22063. 'grave',
  22064. 'acute',
  22065. 'circumflex',
  22066. 'tilde',
  22067. 'macron',
  22068. 'breve',
  22069. 'dotaccent',
  22070. 'dieresis',
  22071. 'ring',
  22072. 'cedilla',
  22073. 'hungarumlaut',
  22074. 'ogonek',
  22075. 'caron',
  22076. 'emdash',
  22077. 'AE',
  22078. 'ordfeminine',
  22079. 'Lslash',
  22080. 'Oslash',
  22081. 'OE',
  22082. 'ordmasculine',
  22083. 'ae',
  22084. 'dotlessi',
  22085. 'lslash',
  22086. 'oslash',
  22087. 'oe',
  22088. 'germandbls',
  22089. 'onesuperior',
  22090. 'logicalnot',
  22091. 'mu',
  22092. 'trademark',
  22093. 'Eth',
  22094. 'onehalf',
  22095. 'plusminus',
  22096. 'Thorn',
  22097. 'onequarter',
  22098. 'divide',
  22099. 'brokenbar',
  22100. 'degree',
  22101. 'thorn',
  22102. 'threequarters',
  22103. 'twosuperior',
  22104. 'registered',
  22105. 'minus',
  22106. 'eth',
  22107. 'multiply',
  22108. 'threesuperior',
  22109. 'copyright',
  22110. 'Aacute',
  22111. 'Acircumflex',
  22112. 'Adieresis',
  22113. 'Agrave',
  22114. 'Aring',
  22115. 'Atilde',
  22116. 'Ccedilla',
  22117. 'Eacute',
  22118. 'Ecircumflex',
  22119. 'Edieresis',
  22120. 'Egrave',
  22121. 'Iacute',
  22122. 'Icircumflex',
  22123. 'Idieresis',
  22124. 'Igrave',
  22125. 'Ntilde',
  22126. 'Oacute',
  22127. 'Ocircumflex',
  22128. 'Odieresis',
  22129. 'Ograve',
  22130. 'Otilde',
  22131. 'Scaron',
  22132. 'Uacute',
  22133. 'Ucircumflex',
  22134. 'Udieresis',
  22135. 'Ugrave',
  22136. 'Yacute',
  22137. 'Ydieresis',
  22138. 'Zcaron',
  22139. 'aacute',
  22140. 'acircumflex',
  22141. 'adieresis',
  22142. 'agrave',
  22143. 'aring',
  22144. 'atilde',
  22145. 'ccedilla',
  22146. 'eacute',
  22147. 'ecircumflex',
  22148. 'edieresis',
  22149. 'egrave',
  22150. 'iacute',
  22151. 'icircumflex',
  22152. 'idieresis',
  22153. 'igrave',
  22154. 'ntilde',
  22155. 'oacute',
  22156. 'ocircumflex',
  22157. 'odieresis',
  22158. 'ograve',
  22159. 'otilde',
  22160. 'scaron',
  22161. 'uacute',
  22162. 'ucircumflex',
  22163. 'udieresis',
  22164. 'ugrave',
  22165. 'yacute',
  22166. 'ydieresis',
  22167. 'zcaron',
  22168. 'exclamsmall',
  22169. 'Hungarumlautsmall',
  22170. 'dollaroldstyle',
  22171. 'dollarsuperior',
  22172. 'ampersandsmall',
  22173. 'Acutesmall',
  22174. 'parenleftsuperior',
  22175. 'parenrightsuperior',
  22176. 'twodotenleader',
  22177. 'onedotenleader',
  22178. 'zerooldstyle',
  22179. 'oneoldstyle',
  22180. 'twooldstyle',
  22181. 'threeoldstyle',
  22182. 'fouroldstyle',
  22183. 'fiveoldstyle',
  22184. 'sixoldstyle',
  22185. 'sevenoldstyle',
  22186. 'eightoldstyle',
  22187. 'nineoldstyle',
  22188. 'commasuperior',
  22189. 'threequartersemdash',
  22190. 'periodsuperior',
  22191. 'questionsmall',
  22192. 'asuperior',
  22193. 'bsuperior',
  22194. 'centsuperior',
  22195. 'dsuperior',
  22196. 'esuperior',
  22197. 'isuperior',
  22198. 'lsuperior',
  22199. 'msuperior',
  22200. 'nsuperior',
  22201. 'osuperior',
  22202. 'rsuperior',
  22203. 'ssuperior',
  22204. 'tsuperior',
  22205. 'ff',
  22206. 'ffi',
  22207. 'ffl',
  22208. 'parenleftinferior',
  22209. 'parenrightinferior',
  22210. 'Circumflexsmall',
  22211. 'hyphensuperior',
  22212. 'Gravesmall',
  22213. 'Asmall',
  22214. 'Bsmall',
  22215. 'Csmall',
  22216. 'Dsmall',
  22217. 'Esmall',
  22218. 'Fsmall',
  22219. 'Gsmall',
  22220. 'Hsmall',
  22221. 'Ismall',
  22222. 'Jsmall',
  22223. 'Ksmall',
  22224. 'Lsmall',
  22225. 'Msmall',
  22226. 'Nsmall',
  22227. 'Osmall',
  22228. 'Psmall',
  22229. 'Qsmall',
  22230. 'Rsmall',
  22231. 'Ssmall',
  22232. 'Tsmall',
  22233. 'Usmall',
  22234. 'Vsmall',
  22235. 'Wsmall',
  22236. 'Xsmall',
  22237. 'Ysmall',
  22238. 'Zsmall',
  22239. 'colonmonetary',
  22240. 'onefitted',
  22241. 'rupiah',
  22242. 'Tildesmall',
  22243. 'exclamdownsmall',
  22244. 'centoldstyle',
  22245. 'Lslashsmall',
  22246. 'Scaronsmall',
  22247. 'Zcaronsmall',
  22248. 'Dieresissmall',
  22249. 'Brevesmall',
  22250. 'Caronsmall',
  22251. 'Dotaccentsmall',
  22252. 'Macronsmall',
  22253. 'figuredash',
  22254. 'hypheninferior',
  22255. 'Ogoneksmall',
  22256. 'Ringsmall',
  22257. 'Cedillasmall',
  22258. 'questiondownsmall',
  22259. 'oneeighth',
  22260. 'threeeighths',
  22261. 'fiveeighths',
  22262. 'seveneighths',
  22263. 'onethird',
  22264. 'twothirds',
  22265. 'zerosuperior',
  22266. 'foursuperior',
  22267. 'fivesuperior',
  22268. 'sixsuperior',
  22269. 'sevensuperior',
  22270. 'eightsuperior',
  22271. 'ninesuperior',
  22272. 'zeroinferior',
  22273. 'oneinferior',
  22274. 'twoinferior',
  22275. 'threeinferior',
  22276. 'fourinferior',
  22277. 'fiveinferior',
  22278. 'sixinferior',
  22279. 'seveninferior',
  22280. 'eightinferior',
  22281. 'nineinferior',
  22282. 'centinferior',
  22283. 'dollarinferior',
  22284. 'periodinferior',
  22285. 'commainferior',
  22286. 'Agravesmall',
  22287. 'Aacutesmall',
  22288. 'Acircumflexsmall',
  22289. 'Atildesmall',
  22290. 'Adieresissmall',
  22291. 'Aringsmall',
  22292. 'AEsmall',
  22293. 'Ccedillasmall',
  22294. 'Egravesmall',
  22295. 'Eacutesmall',
  22296. 'Ecircumflexsmall',
  22297. 'Edieresissmall',
  22298. 'Igravesmall',
  22299. 'Iacutesmall',
  22300. 'Icircumflexsmall',
  22301. 'Idieresissmall',
  22302. 'Ethsmall',
  22303. 'Ntildesmall',
  22304. 'Ogravesmall',
  22305. 'Oacutesmall',
  22306. 'Ocircumflexsmall',
  22307. 'Otildesmall',
  22308. 'Odieresissmall',
  22309. 'OEsmall',
  22310. 'Oslashsmall',
  22311. 'Ugravesmall',
  22312. 'Uacutesmall',
  22313. 'Ucircumflexsmall',
  22314. 'Udieresissmall',
  22315. 'Yacutesmall',
  22316. 'Thornsmall',
  22317. 'Ydieresissmall',
  22318. '001.000',
  22319. '001.001',
  22320. '001.002',
  22321. '001.003',
  22322. 'Black',
  22323. 'Bold',
  22324. 'Book',
  22325. 'Light',
  22326. 'Medium',
  22327. 'Regular',
  22328. 'Roman',
  22329. 'Semibold'
  22330. ];
  22331. var CFFParser = function CFFParserClosure() {
  22332. var CharstringValidationData = [
  22333. null,
  22334. {
  22335. id: 'hstem',
  22336. min: 2,
  22337. stackClearing: true,
  22338. stem: true
  22339. },
  22340. null,
  22341. {
  22342. id: 'vstem',
  22343. min: 2,
  22344. stackClearing: true,
  22345. stem: true
  22346. },
  22347. {
  22348. id: 'vmoveto',
  22349. min: 1,
  22350. stackClearing: true
  22351. },
  22352. {
  22353. id: 'rlineto',
  22354. min: 2,
  22355. resetStack: true
  22356. },
  22357. {
  22358. id: 'hlineto',
  22359. min: 1,
  22360. resetStack: true
  22361. },
  22362. {
  22363. id: 'vlineto',
  22364. min: 1,
  22365. resetStack: true
  22366. },
  22367. {
  22368. id: 'rrcurveto',
  22369. min: 6,
  22370. resetStack: true
  22371. },
  22372. null,
  22373. {
  22374. id: 'callsubr',
  22375. min: 1,
  22376. undefStack: true
  22377. },
  22378. {
  22379. id: 'return',
  22380. min: 0,
  22381. undefStack: true
  22382. },
  22383. null,
  22384. null,
  22385. {
  22386. id: 'endchar',
  22387. min: 0,
  22388. stackClearing: true
  22389. },
  22390. null,
  22391. null,
  22392. null,
  22393. {
  22394. id: 'hstemhm',
  22395. min: 2,
  22396. stackClearing: true,
  22397. stem: true
  22398. },
  22399. {
  22400. id: 'hintmask',
  22401. min: 0,
  22402. stackClearing: true
  22403. },
  22404. {
  22405. id: 'cntrmask',
  22406. min: 0,
  22407. stackClearing: true
  22408. },
  22409. {
  22410. id: 'rmoveto',
  22411. min: 2,
  22412. stackClearing: true
  22413. },
  22414. {
  22415. id: 'hmoveto',
  22416. min: 1,
  22417. stackClearing: true
  22418. },
  22419. {
  22420. id: 'vstemhm',
  22421. min: 2,
  22422. stackClearing: true,
  22423. stem: true
  22424. },
  22425. {
  22426. id: 'rcurveline',
  22427. min: 8,
  22428. resetStack: true
  22429. },
  22430. {
  22431. id: 'rlinecurve',
  22432. min: 8,
  22433. resetStack: true
  22434. },
  22435. {
  22436. id: 'vvcurveto',
  22437. min: 4,
  22438. resetStack: true
  22439. },
  22440. {
  22441. id: 'hhcurveto',
  22442. min: 4,
  22443. resetStack: true
  22444. },
  22445. null,
  22446. {
  22447. id: 'callgsubr',
  22448. min: 1,
  22449. undefStack: true
  22450. },
  22451. {
  22452. id: 'vhcurveto',
  22453. min: 4,
  22454. resetStack: true
  22455. },
  22456. {
  22457. id: 'hvcurveto',
  22458. min: 4,
  22459. resetStack: true
  22460. }
  22461. ];
  22462. var CharstringValidationData12 = [
  22463. null,
  22464. null,
  22465. null,
  22466. {
  22467. id: 'and',
  22468. min: 2,
  22469. stackDelta: -1
  22470. },
  22471. {
  22472. id: 'or',
  22473. min: 2,
  22474. stackDelta: -1
  22475. },
  22476. {
  22477. id: 'not',
  22478. min: 1,
  22479. stackDelta: 0
  22480. },
  22481. null,
  22482. null,
  22483. null,
  22484. {
  22485. id: 'abs',
  22486. min: 1,
  22487. stackDelta: 0
  22488. },
  22489. {
  22490. id: 'add',
  22491. min: 2,
  22492. stackDelta: -1,
  22493. stackFn: function stack_div(stack, index) {
  22494. stack[index - 2] = stack[index - 2] + stack[index - 1];
  22495. }
  22496. },
  22497. {
  22498. id: 'sub',
  22499. min: 2,
  22500. stackDelta: -1,
  22501. stackFn: function stack_div(stack, index) {
  22502. stack[index - 2] = stack[index - 2] - stack[index - 1];
  22503. }
  22504. },
  22505. {
  22506. id: 'div',
  22507. min: 2,
  22508. stackDelta: -1,
  22509. stackFn: function stack_div(stack, index) {
  22510. stack[index - 2] = stack[index - 2] / stack[index - 1];
  22511. }
  22512. },
  22513. null,
  22514. {
  22515. id: 'neg',
  22516. min: 1,
  22517. stackDelta: 0,
  22518. stackFn: function stack_div(stack, index) {
  22519. stack[index - 1] = -stack[index - 1];
  22520. }
  22521. },
  22522. {
  22523. id: 'eq',
  22524. min: 2,
  22525. stackDelta: -1
  22526. },
  22527. null,
  22528. null,
  22529. {
  22530. id: 'drop',
  22531. min: 1,
  22532. stackDelta: -1
  22533. },
  22534. null,
  22535. {
  22536. id: 'put',
  22537. min: 2,
  22538. stackDelta: -2
  22539. },
  22540. {
  22541. id: 'get',
  22542. min: 1,
  22543. stackDelta: 0
  22544. },
  22545. {
  22546. id: 'ifelse',
  22547. min: 4,
  22548. stackDelta: -3
  22549. },
  22550. {
  22551. id: 'random',
  22552. min: 0,
  22553. stackDelta: 1
  22554. },
  22555. {
  22556. id: 'mul',
  22557. min: 2,
  22558. stackDelta: -1,
  22559. stackFn: function stack_div(stack, index) {
  22560. stack[index - 2] = stack[index - 2] * stack[index - 1];
  22561. }
  22562. },
  22563. null,
  22564. {
  22565. id: 'sqrt',
  22566. min: 1,
  22567. stackDelta: 0
  22568. },
  22569. {
  22570. id: 'dup',
  22571. min: 1,
  22572. stackDelta: 1
  22573. },
  22574. {
  22575. id: 'exch',
  22576. min: 2,
  22577. stackDelta: 0
  22578. },
  22579. {
  22580. id: 'index',
  22581. min: 2,
  22582. stackDelta: 0
  22583. },
  22584. {
  22585. id: 'roll',
  22586. min: 3,
  22587. stackDelta: -2
  22588. },
  22589. null,
  22590. null,
  22591. null,
  22592. {
  22593. id: 'hflex',
  22594. min: 7,
  22595. resetStack: true
  22596. },
  22597. {
  22598. id: 'flex',
  22599. min: 13,
  22600. resetStack: true
  22601. },
  22602. {
  22603. id: 'hflex1',
  22604. min: 9,
  22605. resetStack: true
  22606. },
  22607. {
  22608. id: 'flex1',
  22609. min: 11,
  22610. resetStack: true
  22611. }
  22612. ];
  22613. function CFFParser(file, properties, seacAnalysisEnabled) {
  22614. this.bytes = file.getBytes();
  22615. this.properties = properties;
  22616. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  22617. }
  22618. CFFParser.prototype = {
  22619. parse: function CFFParser_parse() {
  22620. var properties = this.properties;
  22621. var cff = new CFF();
  22622. this.cff = cff;
  22623. var header = this.parseHeader();
  22624. var nameIndex = this.parseIndex(header.endPos);
  22625. var topDictIndex = this.parseIndex(nameIndex.endPos);
  22626. var stringIndex = this.parseIndex(topDictIndex.endPos);
  22627. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  22628. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  22629. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  22630. cff.header = header.obj;
  22631. cff.names = this.parseNameIndex(nameIndex.obj);
  22632. cff.strings = this.parseStringIndex(stringIndex.obj);
  22633. cff.topDict = topDict;
  22634. cff.globalSubrIndex = globalSubrIndex.obj;
  22635. this.parsePrivateDict(cff.topDict);
  22636. cff.isCIDFont = topDict.hasName('ROS');
  22637. var charStringOffset = topDict.getByName('CharStrings');
  22638. var charStringIndex = this.parseIndex(charStringOffset).obj;
  22639. var fontMatrix = topDict.getByName('FontMatrix');
  22640. if (fontMatrix) {
  22641. properties.fontMatrix = fontMatrix;
  22642. }
  22643. var fontBBox = topDict.getByName('FontBBox');
  22644. if (fontBBox) {
  22645. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  22646. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  22647. properties.ascentScaled = true;
  22648. }
  22649. var charset, encoding;
  22650. if (cff.isCIDFont) {
  22651. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  22652. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  22653. var dictRaw = fdArrayIndex.get(i);
  22654. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  22655. this.parsePrivateDict(fontDict);
  22656. cff.fdArray.push(fontDict);
  22657. }
  22658. encoding = null;
  22659. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  22660. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  22661. } else {
  22662. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  22663. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  22664. }
  22665. cff.charset = charset;
  22666. cff.encoding = encoding;
  22667. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  22668. cff.charStrings = charStringsAndSeacs.charStrings;
  22669. cff.seacs = charStringsAndSeacs.seacs;
  22670. cff.widths = charStringsAndSeacs.widths;
  22671. return cff;
  22672. },
  22673. parseHeader: function CFFParser_parseHeader() {
  22674. var bytes = this.bytes;
  22675. var bytesLength = bytes.length;
  22676. var offset = 0;
  22677. while (offset < bytesLength && bytes[offset] !== 1) {
  22678. ++offset;
  22679. }
  22680. if (offset >= bytesLength) {
  22681. error('Invalid CFF header');
  22682. } else if (offset !== 0) {
  22683. info('cff data is shifted');
  22684. bytes = bytes.subarray(offset);
  22685. this.bytes = bytes;
  22686. }
  22687. var major = bytes[0];
  22688. var minor = bytes[1];
  22689. var hdrSize = bytes[2];
  22690. var offSize = bytes[3];
  22691. var header = new CFFHeader(major, minor, hdrSize, offSize);
  22692. return {
  22693. obj: header,
  22694. endPos: hdrSize
  22695. };
  22696. },
  22697. parseDict: function CFFParser_parseDict(dict) {
  22698. var pos = 0;
  22699. function parseOperand() {
  22700. var value = dict[pos++];
  22701. if (value === 30) {
  22702. return parseFloatOperand();
  22703. } else if (value === 28) {
  22704. value = dict[pos++];
  22705. value = (value << 24 | dict[pos++] << 16) >> 16;
  22706. return value;
  22707. } else if (value === 29) {
  22708. value = dict[pos++];
  22709. value = value << 8 | dict[pos++];
  22710. value = value << 8 | dict[pos++];
  22711. value = value << 8 | dict[pos++];
  22712. return value;
  22713. } else if (value >= 32 && value <= 246) {
  22714. return value - 139;
  22715. } else if (value >= 247 && value <= 250) {
  22716. return (value - 247) * 256 + dict[pos++] + 108;
  22717. } else if (value >= 251 && value <= 254) {
  22718. return -((value - 251) * 256) - dict[pos++] - 108;
  22719. }
  22720. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  22721. return NaN;
  22722. }
  22723. function parseFloatOperand() {
  22724. var str = '';
  22725. var eof = 15;
  22726. var lookup = [
  22727. '0',
  22728. '1',
  22729. '2',
  22730. '3',
  22731. '4',
  22732. '5',
  22733. '6',
  22734. '7',
  22735. '8',
  22736. '9',
  22737. '.',
  22738. 'E',
  22739. 'E-',
  22740. null,
  22741. '-'
  22742. ];
  22743. var length = dict.length;
  22744. while (pos < length) {
  22745. var b = dict[pos++];
  22746. var b1 = b >> 4;
  22747. var b2 = b & 15;
  22748. if (b1 === eof) {
  22749. break;
  22750. }
  22751. str += lookup[b1];
  22752. if (b2 === eof) {
  22753. break;
  22754. }
  22755. str += lookup[b2];
  22756. }
  22757. return parseFloat(str);
  22758. }
  22759. var operands = [];
  22760. var entries = [];
  22761. pos = 0;
  22762. var end = dict.length;
  22763. while (pos < end) {
  22764. var b = dict[pos];
  22765. if (b <= 21) {
  22766. if (b === 12) {
  22767. b = b << 8 | dict[++pos];
  22768. }
  22769. entries.push([
  22770. b,
  22771. operands
  22772. ]);
  22773. operands = [];
  22774. ++pos;
  22775. } else {
  22776. operands.push(parseOperand());
  22777. }
  22778. }
  22779. return entries;
  22780. },
  22781. parseIndex: function CFFParser_parseIndex(pos) {
  22782. var cffIndex = new CFFIndex();
  22783. var bytes = this.bytes;
  22784. var count = bytes[pos++] << 8 | bytes[pos++];
  22785. var offsets = [];
  22786. var end = pos;
  22787. var i, ii;
  22788. if (count !== 0) {
  22789. var offsetSize = bytes[pos++];
  22790. var startPos = pos + (count + 1) * offsetSize - 1;
  22791. for (i = 0, ii = count + 1; i < ii; ++i) {
  22792. var offset = 0;
  22793. for (var j = 0; j < offsetSize; ++j) {
  22794. offset <<= 8;
  22795. offset += bytes[pos++];
  22796. }
  22797. offsets.push(startPos + offset);
  22798. }
  22799. end = offsets[count];
  22800. }
  22801. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  22802. var offsetStart = offsets[i];
  22803. var offsetEnd = offsets[i + 1];
  22804. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  22805. }
  22806. return {
  22807. obj: cffIndex,
  22808. endPos: end
  22809. };
  22810. },
  22811. parseNameIndex: function CFFParser_parseNameIndex(index) {
  22812. var names = [];
  22813. for (var i = 0, ii = index.count; i < ii; ++i) {
  22814. var name = index.get(i);
  22815. var length = Math.min(name.length, 127);
  22816. var data = [];
  22817. for (var j = 0; j < length; ++j) {
  22818. var c = name[j];
  22819. if (j === 0 && c === 0) {
  22820. data[j] = c;
  22821. continue;
  22822. }
  22823. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35) {
  22824. data[j] = 95;
  22825. continue;
  22826. }
  22827. data[j] = c;
  22828. }
  22829. names.push(bytesToString(data));
  22830. }
  22831. return names;
  22832. },
  22833. parseStringIndex: function CFFParser_parseStringIndex(index) {
  22834. var strings = new CFFStrings();
  22835. for (var i = 0, ii = index.count; i < ii; ++i) {
  22836. var data = index.get(i);
  22837. strings.add(bytesToString(data));
  22838. }
  22839. return strings;
  22840. },
  22841. createDict: function CFFParser_createDict(Type, dict, strings) {
  22842. var cffDict = new Type(strings);
  22843. for (var i = 0, ii = dict.length; i < ii; ++i) {
  22844. var pair = dict[i];
  22845. var key = pair[0];
  22846. var value = pair[1];
  22847. cffDict.setByKey(key, value);
  22848. }
  22849. return cffDict;
  22850. },
  22851. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  22852. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  22853. return false;
  22854. }
  22855. var stackSize = state.stackSize;
  22856. var stack = state.stack;
  22857. var length = data.length;
  22858. for (var j = 0; j < length;) {
  22859. var value = data[j++];
  22860. var validationCommand = null;
  22861. if (value === 12) {
  22862. var q = data[j++];
  22863. if (q === 0) {
  22864. data[j - 2] = 139;
  22865. data[j - 1] = 22;
  22866. stackSize = 0;
  22867. } else {
  22868. validationCommand = CharstringValidationData12[q];
  22869. }
  22870. } else if (value === 28) {
  22871. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  22872. j += 2;
  22873. stackSize++;
  22874. } else if (value === 14) {
  22875. if (stackSize >= 4) {
  22876. stackSize -= 4;
  22877. if (this.seacAnalysisEnabled) {
  22878. state.seac = stack.slice(stackSize, stackSize + 4);
  22879. return false;
  22880. }
  22881. }
  22882. validationCommand = CharstringValidationData[value];
  22883. } else if (value >= 32 && value <= 246) {
  22884. stack[stackSize] = value - 139;
  22885. stackSize++;
  22886. } else if (value >= 247 && value <= 254) {
  22887. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  22888. j++;
  22889. stackSize++;
  22890. } else if (value === 255) {
  22891. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  22892. j += 4;
  22893. stackSize++;
  22894. } else if (value === 19 || value === 20) {
  22895. state.hints += stackSize >> 1;
  22896. j += state.hints + 7 >> 3;
  22897. stackSize %= 2;
  22898. validationCommand = CharstringValidationData[value];
  22899. } else if (value === 10 || value === 29) {
  22900. var subrsIndex;
  22901. if (value === 10) {
  22902. subrsIndex = localSubrIndex;
  22903. } else {
  22904. subrsIndex = globalSubrIndex;
  22905. }
  22906. if (!subrsIndex) {
  22907. validationCommand = CharstringValidationData[value];
  22908. warn('Missing subrsIndex for ' + validationCommand.id);
  22909. return false;
  22910. }
  22911. var bias = 32768;
  22912. if (subrsIndex.count < 1240) {
  22913. bias = 107;
  22914. } else if (subrsIndex.count < 33900) {
  22915. bias = 1131;
  22916. }
  22917. var subrNumber = stack[--stackSize] + bias;
  22918. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  22919. validationCommand = CharstringValidationData[value];
  22920. warn('Out of bounds subrIndex for ' + validationCommand.id);
  22921. return false;
  22922. }
  22923. state.stackSize = stackSize;
  22924. state.callDepth++;
  22925. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  22926. if (!valid) {
  22927. return false;
  22928. }
  22929. state.callDepth--;
  22930. stackSize = state.stackSize;
  22931. continue;
  22932. } else if (value === 11) {
  22933. state.stackSize = stackSize;
  22934. return true;
  22935. } else {
  22936. validationCommand = CharstringValidationData[value];
  22937. }
  22938. if (validationCommand) {
  22939. if (validationCommand.stem) {
  22940. state.hints += stackSize >> 1;
  22941. }
  22942. if ('min' in validationCommand) {
  22943. if (!state.undefStack && stackSize < validationCommand.min) {
  22944. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  22945. return false;
  22946. }
  22947. }
  22948. if (state.firstStackClearing && validationCommand.stackClearing) {
  22949. state.firstStackClearing = false;
  22950. stackSize -= validationCommand.min;
  22951. if (stackSize >= 2 && validationCommand.stem) {
  22952. stackSize %= 2;
  22953. } else if (stackSize > 1) {
  22954. warn('Found too many parameters for stack-clearing command');
  22955. }
  22956. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  22957. state.width = stack[stackSize - 1];
  22958. }
  22959. }
  22960. if ('stackDelta' in validationCommand) {
  22961. if ('stackFn' in validationCommand) {
  22962. validationCommand.stackFn(stack, stackSize);
  22963. }
  22964. stackSize += validationCommand.stackDelta;
  22965. } else if (validationCommand.stackClearing) {
  22966. stackSize = 0;
  22967. } else if (validationCommand.resetStack) {
  22968. stackSize = 0;
  22969. state.undefStack = false;
  22970. } else if (validationCommand.undefStack) {
  22971. stackSize = 0;
  22972. state.undefStack = true;
  22973. state.firstStackClearing = false;
  22974. }
  22975. }
  22976. }
  22977. state.stackSize = stackSize;
  22978. return true;
  22979. },
  22980. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  22981. var seacs = [];
  22982. var widths = [];
  22983. var count = charStrings.count;
  22984. for (var i = 0; i < count; i++) {
  22985. var charstring = charStrings.get(i);
  22986. var state = {
  22987. callDepth: 0,
  22988. stackSize: 0,
  22989. stack: [],
  22990. undefStack: true,
  22991. hints: 0,
  22992. firstStackClearing: true,
  22993. seac: null,
  22994. width: null
  22995. };
  22996. var valid = true;
  22997. var localSubrToUse = null;
  22998. if (fdSelect && fdArray.length) {
  22999. var fdIndex = fdSelect.getFDIndex(i);
  23000. if (fdIndex === -1) {
  23001. warn('Glyph index is not in fd select.');
  23002. valid = false;
  23003. }
  23004. if (fdIndex >= fdArray.length) {
  23005. warn('Invalid fd index for glyph index.');
  23006. valid = false;
  23007. }
  23008. if (valid) {
  23009. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23010. }
  23011. } else if (localSubrIndex) {
  23012. localSubrToUse = localSubrIndex;
  23013. }
  23014. if (valid) {
  23015. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23016. }
  23017. if (state.width !== null) {
  23018. widths[i] = state.width;
  23019. }
  23020. if (state.seac !== null) {
  23021. seacs[i] = state.seac;
  23022. }
  23023. if (!valid) {
  23024. charStrings.set(i, new Uint8Array([14]));
  23025. }
  23026. }
  23027. return {
  23028. charStrings: charStrings,
  23029. seacs: seacs,
  23030. widths: widths
  23031. };
  23032. },
  23033. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23034. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23035. parentDict.setByKey(18, [
  23036. 0,
  23037. 0
  23038. ]);
  23039. parentDict.privateDict = privateDict;
  23040. },
  23041. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23042. if (!parentDict.hasName('Private')) {
  23043. this.emptyPrivateDictionary(parentDict);
  23044. return;
  23045. }
  23046. var privateOffset = parentDict.getByName('Private');
  23047. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23048. parentDict.removeByName('Private');
  23049. return;
  23050. }
  23051. var size = privateOffset[0];
  23052. var offset = privateOffset[1];
  23053. if (size === 0 || offset >= this.bytes.length) {
  23054. this.emptyPrivateDictionary(parentDict);
  23055. return;
  23056. }
  23057. var privateDictEnd = offset + size;
  23058. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23059. var dict = this.parseDict(dictData);
  23060. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23061. parentDict.privateDict = privateDict;
  23062. if (!privateDict.getByName('Subrs')) {
  23063. return;
  23064. }
  23065. var subrsOffset = privateDict.getByName('Subrs');
  23066. var relativeOffset = offset + subrsOffset;
  23067. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23068. this.emptyPrivateDictionary(parentDict);
  23069. return;
  23070. }
  23071. var subrsIndex = this.parseIndex(relativeOffset);
  23072. privateDict.subrsIndex = subrsIndex.obj;
  23073. },
  23074. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23075. if (pos === 0) {
  23076. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23077. } else if (pos === 1) {
  23078. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23079. } else if (pos === 2) {
  23080. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23081. }
  23082. var bytes = this.bytes;
  23083. var start = pos;
  23084. var format = bytes[pos++];
  23085. var charset = ['.notdef'];
  23086. var id, count, i;
  23087. length -= 1;
  23088. switch (format) {
  23089. case 0:
  23090. for (i = 0; i < length; i++) {
  23091. id = bytes[pos++] << 8 | bytes[pos++];
  23092. charset.push(cid ? id : strings.get(id));
  23093. }
  23094. break;
  23095. case 1:
  23096. while (charset.length <= length) {
  23097. id = bytes[pos++] << 8 | bytes[pos++];
  23098. count = bytes[pos++];
  23099. for (i = 0; i <= count; i++) {
  23100. charset.push(cid ? id++ : strings.get(id++));
  23101. }
  23102. }
  23103. break;
  23104. case 2:
  23105. while (charset.length <= length) {
  23106. id = bytes[pos++] << 8 | bytes[pos++];
  23107. count = bytes[pos++] << 8 | bytes[pos++];
  23108. for (i = 0; i <= count; i++) {
  23109. charset.push(cid ? id++ : strings.get(id++));
  23110. }
  23111. }
  23112. break;
  23113. default:
  23114. error('Unknown charset format');
  23115. }
  23116. var end = pos;
  23117. var raw = bytes.subarray(start, end);
  23118. return new CFFCharset(false, format, charset, raw);
  23119. },
  23120. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23121. var encoding = Object.create(null);
  23122. var bytes = this.bytes;
  23123. var predefined = false;
  23124. var format, i, ii;
  23125. var raw = null;
  23126. function readSupplement() {
  23127. var supplementsCount = bytes[pos++];
  23128. for (i = 0; i < supplementsCount; i++) {
  23129. var code = bytes[pos++];
  23130. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23131. encoding[code] = charset.indexOf(strings.get(sid));
  23132. }
  23133. }
  23134. if (pos === 0 || pos === 1) {
  23135. predefined = true;
  23136. format = pos;
  23137. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23138. for (i = 0, ii = charset.length; i < ii; i++) {
  23139. var index = baseEncoding.indexOf(charset[i]);
  23140. if (index !== -1) {
  23141. encoding[index] = i;
  23142. }
  23143. }
  23144. } else {
  23145. var dataStart = pos;
  23146. format = bytes[pos++];
  23147. switch (format & 0x7f) {
  23148. case 0:
  23149. var glyphsCount = bytes[pos++];
  23150. for (i = 1; i <= glyphsCount; i++) {
  23151. encoding[bytes[pos++]] = i;
  23152. }
  23153. break;
  23154. case 1:
  23155. var rangesCount = bytes[pos++];
  23156. var gid = 1;
  23157. for (i = 0; i < rangesCount; i++) {
  23158. var start = bytes[pos++];
  23159. var left = bytes[pos++];
  23160. for (var j = start; j <= start + left; j++) {
  23161. encoding[j] = gid++;
  23162. }
  23163. }
  23164. break;
  23165. default:
  23166. error('Unknown encoding format: ' + format + ' in CFF');
  23167. break;
  23168. }
  23169. var dataEnd = pos;
  23170. if (format & 0x80) {
  23171. bytes[dataStart] &= 0x7f;
  23172. readSupplement();
  23173. }
  23174. raw = bytes.subarray(dataStart, dataEnd);
  23175. }
  23176. format = format & 0x7f;
  23177. return new CFFEncoding(predefined, format, encoding, raw);
  23178. },
  23179. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23180. var start = pos;
  23181. var bytes = this.bytes;
  23182. var format = bytes[pos++];
  23183. var fdSelect = [], rawBytes;
  23184. var i, invalidFirstGID = false;
  23185. switch (format) {
  23186. case 0:
  23187. for (i = 0; i < length; ++i) {
  23188. var id = bytes[pos++];
  23189. fdSelect.push(id);
  23190. }
  23191. rawBytes = bytes.subarray(start, pos);
  23192. break;
  23193. case 3:
  23194. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23195. for (i = 0; i < rangesCount; ++i) {
  23196. var first = bytes[pos++] << 8 | bytes[pos++];
  23197. if (i === 0 && first !== 0) {
  23198. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23199. invalidFirstGID = true;
  23200. first = 0;
  23201. }
  23202. var fdIndex = bytes[pos++];
  23203. var next = bytes[pos] << 8 | bytes[pos + 1];
  23204. for (var j = first; j < next; ++j) {
  23205. fdSelect.push(fdIndex);
  23206. }
  23207. }
  23208. pos += 2;
  23209. rawBytes = bytes.subarray(start, pos);
  23210. if (invalidFirstGID) {
  23211. rawBytes[3] = rawBytes[4] = 0;
  23212. }
  23213. break;
  23214. default:
  23215. error('parseFDSelect: Unknown format "' + format + '".');
  23216. break;
  23217. }
  23218. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23219. return new CFFFDSelect(fdSelect, rawBytes);
  23220. }
  23221. };
  23222. return CFFParser;
  23223. }();
  23224. var CFF = function CFFClosure() {
  23225. function CFF() {
  23226. this.header = null;
  23227. this.names = [];
  23228. this.topDict = null;
  23229. this.strings = new CFFStrings();
  23230. this.globalSubrIndex = null;
  23231. this.encoding = null;
  23232. this.charset = null;
  23233. this.charStrings = null;
  23234. this.fdArray = [];
  23235. this.fdSelect = null;
  23236. this.isCIDFont = false;
  23237. }
  23238. return CFF;
  23239. }();
  23240. var CFFHeader = function CFFHeaderClosure() {
  23241. function CFFHeader(major, minor, hdrSize, offSize) {
  23242. this.major = major;
  23243. this.minor = minor;
  23244. this.hdrSize = hdrSize;
  23245. this.offSize = offSize;
  23246. }
  23247. return CFFHeader;
  23248. }();
  23249. var CFFStrings = function CFFStringsClosure() {
  23250. function CFFStrings() {
  23251. this.strings = [];
  23252. }
  23253. CFFStrings.prototype = {
  23254. get: function CFFStrings_get(index) {
  23255. if (index >= 0 && index <= 390) {
  23256. return CFFStandardStrings[index];
  23257. }
  23258. if (index - 391 <= this.strings.length) {
  23259. return this.strings[index - 391];
  23260. }
  23261. return CFFStandardStrings[0];
  23262. },
  23263. add: function CFFStrings_add(value) {
  23264. this.strings.push(value);
  23265. },
  23266. get count() {
  23267. return this.strings.length;
  23268. }
  23269. };
  23270. return CFFStrings;
  23271. }();
  23272. var CFFIndex = function CFFIndexClosure() {
  23273. function CFFIndex() {
  23274. this.objects = [];
  23275. this.length = 0;
  23276. }
  23277. CFFIndex.prototype = {
  23278. add: function CFFIndex_add(data) {
  23279. this.length += data.length;
  23280. this.objects.push(data);
  23281. },
  23282. set: function CFFIndex_set(index, data) {
  23283. this.length += data.length - this.objects[index].length;
  23284. this.objects[index] = data;
  23285. },
  23286. get: function CFFIndex_get(index) {
  23287. return this.objects[index];
  23288. },
  23289. get count() {
  23290. return this.objects.length;
  23291. }
  23292. };
  23293. return CFFIndex;
  23294. }();
  23295. var CFFDict = function CFFDictClosure() {
  23296. function CFFDict(tables, strings) {
  23297. this.keyToNameMap = tables.keyToNameMap;
  23298. this.nameToKeyMap = tables.nameToKeyMap;
  23299. this.defaults = tables.defaults;
  23300. this.types = tables.types;
  23301. this.opcodes = tables.opcodes;
  23302. this.order = tables.order;
  23303. this.strings = strings;
  23304. this.values = Object.create(null);
  23305. }
  23306. CFFDict.prototype = {
  23307. setByKey: function CFFDict_setByKey(key, value) {
  23308. if (!(key in this.keyToNameMap)) {
  23309. return false;
  23310. }
  23311. var valueLength = value.length;
  23312. if (valueLength === 0) {
  23313. return true;
  23314. }
  23315. for (var i = 0; i < valueLength; i++) {
  23316. if (isNaN(value[i])) {
  23317. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  23318. return true;
  23319. }
  23320. }
  23321. var type = this.types[key];
  23322. if (type === 'num' || type === 'sid' || type === 'offset') {
  23323. value = value[0];
  23324. }
  23325. this.values[key] = value;
  23326. return true;
  23327. },
  23328. setByName: function CFFDict_setByName(name, value) {
  23329. if (!(name in this.nameToKeyMap)) {
  23330. error('Invalid dictionary name "' + name + '"');
  23331. }
  23332. this.values[this.nameToKeyMap[name]] = value;
  23333. },
  23334. hasName: function CFFDict_hasName(name) {
  23335. return this.nameToKeyMap[name] in this.values;
  23336. },
  23337. getByName: function CFFDict_getByName(name) {
  23338. if (!(name in this.nameToKeyMap)) {
  23339. error('Invalid dictionary name "' + name + '"');
  23340. }
  23341. var key = this.nameToKeyMap[name];
  23342. if (!(key in this.values)) {
  23343. return this.defaults[key];
  23344. }
  23345. return this.values[key];
  23346. },
  23347. removeByName: function CFFDict_removeByName(name) {
  23348. delete this.values[this.nameToKeyMap[name]];
  23349. }
  23350. };
  23351. CFFDict.createTables = function CFFDict_createTables(layout) {
  23352. var tables = {
  23353. keyToNameMap: {},
  23354. nameToKeyMap: {},
  23355. defaults: {},
  23356. types: {},
  23357. opcodes: {},
  23358. order: []
  23359. };
  23360. for (var i = 0, ii = layout.length; i < ii; ++i) {
  23361. var entry = layout[i];
  23362. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  23363. tables.keyToNameMap[key] = entry[1];
  23364. tables.nameToKeyMap[entry[1]] = key;
  23365. tables.types[key] = entry[2];
  23366. tables.defaults[key] = entry[3];
  23367. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  23368. tables.order.push(key);
  23369. }
  23370. return tables;
  23371. };
  23372. return CFFDict;
  23373. }();
  23374. var CFFTopDict = function CFFTopDictClosure() {
  23375. var layout = [
  23376. [
  23377. [
  23378. 12,
  23379. 30
  23380. ],
  23381. 'ROS',
  23382. [
  23383. 'sid',
  23384. 'sid',
  23385. 'num'
  23386. ],
  23387. null
  23388. ],
  23389. [
  23390. [
  23391. 12,
  23392. 20
  23393. ],
  23394. 'SyntheticBase',
  23395. 'num',
  23396. null
  23397. ],
  23398. [
  23399. 0,
  23400. 'version',
  23401. 'sid',
  23402. null
  23403. ],
  23404. [
  23405. 1,
  23406. 'Notice',
  23407. 'sid',
  23408. null
  23409. ],
  23410. [
  23411. [
  23412. 12,
  23413. 0
  23414. ],
  23415. 'Copyright',
  23416. 'sid',
  23417. null
  23418. ],
  23419. [
  23420. 2,
  23421. 'FullName',
  23422. 'sid',
  23423. null
  23424. ],
  23425. [
  23426. 3,
  23427. 'FamilyName',
  23428. 'sid',
  23429. null
  23430. ],
  23431. [
  23432. 4,
  23433. 'Weight',
  23434. 'sid',
  23435. null
  23436. ],
  23437. [
  23438. [
  23439. 12,
  23440. 1
  23441. ],
  23442. 'isFixedPitch',
  23443. 'num',
  23444. 0
  23445. ],
  23446. [
  23447. [
  23448. 12,
  23449. 2
  23450. ],
  23451. 'ItalicAngle',
  23452. 'num',
  23453. 0
  23454. ],
  23455. [
  23456. [
  23457. 12,
  23458. 3
  23459. ],
  23460. 'UnderlinePosition',
  23461. 'num',
  23462. -100
  23463. ],
  23464. [
  23465. [
  23466. 12,
  23467. 4
  23468. ],
  23469. 'UnderlineThickness',
  23470. 'num',
  23471. 50
  23472. ],
  23473. [
  23474. [
  23475. 12,
  23476. 5
  23477. ],
  23478. 'PaintType',
  23479. 'num',
  23480. 0
  23481. ],
  23482. [
  23483. [
  23484. 12,
  23485. 6
  23486. ],
  23487. 'CharstringType',
  23488. 'num',
  23489. 2
  23490. ],
  23491. [
  23492. [
  23493. 12,
  23494. 7
  23495. ],
  23496. 'FontMatrix',
  23497. [
  23498. 'num',
  23499. 'num',
  23500. 'num',
  23501. 'num',
  23502. 'num',
  23503. 'num'
  23504. ],
  23505. [
  23506. 0.001,
  23507. 0,
  23508. 0,
  23509. 0.001,
  23510. 0,
  23511. 0
  23512. ]
  23513. ],
  23514. [
  23515. 13,
  23516. 'UniqueID',
  23517. 'num',
  23518. null
  23519. ],
  23520. [
  23521. 5,
  23522. 'FontBBox',
  23523. [
  23524. 'num',
  23525. 'num',
  23526. 'num',
  23527. 'num'
  23528. ],
  23529. [
  23530. 0,
  23531. 0,
  23532. 0,
  23533. 0
  23534. ]
  23535. ],
  23536. [
  23537. [
  23538. 12,
  23539. 8
  23540. ],
  23541. 'StrokeWidth',
  23542. 'num',
  23543. 0
  23544. ],
  23545. [
  23546. 14,
  23547. 'XUID',
  23548. 'array',
  23549. null
  23550. ],
  23551. [
  23552. 15,
  23553. 'charset',
  23554. 'offset',
  23555. 0
  23556. ],
  23557. [
  23558. 16,
  23559. 'Encoding',
  23560. 'offset',
  23561. 0
  23562. ],
  23563. [
  23564. 17,
  23565. 'CharStrings',
  23566. 'offset',
  23567. 0
  23568. ],
  23569. [
  23570. 18,
  23571. 'Private',
  23572. [
  23573. 'offset',
  23574. 'offset'
  23575. ],
  23576. null
  23577. ],
  23578. [
  23579. [
  23580. 12,
  23581. 21
  23582. ],
  23583. 'PostScript',
  23584. 'sid',
  23585. null
  23586. ],
  23587. [
  23588. [
  23589. 12,
  23590. 22
  23591. ],
  23592. 'BaseFontName',
  23593. 'sid',
  23594. null
  23595. ],
  23596. [
  23597. [
  23598. 12,
  23599. 23
  23600. ],
  23601. 'BaseFontBlend',
  23602. 'delta',
  23603. null
  23604. ],
  23605. [
  23606. [
  23607. 12,
  23608. 31
  23609. ],
  23610. 'CIDFontVersion',
  23611. 'num',
  23612. 0
  23613. ],
  23614. [
  23615. [
  23616. 12,
  23617. 32
  23618. ],
  23619. 'CIDFontRevision',
  23620. 'num',
  23621. 0
  23622. ],
  23623. [
  23624. [
  23625. 12,
  23626. 33
  23627. ],
  23628. 'CIDFontType',
  23629. 'num',
  23630. 0
  23631. ],
  23632. [
  23633. [
  23634. 12,
  23635. 34
  23636. ],
  23637. 'CIDCount',
  23638. 'num',
  23639. 8720
  23640. ],
  23641. [
  23642. [
  23643. 12,
  23644. 35
  23645. ],
  23646. 'UIDBase',
  23647. 'num',
  23648. null
  23649. ],
  23650. [
  23651. [
  23652. 12,
  23653. 37
  23654. ],
  23655. 'FDSelect',
  23656. 'offset',
  23657. null
  23658. ],
  23659. [
  23660. [
  23661. 12,
  23662. 36
  23663. ],
  23664. 'FDArray',
  23665. 'offset',
  23666. null
  23667. ],
  23668. [
  23669. [
  23670. 12,
  23671. 38
  23672. ],
  23673. 'FontName',
  23674. 'sid',
  23675. null
  23676. ]
  23677. ];
  23678. var tables = null;
  23679. function CFFTopDict(strings) {
  23680. if (tables === null) {
  23681. tables = CFFDict.createTables(layout);
  23682. }
  23683. CFFDict.call(this, tables, strings);
  23684. this.privateDict = null;
  23685. }
  23686. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  23687. return CFFTopDict;
  23688. }();
  23689. var CFFPrivateDict = function CFFPrivateDictClosure() {
  23690. var layout = [
  23691. [
  23692. 6,
  23693. 'BlueValues',
  23694. 'delta',
  23695. null
  23696. ],
  23697. [
  23698. 7,
  23699. 'OtherBlues',
  23700. 'delta',
  23701. null
  23702. ],
  23703. [
  23704. 8,
  23705. 'FamilyBlues',
  23706. 'delta',
  23707. null
  23708. ],
  23709. [
  23710. 9,
  23711. 'FamilyOtherBlues',
  23712. 'delta',
  23713. null
  23714. ],
  23715. [
  23716. [
  23717. 12,
  23718. 9
  23719. ],
  23720. 'BlueScale',
  23721. 'num',
  23722. 0.039625
  23723. ],
  23724. [
  23725. [
  23726. 12,
  23727. 10
  23728. ],
  23729. 'BlueShift',
  23730. 'num',
  23731. 7
  23732. ],
  23733. [
  23734. [
  23735. 12,
  23736. 11
  23737. ],
  23738. 'BlueFuzz',
  23739. 'num',
  23740. 1
  23741. ],
  23742. [
  23743. 10,
  23744. 'StdHW',
  23745. 'num',
  23746. null
  23747. ],
  23748. [
  23749. 11,
  23750. 'StdVW',
  23751. 'num',
  23752. null
  23753. ],
  23754. [
  23755. [
  23756. 12,
  23757. 12
  23758. ],
  23759. 'StemSnapH',
  23760. 'delta',
  23761. null
  23762. ],
  23763. [
  23764. [
  23765. 12,
  23766. 13
  23767. ],
  23768. 'StemSnapV',
  23769. 'delta',
  23770. null
  23771. ],
  23772. [
  23773. [
  23774. 12,
  23775. 14
  23776. ],
  23777. 'ForceBold',
  23778. 'num',
  23779. 0
  23780. ],
  23781. [
  23782. [
  23783. 12,
  23784. 17
  23785. ],
  23786. 'LanguageGroup',
  23787. 'num',
  23788. 0
  23789. ],
  23790. [
  23791. [
  23792. 12,
  23793. 18
  23794. ],
  23795. 'ExpansionFactor',
  23796. 'num',
  23797. 0.06
  23798. ],
  23799. [
  23800. [
  23801. 12,
  23802. 19
  23803. ],
  23804. 'initialRandomSeed',
  23805. 'num',
  23806. 0
  23807. ],
  23808. [
  23809. 20,
  23810. 'defaultWidthX',
  23811. 'num',
  23812. 0
  23813. ],
  23814. [
  23815. 21,
  23816. 'nominalWidthX',
  23817. 'num',
  23818. 0
  23819. ],
  23820. [
  23821. 19,
  23822. 'Subrs',
  23823. 'offset',
  23824. null
  23825. ]
  23826. ];
  23827. var tables = null;
  23828. function CFFPrivateDict(strings) {
  23829. if (tables === null) {
  23830. tables = CFFDict.createTables(layout);
  23831. }
  23832. CFFDict.call(this, tables, strings);
  23833. this.subrsIndex = null;
  23834. }
  23835. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  23836. return CFFPrivateDict;
  23837. }();
  23838. var CFFCharsetPredefinedTypes = {
  23839. ISO_ADOBE: 0,
  23840. EXPERT: 1,
  23841. EXPERT_SUBSET: 2
  23842. };
  23843. var CFFCharset = function CFFCharsetClosure() {
  23844. function CFFCharset(predefined, format, charset, raw) {
  23845. this.predefined = predefined;
  23846. this.format = format;
  23847. this.charset = charset;
  23848. this.raw = raw;
  23849. }
  23850. return CFFCharset;
  23851. }();
  23852. var CFFEncoding = function CFFEncodingClosure() {
  23853. function CFFEncoding(predefined, format, encoding, raw) {
  23854. this.predefined = predefined;
  23855. this.format = format;
  23856. this.encoding = encoding;
  23857. this.raw = raw;
  23858. }
  23859. return CFFEncoding;
  23860. }();
  23861. var CFFFDSelect = function CFFFDSelectClosure() {
  23862. function CFFFDSelect(fdSelect, raw) {
  23863. this.fdSelect = fdSelect;
  23864. this.raw = raw;
  23865. }
  23866. CFFFDSelect.prototype = {
  23867. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  23868. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  23869. return -1;
  23870. }
  23871. return this.fdSelect[glyphIndex];
  23872. }
  23873. };
  23874. return CFFFDSelect;
  23875. }();
  23876. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  23877. function CFFOffsetTracker() {
  23878. this.offsets = Object.create(null);
  23879. }
  23880. CFFOffsetTracker.prototype = {
  23881. isTracking: function CFFOffsetTracker_isTracking(key) {
  23882. return key in this.offsets;
  23883. },
  23884. track: function CFFOffsetTracker_track(key, location) {
  23885. if (key in this.offsets) {
  23886. error('Already tracking location of ' + key);
  23887. }
  23888. this.offsets[key] = location;
  23889. },
  23890. offset: function CFFOffsetTracker_offset(value) {
  23891. for (var key in this.offsets) {
  23892. this.offsets[key] += value;
  23893. }
  23894. },
  23895. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  23896. if (!(key in this.offsets)) {
  23897. error('Not tracking location of ' + key);
  23898. }
  23899. var data = output.data;
  23900. var dataOffset = this.offsets[key];
  23901. var size = 5;
  23902. for (var i = 0, ii = values.length; i < ii; ++i) {
  23903. var offset0 = i * size + dataOffset;
  23904. var offset1 = offset0 + 1;
  23905. var offset2 = offset0 + 2;
  23906. var offset3 = offset0 + 3;
  23907. var offset4 = offset0 + 4;
  23908. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  23909. error('writing to an offset that is not empty');
  23910. }
  23911. var value = values[i];
  23912. data[offset0] = 0x1d;
  23913. data[offset1] = value >> 24 & 0xFF;
  23914. data[offset2] = value >> 16 & 0xFF;
  23915. data[offset3] = value >> 8 & 0xFF;
  23916. data[offset4] = value & 0xFF;
  23917. }
  23918. }
  23919. };
  23920. return CFFOffsetTracker;
  23921. }();
  23922. var CFFCompiler = function CFFCompilerClosure() {
  23923. function CFFCompiler(cff) {
  23924. this.cff = cff;
  23925. }
  23926. CFFCompiler.prototype = {
  23927. compile: function CFFCompiler_compile() {
  23928. var cff = this.cff;
  23929. var output = {
  23930. data: [],
  23931. length: 0,
  23932. add: function CFFCompiler_add(data) {
  23933. this.data = this.data.concat(data);
  23934. this.length = this.data.length;
  23935. }
  23936. };
  23937. var header = this.compileHeader(cff.header);
  23938. output.add(header);
  23939. var nameIndex = this.compileNameIndex(cff.names);
  23940. output.add(nameIndex);
  23941. if (cff.isCIDFont) {
  23942. if (cff.topDict.hasName('FontMatrix')) {
  23943. var base = cff.topDict.getByName('FontMatrix');
  23944. cff.topDict.removeByName('FontMatrix');
  23945. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  23946. var subDict = cff.fdArray[i];
  23947. var matrix = base.slice(0);
  23948. if (subDict.hasName('FontMatrix')) {
  23949. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  23950. }
  23951. subDict.setByName('FontMatrix', matrix);
  23952. }
  23953. }
  23954. }
  23955. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  23956. output.add(compiled.output);
  23957. var topDictTracker = compiled.trackers[0];
  23958. var stringIndex = this.compileStringIndex(cff.strings.strings);
  23959. output.add(stringIndex);
  23960. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  23961. output.add(globalSubrIndex);
  23962. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  23963. if (cff.encoding.predefined) {
  23964. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  23965. } else {
  23966. var encoding = this.compileEncoding(cff.encoding);
  23967. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  23968. output.add(encoding);
  23969. }
  23970. }
  23971. if (cff.charset && cff.topDict.hasName('charset')) {
  23972. if (cff.charset.predefined) {
  23973. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  23974. } else {
  23975. var charset = this.compileCharset(cff.charset);
  23976. topDictTracker.setEntryLocation('charset', [output.length], output);
  23977. output.add(charset);
  23978. }
  23979. }
  23980. var charStrings = this.compileCharStrings(cff.charStrings);
  23981. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  23982. output.add(charStrings);
  23983. if (cff.isCIDFont) {
  23984. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  23985. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  23986. output.add(fdSelect);
  23987. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  23988. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  23989. output.add(compiled.output);
  23990. var fontDictTrackers = compiled.trackers;
  23991. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  23992. }
  23993. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  23994. output.add([0]);
  23995. return output.data;
  23996. },
  23997. encodeNumber: function CFFCompiler_encodeNumber(value) {
  23998. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  23999. return this.encodeInteger(value);
  24000. }
  24001. return this.encodeFloat(value);
  24002. },
  24003. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24004. var value = num.toString();
  24005. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24006. if (m) {
  24007. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24008. value = (Math.round(num * epsilon) / epsilon).toString();
  24009. }
  24010. var nibbles = '';
  24011. var i, ii;
  24012. for (i = 0, ii = value.length; i < ii; ++i) {
  24013. var a = value[i];
  24014. if (a === 'e') {
  24015. nibbles += value[++i] === '-' ? 'c' : 'b';
  24016. } else if (a === '.') {
  24017. nibbles += 'a';
  24018. } else if (a === '-') {
  24019. nibbles += 'e';
  24020. } else {
  24021. nibbles += a;
  24022. }
  24023. }
  24024. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24025. var out = [30];
  24026. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24027. out.push(parseInt(nibbles.substr(i, 2), 16));
  24028. }
  24029. return out;
  24030. },
  24031. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24032. var code;
  24033. if (value >= -107 && value <= 107) {
  24034. code = [value + 139];
  24035. } else if (value >= 108 && value <= 1131) {
  24036. value = value - 108;
  24037. code = [
  24038. (value >> 8) + 247,
  24039. value & 0xFF
  24040. ];
  24041. } else if (value >= -1131 && value <= -108) {
  24042. value = -value - 108;
  24043. code = [
  24044. (value >> 8) + 251,
  24045. value & 0xFF
  24046. ];
  24047. } else if (value >= -32768 && value <= 32767) {
  24048. code = [
  24049. 0x1c,
  24050. value >> 8 & 0xFF,
  24051. value & 0xFF
  24052. ];
  24053. } else {
  24054. code = [
  24055. 0x1d,
  24056. value >> 24 & 0xFF,
  24057. value >> 16 & 0xFF,
  24058. value >> 8 & 0xFF,
  24059. value & 0xFF
  24060. ];
  24061. }
  24062. return code;
  24063. },
  24064. compileHeader: function CFFCompiler_compileHeader(header) {
  24065. return [
  24066. header.major,
  24067. header.minor,
  24068. header.hdrSize,
  24069. header.offSize
  24070. ];
  24071. },
  24072. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24073. var nameIndex = new CFFIndex();
  24074. for (var i = 0, ii = names.length; i < ii; ++i) {
  24075. nameIndex.add(stringToBytes(names[i]));
  24076. }
  24077. return this.compileIndex(nameIndex);
  24078. },
  24079. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24080. var fontDictTrackers = [];
  24081. var fdArrayIndex = new CFFIndex();
  24082. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24083. var fontDict = dicts[i];
  24084. if (removeCidKeys) {
  24085. fontDict.removeByName('CIDFontVersion');
  24086. fontDict.removeByName('CIDFontRevision');
  24087. fontDict.removeByName('CIDFontType');
  24088. fontDict.removeByName('CIDCount');
  24089. fontDict.removeByName('UIDBase');
  24090. }
  24091. var fontDictTracker = new CFFOffsetTracker();
  24092. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24093. fontDictTrackers.push(fontDictTracker);
  24094. fdArrayIndex.add(fontDictData);
  24095. fontDictTracker.offset(length);
  24096. }
  24097. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24098. return {
  24099. trackers: fontDictTrackers,
  24100. output: fdArrayIndex
  24101. };
  24102. },
  24103. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24104. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24105. var fontDict = dicts[i];
  24106. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24107. var privateDict = fontDict.privateDict;
  24108. var privateDictTracker = new CFFOffsetTracker();
  24109. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24110. var outputLength = output.length;
  24111. privateDictTracker.offset(outputLength);
  24112. if (!privateDictData.length) {
  24113. outputLength = 0;
  24114. }
  24115. trackers[i].setEntryLocation('Private', [
  24116. privateDictData.length,
  24117. outputLength
  24118. ], output);
  24119. output.add(privateDictData);
  24120. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24121. var subrs = this.compileIndex(privateDict.subrsIndex);
  24122. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24123. output.add(subrs);
  24124. }
  24125. }
  24126. },
  24127. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24128. var out = [];
  24129. var order = dict.order;
  24130. for (var i = 0; i < order.length; ++i) {
  24131. var key = order[i];
  24132. if (!(key in dict.values)) {
  24133. continue;
  24134. }
  24135. var values = dict.values[key];
  24136. var types = dict.types[key];
  24137. if (!isArray(types)) {
  24138. types = [types];
  24139. }
  24140. if (!isArray(values)) {
  24141. values = [values];
  24142. }
  24143. if (values.length === 0) {
  24144. continue;
  24145. }
  24146. for (var j = 0, jj = types.length; j < jj; ++j) {
  24147. var type = types[j];
  24148. var value = values[j];
  24149. switch (type) {
  24150. case 'num':
  24151. case 'sid':
  24152. out = out.concat(this.encodeNumber(value));
  24153. break;
  24154. case 'offset':
  24155. var name = dict.keyToNameMap[key];
  24156. if (!offsetTracker.isTracking(name)) {
  24157. offsetTracker.track(name, out.length);
  24158. }
  24159. out = out.concat([
  24160. 0x1d,
  24161. 0,
  24162. 0,
  24163. 0,
  24164. 0
  24165. ]);
  24166. break;
  24167. case 'array':
  24168. case 'delta':
  24169. out = out.concat(this.encodeNumber(value));
  24170. for (var k = 1, kk = values.length; k < kk; ++k) {
  24171. out = out.concat(this.encodeNumber(values[k]));
  24172. }
  24173. break;
  24174. default:
  24175. error('Unknown data type of ' + type);
  24176. break;
  24177. }
  24178. }
  24179. out = out.concat(dict.opcodes[key]);
  24180. }
  24181. return out;
  24182. },
  24183. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24184. var stringIndex = new CFFIndex();
  24185. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24186. stringIndex.add(stringToBytes(strings[i]));
  24187. }
  24188. return this.compileIndex(stringIndex);
  24189. },
  24190. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24191. var globalSubrIndex = this.cff.globalSubrIndex;
  24192. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24193. },
  24194. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24195. return this.compileIndex(charStrings);
  24196. },
  24197. compileCharset: function CFFCompiler_compileCharset(charset) {
  24198. return this.compileTypedArray(charset.raw);
  24199. },
  24200. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24201. return this.compileTypedArray(encoding.raw);
  24202. },
  24203. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24204. return this.compileTypedArray(fdSelect);
  24205. },
  24206. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24207. var out = [];
  24208. for (var i = 0, ii = data.length; i < ii; ++i) {
  24209. out[i] = data[i];
  24210. }
  24211. return out;
  24212. },
  24213. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24214. trackers = trackers || [];
  24215. var objects = index.objects;
  24216. var count = objects.length;
  24217. if (count === 0) {
  24218. return [
  24219. 0,
  24220. 0,
  24221. 0
  24222. ];
  24223. }
  24224. var data = [
  24225. count >> 8 & 0xFF,
  24226. count & 0xff
  24227. ];
  24228. var lastOffset = 1, i;
  24229. for (i = 0; i < count; ++i) {
  24230. lastOffset += objects[i].length;
  24231. }
  24232. var offsetSize;
  24233. if (lastOffset < 0x100) {
  24234. offsetSize = 1;
  24235. } else if (lastOffset < 0x10000) {
  24236. offsetSize = 2;
  24237. } else if (lastOffset < 0x1000000) {
  24238. offsetSize = 3;
  24239. } else {
  24240. offsetSize = 4;
  24241. }
  24242. data.push(offsetSize);
  24243. var relativeOffset = 1;
  24244. for (i = 0; i < count + 1; i++) {
  24245. if (offsetSize === 1) {
  24246. data.push(relativeOffset & 0xFF);
  24247. } else if (offsetSize === 2) {
  24248. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24249. } else if (offsetSize === 3) {
  24250. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24251. } else {
  24252. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24253. }
  24254. if (objects[i]) {
  24255. relativeOffset += objects[i].length;
  24256. }
  24257. }
  24258. for (i = 0; i < count; i++) {
  24259. if (trackers[i]) {
  24260. trackers[i].offset(data.length);
  24261. }
  24262. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24263. data.push(objects[i][j]);
  24264. }
  24265. }
  24266. return data;
  24267. }
  24268. };
  24269. return CFFCompiler;
  24270. }();
  24271. exports.CFFStandardStrings = CFFStandardStrings;
  24272. exports.CFFParser = CFFParser;
  24273. exports.CFF = CFF;
  24274. exports.CFFHeader = CFFHeader;
  24275. exports.CFFStrings = CFFStrings;
  24276. exports.CFFIndex = CFFIndex;
  24277. exports.CFFCharset = CFFCharset;
  24278. exports.CFFTopDict = CFFTopDict;
  24279. exports.CFFPrivateDict = CFFPrivateDict;
  24280. exports.CFFCompiler = CFFCompiler;
  24281. /***/ }),
  24282. /* 16 */
  24283. /***/ (function(module, exports, __w_pdfjs_require__) {
  24284. "use strict";
  24285. var sharedUtil = __w_pdfjs_require__(0);
  24286. var MissingDataException = sharedUtil.MissingDataException;
  24287. var arrayByteLength = sharedUtil.arrayByteLength;
  24288. var arraysToBytes = sharedUtil.arraysToBytes;
  24289. var assert = sharedUtil.assert;
  24290. var createPromiseCapability = sharedUtil.createPromiseCapability;
  24291. var isInt = sharedUtil.isInt;
  24292. var isEmptyObj = sharedUtil.isEmptyObj;
  24293. var ChunkedStream = function ChunkedStreamClosure() {
  24294. function ChunkedStream(length, chunkSize, manager) {
  24295. this.bytes = new Uint8Array(length);
  24296. this.start = 0;
  24297. this.pos = 0;
  24298. this.end = length;
  24299. this.chunkSize = chunkSize;
  24300. this.loadedChunks = [];
  24301. this.numChunksLoaded = 0;
  24302. this.numChunks = Math.ceil(length / chunkSize);
  24303. this.manager = manager;
  24304. this.progressiveDataLength = 0;
  24305. this.lastSuccessfulEnsureByteChunk = -1;
  24306. }
  24307. ChunkedStream.prototype = {
  24308. getMissingChunks: function ChunkedStream_getMissingChunks() {
  24309. var chunks = [];
  24310. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  24311. if (!this.loadedChunks[chunk]) {
  24312. chunks.push(chunk);
  24313. }
  24314. }
  24315. return chunks;
  24316. },
  24317. getBaseStreams: function ChunkedStream_getBaseStreams() {
  24318. return [this];
  24319. },
  24320. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  24321. return this.numChunksLoaded === this.numChunks;
  24322. },
  24323. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  24324. var end = begin + chunk.byteLength;
  24325. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  24326. var length = this.bytes.length;
  24327. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  24328. this.bytes.set(new Uint8Array(chunk), begin);
  24329. var chunkSize = this.chunkSize;
  24330. var beginChunk = Math.floor(begin / chunkSize);
  24331. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24332. var curChunk;
  24333. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24334. if (!this.loadedChunks[curChunk]) {
  24335. this.loadedChunks[curChunk] = true;
  24336. ++this.numChunksLoaded;
  24337. }
  24338. }
  24339. },
  24340. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  24341. var position = this.progressiveDataLength;
  24342. var beginChunk = Math.floor(position / this.chunkSize);
  24343. this.bytes.set(new Uint8Array(data), position);
  24344. position += data.byteLength;
  24345. this.progressiveDataLength = position;
  24346. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  24347. var curChunk;
  24348. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24349. if (!this.loadedChunks[curChunk]) {
  24350. this.loadedChunks[curChunk] = true;
  24351. ++this.numChunksLoaded;
  24352. }
  24353. }
  24354. },
  24355. ensureByte: function ChunkedStream_ensureByte(pos) {
  24356. var chunk = Math.floor(pos / this.chunkSize);
  24357. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  24358. return;
  24359. }
  24360. if (!this.loadedChunks[chunk]) {
  24361. throw new MissingDataException(pos, pos + 1);
  24362. }
  24363. this.lastSuccessfulEnsureByteChunk = chunk;
  24364. },
  24365. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  24366. if (begin >= end) {
  24367. return;
  24368. }
  24369. if (end <= this.progressiveDataLength) {
  24370. return;
  24371. }
  24372. var chunkSize = this.chunkSize;
  24373. var beginChunk = Math.floor(begin / chunkSize);
  24374. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24375. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24376. if (!this.loadedChunks[chunk]) {
  24377. throw new MissingDataException(begin, end);
  24378. }
  24379. }
  24380. },
  24381. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  24382. var chunk, numChunks = this.numChunks;
  24383. for (var i = 0; i < numChunks; ++i) {
  24384. chunk = (beginChunk + i) % numChunks;
  24385. if (!this.loadedChunks[chunk]) {
  24386. return chunk;
  24387. }
  24388. }
  24389. return null;
  24390. },
  24391. hasChunk: function ChunkedStream_hasChunk(chunk) {
  24392. return !!this.loadedChunks[chunk];
  24393. },
  24394. get length() {
  24395. return this.end - this.start;
  24396. },
  24397. get isEmpty() {
  24398. return this.length === 0;
  24399. },
  24400. getByte: function ChunkedStream_getByte() {
  24401. var pos = this.pos;
  24402. if (pos >= this.end) {
  24403. return -1;
  24404. }
  24405. this.ensureByte(pos);
  24406. return this.bytes[this.pos++];
  24407. },
  24408. getUint16: function ChunkedStream_getUint16() {
  24409. var b0 = this.getByte();
  24410. var b1 = this.getByte();
  24411. if (b0 === -1 || b1 === -1) {
  24412. return -1;
  24413. }
  24414. return (b0 << 8) + b1;
  24415. },
  24416. getInt32: function ChunkedStream_getInt32() {
  24417. var b0 = this.getByte();
  24418. var b1 = this.getByte();
  24419. var b2 = this.getByte();
  24420. var b3 = this.getByte();
  24421. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24422. },
  24423. getBytes: function ChunkedStream_getBytes(length) {
  24424. var bytes = this.bytes;
  24425. var pos = this.pos;
  24426. var strEnd = this.end;
  24427. if (!length) {
  24428. this.ensureRange(pos, strEnd);
  24429. return bytes.subarray(pos, strEnd);
  24430. }
  24431. var end = pos + length;
  24432. if (end > strEnd) {
  24433. end = strEnd;
  24434. }
  24435. this.ensureRange(pos, end);
  24436. this.pos = end;
  24437. return bytes.subarray(pos, end);
  24438. },
  24439. peekByte: function ChunkedStream_peekByte() {
  24440. var peekedByte = this.getByte();
  24441. this.pos--;
  24442. return peekedByte;
  24443. },
  24444. peekBytes: function ChunkedStream_peekBytes(length) {
  24445. var bytes = this.getBytes(length);
  24446. this.pos -= bytes.length;
  24447. return bytes;
  24448. },
  24449. getByteRange: function ChunkedStream_getBytes(begin, end) {
  24450. this.ensureRange(begin, end);
  24451. return this.bytes.subarray(begin, end);
  24452. },
  24453. skip: function ChunkedStream_skip(n) {
  24454. if (!n) {
  24455. n = 1;
  24456. }
  24457. this.pos += n;
  24458. },
  24459. reset: function ChunkedStream_reset() {
  24460. this.pos = this.start;
  24461. },
  24462. moveStart: function ChunkedStream_moveStart() {
  24463. this.start = this.pos;
  24464. },
  24465. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  24466. this.ensureRange(start, start + length);
  24467. function ChunkedStreamSubstream() {
  24468. }
  24469. ChunkedStreamSubstream.prototype = Object.create(this);
  24470. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  24471. var chunkSize = this.chunkSize;
  24472. var beginChunk = Math.floor(this.start / chunkSize);
  24473. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  24474. var missingChunks = [];
  24475. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24476. if (!this.loadedChunks[chunk]) {
  24477. missingChunks.push(chunk);
  24478. }
  24479. }
  24480. return missingChunks;
  24481. };
  24482. var subStream = new ChunkedStreamSubstream();
  24483. subStream.pos = subStream.start = start;
  24484. subStream.end = start + length || this.end;
  24485. subStream.dict = dict;
  24486. return subStream;
  24487. }
  24488. };
  24489. return ChunkedStream;
  24490. }();
  24491. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  24492. function ChunkedStreamManager(pdfNetworkStream, args) {
  24493. var chunkSize = args.rangeChunkSize;
  24494. var length = args.length;
  24495. this.stream = new ChunkedStream(length, chunkSize, this);
  24496. this.length = length;
  24497. this.chunkSize = chunkSize;
  24498. this.pdfNetworkStream = pdfNetworkStream;
  24499. this.url = args.url;
  24500. this.disableAutoFetch = args.disableAutoFetch;
  24501. this.msgHandler = args.msgHandler;
  24502. this.currRequestId = 0;
  24503. this.chunksNeededByRequest = Object.create(null);
  24504. this.requestsByChunk = Object.create(null);
  24505. this.promisesByRequest = Object.create(null);
  24506. this.progressiveDataLength = 0;
  24507. this.aborted = false;
  24508. this._loadedStreamCapability = createPromiseCapability();
  24509. }
  24510. ChunkedStreamManager.prototype = {
  24511. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  24512. return this._loadedStreamCapability.promise;
  24513. },
  24514. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  24515. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  24516. if (!rangeReader.isStreamingSupported) {
  24517. rangeReader.onProgress = this.onProgress.bind(this);
  24518. }
  24519. var chunks = [], loaded = 0;
  24520. var manager = this;
  24521. var promise = new Promise(function (resolve, reject) {
  24522. var readChunk = function (chunk) {
  24523. try {
  24524. if (!chunk.done) {
  24525. var data = chunk.value;
  24526. chunks.push(data);
  24527. loaded += arrayByteLength(data);
  24528. if (rangeReader.isStreamingSupported) {
  24529. manager.onProgress({ loaded: loaded });
  24530. }
  24531. rangeReader.read().then(readChunk, reject);
  24532. return;
  24533. }
  24534. var chunkData = arraysToBytes(chunks);
  24535. chunks = null;
  24536. resolve(chunkData);
  24537. } catch (e) {
  24538. reject(e);
  24539. }
  24540. };
  24541. rangeReader.read().then(readChunk, reject);
  24542. });
  24543. promise.then(function (data) {
  24544. if (this.aborted) {
  24545. return;
  24546. }
  24547. this.onReceiveData({
  24548. chunk: data,
  24549. begin: begin
  24550. });
  24551. }.bind(this));
  24552. },
  24553. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  24554. var missingChunks = this.stream.getMissingChunks();
  24555. this._requestChunks(missingChunks);
  24556. return this._loadedStreamCapability.promise;
  24557. },
  24558. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  24559. var requestId = this.currRequestId++;
  24560. var i, ii;
  24561. var chunksNeeded = Object.create(null);
  24562. this.chunksNeededByRequest[requestId] = chunksNeeded;
  24563. for (i = 0, ii = chunks.length; i < ii; i++) {
  24564. if (!this.stream.hasChunk(chunks[i])) {
  24565. chunksNeeded[chunks[i]] = true;
  24566. }
  24567. }
  24568. if (isEmptyObj(chunksNeeded)) {
  24569. return Promise.resolve();
  24570. }
  24571. var capability = createPromiseCapability();
  24572. this.promisesByRequest[requestId] = capability;
  24573. var chunksToRequest = [];
  24574. for (var chunk in chunksNeeded) {
  24575. chunk = chunk | 0;
  24576. if (!(chunk in this.requestsByChunk)) {
  24577. this.requestsByChunk[chunk] = [];
  24578. chunksToRequest.push(chunk);
  24579. }
  24580. this.requestsByChunk[chunk].push(requestId);
  24581. }
  24582. if (!chunksToRequest.length) {
  24583. return capability.promise;
  24584. }
  24585. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  24586. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  24587. var groupedChunk = groupedChunksToRequest[i];
  24588. var begin = groupedChunk.beginChunk * this.chunkSize;
  24589. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  24590. this.sendRequest(begin, end);
  24591. }
  24592. return capability.promise;
  24593. },
  24594. getStream: function ChunkedStreamManager_getStream() {
  24595. return this.stream;
  24596. },
  24597. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  24598. end = Math.min(end, this.length);
  24599. var beginChunk = this.getBeginChunk(begin);
  24600. var endChunk = this.getEndChunk(end);
  24601. var chunks = [];
  24602. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24603. chunks.push(chunk);
  24604. }
  24605. return this._requestChunks(chunks);
  24606. },
  24607. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  24608. ranges = ranges || [];
  24609. var chunksToRequest = [];
  24610. for (var i = 0; i < ranges.length; i++) {
  24611. var beginChunk = this.getBeginChunk(ranges[i].begin);
  24612. var endChunk = this.getEndChunk(ranges[i].end);
  24613. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24614. if (chunksToRequest.indexOf(chunk) < 0) {
  24615. chunksToRequest.push(chunk);
  24616. }
  24617. }
  24618. }
  24619. chunksToRequest.sort(function (a, b) {
  24620. return a - b;
  24621. });
  24622. return this._requestChunks(chunksToRequest);
  24623. },
  24624. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  24625. var groupedChunks = [];
  24626. var beginChunk = -1;
  24627. var prevChunk = -1;
  24628. for (var i = 0; i < chunks.length; ++i) {
  24629. var chunk = chunks[i];
  24630. if (beginChunk < 0) {
  24631. beginChunk = chunk;
  24632. }
  24633. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  24634. groupedChunks.push({
  24635. beginChunk: beginChunk,
  24636. endChunk: prevChunk + 1
  24637. });
  24638. beginChunk = chunk;
  24639. }
  24640. if (i + 1 === chunks.length) {
  24641. groupedChunks.push({
  24642. beginChunk: beginChunk,
  24643. endChunk: chunk + 1
  24644. });
  24645. }
  24646. prevChunk = chunk;
  24647. }
  24648. return groupedChunks;
  24649. },
  24650. onProgress: function ChunkedStreamManager_onProgress(args) {
  24651. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  24652. this.msgHandler.send('DocProgress', {
  24653. loaded: bytesLoaded,
  24654. total: this.length
  24655. });
  24656. },
  24657. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  24658. var chunk = args.chunk;
  24659. var isProgressive = args.begin === undefined;
  24660. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  24661. var end = begin + chunk.byteLength;
  24662. var beginChunk = Math.floor(begin / this.chunkSize);
  24663. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  24664. if (isProgressive) {
  24665. this.stream.onReceiveProgressiveData(chunk);
  24666. this.progressiveDataLength = end;
  24667. } else {
  24668. this.stream.onReceiveData(begin, chunk);
  24669. }
  24670. if (this.stream.allChunksLoaded()) {
  24671. this._loadedStreamCapability.resolve(this.stream);
  24672. }
  24673. var loadedRequests = [];
  24674. var i, requestId;
  24675. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  24676. var requestIds = this.requestsByChunk[chunk] || [];
  24677. delete this.requestsByChunk[chunk];
  24678. for (i = 0; i < requestIds.length; ++i) {
  24679. requestId = requestIds[i];
  24680. var chunksNeeded = this.chunksNeededByRequest[requestId];
  24681. if (chunk in chunksNeeded) {
  24682. delete chunksNeeded[chunk];
  24683. }
  24684. if (!isEmptyObj(chunksNeeded)) {
  24685. continue;
  24686. }
  24687. loadedRequests.push(requestId);
  24688. }
  24689. }
  24690. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  24691. var nextEmptyChunk;
  24692. if (this.stream.numChunksLoaded === 1) {
  24693. var lastChunk = this.stream.numChunks - 1;
  24694. if (!this.stream.hasChunk(lastChunk)) {
  24695. nextEmptyChunk = lastChunk;
  24696. }
  24697. } else {
  24698. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  24699. }
  24700. if (isInt(nextEmptyChunk)) {
  24701. this._requestChunks([nextEmptyChunk]);
  24702. }
  24703. }
  24704. for (i = 0; i < loadedRequests.length; ++i) {
  24705. requestId = loadedRequests[i];
  24706. var capability = this.promisesByRequest[requestId];
  24707. delete this.promisesByRequest[requestId];
  24708. capability.resolve();
  24709. }
  24710. this.msgHandler.send('DocProgress', {
  24711. loaded: this.stream.numChunksLoaded * this.chunkSize,
  24712. total: this.length
  24713. });
  24714. },
  24715. onError: function ChunkedStreamManager_onError(err) {
  24716. this._loadedStreamCapability.reject(err);
  24717. },
  24718. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  24719. var chunk = Math.floor(begin / this.chunkSize);
  24720. return chunk;
  24721. },
  24722. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  24723. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  24724. return chunk;
  24725. },
  24726. abort: function ChunkedStreamManager_abort() {
  24727. this.aborted = true;
  24728. if (this.pdfNetworkStream) {
  24729. this.pdfNetworkStream.cancelAllRequests('abort');
  24730. }
  24731. for (var requestId in this.promisesByRequest) {
  24732. var capability = this.promisesByRequest[requestId];
  24733. capability.reject(new Error('Request was aborted'));
  24734. }
  24735. }
  24736. };
  24737. return ChunkedStreamManager;
  24738. }();
  24739. exports.ChunkedStream = ChunkedStream;
  24740. exports.ChunkedStreamManager = ChunkedStreamManager;
  24741. /***/ }),
  24742. /* 17 */
  24743. /***/ (function(module, exports, __w_pdfjs_require__) {
  24744. "use strict";
  24745. var sharedUtil = __w_pdfjs_require__(0);
  24746. var corePrimitives = __w_pdfjs_require__(1);
  24747. var coreStream = __w_pdfjs_require__(2);
  24748. var PasswordException = sharedUtil.PasswordException;
  24749. var PasswordResponses = sharedUtil.PasswordResponses;
  24750. var bytesToString = sharedUtil.bytesToString;
  24751. var warn = sharedUtil.warn;
  24752. var error = sharedUtil.error;
  24753. var assert = sharedUtil.assert;
  24754. var isInt = sharedUtil.isInt;
  24755. var stringToBytes = sharedUtil.stringToBytes;
  24756. var utf8StringToString = sharedUtil.utf8StringToString;
  24757. var Name = corePrimitives.Name;
  24758. var isName = corePrimitives.isName;
  24759. var isDict = corePrimitives.isDict;
  24760. var DecryptStream = coreStream.DecryptStream;
  24761. var ARCFourCipher = function ARCFourCipherClosure() {
  24762. function ARCFourCipher(key) {
  24763. this.a = 0;
  24764. this.b = 0;
  24765. var s = new Uint8Array(256);
  24766. var i, j = 0, tmp, keyLength = key.length;
  24767. for (i = 0; i < 256; ++i) {
  24768. s[i] = i;
  24769. }
  24770. for (i = 0; i < 256; ++i) {
  24771. tmp = s[i];
  24772. j = j + tmp + key[i % keyLength] & 0xFF;
  24773. s[i] = s[j];
  24774. s[j] = tmp;
  24775. }
  24776. this.s = s;
  24777. }
  24778. ARCFourCipher.prototype = {
  24779. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  24780. var i, n = data.length, tmp, tmp2;
  24781. var a = this.a, b = this.b, s = this.s;
  24782. var output = new Uint8Array(n);
  24783. for (i = 0; i < n; ++i) {
  24784. a = a + 1 & 0xFF;
  24785. tmp = s[a];
  24786. b = b + tmp & 0xFF;
  24787. tmp2 = s[b];
  24788. s[a] = tmp2;
  24789. s[b] = tmp;
  24790. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  24791. }
  24792. this.a = a;
  24793. this.b = b;
  24794. return output;
  24795. }
  24796. };
  24797. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  24798. return ARCFourCipher;
  24799. }();
  24800. var calculateMD5 = function calculateMD5Closure() {
  24801. var r = new Uint8Array([
  24802. 7,
  24803. 12,
  24804. 17,
  24805. 22,
  24806. 7,
  24807. 12,
  24808. 17,
  24809. 22,
  24810. 7,
  24811. 12,
  24812. 17,
  24813. 22,
  24814. 7,
  24815. 12,
  24816. 17,
  24817. 22,
  24818. 5,
  24819. 9,
  24820. 14,
  24821. 20,
  24822. 5,
  24823. 9,
  24824. 14,
  24825. 20,
  24826. 5,
  24827. 9,
  24828. 14,
  24829. 20,
  24830. 5,
  24831. 9,
  24832. 14,
  24833. 20,
  24834. 4,
  24835. 11,
  24836. 16,
  24837. 23,
  24838. 4,
  24839. 11,
  24840. 16,
  24841. 23,
  24842. 4,
  24843. 11,
  24844. 16,
  24845. 23,
  24846. 4,
  24847. 11,
  24848. 16,
  24849. 23,
  24850. 6,
  24851. 10,
  24852. 15,
  24853. 21,
  24854. 6,
  24855. 10,
  24856. 15,
  24857. 21,
  24858. 6,
  24859. 10,
  24860. 15,
  24861. 21,
  24862. 6,
  24863. 10,
  24864. 15,
  24865. 21
  24866. ]);
  24867. var k = new Int32Array([
  24868. -680876936,
  24869. -389564586,
  24870. 606105819,
  24871. -1044525330,
  24872. -176418897,
  24873. 1200080426,
  24874. -1473231341,
  24875. -45705983,
  24876. 1770035416,
  24877. -1958414417,
  24878. -42063,
  24879. -1990404162,
  24880. 1804603682,
  24881. -40341101,
  24882. -1502002290,
  24883. 1236535329,
  24884. -165796510,
  24885. -1069501632,
  24886. 643717713,
  24887. -373897302,
  24888. -701558691,
  24889. 38016083,
  24890. -660478335,
  24891. -405537848,
  24892. 568446438,
  24893. -1019803690,
  24894. -187363961,
  24895. 1163531501,
  24896. -1444681467,
  24897. -51403784,
  24898. 1735328473,
  24899. -1926607734,
  24900. -378558,
  24901. -2022574463,
  24902. 1839030562,
  24903. -35309556,
  24904. -1530992060,
  24905. 1272893353,
  24906. -155497632,
  24907. -1094730640,
  24908. 681279174,
  24909. -358537222,
  24910. -722521979,
  24911. 76029189,
  24912. -640364487,
  24913. -421815835,
  24914. 530742520,
  24915. -995338651,
  24916. -198630844,
  24917. 1126891415,
  24918. -1416354905,
  24919. -57434055,
  24920. 1700485571,
  24921. -1894986606,
  24922. -1051523,
  24923. -2054922799,
  24924. 1873313359,
  24925. -30611744,
  24926. -1560198380,
  24927. 1309151649,
  24928. -145523070,
  24929. -1120210379,
  24930. 718787259,
  24931. -343485551
  24932. ]);
  24933. function hash(data, offset, length) {
  24934. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  24935. var paddedLength = length + 72 & ~63;
  24936. var padded = new Uint8Array(paddedLength);
  24937. var i, j, n;
  24938. for (i = 0; i < length; ++i) {
  24939. padded[i] = data[offset++];
  24940. }
  24941. padded[i++] = 0x80;
  24942. n = paddedLength - 8;
  24943. while (i < n) {
  24944. padded[i++] = 0;
  24945. }
  24946. padded[i++] = length << 3 & 0xFF;
  24947. padded[i++] = length >> 5 & 0xFF;
  24948. padded[i++] = length >> 13 & 0xFF;
  24949. padded[i++] = length >> 21 & 0xFF;
  24950. padded[i++] = length >>> 29 & 0xFF;
  24951. padded[i++] = 0;
  24952. padded[i++] = 0;
  24953. padded[i++] = 0;
  24954. var w = new Int32Array(16);
  24955. for (i = 0; i < paddedLength;) {
  24956. for (j = 0; j < 16; ++j, i += 4) {
  24957. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  24958. }
  24959. var a = h0, b = h1, c = h2, d = h3, f, g;
  24960. for (j = 0; j < 64; ++j) {
  24961. if (j < 16) {
  24962. f = b & c | ~b & d;
  24963. g = j;
  24964. } else if (j < 32) {
  24965. f = d & b | ~d & c;
  24966. g = 5 * j + 1 & 15;
  24967. } else if (j < 48) {
  24968. f = b ^ c ^ d;
  24969. g = 3 * j + 5 & 15;
  24970. } else {
  24971. f = c ^ (b | ~d);
  24972. g = 7 * j & 15;
  24973. }
  24974. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  24975. d = c;
  24976. c = b;
  24977. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  24978. a = tmp;
  24979. }
  24980. h0 = h0 + a | 0;
  24981. h1 = h1 + b | 0;
  24982. h2 = h2 + c | 0;
  24983. h3 = h3 + d | 0;
  24984. }
  24985. return new Uint8Array([
  24986. h0 & 0xFF,
  24987. h0 >> 8 & 0xFF,
  24988. h0 >> 16 & 0xFF,
  24989. h0 >>> 24 & 0xFF,
  24990. h1 & 0xFF,
  24991. h1 >> 8 & 0xFF,
  24992. h1 >> 16 & 0xFF,
  24993. h1 >>> 24 & 0xFF,
  24994. h2 & 0xFF,
  24995. h2 >> 8 & 0xFF,
  24996. h2 >> 16 & 0xFF,
  24997. h2 >>> 24 & 0xFF,
  24998. h3 & 0xFF,
  24999. h3 >> 8 & 0xFF,
  25000. h3 >> 16 & 0xFF,
  25001. h3 >>> 24 & 0xFF
  25002. ]);
  25003. }
  25004. return hash;
  25005. }();
  25006. var Word64 = function Word64Closure() {
  25007. function Word64(highInteger, lowInteger) {
  25008. this.high = highInteger | 0;
  25009. this.low = lowInteger | 0;
  25010. }
  25011. Word64.prototype = {
  25012. and: function Word64_and(word) {
  25013. this.high &= word.high;
  25014. this.low &= word.low;
  25015. },
  25016. xor: function Word64_xor(word) {
  25017. this.high ^= word.high;
  25018. this.low ^= word.low;
  25019. },
  25020. or: function Word64_or(word) {
  25021. this.high |= word.high;
  25022. this.low |= word.low;
  25023. },
  25024. shiftRight: function Word64_shiftRight(places) {
  25025. if (places >= 32) {
  25026. this.low = this.high >>> places - 32 | 0;
  25027. this.high = 0;
  25028. } else {
  25029. this.low = this.low >>> places | this.high << 32 - places;
  25030. this.high = this.high >>> places | 0;
  25031. }
  25032. },
  25033. shiftLeft: function Word64_shiftLeft(places) {
  25034. if (places >= 32) {
  25035. this.high = this.low << places - 32;
  25036. this.low = 0;
  25037. } else {
  25038. this.high = this.high << places | this.low >>> 32 - places;
  25039. this.low = this.low << places;
  25040. }
  25041. },
  25042. rotateRight: function Word64_rotateRight(places) {
  25043. var low, high;
  25044. if (places & 32) {
  25045. high = this.low;
  25046. low = this.high;
  25047. } else {
  25048. low = this.low;
  25049. high = this.high;
  25050. }
  25051. places &= 31;
  25052. this.low = low >>> places | high << 32 - places;
  25053. this.high = high >>> places | low << 32 - places;
  25054. },
  25055. not: function Word64_not() {
  25056. this.high = ~this.high;
  25057. this.low = ~this.low;
  25058. },
  25059. add: function Word64_add(word) {
  25060. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25061. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25062. if (lowAdd > 0xFFFFFFFF) {
  25063. highAdd += 1;
  25064. }
  25065. this.low = lowAdd | 0;
  25066. this.high = highAdd | 0;
  25067. },
  25068. copyTo: function Word64_copyTo(bytes, offset) {
  25069. bytes[offset] = this.high >>> 24 & 0xFF;
  25070. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25071. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25072. bytes[offset + 3] = this.high & 0xFF;
  25073. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25074. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25075. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25076. bytes[offset + 7] = this.low & 0xFF;
  25077. },
  25078. assign: function Word64_assign(word) {
  25079. this.high = word.high;
  25080. this.low = word.low;
  25081. }
  25082. };
  25083. return Word64;
  25084. }();
  25085. var calculateSHA256 = function calculateSHA256Closure() {
  25086. function rotr(x, n) {
  25087. return x >>> n | x << 32 - n;
  25088. }
  25089. function ch(x, y, z) {
  25090. return x & y ^ ~x & z;
  25091. }
  25092. function maj(x, y, z) {
  25093. return x & y ^ x & z ^ y & z;
  25094. }
  25095. function sigma(x) {
  25096. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25097. }
  25098. function sigmaPrime(x) {
  25099. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25100. }
  25101. function littleSigma(x) {
  25102. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25103. }
  25104. function littleSigmaPrime(x) {
  25105. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25106. }
  25107. var k = [
  25108. 0x428a2f98,
  25109. 0x71374491,
  25110. 0xb5c0fbcf,
  25111. 0xe9b5dba5,
  25112. 0x3956c25b,
  25113. 0x59f111f1,
  25114. 0x923f82a4,
  25115. 0xab1c5ed5,
  25116. 0xd807aa98,
  25117. 0x12835b01,
  25118. 0x243185be,
  25119. 0x550c7dc3,
  25120. 0x72be5d74,
  25121. 0x80deb1fe,
  25122. 0x9bdc06a7,
  25123. 0xc19bf174,
  25124. 0xe49b69c1,
  25125. 0xefbe4786,
  25126. 0x0fc19dc6,
  25127. 0x240ca1cc,
  25128. 0x2de92c6f,
  25129. 0x4a7484aa,
  25130. 0x5cb0a9dc,
  25131. 0x76f988da,
  25132. 0x983e5152,
  25133. 0xa831c66d,
  25134. 0xb00327c8,
  25135. 0xbf597fc7,
  25136. 0xc6e00bf3,
  25137. 0xd5a79147,
  25138. 0x06ca6351,
  25139. 0x14292967,
  25140. 0x27b70a85,
  25141. 0x2e1b2138,
  25142. 0x4d2c6dfc,
  25143. 0x53380d13,
  25144. 0x650a7354,
  25145. 0x766a0abb,
  25146. 0x81c2c92e,
  25147. 0x92722c85,
  25148. 0xa2bfe8a1,
  25149. 0xa81a664b,
  25150. 0xc24b8b70,
  25151. 0xc76c51a3,
  25152. 0xd192e819,
  25153. 0xd6990624,
  25154. 0xf40e3585,
  25155. 0x106aa070,
  25156. 0x19a4c116,
  25157. 0x1e376c08,
  25158. 0x2748774c,
  25159. 0x34b0bcb5,
  25160. 0x391c0cb3,
  25161. 0x4ed8aa4a,
  25162. 0x5b9cca4f,
  25163. 0x682e6ff3,
  25164. 0x748f82ee,
  25165. 0x78a5636f,
  25166. 0x84c87814,
  25167. 0x8cc70208,
  25168. 0x90befffa,
  25169. 0xa4506ceb,
  25170. 0xbef9a3f7,
  25171. 0xc67178f2
  25172. ];
  25173. function hash(data, offset, length) {
  25174. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25175. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25176. var padded = new Uint8Array(paddedLength);
  25177. var i, j, n;
  25178. for (i = 0; i < length; ++i) {
  25179. padded[i] = data[offset++];
  25180. }
  25181. padded[i++] = 0x80;
  25182. n = paddedLength - 8;
  25183. while (i < n) {
  25184. padded[i++] = 0;
  25185. }
  25186. padded[i++] = 0;
  25187. padded[i++] = 0;
  25188. padded[i++] = 0;
  25189. padded[i++] = length >>> 29 & 0xFF;
  25190. padded[i++] = length >> 21 & 0xFF;
  25191. padded[i++] = length >> 13 & 0xFF;
  25192. padded[i++] = length >> 5 & 0xFF;
  25193. padded[i++] = length << 3 & 0xFF;
  25194. var w = new Uint32Array(64);
  25195. for (i = 0; i < paddedLength;) {
  25196. for (j = 0; j < 16; ++j) {
  25197. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25198. i += 4;
  25199. }
  25200. for (j = 16; j < 64; ++j) {
  25201. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25202. }
  25203. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25204. for (j = 0; j < 64; ++j) {
  25205. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25206. t2 = sigma(a) + maj(a, b, c);
  25207. h = g;
  25208. g = f;
  25209. f = e;
  25210. e = d + t1 | 0;
  25211. d = c;
  25212. c = b;
  25213. b = a;
  25214. a = t1 + t2 | 0;
  25215. }
  25216. h0 = h0 + a | 0;
  25217. h1 = h1 + b | 0;
  25218. h2 = h2 + c | 0;
  25219. h3 = h3 + d | 0;
  25220. h4 = h4 + e | 0;
  25221. h5 = h5 + f | 0;
  25222. h6 = h6 + g | 0;
  25223. h7 = h7 + h | 0;
  25224. }
  25225. return new Uint8Array([
  25226. h0 >> 24 & 0xFF,
  25227. h0 >> 16 & 0xFF,
  25228. h0 >> 8 & 0xFF,
  25229. h0 & 0xFF,
  25230. h1 >> 24 & 0xFF,
  25231. h1 >> 16 & 0xFF,
  25232. h1 >> 8 & 0xFF,
  25233. h1 & 0xFF,
  25234. h2 >> 24 & 0xFF,
  25235. h2 >> 16 & 0xFF,
  25236. h2 >> 8 & 0xFF,
  25237. h2 & 0xFF,
  25238. h3 >> 24 & 0xFF,
  25239. h3 >> 16 & 0xFF,
  25240. h3 >> 8 & 0xFF,
  25241. h3 & 0xFF,
  25242. h4 >> 24 & 0xFF,
  25243. h4 >> 16 & 0xFF,
  25244. h4 >> 8 & 0xFF,
  25245. h4 & 0xFF,
  25246. h5 >> 24 & 0xFF,
  25247. h5 >> 16 & 0xFF,
  25248. h5 >> 8 & 0xFF,
  25249. h5 & 0xFF,
  25250. h6 >> 24 & 0xFF,
  25251. h6 >> 16 & 0xFF,
  25252. h6 >> 8 & 0xFF,
  25253. h6 & 0xFF,
  25254. h7 >> 24 & 0xFF,
  25255. h7 >> 16 & 0xFF,
  25256. h7 >> 8 & 0xFF,
  25257. h7 & 0xFF
  25258. ]);
  25259. }
  25260. return hash;
  25261. }();
  25262. var calculateSHA512 = function calculateSHA512Closure() {
  25263. function ch(result, x, y, z, tmp) {
  25264. result.assign(x);
  25265. result.and(y);
  25266. tmp.assign(x);
  25267. tmp.not();
  25268. tmp.and(z);
  25269. result.xor(tmp);
  25270. }
  25271. function maj(result, x, y, z, tmp) {
  25272. result.assign(x);
  25273. result.and(y);
  25274. tmp.assign(x);
  25275. tmp.and(z);
  25276. result.xor(tmp);
  25277. tmp.assign(y);
  25278. tmp.and(z);
  25279. result.xor(tmp);
  25280. }
  25281. function sigma(result, x, tmp) {
  25282. result.assign(x);
  25283. result.rotateRight(28);
  25284. tmp.assign(x);
  25285. tmp.rotateRight(34);
  25286. result.xor(tmp);
  25287. tmp.assign(x);
  25288. tmp.rotateRight(39);
  25289. result.xor(tmp);
  25290. }
  25291. function sigmaPrime(result, x, tmp) {
  25292. result.assign(x);
  25293. result.rotateRight(14);
  25294. tmp.assign(x);
  25295. tmp.rotateRight(18);
  25296. result.xor(tmp);
  25297. tmp.assign(x);
  25298. tmp.rotateRight(41);
  25299. result.xor(tmp);
  25300. }
  25301. function littleSigma(result, x, tmp) {
  25302. result.assign(x);
  25303. result.rotateRight(1);
  25304. tmp.assign(x);
  25305. tmp.rotateRight(8);
  25306. result.xor(tmp);
  25307. tmp.assign(x);
  25308. tmp.shiftRight(7);
  25309. result.xor(tmp);
  25310. }
  25311. function littleSigmaPrime(result, x, tmp) {
  25312. result.assign(x);
  25313. result.rotateRight(19);
  25314. tmp.assign(x);
  25315. tmp.rotateRight(61);
  25316. result.xor(tmp);
  25317. tmp.assign(x);
  25318. tmp.shiftRight(6);
  25319. result.xor(tmp);
  25320. }
  25321. var k = [
  25322. new Word64(0x428a2f98, 0xd728ae22),
  25323. new Word64(0x71374491, 0x23ef65cd),
  25324. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  25325. new Word64(0xe9b5dba5, 0x8189dbbc),
  25326. new Word64(0x3956c25b, 0xf348b538),
  25327. new Word64(0x59f111f1, 0xb605d019),
  25328. new Word64(0x923f82a4, 0xaf194f9b),
  25329. new Word64(0xab1c5ed5, 0xda6d8118),
  25330. new Word64(0xd807aa98, 0xa3030242),
  25331. new Word64(0x12835b01, 0x45706fbe),
  25332. new Word64(0x243185be, 0x4ee4b28c),
  25333. new Word64(0x550c7dc3, 0xd5ffb4e2),
  25334. new Word64(0x72be5d74, 0xf27b896f),
  25335. new Word64(0x80deb1fe, 0x3b1696b1),
  25336. new Word64(0x9bdc06a7, 0x25c71235),
  25337. new Word64(0xc19bf174, 0xcf692694),
  25338. new Word64(0xe49b69c1, 0x9ef14ad2),
  25339. new Word64(0xefbe4786, 0x384f25e3),
  25340. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  25341. new Word64(0x240ca1cc, 0x77ac9c65),
  25342. new Word64(0x2de92c6f, 0x592b0275),
  25343. new Word64(0x4a7484aa, 0x6ea6e483),
  25344. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  25345. new Word64(0x76f988da, 0x831153b5),
  25346. new Word64(0x983e5152, 0xee66dfab),
  25347. new Word64(0xa831c66d, 0x2db43210),
  25348. new Word64(0xb00327c8, 0x98fb213f),
  25349. new Word64(0xbf597fc7, 0xbeef0ee4),
  25350. new Word64(0xc6e00bf3, 0x3da88fc2),
  25351. new Word64(0xd5a79147, 0x930aa725),
  25352. new Word64(0x06ca6351, 0xe003826f),
  25353. new Word64(0x14292967, 0x0a0e6e70),
  25354. new Word64(0x27b70a85, 0x46d22ffc),
  25355. new Word64(0x2e1b2138, 0x5c26c926),
  25356. new Word64(0x4d2c6dfc, 0x5ac42aed),
  25357. new Word64(0x53380d13, 0x9d95b3df),
  25358. new Word64(0x650a7354, 0x8baf63de),
  25359. new Word64(0x766a0abb, 0x3c77b2a8),
  25360. new Word64(0x81c2c92e, 0x47edaee6),
  25361. new Word64(0x92722c85, 0x1482353b),
  25362. new Word64(0xa2bfe8a1, 0x4cf10364),
  25363. new Word64(0xa81a664b, 0xbc423001),
  25364. new Word64(0xc24b8b70, 0xd0f89791),
  25365. new Word64(0xc76c51a3, 0x0654be30),
  25366. new Word64(0xd192e819, 0xd6ef5218),
  25367. new Word64(0xd6990624, 0x5565a910),
  25368. new Word64(0xf40e3585, 0x5771202a),
  25369. new Word64(0x106aa070, 0x32bbd1b8),
  25370. new Word64(0x19a4c116, 0xb8d2d0c8),
  25371. new Word64(0x1e376c08, 0x5141ab53),
  25372. new Word64(0x2748774c, 0xdf8eeb99),
  25373. new Word64(0x34b0bcb5, 0xe19b48a8),
  25374. new Word64(0x391c0cb3, 0xc5c95a63),
  25375. new Word64(0x4ed8aa4a, 0xe3418acb),
  25376. new Word64(0x5b9cca4f, 0x7763e373),
  25377. new Word64(0x682e6ff3, 0xd6b2b8a3),
  25378. new Word64(0x748f82ee, 0x5defb2fc),
  25379. new Word64(0x78a5636f, 0x43172f60),
  25380. new Word64(0x84c87814, 0xa1f0ab72),
  25381. new Word64(0x8cc70208, 0x1a6439ec),
  25382. new Word64(0x90befffa, 0x23631e28),
  25383. new Word64(0xa4506ceb, 0xde82bde9),
  25384. new Word64(0xbef9a3f7, 0xb2c67915),
  25385. new Word64(0xc67178f2, 0xe372532b),
  25386. new Word64(0xca273ece, 0xea26619c),
  25387. new Word64(0xd186b8c7, 0x21c0c207),
  25388. new Word64(0xeada7dd6, 0xcde0eb1e),
  25389. new Word64(0xf57d4f7f, 0xee6ed178),
  25390. new Word64(0x06f067aa, 0x72176fba),
  25391. new Word64(0x0a637dc5, 0xa2c898a6),
  25392. new Word64(0x113f9804, 0xbef90dae),
  25393. new Word64(0x1b710b35, 0x131c471b),
  25394. new Word64(0x28db77f5, 0x23047d84),
  25395. new Word64(0x32caab7b, 0x40c72493),
  25396. new Word64(0x3c9ebe0a, 0x15c9bebc),
  25397. new Word64(0x431d67c4, 0x9c100d4c),
  25398. new Word64(0x4cc5d4be, 0xcb3e42b6),
  25399. new Word64(0x597f299c, 0xfc657e2a),
  25400. new Word64(0x5fcb6fab, 0x3ad6faec),
  25401. new Word64(0x6c44198c, 0x4a475817)
  25402. ];
  25403. function hash(data, offset, length, mode384) {
  25404. mode384 = !!mode384;
  25405. var h0, h1, h2, h3, h4, h5, h6, h7;
  25406. if (!mode384) {
  25407. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  25408. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  25409. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  25410. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  25411. h4 = new Word64(0x510e527f, 0xade682d1);
  25412. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  25413. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  25414. h7 = new Word64(0x5be0cd19, 0x137e2179);
  25415. } else {
  25416. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  25417. h1 = new Word64(0x629a292a, 0x367cd507);
  25418. h2 = new Word64(0x9159015a, 0x3070dd17);
  25419. h3 = new Word64(0x152fecd8, 0xf70e5939);
  25420. h4 = new Word64(0x67332667, 0xffc00b31);
  25421. h5 = new Word64(0x8eb44a87, 0x68581511);
  25422. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  25423. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  25424. }
  25425. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  25426. var padded = new Uint8Array(paddedLength);
  25427. var i, j, n;
  25428. for (i = 0; i < length; ++i) {
  25429. padded[i] = data[offset++];
  25430. }
  25431. padded[i++] = 0x80;
  25432. n = paddedLength - 16;
  25433. while (i < n) {
  25434. padded[i++] = 0;
  25435. }
  25436. padded[i++] = 0;
  25437. padded[i++] = 0;
  25438. padded[i++] = 0;
  25439. padded[i++] = 0;
  25440. padded[i++] = 0;
  25441. padded[i++] = 0;
  25442. padded[i++] = 0;
  25443. padded[i++] = 0;
  25444. padded[i++] = 0;
  25445. padded[i++] = 0;
  25446. padded[i++] = 0;
  25447. padded[i++] = length >>> 29 & 0xFF;
  25448. padded[i++] = length >> 21 & 0xFF;
  25449. padded[i++] = length >> 13 & 0xFF;
  25450. padded[i++] = length >> 5 & 0xFF;
  25451. padded[i++] = length << 3 & 0xFF;
  25452. var w = new Array(80);
  25453. for (i = 0; i < 80; i++) {
  25454. w[i] = new Word64(0, 0);
  25455. }
  25456. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  25457. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  25458. var g = new Word64(0, 0), h = new Word64(0, 0);
  25459. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  25460. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  25461. for (i = 0; i < paddedLength;) {
  25462. for (j = 0; j < 16; ++j) {
  25463. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25464. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  25465. i += 8;
  25466. }
  25467. for (j = 16; j < 80; ++j) {
  25468. tmp3 = w[j];
  25469. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  25470. tmp3.add(w[j - 7]);
  25471. littleSigma(tmp1, w[j - 15], tmp2);
  25472. tmp3.add(tmp1);
  25473. tmp3.add(w[j - 16]);
  25474. }
  25475. a.assign(h0);
  25476. b.assign(h1);
  25477. c.assign(h2);
  25478. d.assign(h3);
  25479. e.assign(h4);
  25480. f.assign(h5);
  25481. g.assign(h6);
  25482. h.assign(h7);
  25483. for (j = 0; j < 80; ++j) {
  25484. t1.assign(h);
  25485. sigmaPrime(tmp1, e, tmp2);
  25486. t1.add(tmp1);
  25487. ch(tmp1, e, f, g, tmp2);
  25488. t1.add(tmp1);
  25489. t1.add(k[j]);
  25490. t1.add(w[j]);
  25491. sigma(t2, a, tmp2);
  25492. maj(tmp1, a, b, c, tmp2);
  25493. t2.add(tmp1);
  25494. tmp3 = h;
  25495. h = g;
  25496. g = f;
  25497. f = e;
  25498. d.add(t1);
  25499. e = d;
  25500. d = c;
  25501. c = b;
  25502. b = a;
  25503. tmp3.assign(t1);
  25504. tmp3.add(t2);
  25505. a = tmp3;
  25506. }
  25507. h0.add(a);
  25508. h1.add(b);
  25509. h2.add(c);
  25510. h3.add(d);
  25511. h4.add(e);
  25512. h5.add(f);
  25513. h6.add(g);
  25514. h7.add(h);
  25515. }
  25516. var result;
  25517. if (!mode384) {
  25518. result = new Uint8Array(64);
  25519. h0.copyTo(result, 0);
  25520. h1.copyTo(result, 8);
  25521. h2.copyTo(result, 16);
  25522. h3.copyTo(result, 24);
  25523. h4.copyTo(result, 32);
  25524. h5.copyTo(result, 40);
  25525. h6.copyTo(result, 48);
  25526. h7.copyTo(result, 56);
  25527. } else {
  25528. result = new Uint8Array(48);
  25529. h0.copyTo(result, 0);
  25530. h1.copyTo(result, 8);
  25531. h2.copyTo(result, 16);
  25532. h3.copyTo(result, 24);
  25533. h4.copyTo(result, 32);
  25534. h5.copyTo(result, 40);
  25535. }
  25536. return result;
  25537. }
  25538. return hash;
  25539. }();
  25540. var calculateSHA384 = function calculateSHA384Closure() {
  25541. function hash(data, offset, length) {
  25542. return calculateSHA512(data, offset, length, true);
  25543. }
  25544. return hash;
  25545. }();
  25546. var NullCipher = function NullCipherClosure() {
  25547. function NullCipher() {
  25548. }
  25549. NullCipher.prototype = {
  25550. decryptBlock: function NullCipher_decryptBlock(data) {
  25551. return data;
  25552. }
  25553. };
  25554. return NullCipher;
  25555. }();
  25556. var AES128Cipher = function AES128CipherClosure() {
  25557. var rcon = new Uint8Array([
  25558. 0x8d,
  25559. 0x01,
  25560. 0x02,
  25561. 0x04,
  25562. 0x08,
  25563. 0x10,
  25564. 0x20,
  25565. 0x40,
  25566. 0x80,
  25567. 0x1b,
  25568. 0x36,
  25569. 0x6c,
  25570. 0xd8,
  25571. 0xab,
  25572. 0x4d,
  25573. 0x9a,
  25574. 0x2f,
  25575. 0x5e,
  25576. 0xbc,
  25577. 0x63,
  25578. 0xc6,
  25579. 0x97,
  25580. 0x35,
  25581. 0x6a,
  25582. 0xd4,
  25583. 0xb3,
  25584. 0x7d,
  25585. 0xfa,
  25586. 0xef,
  25587. 0xc5,
  25588. 0x91,
  25589. 0x39,
  25590. 0x72,
  25591. 0xe4,
  25592. 0xd3,
  25593. 0xbd,
  25594. 0x61,
  25595. 0xc2,
  25596. 0x9f,
  25597. 0x25,
  25598. 0x4a,
  25599. 0x94,
  25600. 0x33,
  25601. 0x66,
  25602. 0xcc,
  25603. 0x83,
  25604. 0x1d,
  25605. 0x3a,
  25606. 0x74,
  25607. 0xe8,
  25608. 0xcb,
  25609. 0x8d,
  25610. 0x01,
  25611. 0x02,
  25612. 0x04,
  25613. 0x08,
  25614. 0x10,
  25615. 0x20,
  25616. 0x40,
  25617. 0x80,
  25618. 0x1b,
  25619. 0x36,
  25620. 0x6c,
  25621. 0xd8,
  25622. 0xab,
  25623. 0x4d,
  25624. 0x9a,
  25625. 0x2f,
  25626. 0x5e,
  25627. 0xbc,
  25628. 0x63,
  25629. 0xc6,
  25630. 0x97,
  25631. 0x35,
  25632. 0x6a,
  25633. 0xd4,
  25634. 0xb3,
  25635. 0x7d,
  25636. 0xfa,
  25637. 0xef,
  25638. 0xc5,
  25639. 0x91,
  25640. 0x39,
  25641. 0x72,
  25642. 0xe4,
  25643. 0xd3,
  25644. 0xbd,
  25645. 0x61,
  25646. 0xc2,
  25647. 0x9f,
  25648. 0x25,
  25649. 0x4a,
  25650. 0x94,
  25651. 0x33,
  25652. 0x66,
  25653. 0xcc,
  25654. 0x83,
  25655. 0x1d,
  25656. 0x3a,
  25657. 0x74,
  25658. 0xe8,
  25659. 0xcb,
  25660. 0x8d,
  25661. 0x01,
  25662. 0x02,
  25663. 0x04,
  25664. 0x08,
  25665. 0x10,
  25666. 0x20,
  25667. 0x40,
  25668. 0x80,
  25669. 0x1b,
  25670. 0x36,
  25671. 0x6c,
  25672. 0xd8,
  25673. 0xab,
  25674. 0x4d,
  25675. 0x9a,
  25676. 0x2f,
  25677. 0x5e,
  25678. 0xbc,
  25679. 0x63,
  25680. 0xc6,
  25681. 0x97,
  25682. 0x35,
  25683. 0x6a,
  25684. 0xd4,
  25685. 0xb3,
  25686. 0x7d,
  25687. 0xfa,
  25688. 0xef,
  25689. 0xc5,
  25690. 0x91,
  25691. 0x39,
  25692. 0x72,
  25693. 0xe4,
  25694. 0xd3,
  25695. 0xbd,
  25696. 0x61,
  25697. 0xc2,
  25698. 0x9f,
  25699. 0x25,
  25700. 0x4a,
  25701. 0x94,
  25702. 0x33,
  25703. 0x66,
  25704. 0xcc,
  25705. 0x83,
  25706. 0x1d,
  25707. 0x3a,
  25708. 0x74,
  25709. 0xe8,
  25710. 0xcb,
  25711. 0x8d,
  25712. 0x01,
  25713. 0x02,
  25714. 0x04,
  25715. 0x08,
  25716. 0x10,
  25717. 0x20,
  25718. 0x40,
  25719. 0x80,
  25720. 0x1b,
  25721. 0x36,
  25722. 0x6c,
  25723. 0xd8,
  25724. 0xab,
  25725. 0x4d,
  25726. 0x9a,
  25727. 0x2f,
  25728. 0x5e,
  25729. 0xbc,
  25730. 0x63,
  25731. 0xc6,
  25732. 0x97,
  25733. 0x35,
  25734. 0x6a,
  25735. 0xd4,
  25736. 0xb3,
  25737. 0x7d,
  25738. 0xfa,
  25739. 0xef,
  25740. 0xc5,
  25741. 0x91,
  25742. 0x39,
  25743. 0x72,
  25744. 0xe4,
  25745. 0xd3,
  25746. 0xbd,
  25747. 0x61,
  25748. 0xc2,
  25749. 0x9f,
  25750. 0x25,
  25751. 0x4a,
  25752. 0x94,
  25753. 0x33,
  25754. 0x66,
  25755. 0xcc,
  25756. 0x83,
  25757. 0x1d,
  25758. 0x3a,
  25759. 0x74,
  25760. 0xe8,
  25761. 0xcb,
  25762. 0x8d,
  25763. 0x01,
  25764. 0x02,
  25765. 0x04,
  25766. 0x08,
  25767. 0x10,
  25768. 0x20,
  25769. 0x40,
  25770. 0x80,
  25771. 0x1b,
  25772. 0x36,
  25773. 0x6c,
  25774. 0xd8,
  25775. 0xab,
  25776. 0x4d,
  25777. 0x9a,
  25778. 0x2f,
  25779. 0x5e,
  25780. 0xbc,
  25781. 0x63,
  25782. 0xc6,
  25783. 0x97,
  25784. 0x35,
  25785. 0x6a,
  25786. 0xd4,
  25787. 0xb3,
  25788. 0x7d,
  25789. 0xfa,
  25790. 0xef,
  25791. 0xc5,
  25792. 0x91,
  25793. 0x39,
  25794. 0x72,
  25795. 0xe4,
  25796. 0xd3,
  25797. 0xbd,
  25798. 0x61,
  25799. 0xc2,
  25800. 0x9f,
  25801. 0x25,
  25802. 0x4a,
  25803. 0x94,
  25804. 0x33,
  25805. 0x66,
  25806. 0xcc,
  25807. 0x83,
  25808. 0x1d,
  25809. 0x3a,
  25810. 0x74,
  25811. 0xe8,
  25812. 0xcb,
  25813. 0x8d
  25814. ]);
  25815. var s = new Uint8Array([
  25816. 0x63,
  25817. 0x7c,
  25818. 0x77,
  25819. 0x7b,
  25820. 0xf2,
  25821. 0x6b,
  25822. 0x6f,
  25823. 0xc5,
  25824. 0x30,
  25825. 0x01,
  25826. 0x67,
  25827. 0x2b,
  25828. 0xfe,
  25829. 0xd7,
  25830. 0xab,
  25831. 0x76,
  25832. 0xca,
  25833. 0x82,
  25834. 0xc9,
  25835. 0x7d,
  25836. 0xfa,
  25837. 0x59,
  25838. 0x47,
  25839. 0xf0,
  25840. 0xad,
  25841. 0xd4,
  25842. 0xa2,
  25843. 0xaf,
  25844. 0x9c,
  25845. 0xa4,
  25846. 0x72,
  25847. 0xc0,
  25848. 0xb7,
  25849. 0xfd,
  25850. 0x93,
  25851. 0x26,
  25852. 0x36,
  25853. 0x3f,
  25854. 0xf7,
  25855. 0xcc,
  25856. 0x34,
  25857. 0xa5,
  25858. 0xe5,
  25859. 0xf1,
  25860. 0x71,
  25861. 0xd8,
  25862. 0x31,
  25863. 0x15,
  25864. 0x04,
  25865. 0xc7,
  25866. 0x23,
  25867. 0xc3,
  25868. 0x18,
  25869. 0x96,
  25870. 0x05,
  25871. 0x9a,
  25872. 0x07,
  25873. 0x12,
  25874. 0x80,
  25875. 0xe2,
  25876. 0xeb,
  25877. 0x27,
  25878. 0xb2,
  25879. 0x75,
  25880. 0x09,
  25881. 0x83,
  25882. 0x2c,
  25883. 0x1a,
  25884. 0x1b,
  25885. 0x6e,
  25886. 0x5a,
  25887. 0xa0,
  25888. 0x52,
  25889. 0x3b,
  25890. 0xd6,
  25891. 0xb3,
  25892. 0x29,
  25893. 0xe3,
  25894. 0x2f,
  25895. 0x84,
  25896. 0x53,
  25897. 0xd1,
  25898. 0x00,
  25899. 0xed,
  25900. 0x20,
  25901. 0xfc,
  25902. 0xb1,
  25903. 0x5b,
  25904. 0x6a,
  25905. 0xcb,
  25906. 0xbe,
  25907. 0x39,
  25908. 0x4a,
  25909. 0x4c,
  25910. 0x58,
  25911. 0xcf,
  25912. 0xd0,
  25913. 0xef,
  25914. 0xaa,
  25915. 0xfb,
  25916. 0x43,
  25917. 0x4d,
  25918. 0x33,
  25919. 0x85,
  25920. 0x45,
  25921. 0xf9,
  25922. 0x02,
  25923. 0x7f,
  25924. 0x50,
  25925. 0x3c,
  25926. 0x9f,
  25927. 0xa8,
  25928. 0x51,
  25929. 0xa3,
  25930. 0x40,
  25931. 0x8f,
  25932. 0x92,
  25933. 0x9d,
  25934. 0x38,
  25935. 0xf5,
  25936. 0xbc,
  25937. 0xb6,
  25938. 0xda,
  25939. 0x21,
  25940. 0x10,
  25941. 0xff,
  25942. 0xf3,
  25943. 0xd2,
  25944. 0xcd,
  25945. 0x0c,
  25946. 0x13,
  25947. 0xec,
  25948. 0x5f,
  25949. 0x97,
  25950. 0x44,
  25951. 0x17,
  25952. 0xc4,
  25953. 0xa7,
  25954. 0x7e,
  25955. 0x3d,
  25956. 0x64,
  25957. 0x5d,
  25958. 0x19,
  25959. 0x73,
  25960. 0x60,
  25961. 0x81,
  25962. 0x4f,
  25963. 0xdc,
  25964. 0x22,
  25965. 0x2a,
  25966. 0x90,
  25967. 0x88,
  25968. 0x46,
  25969. 0xee,
  25970. 0xb8,
  25971. 0x14,
  25972. 0xde,
  25973. 0x5e,
  25974. 0x0b,
  25975. 0xdb,
  25976. 0xe0,
  25977. 0x32,
  25978. 0x3a,
  25979. 0x0a,
  25980. 0x49,
  25981. 0x06,
  25982. 0x24,
  25983. 0x5c,
  25984. 0xc2,
  25985. 0xd3,
  25986. 0xac,
  25987. 0x62,
  25988. 0x91,
  25989. 0x95,
  25990. 0xe4,
  25991. 0x79,
  25992. 0xe7,
  25993. 0xc8,
  25994. 0x37,
  25995. 0x6d,
  25996. 0x8d,
  25997. 0xd5,
  25998. 0x4e,
  25999. 0xa9,
  26000. 0x6c,
  26001. 0x56,
  26002. 0xf4,
  26003. 0xea,
  26004. 0x65,
  26005. 0x7a,
  26006. 0xae,
  26007. 0x08,
  26008. 0xba,
  26009. 0x78,
  26010. 0x25,
  26011. 0x2e,
  26012. 0x1c,
  26013. 0xa6,
  26014. 0xb4,
  26015. 0xc6,
  26016. 0xe8,
  26017. 0xdd,
  26018. 0x74,
  26019. 0x1f,
  26020. 0x4b,
  26021. 0xbd,
  26022. 0x8b,
  26023. 0x8a,
  26024. 0x70,
  26025. 0x3e,
  26026. 0xb5,
  26027. 0x66,
  26028. 0x48,
  26029. 0x03,
  26030. 0xf6,
  26031. 0x0e,
  26032. 0x61,
  26033. 0x35,
  26034. 0x57,
  26035. 0xb9,
  26036. 0x86,
  26037. 0xc1,
  26038. 0x1d,
  26039. 0x9e,
  26040. 0xe1,
  26041. 0xf8,
  26042. 0x98,
  26043. 0x11,
  26044. 0x69,
  26045. 0xd9,
  26046. 0x8e,
  26047. 0x94,
  26048. 0x9b,
  26049. 0x1e,
  26050. 0x87,
  26051. 0xe9,
  26052. 0xce,
  26053. 0x55,
  26054. 0x28,
  26055. 0xdf,
  26056. 0x8c,
  26057. 0xa1,
  26058. 0x89,
  26059. 0x0d,
  26060. 0xbf,
  26061. 0xe6,
  26062. 0x42,
  26063. 0x68,
  26064. 0x41,
  26065. 0x99,
  26066. 0x2d,
  26067. 0x0f,
  26068. 0xb0,
  26069. 0x54,
  26070. 0xbb,
  26071. 0x16
  26072. ]);
  26073. var inv_s = new Uint8Array([
  26074. 0x52,
  26075. 0x09,
  26076. 0x6a,
  26077. 0xd5,
  26078. 0x30,
  26079. 0x36,
  26080. 0xa5,
  26081. 0x38,
  26082. 0xbf,
  26083. 0x40,
  26084. 0xa3,
  26085. 0x9e,
  26086. 0x81,
  26087. 0xf3,
  26088. 0xd7,
  26089. 0xfb,
  26090. 0x7c,
  26091. 0xe3,
  26092. 0x39,
  26093. 0x82,
  26094. 0x9b,
  26095. 0x2f,
  26096. 0xff,
  26097. 0x87,
  26098. 0x34,
  26099. 0x8e,
  26100. 0x43,
  26101. 0x44,
  26102. 0xc4,
  26103. 0xde,
  26104. 0xe9,
  26105. 0xcb,
  26106. 0x54,
  26107. 0x7b,
  26108. 0x94,
  26109. 0x32,
  26110. 0xa6,
  26111. 0xc2,
  26112. 0x23,
  26113. 0x3d,
  26114. 0xee,
  26115. 0x4c,
  26116. 0x95,
  26117. 0x0b,
  26118. 0x42,
  26119. 0xfa,
  26120. 0xc3,
  26121. 0x4e,
  26122. 0x08,
  26123. 0x2e,
  26124. 0xa1,
  26125. 0x66,
  26126. 0x28,
  26127. 0xd9,
  26128. 0x24,
  26129. 0xb2,
  26130. 0x76,
  26131. 0x5b,
  26132. 0xa2,
  26133. 0x49,
  26134. 0x6d,
  26135. 0x8b,
  26136. 0xd1,
  26137. 0x25,
  26138. 0x72,
  26139. 0xf8,
  26140. 0xf6,
  26141. 0x64,
  26142. 0x86,
  26143. 0x68,
  26144. 0x98,
  26145. 0x16,
  26146. 0xd4,
  26147. 0xa4,
  26148. 0x5c,
  26149. 0xcc,
  26150. 0x5d,
  26151. 0x65,
  26152. 0xb6,
  26153. 0x92,
  26154. 0x6c,
  26155. 0x70,
  26156. 0x48,
  26157. 0x50,
  26158. 0xfd,
  26159. 0xed,
  26160. 0xb9,
  26161. 0xda,
  26162. 0x5e,
  26163. 0x15,
  26164. 0x46,
  26165. 0x57,
  26166. 0xa7,
  26167. 0x8d,
  26168. 0x9d,
  26169. 0x84,
  26170. 0x90,
  26171. 0xd8,
  26172. 0xab,
  26173. 0x00,
  26174. 0x8c,
  26175. 0xbc,
  26176. 0xd3,
  26177. 0x0a,
  26178. 0xf7,
  26179. 0xe4,
  26180. 0x58,
  26181. 0x05,
  26182. 0xb8,
  26183. 0xb3,
  26184. 0x45,
  26185. 0x06,
  26186. 0xd0,
  26187. 0x2c,
  26188. 0x1e,
  26189. 0x8f,
  26190. 0xca,
  26191. 0x3f,
  26192. 0x0f,
  26193. 0x02,
  26194. 0xc1,
  26195. 0xaf,
  26196. 0xbd,
  26197. 0x03,
  26198. 0x01,
  26199. 0x13,
  26200. 0x8a,
  26201. 0x6b,
  26202. 0x3a,
  26203. 0x91,
  26204. 0x11,
  26205. 0x41,
  26206. 0x4f,
  26207. 0x67,
  26208. 0xdc,
  26209. 0xea,
  26210. 0x97,
  26211. 0xf2,
  26212. 0xcf,
  26213. 0xce,
  26214. 0xf0,
  26215. 0xb4,
  26216. 0xe6,
  26217. 0x73,
  26218. 0x96,
  26219. 0xac,
  26220. 0x74,
  26221. 0x22,
  26222. 0xe7,
  26223. 0xad,
  26224. 0x35,
  26225. 0x85,
  26226. 0xe2,
  26227. 0xf9,
  26228. 0x37,
  26229. 0xe8,
  26230. 0x1c,
  26231. 0x75,
  26232. 0xdf,
  26233. 0x6e,
  26234. 0x47,
  26235. 0xf1,
  26236. 0x1a,
  26237. 0x71,
  26238. 0x1d,
  26239. 0x29,
  26240. 0xc5,
  26241. 0x89,
  26242. 0x6f,
  26243. 0xb7,
  26244. 0x62,
  26245. 0x0e,
  26246. 0xaa,
  26247. 0x18,
  26248. 0xbe,
  26249. 0x1b,
  26250. 0xfc,
  26251. 0x56,
  26252. 0x3e,
  26253. 0x4b,
  26254. 0xc6,
  26255. 0xd2,
  26256. 0x79,
  26257. 0x20,
  26258. 0x9a,
  26259. 0xdb,
  26260. 0xc0,
  26261. 0xfe,
  26262. 0x78,
  26263. 0xcd,
  26264. 0x5a,
  26265. 0xf4,
  26266. 0x1f,
  26267. 0xdd,
  26268. 0xa8,
  26269. 0x33,
  26270. 0x88,
  26271. 0x07,
  26272. 0xc7,
  26273. 0x31,
  26274. 0xb1,
  26275. 0x12,
  26276. 0x10,
  26277. 0x59,
  26278. 0x27,
  26279. 0x80,
  26280. 0xec,
  26281. 0x5f,
  26282. 0x60,
  26283. 0x51,
  26284. 0x7f,
  26285. 0xa9,
  26286. 0x19,
  26287. 0xb5,
  26288. 0x4a,
  26289. 0x0d,
  26290. 0x2d,
  26291. 0xe5,
  26292. 0x7a,
  26293. 0x9f,
  26294. 0x93,
  26295. 0xc9,
  26296. 0x9c,
  26297. 0xef,
  26298. 0xa0,
  26299. 0xe0,
  26300. 0x3b,
  26301. 0x4d,
  26302. 0xae,
  26303. 0x2a,
  26304. 0xf5,
  26305. 0xb0,
  26306. 0xc8,
  26307. 0xeb,
  26308. 0xbb,
  26309. 0x3c,
  26310. 0x83,
  26311. 0x53,
  26312. 0x99,
  26313. 0x61,
  26314. 0x17,
  26315. 0x2b,
  26316. 0x04,
  26317. 0x7e,
  26318. 0xba,
  26319. 0x77,
  26320. 0xd6,
  26321. 0x26,
  26322. 0xe1,
  26323. 0x69,
  26324. 0x14,
  26325. 0x63,
  26326. 0x55,
  26327. 0x21,
  26328. 0x0c,
  26329. 0x7d
  26330. ]);
  26331. var mixCol = new Uint8Array(256);
  26332. for (var i = 0; i < 256; i++) {
  26333. if (i < 128) {
  26334. mixCol[i] = i << 1;
  26335. } else {
  26336. mixCol[i] = i << 1 ^ 0x1b;
  26337. }
  26338. }
  26339. var mix = new Uint32Array([
  26340. 0x00000000,
  26341. 0x0e090d0b,
  26342. 0x1c121a16,
  26343. 0x121b171d,
  26344. 0x3824342c,
  26345. 0x362d3927,
  26346. 0x24362e3a,
  26347. 0x2a3f2331,
  26348. 0x70486858,
  26349. 0x7e416553,
  26350. 0x6c5a724e,
  26351. 0x62537f45,
  26352. 0x486c5c74,
  26353. 0x4665517f,
  26354. 0x547e4662,
  26355. 0x5a774b69,
  26356. 0xe090d0b0,
  26357. 0xee99ddbb,
  26358. 0xfc82caa6,
  26359. 0xf28bc7ad,
  26360. 0xd8b4e49c,
  26361. 0xd6bde997,
  26362. 0xc4a6fe8a,
  26363. 0xcaaff381,
  26364. 0x90d8b8e8,
  26365. 0x9ed1b5e3,
  26366. 0x8ccaa2fe,
  26367. 0x82c3aff5,
  26368. 0xa8fc8cc4,
  26369. 0xa6f581cf,
  26370. 0xb4ee96d2,
  26371. 0xbae79bd9,
  26372. 0xdb3bbb7b,
  26373. 0xd532b670,
  26374. 0xc729a16d,
  26375. 0xc920ac66,
  26376. 0xe31f8f57,
  26377. 0xed16825c,
  26378. 0xff0d9541,
  26379. 0xf104984a,
  26380. 0xab73d323,
  26381. 0xa57ade28,
  26382. 0xb761c935,
  26383. 0xb968c43e,
  26384. 0x9357e70f,
  26385. 0x9d5eea04,
  26386. 0x8f45fd19,
  26387. 0x814cf012,
  26388. 0x3bab6bcb,
  26389. 0x35a266c0,
  26390. 0x27b971dd,
  26391. 0x29b07cd6,
  26392. 0x038f5fe7,
  26393. 0x0d8652ec,
  26394. 0x1f9d45f1,
  26395. 0x119448fa,
  26396. 0x4be30393,
  26397. 0x45ea0e98,
  26398. 0x57f11985,
  26399. 0x59f8148e,
  26400. 0x73c737bf,
  26401. 0x7dce3ab4,
  26402. 0x6fd52da9,
  26403. 0x61dc20a2,
  26404. 0xad766df6,
  26405. 0xa37f60fd,
  26406. 0xb16477e0,
  26407. 0xbf6d7aeb,
  26408. 0x955259da,
  26409. 0x9b5b54d1,
  26410. 0x894043cc,
  26411. 0x87494ec7,
  26412. 0xdd3e05ae,
  26413. 0xd33708a5,
  26414. 0xc12c1fb8,
  26415. 0xcf2512b3,
  26416. 0xe51a3182,
  26417. 0xeb133c89,
  26418. 0xf9082b94,
  26419. 0xf701269f,
  26420. 0x4de6bd46,
  26421. 0x43efb04d,
  26422. 0x51f4a750,
  26423. 0x5ffdaa5b,
  26424. 0x75c2896a,
  26425. 0x7bcb8461,
  26426. 0x69d0937c,
  26427. 0x67d99e77,
  26428. 0x3daed51e,
  26429. 0x33a7d815,
  26430. 0x21bccf08,
  26431. 0x2fb5c203,
  26432. 0x058ae132,
  26433. 0x0b83ec39,
  26434. 0x1998fb24,
  26435. 0x1791f62f,
  26436. 0x764dd68d,
  26437. 0x7844db86,
  26438. 0x6a5fcc9b,
  26439. 0x6456c190,
  26440. 0x4e69e2a1,
  26441. 0x4060efaa,
  26442. 0x527bf8b7,
  26443. 0x5c72f5bc,
  26444. 0x0605bed5,
  26445. 0x080cb3de,
  26446. 0x1a17a4c3,
  26447. 0x141ea9c8,
  26448. 0x3e218af9,
  26449. 0x302887f2,
  26450. 0x223390ef,
  26451. 0x2c3a9de4,
  26452. 0x96dd063d,
  26453. 0x98d40b36,
  26454. 0x8acf1c2b,
  26455. 0x84c61120,
  26456. 0xaef93211,
  26457. 0xa0f03f1a,
  26458. 0xb2eb2807,
  26459. 0xbce2250c,
  26460. 0xe6956e65,
  26461. 0xe89c636e,
  26462. 0xfa877473,
  26463. 0xf48e7978,
  26464. 0xdeb15a49,
  26465. 0xd0b85742,
  26466. 0xc2a3405f,
  26467. 0xccaa4d54,
  26468. 0x41ecdaf7,
  26469. 0x4fe5d7fc,
  26470. 0x5dfec0e1,
  26471. 0x53f7cdea,
  26472. 0x79c8eedb,
  26473. 0x77c1e3d0,
  26474. 0x65daf4cd,
  26475. 0x6bd3f9c6,
  26476. 0x31a4b2af,
  26477. 0x3fadbfa4,
  26478. 0x2db6a8b9,
  26479. 0x23bfa5b2,
  26480. 0x09808683,
  26481. 0x07898b88,
  26482. 0x15929c95,
  26483. 0x1b9b919e,
  26484. 0xa17c0a47,
  26485. 0xaf75074c,
  26486. 0xbd6e1051,
  26487. 0xb3671d5a,
  26488. 0x99583e6b,
  26489. 0x97513360,
  26490. 0x854a247d,
  26491. 0x8b432976,
  26492. 0xd134621f,
  26493. 0xdf3d6f14,
  26494. 0xcd267809,
  26495. 0xc32f7502,
  26496. 0xe9105633,
  26497. 0xe7195b38,
  26498. 0xf5024c25,
  26499. 0xfb0b412e,
  26500. 0x9ad7618c,
  26501. 0x94de6c87,
  26502. 0x86c57b9a,
  26503. 0x88cc7691,
  26504. 0xa2f355a0,
  26505. 0xacfa58ab,
  26506. 0xbee14fb6,
  26507. 0xb0e842bd,
  26508. 0xea9f09d4,
  26509. 0xe49604df,
  26510. 0xf68d13c2,
  26511. 0xf8841ec9,
  26512. 0xd2bb3df8,
  26513. 0xdcb230f3,
  26514. 0xcea927ee,
  26515. 0xc0a02ae5,
  26516. 0x7a47b13c,
  26517. 0x744ebc37,
  26518. 0x6655ab2a,
  26519. 0x685ca621,
  26520. 0x42638510,
  26521. 0x4c6a881b,
  26522. 0x5e719f06,
  26523. 0x5078920d,
  26524. 0x0a0fd964,
  26525. 0x0406d46f,
  26526. 0x161dc372,
  26527. 0x1814ce79,
  26528. 0x322bed48,
  26529. 0x3c22e043,
  26530. 0x2e39f75e,
  26531. 0x2030fa55,
  26532. 0xec9ab701,
  26533. 0xe293ba0a,
  26534. 0xf088ad17,
  26535. 0xfe81a01c,
  26536. 0xd4be832d,
  26537. 0xdab78e26,
  26538. 0xc8ac993b,
  26539. 0xc6a59430,
  26540. 0x9cd2df59,
  26541. 0x92dbd252,
  26542. 0x80c0c54f,
  26543. 0x8ec9c844,
  26544. 0xa4f6eb75,
  26545. 0xaaffe67e,
  26546. 0xb8e4f163,
  26547. 0xb6edfc68,
  26548. 0x0c0a67b1,
  26549. 0x02036aba,
  26550. 0x10187da7,
  26551. 0x1e1170ac,
  26552. 0x342e539d,
  26553. 0x3a275e96,
  26554. 0x283c498b,
  26555. 0x26354480,
  26556. 0x7c420fe9,
  26557. 0x724b02e2,
  26558. 0x605015ff,
  26559. 0x6e5918f4,
  26560. 0x44663bc5,
  26561. 0x4a6f36ce,
  26562. 0x587421d3,
  26563. 0x567d2cd8,
  26564. 0x37a10c7a,
  26565. 0x39a80171,
  26566. 0x2bb3166c,
  26567. 0x25ba1b67,
  26568. 0x0f853856,
  26569. 0x018c355d,
  26570. 0x13972240,
  26571. 0x1d9e2f4b,
  26572. 0x47e96422,
  26573. 0x49e06929,
  26574. 0x5bfb7e34,
  26575. 0x55f2733f,
  26576. 0x7fcd500e,
  26577. 0x71c45d05,
  26578. 0x63df4a18,
  26579. 0x6dd64713,
  26580. 0xd731dcca,
  26581. 0xd938d1c1,
  26582. 0xcb23c6dc,
  26583. 0xc52acbd7,
  26584. 0xef15e8e6,
  26585. 0xe11ce5ed,
  26586. 0xf307f2f0,
  26587. 0xfd0efffb,
  26588. 0xa779b492,
  26589. 0xa970b999,
  26590. 0xbb6bae84,
  26591. 0xb562a38f,
  26592. 0x9f5d80be,
  26593. 0x91548db5,
  26594. 0x834f9aa8,
  26595. 0x8d4697a3
  26596. ]);
  26597. function expandKey128(cipherKey) {
  26598. var b = 176, result = new Uint8Array(b);
  26599. result.set(cipherKey);
  26600. for (var j = 16, i = 1; j < b; ++i) {
  26601. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  26602. t1 = s[t1];
  26603. t2 = s[t2];
  26604. t3 = s[t3];
  26605. t4 = s[t4];
  26606. t1 = t1 ^ rcon[i];
  26607. for (var n = 0; n < 4; ++n) {
  26608. result[j] = t1 ^= result[j - 16];
  26609. j++;
  26610. result[j] = t2 ^= result[j - 16];
  26611. j++;
  26612. result[j] = t3 ^= result[j - 16];
  26613. j++;
  26614. result[j] = t4 ^= result[j - 16];
  26615. j++;
  26616. }
  26617. }
  26618. return result;
  26619. }
  26620. function decrypt128(input, key) {
  26621. var state = new Uint8Array(16);
  26622. state.set(input);
  26623. var i, j, k;
  26624. var t, u, v;
  26625. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26626. state[j] ^= key[k];
  26627. }
  26628. for (i = 9; i >= 1; --i) {
  26629. t = state[13];
  26630. state[13] = state[9];
  26631. state[9] = state[5];
  26632. state[5] = state[1];
  26633. state[1] = t;
  26634. t = state[14];
  26635. u = state[10];
  26636. state[14] = state[6];
  26637. state[10] = state[2];
  26638. state[6] = t;
  26639. state[2] = u;
  26640. t = state[15];
  26641. u = state[11];
  26642. v = state[7];
  26643. state[15] = state[3];
  26644. state[11] = t;
  26645. state[7] = u;
  26646. state[3] = v;
  26647. for (j = 0; j < 16; ++j) {
  26648. state[j] = inv_s[state[j]];
  26649. }
  26650. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26651. state[j] ^= key[k];
  26652. }
  26653. for (j = 0; j < 16; j += 4) {
  26654. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  26655. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  26656. state[j] = t >>> 24 & 0xFF;
  26657. state[j + 1] = t >> 16 & 0xFF;
  26658. state[j + 2] = t >> 8 & 0xFF;
  26659. state[j + 3] = t & 0xFF;
  26660. }
  26661. }
  26662. t = state[13];
  26663. state[13] = state[9];
  26664. state[9] = state[5];
  26665. state[5] = state[1];
  26666. state[1] = t;
  26667. t = state[14];
  26668. u = state[10];
  26669. state[14] = state[6];
  26670. state[10] = state[2];
  26671. state[6] = t;
  26672. state[2] = u;
  26673. t = state[15];
  26674. u = state[11];
  26675. v = state[7];
  26676. state[15] = state[3];
  26677. state[11] = t;
  26678. state[7] = u;
  26679. state[3] = v;
  26680. for (j = 0; j < 16; ++j) {
  26681. state[j] = inv_s[state[j]];
  26682. state[j] ^= key[j];
  26683. }
  26684. return state;
  26685. }
  26686. function encrypt128(input, key) {
  26687. var t, u, v, k;
  26688. var state = new Uint8Array(16);
  26689. state.set(input);
  26690. for (j = 0; j < 16; ++j) {
  26691. state[j] ^= key[j];
  26692. }
  26693. for (i = 1; i < 10; i++) {
  26694. for (j = 0; j < 16; ++j) {
  26695. state[j] = s[state[j]];
  26696. }
  26697. v = state[1];
  26698. state[1] = state[5];
  26699. state[5] = state[9];
  26700. state[9] = state[13];
  26701. state[13] = v;
  26702. v = state[2];
  26703. u = state[6];
  26704. state[2] = state[10];
  26705. state[6] = state[14];
  26706. state[10] = v;
  26707. state[14] = u;
  26708. v = state[3];
  26709. u = state[7];
  26710. t = state[11];
  26711. state[3] = state[15];
  26712. state[7] = v;
  26713. state[11] = u;
  26714. state[15] = t;
  26715. for (var j = 0; j < 16; j += 4) {
  26716. var s0 = state[j + 0], s1 = state[j + 1];
  26717. var s2 = state[j + 2], s3 = state[j + 3];
  26718. t = s0 ^ s1 ^ s2 ^ s3;
  26719. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  26720. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  26721. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  26722. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  26723. }
  26724. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26725. state[j] ^= key[k];
  26726. }
  26727. }
  26728. for (j = 0; j < 16; ++j) {
  26729. state[j] = s[state[j]];
  26730. }
  26731. v = state[1];
  26732. state[1] = state[5];
  26733. state[5] = state[9];
  26734. state[9] = state[13];
  26735. state[13] = v;
  26736. v = state[2];
  26737. u = state[6];
  26738. state[2] = state[10];
  26739. state[6] = state[14];
  26740. state[10] = v;
  26741. state[14] = u;
  26742. v = state[3];
  26743. u = state[7];
  26744. t = state[11];
  26745. state[3] = state[15];
  26746. state[7] = v;
  26747. state[11] = u;
  26748. state[15] = t;
  26749. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26750. state[j] ^= key[k];
  26751. }
  26752. return state;
  26753. }
  26754. function AES128Cipher(key) {
  26755. this.key = expandKey128(key);
  26756. this.buffer = new Uint8Array(16);
  26757. this.bufferPosition = 0;
  26758. }
  26759. function decryptBlock2(data, finalize) {
  26760. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  26761. for (i = 0; i < sourceLength; ++i) {
  26762. buffer[bufferLength] = data[i];
  26763. ++bufferLength;
  26764. if (bufferLength < 16) {
  26765. continue;
  26766. }
  26767. var plain = decrypt128(buffer, this.key);
  26768. for (j = 0; j < 16; ++j) {
  26769. plain[j] ^= iv[j];
  26770. }
  26771. iv = buffer;
  26772. result.push(plain);
  26773. buffer = new Uint8Array(16);
  26774. bufferLength = 0;
  26775. }
  26776. this.buffer = buffer;
  26777. this.bufferLength = bufferLength;
  26778. this.iv = iv;
  26779. if (result.length === 0) {
  26780. return new Uint8Array([]);
  26781. }
  26782. var outputLength = 16 * result.length;
  26783. if (finalize) {
  26784. var lastBlock = result[result.length - 1];
  26785. var psLen = lastBlock[15];
  26786. if (psLen <= 16) {
  26787. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  26788. if (lastBlock[i] !== psLen) {
  26789. psLen = 0;
  26790. break;
  26791. }
  26792. }
  26793. outputLength -= psLen;
  26794. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  26795. }
  26796. }
  26797. var output = new Uint8Array(outputLength);
  26798. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26799. output.set(result[i], j);
  26800. }
  26801. return output;
  26802. }
  26803. AES128Cipher.prototype = {
  26804. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  26805. var i, sourceLength = data.length;
  26806. var buffer = this.buffer, bufferLength = this.bufferPosition;
  26807. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  26808. buffer[bufferLength] = data[i];
  26809. }
  26810. if (bufferLength < 16) {
  26811. this.bufferLength = bufferLength;
  26812. return new Uint8Array([]);
  26813. }
  26814. this.iv = buffer;
  26815. this.buffer = new Uint8Array(16);
  26816. this.bufferLength = 0;
  26817. this.decryptBlock = decryptBlock2;
  26818. return this.decryptBlock(data.subarray(16), finalize);
  26819. },
  26820. encrypt: function AES128Cipher_encrypt(data, iv) {
  26821. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  26822. if (!iv) {
  26823. iv = new Uint8Array(16);
  26824. }
  26825. for (i = 0; i < sourceLength; ++i) {
  26826. buffer[bufferLength] = data[i];
  26827. ++bufferLength;
  26828. if (bufferLength < 16) {
  26829. continue;
  26830. }
  26831. for (j = 0; j < 16; ++j) {
  26832. buffer[j] ^= iv[j];
  26833. }
  26834. var cipher = encrypt128(buffer, this.key);
  26835. iv = cipher;
  26836. result.push(cipher);
  26837. buffer = new Uint8Array(16);
  26838. bufferLength = 0;
  26839. }
  26840. this.buffer = buffer;
  26841. this.bufferLength = bufferLength;
  26842. this.iv = iv;
  26843. if (result.length === 0) {
  26844. return new Uint8Array([]);
  26845. }
  26846. var outputLength = 16 * result.length;
  26847. var output = new Uint8Array(outputLength);
  26848. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26849. output.set(result[i], j);
  26850. }
  26851. return output;
  26852. }
  26853. };
  26854. return AES128Cipher;
  26855. }();
  26856. var AES256Cipher = function AES256CipherClosure() {
  26857. var s = new Uint8Array([
  26858. 0x63,
  26859. 0x7c,
  26860. 0x77,
  26861. 0x7b,
  26862. 0xf2,
  26863. 0x6b,
  26864. 0x6f,
  26865. 0xc5,
  26866. 0x30,
  26867. 0x01,
  26868. 0x67,
  26869. 0x2b,
  26870. 0xfe,
  26871. 0xd7,
  26872. 0xab,
  26873. 0x76,
  26874. 0xca,
  26875. 0x82,
  26876. 0xc9,
  26877. 0x7d,
  26878. 0xfa,
  26879. 0x59,
  26880. 0x47,
  26881. 0xf0,
  26882. 0xad,
  26883. 0xd4,
  26884. 0xa2,
  26885. 0xaf,
  26886. 0x9c,
  26887. 0xa4,
  26888. 0x72,
  26889. 0xc0,
  26890. 0xb7,
  26891. 0xfd,
  26892. 0x93,
  26893. 0x26,
  26894. 0x36,
  26895. 0x3f,
  26896. 0xf7,
  26897. 0xcc,
  26898. 0x34,
  26899. 0xa5,
  26900. 0xe5,
  26901. 0xf1,
  26902. 0x71,
  26903. 0xd8,
  26904. 0x31,
  26905. 0x15,
  26906. 0x04,
  26907. 0xc7,
  26908. 0x23,
  26909. 0xc3,
  26910. 0x18,
  26911. 0x96,
  26912. 0x05,
  26913. 0x9a,
  26914. 0x07,
  26915. 0x12,
  26916. 0x80,
  26917. 0xe2,
  26918. 0xeb,
  26919. 0x27,
  26920. 0xb2,
  26921. 0x75,
  26922. 0x09,
  26923. 0x83,
  26924. 0x2c,
  26925. 0x1a,
  26926. 0x1b,
  26927. 0x6e,
  26928. 0x5a,
  26929. 0xa0,
  26930. 0x52,
  26931. 0x3b,
  26932. 0xd6,
  26933. 0xb3,
  26934. 0x29,
  26935. 0xe3,
  26936. 0x2f,
  26937. 0x84,
  26938. 0x53,
  26939. 0xd1,
  26940. 0x00,
  26941. 0xed,
  26942. 0x20,
  26943. 0xfc,
  26944. 0xb1,
  26945. 0x5b,
  26946. 0x6a,
  26947. 0xcb,
  26948. 0xbe,
  26949. 0x39,
  26950. 0x4a,
  26951. 0x4c,
  26952. 0x58,
  26953. 0xcf,
  26954. 0xd0,
  26955. 0xef,
  26956. 0xaa,
  26957. 0xfb,
  26958. 0x43,
  26959. 0x4d,
  26960. 0x33,
  26961. 0x85,
  26962. 0x45,
  26963. 0xf9,
  26964. 0x02,
  26965. 0x7f,
  26966. 0x50,
  26967. 0x3c,
  26968. 0x9f,
  26969. 0xa8,
  26970. 0x51,
  26971. 0xa3,
  26972. 0x40,
  26973. 0x8f,
  26974. 0x92,
  26975. 0x9d,
  26976. 0x38,
  26977. 0xf5,
  26978. 0xbc,
  26979. 0xb6,
  26980. 0xda,
  26981. 0x21,
  26982. 0x10,
  26983. 0xff,
  26984. 0xf3,
  26985. 0xd2,
  26986. 0xcd,
  26987. 0x0c,
  26988. 0x13,
  26989. 0xec,
  26990. 0x5f,
  26991. 0x97,
  26992. 0x44,
  26993. 0x17,
  26994. 0xc4,
  26995. 0xa7,
  26996. 0x7e,
  26997. 0x3d,
  26998. 0x64,
  26999. 0x5d,
  27000. 0x19,
  27001. 0x73,
  27002. 0x60,
  27003. 0x81,
  27004. 0x4f,
  27005. 0xdc,
  27006. 0x22,
  27007. 0x2a,
  27008. 0x90,
  27009. 0x88,
  27010. 0x46,
  27011. 0xee,
  27012. 0xb8,
  27013. 0x14,
  27014. 0xde,
  27015. 0x5e,
  27016. 0x0b,
  27017. 0xdb,
  27018. 0xe0,
  27019. 0x32,
  27020. 0x3a,
  27021. 0x0a,
  27022. 0x49,
  27023. 0x06,
  27024. 0x24,
  27025. 0x5c,
  27026. 0xc2,
  27027. 0xd3,
  27028. 0xac,
  27029. 0x62,
  27030. 0x91,
  27031. 0x95,
  27032. 0xe4,
  27033. 0x79,
  27034. 0xe7,
  27035. 0xc8,
  27036. 0x37,
  27037. 0x6d,
  27038. 0x8d,
  27039. 0xd5,
  27040. 0x4e,
  27041. 0xa9,
  27042. 0x6c,
  27043. 0x56,
  27044. 0xf4,
  27045. 0xea,
  27046. 0x65,
  27047. 0x7a,
  27048. 0xae,
  27049. 0x08,
  27050. 0xba,
  27051. 0x78,
  27052. 0x25,
  27053. 0x2e,
  27054. 0x1c,
  27055. 0xa6,
  27056. 0xb4,
  27057. 0xc6,
  27058. 0xe8,
  27059. 0xdd,
  27060. 0x74,
  27061. 0x1f,
  27062. 0x4b,
  27063. 0xbd,
  27064. 0x8b,
  27065. 0x8a,
  27066. 0x70,
  27067. 0x3e,
  27068. 0xb5,
  27069. 0x66,
  27070. 0x48,
  27071. 0x03,
  27072. 0xf6,
  27073. 0x0e,
  27074. 0x61,
  27075. 0x35,
  27076. 0x57,
  27077. 0xb9,
  27078. 0x86,
  27079. 0xc1,
  27080. 0x1d,
  27081. 0x9e,
  27082. 0xe1,
  27083. 0xf8,
  27084. 0x98,
  27085. 0x11,
  27086. 0x69,
  27087. 0xd9,
  27088. 0x8e,
  27089. 0x94,
  27090. 0x9b,
  27091. 0x1e,
  27092. 0x87,
  27093. 0xe9,
  27094. 0xce,
  27095. 0x55,
  27096. 0x28,
  27097. 0xdf,
  27098. 0x8c,
  27099. 0xa1,
  27100. 0x89,
  27101. 0x0d,
  27102. 0xbf,
  27103. 0xe6,
  27104. 0x42,
  27105. 0x68,
  27106. 0x41,
  27107. 0x99,
  27108. 0x2d,
  27109. 0x0f,
  27110. 0xb0,
  27111. 0x54,
  27112. 0xbb,
  27113. 0x16
  27114. ]);
  27115. var inv_s = new Uint8Array([
  27116. 0x52,
  27117. 0x09,
  27118. 0x6a,
  27119. 0xd5,
  27120. 0x30,
  27121. 0x36,
  27122. 0xa5,
  27123. 0x38,
  27124. 0xbf,
  27125. 0x40,
  27126. 0xa3,
  27127. 0x9e,
  27128. 0x81,
  27129. 0xf3,
  27130. 0xd7,
  27131. 0xfb,
  27132. 0x7c,
  27133. 0xe3,
  27134. 0x39,
  27135. 0x82,
  27136. 0x9b,
  27137. 0x2f,
  27138. 0xff,
  27139. 0x87,
  27140. 0x34,
  27141. 0x8e,
  27142. 0x43,
  27143. 0x44,
  27144. 0xc4,
  27145. 0xde,
  27146. 0xe9,
  27147. 0xcb,
  27148. 0x54,
  27149. 0x7b,
  27150. 0x94,
  27151. 0x32,
  27152. 0xa6,
  27153. 0xc2,
  27154. 0x23,
  27155. 0x3d,
  27156. 0xee,
  27157. 0x4c,
  27158. 0x95,
  27159. 0x0b,
  27160. 0x42,
  27161. 0xfa,
  27162. 0xc3,
  27163. 0x4e,
  27164. 0x08,
  27165. 0x2e,
  27166. 0xa1,
  27167. 0x66,
  27168. 0x28,
  27169. 0xd9,
  27170. 0x24,
  27171. 0xb2,
  27172. 0x76,
  27173. 0x5b,
  27174. 0xa2,
  27175. 0x49,
  27176. 0x6d,
  27177. 0x8b,
  27178. 0xd1,
  27179. 0x25,
  27180. 0x72,
  27181. 0xf8,
  27182. 0xf6,
  27183. 0x64,
  27184. 0x86,
  27185. 0x68,
  27186. 0x98,
  27187. 0x16,
  27188. 0xd4,
  27189. 0xa4,
  27190. 0x5c,
  27191. 0xcc,
  27192. 0x5d,
  27193. 0x65,
  27194. 0xb6,
  27195. 0x92,
  27196. 0x6c,
  27197. 0x70,
  27198. 0x48,
  27199. 0x50,
  27200. 0xfd,
  27201. 0xed,
  27202. 0xb9,
  27203. 0xda,
  27204. 0x5e,
  27205. 0x15,
  27206. 0x46,
  27207. 0x57,
  27208. 0xa7,
  27209. 0x8d,
  27210. 0x9d,
  27211. 0x84,
  27212. 0x90,
  27213. 0xd8,
  27214. 0xab,
  27215. 0x00,
  27216. 0x8c,
  27217. 0xbc,
  27218. 0xd3,
  27219. 0x0a,
  27220. 0xf7,
  27221. 0xe4,
  27222. 0x58,
  27223. 0x05,
  27224. 0xb8,
  27225. 0xb3,
  27226. 0x45,
  27227. 0x06,
  27228. 0xd0,
  27229. 0x2c,
  27230. 0x1e,
  27231. 0x8f,
  27232. 0xca,
  27233. 0x3f,
  27234. 0x0f,
  27235. 0x02,
  27236. 0xc1,
  27237. 0xaf,
  27238. 0xbd,
  27239. 0x03,
  27240. 0x01,
  27241. 0x13,
  27242. 0x8a,
  27243. 0x6b,
  27244. 0x3a,
  27245. 0x91,
  27246. 0x11,
  27247. 0x41,
  27248. 0x4f,
  27249. 0x67,
  27250. 0xdc,
  27251. 0xea,
  27252. 0x97,
  27253. 0xf2,
  27254. 0xcf,
  27255. 0xce,
  27256. 0xf0,
  27257. 0xb4,
  27258. 0xe6,
  27259. 0x73,
  27260. 0x96,
  27261. 0xac,
  27262. 0x74,
  27263. 0x22,
  27264. 0xe7,
  27265. 0xad,
  27266. 0x35,
  27267. 0x85,
  27268. 0xe2,
  27269. 0xf9,
  27270. 0x37,
  27271. 0xe8,
  27272. 0x1c,
  27273. 0x75,
  27274. 0xdf,
  27275. 0x6e,
  27276. 0x47,
  27277. 0xf1,
  27278. 0x1a,
  27279. 0x71,
  27280. 0x1d,
  27281. 0x29,
  27282. 0xc5,
  27283. 0x89,
  27284. 0x6f,
  27285. 0xb7,
  27286. 0x62,
  27287. 0x0e,
  27288. 0xaa,
  27289. 0x18,
  27290. 0xbe,
  27291. 0x1b,
  27292. 0xfc,
  27293. 0x56,
  27294. 0x3e,
  27295. 0x4b,
  27296. 0xc6,
  27297. 0xd2,
  27298. 0x79,
  27299. 0x20,
  27300. 0x9a,
  27301. 0xdb,
  27302. 0xc0,
  27303. 0xfe,
  27304. 0x78,
  27305. 0xcd,
  27306. 0x5a,
  27307. 0xf4,
  27308. 0x1f,
  27309. 0xdd,
  27310. 0xa8,
  27311. 0x33,
  27312. 0x88,
  27313. 0x07,
  27314. 0xc7,
  27315. 0x31,
  27316. 0xb1,
  27317. 0x12,
  27318. 0x10,
  27319. 0x59,
  27320. 0x27,
  27321. 0x80,
  27322. 0xec,
  27323. 0x5f,
  27324. 0x60,
  27325. 0x51,
  27326. 0x7f,
  27327. 0xa9,
  27328. 0x19,
  27329. 0xb5,
  27330. 0x4a,
  27331. 0x0d,
  27332. 0x2d,
  27333. 0xe5,
  27334. 0x7a,
  27335. 0x9f,
  27336. 0x93,
  27337. 0xc9,
  27338. 0x9c,
  27339. 0xef,
  27340. 0xa0,
  27341. 0xe0,
  27342. 0x3b,
  27343. 0x4d,
  27344. 0xae,
  27345. 0x2a,
  27346. 0xf5,
  27347. 0xb0,
  27348. 0xc8,
  27349. 0xeb,
  27350. 0xbb,
  27351. 0x3c,
  27352. 0x83,
  27353. 0x53,
  27354. 0x99,
  27355. 0x61,
  27356. 0x17,
  27357. 0x2b,
  27358. 0x04,
  27359. 0x7e,
  27360. 0xba,
  27361. 0x77,
  27362. 0xd6,
  27363. 0x26,
  27364. 0xe1,
  27365. 0x69,
  27366. 0x14,
  27367. 0x63,
  27368. 0x55,
  27369. 0x21,
  27370. 0x0c,
  27371. 0x7d
  27372. ]);
  27373. var mixCol = new Uint8Array(256);
  27374. for (var i = 0; i < 256; i++) {
  27375. if (i < 128) {
  27376. mixCol[i] = i << 1;
  27377. } else {
  27378. mixCol[i] = i << 1 ^ 0x1b;
  27379. }
  27380. }
  27381. var mix = new Uint32Array([
  27382. 0x00000000,
  27383. 0x0e090d0b,
  27384. 0x1c121a16,
  27385. 0x121b171d,
  27386. 0x3824342c,
  27387. 0x362d3927,
  27388. 0x24362e3a,
  27389. 0x2a3f2331,
  27390. 0x70486858,
  27391. 0x7e416553,
  27392. 0x6c5a724e,
  27393. 0x62537f45,
  27394. 0x486c5c74,
  27395. 0x4665517f,
  27396. 0x547e4662,
  27397. 0x5a774b69,
  27398. 0xe090d0b0,
  27399. 0xee99ddbb,
  27400. 0xfc82caa6,
  27401. 0xf28bc7ad,
  27402. 0xd8b4e49c,
  27403. 0xd6bde997,
  27404. 0xc4a6fe8a,
  27405. 0xcaaff381,
  27406. 0x90d8b8e8,
  27407. 0x9ed1b5e3,
  27408. 0x8ccaa2fe,
  27409. 0x82c3aff5,
  27410. 0xa8fc8cc4,
  27411. 0xa6f581cf,
  27412. 0xb4ee96d2,
  27413. 0xbae79bd9,
  27414. 0xdb3bbb7b,
  27415. 0xd532b670,
  27416. 0xc729a16d,
  27417. 0xc920ac66,
  27418. 0xe31f8f57,
  27419. 0xed16825c,
  27420. 0xff0d9541,
  27421. 0xf104984a,
  27422. 0xab73d323,
  27423. 0xa57ade28,
  27424. 0xb761c935,
  27425. 0xb968c43e,
  27426. 0x9357e70f,
  27427. 0x9d5eea04,
  27428. 0x8f45fd19,
  27429. 0x814cf012,
  27430. 0x3bab6bcb,
  27431. 0x35a266c0,
  27432. 0x27b971dd,
  27433. 0x29b07cd6,
  27434. 0x038f5fe7,
  27435. 0x0d8652ec,
  27436. 0x1f9d45f1,
  27437. 0x119448fa,
  27438. 0x4be30393,
  27439. 0x45ea0e98,
  27440. 0x57f11985,
  27441. 0x59f8148e,
  27442. 0x73c737bf,
  27443. 0x7dce3ab4,
  27444. 0x6fd52da9,
  27445. 0x61dc20a2,
  27446. 0xad766df6,
  27447. 0xa37f60fd,
  27448. 0xb16477e0,
  27449. 0xbf6d7aeb,
  27450. 0x955259da,
  27451. 0x9b5b54d1,
  27452. 0x894043cc,
  27453. 0x87494ec7,
  27454. 0xdd3e05ae,
  27455. 0xd33708a5,
  27456. 0xc12c1fb8,
  27457. 0xcf2512b3,
  27458. 0xe51a3182,
  27459. 0xeb133c89,
  27460. 0xf9082b94,
  27461. 0xf701269f,
  27462. 0x4de6bd46,
  27463. 0x43efb04d,
  27464. 0x51f4a750,
  27465. 0x5ffdaa5b,
  27466. 0x75c2896a,
  27467. 0x7bcb8461,
  27468. 0x69d0937c,
  27469. 0x67d99e77,
  27470. 0x3daed51e,
  27471. 0x33a7d815,
  27472. 0x21bccf08,
  27473. 0x2fb5c203,
  27474. 0x058ae132,
  27475. 0x0b83ec39,
  27476. 0x1998fb24,
  27477. 0x1791f62f,
  27478. 0x764dd68d,
  27479. 0x7844db86,
  27480. 0x6a5fcc9b,
  27481. 0x6456c190,
  27482. 0x4e69e2a1,
  27483. 0x4060efaa,
  27484. 0x527bf8b7,
  27485. 0x5c72f5bc,
  27486. 0x0605bed5,
  27487. 0x080cb3de,
  27488. 0x1a17a4c3,
  27489. 0x141ea9c8,
  27490. 0x3e218af9,
  27491. 0x302887f2,
  27492. 0x223390ef,
  27493. 0x2c3a9de4,
  27494. 0x96dd063d,
  27495. 0x98d40b36,
  27496. 0x8acf1c2b,
  27497. 0x84c61120,
  27498. 0xaef93211,
  27499. 0xa0f03f1a,
  27500. 0xb2eb2807,
  27501. 0xbce2250c,
  27502. 0xe6956e65,
  27503. 0xe89c636e,
  27504. 0xfa877473,
  27505. 0xf48e7978,
  27506. 0xdeb15a49,
  27507. 0xd0b85742,
  27508. 0xc2a3405f,
  27509. 0xccaa4d54,
  27510. 0x41ecdaf7,
  27511. 0x4fe5d7fc,
  27512. 0x5dfec0e1,
  27513. 0x53f7cdea,
  27514. 0x79c8eedb,
  27515. 0x77c1e3d0,
  27516. 0x65daf4cd,
  27517. 0x6bd3f9c6,
  27518. 0x31a4b2af,
  27519. 0x3fadbfa4,
  27520. 0x2db6a8b9,
  27521. 0x23bfa5b2,
  27522. 0x09808683,
  27523. 0x07898b88,
  27524. 0x15929c95,
  27525. 0x1b9b919e,
  27526. 0xa17c0a47,
  27527. 0xaf75074c,
  27528. 0xbd6e1051,
  27529. 0xb3671d5a,
  27530. 0x99583e6b,
  27531. 0x97513360,
  27532. 0x854a247d,
  27533. 0x8b432976,
  27534. 0xd134621f,
  27535. 0xdf3d6f14,
  27536. 0xcd267809,
  27537. 0xc32f7502,
  27538. 0xe9105633,
  27539. 0xe7195b38,
  27540. 0xf5024c25,
  27541. 0xfb0b412e,
  27542. 0x9ad7618c,
  27543. 0x94de6c87,
  27544. 0x86c57b9a,
  27545. 0x88cc7691,
  27546. 0xa2f355a0,
  27547. 0xacfa58ab,
  27548. 0xbee14fb6,
  27549. 0xb0e842bd,
  27550. 0xea9f09d4,
  27551. 0xe49604df,
  27552. 0xf68d13c2,
  27553. 0xf8841ec9,
  27554. 0xd2bb3df8,
  27555. 0xdcb230f3,
  27556. 0xcea927ee,
  27557. 0xc0a02ae5,
  27558. 0x7a47b13c,
  27559. 0x744ebc37,
  27560. 0x6655ab2a,
  27561. 0x685ca621,
  27562. 0x42638510,
  27563. 0x4c6a881b,
  27564. 0x5e719f06,
  27565. 0x5078920d,
  27566. 0x0a0fd964,
  27567. 0x0406d46f,
  27568. 0x161dc372,
  27569. 0x1814ce79,
  27570. 0x322bed48,
  27571. 0x3c22e043,
  27572. 0x2e39f75e,
  27573. 0x2030fa55,
  27574. 0xec9ab701,
  27575. 0xe293ba0a,
  27576. 0xf088ad17,
  27577. 0xfe81a01c,
  27578. 0xd4be832d,
  27579. 0xdab78e26,
  27580. 0xc8ac993b,
  27581. 0xc6a59430,
  27582. 0x9cd2df59,
  27583. 0x92dbd252,
  27584. 0x80c0c54f,
  27585. 0x8ec9c844,
  27586. 0xa4f6eb75,
  27587. 0xaaffe67e,
  27588. 0xb8e4f163,
  27589. 0xb6edfc68,
  27590. 0x0c0a67b1,
  27591. 0x02036aba,
  27592. 0x10187da7,
  27593. 0x1e1170ac,
  27594. 0x342e539d,
  27595. 0x3a275e96,
  27596. 0x283c498b,
  27597. 0x26354480,
  27598. 0x7c420fe9,
  27599. 0x724b02e2,
  27600. 0x605015ff,
  27601. 0x6e5918f4,
  27602. 0x44663bc5,
  27603. 0x4a6f36ce,
  27604. 0x587421d3,
  27605. 0x567d2cd8,
  27606. 0x37a10c7a,
  27607. 0x39a80171,
  27608. 0x2bb3166c,
  27609. 0x25ba1b67,
  27610. 0x0f853856,
  27611. 0x018c355d,
  27612. 0x13972240,
  27613. 0x1d9e2f4b,
  27614. 0x47e96422,
  27615. 0x49e06929,
  27616. 0x5bfb7e34,
  27617. 0x55f2733f,
  27618. 0x7fcd500e,
  27619. 0x71c45d05,
  27620. 0x63df4a18,
  27621. 0x6dd64713,
  27622. 0xd731dcca,
  27623. 0xd938d1c1,
  27624. 0xcb23c6dc,
  27625. 0xc52acbd7,
  27626. 0xef15e8e6,
  27627. 0xe11ce5ed,
  27628. 0xf307f2f0,
  27629. 0xfd0efffb,
  27630. 0xa779b492,
  27631. 0xa970b999,
  27632. 0xbb6bae84,
  27633. 0xb562a38f,
  27634. 0x9f5d80be,
  27635. 0x91548db5,
  27636. 0x834f9aa8,
  27637. 0x8d4697a3
  27638. ]);
  27639. function expandKey256(cipherKey) {
  27640. var b = 240, result = new Uint8Array(b);
  27641. var r = 1;
  27642. result.set(cipherKey);
  27643. for (var j = 32, i = 1; j < b; ++i) {
  27644. if (j % 32 === 16) {
  27645. t1 = s[t1];
  27646. t2 = s[t2];
  27647. t3 = s[t3];
  27648. t4 = s[t4];
  27649. } else if (j % 32 === 0) {
  27650. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27651. t1 = s[t1];
  27652. t2 = s[t2];
  27653. t3 = s[t3];
  27654. t4 = s[t4];
  27655. t1 = t1 ^ r;
  27656. if ((r <<= 1) >= 256) {
  27657. r = (r ^ 0x1b) & 0xFF;
  27658. }
  27659. }
  27660. for (var n = 0; n < 4; ++n) {
  27661. result[j] = t1 ^= result[j - 32];
  27662. j++;
  27663. result[j] = t2 ^= result[j - 32];
  27664. j++;
  27665. result[j] = t3 ^= result[j - 32];
  27666. j++;
  27667. result[j] = t4 ^= result[j - 32];
  27668. j++;
  27669. }
  27670. }
  27671. return result;
  27672. }
  27673. function decrypt256(input, key) {
  27674. var state = new Uint8Array(16);
  27675. state.set(input);
  27676. var i, j, k;
  27677. var t, u, v;
  27678. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27679. state[j] ^= key[k];
  27680. }
  27681. for (i = 13; i >= 1; --i) {
  27682. t = state[13];
  27683. state[13] = state[9];
  27684. state[9] = state[5];
  27685. state[5] = state[1];
  27686. state[1] = t;
  27687. t = state[14];
  27688. u = state[10];
  27689. state[14] = state[6];
  27690. state[10] = state[2];
  27691. state[6] = t;
  27692. state[2] = u;
  27693. t = state[15];
  27694. u = state[11];
  27695. v = state[7];
  27696. state[15] = state[3];
  27697. state[11] = t;
  27698. state[7] = u;
  27699. state[3] = v;
  27700. for (j = 0; j < 16; ++j) {
  27701. state[j] = inv_s[state[j]];
  27702. }
  27703. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27704. state[j] ^= key[k];
  27705. }
  27706. for (j = 0; j < 16; j += 4) {
  27707. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27708. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27709. state[j] = t >>> 24 & 0xFF;
  27710. state[j + 1] = t >> 16 & 0xFF;
  27711. state[j + 2] = t >> 8 & 0xFF;
  27712. state[j + 3] = t & 0xFF;
  27713. }
  27714. }
  27715. t = state[13];
  27716. state[13] = state[9];
  27717. state[9] = state[5];
  27718. state[5] = state[1];
  27719. state[1] = t;
  27720. t = state[14];
  27721. u = state[10];
  27722. state[14] = state[6];
  27723. state[10] = state[2];
  27724. state[6] = t;
  27725. state[2] = u;
  27726. t = state[15];
  27727. u = state[11];
  27728. v = state[7];
  27729. state[15] = state[3];
  27730. state[11] = t;
  27731. state[7] = u;
  27732. state[3] = v;
  27733. for (j = 0; j < 16; ++j) {
  27734. state[j] = inv_s[state[j]];
  27735. state[j] ^= key[j];
  27736. }
  27737. return state;
  27738. }
  27739. function encrypt256(input, key) {
  27740. var t, u, v, k;
  27741. var state = new Uint8Array(16);
  27742. state.set(input);
  27743. for (j = 0; j < 16; ++j) {
  27744. state[j] ^= key[j];
  27745. }
  27746. for (i = 1; i < 14; i++) {
  27747. for (j = 0; j < 16; ++j) {
  27748. state[j] = s[state[j]];
  27749. }
  27750. v = state[1];
  27751. state[1] = state[5];
  27752. state[5] = state[9];
  27753. state[9] = state[13];
  27754. state[13] = v;
  27755. v = state[2];
  27756. u = state[6];
  27757. state[2] = state[10];
  27758. state[6] = state[14];
  27759. state[10] = v;
  27760. state[14] = u;
  27761. v = state[3];
  27762. u = state[7];
  27763. t = state[11];
  27764. state[3] = state[15];
  27765. state[7] = v;
  27766. state[11] = u;
  27767. state[15] = t;
  27768. for (var j = 0; j < 16; j += 4) {
  27769. var s0 = state[j + 0], s1 = state[j + 1];
  27770. var s2 = state[j + 2], s3 = state[j + 3];
  27771. t = s0 ^ s1 ^ s2 ^ s3;
  27772. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27773. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27774. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27775. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27776. }
  27777. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27778. state[j] ^= key[k];
  27779. }
  27780. }
  27781. for (j = 0; j < 16; ++j) {
  27782. state[j] = s[state[j]];
  27783. }
  27784. v = state[1];
  27785. state[1] = state[5];
  27786. state[5] = state[9];
  27787. state[9] = state[13];
  27788. state[13] = v;
  27789. v = state[2];
  27790. u = state[6];
  27791. state[2] = state[10];
  27792. state[6] = state[14];
  27793. state[10] = v;
  27794. state[14] = u;
  27795. v = state[3];
  27796. u = state[7];
  27797. t = state[11];
  27798. state[3] = state[15];
  27799. state[7] = v;
  27800. state[11] = u;
  27801. state[15] = t;
  27802. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27803. state[j] ^= key[k];
  27804. }
  27805. return state;
  27806. }
  27807. function AES256Cipher(key) {
  27808. this.key = expandKey256(key);
  27809. this.buffer = new Uint8Array(16);
  27810. this.bufferPosition = 0;
  27811. }
  27812. function decryptBlock2(data, finalize) {
  27813. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27814. for (i = 0; i < sourceLength; ++i) {
  27815. buffer[bufferLength] = data[i];
  27816. ++bufferLength;
  27817. if (bufferLength < 16) {
  27818. continue;
  27819. }
  27820. var plain = decrypt256(buffer, this.key);
  27821. for (j = 0; j < 16; ++j) {
  27822. plain[j] ^= iv[j];
  27823. }
  27824. iv = buffer;
  27825. result.push(plain);
  27826. buffer = new Uint8Array(16);
  27827. bufferLength = 0;
  27828. }
  27829. this.buffer = buffer;
  27830. this.bufferLength = bufferLength;
  27831. this.iv = iv;
  27832. if (result.length === 0) {
  27833. return new Uint8Array([]);
  27834. }
  27835. var outputLength = 16 * result.length;
  27836. if (finalize) {
  27837. var lastBlock = result[result.length - 1];
  27838. var psLen = lastBlock[15];
  27839. if (psLen <= 16) {
  27840. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27841. if (lastBlock[i] !== psLen) {
  27842. psLen = 0;
  27843. break;
  27844. }
  27845. }
  27846. outputLength -= psLen;
  27847. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27848. }
  27849. }
  27850. var output = new Uint8Array(outputLength);
  27851. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27852. output.set(result[i], j);
  27853. }
  27854. return output;
  27855. }
  27856. AES256Cipher.prototype = {
  27857. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  27858. var i, sourceLength = data.length;
  27859. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27860. if (iv) {
  27861. this.iv = iv;
  27862. } else {
  27863. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27864. buffer[bufferLength] = data[i];
  27865. }
  27866. if (bufferLength < 16) {
  27867. this.bufferLength = bufferLength;
  27868. return new Uint8Array([]);
  27869. }
  27870. this.iv = buffer;
  27871. data = data.subarray(16);
  27872. }
  27873. this.buffer = new Uint8Array(16);
  27874. this.bufferLength = 0;
  27875. this.decryptBlock = decryptBlock2;
  27876. return this.decryptBlock(data, finalize);
  27877. },
  27878. encrypt: function AES256Cipher_encrypt(data, iv) {
  27879. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27880. if (!iv) {
  27881. iv = new Uint8Array(16);
  27882. }
  27883. for (i = 0; i < sourceLength; ++i) {
  27884. buffer[bufferLength] = data[i];
  27885. ++bufferLength;
  27886. if (bufferLength < 16) {
  27887. continue;
  27888. }
  27889. for (j = 0; j < 16; ++j) {
  27890. buffer[j] ^= iv[j];
  27891. }
  27892. var cipher = encrypt256(buffer, this.key);
  27893. this.iv = cipher;
  27894. result.push(cipher);
  27895. buffer = new Uint8Array(16);
  27896. bufferLength = 0;
  27897. }
  27898. this.buffer = buffer;
  27899. this.bufferLength = bufferLength;
  27900. this.iv = iv;
  27901. if (result.length === 0) {
  27902. return new Uint8Array([]);
  27903. }
  27904. var outputLength = 16 * result.length;
  27905. var output = new Uint8Array(outputLength);
  27906. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27907. output.set(result[i], j);
  27908. }
  27909. return output;
  27910. }
  27911. };
  27912. return AES256Cipher;
  27913. }();
  27914. var PDF17 = function PDF17Closure() {
  27915. function compareByteArrays(array1, array2) {
  27916. if (array1.length !== array2.length) {
  27917. return false;
  27918. }
  27919. for (var i = 0; i < array1.length; i++) {
  27920. if (array1[i] !== array2[i]) {
  27921. return false;
  27922. }
  27923. }
  27924. return true;
  27925. }
  27926. function PDF17() {
  27927. }
  27928. PDF17.prototype = {
  27929. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  27930. var hashData = new Uint8Array(password.length + 56);
  27931. hashData.set(password, 0);
  27932. hashData.set(ownerValidationSalt, password.length);
  27933. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  27934. var result = calculateSHA256(hashData, 0, hashData.length);
  27935. return compareByteArrays(result, ownerPassword);
  27936. },
  27937. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  27938. var hashData = new Uint8Array(password.length + 8);
  27939. hashData.set(password, 0);
  27940. hashData.set(userValidationSalt, password.length);
  27941. var result = calculateSHA256(hashData, 0, hashData.length);
  27942. return compareByteArrays(result, userPassword);
  27943. },
  27944. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  27945. var hashData = new Uint8Array(password.length + 56);
  27946. hashData.set(password, 0);
  27947. hashData.set(ownerKeySalt, password.length);
  27948. hashData.set(userBytes, password.length + ownerKeySalt.length);
  27949. var key = calculateSHA256(hashData, 0, hashData.length);
  27950. var cipher = new AES256Cipher(key);
  27951. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  27952. },
  27953. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  27954. var hashData = new Uint8Array(password.length + 8);
  27955. hashData.set(password, 0);
  27956. hashData.set(userKeySalt, password.length);
  27957. var key = calculateSHA256(hashData, 0, hashData.length);
  27958. var cipher = new AES256Cipher(key);
  27959. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  27960. }
  27961. };
  27962. return PDF17;
  27963. }();
  27964. var PDF20 = function PDF20Closure() {
  27965. function concatArrays(array1, array2) {
  27966. var t = new Uint8Array(array1.length + array2.length);
  27967. t.set(array1, 0);
  27968. t.set(array2, array1.length);
  27969. return t;
  27970. }
  27971. function calculatePDF20Hash(password, input, userBytes) {
  27972. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  27973. var e = [0];
  27974. var i = 0;
  27975. while (i < 64 || e[e.length - 1] > i - 32) {
  27976. var arrayLength = password.length + k.length + userBytes.length;
  27977. var k1 = new Uint8Array(arrayLength * 64);
  27978. var array = concatArrays(password, k);
  27979. array = concatArrays(array, userBytes);
  27980. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  27981. k1.set(array, pos);
  27982. }
  27983. var cipher = new AES128Cipher(k.subarray(0, 16));
  27984. e = cipher.encrypt(k1, k.subarray(16, 32));
  27985. var remainder = 0;
  27986. for (var z = 0; z < 16; z++) {
  27987. remainder *= 256 % 3;
  27988. remainder %= 3;
  27989. remainder += (e[z] >>> 0) % 3;
  27990. remainder %= 3;
  27991. }
  27992. if (remainder === 0) {
  27993. k = calculateSHA256(e, 0, e.length);
  27994. } else if (remainder === 1) {
  27995. k = calculateSHA384(e, 0, e.length);
  27996. } else if (remainder === 2) {
  27997. k = calculateSHA512(e, 0, e.length);
  27998. }
  27999. i++;
  28000. }
  28001. return k.subarray(0, 32);
  28002. }
  28003. function PDF20() {
  28004. }
  28005. function compareByteArrays(array1, array2) {
  28006. if (array1.length !== array2.length) {
  28007. return false;
  28008. }
  28009. for (var i = 0; i < array1.length; i++) {
  28010. if (array1[i] !== array2[i]) {
  28011. return false;
  28012. }
  28013. }
  28014. return true;
  28015. }
  28016. PDF20.prototype = {
  28017. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28018. return calculatePDF20Hash(password, concatBytes, userBytes);
  28019. },
  28020. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28021. var hashData = new Uint8Array(password.length + 56);
  28022. hashData.set(password, 0);
  28023. hashData.set(ownerValidationSalt, password.length);
  28024. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28025. var result = calculatePDF20Hash(password, hashData, userBytes);
  28026. return compareByteArrays(result, ownerPassword);
  28027. },
  28028. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28029. var hashData = new Uint8Array(password.length + 8);
  28030. hashData.set(password, 0);
  28031. hashData.set(userValidationSalt, password.length);
  28032. var result = calculatePDF20Hash(password, hashData, []);
  28033. return compareByteArrays(result, userPassword);
  28034. },
  28035. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28036. var hashData = new Uint8Array(password.length + 56);
  28037. hashData.set(password, 0);
  28038. hashData.set(ownerKeySalt, password.length);
  28039. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28040. var key = calculatePDF20Hash(password, hashData, userBytes);
  28041. var cipher = new AES256Cipher(key);
  28042. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28043. },
  28044. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28045. var hashData = new Uint8Array(password.length + 8);
  28046. hashData.set(password, 0);
  28047. hashData.set(userKeySalt, password.length);
  28048. var key = calculatePDF20Hash(password, hashData, []);
  28049. var cipher = new AES256Cipher(key);
  28050. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28051. }
  28052. };
  28053. return PDF20;
  28054. }();
  28055. var CipherTransform = function CipherTransformClosure() {
  28056. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28057. this.StringCipherConstructor = stringCipherConstructor;
  28058. this.StreamCipherConstructor = streamCipherConstructor;
  28059. }
  28060. CipherTransform.prototype = {
  28061. createStream: function CipherTransform_createStream(stream, length) {
  28062. var cipher = new this.StreamCipherConstructor();
  28063. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28064. return cipher.decryptBlock(data, finalize);
  28065. });
  28066. },
  28067. decryptString: function CipherTransform_decryptString(s) {
  28068. var cipher = new this.StringCipherConstructor();
  28069. var data = stringToBytes(s);
  28070. data = cipher.decryptBlock(data, true);
  28071. return bytesToString(data);
  28072. }
  28073. };
  28074. return CipherTransform;
  28075. }();
  28076. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28077. var defaultPasswordBytes = new Uint8Array([
  28078. 0x28,
  28079. 0xBF,
  28080. 0x4E,
  28081. 0x5E,
  28082. 0x4E,
  28083. 0x75,
  28084. 0x8A,
  28085. 0x41,
  28086. 0x64,
  28087. 0x00,
  28088. 0x4E,
  28089. 0x56,
  28090. 0xFF,
  28091. 0xFA,
  28092. 0x01,
  28093. 0x08,
  28094. 0x2E,
  28095. 0x2E,
  28096. 0x00,
  28097. 0xB6,
  28098. 0xD0,
  28099. 0x68,
  28100. 0x3E,
  28101. 0x80,
  28102. 0x2F,
  28103. 0x0C,
  28104. 0xA9,
  28105. 0xFE,
  28106. 0x64,
  28107. 0x53,
  28108. 0x69,
  28109. 0x7A
  28110. ]);
  28111. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28112. if (password) {
  28113. var passwordLength = Math.min(127, password.length);
  28114. password = password.subarray(0, passwordLength);
  28115. } else {
  28116. password = [];
  28117. }
  28118. var pdfAlgorithm;
  28119. if (revision === 6) {
  28120. pdfAlgorithm = new PDF20();
  28121. } else {
  28122. pdfAlgorithm = new PDF17();
  28123. }
  28124. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28125. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28126. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28127. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28128. }
  28129. return null;
  28130. }
  28131. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28132. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28133. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28134. if (password) {
  28135. n = Math.min(32, password.length);
  28136. for (; i < n; ++i) {
  28137. hashData[i] = password[i];
  28138. }
  28139. }
  28140. j = 0;
  28141. while (i < 32) {
  28142. hashData[i++] = defaultPasswordBytes[j++];
  28143. }
  28144. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28145. hashData[i++] = ownerPassword[j];
  28146. }
  28147. hashData[i++] = flags & 0xFF;
  28148. hashData[i++] = flags >> 8 & 0xFF;
  28149. hashData[i++] = flags >> 16 & 0xFF;
  28150. hashData[i++] = flags >>> 24 & 0xFF;
  28151. for (j = 0, n = fileId.length; j < n; ++j) {
  28152. hashData[i++] = fileId[j];
  28153. }
  28154. if (revision >= 4 && !encryptMetadata) {
  28155. hashData[i++] = 0xFF;
  28156. hashData[i++] = 0xFF;
  28157. hashData[i++] = 0xFF;
  28158. hashData[i++] = 0xFF;
  28159. }
  28160. var hash = calculateMD5(hashData, 0, i);
  28161. var keyLengthInBytes = keyLength >> 3;
  28162. if (revision >= 3) {
  28163. for (j = 0; j < 50; ++j) {
  28164. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28165. }
  28166. }
  28167. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28168. var cipher, checkData;
  28169. if (revision >= 3) {
  28170. for (i = 0; i < 32; ++i) {
  28171. hashData[i] = defaultPasswordBytes[i];
  28172. }
  28173. for (j = 0, n = fileId.length; j < n; ++j) {
  28174. hashData[i++] = fileId[j];
  28175. }
  28176. cipher = new ARCFourCipher(encryptionKey);
  28177. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28178. n = encryptionKey.length;
  28179. var derivedKey = new Uint8Array(n), k;
  28180. for (j = 1; j <= 19; ++j) {
  28181. for (k = 0; k < n; ++k) {
  28182. derivedKey[k] = encryptionKey[k] ^ j;
  28183. }
  28184. cipher = new ARCFourCipher(derivedKey);
  28185. checkData = cipher.encryptBlock(checkData);
  28186. }
  28187. for (j = 0, n = checkData.length; j < n; ++j) {
  28188. if (userPassword[j] !== checkData[j]) {
  28189. return null;
  28190. }
  28191. }
  28192. } else {
  28193. cipher = new ARCFourCipher(encryptionKey);
  28194. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28195. for (j = 0, n = checkData.length; j < n; ++j) {
  28196. if (userPassword[j] !== checkData[j]) {
  28197. return null;
  28198. }
  28199. }
  28200. }
  28201. return encryptionKey;
  28202. }
  28203. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28204. var hashData = new Uint8Array(32), i = 0, j, n;
  28205. n = Math.min(32, password.length);
  28206. for (; i < n; ++i) {
  28207. hashData[i] = password[i];
  28208. }
  28209. j = 0;
  28210. while (i < 32) {
  28211. hashData[i++] = defaultPasswordBytes[j++];
  28212. }
  28213. var hash = calculateMD5(hashData, 0, i);
  28214. var keyLengthInBytes = keyLength >> 3;
  28215. if (revision >= 3) {
  28216. for (j = 0; j < 50; ++j) {
  28217. hash = calculateMD5(hash, 0, hash.length);
  28218. }
  28219. }
  28220. var cipher, userPassword;
  28221. if (revision >= 3) {
  28222. userPassword = ownerPassword;
  28223. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28224. for (j = 19; j >= 0; j--) {
  28225. for (k = 0; k < keyLengthInBytes; ++k) {
  28226. derivedKey[k] = hash[k] ^ j;
  28227. }
  28228. cipher = new ARCFourCipher(derivedKey);
  28229. userPassword = cipher.encryptBlock(userPassword);
  28230. }
  28231. } else {
  28232. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28233. userPassword = cipher.encryptBlock(ownerPassword);
  28234. }
  28235. return userPassword;
  28236. }
  28237. var identityName = Name.get('Identity');
  28238. function CipherTransformFactory(dict, fileId, password) {
  28239. var filter = dict.get('Filter');
  28240. if (!isName(filter, 'Standard')) {
  28241. error('unknown encryption method');
  28242. }
  28243. this.dict = dict;
  28244. var algorithm = dict.get('V');
  28245. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28246. error('unsupported encryption algorithm');
  28247. }
  28248. this.algorithm = algorithm;
  28249. var keyLength = dict.get('Length');
  28250. if (!keyLength) {
  28251. if (algorithm <= 3) {
  28252. keyLength = 40;
  28253. } else {
  28254. var cfDict = dict.get('CF');
  28255. var streamCryptoName = dict.get('StmF');
  28256. if (isDict(cfDict) && isName(streamCryptoName)) {
  28257. cfDict.suppressEncryption = true;
  28258. var handlerDict = cfDict.get(streamCryptoName.name);
  28259. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28260. if (keyLength < 40) {
  28261. keyLength <<= 3;
  28262. }
  28263. }
  28264. }
  28265. }
  28266. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28267. error('invalid key length');
  28268. }
  28269. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28270. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28271. var flags = dict.get('P');
  28272. var revision = dict.get('R');
  28273. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28274. this.encryptMetadata = encryptMetadata;
  28275. var fileIdBytes = stringToBytes(fileId);
  28276. var passwordBytes;
  28277. if (password) {
  28278. if (revision === 6) {
  28279. try {
  28280. password = utf8StringToString(password);
  28281. } catch (ex) {
  28282. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  28283. }
  28284. }
  28285. passwordBytes = stringToBytes(password);
  28286. }
  28287. var encryptionKey;
  28288. if (algorithm !== 5) {
  28289. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28290. } else {
  28291. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  28292. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  28293. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  28294. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  28295. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  28296. var ownerEncryption = stringToBytes(dict.get('OE'));
  28297. var userEncryption = stringToBytes(dict.get('UE'));
  28298. var perms = stringToBytes(dict.get('Perms'));
  28299. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  28300. }
  28301. if (!encryptionKey && !password) {
  28302. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  28303. } else if (!encryptionKey && password) {
  28304. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  28305. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28306. }
  28307. if (!encryptionKey) {
  28308. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  28309. }
  28310. this.encryptionKey = encryptionKey;
  28311. if (algorithm >= 4) {
  28312. var cf = dict.get('CF');
  28313. if (isDict(cf)) {
  28314. cf.suppressEncryption = true;
  28315. }
  28316. this.cf = cf;
  28317. this.stmf = dict.get('StmF') || identityName;
  28318. this.strf = dict.get('StrF') || identityName;
  28319. this.eff = dict.get('EFF') || this.stmf;
  28320. }
  28321. }
  28322. function buildObjectKey(num, gen, encryptionKey, isAes) {
  28323. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  28324. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  28325. key[i] = encryptionKey[i];
  28326. }
  28327. key[i++] = num & 0xFF;
  28328. key[i++] = num >> 8 & 0xFF;
  28329. key[i++] = num >> 16 & 0xFF;
  28330. key[i++] = gen & 0xFF;
  28331. key[i++] = gen >> 8 & 0xFF;
  28332. if (isAes) {
  28333. key[i++] = 0x73;
  28334. key[i++] = 0x41;
  28335. key[i++] = 0x6C;
  28336. key[i++] = 0x54;
  28337. }
  28338. var hash = calculateMD5(key, 0, i);
  28339. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  28340. }
  28341. function buildCipherConstructor(cf, name, num, gen, key) {
  28342. assert(isName(name), 'Invalid crypt filter name.');
  28343. var cryptFilter = cf.get(name.name);
  28344. var cfm;
  28345. if (cryptFilter !== null && cryptFilter !== undefined) {
  28346. cfm = cryptFilter.get('CFM');
  28347. }
  28348. if (!cfm || cfm.name === 'None') {
  28349. return function cipherTransformFactoryBuildCipherConstructorNone() {
  28350. return new NullCipher();
  28351. };
  28352. }
  28353. if (cfm.name === 'V2') {
  28354. return function cipherTransformFactoryBuildCipherConstructorV2() {
  28355. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  28356. };
  28357. }
  28358. if (cfm.name === 'AESV2') {
  28359. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  28360. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  28361. };
  28362. }
  28363. if (cfm.name === 'AESV3') {
  28364. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  28365. return new AES256Cipher(key);
  28366. };
  28367. }
  28368. error('Unknown crypto method');
  28369. }
  28370. CipherTransformFactory.prototype = {
  28371. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  28372. if (this.algorithm === 4 || this.algorithm === 5) {
  28373. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  28374. }
  28375. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  28376. var cipherConstructor = function buildCipherCipherConstructor() {
  28377. return new ARCFourCipher(key);
  28378. };
  28379. return new CipherTransform(cipherConstructor, cipherConstructor);
  28380. }
  28381. };
  28382. return CipherTransformFactory;
  28383. }();
  28384. exports.AES128Cipher = AES128Cipher;
  28385. exports.AES256Cipher = AES256Cipher;
  28386. exports.ARCFourCipher = ARCFourCipher;
  28387. exports.CipherTransformFactory = CipherTransformFactory;
  28388. exports.PDF17 = PDF17;
  28389. exports.PDF20 = PDF20;
  28390. exports.calculateMD5 = calculateMD5;
  28391. exports.calculateSHA256 = calculateSHA256;
  28392. exports.calculateSHA384 = calculateSHA384;
  28393. exports.calculateSHA512 = calculateSHA512;
  28394. /***/ }),
  28395. /* 18 */
  28396. /***/ (function(module, exports, __w_pdfjs_require__) {
  28397. "use strict";
  28398. var sharedUtil = __w_pdfjs_require__(0);
  28399. var corePrimitives = __w_pdfjs_require__(1);
  28400. var coreStream = __w_pdfjs_require__(2);
  28401. var coreParser = __w_pdfjs_require__(6);
  28402. var coreImage = __w_pdfjs_require__(34);
  28403. var coreColorSpace = __w_pdfjs_require__(4);
  28404. var coreMurmurHash3 = __w_pdfjs_require__(38);
  28405. var coreFonts = __w_pdfjs_require__(33);
  28406. var coreFunction = __w_pdfjs_require__(7);
  28407. var corePattern = __w_pdfjs_require__(40);
  28408. var coreCMap = __w_pdfjs_require__(30);
  28409. var coreMetrics = __w_pdfjs_require__(37);
  28410. var coreBidi = __w_pdfjs_require__(28);
  28411. var coreEncodings = __w_pdfjs_require__(5);
  28412. var coreStandardFonts = __w_pdfjs_require__(21);
  28413. var coreUnicode = __w_pdfjs_require__(22);
  28414. var coreGlyphList = __w_pdfjs_require__(8);
  28415. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  28416. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  28417. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  28418. var ImageKind = sharedUtil.ImageKind;
  28419. var OPS = sharedUtil.OPS;
  28420. var TextRenderingMode = sharedUtil.TextRenderingMode;
  28421. var CMapCompressionType = sharedUtil.CMapCompressionType;
  28422. var Util = sharedUtil.Util;
  28423. var assert = sharedUtil.assert;
  28424. var createPromiseCapability = sharedUtil.createPromiseCapability;
  28425. var error = sharedUtil.error;
  28426. var info = sharedUtil.info;
  28427. var isArray = sharedUtil.isArray;
  28428. var isNum = sharedUtil.isNum;
  28429. var isString = sharedUtil.isString;
  28430. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  28431. var warn = sharedUtil.warn;
  28432. var Dict = corePrimitives.Dict;
  28433. var Name = corePrimitives.Name;
  28434. var isEOF = corePrimitives.isEOF;
  28435. var isCmd = corePrimitives.isCmd;
  28436. var isDict = corePrimitives.isDict;
  28437. var isName = corePrimitives.isName;
  28438. var isRef = corePrimitives.isRef;
  28439. var isStream = corePrimitives.isStream;
  28440. var DecodeStream = coreStream.DecodeStream;
  28441. var JpegStream = coreStream.JpegStream;
  28442. var Stream = coreStream.Stream;
  28443. var Lexer = coreParser.Lexer;
  28444. var Parser = coreParser.Parser;
  28445. var PDFImage = coreImage.PDFImage;
  28446. var ColorSpace = coreColorSpace.ColorSpace;
  28447. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  28448. var ErrorFont = coreFonts.ErrorFont;
  28449. var FontFlags = coreFonts.FontFlags;
  28450. var Font = coreFonts.Font;
  28451. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  28452. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  28453. var getFontType = coreFonts.getFontType;
  28454. var isPDFFunction = coreFunction.isPDFFunction;
  28455. var PDFFunction = coreFunction.PDFFunction;
  28456. var Pattern = corePattern.Pattern;
  28457. var getTilingPatternIR = corePattern.getTilingPatternIR;
  28458. var CMapFactory = coreCMap.CMapFactory;
  28459. var IdentityCMap = coreCMap.IdentityCMap;
  28460. var getMetrics = coreMetrics.getMetrics;
  28461. var bidi = coreBidi.bidi;
  28462. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  28463. var StandardEncoding = coreEncodings.StandardEncoding;
  28464. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  28465. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  28466. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  28467. var getEncoding = coreEncodings.getEncoding;
  28468. var getStdFontMap = coreStandardFonts.getStdFontMap;
  28469. var getSerifFonts = coreStandardFonts.getSerifFonts;
  28470. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  28471. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  28472. var reverseIfRtl = coreUnicode.reverseIfRtl;
  28473. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  28474. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  28475. var PartialEvaluator = function PartialEvaluatorClosure() {
  28476. var DefaultPartialEvaluatorOptions = {
  28477. forceDataSchema: false,
  28478. maxImageSize: -1,
  28479. disableFontFace: false,
  28480. disableNativeImageDecoder: false
  28481. };
  28482. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  28483. this.xref = xref;
  28484. this.resources = resources;
  28485. this.handler = handler;
  28486. this.forceDataSchema = forceDataSchema;
  28487. }
  28488. NativeImageDecoder.prototype = {
  28489. canDecode: function (image) {
  28490. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  28491. },
  28492. decode: function (image) {
  28493. var dict = image.dict;
  28494. var colorSpace = dict.get('ColorSpace', 'CS');
  28495. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  28496. var numComps = colorSpace.numComps;
  28497. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  28498. image.getIR(this.forceDataSchema),
  28499. numComps
  28500. ]);
  28501. return decodePromise.then(function (message) {
  28502. var data = message.data;
  28503. return new Stream(data, 0, data.length, image.dict);
  28504. });
  28505. }
  28506. };
  28507. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  28508. var dict = image.dict;
  28509. if (dict.has('DecodeParms') || dict.has('DP')) {
  28510. return false;
  28511. }
  28512. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28513. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28514. };
  28515. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  28516. var dict = image.dict;
  28517. if (dict.has('DecodeParms') || dict.has('DP')) {
  28518. return false;
  28519. }
  28520. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28521. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28522. };
  28523. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  28524. this.pdfManager = pdfManager;
  28525. this.xref = xref;
  28526. this.handler = handler;
  28527. this.pageIndex = pageIndex;
  28528. this.idFactory = idFactory;
  28529. this.fontCache = fontCache;
  28530. this.builtInCMapCache = builtInCMapCache;
  28531. this.options = options || DefaultPartialEvaluatorOptions;
  28532. this.fetchBuiltInCMap = function (name) {
  28533. var cachedCMap = builtInCMapCache[name];
  28534. if (cachedCMap) {
  28535. return Promise.resolve(cachedCMap);
  28536. }
  28537. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  28538. if (data.compressionType !== CMapCompressionType.NONE) {
  28539. builtInCMapCache[name] = data;
  28540. }
  28541. return data;
  28542. });
  28543. };
  28544. }
  28545. var TIME_SLOT_DURATION_MS = 20;
  28546. var CHECK_TIME_EVERY = 100;
  28547. function TimeSlotManager() {
  28548. this.reset();
  28549. }
  28550. TimeSlotManager.prototype = {
  28551. check: function TimeSlotManager_check() {
  28552. if (++this.checked < CHECK_TIME_EVERY) {
  28553. return false;
  28554. }
  28555. this.checked = 0;
  28556. return this.endTime <= Date.now();
  28557. },
  28558. reset: function TimeSlotManager_reset() {
  28559. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  28560. this.checked = 0;
  28561. }
  28562. };
  28563. var deferred = Promise.resolve();
  28564. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  28565. PartialEvaluator.prototype = {
  28566. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  28567. if (!isDict(resources)) {
  28568. return false;
  28569. }
  28570. var processed = Object.create(null);
  28571. if (resources.objId) {
  28572. processed[resources.objId] = true;
  28573. }
  28574. var nodes = [resources], xref = this.xref;
  28575. while (nodes.length) {
  28576. var key, i, ii;
  28577. var node = nodes.shift();
  28578. var graphicStates = node.get('ExtGState');
  28579. if (isDict(graphicStates)) {
  28580. var graphicStatesKeys = graphicStates.getKeys();
  28581. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  28582. key = graphicStatesKeys[i];
  28583. var graphicState = graphicStates.get(key);
  28584. var bm = graphicState.get('BM');
  28585. if (isName(bm) && bm.name !== 'Normal') {
  28586. return true;
  28587. }
  28588. }
  28589. }
  28590. var xObjects = node.get('XObject');
  28591. if (!isDict(xObjects)) {
  28592. continue;
  28593. }
  28594. var xObjectsKeys = xObjects.getKeys();
  28595. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  28596. key = xObjectsKeys[i];
  28597. var xObject = xObjects.getRaw(key);
  28598. if (isRef(xObject)) {
  28599. if (processed[xObject.toString()]) {
  28600. continue;
  28601. }
  28602. xObject = xref.fetch(xObject);
  28603. }
  28604. if (!isStream(xObject)) {
  28605. continue;
  28606. }
  28607. if (xObject.dict.objId) {
  28608. if (processed[xObject.dict.objId]) {
  28609. continue;
  28610. }
  28611. processed[xObject.dict.objId] = true;
  28612. }
  28613. var xResources = xObject.dict.get('Resources');
  28614. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  28615. nodes.push(xResources);
  28616. if (xResources.objId) {
  28617. processed[xResources.objId] = true;
  28618. }
  28619. }
  28620. }
  28621. }
  28622. return false;
  28623. },
  28624. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  28625. var matrix = xobj.dict.getArray('Matrix');
  28626. var bbox = xobj.dict.getArray('BBox');
  28627. var group = xobj.dict.get('Group');
  28628. if (group) {
  28629. var groupOptions = {
  28630. matrix: matrix,
  28631. bbox: bbox,
  28632. smask: smask,
  28633. isolated: false,
  28634. knockout: false
  28635. };
  28636. var groupSubtype = group.get('S');
  28637. var colorSpace;
  28638. if (isName(groupSubtype, 'Transparency')) {
  28639. groupOptions.isolated = group.get('I') || false;
  28640. groupOptions.knockout = group.get('K') || false;
  28641. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  28642. }
  28643. if (smask && smask.backdrop) {
  28644. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  28645. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  28646. }
  28647. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  28648. }
  28649. operatorList.addOp(OPS.paintFormXObjectBegin, [
  28650. matrix,
  28651. bbox
  28652. ]);
  28653. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  28654. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  28655. if (group) {
  28656. operatorList.addOp(OPS.endGroup, [groupOptions]);
  28657. }
  28658. });
  28659. },
  28660. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  28661. var self = this;
  28662. var dict = image.dict;
  28663. var w = dict.get('Width', 'W');
  28664. var h = dict.get('Height', 'H');
  28665. if (!(w && isNum(w)) || !(h && isNum(h))) {
  28666. warn('Image dimensions are missing, or not numbers.');
  28667. return;
  28668. }
  28669. var maxImageSize = this.options.maxImageSize;
  28670. if (maxImageSize !== -1 && w * h > maxImageSize) {
  28671. warn('Image exceeded maximum allowed size and was removed.');
  28672. return;
  28673. }
  28674. var imageMask = dict.get('ImageMask', 'IM') || false;
  28675. var imgData, args;
  28676. if (imageMask) {
  28677. var width = dict.get('Width', 'W');
  28678. var height = dict.get('Height', 'H');
  28679. var bitStrideLength = width + 7 >> 3;
  28680. var imgArray = image.getBytes(bitStrideLength * height);
  28681. var decode = dict.getArray('Decode', 'D');
  28682. var inverseDecode = !!decode && decode[0] > 0;
  28683. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  28684. imgData.cached = true;
  28685. args = [imgData];
  28686. operatorList.addOp(OPS.paintImageMaskXObject, args);
  28687. if (cacheKey) {
  28688. imageCache[cacheKey] = {
  28689. fn: OPS.paintImageMaskXObject,
  28690. args: args
  28691. };
  28692. }
  28693. return;
  28694. }
  28695. var softMask = dict.get('SMask', 'SM') || false;
  28696. var mask = dict.get('Mask') || false;
  28697. var SMALL_IMAGE_DIMENSIONS = 200;
  28698. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  28699. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  28700. imgData = imageObj.createImageData(true);
  28701. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  28702. return;
  28703. }
  28704. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  28705. var objId = 'img_' + this.idFactory.createObjId();
  28706. operatorList.addDependency(objId);
  28707. args = [
  28708. objId,
  28709. w,
  28710. h
  28711. ];
  28712. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  28713. operatorList.addOp(OPS.paintJpegXObject, args);
  28714. this.handler.send('obj', [
  28715. objId,
  28716. this.pageIndex,
  28717. 'JpegStream',
  28718. image.getIR(this.options.forceDataSchema)
  28719. ]);
  28720. return;
  28721. }
  28722. var nativeImageDecoder = null;
  28723. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  28724. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  28725. }
  28726. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  28727. var imgData = imageObj.createImageData(false);
  28728. self.handler.send('obj', [
  28729. objId,
  28730. self.pageIndex,
  28731. 'Image',
  28732. imgData
  28733. ], [imgData.data.buffer]);
  28734. }).then(undefined, function (reason) {
  28735. warn('Unable to decode image: ' + reason);
  28736. self.handler.send('obj', [
  28737. objId,
  28738. self.pageIndex,
  28739. 'Image',
  28740. null
  28741. ]);
  28742. });
  28743. operatorList.addOp(OPS.paintImageXObject, args);
  28744. if (cacheKey) {
  28745. imageCache[cacheKey] = {
  28746. fn: OPS.paintImageXObject,
  28747. args: args
  28748. };
  28749. }
  28750. },
  28751. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  28752. var smaskContent = smask.get('G');
  28753. var smaskOptions = {
  28754. subtype: smask.get('S').name,
  28755. backdrop: smask.get('BC')
  28756. };
  28757. var transferObj = smask.get('TR');
  28758. if (isPDFFunction(transferObj)) {
  28759. var transferFn = PDFFunction.parse(this.xref, transferObj);
  28760. var transferMap = new Uint8Array(256);
  28761. var tmp = new Float32Array(1);
  28762. for (var i = 0; i < 256; i++) {
  28763. tmp[0] = i / 255;
  28764. transferFn(tmp, 0, tmp, 0);
  28765. transferMap[i] = tmp[0] * 255 | 0;
  28766. }
  28767. smaskOptions.transferMap = transferMap;
  28768. }
  28769. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  28770. },
  28771. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  28772. var tilingOpList = new OperatorList();
  28773. var resourcesArray = [
  28774. patternDict.get('Resources'),
  28775. resources
  28776. ];
  28777. var patternResources = Dict.merge(this.xref, resourcesArray);
  28778. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  28779. operatorList.addDependencies(tilingOpList.dependencies);
  28780. operatorList.addOp(fn, getTilingPatternIR({
  28781. fnArray: tilingOpList.fnArray,
  28782. argsArray: tilingOpList.argsArray
  28783. }, patternDict, args));
  28784. });
  28785. },
  28786. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  28787. var fontName;
  28788. if (fontArgs) {
  28789. fontArgs = fontArgs.slice();
  28790. fontName = fontArgs[0].name;
  28791. }
  28792. var self = this;
  28793. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  28794. if (!translated.font.isType3Font) {
  28795. return translated;
  28796. }
  28797. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  28798. return translated;
  28799. }, function (reason) {
  28800. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28801. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  28802. });
  28803. }).then(function (translated) {
  28804. state.font = translated.font;
  28805. translated.send(self.handler);
  28806. return translated.loadedName;
  28807. });
  28808. },
  28809. handleText: function PartialEvaluator_handleText(chars, state) {
  28810. var font = state.font;
  28811. var glyphs = font.charsToGlyphs(chars);
  28812. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  28813. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  28814. var buildPath = function (fontChar) {
  28815. if (!font.renderer.hasBuiltPath(fontChar)) {
  28816. var path = font.renderer.getPathJs(fontChar);
  28817. this.handler.send('commonobj', [
  28818. font.loadedName + '_path_' + fontChar,
  28819. 'FontPath',
  28820. path
  28821. ]);
  28822. }
  28823. }.bind(this);
  28824. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  28825. var glyph = glyphs[i];
  28826. buildPath(glyph.fontChar);
  28827. var accent = glyph.accent;
  28828. if (accent && accent.fontChar) {
  28829. buildPath(accent.fontChar);
  28830. }
  28831. }
  28832. }
  28833. return glyphs;
  28834. },
  28835. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  28836. var gStateObj = [];
  28837. var gStateKeys = gState.getKeys();
  28838. var self = this;
  28839. var promise = Promise.resolve();
  28840. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  28841. var key = gStateKeys[i];
  28842. var value = gState.get(key);
  28843. switch (key) {
  28844. case 'Type':
  28845. break;
  28846. case 'LW':
  28847. case 'LC':
  28848. case 'LJ':
  28849. case 'ML':
  28850. case 'D':
  28851. case 'RI':
  28852. case 'FL':
  28853. case 'CA':
  28854. case 'ca':
  28855. gStateObj.push([
  28856. key,
  28857. value
  28858. ]);
  28859. break;
  28860. case 'Font':
  28861. promise = promise.then(function () {
  28862. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  28863. operatorList.addDependency(loadedName);
  28864. gStateObj.push([
  28865. key,
  28866. [
  28867. loadedName,
  28868. value[1]
  28869. ]
  28870. ]);
  28871. });
  28872. });
  28873. break;
  28874. case 'BM':
  28875. gStateObj.push([
  28876. key,
  28877. value
  28878. ]);
  28879. break;
  28880. case 'SMask':
  28881. if (isName(value, 'None')) {
  28882. gStateObj.push([
  28883. key,
  28884. false
  28885. ]);
  28886. break;
  28887. }
  28888. if (isDict(value)) {
  28889. promise = promise.then(function (dict) {
  28890. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  28891. }.bind(this, value));
  28892. gStateObj.push([
  28893. key,
  28894. true
  28895. ]);
  28896. } else {
  28897. warn('Unsupported SMask type');
  28898. }
  28899. break;
  28900. case 'OP':
  28901. case 'op':
  28902. case 'OPM':
  28903. case 'BG':
  28904. case 'BG2':
  28905. case 'UCR':
  28906. case 'UCR2':
  28907. case 'TR':
  28908. case 'TR2':
  28909. case 'HT':
  28910. case 'SM':
  28911. case 'SA':
  28912. case 'AIS':
  28913. case 'TK':
  28914. info('graphic state operator ' + key);
  28915. break;
  28916. default:
  28917. info('Unknown graphic state operator ' + key);
  28918. break;
  28919. }
  28920. }
  28921. return promise.then(function () {
  28922. if (gStateObj.length > 0) {
  28923. operatorList.addOp(OPS.setGState, [gStateObj]);
  28924. }
  28925. });
  28926. },
  28927. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  28928. function errorFont() {
  28929. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  28930. }
  28931. var fontRef;
  28932. if (font) {
  28933. assert(isRef(font));
  28934. fontRef = font;
  28935. } else {
  28936. var fontRes = resources.get('Font');
  28937. if (fontRes) {
  28938. fontRef = fontRes.getRaw(fontName);
  28939. } else {
  28940. warn('fontRes not available');
  28941. return errorFont();
  28942. }
  28943. }
  28944. if (!fontRef) {
  28945. warn('fontRef not available');
  28946. return errorFont();
  28947. }
  28948. if (this.fontCache.has(fontRef)) {
  28949. return this.fontCache.get(fontRef);
  28950. }
  28951. font = xref.fetchIfRef(fontRef);
  28952. if (!isDict(font)) {
  28953. return errorFont();
  28954. }
  28955. if (font.translated) {
  28956. return font.translated;
  28957. }
  28958. var fontCapability = createPromiseCapability();
  28959. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  28960. var descriptor = preEvaluatedFont.descriptor;
  28961. var fontRefIsRef = isRef(fontRef), fontID;
  28962. if (fontRefIsRef) {
  28963. fontID = fontRef.toString();
  28964. }
  28965. if (isDict(descriptor)) {
  28966. if (!descriptor.fontAliases) {
  28967. descriptor.fontAliases = Object.create(null);
  28968. }
  28969. var fontAliases = descriptor.fontAliases;
  28970. var hash = preEvaluatedFont.hash;
  28971. if (fontAliases[hash]) {
  28972. var aliasFontRef = fontAliases[hash].aliasRef;
  28973. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  28974. this.fontCache.putAlias(fontRef, aliasFontRef);
  28975. return this.fontCache.get(fontRef);
  28976. }
  28977. } else {
  28978. fontAliases[hash] = { fontID: Font.getFontID() };
  28979. }
  28980. if (fontRefIsRef) {
  28981. fontAliases[hash].aliasRef = fontRef;
  28982. }
  28983. fontID = fontAliases[hash].fontID;
  28984. }
  28985. if (fontRefIsRef) {
  28986. this.fontCache.put(fontRef, fontCapability.promise);
  28987. } else {
  28988. if (!fontID) {
  28989. fontID = this.idFactory.createObjId();
  28990. }
  28991. this.fontCache.put('id_' + fontID, fontCapability.promise);
  28992. }
  28993. assert(fontID, 'The "fontID" must be defined.');
  28994. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  28995. font.translated = fontCapability.promise;
  28996. var translatedPromise;
  28997. try {
  28998. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  28999. } catch (e) {
  29000. translatedPromise = Promise.reject(e);
  29001. }
  29002. var self = this;
  29003. translatedPromise.then(function (translatedFont) {
  29004. if (translatedFont.fontType !== undefined) {
  29005. var xrefFontStats = xref.stats.fontTypes;
  29006. xrefFontStats[translatedFont.fontType] = true;
  29007. }
  29008. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29009. }, function (reason) {
  29010. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29011. try {
  29012. var descriptor = preEvaluatedFont.descriptor;
  29013. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29014. var subtype = fontFile3 && fontFile3.get('Subtype');
  29015. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29016. var xrefFontStats = xref.stats.fontTypes;
  29017. xrefFontStats[fontType] = true;
  29018. } catch (ex) {
  29019. }
  29020. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29021. });
  29022. return fontCapability.promise;
  29023. },
  29024. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29025. var lastIndex = operatorList.length - 1;
  29026. if (!args) {
  29027. args = [];
  29028. }
  29029. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29030. operatorList.addOp(OPS.constructPath, [
  29031. [fn],
  29032. args
  29033. ]);
  29034. } else {
  29035. var opArgs = operatorList.argsArray[lastIndex];
  29036. opArgs[0].push(fn);
  29037. Array.prototype.push.apply(opArgs[1], args);
  29038. }
  29039. },
  29040. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29041. var patternName = args[args.length - 1];
  29042. var pattern;
  29043. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29044. var dict = isStream(pattern) ? pattern.dict : pattern;
  29045. var typeNum = dict.get('PatternType');
  29046. if (typeNum === TILING_PATTERN) {
  29047. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29048. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29049. } else if (typeNum === SHADING_PATTERN) {
  29050. var shading = dict.get('Shading');
  29051. var matrix = dict.getArray('Matrix');
  29052. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29053. operatorList.addOp(fn, pattern.getIR());
  29054. return Promise.resolve();
  29055. }
  29056. return Promise.reject('Unknown PatternType: ' + typeNum);
  29057. }
  29058. operatorList.addOp(fn, args);
  29059. return Promise.resolve();
  29060. },
  29061. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29062. var self = this;
  29063. var xref = this.xref;
  29064. var imageCache = Object.create(null);
  29065. assert(operatorList);
  29066. resources = resources || Dict.empty;
  29067. var xobjs = resources.get('XObject') || Dict.empty;
  29068. var patterns = resources.get('Pattern') || Dict.empty;
  29069. var stateManager = new StateManager(initialState || new EvalState());
  29070. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29071. var timeSlotManager = new TimeSlotManager();
  29072. return new Promise(function promiseBody(resolve, reject) {
  29073. var next = function (promise) {
  29074. promise.then(function () {
  29075. try {
  29076. promiseBody(resolve, reject);
  29077. } catch (ex) {
  29078. reject(ex);
  29079. }
  29080. }, reject);
  29081. };
  29082. task.ensureNotTerminated();
  29083. timeSlotManager.reset();
  29084. var stop, operation = {}, i, ii, cs;
  29085. while (!(stop = timeSlotManager.check())) {
  29086. operation.args = null;
  29087. if (!preprocessor.read(operation)) {
  29088. break;
  29089. }
  29090. var args = operation.args;
  29091. var fn = operation.fn;
  29092. switch (fn | 0) {
  29093. case OPS.paintXObject:
  29094. if (args[0].code) {
  29095. break;
  29096. }
  29097. var name = args[0].name;
  29098. if (!name) {
  29099. warn('XObject must be referred to by name.');
  29100. continue;
  29101. }
  29102. if (imageCache[name] !== undefined) {
  29103. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29104. args = null;
  29105. continue;
  29106. }
  29107. var xobj = xobjs.get(name);
  29108. if (xobj) {
  29109. assert(isStream(xobj), 'XObject should be a stream');
  29110. var type = xobj.dict.get('Subtype');
  29111. assert(isName(type), 'XObject should have a Name subtype');
  29112. if (type.name === 'Form') {
  29113. stateManager.save();
  29114. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29115. stateManager.restore();
  29116. }));
  29117. return;
  29118. } else if (type.name === 'Image') {
  29119. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29120. args = null;
  29121. continue;
  29122. } else if (type.name === 'PS') {
  29123. info('Ignored XObject subtype PS');
  29124. continue;
  29125. } else {
  29126. error('Unhandled XObject subtype ' + type.name);
  29127. }
  29128. }
  29129. break;
  29130. case OPS.setFont:
  29131. var fontSize = args[1];
  29132. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29133. operatorList.addDependency(loadedName);
  29134. operatorList.addOp(OPS.setFont, [
  29135. loadedName,
  29136. fontSize
  29137. ]);
  29138. }));
  29139. return;
  29140. case OPS.endInlineImage:
  29141. var cacheKey = args[0].cacheKey;
  29142. if (cacheKey) {
  29143. var cacheEntry = imageCache[cacheKey];
  29144. if (cacheEntry !== undefined) {
  29145. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29146. args = null;
  29147. continue;
  29148. }
  29149. }
  29150. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29151. args = null;
  29152. continue;
  29153. case OPS.showText:
  29154. args[0] = self.handleText(args[0], stateManager.state);
  29155. break;
  29156. case OPS.showSpacedText:
  29157. var arr = args[0];
  29158. var combinedGlyphs = [];
  29159. var arrLength = arr.length;
  29160. var state = stateManager.state;
  29161. for (i = 0; i < arrLength; ++i) {
  29162. var arrItem = arr[i];
  29163. if (isString(arrItem)) {
  29164. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29165. } else if (isNum(arrItem)) {
  29166. combinedGlyphs.push(arrItem);
  29167. }
  29168. }
  29169. args[0] = combinedGlyphs;
  29170. fn = OPS.showText;
  29171. break;
  29172. case OPS.nextLineShowText:
  29173. operatorList.addOp(OPS.nextLine);
  29174. args[0] = self.handleText(args[0], stateManager.state);
  29175. fn = OPS.showText;
  29176. break;
  29177. case OPS.nextLineSetSpacingShowText:
  29178. operatorList.addOp(OPS.nextLine);
  29179. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29180. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29181. args[0] = self.handleText(args[0], stateManager.state);
  29182. fn = OPS.showText;
  29183. break;
  29184. case OPS.setTextRenderingMode:
  29185. stateManager.state.textRenderingMode = args[0];
  29186. break;
  29187. case OPS.setFillColorSpace:
  29188. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29189. continue;
  29190. case OPS.setStrokeColorSpace:
  29191. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29192. continue;
  29193. case OPS.setFillColor:
  29194. cs = stateManager.state.fillColorSpace;
  29195. args = cs.getRgb(args, 0);
  29196. fn = OPS.setFillRGBColor;
  29197. break;
  29198. case OPS.setStrokeColor:
  29199. cs = stateManager.state.strokeColorSpace;
  29200. args = cs.getRgb(args, 0);
  29201. fn = OPS.setStrokeRGBColor;
  29202. break;
  29203. case OPS.setFillGray:
  29204. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29205. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29206. fn = OPS.setFillRGBColor;
  29207. break;
  29208. case OPS.setStrokeGray:
  29209. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29210. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29211. fn = OPS.setStrokeRGBColor;
  29212. break;
  29213. case OPS.setFillCMYKColor:
  29214. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29215. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29216. fn = OPS.setFillRGBColor;
  29217. break;
  29218. case OPS.setStrokeCMYKColor:
  29219. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29220. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29221. fn = OPS.setStrokeRGBColor;
  29222. break;
  29223. case OPS.setFillRGBColor:
  29224. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29225. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29226. break;
  29227. case OPS.setStrokeRGBColor:
  29228. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29229. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29230. break;
  29231. case OPS.setFillColorN:
  29232. cs = stateManager.state.fillColorSpace;
  29233. if (cs.name === 'Pattern') {
  29234. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29235. return;
  29236. }
  29237. args = cs.getRgb(args, 0);
  29238. fn = OPS.setFillRGBColor;
  29239. break;
  29240. case OPS.setStrokeColorN:
  29241. cs = stateManager.state.strokeColorSpace;
  29242. if (cs.name === 'Pattern') {
  29243. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29244. return;
  29245. }
  29246. args = cs.getRgb(args, 0);
  29247. fn = OPS.setStrokeRGBColor;
  29248. break;
  29249. case OPS.shadingFill:
  29250. var shadingRes = resources.get('Shading');
  29251. if (!shadingRes) {
  29252. error('No shading resource found');
  29253. }
  29254. var shading = shadingRes.get(args[0].name);
  29255. if (!shading) {
  29256. error('No shading object found');
  29257. }
  29258. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29259. var patternIR = shadingFill.getIR();
  29260. args = [patternIR];
  29261. fn = OPS.shadingFill;
  29262. break;
  29263. case OPS.setGState:
  29264. var dictName = args[0];
  29265. var extGState = resources.get('ExtGState');
  29266. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29267. break;
  29268. }
  29269. var gState = extGState.get(dictName.name);
  29270. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29271. return;
  29272. case OPS.moveTo:
  29273. case OPS.lineTo:
  29274. case OPS.curveTo:
  29275. case OPS.curveTo2:
  29276. case OPS.curveTo3:
  29277. case OPS.closePath:
  29278. self.buildPath(operatorList, fn, args);
  29279. continue;
  29280. case OPS.rectangle:
  29281. self.buildPath(operatorList, fn, args);
  29282. continue;
  29283. case OPS.markPoint:
  29284. case OPS.markPointProps:
  29285. case OPS.beginMarkedContent:
  29286. case OPS.beginMarkedContentProps:
  29287. case OPS.endMarkedContent:
  29288. case OPS.beginCompat:
  29289. case OPS.endCompat:
  29290. continue;
  29291. default:
  29292. if (args !== null) {
  29293. for (i = 0, ii = args.length; i < ii; i++) {
  29294. if (args[i] instanceof Dict) {
  29295. break;
  29296. }
  29297. }
  29298. if (i < ii) {
  29299. warn('getOperatorList - ignoring operator: ' + fn);
  29300. continue;
  29301. }
  29302. }
  29303. }
  29304. operatorList.addOp(fn, args);
  29305. }
  29306. if (stop) {
  29307. next(deferred);
  29308. return;
  29309. }
  29310. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  29311. operatorList.addOp(OPS.restore, []);
  29312. }
  29313. resolve();
  29314. });
  29315. },
  29316. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  29317. stateManager = stateManager || new StateManager(new TextState());
  29318. var WhitespaceRegexp = /\s/g;
  29319. var textContent = {
  29320. items: [],
  29321. styles: Object.create(null)
  29322. };
  29323. var textContentItem = {
  29324. initialized: false,
  29325. str: [],
  29326. width: 0,
  29327. height: 0,
  29328. vertical: false,
  29329. lastAdvanceWidth: 0,
  29330. lastAdvanceHeight: 0,
  29331. textAdvanceScale: 0,
  29332. spaceWidth: 0,
  29333. fakeSpaceMin: Infinity,
  29334. fakeMultiSpaceMin: Infinity,
  29335. fakeMultiSpaceMax: -0,
  29336. textRunBreakAllowed: false,
  29337. transform: null,
  29338. fontName: null
  29339. };
  29340. var SPACE_FACTOR = 0.3;
  29341. var MULTI_SPACE_FACTOR = 1.5;
  29342. var MULTI_SPACE_FACTOR_MAX = 4;
  29343. var self = this;
  29344. var xref = this.xref;
  29345. resources = xref.fetchIfRef(resources) || Dict.empty;
  29346. var xobjs = null;
  29347. var xobjsCache = Object.create(null);
  29348. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29349. var textState;
  29350. function ensureTextContentItem() {
  29351. if (textContentItem.initialized) {
  29352. return textContentItem;
  29353. }
  29354. var font = textState.font;
  29355. if (!(font.loadedName in textContent.styles)) {
  29356. textContent.styles[font.loadedName] = {
  29357. fontFamily: font.fallbackName,
  29358. ascent: font.ascent,
  29359. descent: font.descent,
  29360. vertical: font.vertical
  29361. };
  29362. }
  29363. textContentItem.fontName = font.loadedName;
  29364. var tsm = [
  29365. textState.fontSize * textState.textHScale,
  29366. 0,
  29367. 0,
  29368. textState.fontSize,
  29369. 0,
  29370. textState.textRise
  29371. ];
  29372. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  29373. var glyphHeight = font.bbox[3] - font.bbox[1];
  29374. if (glyphHeight > 0) {
  29375. glyphHeight = glyphHeight * textState.fontMatrix[3];
  29376. tsm[3] *= glyphHeight;
  29377. }
  29378. }
  29379. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  29380. textContentItem.transform = trm;
  29381. if (!font.vertical) {
  29382. textContentItem.width = 0;
  29383. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  29384. textContentItem.vertical = false;
  29385. } else {
  29386. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  29387. textContentItem.height = 0;
  29388. textContentItem.vertical = true;
  29389. }
  29390. var a = textState.textLineMatrix[0];
  29391. var b = textState.textLineMatrix[1];
  29392. var scaleLineX = Math.sqrt(a * a + b * b);
  29393. a = textState.ctm[0];
  29394. b = textState.ctm[1];
  29395. var scaleCtmX = Math.sqrt(a * a + b * b);
  29396. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  29397. textContentItem.lastAdvanceWidth = 0;
  29398. textContentItem.lastAdvanceHeight = 0;
  29399. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  29400. if (spaceWidth) {
  29401. textContentItem.spaceWidth = spaceWidth;
  29402. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  29403. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  29404. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  29405. textContentItem.textRunBreakAllowed = !font.isMonospace;
  29406. } else {
  29407. textContentItem.spaceWidth = 0;
  29408. textContentItem.fakeSpaceMin = Infinity;
  29409. textContentItem.fakeMultiSpaceMin = Infinity;
  29410. textContentItem.fakeMultiSpaceMax = 0;
  29411. textContentItem.textRunBreakAllowed = false;
  29412. }
  29413. textContentItem.initialized = true;
  29414. return textContentItem;
  29415. }
  29416. function replaceWhitespace(str) {
  29417. var i = 0, ii = str.length, code;
  29418. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  29419. i++;
  29420. }
  29421. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  29422. }
  29423. function runBidiTransform(textChunk) {
  29424. var str = textChunk.str.join('');
  29425. var bidiResult = bidi(str, -1, textChunk.vertical);
  29426. return {
  29427. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  29428. dir: bidiResult.dir,
  29429. width: textChunk.width,
  29430. height: textChunk.height,
  29431. transform: textChunk.transform,
  29432. fontName: textChunk.fontName
  29433. };
  29434. }
  29435. function handleSetFont(fontName, fontRef) {
  29436. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  29437. textState.font = translated.font;
  29438. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  29439. });
  29440. }
  29441. function buildTextContentItem(chars) {
  29442. var font = textState.font;
  29443. var textChunk = ensureTextContentItem();
  29444. var width = 0;
  29445. var height = 0;
  29446. var glyphs = font.charsToGlyphs(chars);
  29447. for (var i = 0; i < glyphs.length; i++) {
  29448. var glyph = glyphs[i];
  29449. var glyphWidth = null;
  29450. if (font.vertical && glyph.vmetric) {
  29451. glyphWidth = glyph.vmetric[0];
  29452. } else {
  29453. glyphWidth = glyph.width;
  29454. }
  29455. var glyphUnicode = glyph.unicode;
  29456. var NormalizedUnicodes = getNormalizedUnicodes();
  29457. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  29458. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  29459. }
  29460. glyphUnicode = reverseIfRtl(glyphUnicode);
  29461. var charSpacing = textState.charSpacing;
  29462. if (glyph.isSpace) {
  29463. var wordSpacing = textState.wordSpacing;
  29464. charSpacing += wordSpacing;
  29465. if (wordSpacing > 0) {
  29466. addFakeSpaces(wordSpacing, textChunk.str);
  29467. }
  29468. }
  29469. var tx = 0;
  29470. var ty = 0;
  29471. if (!font.vertical) {
  29472. var w0 = glyphWidth * textState.fontMatrix[0];
  29473. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  29474. width += tx;
  29475. } else {
  29476. var w1 = glyphWidth * textState.fontMatrix[0];
  29477. ty = w1 * textState.fontSize + charSpacing;
  29478. height += ty;
  29479. }
  29480. textState.translateTextMatrix(tx, ty);
  29481. textChunk.str.push(glyphUnicode);
  29482. }
  29483. if (!font.vertical) {
  29484. textChunk.lastAdvanceWidth = width;
  29485. textChunk.width += width;
  29486. } else {
  29487. textChunk.lastAdvanceHeight = height;
  29488. textChunk.height += Math.abs(height);
  29489. }
  29490. return textChunk;
  29491. }
  29492. function addFakeSpaces(width, strBuf) {
  29493. if (width < textContentItem.fakeSpaceMin) {
  29494. return;
  29495. }
  29496. if (width < textContentItem.fakeMultiSpaceMin) {
  29497. strBuf.push(' ');
  29498. return;
  29499. }
  29500. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  29501. while (fakeSpaces-- > 0) {
  29502. strBuf.push(' ');
  29503. }
  29504. }
  29505. function flushTextContentItem() {
  29506. if (!textContentItem.initialized) {
  29507. return;
  29508. }
  29509. textContentItem.width *= textContentItem.textAdvanceScale;
  29510. textContentItem.height *= textContentItem.textAdvanceScale;
  29511. textContent.items.push(runBidiTransform(textContentItem));
  29512. textContentItem.initialized = false;
  29513. textContentItem.str.length = 0;
  29514. }
  29515. var timeSlotManager = new TimeSlotManager();
  29516. return new Promise(function promiseBody(resolve, reject) {
  29517. var next = function (promise) {
  29518. promise.then(function () {
  29519. try {
  29520. promiseBody(resolve, reject);
  29521. } catch (ex) {
  29522. reject(ex);
  29523. }
  29524. }, reject);
  29525. };
  29526. task.ensureNotTerminated();
  29527. timeSlotManager.reset();
  29528. var stop, operation = {}, args = [];
  29529. while (!(stop = timeSlotManager.check())) {
  29530. args.length = 0;
  29531. operation.args = args;
  29532. if (!preprocessor.read(operation)) {
  29533. break;
  29534. }
  29535. textState = stateManager.state;
  29536. var fn = operation.fn;
  29537. args = operation.args;
  29538. var advance, diff;
  29539. switch (fn | 0) {
  29540. case OPS.setFont:
  29541. var fontNameArg = args[0].name, fontSizeArg = args[1];
  29542. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  29543. break;
  29544. }
  29545. flushTextContentItem();
  29546. textState.fontName = fontNameArg;
  29547. textState.fontSize = fontSizeArg;
  29548. next(handleSetFont(fontNameArg, null));
  29549. return;
  29550. case OPS.setTextRise:
  29551. flushTextContentItem();
  29552. textState.textRise = args[0];
  29553. break;
  29554. case OPS.setHScale:
  29555. flushTextContentItem();
  29556. textState.textHScale = args[0] / 100;
  29557. break;
  29558. case OPS.setLeading:
  29559. flushTextContentItem();
  29560. textState.leading = args[0];
  29561. break;
  29562. case OPS.moveText:
  29563. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  29564. advance = args[0] - args[1];
  29565. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  29566. textState.translateTextLineMatrix(args[0], args[1]);
  29567. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  29568. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  29569. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  29570. addFakeSpaces(diff, textContentItem.str);
  29571. break;
  29572. }
  29573. flushTextContentItem();
  29574. textState.translateTextLineMatrix(args[0], args[1]);
  29575. textState.textMatrix = textState.textLineMatrix.slice();
  29576. break;
  29577. case OPS.setLeadingMoveText:
  29578. flushTextContentItem();
  29579. textState.leading = -args[1];
  29580. textState.translateTextLineMatrix(args[0], args[1]);
  29581. textState.textMatrix = textState.textLineMatrix.slice();
  29582. break;
  29583. case OPS.nextLine:
  29584. flushTextContentItem();
  29585. textState.carriageReturn();
  29586. break;
  29587. case OPS.setTextMatrix:
  29588. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  29589. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  29590. textState.translateTextLineMatrix(advance.width, advance.height);
  29591. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  29592. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  29593. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  29594. addFakeSpaces(diff, textContentItem.str);
  29595. break;
  29596. }
  29597. flushTextContentItem();
  29598. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29599. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29600. break;
  29601. case OPS.setCharSpacing:
  29602. textState.charSpacing = args[0];
  29603. break;
  29604. case OPS.setWordSpacing:
  29605. textState.wordSpacing = args[0];
  29606. break;
  29607. case OPS.beginText:
  29608. flushTextContentItem();
  29609. textState.textMatrix = IDENTITY_MATRIX.slice();
  29610. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  29611. break;
  29612. case OPS.showSpacedText:
  29613. var items = args[0];
  29614. var offset;
  29615. for (var j = 0, jj = items.length; j < jj; j++) {
  29616. if (typeof items[j] === 'string') {
  29617. buildTextContentItem(items[j]);
  29618. } else if (isNum(items[j])) {
  29619. ensureTextContentItem();
  29620. advance = items[j] * textState.fontSize / 1000;
  29621. var breakTextRun = false;
  29622. if (textState.font.vertical) {
  29623. offset = advance;
  29624. textState.translateTextMatrix(0, offset);
  29625. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29626. if (!breakTextRun) {
  29627. textContentItem.height += offset;
  29628. }
  29629. } else {
  29630. advance = -advance;
  29631. offset = advance * textState.textHScale;
  29632. textState.translateTextMatrix(offset, 0);
  29633. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29634. if (!breakTextRun) {
  29635. textContentItem.width += offset;
  29636. }
  29637. }
  29638. if (breakTextRun) {
  29639. flushTextContentItem();
  29640. } else if (advance > 0) {
  29641. addFakeSpaces(advance, textContentItem.str);
  29642. }
  29643. }
  29644. }
  29645. break;
  29646. case OPS.showText:
  29647. buildTextContentItem(args[0]);
  29648. break;
  29649. case OPS.nextLineShowText:
  29650. flushTextContentItem();
  29651. textState.carriageReturn();
  29652. buildTextContentItem(args[0]);
  29653. break;
  29654. case OPS.nextLineSetSpacingShowText:
  29655. flushTextContentItem();
  29656. textState.wordSpacing = args[0];
  29657. textState.charSpacing = args[1];
  29658. textState.carriageReturn();
  29659. buildTextContentItem(args[2]);
  29660. break;
  29661. case OPS.paintXObject:
  29662. flushTextContentItem();
  29663. if (args[0].code) {
  29664. break;
  29665. }
  29666. if (!xobjs) {
  29667. xobjs = resources.get('XObject') || Dict.empty;
  29668. }
  29669. var name = args[0].name;
  29670. if (xobjsCache.key === name) {
  29671. if (xobjsCache.texts) {
  29672. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  29673. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  29674. }
  29675. break;
  29676. }
  29677. var xobj = xobjs.get(name);
  29678. if (!xobj) {
  29679. break;
  29680. }
  29681. assert(isStream(xobj), 'XObject should be a stream');
  29682. var type = xobj.dict.get('Subtype');
  29683. assert(isName(type), 'XObject should have a Name subtype');
  29684. if ('Form' !== type.name) {
  29685. xobjsCache.key = name;
  29686. xobjsCache.texts = null;
  29687. break;
  29688. }
  29689. stateManager.save();
  29690. var matrix = xobj.dict.getArray('Matrix');
  29691. if (isArray(matrix) && matrix.length === 6) {
  29692. stateManager.transform(matrix);
  29693. }
  29694. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  29695. Util.appendToArray(textContent.items, formTextContent.items);
  29696. Util.extendObj(textContent.styles, formTextContent.styles);
  29697. stateManager.restore();
  29698. xobjsCache.key = name;
  29699. xobjsCache.texts = formTextContent;
  29700. }));
  29701. return;
  29702. case OPS.setGState:
  29703. flushTextContentItem();
  29704. var dictName = args[0];
  29705. var extGState = resources.get('ExtGState');
  29706. if (!isDict(extGState) || !isName(dictName)) {
  29707. break;
  29708. }
  29709. var gState = extGState.get(dictName.name);
  29710. if (!isDict(gState)) {
  29711. break;
  29712. }
  29713. var gStateFont = gState.get('Font');
  29714. if (gStateFont) {
  29715. textState.fontName = null;
  29716. textState.fontSize = gStateFont[1];
  29717. next(handleSetFont(null, gStateFont[0]));
  29718. return;
  29719. }
  29720. break;
  29721. }
  29722. }
  29723. if (stop) {
  29724. next(deferred);
  29725. return;
  29726. }
  29727. flushTextContentItem();
  29728. resolve(textContent);
  29729. });
  29730. },
  29731. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  29732. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  29733. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  29734. if (properties.composite) {
  29735. var cidSystemInfo = dict.get('CIDSystemInfo');
  29736. if (isDict(cidSystemInfo)) {
  29737. properties.cidSystemInfo = {
  29738. registry: cidSystemInfo.get('Registry'),
  29739. ordering: cidSystemInfo.get('Ordering'),
  29740. supplement: cidSystemInfo.get('Supplement')
  29741. };
  29742. }
  29743. var cidToGidMap = dict.get('CIDToGIDMap');
  29744. if (isStream(cidToGidMap)) {
  29745. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  29746. }
  29747. }
  29748. var differences = [];
  29749. var baseEncodingName = null;
  29750. var encoding;
  29751. if (dict.has('Encoding')) {
  29752. encoding = dict.get('Encoding');
  29753. if (isDict(encoding)) {
  29754. baseEncodingName = encoding.get('BaseEncoding');
  29755. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  29756. if (encoding.has('Differences')) {
  29757. var diffEncoding = encoding.get('Differences');
  29758. var index = 0;
  29759. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  29760. var data = xref.fetchIfRef(diffEncoding[j]);
  29761. if (isNum(data)) {
  29762. index = data;
  29763. } else if (isName(data)) {
  29764. differences[index++] = data.name;
  29765. } else {
  29766. error('Invalid entry in \'Differences\' array: ' + data);
  29767. }
  29768. }
  29769. }
  29770. } else if (isName(encoding)) {
  29771. baseEncodingName = encoding.name;
  29772. } else {
  29773. error('Encoding is not a Name nor a Dict');
  29774. }
  29775. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  29776. baseEncodingName = null;
  29777. }
  29778. }
  29779. if (baseEncodingName) {
  29780. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  29781. } else {
  29782. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  29783. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  29784. encoding = StandardEncoding;
  29785. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  29786. encoding = WinAnsiEncoding;
  29787. }
  29788. if (isSymbolicFont) {
  29789. encoding = MacRomanEncoding;
  29790. if (!properties.file) {
  29791. if (/Symbol/i.test(properties.name)) {
  29792. encoding = SymbolSetEncoding;
  29793. } else if (/Dingbats/i.test(properties.name)) {
  29794. encoding = ZapfDingbatsEncoding;
  29795. }
  29796. }
  29797. }
  29798. properties.defaultEncoding = encoding;
  29799. }
  29800. properties.differences = differences;
  29801. properties.baseEncodingName = baseEncodingName;
  29802. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  29803. properties.dict = dict;
  29804. return toUnicodePromise.then(function (toUnicode) {
  29805. properties.toUnicode = toUnicode;
  29806. return this.buildToUnicode(properties);
  29807. }.bind(this)).then(function (toUnicode) {
  29808. properties.toUnicode = toUnicode;
  29809. return properties;
  29810. });
  29811. },
  29812. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  29813. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  29814. if (properties.hasIncludedToUnicodeMap) {
  29815. return Promise.resolve(properties.toUnicode);
  29816. }
  29817. var toUnicode, charcode, glyphName;
  29818. if (!properties.composite) {
  29819. toUnicode = [];
  29820. var encoding = properties.defaultEncoding.slice();
  29821. var baseEncodingName = properties.baseEncodingName;
  29822. var differences = properties.differences;
  29823. for (charcode in differences) {
  29824. glyphName = differences[charcode];
  29825. if (glyphName === '.notdef') {
  29826. continue;
  29827. }
  29828. encoding[charcode] = glyphName;
  29829. }
  29830. var glyphsUnicodeMap = getGlyphsUnicode();
  29831. for (charcode in encoding) {
  29832. glyphName = encoding[charcode];
  29833. if (glyphName === '') {
  29834. continue;
  29835. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  29836. var code = 0;
  29837. switch (glyphName[0]) {
  29838. case 'G':
  29839. if (glyphName.length === 3) {
  29840. code = parseInt(glyphName.substr(1), 16);
  29841. }
  29842. break;
  29843. case 'g':
  29844. if (glyphName.length === 5) {
  29845. code = parseInt(glyphName.substr(1), 16);
  29846. }
  29847. break;
  29848. case 'C':
  29849. case 'c':
  29850. if (glyphName.length >= 3) {
  29851. code = +glyphName.substr(1);
  29852. }
  29853. break;
  29854. default:
  29855. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  29856. if (unicode !== -1) {
  29857. code = unicode;
  29858. }
  29859. }
  29860. if (code) {
  29861. if (baseEncodingName && code === +charcode) {
  29862. var baseEncoding = getEncoding(baseEncodingName);
  29863. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  29864. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29865. continue;
  29866. }
  29867. }
  29868. toUnicode[charcode] = String.fromCharCode(code);
  29869. }
  29870. continue;
  29871. }
  29872. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29873. }
  29874. return Promise.resolve(new ToUnicodeMap(toUnicode));
  29875. }
  29876. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
  29877. var registry = properties.cidSystemInfo.registry;
  29878. var ordering = properties.cidSystemInfo.ordering;
  29879. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  29880. return CMapFactory.create({
  29881. encoding: ucs2CMapName,
  29882. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29883. useCMap: null
  29884. }).then(function (ucs2CMap) {
  29885. var cMap = properties.cMap;
  29886. toUnicode = [];
  29887. cMap.forEach(function (charcode, cid) {
  29888. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  29889. var ucs2 = ucs2CMap.lookup(cid);
  29890. if (ucs2) {
  29891. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  29892. }
  29893. });
  29894. return new ToUnicodeMap(toUnicode);
  29895. });
  29896. }
  29897. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  29898. },
  29899. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  29900. var cmapObj = toUnicode;
  29901. if (isName(cmapObj)) {
  29902. return CMapFactory.create({
  29903. encoding: cmapObj,
  29904. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29905. useCMap: null
  29906. }).then(function (cmap) {
  29907. if (cmap instanceof IdentityCMap) {
  29908. return new IdentityToUnicodeMap(0, 0xFFFF);
  29909. }
  29910. return new ToUnicodeMap(cmap.getMap());
  29911. });
  29912. } else if (isStream(cmapObj)) {
  29913. return CMapFactory.create({
  29914. encoding: cmapObj,
  29915. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29916. useCMap: null
  29917. }).then(function (cmap) {
  29918. if (cmap instanceof IdentityCMap) {
  29919. return new IdentityToUnicodeMap(0, 0xFFFF);
  29920. }
  29921. var map = new Array(cmap.length);
  29922. cmap.forEach(function (charCode, token) {
  29923. var str = [];
  29924. for (var k = 0; k < token.length; k += 2) {
  29925. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29926. if ((w1 & 0xF800) !== 0xD800) {
  29927. str.push(w1);
  29928. continue;
  29929. }
  29930. k += 2;
  29931. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29932. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  29933. }
  29934. map[charCode] = String.fromCharCode.apply(String, str);
  29935. });
  29936. return new ToUnicodeMap(map);
  29937. });
  29938. }
  29939. return Promise.resolve(null);
  29940. },
  29941. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  29942. var glyphsData = cidToGidStream.getBytes();
  29943. var result = [];
  29944. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  29945. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  29946. if (glyphID === 0) {
  29947. continue;
  29948. }
  29949. var code = j >> 1;
  29950. result[code] = glyphID;
  29951. }
  29952. return result;
  29953. },
  29954. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  29955. var glyphsWidths = [];
  29956. var defaultWidth = 0;
  29957. var glyphsVMetrics = [];
  29958. var defaultVMetrics;
  29959. var i, ii, j, jj, start, code, widths;
  29960. if (properties.composite) {
  29961. defaultWidth = dict.get('DW') || 1000;
  29962. widths = dict.get('W');
  29963. if (widths) {
  29964. for (i = 0, ii = widths.length; i < ii; i++) {
  29965. start = xref.fetchIfRef(widths[i++]);
  29966. code = xref.fetchIfRef(widths[i]);
  29967. if (isArray(code)) {
  29968. for (j = 0, jj = code.length; j < jj; j++) {
  29969. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  29970. }
  29971. } else {
  29972. var width = xref.fetchIfRef(widths[++i]);
  29973. for (j = start; j <= code; j++) {
  29974. glyphsWidths[j] = width;
  29975. }
  29976. }
  29977. }
  29978. }
  29979. if (properties.vertical) {
  29980. var vmetrics = dict.getArray('DW2') || [
  29981. 880,
  29982. -1000
  29983. ];
  29984. defaultVMetrics = [
  29985. vmetrics[1],
  29986. defaultWidth * 0.5,
  29987. vmetrics[0]
  29988. ];
  29989. vmetrics = dict.get('W2');
  29990. if (vmetrics) {
  29991. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  29992. start = xref.fetchIfRef(vmetrics[i++]);
  29993. code = xref.fetchIfRef(vmetrics[i]);
  29994. if (isArray(code)) {
  29995. for (j = 0, jj = code.length; j < jj; j++) {
  29996. glyphsVMetrics[start++] = [
  29997. xref.fetchIfRef(code[j++]),
  29998. xref.fetchIfRef(code[j++]),
  29999. xref.fetchIfRef(code[j])
  30000. ];
  30001. }
  30002. } else {
  30003. var vmetric = [
  30004. xref.fetchIfRef(vmetrics[++i]),
  30005. xref.fetchIfRef(vmetrics[++i]),
  30006. xref.fetchIfRef(vmetrics[++i])
  30007. ];
  30008. for (j = start; j <= code; j++) {
  30009. glyphsVMetrics[j] = vmetric;
  30010. }
  30011. }
  30012. }
  30013. }
  30014. }
  30015. } else {
  30016. var firstChar = properties.firstChar;
  30017. widths = dict.get('Widths');
  30018. if (widths) {
  30019. j = firstChar;
  30020. for (i = 0, ii = widths.length; i < ii; i++) {
  30021. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30022. }
  30023. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30024. } else {
  30025. var baseFontName = dict.get('BaseFont');
  30026. if (isName(baseFontName)) {
  30027. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30028. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30029. defaultWidth = metrics.defaultWidth;
  30030. }
  30031. }
  30032. }
  30033. var isMonospace = true;
  30034. var firstWidth = defaultWidth;
  30035. for (var glyph in glyphsWidths) {
  30036. var glyphWidth = glyphsWidths[glyph];
  30037. if (!glyphWidth) {
  30038. continue;
  30039. }
  30040. if (!firstWidth) {
  30041. firstWidth = glyphWidth;
  30042. continue;
  30043. }
  30044. if (firstWidth !== glyphWidth) {
  30045. isMonospace = false;
  30046. break;
  30047. }
  30048. }
  30049. if (isMonospace) {
  30050. properties.flags |= FontFlags.FixedPitch;
  30051. }
  30052. properties.defaultWidth = defaultWidth;
  30053. properties.widths = glyphsWidths;
  30054. properties.defaultVMetrics = defaultVMetrics;
  30055. properties.vmetrics = glyphsVMetrics;
  30056. },
  30057. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30058. var fontNameWoStyle = baseFontName.split('-')[0];
  30059. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30060. },
  30061. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30062. var defaultWidth = 0;
  30063. var widths = [];
  30064. var monospace = false;
  30065. var stdFontMap = getStdFontMap();
  30066. var lookupName = stdFontMap[name] || name;
  30067. var Metrics = getMetrics();
  30068. if (!(lookupName in Metrics)) {
  30069. if (this.isSerifFont(name)) {
  30070. lookupName = 'Times-Roman';
  30071. } else {
  30072. lookupName = 'Helvetica';
  30073. }
  30074. }
  30075. var glyphWidths = Metrics[lookupName];
  30076. if (isNum(glyphWidths)) {
  30077. defaultWidth = glyphWidths;
  30078. monospace = true;
  30079. } else {
  30080. widths = glyphWidths();
  30081. }
  30082. return {
  30083. defaultWidth: defaultWidth,
  30084. monospace: monospace,
  30085. widths: widths
  30086. };
  30087. },
  30088. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30089. var widths = Object.create(null);
  30090. var differences = properties.differences;
  30091. var encoding = properties.defaultEncoding;
  30092. for (var charCode = 0; charCode < 256; charCode++) {
  30093. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30094. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30095. continue;
  30096. }
  30097. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30098. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30099. continue;
  30100. }
  30101. }
  30102. return widths;
  30103. },
  30104. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30105. var baseDict = dict;
  30106. var type = dict.get('Subtype');
  30107. assert(isName(type), 'invalid font Subtype');
  30108. var composite = false;
  30109. var uint8array;
  30110. if (type.name === 'Type0') {
  30111. var df = dict.get('DescendantFonts');
  30112. if (!df) {
  30113. error('Descendant fonts are not specified');
  30114. }
  30115. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30116. type = dict.get('Subtype');
  30117. assert(isName(type), 'invalid font Subtype');
  30118. composite = true;
  30119. }
  30120. var descriptor = dict.get('FontDescriptor');
  30121. if (descriptor) {
  30122. var hash = new MurmurHash3_64();
  30123. var encoding = baseDict.getRaw('Encoding');
  30124. if (isName(encoding)) {
  30125. hash.update(encoding.name);
  30126. } else if (isRef(encoding)) {
  30127. hash.update(encoding.toString());
  30128. } else if (isDict(encoding)) {
  30129. var keys = encoding.getKeys();
  30130. for (var i = 0, ii = keys.length; i < ii; i++) {
  30131. var entry = encoding.getRaw(keys[i]);
  30132. if (isName(entry)) {
  30133. hash.update(entry.name);
  30134. } else if (isRef(entry)) {
  30135. hash.update(entry.toString());
  30136. } else if (isArray(entry)) {
  30137. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30138. for (var j = 0; j < diffLength; j++) {
  30139. var diffEntry = entry[j];
  30140. if (isName(diffEntry)) {
  30141. diffBuf[j] = diffEntry.name;
  30142. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30143. diffBuf[j] = diffEntry.toString();
  30144. }
  30145. }
  30146. hash.update(diffBuf.join());
  30147. }
  30148. }
  30149. }
  30150. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30151. if (isStream(toUnicode)) {
  30152. var stream = toUnicode.str || toUnicode;
  30153. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30154. hash.update(uint8array);
  30155. } else if (isName(toUnicode)) {
  30156. hash.update(toUnicode.name);
  30157. }
  30158. var widths = dict.get('Widths') || baseDict.get('Widths');
  30159. if (widths) {
  30160. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30161. hash.update(uint8array);
  30162. }
  30163. }
  30164. return {
  30165. descriptor: descriptor,
  30166. dict: dict,
  30167. baseDict: baseDict,
  30168. composite: composite,
  30169. type: type.name,
  30170. hash: hash ? hash.hexdigest() : ''
  30171. };
  30172. },
  30173. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30174. var baseDict = preEvaluatedFont.baseDict;
  30175. var dict = preEvaluatedFont.dict;
  30176. var composite = preEvaluatedFont.composite;
  30177. var descriptor = preEvaluatedFont.descriptor;
  30178. var type = preEvaluatedFont.type;
  30179. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30180. var properties;
  30181. if (!descriptor) {
  30182. if (type === 'Type3') {
  30183. descriptor = new Dict(null);
  30184. descriptor.set('FontName', Name.get(type));
  30185. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30186. } else {
  30187. var baseFontName = dict.get('BaseFont');
  30188. if (!isName(baseFontName)) {
  30189. error('Base font is not specified');
  30190. }
  30191. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30192. var metrics = this.getBaseFontMetrics(baseFontName);
  30193. var fontNameWoStyle = baseFontName.split('-')[0];
  30194. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30195. properties = {
  30196. type: type,
  30197. name: baseFontName,
  30198. widths: metrics.widths,
  30199. defaultWidth: metrics.defaultWidth,
  30200. flags: flags,
  30201. firstChar: 0,
  30202. lastChar: maxCharIndex
  30203. };
  30204. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30205. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30206. return new Font(baseFontName, null, properties);
  30207. }.bind(this));
  30208. }
  30209. }
  30210. var firstChar = dict.get('FirstChar') || 0;
  30211. var lastChar = dict.get('LastChar') || maxCharIndex;
  30212. var fontName = descriptor.get('FontName');
  30213. var baseFont = dict.get('BaseFont');
  30214. if (isString(fontName)) {
  30215. fontName = Name.get(fontName);
  30216. }
  30217. if (isString(baseFont)) {
  30218. baseFont = Name.get(baseFont);
  30219. }
  30220. if (type !== 'Type3') {
  30221. var fontNameStr = fontName && fontName.name;
  30222. var baseFontStr = baseFont && baseFont.name;
  30223. if (fontNameStr !== baseFontStr) {
  30224. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30225. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30226. fontName = baseFont;
  30227. }
  30228. }
  30229. }
  30230. fontName = fontName || baseFont;
  30231. assert(isName(fontName), 'invalid font name');
  30232. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30233. if (fontFile) {
  30234. if (fontFile.dict) {
  30235. var subtype = fontFile.dict.get('Subtype');
  30236. if (subtype) {
  30237. subtype = subtype.name;
  30238. }
  30239. var length1 = fontFile.dict.get('Length1');
  30240. var length2 = fontFile.dict.get('Length2');
  30241. var length3 = fontFile.dict.get('Length3');
  30242. }
  30243. }
  30244. properties = {
  30245. type: type,
  30246. name: fontName.name,
  30247. subtype: subtype,
  30248. file: fontFile,
  30249. length1: length1,
  30250. length2: length2,
  30251. length3: length3,
  30252. loadedName: baseDict.loadedName,
  30253. composite: composite,
  30254. wideChars: composite,
  30255. fixedPitch: false,
  30256. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30257. firstChar: firstChar || 0,
  30258. lastChar: lastChar || maxCharIndex,
  30259. bbox: descriptor.getArray('FontBBox'),
  30260. ascent: descriptor.get('Ascent'),
  30261. descent: descriptor.get('Descent'),
  30262. xHeight: descriptor.get('XHeight'),
  30263. capHeight: descriptor.get('CapHeight'),
  30264. flags: descriptor.get('Flags'),
  30265. italicAngle: descriptor.get('ItalicAngle'),
  30266. coded: false
  30267. };
  30268. var cMapPromise;
  30269. if (composite) {
  30270. var cidEncoding = baseDict.get('Encoding');
  30271. if (isName(cidEncoding)) {
  30272. properties.cidEncoding = cidEncoding.name;
  30273. }
  30274. cMapPromise = CMapFactory.create({
  30275. encoding: cidEncoding,
  30276. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30277. useCMap: null
  30278. }).then(function (cMap) {
  30279. properties.cMap = cMap;
  30280. properties.vertical = properties.cMap.vertical;
  30281. });
  30282. } else {
  30283. cMapPromise = Promise.resolve(undefined);
  30284. }
  30285. return cMapPromise.then(function () {
  30286. return this.extractDataStructures(dict, baseDict, xref, properties);
  30287. }.bind(this)).then(function (properties) {
  30288. this.extractWidths(dict, xref, descriptor, properties);
  30289. if (type === 'Type3') {
  30290. properties.isType3Font = true;
  30291. }
  30292. return new Font(fontName.name, fontFile, properties);
  30293. }.bind(this));
  30294. }
  30295. };
  30296. return PartialEvaluator;
  30297. }();
  30298. var TranslatedFont = function TranslatedFontClosure() {
  30299. function TranslatedFont(loadedName, font, dict) {
  30300. this.loadedName = loadedName;
  30301. this.font = font;
  30302. this.dict = dict;
  30303. this.type3Loaded = null;
  30304. this.sent = false;
  30305. }
  30306. TranslatedFont.prototype = {
  30307. send: function (handler) {
  30308. if (this.sent) {
  30309. return;
  30310. }
  30311. var fontData = this.font.exportData();
  30312. handler.send('commonobj', [
  30313. this.loadedName,
  30314. 'Font',
  30315. fontData
  30316. ]);
  30317. this.sent = true;
  30318. },
  30319. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  30320. assert(this.font.isType3Font);
  30321. if (this.type3Loaded) {
  30322. return this.type3Loaded;
  30323. }
  30324. var translatedFont = this.font;
  30325. var loadCharProcsPromise = Promise.resolve();
  30326. var charProcs = this.dict.get('CharProcs');
  30327. var fontResources = this.dict.get('Resources') || resources;
  30328. var charProcKeys = charProcs.getKeys();
  30329. var charProcOperatorList = Object.create(null);
  30330. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  30331. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  30332. var glyphStream = charProcs.get(key);
  30333. var operatorList = new OperatorList();
  30334. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  30335. charProcOperatorList[key] = operatorList.getIR();
  30336. parentOperatorList.addDependencies(operatorList.dependencies);
  30337. }, function (reason) {
  30338. warn('Type3 font resource \"' + key + '\" is not available');
  30339. var operatorList = new OperatorList();
  30340. charProcOperatorList[key] = operatorList.getIR();
  30341. });
  30342. }.bind(this, charProcKeys[i]));
  30343. }
  30344. this.type3Loaded = loadCharProcsPromise.then(function () {
  30345. translatedFont.charProcOperatorList = charProcOperatorList;
  30346. });
  30347. return this.type3Loaded;
  30348. }
  30349. };
  30350. return TranslatedFont;
  30351. }();
  30352. var OperatorList = function OperatorListClosure() {
  30353. var CHUNK_SIZE = 1000;
  30354. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  30355. function getTransfers(queue) {
  30356. var transfers = [];
  30357. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  30358. for (var i = 0, ii = queue.length; i < ii; i++) {
  30359. switch (fnArray[i]) {
  30360. case OPS.paintInlineImageXObject:
  30361. case OPS.paintInlineImageXObjectGroup:
  30362. case OPS.paintImageMaskXObject:
  30363. var arg = argsArray[i][0];
  30364. if (!arg.cached) {
  30365. transfers.push(arg.data.buffer);
  30366. }
  30367. break;
  30368. }
  30369. }
  30370. return transfers;
  30371. }
  30372. function OperatorList(intent, messageHandler, pageIndex) {
  30373. this.messageHandler = messageHandler;
  30374. this.fnArray = [];
  30375. this.argsArray = [];
  30376. this.dependencies = Object.create(null);
  30377. this._totalLength = 0;
  30378. this.pageIndex = pageIndex;
  30379. this.intent = intent;
  30380. }
  30381. OperatorList.prototype = {
  30382. get length() {
  30383. return this.argsArray.length;
  30384. },
  30385. get totalLength() {
  30386. return this._totalLength + this.length;
  30387. },
  30388. addOp: function (fn, args) {
  30389. this.fnArray.push(fn);
  30390. this.argsArray.push(args);
  30391. if (this.messageHandler) {
  30392. if (this.fnArray.length >= CHUNK_SIZE) {
  30393. this.flush();
  30394. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  30395. this.flush();
  30396. }
  30397. }
  30398. },
  30399. addDependency: function (dependency) {
  30400. if (dependency in this.dependencies) {
  30401. return;
  30402. }
  30403. this.dependencies[dependency] = true;
  30404. this.addOp(OPS.dependency, [dependency]);
  30405. },
  30406. addDependencies: function (dependencies) {
  30407. for (var key in dependencies) {
  30408. this.addDependency(key);
  30409. }
  30410. },
  30411. addOpList: function (opList) {
  30412. Util.extendObj(this.dependencies, opList.dependencies);
  30413. for (var i = 0, ii = opList.length; i < ii; i++) {
  30414. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  30415. }
  30416. },
  30417. getIR: function () {
  30418. return {
  30419. fnArray: this.fnArray,
  30420. argsArray: this.argsArray,
  30421. length: this.length
  30422. };
  30423. },
  30424. flush: function (lastChunk) {
  30425. if (this.intent !== 'oplist') {
  30426. new QueueOptimizer().optimize(this);
  30427. }
  30428. var transfers = getTransfers(this);
  30429. var length = this.length;
  30430. this._totalLength += length;
  30431. this.messageHandler.send('RenderPageChunk', {
  30432. operatorList: {
  30433. fnArray: this.fnArray,
  30434. argsArray: this.argsArray,
  30435. lastChunk: lastChunk,
  30436. length: length
  30437. },
  30438. pageIndex: this.pageIndex,
  30439. intent: this.intent
  30440. }, transfers);
  30441. this.dependencies = Object.create(null);
  30442. this.fnArray.length = 0;
  30443. this.argsArray.length = 0;
  30444. }
  30445. };
  30446. return OperatorList;
  30447. }();
  30448. var StateManager = function StateManagerClosure() {
  30449. function StateManager(initialState) {
  30450. this.state = initialState;
  30451. this.stateStack = [];
  30452. }
  30453. StateManager.prototype = {
  30454. save: function () {
  30455. var old = this.state;
  30456. this.stateStack.push(this.state);
  30457. this.state = old.clone();
  30458. },
  30459. restore: function () {
  30460. var prev = this.stateStack.pop();
  30461. if (prev) {
  30462. this.state = prev;
  30463. }
  30464. },
  30465. transform: function (args) {
  30466. this.state.ctm = Util.transform(this.state.ctm, args);
  30467. }
  30468. };
  30469. return StateManager;
  30470. }();
  30471. var TextState = function TextStateClosure() {
  30472. function TextState() {
  30473. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30474. this.fontName = null;
  30475. this.fontSize = 0;
  30476. this.font = null;
  30477. this.fontMatrix = FONT_IDENTITY_MATRIX;
  30478. this.textMatrix = IDENTITY_MATRIX.slice();
  30479. this.textLineMatrix = IDENTITY_MATRIX.slice();
  30480. this.charSpacing = 0;
  30481. this.wordSpacing = 0;
  30482. this.leading = 0;
  30483. this.textHScale = 1;
  30484. this.textRise = 0;
  30485. }
  30486. TextState.prototype = {
  30487. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30488. var m = this.textMatrix;
  30489. m[0] = a;
  30490. m[1] = b;
  30491. m[2] = c;
  30492. m[3] = d;
  30493. m[4] = e;
  30494. m[5] = f;
  30495. },
  30496. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30497. var m = this.textLineMatrix;
  30498. m[0] = a;
  30499. m[1] = b;
  30500. m[2] = c;
  30501. m[3] = d;
  30502. m[4] = e;
  30503. m[5] = f;
  30504. },
  30505. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  30506. var m = this.textMatrix;
  30507. m[4] = m[0] * x + m[2] * y + m[4];
  30508. m[5] = m[1] * x + m[3] * y + m[5];
  30509. },
  30510. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  30511. var m = this.textLineMatrix;
  30512. m[4] = m[0] * x + m[2] * y + m[4];
  30513. m[5] = m[1] * x + m[3] * y + m[5];
  30514. },
  30515. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  30516. var font = this.font;
  30517. if (!font) {
  30518. return null;
  30519. }
  30520. var m = this.textLineMatrix;
  30521. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  30522. return null;
  30523. }
  30524. var txDiff = e - m[4], tyDiff = f - m[5];
  30525. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  30526. return null;
  30527. }
  30528. var tx, ty, denominator = a * d - b * c;
  30529. if (font.vertical) {
  30530. tx = -tyDiff * c / denominator;
  30531. ty = tyDiff * a / denominator;
  30532. } else {
  30533. tx = txDiff * d / denominator;
  30534. ty = -txDiff * b / denominator;
  30535. }
  30536. return {
  30537. width: tx,
  30538. height: ty,
  30539. value: font.vertical ? ty : tx
  30540. };
  30541. },
  30542. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  30543. var tsm = [
  30544. this.fontSize * this.textHScale,
  30545. 0,
  30546. 0,
  30547. this.fontSize,
  30548. 0,
  30549. this.textRise
  30550. ];
  30551. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  30552. },
  30553. carriageReturn: function TextState_carriageReturn() {
  30554. this.translateTextLineMatrix(0, -this.leading);
  30555. this.textMatrix = this.textLineMatrix.slice();
  30556. },
  30557. clone: function TextState_clone() {
  30558. var clone = Object.create(this);
  30559. clone.textMatrix = this.textMatrix.slice();
  30560. clone.textLineMatrix = this.textLineMatrix.slice();
  30561. clone.fontMatrix = this.fontMatrix.slice();
  30562. return clone;
  30563. }
  30564. };
  30565. return TextState;
  30566. }();
  30567. var EvalState = function EvalStateClosure() {
  30568. function EvalState() {
  30569. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30570. this.font = null;
  30571. this.textRenderingMode = TextRenderingMode.FILL;
  30572. this.fillColorSpace = ColorSpace.singletons.gray;
  30573. this.strokeColorSpace = ColorSpace.singletons.gray;
  30574. }
  30575. EvalState.prototype = {
  30576. clone: function CanvasExtraState_clone() {
  30577. return Object.create(this);
  30578. }
  30579. };
  30580. return EvalState;
  30581. }();
  30582. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  30583. var getOPMap = getLookupTableFactory(function (t) {
  30584. t['w'] = {
  30585. id: OPS.setLineWidth,
  30586. numArgs: 1,
  30587. variableArgs: false
  30588. };
  30589. t['J'] = {
  30590. id: OPS.setLineCap,
  30591. numArgs: 1,
  30592. variableArgs: false
  30593. };
  30594. t['j'] = {
  30595. id: OPS.setLineJoin,
  30596. numArgs: 1,
  30597. variableArgs: false
  30598. };
  30599. t['M'] = {
  30600. id: OPS.setMiterLimit,
  30601. numArgs: 1,
  30602. variableArgs: false
  30603. };
  30604. t['d'] = {
  30605. id: OPS.setDash,
  30606. numArgs: 2,
  30607. variableArgs: false
  30608. };
  30609. t['ri'] = {
  30610. id: OPS.setRenderingIntent,
  30611. numArgs: 1,
  30612. variableArgs: false
  30613. };
  30614. t['i'] = {
  30615. id: OPS.setFlatness,
  30616. numArgs: 1,
  30617. variableArgs: false
  30618. };
  30619. t['gs'] = {
  30620. id: OPS.setGState,
  30621. numArgs: 1,
  30622. variableArgs: false
  30623. };
  30624. t['q'] = {
  30625. id: OPS.save,
  30626. numArgs: 0,
  30627. variableArgs: false
  30628. };
  30629. t['Q'] = {
  30630. id: OPS.restore,
  30631. numArgs: 0,
  30632. variableArgs: false
  30633. };
  30634. t['cm'] = {
  30635. id: OPS.transform,
  30636. numArgs: 6,
  30637. variableArgs: false
  30638. };
  30639. t['m'] = {
  30640. id: OPS.moveTo,
  30641. numArgs: 2,
  30642. variableArgs: false
  30643. };
  30644. t['l'] = {
  30645. id: OPS.lineTo,
  30646. numArgs: 2,
  30647. variableArgs: false
  30648. };
  30649. t['c'] = {
  30650. id: OPS.curveTo,
  30651. numArgs: 6,
  30652. variableArgs: false
  30653. };
  30654. t['v'] = {
  30655. id: OPS.curveTo2,
  30656. numArgs: 4,
  30657. variableArgs: false
  30658. };
  30659. t['y'] = {
  30660. id: OPS.curveTo3,
  30661. numArgs: 4,
  30662. variableArgs: false
  30663. };
  30664. t['h'] = {
  30665. id: OPS.closePath,
  30666. numArgs: 0,
  30667. variableArgs: false
  30668. };
  30669. t['re'] = {
  30670. id: OPS.rectangle,
  30671. numArgs: 4,
  30672. variableArgs: false
  30673. };
  30674. t['S'] = {
  30675. id: OPS.stroke,
  30676. numArgs: 0,
  30677. variableArgs: false
  30678. };
  30679. t['s'] = {
  30680. id: OPS.closeStroke,
  30681. numArgs: 0,
  30682. variableArgs: false
  30683. };
  30684. t['f'] = {
  30685. id: OPS.fill,
  30686. numArgs: 0,
  30687. variableArgs: false
  30688. };
  30689. t['F'] = {
  30690. id: OPS.fill,
  30691. numArgs: 0,
  30692. variableArgs: false
  30693. };
  30694. t['f*'] = {
  30695. id: OPS.eoFill,
  30696. numArgs: 0,
  30697. variableArgs: false
  30698. };
  30699. t['B'] = {
  30700. id: OPS.fillStroke,
  30701. numArgs: 0,
  30702. variableArgs: false
  30703. };
  30704. t['B*'] = {
  30705. id: OPS.eoFillStroke,
  30706. numArgs: 0,
  30707. variableArgs: false
  30708. };
  30709. t['b'] = {
  30710. id: OPS.closeFillStroke,
  30711. numArgs: 0,
  30712. variableArgs: false
  30713. };
  30714. t['b*'] = {
  30715. id: OPS.closeEOFillStroke,
  30716. numArgs: 0,
  30717. variableArgs: false
  30718. };
  30719. t['n'] = {
  30720. id: OPS.endPath,
  30721. numArgs: 0,
  30722. variableArgs: false
  30723. };
  30724. t['W'] = {
  30725. id: OPS.clip,
  30726. numArgs: 0,
  30727. variableArgs: false
  30728. };
  30729. t['W*'] = {
  30730. id: OPS.eoClip,
  30731. numArgs: 0,
  30732. variableArgs: false
  30733. };
  30734. t['BT'] = {
  30735. id: OPS.beginText,
  30736. numArgs: 0,
  30737. variableArgs: false
  30738. };
  30739. t['ET'] = {
  30740. id: OPS.endText,
  30741. numArgs: 0,
  30742. variableArgs: false
  30743. };
  30744. t['Tc'] = {
  30745. id: OPS.setCharSpacing,
  30746. numArgs: 1,
  30747. variableArgs: false
  30748. };
  30749. t['Tw'] = {
  30750. id: OPS.setWordSpacing,
  30751. numArgs: 1,
  30752. variableArgs: false
  30753. };
  30754. t['Tz'] = {
  30755. id: OPS.setHScale,
  30756. numArgs: 1,
  30757. variableArgs: false
  30758. };
  30759. t['TL'] = {
  30760. id: OPS.setLeading,
  30761. numArgs: 1,
  30762. variableArgs: false
  30763. };
  30764. t['Tf'] = {
  30765. id: OPS.setFont,
  30766. numArgs: 2,
  30767. variableArgs: false
  30768. };
  30769. t['Tr'] = {
  30770. id: OPS.setTextRenderingMode,
  30771. numArgs: 1,
  30772. variableArgs: false
  30773. };
  30774. t['Ts'] = {
  30775. id: OPS.setTextRise,
  30776. numArgs: 1,
  30777. variableArgs: false
  30778. };
  30779. t['Td'] = {
  30780. id: OPS.moveText,
  30781. numArgs: 2,
  30782. variableArgs: false
  30783. };
  30784. t['TD'] = {
  30785. id: OPS.setLeadingMoveText,
  30786. numArgs: 2,
  30787. variableArgs: false
  30788. };
  30789. t['Tm'] = {
  30790. id: OPS.setTextMatrix,
  30791. numArgs: 6,
  30792. variableArgs: false
  30793. };
  30794. t['T*'] = {
  30795. id: OPS.nextLine,
  30796. numArgs: 0,
  30797. variableArgs: false
  30798. };
  30799. t['Tj'] = {
  30800. id: OPS.showText,
  30801. numArgs: 1,
  30802. variableArgs: false
  30803. };
  30804. t['TJ'] = {
  30805. id: OPS.showSpacedText,
  30806. numArgs: 1,
  30807. variableArgs: false
  30808. };
  30809. t['\''] = {
  30810. id: OPS.nextLineShowText,
  30811. numArgs: 1,
  30812. variableArgs: false
  30813. };
  30814. t['"'] = {
  30815. id: OPS.nextLineSetSpacingShowText,
  30816. numArgs: 3,
  30817. variableArgs: false
  30818. };
  30819. t['d0'] = {
  30820. id: OPS.setCharWidth,
  30821. numArgs: 2,
  30822. variableArgs: false
  30823. };
  30824. t['d1'] = {
  30825. id: OPS.setCharWidthAndBounds,
  30826. numArgs: 6,
  30827. variableArgs: false
  30828. };
  30829. t['CS'] = {
  30830. id: OPS.setStrokeColorSpace,
  30831. numArgs: 1,
  30832. variableArgs: false
  30833. };
  30834. t['cs'] = {
  30835. id: OPS.setFillColorSpace,
  30836. numArgs: 1,
  30837. variableArgs: false
  30838. };
  30839. t['SC'] = {
  30840. id: OPS.setStrokeColor,
  30841. numArgs: 4,
  30842. variableArgs: true
  30843. };
  30844. t['SCN'] = {
  30845. id: OPS.setStrokeColorN,
  30846. numArgs: 33,
  30847. variableArgs: true
  30848. };
  30849. t['sc'] = {
  30850. id: OPS.setFillColor,
  30851. numArgs: 4,
  30852. variableArgs: true
  30853. };
  30854. t['scn'] = {
  30855. id: OPS.setFillColorN,
  30856. numArgs: 33,
  30857. variableArgs: true
  30858. };
  30859. t['G'] = {
  30860. id: OPS.setStrokeGray,
  30861. numArgs: 1,
  30862. variableArgs: false
  30863. };
  30864. t['g'] = {
  30865. id: OPS.setFillGray,
  30866. numArgs: 1,
  30867. variableArgs: false
  30868. };
  30869. t['RG'] = {
  30870. id: OPS.setStrokeRGBColor,
  30871. numArgs: 3,
  30872. variableArgs: false
  30873. };
  30874. t['rg'] = {
  30875. id: OPS.setFillRGBColor,
  30876. numArgs: 3,
  30877. variableArgs: false
  30878. };
  30879. t['K'] = {
  30880. id: OPS.setStrokeCMYKColor,
  30881. numArgs: 4,
  30882. variableArgs: false
  30883. };
  30884. t['k'] = {
  30885. id: OPS.setFillCMYKColor,
  30886. numArgs: 4,
  30887. variableArgs: false
  30888. };
  30889. t['sh'] = {
  30890. id: OPS.shadingFill,
  30891. numArgs: 1,
  30892. variableArgs: false
  30893. };
  30894. t['BI'] = {
  30895. id: OPS.beginInlineImage,
  30896. numArgs: 0,
  30897. variableArgs: false
  30898. };
  30899. t['ID'] = {
  30900. id: OPS.beginImageData,
  30901. numArgs: 0,
  30902. variableArgs: false
  30903. };
  30904. t['EI'] = {
  30905. id: OPS.endInlineImage,
  30906. numArgs: 1,
  30907. variableArgs: false
  30908. };
  30909. t['Do'] = {
  30910. id: OPS.paintXObject,
  30911. numArgs: 1,
  30912. variableArgs: false
  30913. };
  30914. t['MP'] = {
  30915. id: OPS.markPoint,
  30916. numArgs: 1,
  30917. variableArgs: false
  30918. };
  30919. t['DP'] = {
  30920. id: OPS.markPointProps,
  30921. numArgs: 2,
  30922. variableArgs: false
  30923. };
  30924. t['BMC'] = {
  30925. id: OPS.beginMarkedContent,
  30926. numArgs: 1,
  30927. variableArgs: false
  30928. };
  30929. t['BDC'] = {
  30930. id: OPS.beginMarkedContentProps,
  30931. numArgs: 2,
  30932. variableArgs: false
  30933. };
  30934. t['EMC'] = {
  30935. id: OPS.endMarkedContent,
  30936. numArgs: 0,
  30937. variableArgs: false
  30938. };
  30939. t['BX'] = {
  30940. id: OPS.beginCompat,
  30941. numArgs: 0,
  30942. variableArgs: false
  30943. };
  30944. t['EX'] = {
  30945. id: OPS.endCompat,
  30946. numArgs: 0,
  30947. variableArgs: false
  30948. };
  30949. t['BM'] = null;
  30950. t['BD'] = null;
  30951. t['true'] = null;
  30952. t['fa'] = null;
  30953. t['fal'] = null;
  30954. t['fals'] = null;
  30955. t['false'] = null;
  30956. t['nu'] = null;
  30957. t['nul'] = null;
  30958. t['null'] = null;
  30959. });
  30960. function EvaluatorPreprocessor(stream, xref, stateManager) {
  30961. this.opMap = getOPMap();
  30962. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  30963. this.stateManager = stateManager;
  30964. this.nonProcessedArgs = [];
  30965. }
  30966. EvaluatorPreprocessor.prototype = {
  30967. get savedStatesDepth() {
  30968. return this.stateManager.stateStack.length;
  30969. },
  30970. read: function EvaluatorPreprocessor_read(operation) {
  30971. var args = operation.args;
  30972. while (true) {
  30973. var obj = this.parser.getObj();
  30974. if (isCmd(obj)) {
  30975. var cmd = obj.cmd;
  30976. var opSpec = this.opMap[cmd];
  30977. if (!opSpec) {
  30978. warn('Unknown command "' + cmd + '"');
  30979. continue;
  30980. }
  30981. var fn = opSpec.id;
  30982. var numArgs = opSpec.numArgs;
  30983. var argsLength = args !== null ? args.length : 0;
  30984. if (!opSpec.variableArgs) {
  30985. if (argsLength !== numArgs) {
  30986. var nonProcessedArgs = this.nonProcessedArgs;
  30987. while (argsLength > numArgs) {
  30988. nonProcessedArgs.push(args.shift());
  30989. argsLength--;
  30990. }
  30991. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  30992. if (args === null) {
  30993. args = [];
  30994. }
  30995. args.unshift(nonProcessedArgs.pop());
  30996. argsLength++;
  30997. }
  30998. }
  30999. if (argsLength < numArgs) {
  31000. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31001. if (args !== null) {
  31002. args.length = 0;
  31003. }
  31004. continue;
  31005. }
  31006. } else if (argsLength > numArgs) {
  31007. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31008. }
  31009. this.preprocessCommand(fn, args);
  31010. operation.fn = fn;
  31011. operation.args = args;
  31012. return true;
  31013. }
  31014. if (isEOF(obj)) {
  31015. return false;
  31016. }
  31017. if (obj !== null) {
  31018. if (args === null) {
  31019. args = [];
  31020. }
  31021. args.push(obj);
  31022. assert(args.length <= 33, 'Too many arguments');
  31023. }
  31024. }
  31025. },
  31026. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31027. switch (fn | 0) {
  31028. case OPS.save:
  31029. this.stateManager.save();
  31030. break;
  31031. case OPS.restore:
  31032. this.stateManager.restore();
  31033. break;
  31034. case OPS.transform:
  31035. this.stateManager.transform(args);
  31036. break;
  31037. }
  31038. }
  31039. };
  31040. return EvaluatorPreprocessor;
  31041. }();
  31042. var QueueOptimizer = function QueueOptimizerClosure() {
  31043. function addState(parentState, pattern, fn) {
  31044. var state = parentState;
  31045. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31046. var item = pattern[i];
  31047. state = state[item] || (state[item] = []);
  31048. }
  31049. state[pattern[pattern.length - 1]] = fn;
  31050. }
  31051. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31052. var iFirstPIMXO = iFirstSave + 2;
  31053. for (var i = 0; i < count; i++) {
  31054. var arg = argsArray[iFirstPIMXO + 4 * i];
  31055. var imageMask = arg.length === 1 && arg[0];
  31056. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31057. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31058. continue;
  31059. }
  31060. break;
  31061. }
  31062. return count - i;
  31063. }
  31064. var InitialState = [];
  31065. addState(InitialState, [
  31066. OPS.save,
  31067. OPS.transform,
  31068. OPS.paintInlineImageXObject,
  31069. OPS.restore
  31070. ], function foundInlineImageGroup(context) {
  31071. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31072. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31073. var MAX_WIDTH = 1000;
  31074. var IMAGE_PADDING = 1;
  31075. var fnArray = context.fnArray, argsArray = context.argsArray;
  31076. var curr = context.iCurr;
  31077. var iFirstSave = curr - 3;
  31078. var iFirstTransform = curr - 2;
  31079. var iFirstPIIXO = curr - 1;
  31080. var i = iFirstSave + 4;
  31081. var ii = fnArray.length;
  31082. while (i + 3 < ii) {
  31083. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31084. break;
  31085. }
  31086. i += 4;
  31087. }
  31088. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31089. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31090. return i;
  31091. }
  31092. var maxX = 0;
  31093. var map = [], maxLineHeight = 0;
  31094. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31095. var q;
  31096. for (q = 0; q < count; q++) {
  31097. var transform = argsArray[iFirstTransform + (q << 2)];
  31098. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31099. if (currentX + img.width > MAX_WIDTH) {
  31100. maxX = Math.max(maxX, currentX);
  31101. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31102. currentX = 0;
  31103. maxLineHeight = 0;
  31104. }
  31105. map.push({
  31106. transform: transform,
  31107. x: currentX,
  31108. y: currentY,
  31109. w: img.width,
  31110. h: img.height
  31111. });
  31112. currentX += img.width + 2 * IMAGE_PADDING;
  31113. maxLineHeight = Math.max(maxLineHeight, img.height);
  31114. }
  31115. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31116. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31117. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31118. var imgRowSize = imgWidth << 2;
  31119. for (q = 0; q < count; q++) {
  31120. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31121. var rowSize = map[q].w << 2;
  31122. var dataOffset = 0;
  31123. var offset = map[q].x + map[q].y * imgWidth << 2;
  31124. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31125. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31126. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31127. dataOffset += rowSize;
  31128. offset += imgRowSize;
  31129. }
  31130. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31131. while (offset >= 0) {
  31132. data[offset - 4] = data[offset];
  31133. data[offset - 3] = data[offset + 1];
  31134. data[offset - 2] = data[offset + 2];
  31135. data[offset - 1] = data[offset + 3];
  31136. data[offset + rowSize] = data[offset + rowSize - 4];
  31137. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31138. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31139. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31140. offset -= imgRowSize;
  31141. }
  31142. }
  31143. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31144. argsArray.splice(iFirstSave, count * 4, [
  31145. {
  31146. width: imgWidth,
  31147. height: imgHeight,
  31148. kind: ImageKind.RGBA_32BPP,
  31149. data: imgData
  31150. },
  31151. map
  31152. ]);
  31153. return iFirstSave + 1;
  31154. });
  31155. addState(InitialState, [
  31156. OPS.save,
  31157. OPS.transform,
  31158. OPS.paintImageMaskXObject,
  31159. OPS.restore
  31160. ], function foundImageMaskGroup(context) {
  31161. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31162. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31163. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31164. var fnArray = context.fnArray, argsArray = context.argsArray;
  31165. var curr = context.iCurr;
  31166. var iFirstSave = curr - 3;
  31167. var iFirstTransform = curr - 2;
  31168. var iFirstPIMXO = curr - 1;
  31169. var i = iFirstSave + 4;
  31170. var ii = fnArray.length;
  31171. while (i + 3 < ii) {
  31172. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31173. break;
  31174. }
  31175. i += 4;
  31176. }
  31177. var count = (i - iFirstSave) / 4;
  31178. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31179. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31180. return i;
  31181. }
  31182. var q;
  31183. var isSameImage = false;
  31184. var iTransform, transformArgs;
  31185. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31186. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31187. isSameImage = true;
  31188. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31189. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31190. iTransform = iFirstTransform + 4;
  31191. var iPIMXO = iFirstPIMXO + 4;
  31192. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31193. transformArgs = argsArray[iTransform];
  31194. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31195. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31196. isSameImage = false;
  31197. } else {
  31198. count = q;
  31199. }
  31200. break;
  31201. }
  31202. }
  31203. }
  31204. if (isSameImage) {
  31205. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31206. var positions = new Float32Array(count * 2);
  31207. iTransform = iFirstTransform;
  31208. for (q = 0; q < count; q++, iTransform += 4) {
  31209. transformArgs = argsArray[iTransform];
  31210. positions[q << 1] = transformArgs[4];
  31211. positions[(q << 1) + 1] = transformArgs[5];
  31212. }
  31213. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31214. argsArray.splice(iFirstSave, count * 4, [
  31215. firstPIMXOArg0,
  31216. firstTransformArg0,
  31217. firstTransformArg3,
  31218. positions
  31219. ]);
  31220. } else {
  31221. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31222. var images = [];
  31223. for (q = 0; q < count; q++) {
  31224. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31225. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31226. images.push({
  31227. data: maskParams.data,
  31228. width: maskParams.width,
  31229. height: maskParams.height,
  31230. transform: transformArgs
  31231. });
  31232. }
  31233. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31234. argsArray.splice(iFirstSave, count * 4, [images]);
  31235. }
  31236. return iFirstSave + 1;
  31237. });
  31238. addState(InitialState, [
  31239. OPS.save,
  31240. OPS.transform,
  31241. OPS.paintImageXObject,
  31242. OPS.restore
  31243. ], function (context) {
  31244. var MIN_IMAGES_IN_BLOCK = 3;
  31245. var MAX_IMAGES_IN_BLOCK = 1000;
  31246. var fnArray = context.fnArray, argsArray = context.argsArray;
  31247. var curr = context.iCurr;
  31248. var iFirstSave = curr - 3;
  31249. var iFirstTransform = curr - 2;
  31250. var iFirstPIXO = curr - 1;
  31251. var iFirstRestore = curr;
  31252. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31253. return iFirstRestore + 1;
  31254. }
  31255. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31256. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31257. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31258. var i = iFirstSave + 4;
  31259. var ii = fnArray.length;
  31260. while (i + 3 < ii) {
  31261. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31262. break;
  31263. }
  31264. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31265. break;
  31266. }
  31267. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31268. break;
  31269. }
  31270. i += 4;
  31271. }
  31272. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31273. if (count < MIN_IMAGES_IN_BLOCK) {
  31274. return i;
  31275. }
  31276. var positions = new Float32Array(count * 2);
  31277. var iTransform = iFirstTransform;
  31278. for (var q = 0; q < count; q++, iTransform += 4) {
  31279. var transformArgs = argsArray[iTransform];
  31280. positions[q << 1] = transformArgs[4];
  31281. positions[(q << 1) + 1] = transformArgs[5];
  31282. }
  31283. var args = [
  31284. firstPIXOArg0,
  31285. firstTransformArg0,
  31286. firstTransformArg3,
  31287. positions
  31288. ];
  31289. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31290. argsArray.splice(iFirstSave, count * 4, args);
  31291. return iFirstSave + 1;
  31292. });
  31293. addState(InitialState, [
  31294. OPS.beginText,
  31295. OPS.setFont,
  31296. OPS.setTextMatrix,
  31297. OPS.showText,
  31298. OPS.endText
  31299. ], function (context) {
  31300. var MIN_CHARS_IN_BLOCK = 3;
  31301. var MAX_CHARS_IN_BLOCK = 1000;
  31302. var fnArray = context.fnArray, argsArray = context.argsArray;
  31303. var curr = context.iCurr;
  31304. var iFirstBeginText = curr - 4;
  31305. var iFirstSetFont = curr - 3;
  31306. var iFirstSetTextMatrix = curr - 2;
  31307. var iFirstShowText = curr - 1;
  31308. var iFirstEndText = curr;
  31309. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  31310. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  31311. var i = iFirstBeginText + 5;
  31312. var ii = fnArray.length;
  31313. while (i + 4 < ii) {
  31314. if (fnArray[i] !== OPS.beginText || fnArray[i + 1] !== OPS.setFont || fnArray[i + 2] !== OPS.setTextMatrix || fnArray[i + 3] !== OPS.showText || fnArray[i + 4] !== OPS.endText) {
  31315. break;
  31316. }
  31317. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  31318. break;
  31319. }
  31320. i += 5;
  31321. }
  31322. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  31323. if (count < MIN_CHARS_IN_BLOCK) {
  31324. return i;
  31325. }
  31326. var iFirst = iFirstBeginText;
  31327. if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
  31328. count++;
  31329. iFirst -= 5;
  31330. }
  31331. var iEndText = iFirst + 4;
  31332. for (var q = 1; q < count; q++) {
  31333. fnArray.splice(iEndText, 3);
  31334. argsArray.splice(iEndText, 3);
  31335. iEndText += 2;
  31336. }
  31337. return iEndText + 1;
  31338. });
  31339. function QueueOptimizer() {
  31340. }
  31341. QueueOptimizer.prototype = {
  31342. optimize: function QueueOptimizer_optimize(queue) {
  31343. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31344. var context = {
  31345. iCurr: 0,
  31346. fnArray: fnArray,
  31347. argsArray: argsArray
  31348. };
  31349. var state;
  31350. var i = 0, ii = fnArray.length;
  31351. while (i < ii) {
  31352. state = (state || InitialState)[fnArray[i]];
  31353. if (typeof state === 'function') {
  31354. context.iCurr = i;
  31355. i = state(context);
  31356. state = undefined;
  31357. ii = context.fnArray.length;
  31358. } else {
  31359. i++;
  31360. }
  31361. }
  31362. }
  31363. };
  31364. return QueueOptimizer;
  31365. }();
  31366. exports.OperatorList = OperatorList;
  31367. exports.PartialEvaluator = PartialEvaluator;
  31368. /***/ }),
  31369. /* 19 */
  31370. /***/ (function(module, exports, __w_pdfjs_require__) {
  31371. "use strict";
  31372. var sharedUtil = __w_pdfjs_require__(0);
  31373. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  31374. var info = sharedUtil.info;
  31375. var warn = sharedUtil.warn;
  31376. var error = sharedUtil.error;
  31377. var log2 = sharedUtil.log2;
  31378. var readUint16 = sharedUtil.readUint16;
  31379. var readUint32 = sharedUtil.readUint32;
  31380. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  31381. var JpxImage = function JpxImageClosure() {
  31382. var SubbandsGainLog2 = {
  31383. 'LL': 0,
  31384. 'LH': 1,
  31385. 'HL': 1,
  31386. 'HH': 2
  31387. };
  31388. function JpxImage() {
  31389. this.failOnCorruptedImage = false;
  31390. }
  31391. JpxImage.prototype = {
  31392. parse: function JpxImage_parse(data) {
  31393. var head = readUint16(data, 0);
  31394. if (head === 0xFF4F) {
  31395. this.parseCodestream(data, 0, data.length);
  31396. return;
  31397. }
  31398. var position = 0, length = data.length;
  31399. while (position < length) {
  31400. var headerSize = 8;
  31401. var lbox = readUint32(data, position);
  31402. var tbox = readUint32(data, position + 4);
  31403. position += headerSize;
  31404. if (lbox === 1) {
  31405. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  31406. position += 8;
  31407. headerSize += 8;
  31408. }
  31409. if (lbox === 0) {
  31410. lbox = length - position + headerSize;
  31411. }
  31412. if (lbox < headerSize) {
  31413. error('JPX Error: Invalid box field size');
  31414. }
  31415. var dataLength = lbox - headerSize;
  31416. var jumpDataLength = true;
  31417. switch (tbox) {
  31418. case 0x6A703268:
  31419. jumpDataLength = false;
  31420. break;
  31421. case 0x636F6C72:
  31422. var method = data[position];
  31423. if (method === 1) {
  31424. var colorspace = readUint32(data, position + 3);
  31425. switch (colorspace) {
  31426. case 16:
  31427. case 17:
  31428. case 18:
  31429. break;
  31430. default:
  31431. warn('Unknown colorspace ' + colorspace);
  31432. break;
  31433. }
  31434. } else if (method === 2) {
  31435. info('ICC profile not supported');
  31436. }
  31437. break;
  31438. case 0x6A703263:
  31439. this.parseCodestream(data, position, position + dataLength);
  31440. break;
  31441. case 0x6A502020:
  31442. if (0x0d0a870a !== readUint32(data, position)) {
  31443. warn('Invalid JP2 signature');
  31444. }
  31445. break;
  31446. case 0x6A501A1A:
  31447. case 0x66747970:
  31448. case 0x72726571:
  31449. case 0x72657320:
  31450. case 0x69686472:
  31451. break;
  31452. default:
  31453. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  31454. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  31455. break;
  31456. }
  31457. if (jumpDataLength) {
  31458. position += dataLength;
  31459. }
  31460. }
  31461. },
  31462. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  31463. var newByte = stream.getByte();
  31464. while (newByte >= 0) {
  31465. var oldByte = newByte;
  31466. newByte = stream.getByte();
  31467. var code = oldByte << 8 | newByte;
  31468. if (code === 0xFF51) {
  31469. stream.skip(4);
  31470. var Xsiz = stream.getInt32() >>> 0;
  31471. var Ysiz = stream.getInt32() >>> 0;
  31472. var XOsiz = stream.getInt32() >>> 0;
  31473. var YOsiz = stream.getInt32() >>> 0;
  31474. stream.skip(16);
  31475. var Csiz = stream.getUint16();
  31476. this.width = Xsiz - XOsiz;
  31477. this.height = Ysiz - YOsiz;
  31478. this.componentsCount = Csiz;
  31479. this.bitsPerComponent = 8;
  31480. return;
  31481. }
  31482. }
  31483. error('JPX Error: No size marker found in JPX stream');
  31484. },
  31485. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  31486. var context = {};
  31487. var doNotRecover = false;
  31488. try {
  31489. var position = start;
  31490. while (position + 1 < end) {
  31491. var code = readUint16(data, position);
  31492. position += 2;
  31493. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  31494. switch (code) {
  31495. case 0xFF4F:
  31496. context.mainHeader = true;
  31497. break;
  31498. case 0xFFD9:
  31499. break;
  31500. case 0xFF51:
  31501. length = readUint16(data, position);
  31502. var siz = {};
  31503. siz.Xsiz = readUint32(data, position + 4);
  31504. siz.Ysiz = readUint32(data, position + 8);
  31505. siz.XOsiz = readUint32(data, position + 12);
  31506. siz.YOsiz = readUint32(data, position + 16);
  31507. siz.XTsiz = readUint32(data, position + 20);
  31508. siz.YTsiz = readUint32(data, position + 24);
  31509. siz.XTOsiz = readUint32(data, position + 28);
  31510. siz.YTOsiz = readUint32(data, position + 32);
  31511. var componentsCount = readUint16(data, position + 36);
  31512. siz.Csiz = componentsCount;
  31513. var components = [];
  31514. j = position + 38;
  31515. for (var i = 0; i < componentsCount; i++) {
  31516. var component = {
  31517. precision: (data[j] & 0x7F) + 1,
  31518. isSigned: !!(data[j] & 0x80),
  31519. XRsiz: data[j + 1],
  31520. YRsiz: data[j + 1]
  31521. };
  31522. calculateComponentDimensions(component, siz);
  31523. components.push(component);
  31524. }
  31525. context.SIZ = siz;
  31526. context.components = components;
  31527. calculateTileGrids(context, components);
  31528. context.QCC = [];
  31529. context.COC = [];
  31530. break;
  31531. case 0xFF5C:
  31532. length = readUint16(data, position);
  31533. var qcd = {};
  31534. j = position + 2;
  31535. sqcd = data[j++];
  31536. switch (sqcd & 0x1F) {
  31537. case 0:
  31538. spqcdSize = 8;
  31539. scalarExpounded = true;
  31540. break;
  31541. case 1:
  31542. spqcdSize = 16;
  31543. scalarExpounded = false;
  31544. break;
  31545. case 2:
  31546. spqcdSize = 16;
  31547. scalarExpounded = true;
  31548. break;
  31549. default:
  31550. throw new Error('Invalid SQcd value ' + sqcd);
  31551. }
  31552. qcd.noQuantization = spqcdSize === 8;
  31553. qcd.scalarExpounded = scalarExpounded;
  31554. qcd.guardBits = sqcd >> 5;
  31555. spqcds = [];
  31556. while (j < length + position) {
  31557. var spqcd = {};
  31558. if (spqcdSize === 8) {
  31559. spqcd.epsilon = data[j++] >> 3;
  31560. spqcd.mu = 0;
  31561. } else {
  31562. spqcd.epsilon = data[j] >> 3;
  31563. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31564. j += 2;
  31565. }
  31566. spqcds.push(spqcd);
  31567. }
  31568. qcd.SPqcds = spqcds;
  31569. if (context.mainHeader) {
  31570. context.QCD = qcd;
  31571. } else {
  31572. context.currentTile.QCD = qcd;
  31573. context.currentTile.QCC = [];
  31574. }
  31575. break;
  31576. case 0xFF5D:
  31577. length = readUint16(data, position);
  31578. var qcc = {};
  31579. j = position + 2;
  31580. var cqcc;
  31581. if (context.SIZ.Csiz < 257) {
  31582. cqcc = data[j++];
  31583. } else {
  31584. cqcc = readUint16(data, j);
  31585. j += 2;
  31586. }
  31587. sqcd = data[j++];
  31588. switch (sqcd & 0x1F) {
  31589. case 0:
  31590. spqcdSize = 8;
  31591. scalarExpounded = true;
  31592. break;
  31593. case 1:
  31594. spqcdSize = 16;
  31595. scalarExpounded = false;
  31596. break;
  31597. case 2:
  31598. spqcdSize = 16;
  31599. scalarExpounded = true;
  31600. break;
  31601. default:
  31602. throw new Error('Invalid SQcd value ' + sqcd);
  31603. }
  31604. qcc.noQuantization = spqcdSize === 8;
  31605. qcc.scalarExpounded = scalarExpounded;
  31606. qcc.guardBits = sqcd >> 5;
  31607. spqcds = [];
  31608. while (j < length + position) {
  31609. spqcd = {};
  31610. if (spqcdSize === 8) {
  31611. spqcd.epsilon = data[j++] >> 3;
  31612. spqcd.mu = 0;
  31613. } else {
  31614. spqcd.epsilon = data[j] >> 3;
  31615. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31616. j += 2;
  31617. }
  31618. spqcds.push(spqcd);
  31619. }
  31620. qcc.SPqcds = spqcds;
  31621. if (context.mainHeader) {
  31622. context.QCC[cqcc] = qcc;
  31623. } else {
  31624. context.currentTile.QCC[cqcc] = qcc;
  31625. }
  31626. break;
  31627. case 0xFF52:
  31628. length = readUint16(data, position);
  31629. var cod = {};
  31630. j = position + 2;
  31631. var scod = data[j++];
  31632. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  31633. cod.sopMarkerUsed = !!(scod & 2);
  31634. cod.ephMarkerUsed = !!(scod & 4);
  31635. cod.progressionOrder = data[j++];
  31636. cod.layersCount = readUint16(data, j);
  31637. j += 2;
  31638. cod.multipleComponentTransform = data[j++];
  31639. cod.decompositionLevelsCount = data[j++];
  31640. cod.xcb = (data[j++] & 0xF) + 2;
  31641. cod.ycb = (data[j++] & 0xF) + 2;
  31642. var blockStyle = data[j++];
  31643. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  31644. cod.resetContextProbabilities = !!(blockStyle & 2);
  31645. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  31646. cod.verticalyStripe = !!(blockStyle & 8);
  31647. cod.predictableTermination = !!(blockStyle & 16);
  31648. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  31649. cod.reversibleTransformation = data[j++];
  31650. if (cod.entropyCoderWithCustomPrecincts) {
  31651. var precinctsSizes = [];
  31652. while (j < length + position) {
  31653. var precinctsSize = data[j++];
  31654. precinctsSizes.push({
  31655. PPx: precinctsSize & 0xF,
  31656. PPy: precinctsSize >> 4
  31657. });
  31658. }
  31659. cod.precinctsSizes = precinctsSizes;
  31660. }
  31661. var unsupported = [];
  31662. if (cod.selectiveArithmeticCodingBypass) {
  31663. unsupported.push('selectiveArithmeticCodingBypass');
  31664. }
  31665. if (cod.resetContextProbabilities) {
  31666. unsupported.push('resetContextProbabilities');
  31667. }
  31668. if (cod.terminationOnEachCodingPass) {
  31669. unsupported.push('terminationOnEachCodingPass');
  31670. }
  31671. if (cod.verticalyStripe) {
  31672. unsupported.push('verticalyStripe');
  31673. }
  31674. if (cod.predictableTermination) {
  31675. unsupported.push('predictableTermination');
  31676. }
  31677. if (unsupported.length > 0) {
  31678. doNotRecover = true;
  31679. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  31680. }
  31681. if (context.mainHeader) {
  31682. context.COD = cod;
  31683. } else {
  31684. context.currentTile.COD = cod;
  31685. context.currentTile.COC = [];
  31686. }
  31687. break;
  31688. case 0xFF90:
  31689. length = readUint16(data, position);
  31690. tile = {};
  31691. tile.index = readUint16(data, position + 2);
  31692. tile.length = readUint32(data, position + 4);
  31693. tile.dataEnd = tile.length + position - 2;
  31694. tile.partIndex = data[position + 8];
  31695. tile.partsCount = data[position + 9];
  31696. context.mainHeader = false;
  31697. if (tile.partIndex === 0) {
  31698. tile.COD = context.COD;
  31699. tile.COC = context.COC.slice(0);
  31700. tile.QCD = context.QCD;
  31701. tile.QCC = context.QCC.slice(0);
  31702. }
  31703. context.currentTile = tile;
  31704. break;
  31705. case 0xFF93:
  31706. tile = context.currentTile;
  31707. if (tile.partIndex === 0) {
  31708. initializeTile(context, tile.index);
  31709. buildPackets(context);
  31710. }
  31711. length = tile.dataEnd - position;
  31712. parseTilePackets(context, data, position, length);
  31713. break;
  31714. case 0xFF55:
  31715. case 0xFF57:
  31716. case 0xFF58:
  31717. case 0xFF64:
  31718. length = readUint16(data, position);
  31719. break;
  31720. case 0xFF53:
  31721. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  31722. default:
  31723. throw new Error('Unknown codestream code: ' + code.toString(16));
  31724. }
  31725. position += length;
  31726. }
  31727. } catch (e) {
  31728. if (doNotRecover || this.failOnCorruptedImage) {
  31729. error('JPX Error: ' + e.message);
  31730. } else {
  31731. warn('JPX: Trying to recover from: ' + e.message);
  31732. }
  31733. }
  31734. this.tiles = transformComponents(context);
  31735. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  31736. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  31737. this.componentsCount = context.SIZ.Csiz;
  31738. }
  31739. };
  31740. function calculateComponentDimensions(component, siz) {
  31741. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  31742. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  31743. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  31744. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  31745. component.width = component.x1 - component.x0;
  31746. component.height = component.y1 - component.y0;
  31747. }
  31748. function calculateTileGrids(context, components) {
  31749. var siz = context.SIZ;
  31750. var tile, tiles = [];
  31751. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  31752. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  31753. for (var q = 0; q < numYtiles; q++) {
  31754. for (var p = 0; p < numXtiles; p++) {
  31755. tile = {};
  31756. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  31757. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  31758. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  31759. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  31760. tile.width = tile.tx1 - tile.tx0;
  31761. tile.height = tile.ty1 - tile.ty0;
  31762. tile.components = [];
  31763. tiles.push(tile);
  31764. }
  31765. }
  31766. context.tiles = tiles;
  31767. var componentsCount = siz.Csiz;
  31768. for (var i = 0, ii = componentsCount; i < ii; i++) {
  31769. var component = components[i];
  31770. for (var j = 0, jj = tiles.length; j < jj; j++) {
  31771. var tileComponent = {};
  31772. tile = tiles[j];
  31773. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  31774. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  31775. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  31776. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  31777. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  31778. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  31779. tile.components[i] = tileComponent;
  31780. }
  31781. }
  31782. }
  31783. function getBlocksDimensions(context, component, r) {
  31784. var codOrCoc = component.codingStyleParameters;
  31785. var result = {};
  31786. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  31787. result.PPx = 15;
  31788. result.PPy = 15;
  31789. } else {
  31790. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  31791. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  31792. }
  31793. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  31794. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  31795. return result;
  31796. }
  31797. function buildPrecincts(context, resolution, dimensions) {
  31798. var precinctWidth = 1 << dimensions.PPx;
  31799. var precinctHeight = 1 << dimensions.PPy;
  31800. var isZeroRes = resolution.resLevel === 0;
  31801. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  31802. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  31803. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  31804. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  31805. var numprecincts = numprecinctswide * numprecinctshigh;
  31806. resolution.precinctParameters = {
  31807. precinctWidth: precinctWidth,
  31808. precinctHeight: precinctHeight,
  31809. numprecinctswide: numprecinctswide,
  31810. numprecinctshigh: numprecinctshigh,
  31811. numprecincts: numprecincts,
  31812. precinctWidthInSubband: precinctWidthInSubband,
  31813. precinctHeightInSubband: precinctHeightInSubband
  31814. };
  31815. }
  31816. function buildCodeblocks(context, subband, dimensions) {
  31817. var xcb_ = dimensions.xcb_;
  31818. var ycb_ = dimensions.ycb_;
  31819. var codeblockWidth = 1 << xcb_;
  31820. var codeblockHeight = 1 << ycb_;
  31821. var cbx0 = subband.tbx0 >> xcb_;
  31822. var cby0 = subband.tby0 >> ycb_;
  31823. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  31824. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  31825. var precinctParameters = subband.resolution.precinctParameters;
  31826. var codeblocks = [];
  31827. var precincts = [];
  31828. var i, j, codeblock, precinctNumber;
  31829. for (j = cby0; j < cby1; j++) {
  31830. for (i = cbx0; i < cbx1; i++) {
  31831. codeblock = {
  31832. cbx: i,
  31833. cby: j,
  31834. tbx0: codeblockWidth * i,
  31835. tby0: codeblockHeight * j,
  31836. tbx1: codeblockWidth * (i + 1),
  31837. tby1: codeblockHeight * (j + 1)
  31838. };
  31839. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  31840. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  31841. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  31842. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  31843. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  31844. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  31845. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  31846. codeblock.precinctNumber = precinctNumber;
  31847. codeblock.subbandType = subband.type;
  31848. codeblock.Lblock = 3;
  31849. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  31850. continue;
  31851. }
  31852. codeblocks.push(codeblock);
  31853. var precinct = precincts[precinctNumber];
  31854. if (precinct !== undefined) {
  31855. if (i < precinct.cbxMin) {
  31856. precinct.cbxMin = i;
  31857. } else if (i > precinct.cbxMax) {
  31858. precinct.cbxMax = i;
  31859. }
  31860. if (j < precinct.cbyMin) {
  31861. precinct.cbxMin = j;
  31862. } else if (j > precinct.cbyMax) {
  31863. precinct.cbyMax = j;
  31864. }
  31865. } else {
  31866. precincts[precinctNumber] = precinct = {
  31867. cbxMin: i,
  31868. cbyMin: j,
  31869. cbxMax: i,
  31870. cbyMax: j
  31871. };
  31872. }
  31873. codeblock.precinct = precinct;
  31874. }
  31875. }
  31876. subband.codeblockParameters = {
  31877. codeblockWidth: xcb_,
  31878. codeblockHeight: ycb_,
  31879. numcodeblockwide: cbx1 - cbx0 + 1,
  31880. numcodeblockhigh: cby1 - cby0 + 1
  31881. };
  31882. subband.codeblocks = codeblocks;
  31883. subband.precincts = precincts;
  31884. }
  31885. function createPacket(resolution, precinctNumber, layerNumber) {
  31886. var precinctCodeblocks = [];
  31887. var subbands = resolution.subbands;
  31888. for (var i = 0, ii = subbands.length; i < ii; i++) {
  31889. var subband = subbands[i];
  31890. var codeblocks = subband.codeblocks;
  31891. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  31892. var codeblock = codeblocks[j];
  31893. if (codeblock.precinctNumber !== precinctNumber) {
  31894. continue;
  31895. }
  31896. precinctCodeblocks.push(codeblock);
  31897. }
  31898. }
  31899. return {
  31900. layerNumber: layerNumber,
  31901. codeblocks: precinctCodeblocks
  31902. };
  31903. }
  31904. function LayerResolutionComponentPositionIterator(context) {
  31905. var siz = context.SIZ;
  31906. var tileIndex = context.currentTile.index;
  31907. var tile = context.tiles[tileIndex];
  31908. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31909. var componentsCount = siz.Csiz;
  31910. var maxDecompositionLevelsCount = 0;
  31911. for (var q = 0; q < componentsCount; q++) {
  31912. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31913. }
  31914. var l = 0, r = 0, i = 0, k = 0;
  31915. this.nextPacket = function JpxImage_nextPacket() {
  31916. for (; l < layersCount; l++) {
  31917. for (; r <= maxDecompositionLevelsCount; r++) {
  31918. for (; i < componentsCount; i++) {
  31919. var component = tile.components[i];
  31920. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31921. continue;
  31922. }
  31923. var resolution = component.resolutions[r];
  31924. var numprecincts = resolution.precinctParameters.numprecincts;
  31925. for (; k < numprecincts;) {
  31926. var packet = createPacket(resolution, k, l);
  31927. k++;
  31928. return packet;
  31929. }
  31930. k = 0;
  31931. }
  31932. i = 0;
  31933. }
  31934. r = 0;
  31935. }
  31936. error('JPX Error: Out of packets');
  31937. };
  31938. }
  31939. function ResolutionLayerComponentPositionIterator(context) {
  31940. var siz = context.SIZ;
  31941. var tileIndex = context.currentTile.index;
  31942. var tile = context.tiles[tileIndex];
  31943. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31944. var componentsCount = siz.Csiz;
  31945. var maxDecompositionLevelsCount = 0;
  31946. for (var q = 0; q < componentsCount; q++) {
  31947. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31948. }
  31949. var r = 0, l = 0, i = 0, k = 0;
  31950. this.nextPacket = function JpxImage_nextPacket() {
  31951. for (; r <= maxDecompositionLevelsCount; r++) {
  31952. for (; l < layersCount; l++) {
  31953. for (; i < componentsCount; i++) {
  31954. var component = tile.components[i];
  31955. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31956. continue;
  31957. }
  31958. var resolution = component.resolutions[r];
  31959. var numprecincts = resolution.precinctParameters.numprecincts;
  31960. for (; k < numprecincts;) {
  31961. var packet = createPacket(resolution, k, l);
  31962. k++;
  31963. return packet;
  31964. }
  31965. k = 0;
  31966. }
  31967. i = 0;
  31968. }
  31969. l = 0;
  31970. }
  31971. error('JPX Error: Out of packets');
  31972. };
  31973. }
  31974. function ResolutionPositionComponentLayerIterator(context) {
  31975. var siz = context.SIZ;
  31976. var tileIndex = context.currentTile.index;
  31977. var tile = context.tiles[tileIndex];
  31978. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31979. var componentsCount = siz.Csiz;
  31980. var l, r, c, p;
  31981. var maxDecompositionLevelsCount = 0;
  31982. for (c = 0; c < componentsCount; c++) {
  31983. var component = tile.components[c];
  31984. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  31985. }
  31986. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  31987. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  31988. var maxNumPrecincts = 0;
  31989. for (c = 0; c < componentsCount; ++c) {
  31990. var resolutions = tile.components[c].resolutions;
  31991. if (r < resolutions.length) {
  31992. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  31993. }
  31994. }
  31995. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  31996. }
  31997. l = 0;
  31998. r = 0;
  31999. c = 0;
  32000. p = 0;
  32001. this.nextPacket = function JpxImage_nextPacket() {
  32002. for (; r <= maxDecompositionLevelsCount; r++) {
  32003. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32004. for (; c < componentsCount; c++) {
  32005. var component = tile.components[c];
  32006. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32007. continue;
  32008. }
  32009. var resolution = component.resolutions[r];
  32010. var numprecincts = resolution.precinctParameters.numprecincts;
  32011. if (p >= numprecincts) {
  32012. continue;
  32013. }
  32014. for (; l < layersCount;) {
  32015. var packet = createPacket(resolution, p, l);
  32016. l++;
  32017. return packet;
  32018. }
  32019. l = 0;
  32020. }
  32021. c = 0;
  32022. }
  32023. p = 0;
  32024. }
  32025. error('JPX Error: Out of packets');
  32026. };
  32027. }
  32028. function PositionComponentResolutionLayerIterator(context) {
  32029. var siz = context.SIZ;
  32030. var tileIndex = context.currentTile.index;
  32031. var tile = context.tiles[tileIndex];
  32032. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32033. var componentsCount = siz.Csiz;
  32034. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32035. var precinctsIterationSizes = precinctsSizes;
  32036. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32037. this.nextPacket = function JpxImage_nextPacket() {
  32038. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32039. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32040. for (; c < componentsCount; c++) {
  32041. var component = tile.components[c];
  32042. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32043. for (; r <= decompositionLevelsCount; r++) {
  32044. var resolution = component.resolutions[r];
  32045. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32046. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32047. if (k === null) {
  32048. continue;
  32049. }
  32050. for (; l < layersCount;) {
  32051. var packet = createPacket(resolution, k, l);
  32052. l++;
  32053. return packet;
  32054. }
  32055. l = 0;
  32056. }
  32057. r = 0;
  32058. }
  32059. c = 0;
  32060. }
  32061. px = 0;
  32062. }
  32063. error('JPX Error: Out of packets');
  32064. };
  32065. }
  32066. function ComponentPositionResolutionLayerIterator(context) {
  32067. var siz = context.SIZ;
  32068. var tileIndex = context.currentTile.index;
  32069. var tile = context.tiles[tileIndex];
  32070. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32071. var componentsCount = siz.Csiz;
  32072. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32073. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32074. this.nextPacket = function JpxImage_nextPacket() {
  32075. for (; c < componentsCount; ++c) {
  32076. var component = tile.components[c];
  32077. var precinctsIterationSizes = precinctsSizes.components[c];
  32078. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32079. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32080. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32081. for (; r <= decompositionLevelsCount; r++) {
  32082. var resolution = component.resolutions[r];
  32083. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32084. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32085. if (k === null) {
  32086. continue;
  32087. }
  32088. for (; l < layersCount;) {
  32089. var packet = createPacket(resolution, k, l);
  32090. l++;
  32091. return packet;
  32092. }
  32093. l = 0;
  32094. }
  32095. r = 0;
  32096. }
  32097. px = 0;
  32098. }
  32099. py = 0;
  32100. }
  32101. error('JPX Error: Out of packets');
  32102. };
  32103. }
  32104. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32105. var posX = pxIndex * precinctIterationSizes.minWidth;
  32106. var posY = pyIndex * precinctIterationSizes.minHeight;
  32107. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32108. return null;
  32109. }
  32110. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32111. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32112. }
  32113. function getPrecinctSizesInImageScale(tile) {
  32114. var componentsCount = tile.components.length;
  32115. var minWidth = Number.MAX_VALUE;
  32116. var minHeight = Number.MAX_VALUE;
  32117. var maxNumWide = 0;
  32118. var maxNumHigh = 0;
  32119. var sizePerComponent = new Array(componentsCount);
  32120. for (var c = 0; c < componentsCount; c++) {
  32121. var component = tile.components[c];
  32122. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32123. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32124. var minWidthCurrentComponent = Number.MAX_VALUE;
  32125. var minHeightCurrentComponent = Number.MAX_VALUE;
  32126. var maxNumWideCurrentComponent = 0;
  32127. var maxNumHighCurrentComponent = 0;
  32128. var scale = 1;
  32129. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32130. var resolution = component.resolutions[r];
  32131. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32132. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32133. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32134. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32135. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32136. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32137. sizePerResolution[r] = {
  32138. width: widthCurrentResolution,
  32139. height: heightCurrentResolution
  32140. };
  32141. scale <<= 1;
  32142. }
  32143. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32144. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32145. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32146. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32147. sizePerComponent[c] = {
  32148. resolutions: sizePerResolution,
  32149. minWidth: minWidthCurrentComponent,
  32150. minHeight: minHeightCurrentComponent,
  32151. maxNumWide: maxNumWideCurrentComponent,
  32152. maxNumHigh: maxNumHighCurrentComponent
  32153. };
  32154. }
  32155. return {
  32156. components: sizePerComponent,
  32157. minWidth: minWidth,
  32158. minHeight: minHeight,
  32159. maxNumWide: maxNumWide,
  32160. maxNumHigh: maxNumHigh
  32161. };
  32162. }
  32163. function buildPackets(context) {
  32164. var siz = context.SIZ;
  32165. var tileIndex = context.currentTile.index;
  32166. var tile = context.tiles[tileIndex];
  32167. var componentsCount = siz.Csiz;
  32168. for (var c = 0; c < componentsCount; c++) {
  32169. var component = tile.components[c];
  32170. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32171. var resolutions = [];
  32172. var subbands = [];
  32173. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32174. var blocksDimensions = getBlocksDimensions(context, component, r);
  32175. var resolution = {};
  32176. var scale = 1 << decompositionLevelsCount - r;
  32177. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32178. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32179. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32180. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32181. resolution.resLevel = r;
  32182. buildPrecincts(context, resolution, blocksDimensions);
  32183. resolutions.push(resolution);
  32184. var subband;
  32185. if (r === 0) {
  32186. subband = {};
  32187. subband.type = 'LL';
  32188. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32189. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32190. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32191. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32192. subband.resolution = resolution;
  32193. buildCodeblocks(context, subband, blocksDimensions);
  32194. subbands.push(subband);
  32195. resolution.subbands = [subband];
  32196. } else {
  32197. var bscale = 1 << decompositionLevelsCount - r + 1;
  32198. var resolutionSubbands = [];
  32199. subband = {};
  32200. subband.type = 'HL';
  32201. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32202. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32203. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32204. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32205. subband.resolution = resolution;
  32206. buildCodeblocks(context, subband, blocksDimensions);
  32207. subbands.push(subband);
  32208. resolutionSubbands.push(subband);
  32209. subband = {};
  32210. subband.type = 'LH';
  32211. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32212. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32213. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32214. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32215. subband.resolution = resolution;
  32216. buildCodeblocks(context, subband, blocksDimensions);
  32217. subbands.push(subband);
  32218. resolutionSubbands.push(subband);
  32219. subband = {};
  32220. subband.type = 'HH';
  32221. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32222. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32223. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32224. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32225. subband.resolution = resolution;
  32226. buildCodeblocks(context, subband, blocksDimensions);
  32227. subbands.push(subband);
  32228. resolutionSubbands.push(subband);
  32229. resolution.subbands = resolutionSubbands;
  32230. }
  32231. }
  32232. component.resolutions = resolutions;
  32233. component.subbands = subbands;
  32234. }
  32235. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32236. switch (progressionOrder) {
  32237. case 0:
  32238. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32239. break;
  32240. case 1:
  32241. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32242. break;
  32243. case 2:
  32244. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32245. break;
  32246. case 3:
  32247. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32248. break;
  32249. case 4:
  32250. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32251. break;
  32252. default:
  32253. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32254. }
  32255. }
  32256. function parseTilePackets(context, data, offset, dataLength) {
  32257. var position = 0;
  32258. var buffer, bufferSize = 0, skipNextBit = false;
  32259. function readBits(count) {
  32260. while (bufferSize < count) {
  32261. var b = data[offset + position];
  32262. position++;
  32263. if (skipNextBit) {
  32264. buffer = buffer << 7 | b;
  32265. bufferSize += 7;
  32266. skipNextBit = false;
  32267. } else {
  32268. buffer = buffer << 8 | b;
  32269. bufferSize += 8;
  32270. }
  32271. if (b === 0xFF) {
  32272. skipNextBit = true;
  32273. }
  32274. }
  32275. bufferSize -= count;
  32276. return buffer >>> bufferSize & (1 << count) - 1;
  32277. }
  32278. function skipMarkerIfEqual(value) {
  32279. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32280. skipBytes(1);
  32281. return true;
  32282. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32283. skipBytes(2);
  32284. return true;
  32285. }
  32286. return false;
  32287. }
  32288. function skipBytes(count) {
  32289. position += count;
  32290. }
  32291. function alignToByte() {
  32292. bufferSize = 0;
  32293. if (skipNextBit) {
  32294. position++;
  32295. skipNextBit = false;
  32296. }
  32297. }
  32298. function readCodingpasses() {
  32299. if (readBits(1) === 0) {
  32300. return 1;
  32301. }
  32302. if (readBits(1) === 0) {
  32303. return 2;
  32304. }
  32305. var value = readBits(2);
  32306. if (value < 3) {
  32307. return value + 3;
  32308. }
  32309. value = readBits(5);
  32310. if (value < 31) {
  32311. return value + 6;
  32312. }
  32313. value = readBits(7);
  32314. return value + 37;
  32315. }
  32316. var tileIndex = context.currentTile.index;
  32317. var tile = context.tiles[tileIndex];
  32318. var sopMarkerUsed = context.COD.sopMarkerUsed;
  32319. var ephMarkerUsed = context.COD.ephMarkerUsed;
  32320. var packetsIterator = tile.packetsIterator;
  32321. while (position < dataLength) {
  32322. alignToByte();
  32323. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  32324. skipBytes(4);
  32325. }
  32326. var packet = packetsIterator.nextPacket();
  32327. if (!readBits(1)) {
  32328. continue;
  32329. }
  32330. var layerNumber = packet.layerNumber;
  32331. var queue = [], codeblock;
  32332. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  32333. codeblock = packet.codeblocks[i];
  32334. var precinct = codeblock.precinct;
  32335. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  32336. var codeblockRow = codeblock.cby - precinct.cbyMin;
  32337. var codeblockIncluded = false;
  32338. var firstTimeInclusion = false;
  32339. var valueReady;
  32340. if (codeblock['included'] !== undefined) {
  32341. codeblockIncluded = !!readBits(1);
  32342. } else {
  32343. precinct = codeblock.precinct;
  32344. var inclusionTree, zeroBitPlanesTree;
  32345. if (precinct['inclusionTree'] !== undefined) {
  32346. inclusionTree = precinct.inclusionTree;
  32347. } else {
  32348. var width = precinct.cbxMax - precinct.cbxMin + 1;
  32349. var height = precinct.cbyMax - precinct.cbyMin + 1;
  32350. inclusionTree = new InclusionTree(width, height, layerNumber);
  32351. zeroBitPlanesTree = new TagTree(width, height);
  32352. precinct.inclusionTree = inclusionTree;
  32353. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  32354. }
  32355. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  32356. while (true) {
  32357. if (readBits(1)) {
  32358. valueReady = !inclusionTree.nextLevel();
  32359. if (valueReady) {
  32360. codeblock.included = true;
  32361. codeblockIncluded = firstTimeInclusion = true;
  32362. break;
  32363. }
  32364. } else {
  32365. inclusionTree.incrementValue(layerNumber);
  32366. break;
  32367. }
  32368. }
  32369. }
  32370. }
  32371. if (!codeblockIncluded) {
  32372. continue;
  32373. }
  32374. if (firstTimeInclusion) {
  32375. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  32376. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  32377. while (true) {
  32378. if (readBits(1)) {
  32379. valueReady = !zeroBitPlanesTree.nextLevel();
  32380. if (valueReady) {
  32381. break;
  32382. }
  32383. } else {
  32384. zeroBitPlanesTree.incrementValue();
  32385. }
  32386. }
  32387. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  32388. }
  32389. var codingpasses = readCodingpasses();
  32390. while (readBits(1)) {
  32391. codeblock.Lblock++;
  32392. }
  32393. var codingpassesLog2 = log2(codingpasses);
  32394. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  32395. var codedDataLength = readBits(bits);
  32396. queue.push({
  32397. codeblock: codeblock,
  32398. codingpasses: codingpasses,
  32399. dataLength: codedDataLength
  32400. });
  32401. }
  32402. alignToByte();
  32403. if (ephMarkerUsed) {
  32404. skipMarkerIfEqual(0x92);
  32405. }
  32406. while (queue.length > 0) {
  32407. var packetItem = queue.shift();
  32408. codeblock = packetItem.codeblock;
  32409. if (codeblock['data'] === undefined) {
  32410. codeblock.data = [];
  32411. }
  32412. codeblock.data.push({
  32413. data: data,
  32414. start: offset + position,
  32415. end: offset + position + packetItem.dataLength,
  32416. codingpasses: packetItem.codingpasses
  32417. });
  32418. position += packetItem.dataLength;
  32419. }
  32420. }
  32421. return position;
  32422. }
  32423. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  32424. var x0 = subband.tbx0;
  32425. var y0 = subband.tby0;
  32426. var width = subband.tbx1 - subband.tbx0;
  32427. var codeblocks = subband.codeblocks;
  32428. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  32429. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  32430. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  32431. var codeblock = codeblocks[i];
  32432. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  32433. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  32434. if (blockWidth === 0 || blockHeight === 0) {
  32435. continue;
  32436. }
  32437. if (codeblock['data'] === undefined) {
  32438. continue;
  32439. }
  32440. var bitModel, currentCodingpassType;
  32441. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  32442. currentCodingpassType = 2;
  32443. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  32444. var j, jj, dataItem;
  32445. for (j = 0, jj = data.length; j < jj; j++) {
  32446. dataItem = data[j];
  32447. totalLength += dataItem.end - dataItem.start;
  32448. codingpasses += dataItem.codingpasses;
  32449. }
  32450. var encodedData = new Uint8Array(totalLength);
  32451. var position = 0;
  32452. for (j = 0, jj = data.length; j < jj; j++) {
  32453. dataItem = data[j];
  32454. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  32455. encodedData.set(chunk, position);
  32456. position += chunk.length;
  32457. }
  32458. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  32459. bitModel.setDecoder(decoder);
  32460. for (j = 0; j < codingpasses; j++) {
  32461. switch (currentCodingpassType) {
  32462. case 0:
  32463. bitModel.runSignificancePropagationPass();
  32464. break;
  32465. case 1:
  32466. bitModel.runMagnitudeRefinementPass();
  32467. break;
  32468. case 2:
  32469. bitModel.runCleanupPass();
  32470. if (segmentationSymbolUsed) {
  32471. bitModel.checkSegmentationSymbol();
  32472. }
  32473. break;
  32474. }
  32475. currentCodingpassType = (currentCodingpassType + 1) % 3;
  32476. }
  32477. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  32478. var sign = bitModel.coefficentsSign;
  32479. var magnitude = bitModel.coefficentsMagnitude;
  32480. var bitsDecoded = bitModel.bitsDecoded;
  32481. var magnitudeCorrection = reversible ? 0 : 0.5;
  32482. var k, n, nb;
  32483. position = 0;
  32484. var interleave = subband.type !== 'LL';
  32485. for (j = 0; j < blockHeight; j++) {
  32486. var row = offset / width | 0;
  32487. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  32488. for (k = 0; k < blockWidth; k++) {
  32489. n = magnitude[position];
  32490. if (n !== 0) {
  32491. n = (n + magnitudeCorrection) * delta;
  32492. if (sign[position] !== 0) {
  32493. n = -n;
  32494. }
  32495. nb = bitsDecoded[position];
  32496. var pos = interleave ? levelOffset + (offset << 1) : offset;
  32497. if (reversible && nb >= mb) {
  32498. coefficients[pos] = n;
  32499. } else {
  32500. coefficients[pos] = n * (1 << mb - nb);
  32501. }
  32502. }
  32503. offset++;
  32504. position++;
  32505. }
  32506. offset += width - blockWidth;
  32507. }
  32508. }
  32509. }
  32510. function transformTile(context, tile, c) {
  32511. var component = tile.components[c];
  32512. var codingStyleParameters = component.codingStyleParameters;
  32513. var quantizationParameters = component.quantizationParameters;
  32514. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  32515. var spqcds = quantizationParameters.SPqcds;
  32516. var scalarExpounded = quantizationParameters.scalarExpounded;
  32517. var guardBits = quantizationParameters.guardBits;
  32518. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  32519. var precision = context.components[c].precision;
  32520. var reversible = codingStyleParameters.reversibleTransformation;
  32521. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  32522. var subbandCoefficients = [];
  32523. var b = 0;
  32524. for (var i = 0; i <= decompositionLevelsCount; i++) {
  32525. var resolution = component.resolutions[i];
  32526. var width = resolution.trx1 - resolution.trx0;
  32527. var height = resolution.try1 - resolution.try0;
  32528. var coefficients = new Float32Array(width * height);
  32529. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  32530. var mu, epsilon;
  32531. if (!scalarExpounded) {
  32532. mu = spqcds[0].mu;
  32533. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  32534. } else {
  32535. mu = spqcds[b].mu;
  32536. epsilon = spqcds[b].epsilon;
  32537. b++;
  32538. }
  32539. var subband = resolution.subbands[j];
  32540. var gainLog2 = SubbandsGainLog2[subband.type];
  32541. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  32542. var mb = guardBits + epsilon - 1;
  32543. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  32544. }
  32545. subbandCoefficients.push({
  32546. width: width,
  32547. height: height,
  32548. items: coefficients
  32549. });
  32550. }
  32551. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  32552. return {
  32553. left: component.tcx0,
  32554. top: component.tcy0,
  32555. width: result.width,
  32556. height: result.height,
  32557. items: result.items
  32558. };
  32559. }
  32560. function transformComponents(context) {
  32561. var siz = context.SIZ;
  32562. var components = context.components;
  32563. var componentsCount = siz.Csiz;
  32564. var resultImages = [];
  32565. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  32566. var tile = context.tiles[i];
  32567. var transformedTiles = [];
  32568. var c;
  32569. for (c = 0; c < componentsCount; c++) {
  32570. transformedTiles[c] = transformTile(context, tile, c);
  32571. }
  32572. var tile0 = transformedTiles[0];
  32573. var out = new Uint8Array(tile0.items.length * componentsCount);
  32574. var result = {
  32575. left: tile0.left,
  32576. top: tile0.top,
  32577. width: tile0.width,
  32578. height: tile0.height,
  32579. items: out
  32580. };
  32581. var shift, offset, max, min, maxK;
  32582. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  32583. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  32584. var fourComponents = componentsCount === 4;
  32585. var y0items = transformedTiles[0].items;
  32586. var y1items = transformedTiles[1].items;
  32587. var y2items = transformedTiles[2].items;
  32588. var y3items = fourComponents ? transformedTiles[3].items : null;
  32589. shift = components[0].precision - 8;
  32590. offset = (128 << shift) + 0.5;
  32591. max = 255 * (1 << shift);
  32592. maxK = max * 0.5;
  32593. min = -maxK;
  32594. var component0 = tile.components[0];
  32595. var alpha01 = componentsCount - 3;
  32596. jj = y0items.length;
  32597. if (!component0.codingStyleParameters.reversibleTransformation) {
  32598. for (j = 0; j < jj; j++, pos += alpha01) {
  32599. y0 = y0items[j] + offset;
  32600. y1 = y1items[j];
  32601. y2 = y2items[j];
  32602. r = y0 + 1.402 * y2;
  32603. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  32604. b = y0 + 1.772 * y1;
  32605. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32606. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32607. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32608. }
  32609. } else {
  32610. for (j = 0; j < jj; j++, pos += alpha01) {
  32611. y0 = y0items[j] + offset;
  32612. y1 = y1items[j];
  32613. y2 = y2items[j];
  32614. g = y0 - (y2 + y1 >> 2);
  32615. r = g + y2;
  32616. b = g + y1;
  32617. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32618. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32619. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32620. }
  32621. }
  32622. if (fourComponents) {
  32623. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  32624. k = y3items[j];
  32625. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  32626. }
  32627. }
  32628. } else {
  32629. for (c = 0; c < componentsCount; c++) {
  32630. var items = transformedTiles[c].items;
  32631. shift = components[c].precision - 8;
  32632. offset = (128 << shift) + 0.5;
  32633. max = 127.5 * (1 << shift);
  32634. min = -max;
  32635. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  32636. val = items[j];
  32637. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  32638. pos += componentsCount;
  32639. }
  32640. }
  32641. }
  32642. resultImages.push(result);
  32643. }
  32644. return resultImages;
  32645. }
  32646. function initializeTile(context, tileIndex) {
  32647. var siz = context.SIZ;
  32648. var componentsCount = siz.Csiz;
  32649. var tile = context.tiles[tileIndex];
  32650. for (var c = 0; c < componentsCount; c++) {
  32651. var component = tile.components[c];
  32652. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  32653. component.quantizationParameters = qcdOrQcc;
  32654. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  32655. component.codingStyleParameters = codOrCoc;
  32656. }
  32657. tile.codingStyleDefaultParameters = context.currentTile.COD;
  32658. }
  32659. var TagTree = function TagTreeClosure() {
  32660. function TagTree(width, height) {
  32661. var levelsLength = log2(Math.max(width, height)) + 1;
  32662. this.levels = [];
  32663. for (var i = 0; i < levelsLength; i++) {
  32664. var level = {
  32665. width: width,
  32666. height: height,
  32667. items: []
  32668. };
  32669. this.levels.push(level);
  32670. width = Math.ceil(width / 2);
  32671. height = Math.ceil(height / 2);
  32672. }
  32673. }
  32674. TagTree.prototype = {
  32675. reset: function TagTree_reset(i, j) {
  32676. var currentLevel = 0, value = 0, level;
  32677. while (currentLevel < this.levels.length) {
  32678. level = this.levels[currentLevel];
  32679. var index = i + j * level.width;
  32680. if (level.items[index] !== undefined) {
  32681. value = level.items[index];
  32682. break;
  32683. }
  32684. level.index = index;
  32685. i >>= 1;
  32686. j >>= 1;
  32687. currentLevel++;
  32688. }
  32689. currentLevel--;
  32690. level = this.levels[currentLevel];
  32691. level.items[level.index] = value;
  32692. this.currentLevel = currentLevel;
  32693. delete this.value;
  32694. },
  32695. incrementValue: function TagTree_incrementValue() {
  32696. var level = this.levels[this.currentLevel];
  32697. level.items[level.index]++;
  32698. },
  32699. nextLevel: function TagTree_nextLevel() {
  32700. var currentLevel = this.currentLevel;
  32701. var level = this.levels[currentLevel];
  32702. var value = level.items[level.index];
  32703. currentLevel--;
  32704. if (currentLevel < 0) {
  32705. this.value = value;
  32706. return false;
  32707. }
  32708. this.currentLevel = currentLevel;
  32709. level = this.levels[currentLevel];
  32710. level.items[level.index] = value;
  32711. return true;
  32712. }
  32713. };
  32714. return TagTree;
  32715. }();
  32716. var InclusionTree = function InclusionTreeClosure() {
  32717. function InclusionTree(width, height, defaultValue) {
  32718. var levelsLength = log2(Math.max(width, height)) + 1;
  32719. this.levels = [];
  32720. for (var i = 0; i < levelsLength; i++) {
  32721. var items = new Uint8Array(width * height);
  32722. for (var j = 0, jj = items.length; j < jj; j++) {
  32723. items[j] = defaultValue;
  32724. }
  32725. var level = {
  32726. width: width,
  32727. height: height,
  32728. items: items
  32729. };
  32730. this.levels.push(level);
  32731. width = Math.ceil(width / 2);
  32732. height = Math.ceil(height / 2);
  32733. }
  32734. }
  32735. InclusionTree.prototype = {
  32736. reset: function InclusionTree_reset(i, j, stopValue) {
  32737. var currentLevel = 0;
  32738. while (currentLevel < this.levels.length) {
  32739. var level = this.levels[currentLevel];
  32740. var index = i + j * level.width;
  32741. level.index = index;
  32742. var value = level.items[index];
  32743. if (value === 0xFF) {
  32744. break;
  32745. }
  32746. if (value > stopValue) {
  32747. this.currentLevel = currentLevel;
  32748. this.propagateValues();
  32749. return false;
  32750. }
  32751. i >>= 1;
  32752. j >>= 1;
  32753. currentLevel++;
  32754. }
  32755. this.currentLevel = currentLevel - 1;
  32756. return true;
  32757. },
  32758. incrementValue: function InclusionTree_incrementValue(stopValue) {
  32759. var level = this.levels[this.currentLevel];
  32760. level.items[level.index] = stopValue + 1;
  32761. this.propagateValues();
  32762. },
  32763. propagateValues: function InclusionTree_propagateValues() {
  32764. var levelIndex = this.currentLevel;
  32765. var level = this.levels[levelIndex];
  32766. var currentValue = level.items[level.index];
  32767. while (--levelIndex >= 0) {
  32768. level = this.levels[levelIndex];
  32769. level.items[level.index] = currentValue;
  32770. }
  32771. },
  32772. nextLevel: function InclusionTree_nextLevel() {
  32773. var currentLevel = this.currentLevel;
  32774. var level = this.levels[currentLevel];
  32775. var value = level.items[level.index];
  32776. level.items[level.index] = 0xFF;
  32777. currentLevel--;
  32778. if (currentLevel < 0) {
  32779. return false;
  32780. }
  32781. this.currentLevel = currentLevel;
  32782. level = this.levels[currentLevel];
  32783. level.items[level.index] = value;
  32784. return true;
  32785. }
  32786. };
  32787. return InclusionTree;
  32788. }();
  32789. var BitModel = function BitModelClosure() {
  32790. var UNIFORM_CONTEXT = 17;
  32791. var RUNLENGTH_CONTEXT = 18;
  32792. var LLAndLHContextsLabel = new Uint8Array([
  32793. 0,
  32794. 5,
  32795. 8,
  32796. 0,
  32797. 3,
  32798. 7,
  32799. 8,
  32800. 0,
  32801. 4,
  32802. 7,
  32803. 8,
  32804. 0,
  32805. 0,
  32806. 0,
  32807. 0,
  32808. 0,
  32809. 1,
  32810. 6,
  32811. 8,
  32812. 0,
  32813. 3,
  32814. 7,
  32815. 8,
  32816. 0,
  32817. 4,
  32818. 7,
  32819. 8,
  32820. 0,
  32821. 0,
  32822. 0,
  32823. 0,
  32824. 0,
  32825. 2,
  32826. 6,
  32827. 8,
  32828. 0,
  32829. 3,
  32830. 7,
  32831. 8,
  32832. 0,
  32833. 4,
  32834. 7,
  32835. 8,
  32836. 0,
  32837. 0,
  32838. 0,
  32839. 0,
  32840. 0,
  32841. 2,
  32842. 6,
  32843. 8,
  32844. 0,
  32845. 3,
  32846. 7,
  32847. 8,
  32848. 0,
  32849. 4,
  32850. 7,
  32851. 8,
  32852. 0,
  32853. 0,
  32854. 0,
  32855. 0,
  32856. 0,
  32857. 2,
  32858. 6,
  32859. 8,
  32860. 0,
  32861. 3,
  32862. 7,
  32863. 8,
  32864. 0,
  32865. 4,
  32866. 7,
  32867. 8
  32868. ]);
  32869. var HLContextLabel = new Uint8Array([
  32870. 0,
  32871. 3,
  32872. 4,
  32873. 0,
  32874. 5,
  32875. 7,
  32876. 7,
  32877. 0,
  32878. 8,
  32879. 8,
  32880. 8,
  32881. 0,
  32882. 0,
  32883. 0,
  32884. 0,
  32885. 0,
  32886. 1,
  32887. 3,
  32888. 4,
  32889. 0,
  32890. 6,
  32891. 7,
  32892. 7,
  32893. 0,
  32894. 8,
  32895. 8,
  32896. 8,
  32897. 0,
  32898. 0,
  32899. 0,
  32900. 0,
  32901. 0,
  32902. 2,
  32903. 3,
  32904. 4,
  32905. 0,
  32906. 6,
  32907. 7,
  32908. 7,
  32909. 0,
  32910. 8,
  32911. 8,
  32912. 8,
  32913. 0,
  32914. 0,
  32915. 0,
  32916. 0,
  32917. 0,
  32918. 2,
  32919. 3,
  32920. 4,
  32921. 0,
  32922. 6,
  32923. 7,
  32924. 7,
  32925. 0,
  32926. 8,
  32927. 8,
  32928. 8,
  32929. 0,
  32930. 0,
  32931. 0,
  32932. 0,
  32933. 0,
  32934. 2,
  32935. 3,
  32936. 4,
  32937. 0,
  32938. 6,
  32939. 7,
  32940. 7,
  32941. 0,
  32942. 8,
  32943. 8,
  32944. 8
  32945. ]);
  32946. var HHContextLabel = new Uint8Array([
  32947. 0,
  32948. 1,
  32949. 2,
  32950. 0,
  32951. 1,
  32952. 2,
  32953. 2,
  32954. 0,
  32955. 2,
  32956. 2,
  32957. 2,
  32958. 0,
  32959. 0,
  32960. 0,
  32961. 0,
  32962. 0,
  32963. 3,
  32964. 4,
  32965. 5,
  32966. 0,
  32967. 4,
  32968. 5,
  32969. 5,
  32970. 0,
  32971. 5,
  32972. 5,
  32973. 5,
  32974. 0,
  32975. 0,
  32976. 0,
  32977. 0,
  32978. 0,
  32979. 6,
  32980. 7,
  32981. 7,
  32982. 0,
  32983. 7,
  32984. 7,
  32985. 7,
  32986. 0,
  32987. 7,
  32988. 7,
  32989. 7,
  32990. 0,
  32991. 0,
  32992. 0,
  32993. 0,
  32994. 0,
  32995. 8,
  32996. 8,
  32997. 8,
  32998. 0,
  32999. 8,
  33000. 8,
  33001. 8,
  33002. 0,
  33003. 8,
  33004. 8,
  33005. 8,
  33006. 0,
  33007. 0,
  33008. 0,
  33009. 0,
  33010. 0,
  33011. 8,
  33012. 8,
  33013. 8,
  33014. 0,
  33015. 8,
  33016. 8,
  33017. 8,
  33018. 0,
  33019. 8,
  33020. 8,
  33021. 8
  33022. ]);
  33023. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33024. this.width = width;
  33025. this.height = height;
  33026. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33027. var coefficientCount = width * height;
  33028. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33029. this.coefficentsSign = new Uint8Array(coefficientCount);
  33030. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33031. this.processingFlags = new Uint8Array(coefficientCount);
  33032. var bitsDecoded = new Uint8Array(coefficientCount);
  33033. if (zeroBitPlanes !== 0) {
  33034. for (var i = 0; i < coefficientCount; i++) {
  33035. bitsDecoded[i] = zeroBitPlanes;
  33036. }
  33037. }
  33038. this.bitsDecoded = bitsDecoded;
  33039. this.reset();
  33040. }
  33041. BitModel.prototype = {
  33042. setDecoder: function BitModel_setDecoder(decoder) {
  33043. this.decoder = decoder;
  33044. },
  33045. reset: function BitModel_reset() {
  33046. this.contexts = new Int8Array(19);
  33047. this.contexts[0] = 4 << 1 | 0;
  33048. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33049. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33050. },
  33051. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33052. var neighborsSignificance = this.neighborsSignificance;
  33053. var width = this.width, height = this.height;
  33054. var left = column > 0;
  33055. var right = column + 1 < width;
  33056. var i;
  33057. if (row > 0) {
  33058. i = index - width;
  33059. if (left) {
  33060. neighborsSignificance[i - 1] += 0x10;
  33061. }
  33062. if (right) {
  33063. neighborsSignificance[i + 1] += 0x10;
  33064. }
  33065. neighborsSignificance[i] += 0x04;
  33066. }
  33067. if (row + 1 < height) {
  33068. i = index + width;
  33069. if (left) {
  33070. neighborsSignificance[i - 1] += 0x10;
  33071. }
  33072. if (right) {
  33073. neighborsSignificance[i + 1] += 0x10;
  33074. }
  33075. neighborsSignificance[i] += 0x04;
  33076. }
  33077. if (left) {
  33078. neighborsSignificance[index - 1] += 0x01;
  33079. }
  33080. if (right) {
  33081. neighborsSignificance[index + 1] += 0x01;
  33082. }
  33083. neighborsSignificance[index] |= 0x80;
  33084. },
  33085. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33086. var decoder = this.decoder;
  33087. var width = this.width, height = this.height;
  33088. var coefficentsMagnitude = this.coefficentsMagnitude;
  33089. var coefficentsSign = this.coefficentsSign;
  33090. var neighborsSignificance = this.neighborsSignificance;
  33091. var processingFlags = this.processingFlags;
  33092. var contexts = this.contexts;
  33093. var labels = this.contextLabelTable;
  33094. var bitsDecoded = this.bitsDecoded;
  33095. var processedInverseMask = ~1;
  33096. var processedMask = 1;
  33097. var firstMagnitudeBitMask = 2;
  33098. for (var i0 = 0; i0 < height; i0 += 4) {
  33099. for (var j = 0; j < width; j++) {
  33100. var index = i0 * width + j;
  33101. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33102. var i = i0 + i1;
  33103. if (i >= height) {
  33104. break;
  33105. }
  33106. processingFlags[index] &= processedInverseMask;
  33107. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33108. continue;
  33109. }
  33110. var contextLabel = labels[neighborsSignificance[index]];
  33111. var decision = decoder.readBit(contexts, contextLabel);
  33112. if (decision) {
  33113. var sign = this.decodeSignBit(i, j, index);
  33114. coefficentsSign[index] = sign;
  33115. coefficentsMagnitude[index] = 1;
  33116. this.setNeighborsSignificance(i, j, index);
  33117. processingFlags[index] |= firstMagnitudeBitMask;
  33118. }
  33119. bitsDecoded[index]++;
  33120. processingFlags[index] |= processedMask;
  33121. }
  33122. }
  33123. }
  33124. },
  33125. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33126. var width = this.width, height = this.height;
  33127. var coefficentsMagnitude = this.coefficentsMagnitude;
  33128. var coefficentsSign = this.coefficentsSign;
  33129. var contribution, sign0, sign1, significance1;
  33130. var contextLabel, decoded;
  33131. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33132. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33133. sign1 = coefficentsSign[index + 1];
  33134. if (significance1) {
  33135. sign0 = coefficentsSign[index - 1];
  33136. contribution = 1 - sign1 - sign0;
  33137. } else {
  33138. contribution = 1 - sign1 - sign1;
  33139. }
  33140. } else if (significance1) {
  33141. sign0 = coefficentsSign[index - 1];
  33142. contribution = 1 - sign0 - sign0;
  33143. } else {
  33144. contribution = 0;
  33145. }
  33146. var horizontalContribution = 3 * contribution;
  33147. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33148. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33149. sign1 = coefficentsSign[index + width];
  33150. if (significance1) {
  33151. sign0 = coefficentsSign[index - width];
  33152. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33153. } else {
  33154. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33155. }
  33156. } else if (significance1) {
  33157. sign0 = coefficentsSign[index - width];
  33158. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33159. } else {
  33160. contribution = horizontalContribution;
  33161. }
  33162. if (contribution >= 0) {
  33163. contextLabel = 9 + contribution;
  33164. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33165. } else {
  33166. contextLabel = 9 - contribution;
  33167. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33168. }
  33169. return decoded;
  33170. },
  33171. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33172. var decoder = this.decoder;
  33173. var width = this.width, height = this.height;
  33174. var coefficentsMagnitude = this.coefficentsMagnitude;
  33175. var neighborsSignificance = this.neighborsSignificance;
  33176. var contexts = this.contexts;
  33177. var bitsDecoded = this.bitsDecoded;
  33178. var processingFlags = this.processingFlags;
  33179. var processedMask = 1;
  33180. var firstMagnitudeBitMask = 2;
  33181. var length = width * height;
  33182. var width4 = width * 4;
  33183. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33184. indexNext = Math.min(length, index0 + width4);
  33185. for (var j = 0; j < width; j++) {
  33186. for (var index = index0 + j; index < indexNext; index += width) {
  33187. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33188. continue;
  33189. }
  33190. var contextLabel = 16;
  33191. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33192. processingFlags[index] ^= firstMagnitudeBitMask;
  33193. var significance = neighborsSignificance[index] & 127;
  33194. contextLabel = significance === 0 ? 15 : 14;
  33195. }
  33196. var bit = decoder.readBit(contexts, contextLabel);
  33197. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33198. bitsDecoded[index]++;
  33199. processingFlags[index] |= processedMask;
  33200. }
  33201. }
  33202. }
  33203. },
  33204. runCleanupPass: function BitModel_runCleanupPass() {
  33205. var decoder = this.decoder;
  33206. var width = this.width, height = this.height;
  33207. var neighborsSignificance = this.neighborsSignificance;
  33208. var coefficentsMagnitude = this.coefficentsMagnitude;
  33209. var coefficentsSign = this.coefficentsSign;
  33210. var contexts = this.contexts;
  33211. var labels = this.contextLabelTable;
  33212. var bitsDecoded = this.bitsDecoded;
  33213. var processingFlags = this.processingFlags;
  33214. var processedMask = 1;
  33215. var firstMagnitudeBitMask = 2;
  33216. var oneRowDown = width;
  33217. var twoRowsDown = width * 2;
  33218. var threeRowsDown = width * 3;
  33219. var iNext;
  33220. for (var i0 = 0; i0 < height; i0 = iNext) {
  33221. iNext = Math.min(i0 + 4, height);
  33222. var indexBase = i0 * width;
  33223. var checkAllEmpty = i0 + 3 < height;
  33224. for (var j = 0; j < width; j++) {
  33225. var index0 = indexBase + j;
  33226. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  33227. var i1 = 0, index = index0;
  33228. var i = i0, sign;
  33229. if (allEmpty) {
  33230. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33231. if (!hasSignificantCoefficent) {
  33232. bitsDecoded[index0]++;
  33233. bitsDecoded[index0 + oneRowDown]++;
  33234. bitsDecoded[index0 + twoRowsDown]++;
  33235. bitsDecoded[index0 + threeRowsDown]++;
  33236. continue;
  33237. }
  33238. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33239. if (i1 !== 0) {
  33240. i = i0 + i1;
  33241. index += i1 * width;
  33242. }
  33243. sign = this.decodeSignBit(i, j, index);
  33244. coefficentsSign[index] = sign;
  33245. coefficentsMagnitude[index] = 1;
  33246. this.setNeighborsSignificance(i, j, index);
  33247. processingFlags[index] |= firstMagnitudeBitMask;
  33248. index = index0;
  33249. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33250. bitsDecoded[index]++;
  33251. }
  33252. i1++;
  33253. }
  33254. for (i = i0 + i1; i < iNext; i++, index += width) {
  33255. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33256. continue;
  33257. }
  33258. var contextLabel = labels[neighborsSignificance[index]];
  33259. var decision = decoder.readBit(contexts, contextLabel);
  33260. if (decision === 1) {
  33261. sign = this.decodeSignBit(i, j, index);
  33262. coefficentsSign[index] = sign;
  33263. coefficentsMagnitude[index] = 1;
  33264. this.setNeighborsSignificance(i, j, index);
  33265. processingFlags[index] |= firstMagnitudeBitMask;
  33266. }
  33267. bitsDecoded[index]++;
  33268. }
  33269. }
  33270. }
  33271. },
  33272. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33273. var decoder = this.decoder;
  33274. var contexts = this.contexts;
  33275. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33276. if (symbol !== 0xA) {
  33277. error('JPX Error: Invalid segmentation symbol');
  33278. }
  33279. }
  33280. };
  33281. return BitModel;
  33282. }();
  33283. var Transform = function TransformClosure() {
  33284. function Transform() {
  33285. }
  33286. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33287. var ll = subbands[0];
  33288. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33289. ll = this.iterate(ll, subbands[i], u0, v0);
  33290. }
  33291. return ll;
  33292. };
  33293. Transform.prototype.extend = function extend(buffer, offset, size) {
  33294. var i1 = offset - 1, j1 = offset + 1;
  33295. var i2 = offset + size - 2, j2 = offset + size;
  33296. buffer[i1--] = buffer[j1++];
  33297. buffer[j2++] = buffer[i2--];
  33298. buffer[i1--] = buffer[j1++];
  33299. buffer[j2++] = buffer[i2--];
  33300. buffer[i1--] = buffer[j1++];
  33301. buffer[j2++] = buffer[i2--];
  33302. buffer[i1] = buffer[j1];
  33303. buffer[j2] = buffer[i2];
  33304. };
  33305. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  33306. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  33307. var width = hl_lh_hh.width;
  33308. var height = hl_lh_hh.height;
  33309. var items = hl_lh_hh.items;
  33310. var i, j, k, l, u, v;
  33311. for (k = 0, i = 0; i < llHeight; i++) {
  33312. l = i * 2 * width;
  33313. for (j = 0; j < llWidth; j++, k++, l += 2) {
  33314. items[l] = llItems[k];
  33315. }
  33316. }
  33317. llItems = ll.items = null;
  33318. var bufferPadding = 4;
  33319. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  33320. if (width === 1) {
  33321. if ((u0 & 1) !== 0) {
  33322. for (v = 0, k = 0; v < height; v++, k += width) {
  33323. items[k] *= 0.5;
  33324. }
  33325. }
  33326. } else {
  33327. for (v = 0, k = 0; v < height; v++, k += width) {
  33328. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  33329. this.extend(rowBuffer, bufferPadding, width);
  33330. this.filter(rowBuffer, bufferPadding, width);
  33331. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  33332. }
  33333. }
  33334. var numBuffers = 16;
  33335. var colBuffers = [];
  33336. for (i = 0; i < numBuffers; i++) {
  33337. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  33338. }
  33339. var b, currentBuffer = 0;
  33340. ll = bufferPadding + height;
  33341. if (height === 1) {
  33342. if ((v0 & 1) !== 0) {
  33343. for (u = 0; u < width; u++) {
  33344. items[u] *= 0.5;
  33345. }
  33346. }
  33347. } else {
  33348. for (u = 0; u < width; u++) {
  33349. if (currentBuffer === 0) {
  33350. numBuffers = Math.min(width - u, numBuffers);
  33351. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  33352. for (b = 0; b < numBuffers; b++) {
  33353. colBuffers[b][l] = items[k + b];
  33354. }
  33355. }
  33356. currentBuffer = numBuffers;
  33357. }
  33358. currentBuffer--;
  33359. var buffer = colBuffers[currentBuffer];
  33360. this.extend(buffer, bufferPadding, height);
  33361. this.filter(buffer, bufferPadding, height);
  33362. if (currentBuffer === 0) {
  33363. k = u - numBuffers + 1;
  33364. for (l = bufferPadding; l < ll; k += width, l++) {
  33365. for (b = 0; b < numBuffers; b++) {
  33366. items[k + b] = colBuffers[b][l];
  33367. }
  33368. }
  33369. }
  33370. }
  33371. }
  33372. return {
  33373. width: width,
  33374. height: height,
  33375. items: items
  33376. };
  33377. };
  33378. return Transform;
  33379. }();
  33380. var IrreversibleTransform = function IrreversibleTransformClosure() {
  33381. function IrreversibleTransform() {
  33382. Transform.call(this);
  33383. }
  33384. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  33385. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  33386. var len = length >> 1;
  33387. offset = offset | 0;
  33388. var j, n, current, next;
  33389. var alpha = -1.586134342059924;
  33390. var beta = -0.052980118572961;
  33391. var gamma = 0.882911075530934;
  33392. var delta = 0.443506852043971;
  33393. var K = 1.230174104914001;
  33394. var K_ = 1 / K;
  33395. j = offset - 3;
  33396. for (n = len + 4; n--; j += 2) {
  33397. x[j] *= K_;
  33398. }
  33399. j = offset - 2;
  33400. current = delta * x[j - 1];
  33401. for (n = len + 3; n--; j += 2) {
  33402. next = delta * x[j + 1];
  33403. x[j] = K * x[j] - current - next;
  33404. if (n--) {
  33405. j += 2;
  33406. current = delta * x[j + 1];
  33407. x[j] = K * x[j] - current - next;
  33408. } else {
  33409. break;
  33410. }
  33411. }
  33412. j = offset - 1;
  33413. current = gamma * x[j - 1];
  33414. for (n = len + 2; n--; j += 2) {
  33415. next = gamma * x[j + 1];
  33416. x[j] -= current + next;
  33417. if (n--) {
  33418. j += 2;
  33419. current = gamma * x[j + 1];
  33420. x[j] -= current + next;
  33421. } else {
  33422. break;
  33423. }
  33424. }
  33425. j = offset;
  33426. current = beta * x[j - 1];
  33427. for (n = len + 1; n--; j += 2) {
  33428. next = beta * x[j + 1];
  33429. x[j] -= current + next;
  33430. if (n--) {
  33431. j += 2;
  33432. current = beta * x[j + 1];
  33433. x[j] -= current + next;
  33434. } else {
  33435. break;
  33436. }
  33437. }
  33438. if (len !== 0) {
  33439. j = offset + 1;
  33440. current = alpha * x[j - 1];
  33441. for (n = len; n--; j += 2) {
  33442. next = alpha * x[j + 1];
  33443. x[j] -= current + next;
  33444. if (n--) {
  33445. j += 2;
  33446. current = alpha * x[j + 1];
  33447. x[j] -= current + next;
  33448. } else {
  33449. break;
  33450. }
  33451. }
  33452. }
  33453. };
  33454. return IrreversibleTransform;
  33455. }();
  33456. var ReversibleTransform = function ReversibleTransformClosure() {
  33457. function ReversibleTransform() {
  33458. Transform.call(this);
  33459. }
  33460. ReversibleTransform.prototype = Object.create(Transform.prototype);
  33461. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  33462. var len = length >> 1;
  33463. offset = offset | 0;
  33464. var j, n;
  33465. for (j = offset, n = len + 1; n--; j += 2) {
  33466. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  33467. }
  33468. for (j = offset + 1, n = len; n--; j += 2) {
  33469. x[j] += x[j - 1] + x[j + 1] >> 1;
  33470. }
  33471. };
  33472. return ReversibleTransform;
  33473. }();
  33474. return JpxImage;
  33475. }();
  33476. exports.JpxImage = JpxImage;
  33477. /***/ }),
  33478. /* 20 */
  33479. /***/ (function(module, exports, __w_pdfjs_require__) {
  33480. "use strict";
  33481. var sharedUtil = __w_pdfjs_require__(0);
  33482. var corePrimitives = __w_pdfjs_require__(1);
  33483. var coreCrypto = __w_pdfjs_require__(17);
  33484. var coreParser = __w_pdfjs_require__(6);
  33485. var coreChunkedStream = __w_pdfjs_require__(16);
  33486. var coreColorSpace = __w_pdfjs_require__(4);
  33487. var InvalidPDFException = sharedUtil.InvalidPDFException;
  33488. var MissingDataException = sharedUtil.MissingDataException;
  33489. var XRefParseException = sharedUtil.XRefParseException;
  33490. var assert = sharedUtil.assert;
  33491. var bytesToString = sharedUtil.bytesToString;
  33492. var createPromiseCapability = sharedUtil.createPromiseCapability;
  33493. var error = sharedUtil.error;
  33494. var info = sharedUtil.info;
  33495. var isArray = sharedUtil.isArray;
  33496. var isBool = sharedUtil.isBool;
  33497. var isInt = sharedUtil.isInt;
  33498. var isString = sharedUtil.isString;
  33499. var shadow = sharedUtil.shadow;
  33500. var stringToPDFString = sharedUtil.stringToPDFString;
  33501. var stringToUTF8String = sharedUtil.stringToUTF8String;
  33502. var warn = sharedUtil.warn;
  33503. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  33504. var Util = sharedUtil.Util;
  33505. var Ref = corePrimitives.Ref;
  33506. var RefSet = corePrimitives.RefSet;
  33507. var RefSetCache = corePrimitives.RefSetCache;
  33508. var isName = corePrimitives.isName;
  33509. var isCmd = corePrimitives.isCmd;
  33510. var isDict = corePrimitives.isDict;
  33511. var isRef = corePrimitives.isRef;
  33512. var isRefsEqual = corePrimitives.isRefsEqual;
  33513. var isStream = corePrimitives.isStream;
  33514. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  33515. var Lexer = coreParser.Lexer;
  33516. var Parser = coreParser.Parser;
  33517. var ChunkedStream = coreChunkedStream.ChunkedStream;
  33518. var ColorSpace = coreColorSpace.ColorSpace;
  33519. var Catalog = function CatalogClosure() {
  33520. function Catalog(pdfManager, xref, pageFactory) {
  33521. this.pdfManager = pdfManager;
  33522. this.xref = xref;
  33523. this.catDict = xref.getCatalogObj();
  33524. this.fontCache = new RefSetCache();
  33525. this.builtInCMapCache = Object.create(null);
  33526. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  33527. this.pageFactory = pageFactory;
  33528. this.pagePromises = [];
  33529. }
  33530. Catalog.prototype = {
  33531. get metadata() {
  33532. var streamRef = this.catDict.getRaw('Metadata');
  33533. if (!isRef(streamRef)) {
  33534. return shadow(this, 'metadata', null);
  33535. }
  33536. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  33537. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  33538. var metadata;
  33539. if (stream && isDict(stream.dict)) {
  33540. var type = stream.dict.get('Type');
  33541. var subtype = stream.dict.get('Subtype');
  33542. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  33543. try {
  33544. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  33545. } catch (e) {
  33546. info('Skipping invalid metadata.');
  33547. }
  33548. }
  33549. }
  33550. return shadow(this, 'metadata', metadata);
  33551. },
  33552. get toplevelPagesDict() {
  33553. var pagesObj = this.catDict.get('Pages');
  33554. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  33555. return shadow(this, 'toplevelPagesDict', pagesObj);
  33556. },
  33557. get documentOutline() {
  33558. var obj = null;
  33559. try {
  33560. obj = this.readDocumentOutline();
  33561. } catch (ex) {
  33562. if (ex instanceof MissingDataException) {
  33563. throw ex;
  33564. }
  33565. warn('Unable to read document outline');
  33566. }
  33567. return shadow(this, 'documentOutline', obj);
  33568. },
  33569. readDocumentOutline: function Catalog_readDocumentOutline() {
  33570. var obj = this.catDict.get('Outlines');
  33571. if (!isDict(obj)) {
  33572. return null;
  33573. }
  33574. obj = obj.getRaw('First');
  33575. if (!isRef(obj)) {
  33576. return null;
  33577. }
  33578. var root = { items: [] };
  33579. var queue = [{
  33580. obj: obj,
  33581. parent: root
  33582. }];
  33583. var processed = new RefSet();
  33584. processed.put(obj);
  33585. var xref = this.xref, blackColor = new Uint8Array(3);
  33586. while (queue.length > 0) {
  33587. var i = queue.shift();
  33588. var outlineDict = xref.fetchIfRef(i.obj);
  33589. if (outlineDict === null) {
  33590. continue;
  33591. }
  33592. assert(outlineDict.has('Title'), 'Invalid outline item');
  33593. var data = {
  33594. url: null,
  33595. dest: null
  33596. };
  33597. Catalog.parseDestDictionary({
  33598. destDict: outlineDict,
  33599. resultObj: data,
  33600. docBaseUrl: this.pdfManager.docBaseUrl
  33601. });
  33602. var title = outlineDict.get('Title');
  33603. var flags = outlineDict.get('F') || 0;
  33604. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  33605. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  33606. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  33607. }
  33608. var outlineItem = {
  33609. dest: data.dest,
  33610. url: data.url,
  33611. unsafeUrl: data.unsafeUrl,
  33612. newWindow: data.newWindow,
  33613. title: stringToPDFString(title),
  33614. color: rgbColor,
  33615. count: outlineDict.get('Count'),
  33616. bold: !!(flags & 2),
  33617. italic: !!(flags & 1),
  33618. items: []
  33619. };
  33620. i.parent.items.push(outlineItem);
  33621. obj = outlineDict.getRaw('First');
  33622. if (isRef(obj) && !processed.has(obj)) {
  33623. queue.push({
  33624. obj: obj,
  33625. parent: outlineItem
  33626. });
  33627. processed.put(obj);
  33628. }
  33629. obj = outlineDict.getRaw('Next');
  33630. if (isRef(obj) && !processed.has(obj)) {
  33631. queue.push({
  33632. obj: obj,
  33633. parent: i.parent
  33634. });
  33635. processed.put(obj);
  33636. }
  33637. }
  33638. return root.items.length > 0 ? root.items : null;
  33639. },
  33640. get numPages() {
  33641. var obj = this.toplevelPagesDict.get('Count');
  33642. assert(isInt(obj), 'page count in top level pages object is not an integer');
  33643. return shadow(this, 'num', obj);
  33644. },
  33645. get destinations() {
  33646. function fetchDestination(dest) {
  33647. return isDict(dest) ? dest.get('D') : dest;
  33648. }
  33649. var xref = this.xref;
  33650. var dests = {}, nameTreeRef, nameDictionaryRef;
  33651. var obj = this.catDict.get('Names');
  33652. if (obj && obj.has('Dests')) {
  33653. nameTreeRef = obj.getRaw('Dests');
  33654. } else if (this.catDict.has('Dests')) {
  33655. nameDictionaryRef = this.catDict.get('Dests');
  33656. }
  33657. if (nameDictionaryRef) {
  33658. obj = nameDictionaryRef;
  33659. obj.forEach(function catalogForEach(key, value) {
  33660. if (!value) {
  33661. return;
  33662. }
  33663. dests[key] = fetchDestination(value);
  33664. });
  33665. }
  33666. if (nameTreeRef) {
  33667. var nameTree = new NameTree(nameTreeRef, xref);
  33668. var names = nameTree.getAll();
  33669. for (var name in names) {
  33670. dests[name] = fetchDestination(names[name]);
  33671. }
  33672. }
  33673. return shadow(this, 'destinations', dests);
  33674. },
  33675. getDestination: function Catalog_getDestination(destinationId) {
  33676. function fetchDestination(dest) {
  33677. return isDict(dest) ? dest.get('D') : dest;
  33678. }
  33679. var xref = this.xref;
  33680. var dest = null, nameTreeRef, nameDictionaryRef;
  33681. var obj = this.catDict.get('Names');
  33682. if (obj && obj.has('Dests')) {
  33683. nameTreeRef = obj.getRaw('Dests');
  33684. } else if (this.catDict.has('Dests')) {
  33685. nameDictionaryRef = this.catDict.get('Dests');
  33686. }
  33687. if (nameDictionaryRef) {
  33688. var value = nameDictionaryRef.get(destinationId);
  33689. if (value) {
  33690. dest = fetchDestination(value);
  33691. }
  33692. }
  33693. if (nameTreeRef) {
  33694. var nameTree = new NameTree(nameTreeRef, xref);
  33695. dest = fetchDestination(nameTree.get(destinationId));
  33696. }
  33697. return dest;
  33698. },
  33699. get pageLabels() {
  33700. var obj = null;
  33701. try {
  33702. obj = this.readPageLabels();
  33703. } catch (ex) {
  33704. if (ex instanceof MissingDataException) {
  33705. throw ex;
  33706. }
  33707. warn('Unable to read page labels.');
  33708. }
  33709. return shadow(this, 'pageLabels', obj);
  33710. },
  33711. readPageLabels: function Catalog_readPageLabels() {
  33712. var obj = this.catDict.getRaw('PageLabels');
  33713. if (!obj) {
  33714. return null;
  33715. }
  33716. var pageLabels = new Array(this.numPages);
  33717. var style = null;
  33718. var prefix = '';
  33719. var numberTree = new NumberTree(obj, this.xref);
  33720. var nums = numberTree.getAll();
  33721. var currentLabel = '', currentIndex = 1;
  33722. for (var i = 0, ii = this.numPages; i < ii; i++) {
  33723. if (i in nums) {
  33724. var labelDict = nums[i];
  33725. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  33726. var type = labelDict.get('Type');
  33727. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  33728. var s = labelDict.get('S');
  33729. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  33730. style = s ? s.name : null;
  33731. var p = labelDict.get('P');
  33732. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  33733. prefix = p ? stringToPDFString(p) : '';
  33734. var st = labelDict.get('St');
  33735. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  33736. currentIndex = st || 1;
  33737. }
  33738. switch (style) {
  33739. case 'D':
  33740. currentLabel = currentIndex;
  33741. break;
  33742. case 'R':
  33743. case 'r':
  33744. currentLabel = Util.toRoman(currentIndex, style === 'r');
  33745. break;
  33746. case 'A':
  33747. case 'a':
  33748. var LIMIT = 26;
  33749. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  33750. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  33751. var letterIndex = currentIndex - 1;
  33752. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  33753. var charBuf = [];
  33754. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  33755. charBuf.push(character);
  33756. }
  33757. currentLabel = charBuf.join('');
  33758. break;
  33759. default:
  33760. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  33761. }
  33762. pageLabels[i] = prefix + currentLabel;
  33763. currentLabel = '';
  33764. currentIndex++;
  33765. }
  33766. return pageLabels;
  33767. },
  33768. get attachments() {
  33769. var xref = this.xref;
  33770. var attachments = null, nameTreeRef;
  33771. var obj = this.catDict.get('Names');
  33772. if (obj) {
  33773. nameTreeRef = obj.getRaw('EmbeddedFiles');
  33774. }
  33775. if (nameTreeRef) {
  33776. var nameTree = new NameTree(nameTreeRef, xref);
  33777. var names = nameTree.getAll();
  33778. for (var name in names) {
  33779. var fs = new FileSpec(names[name], xref);
  33780. if (!attachments) {
  33781. attachments = Object.create(null);
  33782. }
  33783. attachments[stringToPDFString(name)] = fs.serializable;
  33784. }
  33785. }
  33786. return shadow(this, 'attachments', attachments);
  33787. },
  33788. get javaScript() {
  33789. var xref = this.xref;
  33790. var obj = this.catDict.get('Names');
  33791. var javaScript = [];
  33792. function appendIfJavaScriptDict(jsDict) {
  33793. var type = jsDict.get('S');
  33794. if (!isName(type, 'JavaScript')) {
  33795. return;
  33796. }
  33797. var js = jsDict.get('JS');
  33798. if (isStream(js)) {
  33799. js = bytesToString(js.getBytes());
  33800. } else if (!isString(js)) {
  33801. return;
  33802. }
  33803. javaScript.push(stringToPDFString(js));
  33804. }
  33805. if (obj && obj.has('JavaScript')) {
  33806. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  33807. var names = nameTree.getAll();
  33808. for (var name in names) {
  33809. var jsDict = names[name];
  33810. if (isDict(jsDict)) {
  33811. appendIfJavaScriptDict(jsDict);
  33812. }
  33813. }
  33814. }
  33815. var openactionDict = this.catDict.get('OpenAction');
  33816. if (isDict(openactionDict, 'Action')) {
  33817. var actionType = openactionDict.get('S');
  33818. if (isName(actionType, 'Named')) {
  33819. var action = openactionDict.get('N');
  33820. if (isName(action, 'Print')) {
  33821. javaScript.push('print({});');
  33822. }
  33823. } else {
  33824. appendIfJavaScriptDict(openactionDict);
  33825. }
  33826. }
  33827. return shadow(this, 'javaScript', javaScript);
  33828. },
  33829. cleanup: function Catalog_cleanup() {
  33830. var promises = [];
  33831. this.fontCache.forEach(function (promise) {
  33832. promises.push(promise);
  33833. });
  33834. return Promise.all(promises).then(function (translatedFonts) {
  33835. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  33836. var font = translatedFonts[i].dict;
  33837. delete font.translated;
  33838. }
  33839. this.fontCache.clear();
  33840. this.builtInCMapCache = Object.create(null);
  33841. }.bind(this));
  33842. },
  33843. getPage: function Catalog_getPage(pageIndex) {
  33844. if (!(pageIndex in this.pagePromises)) {
  33845. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  33846. var dict = a[0];
  33847. var ref = a[1];
  33848. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  33849. }.bind(this));
  33850. }
  33851. return this.pagePromises[pageIndex];
  33852. },
  33853. getPageDict: function Catalog_getPageDict(pageIndex) {
  33854. var capability = createPromiseCapability();
  33855. var nodesToVisit = [this.catDict.getRaw('Pages')];
  33856. var currentPageIndex = 0;
  33857. var xref = this.xref;
  33858. function next() {
  33859. while (nodesToVisit.length) {
  33860. var currentNode = nodesToVisit.pop();
  33861. if (isRef(currentNode)) {
  33862. xref.fetchAsync(currentNode).then(function (obj) {
  33863. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  33864. if (pageIndex === currentPageIndex) {
  33865. capability.resolve([
  33866. obj,
  33867. currentNode
  33868. ]);
  33869. } else {
  33870. currentPageIndex++;
  33871. next();
  33872. }
  33873. return;
  33874. }
  33875. nodesToVisit.push(obj);
  33876. next();
  33877. }, capability.reject);
  33878. return;
  33879. }
  33880. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  33881. var count = currentNode.get('Count');
  33882. if (currentPageIndex + count <= pageIndex) {
  33883. currentPageIndex += count;
  33884. continue;
  33885. }
  33886. var kids = currentNode.get('Kids');
  33887. assert(isArray(kids), 'page dictionary kids object is not an array');
  33888. for (var last = kids.length - 1; last >= 0; last--) {
  33889. nodesToVisit.push(kids[last]);
  33890. }
  33891. }
  33892. capability.reject('Page index ' + pageIndex + ' not found.');
  33893. }
  33894. next();
  33895. return capability.promise;
  33896. },
  33897. getPageIndex: function Catalog_getPageIndex(pageRef) {
  33898. var xref = this.xref;
  33899. function pagesBeforeRef(kidRef) {
  33900. var total = 0;
  33901. var parentRef;
  33902. return xref.fetchAsync(kidRef).then(function (node) {
  33903. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  33904. throw new Error('The reference does not point to a /Page Dict.');
  33905. }
  33906. if (!node) {
  33907. return null;
  33908. }
  33909. assert(isDict(node), 'node must be a Dict.');
  33910. parentRef = node.getRaw('Parent');
  33911. return node.getAsync('Parent');
  33912. }).then(function (parent) {
  33913. if (!parent) {
  33914. return null;
  33915. }
  33916. assert(isDict(parent), 'parent must be a Dict.');
  33917. return parent.getAsync('Kids');
  33918. }).then(function (kids) {
  33919. if (!kids) {
  33920. return null;
  33921. }
  33922. var kidPromises = [];
  33923. var found = false;
  33924. for (var i = 0; i < kids.length; i++) {
  33925. var kid = kids[i];
  33926. assert(isRef(kid), 'kid must be a Ref.');
  33927. if (kid.num === kidRef.num) {
  33928. found = true;
  33929. break;
  33930. }
  33931. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  33932. if (kid.has('Count')) {
  33933. var count = kid.get('Count');
  33934. total += count;
  33935. } else {
  33936. total++;
  33937. }
  33938. }));
  33939. }
  33940. if (!found) {
  33941. error('kid ref not found in parents kids');
  33942. }
  33943. return Promise.all(kidPromises).then(function () {
  33944. return [
  33945. total,
  33946. parentRef
  33947. ];
  33948. });
  33949. });
  33950. }
  33951. var total = 0;
  33952. function next(ref) {
  33953. return pagesBeforeRef(ref).then(function (args) {
  33954. if (!args) {
  33955. return total;
  33956. }
  33957. var count = args[0];
  33958. var parentRef = args[1];
  33959. total += count;
  33960. return next(parentRef);
  33961. });
  33962. }
  33963. return next(pageRef);
  33964. }
  33965. };
  33966. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  33967. function addDefaultProtocolToUrl(url) {
  33968. if (url.indexOf('www.') === 0) {
  33969. return 'http://' + url;
  33970. }
  33971. return url;
  33972. }
  33973. function tryConvertUrlEncoding(url) {
  33974. try {
  33975. return stringToUTF8String(url);
  33976. } catch (e) {
  33977. return url;
  33978. }
  33979. }
  33980. var destDict = params.destDict;
  33981. if (!isDict(destDict)) {
  33982. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  33983. return;
  33984. }
  33985. var resultObj = params.resultObj;
  33986. if (typeof resultObj !== 'object') {
  33987. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  33988. return;
  33989. }
  33990. var docBaseUrl = params.docBaseUrl || null;
  33991. var action = destDict.get('A'), url, dest;
  33992. if (isDict(action)) {
  33993. var linkType = action.get('S').name;
  33994. switch (linkType) {
  33995. case 'URI':
  33996. url = action.get('URI');
  33997. if (isName(url)) {
  33998. url = '/' + url.name;
  33999. } else if (isString(url)) {
  34000. url = addDefaultProtocolToUrl(url);
  34001. }
  34002. break;
  34003. case 'GoTo':
  34004. dest = action.get('D');
  34005. break;
  34006. case 'Launch':
  34007. case 'GoToR':
  34008. var urlDict = action.get('F');
  34009. if (isDict(urlDict)) {
  34010. url = urlDict.get('F') || null;
  34011. } else if (isString(urlDict)) {
  34012. url = urlDict;
  34013. }
  34014. var remoteDest = action.get('D');
  34015. if (remoteDest) {
  34016. if (isName(remoteDest)) {
  34017. remoteDest = remoteDest.name;
  34018. }
  34019. if (isString(url)) {
  34020. var baseUrl = url.split('#')[0];
  34021. if (isString(remoteDest)) {
  34022. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34023. } else if (isArray(remoteDest)) {
  34024. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34025. }
  34026. }
  34027. }
  34028. var newWindow = action.get('NewWindow');
  34029. if (isBool(newWindow)) {
  34030. resultObj.newWindow = newWindow;
  34031. }
  34032. break;
  34033. case 'Named':
  34034. var namedAction = action.get('N');
  34035. if (isName(namedAction)) {
  34036. resultObj.action = namedAction.name;
  34037. }
  34038. break;
  34039. case 'JavaScript':
  34040. var jsAction = action.get('JS'), js;
  34041. if (isStream(jsAction)) {
  34042. js = bytesToString(jsAction.getBytes());
  34043. } else if (isString(jsAction)) {
  34044. js = jsAction;
  34045. }
  34046. if (js) {
  34047. var URL_OPEN_METHODS = [
  34048. 'app.launchURL',
  34049. 'window.open'
  34050. ];
  34051. var regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
  34052. var jsUrl = regex.exec(stringToPDFString(js));
  34053. if (jsUrl && jsUrl[2]) {
  34054. url = jsUrl[2];
  34055. if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
  34056. resultObj.newWindow = true;
  34057. }
  34058. break;
  34059. }
  34060. }
  34061. default:
  34062. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34063. break;
  34064. }
  34065. } else if (destDict.has('Dest')) {
  34066. dest = destDict.get('Dest');
  34067. }
  34068. if (isString(url)) {
  34069. url = tryConvertUrlEncoding(url);
  34070. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34071. if (absoluteUrl) {
  34072. resultObj.url = absoluteUrl.href;
  34073. }
  34074. resultObj.unsafeUrl = url;
  34075. }
  34076. if (dest) {
  34077. if (isName(dest)) {
  34078. dest = dest.name;
  34079. }
  34080. if (isString(dest) || isArray(dest)) {
  34081. resultObj.dest = dest;
  34082. }
  34083. }
  34084. };
  34085. return Catalog;
  34086. }();
  34087. var XRef = function XRefClosure() {
  34088. function XRef(stream, pdfManager) {
  34089. this.stream = stream;
  34090. this.pdfManager = pdfManager;
  34091. this.entries = [];
  34092. this.xrefstms = Object.create(null);
  34093. this.cache = [];
  34094. this.stats = {
  34095. streamTypes: [],
  34096. fontTypes: []
  34097. };
  34098. }
  34099. XRef.prototype = {
  34100. setStartXRef: function XRef_setStartXRef(startXRef) {
  34101. this.startXRefQueue = [startXRef];
  34102. },
  34103. parse: function XRef_parse(recoveryMode) {
  34104. var trailerDict;
  34105. if (!recoveryMode) {
  34106. trailerDict = this.readXRef();
  34107. } else {
  34108. warn('Indexing all PDF objects');
  34109. trailerDict = this.indexObjects();
  34110. }
  34111. trailerDict.assignXref(this);
  34112. this.trailer = trailerDict;
  34113. var encrypt = trailerDict.get('Encrypt');
  34114. if (isDict(encrypt)) {
  34115. var ids = trailerDict.get('ID');
  34116. var fileId = ids && ids.length ? ids[0] : '';
  34117. encrypt.suppressEncryption = true;
  34118. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34119. }
  34120. if (!(this.root = trailerDict.get('Root'))) {
  34121. error('Invalid root reference');
  34122. }
  34123. },
  34124. processXRefTable: function XRef_processXRefTable(parser) {
  34125. if (!('tableState' in this)) {
  34126. this.tableState = {
  34127. entryNum: 0,
  34128. streamPos: parser.lexer.stream.pos,
  34129. parserBuf1: parser.buf1,
  34130. parserBuf2: parser.buf2
  34131. };
  34132. }
  34133. var obj = this.readXRefTable(parser);
  34134. if (!isCmd(obj, 'trailer')) {
  34135. error('Invalid XRef table: could not find trailer dictionary');
  34136. }
  34137. var dict = parser.getObj();
  34138. if (!isDict(dict) && dict.dict) {
  34139. dict = dict.dict;
  34140. }
  34141. if (!isDict(dict)) {
  34142. error('Invalid XRef table: could not parse trailer dictionary');
  34143. }
  34144. delete this.tableState;
  34145. return dict;
  34146. },
  34147. readXRefTable: function XRef_readXRefTable(parser) {
  34148. var stream = parser.lexer.stream;
  34149. var tableState = this.tableState;
  34150. stream.pos = tableState.streamPos;
  34151. parser.buf1 = tableState.parserBuf1;
  34152. parser.buf2 = tableState.parserBuf2;
  34153. var obj;
  34154. while (true) {
  34155. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34156. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34157. break;
  34158. }
  34159. tableState.firstEntryNum = obj;
  34160. tableState.entryCount = parser.getObj();
  34161. }
  34162. var first = tableState.firstEntryNum;
  34163. var count = tableState.entryCount;
  34164. if (!isInt(first) || !isInt(count)) {
  34165. error('Invalid XRef table: wrong types in subsection header');
  34166. }
  34167. for (var i = tableState.entryNum; i < count; i++) {
  34168. tableState.streamPos = stream.pos;
  34169. tableState.entryNum = i;
  34170. tableState.parserBuf1 = parser.buf1;
  34171. tableState.parserBuf2 = parser.buf2;
  34172. var entry = {};
  34173. entry.offset = parser.getObj();
  34174. entry.gen = parser.getObj();
  34175. var type = parser.getObj();
  34176. if (isCmd(type, 'f')) {
  34177. entry.free = true;
  34178. } else if (isCmd(type, 'n')) {
  34179. entry.uncompressed = true;
  34180. }
  34181. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34182. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34183. }
  34184. if (i === 0 && entry.free && first === 1) {
  34185. first = 0;
  34186. }
  34187. if (!this.entries[i + first]) {
  34188. this.entries[i + first] = entry;
  34189. }
  34190. }
  34191. tableState.entryNum = 0;
  34192. tableState.streamPos = stream.pos;
  34193. tableState.parserBuf1 = parser.buf1;
  34194. tableState.parserBuf2 = parser.buf2;
  34195. delete tableState.firstEntryNum;
  34196. delete tableState.entryCount;
  34197. }
  34198. if (this.entries[0] && !this.entries[0].free) {
  34199. error('Invalid XRef table: unexpected first object');
  34200. }
  34201. return obj;
  34202. },
  34203. processXRefStream: function XRef_processXRefStream(stream) {
  34204. if (!('streamState' in this)) {
  34205. var streamParameters = stream.dict;
  34206. var byteWidths = streamParameters.get('W');
  34207. var range = streamParameters.get('Index');
  34208. if (!range) {
  34209. range = [
  34210. 0,
  34211. streamParameters.get('Size')
  34212. ];
  34213. }
  34214. this.streamState = {
  34215. entryRanges: range,
  34216. byteWidths: byteWidths,
  34217. entryNum: 0,
  34218. streamPos: stream.pos
  34219. };
  34220. }
  34221. this.readXRefStream(stream);
  34222. delete this.streamState;
  34223. return stream.dict;
  34224. },
  34225. readXRefStream: function XRef_readXRefStream(stream) {
  34226. var i, j;
  34227. var streamState = this.streamState;
  34228. stream.pos = streamState.streamPos;
  34229. var byteWidths = streamState.byteWidths;
  34230. var typeFieldWidth = byteWidths[0];
  34231. var offsetFieldWidth = byteWidths[1];
  34232. var generationFieldWidth = byteWidths[2];
  34233. var entryRanges = streamState.entryRanges;
  34234. while (entryRanges.length > 0) {
  34235. var first = entryRanges[0];
  34236. var n = entryRanges[1];
  34237. if (!isInt(first) || !isInt(n)) {
  34238. error('Invalid XRef range fields: ' + first + ', ' + n);
  34239. }
  34240. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34241. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34242. }
  34243. for (i = streamState.entryNum; i < n; ++i) {
  34244. streamState.entryNum = i;
  34245. streamState.streamPos = stream.pos;
  34246. var type = 0, offset = 0, generation = 0;
  34247. for (j = 0; j < typeFieldWidth; ++j) {
  34248. type = type << 8 | stream.getByte();
  34249. }
  34250. if (typeFieldWidth === 0) {
  34251. type = 1;
  34252. }
  34253. for (j = 0; j < offsetFieldWidth; ++j) {
  34254. offset = offset << 8 | stream.getByte();
  34255. }
  34256. for (j = 0; j < generationFieldWidth; ++j) {
  34257. generation = generation << 8 | stream.getByte();
  34258. }
  34259. var entry = {};
  34260. entry.offset = offset;
  34261. entry.gen = generation;
  34262. switch (type) {
  34263. case 0:
  34264. entry.free = true;
  34265. break;
  34266. case 1:
  34267. entry.uncompressed = true;
  34268. break;
  34269. case 2:
  34270. break;
  34271. default:
  34272. error('Invalid XRef entry type: ' + type);
  34273. }
  34274. if (!this.entries[first + i]) {
  34275. this.entries[first + i] = entry;
  34276. }
  34277. }
  34278. streamState.entryNum = 0;
  34279. streamState.streamPos = stream.pos;
  34280. entryRanges.splice(0, 2);
  34281. }
  34282. },
  34283. indexObjects: function XRef_indexObjects() {
  34284. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34285. var PERCENT = 0x25, LT = 0x3C;
  34286. function readToken(data, offset) {
  34287. var token = '', ch = data[offset];
  34288. while (ch !== LF && ch !== CR && ch !== LT) {
  34289. if (++offset >= data.length) {
  34290. break;
  34291. }
  34292. token += String.fromCharCode(ch);
  34293. ch = data[offset];
  34294. }
  34295. return token;
  34296. }
  34297. function skipUntil(data, offset, what) {
  34298. var length = what.length, dataLength = data.length;
  34299. var skipped = 0;
  34300. while (offset < dataLength) {
  34301. var i = 0;
  34302. while (i < length && data[offset + i] === what[i]) {
  34303. ++i;
  34304. }
  34305. if (i >= length) {
  34306. break;
  34307. }
  34308. offset++;
  34309. skipped++;
  34310. }
  34311. return skipped;
  34312. }
  34313. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  34314. var trailerBytes = new Uint8Array([
  34315. 116,
  34316. 114,
  34317. 97,
  34318. 105,
  34319. 108,
  34320. 101,
  34321. 114
  34322. ]);
  34323. var startxrefBytes = new Uint8Array([
  34324. 115,
  34325. 116,
  34326. 97,
  34327. 114,
  34328. 116,
  34329. 120,
  34330. 114,
  34331. 101,
  34332. 102
  34333. ]);
  34334. var endobjBytes = new Uint8Array([
  34335. 101,
  34336. 110,
  34337. 100,
  34338. 111,
  34339. 98,
  34340. 106
  34341. ]);
  34342. var xrefBytes = new Uint8Array([
  34343. 47,
  34344. 88,
  34345. 82,
  34346. 101,
  34347. 102
  34348. ]);
  34349. this.entries.length = 0;
  34350. var stream = this.stream;
  34351. stream.pos = 0;
  34352. var buffer = stream.getBytes();
  34353. var position = stream.start, length = buffer.length;
  34354. var trailers = [], xrefStms = [];
  34355. while (position < length) {
  34356. var ch = buffer[position];
  34357. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  34358. ++position;
  34359. continue;
  34360. }
  34361. if (ch === PERCENT) {
  34362. do {
  34363. ++position;
  34364. if (position >= length) {
  34365. break;
  34366. }
  34367. ch = buffer[position];
  34368. } while (ch !== LF && ch !== CR);
  34369. continue;
  34370. }
  34371. var token = readToken(buffer, position);
  34372. var m;
  34373. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  34374. position += skipUntil(buffer, position, trailerBytes);
  34375. trailers.push(position);
  34376. position += skipUntil(buffer, position, startxrefBytes);
  34377. } else if (m = objRegExp.exec(token)) {
  34378. if (typeof this.entries[m[1]] === 'undefined') {
  34379. this.entries[m[1]] = {
  34380. offset: position - stream.start,
  34381. gen: m[2] | 0,
  34382. uncompressed: true
  34383. };
  34384. }
  34385. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  34386. var content = buffer.subarray(position, position + contentLength);
  34387. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  34388. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  34389. xrefStms.push(position - stream.start);
  34390. this.xrefstms[position - stream.start] = 1;
  34391. }
  34392. position += contentLength;
  34393. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  34394. trailers.push(position);
  34395. position += skipUntil(buffer, position, startxrefBytes);
  34396. } else {
  34397. position += token.length + 1;
  34398. }
  34399. }
  34400. var i, ii;
  34401. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  34402. this.startXRefQueue.push(xrefStms[i]);
  34403. this.readXRef(true);
  34404. }
  34405. var dict;
  34406. for (i = 0, ii = trailers.length; i < ii; ++i) {
  34407. stream.pos = trailers[i];
  34408. var parser = new Parser(new Lexer(stream), true, this, true);
  34409. var obj = parser.getObj();
  34410. if (!isCmd(obj, 'trailer')) {
  34411. continue;
  34412. }
  34413. dict = parser.getObj();
  34414. if (!isDict(dict)) {
  34415. continue;
  34416. }
  34417. if (dict.has('ID')) {
  34418. return dict;
  34419. }
  34420. }
  34421. if (dict) {
  34422. return dict;
  34423. }
  34424. throw new InvalidPDFException('Invalid PDF structure');
  34425. },
  34426. readXRef: function XRef_readXRef(recoveryMode) {
  34427. var stream = this.stream;
  34428. try {
  34429. while (this.startXRefQueue.length) {
  34430. var startXRef = this.startXRefQueue[0];
  34431. stream.pos = startXRef + stream.start;
  34432. var parser = new Parser(new Lexer(stream), true, this);
  34433. var obj = parser.getObj();
  34434. var dict;
  34435. if (isCmd(obj, 'xref')) {
  34436. dict = this.processXRefTable(parser);
  34437. if (!this.topDict) {
  34438. this.topDict = dict;
  34439. }
  34440. obj = dict.get('XRefStm');
  34441. if (isInt(obj)) {
  34442. var pos = obj;
  34443. if (!(pos in this.xrefstms)) {
  34444. this.xrefstms[pos] = 1;
  34445. this.startXRefQueue.push(pos);
  34446. }
  34447. }
  34448. } else if (isInt(obj)) {
  34449. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  34450. error('Invalid XRef stream');
  34451. }
  34452. dict = this.processXRefStream(obj);
  34453. if (!this.topDict) {
  34454. this.topDict = dict;
  34455. }
  34456. if (!dict) {
  34457. error('Failed to read XRef stream');
  34458. }
  34459. } else {
  34460. error('Invalid XRef stream header');
  34461. }
  34462. obj = dict.get('Prev');
  34463. if (isInt(obj)) {
  34464. this.startXRefQueue.push(obj);
  34465. } else if (isRef(obj)) {
  34466. this.startXRefQueue.push(obj.num);
  34467. }
  34468. this.startXRefQueue.shift();
  34469. }
  34470. return this.topDict;
  34471. } catch (e) {
  34472. if (e instanceof MissingDataException) {
  34473. throw e;
  34474. }
  34475. info('(while reading XRef): ' + e);
  34476. }
  34477. if (recoveryMode) {
  34478. return;
  34479. }
  34480. throw new XRefParseException();
  34481. },
  34482. getEntry: function XRef_getEntry(i) {
  34483. var xrefEntry = this.entries[i];
  34484. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  34485. return xrefEntry;
  34486. }
  34487. return null;
  34488. },
  34489. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  34490. if (!isRef(obj)) {
  34491. return obj;
  34492. }
  34493. return this.fetch(obj, suppressEncryption);
  34494. },
  34495. fetch: function XRef_fetch(ref, suppressEncryption) {
  34496. assert(isRef(ref), 'ref object is not a reference');
  34497. var num = ref.num;
  34498. if (num in this.cache) {
  34499. var cacheEntry = this.cache[num];
  34500. if (isDict(cacheEntry) && !cacheEntry.objId) {
  34501. cacheEntry.objId = ref.toString();
  34502. }
  34503. return cacheEntry;
  34504. }
  34505. var xrefEntry = this.getEntry(num);
  34506. if (xrefEntry === null) {
  34507. return this.cache[num] = null;
  34508. }
  34509. if (xrefEntry.uncompressed) {
  34510. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  34511. } else {
  34512. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  34513. }
  34514. if (isDict(xrefEntry)) {
  34515. xrefEntry.objId = ref.toString();
  34516. } else if (isStream(xrefEntry)) {
  34517. xrefEntry.dict.objId = ref.toString();
  34518. }
  34519. return xrefEntry;
  34520. },
  34521. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  34522. var gen = ref.gen;
  34523. var num = ref.num;
  34524. if (xrefEntry.gen !== gen) {
  34525. error('inconsistent generation in XRef');
  34526. }
  34527. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  34528. var parser = new Parser(new Lexer(stream), true, this);
  34529. var obj1 = parser.getObj();
  34530. var obj2 = parser.getObj();
  34531. var obj3 = parser.getObj();
  34532. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  34533. error('bad XRef entry');
  34534. }
  34535. if (!isCmd(obj3, 'obj')) {
  34536. if (obj3.cmd.indexOf('obj') === 0) {
  34537. num = parseInt(obj3.cmd.substring(3), 10);
  34538. if (!isNaN(num)) {
  34539. return num;
  34540. }
  34541. }
  34542. error('bad XRef entry');
  34543. }
  34544. if (this.encrypt && !suppressEncryption) {
  34545. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  34546. } else {
  34547. xrefEntry = parser.getObj();
  34548. }
  34549. if (!isStream(xrefEntry)) {
  34550. this.cache[num] = xrefEntry;
  34551. }
  34552. return xrefEntry;
  34553. },
  34554. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  34555. var tableOffset = xrefEntry.offset;
  34556. var stream = this.fetch(new Ref(tableOffset, 0));
  34557. if (!isStream(stream)) {
  34558. error('bad ObjStm stream');
  34559. }
  34560. var first = stream.dict.get('First');
  34561. var n = stream.dict.get('N');
  34562. if (!isInt(first) || !isInt(n)) {
  34563. error('invalid first and n parameters for ObjStm stream');
  34564. }
  34565. var parser = new Parser(new Lexer(stream), false, this);
  34566. parser.allowStreams = true;
  34567. var i, entries = [], num, nums = [];
  34568. for (i = 0; i < n; ++i) {
  34569. num = parser.getObj();
  34570. if (!isInt(num)) {
  34571. error('invalid object number in the ObjStm stream: ' + num);
  34572. }
  34573. nums.push(num);
  34574. var offset = parser.getObj();
  34575. if (!isInt(offset)) {
  34576. error('invalid object offset in the ObjStm stream: ' + offset);
  34577. }
  34578. }
  34579. for (i = 0; i < n; ++i) {
  34580. entries.push(parser.getObj());
  34581. if (isCmd(parser.buf1, 'endobj')) {
  34582. parser.shift();
  34583. }
  34584. num = nums[i];
  34585. var entry = this.entries[num];
  34586. if (entry && entry.offset === tableOffset && entry.gen === i) {
  34587. this.cache[num] = entries[i];
  34588. }
  34589. }
  34590. xrefEntry = entries[xrefEntry.gen];
  34591. if (xrefEntry === undefined) {
  34592. error('bad XRef entry for compressed object');
  34593. }
  34594. return xrefEntry;
  34595. },
  34596. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  34597. if (!isRef(obj)) {
  34598. return Promise.resolve(obj);
  34599. }
  34600. return this.fetchAsync(obj, suppressEncryption);
  34601. },
  34602. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  34603. var streamManager = this.stream.manager;
  34604. var xref = this;
  34605. return new Promise(function tryFetch(resolve, reject) {
  34606. try {
  34607. resolve(xref.fetch(ref, suppressEncryption));
  34608. } catch (e) {
  34609. if (e instanceof MissingDataException) {
  34610. streamManager.requestRange(e.begin, e.end).then(function () {
  34611. tryFetch(resolve, reject);
  34612. }, reject);
  34613. return;
  34614. }
  34615. reject(e);
  34616. }
  34617. });
  34618. },
  34619. getCatalogObj: function XRef_getCatalogObj() {
  34620. return this.root;
  34621. }
  34622. };
  34623. return XRef;
  34624. }();
  34625. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  34626. function NameOrNumberTree(root, xref) {
  34627. throw new Error('Cannot initialize NameOrNumberTree.');
  34628. }
  34629. NameOrNumberTree.prototype = {
  34630. getAll: function NameOrNumberTree_getAll() {
  34631. var dict = Object.create(null);
  34632. if (!this.root) {
  34633. return dict;
  34634. }
  34635. var xref = this.xref;
  34636. var processed = new RefSet();
  34637. processed.put(this.root);
  34638. var queue = [this.root];
  34639. while (queue.length > 0) {
  34640. var i, n;
  34641. var obj = xref.fetchIfRef(queue.shift());
  34642. if (!isDict(obj)) {
  34643. continue;
  34644. }
  34645. if (obj.has('Kids')) {
  34646. var kids = obj.get('Kids');
  34647. for (i = 0, n = kids.length; i < n; i++) {
  34648. var kid = kids[i];
  34649. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  34650. queue.push(kid);
  34651. processed.put(kid);
  34652. }
  34653. continue;
  34654. }
  34655. var entries = obj.get(this._type);
  34656. if (isArray(entries)) {
  34657. for (i = 0, n = entries.length; i < n; i += 2) {
  34658. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  34659. }
  34660. }
  34661. }
  34662. return dict;
  34663. },
  34664. get: function NameOrNumberTree_get(key) {
  34665. if (!this.root) {
  34666. return null;
  34667. }
  34668. var xref = this.xref;
  34669. var kidsOrEntries = xref.fetchIfRef(this.root);
  34670. var loopCount = 0;
  34671. var MAX_LEVELS = 10;
  34672. var l, r, m;
  34673. while (kidsOrEntries.has('Kids')) {
  34674. if (++loopCount > MAX_LEVELS) {
  34675. warn('Search depth limit reached for "' + this._type + '" tree.');
  34676. return null;
  34677. }
  34678. var kids = kidsOrEntries.get('Kids');
  34679. if (!isArray(kids)) {
  34680. return null;
  34681. }
  34682. l = 0;
  34683. r = kids.length - 1;
  34684. while (l <= r) {
  34685. m = l + r >> 1;
  34686. var kid = xref.fetchIfRef(kids[m]);
  34687. var limits = kid.get('Limits');
  34688. if (key < xref.fetchIfRef(limits[0])) {
  34689. r = m - 1;
  34690. } else if (key > xref.fetchIfRef(limits[1])) {
  34691. l = m + 1;
  34692. } else {
  34693. kidsOrEntries = xref.fetchIfRef(kids[m]);
  34694. break;
  34695. }
  34696. }
  34697. if (l > r) {
  34698. return null;
  34699. }
  34700. }
  34701. var entries = kidsOrEntries.get(this._type);
  34702. if (isArray(entries)) {
  34703. l = 0;
  34704. r = entries.length - 2;
  34705. while (l <= r) {
  34706. m = l + r & ~1;
  34707. var currentKey = xref.fetchIfRef(entries[m]);
  34708. if (key < currentKey) {
  34709. r = m - 2;
  34710. } else if (key > currentKey) {
  34711. l = m + 2;
  34712. } else {
  34713. return xref.fetchIfRef(entries[m + 1]);
  34714. }
  34715. }
  34716. }
  34717. return null;
  34718. }
  34719. };
  34720. return NameOrNumberTree;
  34721. }();
  34722. var NameTree = function NameTreeClosure() {
  34723. function NameTree(root, xref) {
  34724. this.root = root;
  34725. this.xref = xref;
  34726. this._type = 'Names';
  34727. }
  34728. Util.inherit(NameTree, NameOrNumberTree, {});
  34729. return NameTree;
  34730. }();
  34731. var NumberTree = function NumberTreeClosure() {
  34732. function NumberTree(root, xref) {
  34733. this.root = root;
  34734. this.xref = xref;
  34735. this._type = 'Nums';
  34736. }
  34737. Util.inherit(NumberTree, NameOrNumberTree, {});
  34738. return NumberTree;
  34739. }();
  34740. var FileSpec = function FileSpecClosure() {
  34741. function FileSpec(root, xref) {
  34742. if (!root || !isDict(root)) {
  34743. return;
  34744. }
  34745. this.xref = xref;
  34746. this.root = root;
  34747. if (root.has('FS')) {
  34748. this.fs = root.get('FS');
  34749. }
  34750. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  34751. if (root.has('RF')) {
  34752. warn('Related file specifications are not supported');
  34753. }
  34754. this.contentAvailable = true;
  34755. if (!root.has('EF')) {
  34756. this.contentAvailable = false;
  34757. warn('Non-embedded file specifications are not supported');
  34758. }
  34759. }
  34760. function pickPlatformItem(dict) {
  34761. if (dict.has('UF')) {
  34762. return dict.get('UF');
  34763. } else if (dict.has('F')) {
  34764. return dict.get('F');
  34765. } else if (dict.has('Unix')) {
  34766. return dict.get('Unix');
  34767. } else if (dict.has('Mac')) {
  34768. return dict.get('Mac');
  34769. } else if (dict.has('DOS')) {
  34770. return dict.get('DOS');
  34771. }
  34772. return null;
  34773. }
  34774. FileSpec.prototype = {
  34775. get filename() {
  34776. if (!this._filename && this.root) {
  34777. var filename = pickPlatformItem(this.root) || 'unnamed';
  34778. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  34779. }
  34780. return this._filename;
  34781. },
  34782. get content() {
  34783. if (!this.contentAvailable) {
  34784. return null;
  34785. }
  34786. if (!this.contentRef && this.root) {
  34787. this.contentRef = pickPlatformItem(this.root.get('EF'));
  34788. }
  34789. var content = null;
  34790. if (this.contentRef) {
  34791. var xref = this.xref;
  34792. var fileObj = xref.fetchIfRef(this.contentRef);
  34793. if (fileObj && isStream(fileObj)) {
  34794. content = fileObj.getBytes();
  34795. } else {
  34796. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  34797. }
  34798. } else {
  34799. warn('Embedded file specification does not have a content');
  34800. }
  34801. return content;
  34802. },
  34803. get serializable() {
  34804. return {
  34805. filename: this.filename,
  34806. content: this.content
  34807. };
  34808. }
  34809. };
  34810. return FileSpec;
  34811. }();
  34812. var ObjectLoader = function () {
  34813. function mayHaveChildren(value) {
  34814. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  34815. }
  34816. function addChildren(node, nodesToVisit) {
  34817. var value;
  34818. if (isDict(node) || isStream(node)) {
  34819. var map;
  34820. if (isDict(node)) {
  34821. map = node.map;
  34822. } else {
  34823. map = node.dict.map;
  34824. }
  34825. for (var key in map) {
  34826. value = map[key];
  34827. if (mayHaveChildren(value)) {
  34828. nodesToVisit.push(value);
  34829. }
  34830. }
  34831. } else if (isArray(node)) {
  34832. for (var i = 0, ii = node.length; i < ii; i++) {
  34833. value = node[i];
  34834. if (mayHaveChildren(value)) {
  34835. nodesToVisit.push(value);
  34836. }
  34837. }
  34838. }
  34839. }
  34840. function ObjectLoader(obj, keys, xref) {
  34841. this.obj = obj;
  34842. this.keys = keys;
  34843. this.xref = xref;
  34844. this.refSet = null;
  34845. this.capability = null;
  34846. }
  34847. ObjectLoader.prototype = {
  34848. load: function ObjectLoader_load() {
  34849. var keys = this.keys;
  34850. this.capability = createPromiseCapability();
  34851. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  34852. this.capability.resolve();
  34853. return this.capability.promise;
  34854. }
  34855. this.refSet = new RefSet();
  34856. var nodesToVisit = [];
  34857. for (var i = 0; i < keys.length; i++) {
  34858. nodesToVisit.push(this.obj[keys[i]]);
  34859. }
  34860. this._walk(nodesToVisit);
  34861. return this.capability.promise;
  34862. },
  34863. _walk: function ObjectLoader_walk(nodesToVisit) {
  34864. var nodesToRevisit = [];
  34865. var pendingRequests = [];
  34866. while (nodesToVisit.length) {
  34867. var currentNode = nodesToVisit.pop();
  34868. if (isRef(currentNode)) {
  34869. if (this.refSet.has(currentNode)) {
  34870. continue;
  34871. }
  34872. try {
  34873. var ref = currentNode;
  34874. this.refSet.put(ref);
  34875. currentNode = this.xref.fetch(currentNode);
  34876. } catch (e) {
  34877. if (!(e instanceof MissingDataException)) {
  34878. throw e;
  34879. }
  34880. nodesToRevisit.push(currentNode);
  34881. pendingRequests.push({
  34882. begin: e.begin,
  34883. end: e.end
  34884. });
  34885. }
  34886. }
  34887. if (currentNode && currentNode.getBaseStreams) {
  34888. var baseStreams = currentNode.getBaseStreams();
  34889. var foundMissingData = false;
  34890. for (var i = 0; i < baseStreams.length; i++) {
  34891. var stream = baseStreams[i];
  34892. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  34893. foundMissingData = true;
  34894. pendingRequests.push({
  34895. begin: stream.start,
  34896. end: stream.end
  34897. });
  34898. }
  34899. }
  34900. if (foundMissingData) {
  34901. nodesToRevisit.push(currentNode);
  34902. }
  34903. }
  34904. addChildren(currentNode, nodesToVisit);
  34905. }
  34906. if (pendingRequests.length) {
  34907. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  34908. nodesToVisit = nodesToRevisit;
  34909. for (var i = 0; i < nodesToRevisit.length; i++) {
  34910. var node = nodesToRevisit[i];
  34911. if (isRef(node)) {
  34912. this.refSet.remove(node);
  34913. }
  34914. }
  34915. this._walk(nodesToVisit);
  34916. }.bind(this), this.capability.reject);
  34917. return;
  34918. }
  34919. this.refSet = null;
  34920. this.capability.resolve();
  34921. }
  34922. };
  34923. return ObjectLoader;
  34924. }();
  34925. exports.Catalog = Catalog;
  34926. exports.ObjectLoader = ObjectLoader;
  34927. exports.XRef = XRef;
  34928. exports.FileSpec = FileSpec;
  34929. /***/ }),
  34930. /* 21 */
  34931. /***/ (function(module, exports, __w_pdfjs_require__) {
  34932. "use strict";
  34933. var sharedUtil = __w_pdfjs_require__(0);
  34934. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  34935. var getStdFontMap = getLookupTableFactory(function (t) {
  34936. t['ArialNarrow'] = 'Helvetica';
  34937. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  34938. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  34939. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  34940. t['ArialBlack'] = 'Helvetica';
  34941. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  34942. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  34943. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  34944. t['Arial-Black'] = 'Helvetica';
  34945. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  34946. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  34947. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  34948. t['Arial'] = 'Helvetica';
  34949. t['Arial-Bold'] = 'Helvetica-Bold';
  34950. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  34951. t['Arial-Italic'] = 'Helvetica-Oblique';
  34952. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  34953. t['Arial-BoldMT'] = 'Helvetica-Bold';
  34954. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  34955. t['ArialMT'] = 'Helvetica';
  34956. t['Courier-Bold'] = 'Courier-Bold';
  34957. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  34958. t['Courier-Italic'] = 'Courier-Oblique';
  34959. t['CourierNew'] = 'Courier';
  34960. t['CourierNew-Bold'] = 'Courier-Bold';
  34961. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  34962. t['CourierNew-Italic'] = 'Courier-Oblique';
  34963. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  34964. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  34965. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  34966. t['CourierNewPSMT'] = 'Courier';
  34967. t['Helvetica'] = 'Helvetica';
  34968. t['Helvetica-Bold'] = 'Helvetica-Bold';
  34969. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  34970. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  34971. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  34972. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  34973. t['Symbol-Bold'] = 'Symbol';
  34974. t['Symbol-BoldItalic'] = 'Symbol';
  34975. t['Symbol-Italic'] = 'Symbol';
  34976. t['TimesNewRoman'] = 'Times-Roman';
  34977. t['TimesNewRoman-Bold'] = 'Times-Bold';
  34978. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  34979. t['TimesNewRoman-Italic'] = 'Times-Italic';
  34980. t['TimesNewRomanPS'] = 'Times-Roman';
  34981. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  34982. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  34983. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  34984. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  34985. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  34986. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  34987. t['TimesNewRomanPSMT'] = 'Times-Roman';
  34988. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  34989. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  34990. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  34991. });
  34992. var getNonStdFontMap = getLookupTableFactory(function (t) {
  34993. t['CenturyGothic'] = 'Helvetica';
  34994. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  34995. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  34996. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  34997. t['ComicSansMS'] = 'Comic Sans MS';
  34998. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  34999. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35000. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35001. t['LucidaConsole'] = 'Courier';
  35002. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35003. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35004. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35005. t['MS-Gothic'] = 'MS Gothic';
  35006. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35007. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35008. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35009. t['MS-Mincho'] = 'MS Mincho';
  35010. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35011. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35012. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35013. t['MS-PGothic'] = 'MS PGothic';
  35014. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35015. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35016. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35017. t['MS-PMincho'] = 'MS PMincho';
  35018. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35019. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35020. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35021. t['NuptialScript'] = 'Times-Italic';
  35022. t['Wingdings'] = 'ZapfDingbats';
  35023. });
  35024. var getSerifFonts = getLookupTableFactory(function (t) {
  35025. t['Adobe Jenson'] = true;
  35026. t['Adobe Text'] = true;
  35027. t['Albertus'] = true;
  35028. t['Aldus'] = true;
  35029. t['Alexandria'] = true;
  35030. t['Algerian'] = true;
  35031. t['American Typewriter'] = true;
  35032. t['Antiqua'] = true;
  35033. t['Apex'] = true;
  35034. t['Arno'] = true;
  35035. t['Aster'] = true;
  35036. t['Aurora'] = true;
  35037. t['Baskerville'] = true;
  35038. t['Bell'] = true;
  35039. t['Bembo'] = true;
  35040. t['Bembo Schoolbook'] = true;
  35041. t['Benguiat'] = true;
  35042. t['Berkeley Old Style'] = true;
  35043. t['Bernhard Modern'] = true;
  35044. t['Berthold City'] = true;
  35045. t['Bodoni'] = true;
  35046. t['Bauer Bodoni'] = true;
  35047. t['Book Antiqua'] = true;
  35048. t['Bookman'] = true;
  35049. t['Bordeaux Roman'] = true;
  35050. t['Californian FB'] = true;
  35051. t['Calisto'] = true;
  35052. t['Calvert'] = true;
  35053. t['Capitals'] = true;
  35054. t['Cambria'] = true;
  35055. t['Cartier'] = true;
  35056. t['Caslon'] = true;
  35057. t['Catull'] = true;
  35058. t['Centaur'] = true;
  35059. t['Century Old Style'] = true;
  35060. t['Century Schoolbook'] = true;
  35061. t['Chaparral'] = true;
  35062. t['Charis SIL'] = true;
  35063. t['Cheltenham'] = true;
  35064. t['Cholla Slab'] = true;
  35065. t['Clarendon'] = true;
  35066. t['Clearface'] = true;
  35067. t['Cochin'] = true;
  35068. t['Colonna'] = true;
  35069. t['Computer Modern'] = true;
  35070. t['Concrete Roman'] = true;
  35071. t['Constantia'] = true;
  35072. t['Cooper Black'] = true;
  35073. t['Corona'] = true;
  35074. t['Ecotype'] = true;
  35075. t['Egyptienne'] = true;
  35076. t['Elephant'] = true;
  35077. t['Excelsior'] = true;
  35078. t['Fairfield'] = true;
  35079. t['FF Scala'] = true;
  35080. t['Folkard'] = true;
  35081. t['Footlight'] = true;
  35082. t['FreeSerif'] = true;
  35083. t['Friz Quadrata'] = true;
  35084. t['Garamond'] = true;
  35085. t['Gentium'] = true;
  35086. t['Georgia'] = true;
  35087. t['Gloucester'] = true;
  35088. t['Goudy Old Style'] = true;
  35089. t['Goudy Schoolbook'] = true;
  35090. t['Goudy Pro Font'] = true;
  35091. t['Granjon'] = true;
  35092. t['Guardian Egyptian'] = true;
  35093. t['Heather'] = true;
  35094. t['Hercules'] = true;
  35095. t['High Tower Text'] = true;
  35096. t['Hiroshige'] = true;
  35097. t['Hoefler Text'] = true;
  35098. t['Humana Serif'] = true;
  35099. t['Imprint'] = true;
  35100. t['Ionic No. 5'] = true;
  35101. t['Janson'] = true;
  35102. t['Joanna'] = true;
  35103. t['Korinna'] = true;
  35104. t['Lexicon'] = true;
  35105. t['Liberation Serif'] = true;
  35106. t['Linux Libertine'] = true;
  35107. t['Literaturnaya'] = true;
  35108. t['Lucida'] = true;
  35109. t['Lucida Bright'] = true;
  35110. t['Melior'] = true;
  35111. t['Memphis'] = true;
  35112. t['Miller'] = true;
  35113. t['Minion'] = true;
  35114. t['Modern'] = true;
  35115. t['Mona Lisa'] = true;
  35116. t['Mrs Eaves'] = true;
  35117. t['MS Serif'] = true;
  35118. t['Museo Slab'] = true;
  35119. t['New York'] = true;
  35120. t['Nimbus Roman'] = true;
  35121. t['NPS Rawlinson Roadway'] = true;
  35122. t['NuptialScript'] = true;
  35123. t['Palatino'] = true;
  35124. t['Perpetua'] = true;
  35125. t['Plantin'] = true;
  35126. t['Plantin Schoolbook'] = true;
  35127. t['Playbill'] = true;
  35128. t['Poor Richard'] = true;
  35129. t['Rawlinson Roadway'] = true;
  35130. t['Renault'] = true;
  35131. t['Requiem'] = true;
  35132. t['Rockwell'] = true;
  35133. t['Roman'] = true;
  35134. t['Rotis Serif'] = true;
  35135. t['Sabon'] = true;
  35136. t['Scala'] = true;
  35137. t['Seagull'] = true;
  35138. t['Sistina'] = true;
  35139. t['Souvenir'] = true;
  35140. t['STIX'] = true;
  35141. t['Stone Informal'] = true;
  35142. t['Stone Serif'] = true;
  35143. t['Sylfaen'] = true;
  35144. t['Times'] = true;
  35145. t['Trajan'] = true;
  35146. t['Trinité'] = true;
  35147. t['Trump Mediaeval'] = true;
  35148. t['Utopia'] = true;
  35149. t['Vale Type'] = true;
  35150. t['Bitstream Vera'] = true;
  35151. t['Vera Serif'] = true;
  35152. t['Versailles'] = true;
  35153. t['Wanted'] = true;
  35154. t['Weiss'] = true;
  35155. t['Wide Latin'] = true;
  35156. t['Windsor'] = true;
  35157. t['XITS'] = true;
  35158. });
  35159. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35160. t['Dingbats'] = true;
  35161. t['Symbol'] = true;
  35162. t['ZapfDingbats'] = true;
  35163. });
  35164. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35165. t[2] = 10;
  35166. t[3] = 32;
  35167. t[4] = 33;
  35168. t[5] = 34;
  35169. t[6] = 35;
  35170. t[7] = 36;
  35171. t[8] = 37;
  35172. t[9] = 38;
  35173. t[10] = 39;
  35174. t[11] = 40;
  35175. t[12] = 41;
  35176. t[13] = 42;
  35177. t[14] = 43;
  35178. t[15] = 44;
  35179. t[16] = 45;
  35180. t[17] = 46;
  35181. t[18] = 47;
  35182. t[19] = 48;
  35183. t[20] = 49;
  35184. t[21] = 50;
  35185. t[22] = 51;
  35186. t[23] = 52;
  35187. t[24] = 53;
  35188. t[25] = 54;
  35189. t[26] = 55;
  35190. t[27] = 56;
  35191. t[28] = 57;
  35192. t[29] = 58;
  35193. t[30] = 894;
  35194. t[31] = 60;
  35195. t[32] = 61;
  35196. t[33] = 62;
  35197. t[34] = 63;
  35198. t[35] = 64;
  35199. t[36] = 65;
  35200. t[37] = 66;
  35201. t[38] = 67;
  35202. t[39] = 68;
  35203. t[40] = 69;
  35204. t[41] = 70;
  35205. t[42] = 71;
  35206. t[43] = 72;
  35207. t[44] = 73;
  35208. t[45] = 74;
  35209. t[46] = 75;
  35210. t[47] = 76;
  35211. t[48] = 77;
  35212. t[49] = 78;
  35213. t[50] = 79;
  35214. t[51] = 80;
  35215. t[52] = 81;
  35216. t[53] = 82;
  35217. t[54] = 83;
  35218. t[55] = 84;
  35219. t[56] = 85;
  35220. t[57] = 86;
  35221. t[58] = 87;
  35222. t[59] = 88;
  35223. t[60] = 89;
  35224. t[61] = 90;
  35225. t[62] = 91;
  35226. t[63] = 92;
  35227. t[64] = 93;
  35228. t[65] = 94;
  35229. t[66] = 95;
  35230. t[67] = 96;
  35231. t[68] = 97;
  35232. t[69] = 98;
  35233. t[70] = 99;
  35234. t[71] = 100;
  35235. t[72] = 101;
  35236. t[73] = 102;
  35237. t[74] = 103;
  35238. t[75] = 104;
  35239. t[76] = 105;
  35240. t[77] = 106;
  35241. t[78] = 107;
  35242. t[79] = 108;
  35243. t[80] = 109;
  35244. t[81] = 110;
  35245. t[82] = 111;
  35246. t[83] = 112;
  35247. t[84] = 113;
  35248. t[85] = 114;
  35249. t[86] = 115;
  35250. t[87] = 116;
  35251. t[88] = 117;
  35252. t[89] = 118;
  35253. t[90] = 119;
  35254. t[91] = 120;
  35255. t[92] = 121;
  35256. t[93] = 122;
  35257. t[94] = 123;
  35258. t[95] = 124;
  35259. t[96] = 125;
  35260. t[97] = 126;
  35261. t[98] = 196;
  35262. t[99] = 197;
  35263. t[100] = 199;
  35264. t[101] = 201;
  35265. t[102] = 209;
  35266. t[103] = 214;
  35267. t[104] = 220;
  35268. t[105] = 225;
  35269. t[106] = 224;
  35270. t[107] = 226;
  35271. t[108] = 228;
  35272. t[109] = 227;
  35273. t[110] = 229;
  35274. t[111] = 231;
  35275. t[112] = 233;
  35276. t[113] = 232;
  35277. t[114] = 234;
  35278. t[115] = 235;
  35279. t[116] = 237;
  35280. t[117] = 236;
  35281. t[118] = 238;
  35282. t[119] = 239;
  35283. t[120] = 241;
  35284. t[121] = 243;
  35285. t[122] = 242;
  35286. t[123] = 244;
  35287. t[124] = 246;
  35288. t[125] = 245;
  35289. t[126] = 250;
  35290. t[127] = 249;
  35291. t[128] = 251;
  35292. t[129] = 252;
  35293. t[130] = 8224;
  35294. t[131] = 176;
  35295. t[132] = 162;
  35296. t[133] = 163;
  35297. t[134] = 167;
  35298. t[135] = 8226;
  35299. t[136] = 182;
  35300. t[137] = 223;
  35301. t[138] = 174;
  35302. t[139] = 169;
  35303. t[140] = 8482;
  35304. t[141] = 180;
  35305. t[142] = 168;
  35306. t[143] = 8800;
  35307. t[144] = 198;
  35308. t[145] = 216;
  35309. t[146] = 8734;
  35310. t[147] = 177;
  35311. t[148] = 8804;
  35312. t[149] = 8805;
  35313. t[150] = 165;
  35314. t[151] = 181;
  35315. t[152] = 8706;
  35316. t[153] = 8721;
  35317. t[154] = 8719;
  35318. t[156] = 8747;
  35319. t[157] = 170;
  35320. t[158] = 186;
  35321. t[159] = 8486;
  35322. t[160] = 230;
  35323. t[161] = 248;
  35324. t[162] = 191;
  35325. t[163] = 161;
  35326. t[164] = 172;
  35327. t[165] = 8730;
  35328. t[166] = 402;
  35329. t[167] = 8776;
  35330. t[168] = 8710;
  35331. t[169] = 171;
  35332. t[170] = 187;
  35333. t[171] = 8230;
  35334. t[210] = 218;
  35335. t[223] = 711;
  35336. t[224] = 321;
  35337. t[225] = 322;
  35338. t[227] = 353;
  35339. t[229] = 382;
  35340. t[234] = 253;
  35341. t[252] = 263;
  35342. t[253] = 268;
  35343. t[254] = 269;
  35344. t[258] = 258;
  35345. t[260] = 260;
  35346. t[261] = 261;
  35347. t[265] = 280;
  35348. t[266] = 281;
  35349. t[268] = 283;
  35350. t[269] = 313;
  35351. t[275] = 323;
  35352. t[276] = 324;
  35353. t[278] = 328;
  35354. t[284] = 345;
  35355. t[285] = 346;
  35356. t[286] = 347;
  35357. t[292] = 367;
  35358. t[295] = 377;
  35359. t[296] = 378;
  35360. t[298] = 380;
  35361. t[305] = 963;
  35362. t[306] = 964;
  35363. t[307] = 966;
  35364. t[308] = 8215;
  35365. t[309] = 8252;
  35366. t[310] = 8319;
  35367. t[311] = 8359;
  35368. t[312] = 8592;
  35369. t[313] = 8593;
  35370. t[337] = 9552;
  35371. t[493] = 1039;
  35372. t[494] = 1040;
  35373. t[705] = 1524;
  35374. t[706] = 8362;
  35375. t[710] = 64288;
  35376. t[711] = 64298;
  35377. t[759] = 1617;
  35378. t[761] = 1776;
  35379. t[763] = 1778;
  35380. t[775] = 1652;
  35381. t[777] = 1764;
  35382. t[778] = 1780;
  35383. t[779] = 1781;
  35384. t[780] = 1782;
  35385. t[782] = 771;
  35386. t[783] = 64726;
  35387. t[786] = 8363;
  35388. t[788] = 8532;
  35389. t[790] = 768;
  35390. t[791] = 769;
  35391. t[792] = 768;
  35392. t[795] = 803;
  35393. t[797] = 64336;
  35394. t[798] = 64337;
  35395. t[799] = 64342;
  35396. t[800] = 64343;
  35397. t[801] = 64344;
  35398. t[802] = 64345;
  35399. t[803] = 64362;
  35400. t[804] = 64363;
  35401. t[805] = 64364;
  35402. t[2424] = 7821;
  35403. t[2425] = 7822;
  35404. t[2426] = 7823;
  35405. t[2427] = 7824;
  35406. t[2428] = 7825;
  35407. t[2429] = 7826;
  35408. t[2430] = 7827;
  35409. t[2433] = 7682;
  35410. t[2678] = 8045;
  35411. t[2679] = 8046;
  35412. t[2830] = 1552;
  35413. t[2838] = 686;
  35414. t[2840] = 751;
  35415. t[2842] = 753;
  35416. t[2843] = 754;
  35417. t[2844] = 755;
  35418. t[2846] = 757;
  35419. t[2856] = 767;
  35420. t[2857] = 848;
  35421. t[2858] = 849;
  35422. t[2862] = 853;
  35423. t[2863] = 854;
  35424. t[2864] = 855;
  35425. t[2865] = 861;
  35426. t[2866] = 862;
  35427. t[2906] = 7460;
  35428. t[2908] = 7462;
  35429. t[2909] = 7463;
  35430. t[2910] = 7464;
  35431. t[2912] = 7466;
  35432. t[2913] = 7467;
  35433. t[2914] = 7468;
  35434. t[2916] = 7470;
  35435. t[2917] = 7471;
  35436. t[2918] = 7472;
  35437. t[2920] = 7474;
  35438. t[2921] = 7475;
  35439. t[2922] = 7476;
  35440. t[2924] = 7478;
  35441. t[2925] = 7479;
  35442. t[2926] = 7480;
  35443. t[2928] = 7482;
  35444. t[2929] = 7483;
  35445. t[2930] = 7484;
  35446. t[2932] = 7486;
  35447. t[2933] = 7487;
  35448. t[2934] = 7488;
  35449. t[2936] = 7490;
  35450. t[2937] = 7491;
  35451. t[2938] = 7492;
  35452. t[2940] = 7494;
  35453. t[2941] = 7495;
  35454. t[2942] = 7496;
  35455. t[2944] = 7498;
  35456. t[2946] = 7500;
  35457. t[2948] = 7502;
  35458. t[2950] = 7504;
  35459. t[2951] = 7505;
  35460. t[2952] = 7506;
  35461. t[2954] = 7508;
  35462. t[2955] = 7509;
  35463. t[2956] = 7510;
  35464. t[2958] = 7512;
  35465. t[2959] = 7513;
  35466. t[2960] = 7514;
  35467. t[2962] = 7516;
  35468. t[2963] = 7517;
  35469. t[2964] = 7518;
  35470. t[2966] = 7520;
  35471. t[2967] = 7521;
  35472. t[2968] = 7522;
  35473. t[2970] = 7524;
  35474. t[2971] = 7525;
  35475. t[2972] = 7526;
  35476. t[2974] = 7528;
  35477. t[2975] = 7529;
  35478. t[2976] = 7530;
  35479. t[2978] = 1537;
  35480. t[2979] = 1538;
  35481. t[2980] = 1539;
  35482. t[2982] = 1549;
  35483. t[2983] = 1551;
  35484. t[2984] = 1552;
  35485. t[2986] = 1554;
  35486. t[2987] = 1555;
  35487. t[2988] = 1556;
  35488. t[2990] = 1623;
  35489. t[2991] = 1624;
  35490. t[2995] = 1775;
  35491. t[2999] = 1791;
  35492. t[3002] = 64290;
  35493. t[3003] = 64291;
  35494. t[3004] = 64292;
  35495. t[3006] = 64294;
  35496. t[3007] = 64295;
  35497. t[3008] = 64296;
  35498. t[3011] = 1900;
  35499. t[3014] = 8223;
  35500. t[3015] = 8244;
  35501. t[3017] = 7532;
  35502. t[3018] = 7533;
  35503. t[3019] = 7534;
  35504. t[3075] = 7590;
  35505. t[3076] = 7591;
  35506. t[3079] = 7594;
  35507. t[3080] = 7595;
  35508. t[3083] = 7598;
  35509. t[3084] = 7599;
  35510. t[3087] = 7602;
  35511. t[3088] = 7603;
  35512. t[3091] = 7606;
  35513. t[3092] = 7607;
  35514. t[3095] = 7610;
  35515. t[3096] = 7611;
  35516. t[3099] = 7614;
  35517. t[3100] = 7615;
  35518. t[3103] = 7618;
  35519. t[3104] = 7619;
  35520. t[3107] = 8337;
  35521. t[3108] = 8338;
  35522. t[3116] = 1884;
  35523. t[3119] = 1885;
  35524. t[3120] = 1885;
  35525. t[3123] = 1886;
  35526. t[3124] = 1886;
  35527. t[3127] = 1887;
  35528. t[3128] = 1887;
  35529. t[3131] = 1888;
  35530. t[3132] = 1888;
  35531. t[3135] = 1889;
  35532. t[3136] = 1889;
  35533. t[3139] = 1890;
  35534. t[3140] = 1890;
  35535. t[3143] = 1891;
  35536. t[3144] = 1891;
  35537. t[3147] = 1892;
  35538. t[3148] = 1892;
  35539. t[3153] = 580;
  35540. t[3154] = 581;
  35541. t[3157] = 584;
  35542. t[3158] = 585;
  35543. t[3161] = 588;
  35544. t[3162] = 589;
  35545. t[3165] = 891;
  35546. t[3166] = 892;
  35547. t[3169] = 1274;
  35548. t[3170] = 1275;
  35549. t[3173] = 1278;
  35550. t[3174] = 1279;
  35551. t[3181] = 7622;
  35552. t[3182] = 7623;
  35553. t[3282] = 11799;
  35554. t[3316] = 578;
  35555. t[3379] = 42785;
  35556. t[3393] = 1159;
  35557. t[3416] = 8377;
  35558. });
  35559. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  35560. t[227] = 322;
  35561. t[264] = 261;
  35562. t[291] = 346;
  35563. });
  35564. exports.getStdFontMap = getStdFontMap;
  35565. exports.getNonStdFontMap = getNonStdFontMap;
  35566. exports.getSerifFonts = getSerifFonts;
  35567. exports.getSymbolsFonts = getSymbolsFonts;
  35568. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  35569. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  35570. /***/ }),
  35571. /* 22 */
  35572. /***/ (function(module, exports, __w_pdfjs_require__) {
  35573. "use strict";
  35574. var sharedUtil = __w_pdfjs_require__(0);
  35575. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35576. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  35577. t[63721] = 0x00A9;
  35578. t[63193] = 0x00A9;
  35579. t[63720] = 0x00AE;
  35580. t[63194] = 0x00AE;
  35581. t[63722] = 0x2122;
  35582. t[63195] = 0x2122;
  35583. t[63729] = 0x23A7;
  35584. t[63730] = 0x23A8;
  35585. t[63731] = 0x23A9;
  35586. t[63740] = 0x23AB;
  35587. t[63741] = 0x23AC;
  35588. t[63742] = 0x23AD;
  35589. t[63726] = 0x23A1;
  35590. t[63727] = 0x23A2;
  35591. t[63728] = 0x23A3;
  35592. t[63737] = 0x23A4;
  35593. t[63738] = 0x23A5;
  35594. t[63739] = 0x23A6;
  35595. t[63723] = 0x239B;
  35596. t[63724] = 0x239C;
  35597. t[63725] = 0x239D;
  35598. t[63734] = 0x239E;
  35599. t[63735] = 0x239F;
  35600. t[63736] = 0x23A0;
  35601. });
  35602. function mapSpecialUnicodeValues(code) {
  35603. if (code >= 0xFFF0 && code <= 0xFFFF) {
  35604. return 0;
  35605. } else if (code >= 0xF600 && code <= 0xF8FF) {
  35606. return getSpecialPUASymbols()[code] || code;
  35607. }
  35608. return code;
  35609. }
  35610. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  35611. var unicode = glyphsUnicodeMap[name];
  35612. if (unicode !== undefined) {
  35613. return unicode;
  35614. }
  35615. if (!name) {
  35616. return -1;
  35617. }
  35618. if (name[0] === 'u') {
  35619. var nameLen = name.length, hexStr;
  35620. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  35621. hexStr = name.substr(3);
  35622. } else if (nameLen >= 5 && nameLen <= 7) {
  35623. hexStr = name.substr(1);
  35624. } else {
  35625. return -1;
  35626. }
  35627. if (hexStr === hexStr.toUpperCase()) {
  35628. unicode = parseInt(hexStr, 16);
  35629. if (unicode >= 0) {
  35630. return unicode;
  35631. }
  35632. }
  35633. }
  35634. return -1;
  35635. }
  35636. var UnicodeRanges = [
  35637. {
  35638. 'begin': 0x0000,
  35639. 'end': 0x007F
  35640. },
  35641. {
  35642. 'begin': 0x0080,
  35643. 'end': 0x00FF
  35644. },
  35645. {
  35646. 'begin': 0x0100,
  35647. 'end': 0x017F
  35648. },
  35649. {
  35650. 'begin': 0x0180,
  35651. 'end': 0x024F
  35652. },
  35653. {
  35654. 'begin': 0x0250,
  35655. 'end': 0x02AF
  35656. },
  35657. {
  35658. 'begin': 0x02B0,
  35659. 'end': 0x02FF
  35660. },
  35661. {
  35662. 'begin': 0x0300,
  35663. 'end': 0x036F
  35664. },
  35665. {
  35666. 'begin': 0x0370,
  35667. 'end': 0x03FF
  35668. },
  35669. {
  35670. 'begin': 0x2C80,
  35671. 'end': 0x2CFF
  35672. },
  35673. {
  35674. 'begin': 0x0400,
  35675. 'end': 0x04FF
  35676. },
  35677. {
  35678. 'begin': 0x0530,
  35679. 'end': 0x058F
  35680. },
  35681. {
  35682. 'begin': 0x0590,
  35683. 'end': 0x05FF
  35684. },
  35685. {
  35686. 'begin': 0xA500,
  35687. 'end': 0xA63F
  35688. },
  35689. {
  35690. 'begin': 0x0600,
  35691. 'end': 0x06FF
  35692. },
  35693. {
  35694. 'begin': 0x07C0,
  35695. 'end': 0x07FF
  35696. },
  35697. {
  35698. 'begin': 0x0900,
  35699. 'end': 0x097F
  35700. },
  35701. {
  35702. 'begin': 0x0980,
  35703. 'end': 0x09FF
  35704. },
  35705. {
  35706. 'begin': 0x0A00,
  35707. 'end': 0x0A7F
  35708. },
  35709. {
  35710. 'begin': 0x0A80,
  35711. 'end': 0x0AFF
  35712. },
  35713. {
  35714. 'begin': 0x0B00,
  35715. 'end': 0x0B7F
  35716. },
  35717. {
  35718. 'begin': 0x0B80,
  35719. 'end': 0x0BFF
  35720. },
  35721. {
  35722. 'begin': 0x0C00,
  35723. 'end': 0x0C7F
  35724. },
  35725. {
  35726. 'begin': 0x0C80,
  35727. 'end': 0x0CFF
  35728. },
  35729. {
  35730. 'begin': 0x0D00,
  35731. 'end': 0x0D7F
  35732. },
  35733. {
  35734. 'begin': 0x0E00,
  35735. 'end': 0x0E7F
  35736. },
  35737. {
  35738. 'begin': 0x0E80,
  35739. 'end': 0x0EFF
  35740. },
  35741. {
  35742. 'begin': 0x10A0,
  35743. 'end': 0x10FF
  35744. },
  35745. {
  35746. 'begin': 0x1B00,
  35747. 'end': 0x1B7F
  35748. },
  35749. {
  35750. 'begin': 0x1100,
  35751. 'end': 0x11FF
  35752. },
  35753. {
  35754. 'begin': 0x1E00,
  35755. 'end': 0x1EFF
  35756. },
  35757. {
  35758. 'begin': 0x1F00,
  35759. 'end': 0x1FFF
  35760. },
  35761. {
  35762. 'begin': 0x2000,
  35763. 'end': 0x206F
  35764. },
  35765. {
  35766. 'begin': 0x2070,
  35767. 'end': 0x209F
  35768. },
  35769. {
  35770. 'begin': 0x20A0,
  35771. 'end': 0x20CF
  35772. },
  35773. {
  35774. 'begin': 0x20D0,
  35775. 'end': 0x20FF
  35776. },
  35777. {
  35778. 'begin': 0x2100,
  35779. 'end': 0x214F
  35780. },
  35781. {
  35782. 'begin': 0x2150,
  35783. 'end': 0x218F
  35784. },
  35785. {
  35786. 'begin': 0x2190,
  35787. 'end': 0x21FF
  35788. },
  35789. {
  35790. 'begin': 0x2200,
  35791. 'end': 0x22FF
  35792. },
  35793. {
  35794. 'begin': 0x2300,
  35795. 'end': 0x23FF
  35796. },
  35797. {
  35798. 'begin': 0x2400,
  35799. 'end': 0x243F
  35800. },
  35801. {
  35802. 'begin': 0x2440,
  35803. 'end': 0x245F
  35804. },
  35805. {
  35806. 'begin': 0x2460,
  35807. 'end': 0x24FF
  35808. },
  35809. {
  35810. 'begin': 0x2500,
  35811. 'end': 0x257F
  35812. },
  35813. {
  35814. 'begin': 0x2580,
  35815. 'end': 0x259F
  35816. },
  35817. {
  35818. 'begin': 0x25A0,
  35819. 'end': 0x25FF
  35820. },
  35821. {
  35822. 'begin': 0x2600,
  35823. 'end': 0x26FF
  35824. },
  35825. {
  35826. 'begin': 0x2700,
  35827. 'end': 0x27BF
  35828. },
  35829. {
  35830. 'begin': 0x3000,
  35831. 'end': 0x303F
  35832. },
  35833. {
  35834. 'begin': 0x3040,
  35835. 'end': 0x309F
  35836. },
  35837. {
  35838. 'begin': 0x30A0,
  35839. 'end': 0x30FF
  35840. },
  35841. {
  35842. 'begin': 0x3100,
  35843. 'end': 0x312F
  35844. },
  35845. {
  35846. 'begin': 0x3130,
  35847. 'end': 0x318F
  35848. },
  35849. {
  35850. 'begin': 0xA840,
  35851. 'end': 0xA87F
  35852. },
  35853. {
  35854. 'begin': 0x3200,
  35855. 'end': 0x32FF
  35856. },
  35857. {
  35858. 'begin': 0x3300,
  35859. 'end': 0x33FF
  35860. },
  35861. {
  35862. 'begin': 0xAC00,
  35863. 'end': 0xD7AF
  35864. },
  35865. {
  35866. 'begin': 0xD800,
  35867. 'end': 0xDFFF
  35868. },
  35869. {
  35870. 'begin': 0x10900,
  35871. 'end': 0x1091F
  35872. },
  35873. {
  35874. 'begin': 0x4E00,
  35875. 'end': 0x9FFF
  35876. },
  35877. {
  35878. 'begin': 0xE000,
  35879. 'end': 0xF8FF
  35880. },
  35881. {
  35882. 'begin': 0x31C0,
  35883. 'end': 0x31EF
  35884. },
  35885. {
  35886. 'begin': 0xFB00,
  35887. 'end': 0xFB4F
  35888. },
  35889. {
  35890. 'begin': 0xFB50,
  35891. 'end': 0xFDFF
  35892. },
  35893. {
  35894. 'begin': 0xFE20,
  35895. 'end': 0xFE2F
  35896. },
  35897. {
  35898. 'begin': 0xFE10,
  35899. 'end': 0xFE1F
  35900. },
  35901. {
  35902. 'begin': 0xFE50,
  35903. 'end': 0xFE6F
  35904. },
  35905. {
  35906. 'begin': 0xFE70,
  35907. 'end': 0xFEFF
  35908. },
  35909. {
  35910. 'begin': 0xFF00,
  35911. 'end': 0xFFEF
  35912. },
  35913. {
  35914. 'begin': 0xFFF0,
  35915. 'end': 0xFFFF
  35916. },
  35917. {
  35918. 'begin': 0x0F00,
  35919. 'end': 0x0FFF
  35920. },
  35921. {
  35922. 'begin': 0x0700,
  35923. 'end': 0x074F
  35924. },
  35925. {
  35926. 'begin': 0x0780,
  35927. 'end': 0x07BF
  35928. },
  35929. {
  35930. 'begin': 0x0D80,
  35931. 'end': 0x0DFF
  35932. },
  35933. {
  35934. 'begin': 0x1000,
  35935. 'end': 0x109F
  35936. },
  35937. {
  35938. 'begin': 0x1200,
  35939. 'end': 0x137F
  35940. },
  35941. {
  35942. 'begin': 0x13A0,
  35943. 'end': 0x13FF
  35944. },
  35945. {
  35946. 'begin': 0x1400,
  35947. 'end': 0x167F
  35948. },
  35949. {
  35950. 'begin': 0x1680,
  35951. 'end': 0x169F
  35952. },
  35953. {
  35954. 'begin': 0x16A0,
  35955. 'end': 0x16FF
  35956. },
  35957. {
  35958. 'begin': 0x1780,
  35959. 'end': 0x17FF
  35960. },
  35961. {
  35962. 'begin': 0x1800,
  35963. 'end': 0x18AF
  35964. },
  35965. {
  35966. 'begin': 0x2800,
  35967. 'end': 0x28FF
  35968. },
  35969. {
  35970. 'begin': 0xA000,
  35971. 'end': 0xA48F
  35972. },
  35973. {
  35974. 'begin': 0x1700,
  35975. 'end': 0x171F
  35976. },
  35977. {
  35978. 'begin': 0x10300,
  35979. 'end': 0x1032F
  35980. },
  35981. {
  35982. 'begin': 0x10330,
  35983. 'end': 0x1034F
  35984. },
  35985. {
  35986. 'begin': 0x10400,
  35987. 'end': 0x1044F
  35988. },
  35989. {
  35990. 'begin': 0x1D000,
  35991. 'end': 0x1D0FF
  35992. },
  35993. {
  35994. 'begin': 0x1D400,
  35995. 'end': 0x1D7FF
  35996. },
  35997. {
  35998. 'begin': 0xFF000,
  35999. 'end': 0xFFFFD
  36000. },
  36001. {
  36002. 'begin': 0xFE00,
  36003. 'end': 0xFE0F
  36004. },
  36005. {
  36006. 'begin': 0xE0000,
  36007. 'end': 0xE007F
  36008. },
  36009. {
  36010. 'begin': 0x1900,
  36011. 'end': 0x194F
  36012. },
  36013. {
  36014. 'begin': 0x1950,
  36015. 'end': 0x197F
  36016. },
  36017. {
  36018. 'begin': 0x1980,
  36019. 'end': 0x19DF
  36020. },
  36021. {
  36022. 'begin': 0x1A00,
  36023. 'end': 0x1A1F
  36024. },
  36025. {
  36026. 'begin': 0x2C00,
  36027. 'end': 0x2C5F
  36028. },
  36029. {
  36030. 'begin': 0x2D30,
  36031. 'end': 0x2D7F
  36032. },
  36033. {
  36034. 'begin': 0x4DC0,
  36035. 'end': 0x4DFF
  36036. },
  36037. {
  36038. 'begin': 0xA800,
  36039. 'end': 0xA82F
  36040. },
  36041. {
  36042. 'begin': 0x10000,
  36043. 'end': 0x1007F
  36044. },
  36045. {
  36046. 'begin': 0x10140,
  36047. 'end': 0x1018F
  36048. },
  36049. {
  36050. 'begin': 0x10380,
  36051. 'end': 0x1039F
  36052. },
  36053. {
  36054. 'begin': 0x103A0,
  36055. 'end': 0x103DF
  36056. },
  36057. {
  36058. 'begin': 0x10450,
  36059. 'end': 0x1047F
  36060. },
  36061. {
  36062. 'begin': 0x10480,
  36063. 'end': 0x104AF
  36064. },
  36065. {
  36066. 'begin': 0x10800,
  36067. 'end': 0x1083F
  36068. },
  36069. {
  36070. 'begin': 0x10A00,
  36071. 'end': 0x10A5F
  36072. },
  36073. {
  36074. 'begin': 0x1D300,
  36075. 'end': 0x1D35F
  36076. },
  36077. {
  36078. 'begin': 0x12000,
  36079. 'end': 0x123FF
  36080. },
  36081. {
  36082. 'begin': 0x1D360,
  36083. 'end': 0x1D37F
  36084. },
  36085. {
  36086. 'begin': 0x1B80,
  36087. 'end': 0x1BBF
  36088. },
  36089. {
  36090. 'begin': 0x1C00,
  36091. 'end': 0x1C4F
  36092. },
  36093. {
  36094. 'begin': 0x1C50,
  36095. 'end': 0x1C7F
  36096. },
  36097. {
  36098. 'begin': 0xA880,
  36099. 'end': 0xA8DF
  36100. },
  36101. {
  36102. 'begin': 0xA900,
  36103. 'end': 0xA92F
  36104. },
  36105. {
  36106. 'begin': 0xA930,
  36107. 'end': 0xA95F
  36108. },
  36109. {
  36110. 'begin': 0xAA00,
  36111. 'end': 0xAA5F
  36112. },
  36113. {
  36114. 'begin': 0x10190,
  36115. 'end': 0x101CF
  36116. },
  36117. {
  36118. 'begin': 0x101D0,
  36119. 'end': 0x101FF
  36120. },
  36121. {
  36122. 'begin': 0x102A0,
  36123. 'end': 0x102DF
  36124. },
  36125. {
  36126. 'begin': 0x1F030,
  36127. 'end': 0x1F09F
  36128. }
  36129. ];
  36130. function getUnicodeRangeFor(value) {
  36131. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36132. var range = UnicodeRanges[i];
  36133. if (value >= range.begin && value < range.end) {
  36134. return i;
  36135. }
  36136. }
  36137. return -1;
  36138. }
  36139. function isRTLRangeFor(value) {
  36140. var range = UnicodeRanges[13];
  36141. if (value >= range.begin && value < range.end) {
  36142. return true;
  36143. }
  36144. range = UnicodeRanges[11];
  36145. if (value >= range.begin && value < range.end) {
  36146. return true;
  36147. }
  36148. return false;
  36149. }
  36150. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36151. t['\u00A8'] = '\u0020\u0308';
  36152. t['\u00AF'] = '\u0020\u0304';
  36153. t['\u00B4'] = '\u0020\u0301';
  36154. t['\u00B5'] = '\u03BC';
  36155. t['\u00B8'] = '\u0020\u0327';
  36156. t['\u0132'] = '\u0049\u004A';
  36157. t['\u0133'] = '\u0069\u006A';
  36158. t['\u013F'] = '\u004C\u00B7';
  36159. t['\u0140'] = '\u006C\u00B7';
  36160. t['\u0149'] = '\u02BC\u006E';
  36161. t['\u017F'] = '\u0073';
  36162. t['\u01C4'] = '\u0044\u017D';
  36163. t['\u01C5'] = '\u0044\u017E';
  36164. t['\u01C6'] = '\u0064\u017E';
  36165. t['\u01C7'] = '\u004C\u004A';
  36166. t['\u01C8'] = '\u004C\u006A';
  36167. t['\u01C9'] = '\u006C\u006A';
  36168. t['\u01CA'] = '\u004E\u004A';
  36169. t['\u01CB'] = '\u004E\u006A';
  36170. t['\u01CC'] = '\u006E\u006A';
  36171. t['\u01F1'] = '\u0044\u005A';
  36172. t['\u01F2'] = '\u0044\u007A';
  36173. t['\u01F3'] = '\u0064\u007A';
  36174. t['\u02D8'] = '\u0020\u0306';
  36175. t['\u02D9'] = '\u0020\u0307';
  36176. t['\u02DA'] = '\u0020\u030A';
  36177. t['\u02DB'] = '\u0020\u0328';
  36178. t['\u02DC'] = '\u0020\u0303';
  36179. t['\u02DD'] = '\u0020\u030B';
  36180. t['\u037A'] = '\u0020\u0345';
  36181. t['\u0384'] = '\u0020\u0301';
  36182. t['\u03D0'] = '\u03B2';
  36183. t['\u03D1'] = '\u03B8';
  36184. t['\u03D2'] = '\u03A5';
  36185. t['\u03D5'] = '\u03C6';
  36186. t['\u03D6'] = '\u03C0';
  36187. t['\u03F0'] = '\u03BA';
  36188. t['\u03F1'] = '\u03C1';
  36189. t['\u03F2'] = '\u03C2';
  36190. t['\u03F4'] = '\u0398';
  36191. t['\u03F5'] = '\u03B5';
  36192. t['\u03F9'] = '\u03A3';
  36193. t['\u0587'] = '\u0565\u0582';
  36194. t['\u0675'] = '\u0627\u0674';
  36195. t['\u0676'] = '\u0648\u0674';
  36196. t['\u0677'] = '\u06C7\u0674';
  36197. t['\u0678'] = '\u064A\u0674';
  36198. t['\u0E33'] = '\u0E4D\u0E32';
  36199. t['\u0EB3'] = '\u0ECD\u0EB2';
  36200. t['\u0EDC'] = '\u0EAB\u0E99';
  36201. t['\u0EDD'] = '\u0EAB\u0EA1';
  36202. t['\u0F77'] = '\u0FB2\u0F81';
  36203. t['\u0F79'] = '\u0FB3\u0F81';
  36204. t['\u1E9A'] = '\u0061\u02BE';
  36205. t['\u1FBD'] = '\u0020\u0313';
  36206. t['\u1FBF'] = '\u0020\u0313';
  36207. t['\u1FC0'] = '\u0020\u0342';
  36208. t['\u1FFE'] = '\u0020\u0314';
  36209. t['\u2002'] = '\u0020';
  36210. t['\u2003'] = '\u0020';
  36211. t['\u2004'] = '\u0020';
  36212. t['\u2005'] = '\u0020';
  36213. t['\u2006'] = '\u0020';
  36214. t['\u2008'] = '\u0020';
  36215. t['\u2009'] = '\u0020';
  36216. t['\u200A'] = '\u0020';
  36217. t['\u2017'] = '\u0020\u0333';
  36218. t['\u2024'] = '\u002E';
  36219. t['\u2025'] = '\u002E\u002E';
  36220. t['\u2026'] = '\u002E\u002E\u002E';
  36221. t['\u2033'] = '\u2032\u2032';
  36222. t['\u2034'] = '\u2032\u2032\u2032';
  36223. t['\u2036'] = '\u2035\u2035';
  36224. t['\u2037'] = '\u2035\u2035\u2035';
  36225. t['\u203C'] = '\u0021\u0021';
  36226. t['\u203E'] = '\u0020\u0305';
  36227. t['\u2047'] = '\u003F\u003F';
  36228. t['\u2048'] = '\u003F\u0021';
  36229. t['\u2049'] = '\u0021\u003F';
  36230. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36231. t['\u205F'] = '\u0020';
  36232. t['\u20A8'] = '\u0052\u0073';
  36233. t['\u2100'] = '\u0061\u002F\u0063';
  36234. t['\u2101'] = '\u0061\u002F\u0073';
  36235. t['\u2103'] = '\u00B0\u0043';
  36236. t['\u2105'] = '\u0063\u002F\u006F';
  36237. t['\u2106'] = '\u0063\u002F\u0075';
  36238. t['\u2107'] = '\u0190';
  36239. t['\u2109'] = '\u00B0\u0046';
  36240. t['\u2116'] = '\u004E\u006F';
  36241. t['\u2121'] = '\u0054\u0045\u004C';
  36242. t['\u2135'] = '\u05D0';
  36243. t['\u2136'] = '\u05D1';
  36244. t['\u2137'] = '\u05D2';
  36245. t['\u2138'] = '\u05D3';
  36246. t['\u213B'] = '\u0046\u0041\u0058';
  36247. t['\u2160'] = '\u0049';
  36248. t['\u2161'] = '\u0049\u0049';
  36249. t['\u2162'] = '\u0049\u0049\u0049';
  36250. t['\u2163'] = '\u0049\u0056';
  36251. t['\u2164'] = '\u0056';
  36252. t['\u2165'] = '\u0056\u0049';
  36253. t['\u2166'] = '\u0056\u0049\u0049';
  36254. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36255. t['\u2168'] = '\u0049\u0058';
  36256. t['\u2169'] = '\u0058';
  36257. t['\u216A'] = '\u0058\u0049';
  36258. t['\u216B'] = '\u0058\u0049\u0049';
  36259. t['\u216C'] = '\u004C';
  36260. t['\u216D'] = '\u0043';
  36261. t['\u216E'] = '\u0044';
  36262. t['\u216F'] = '\u004D';
  36263. t['\u2170'] = '\u0069';
  36264. t['\u2171'] = '\u0069\u0069';
  36265. t['\u2172'] = '\u0069\u0069\u0069';
  36266. t['\u2173'] = '\u0069\u0076';
  36267. t['\u2174'] = '\u0076';
  36268. t['\u2175'] = '\u0076\u0069';
  36269. t['\u2176'] = '\u0076\u0069\u0069';
  36270. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36271. t['\u2178'] = '\u0069\u0078';
  36272. t['\u2179'] = '\u0078';
  36273. t['\u217A'] = '\u0078\u0069';
  36274. t['\u217B'] = '\u0078\u0069\u0069';
  36275. t['\u217C'] = '\u006C';
  36276. t['\u217D'] = '\u0063';
  36277. t['\u217E'] = '\u0064';
  36278. t['\u217F'] = '\u006D';
  36279. t['\u222C'] = '\u222B\u222B';
  36280. t['\u222D'] = '\u222B\u222B\u222B';
  36281. t['\u222F'] = '\u222E\u222E';
  36282. t['\u2230'] = '\u222E\u222E\u222E';
  36283. t['\u2474'] = '\u0028\u0031\u0029';
  36284. t['\u2475'] = '\u0028\u0032\u0029';
  36285. t['\u2476'] = '\u0028\u0033\u0029';
  36286. t['\u2477'] = '\u0028\u0034\u0029';
  36287. t['\u2478'] = '\u0028\u0035\u0029';
  36288. t['\u2479'] = '\u0028\u0036\u0029';
  36289. t['\u247A'] = '\u0028\u0037\u0029';
  36290. t['\u247B'] = '\u0028\u0038\u0029';
  36291. t['\u247C'] = '\u0028\u0039\u0029';
  36292. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36293. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36294. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36295. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36296. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36297. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36298. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36299. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36300. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36301. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36302. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  36303. t['\u2488'] = '\u0031\u002E';
  36304. t['\u2489'] = '\u0032\u002E';
  36305. t['\u248A'] = '\u0033\u002E';
  36306. t['\u248B'] = '\u0034\u002E';
  36307. t['\u248C'] = '\u0035\u002E';
  36308. t['\u248D'] = '\u0036\u002E';
  36309. t['\u248E'] = '\u0037\u002E';
  36310. t['\u248F'] = '\u0038\u002E';
  36311. t['\u2490'] = '\u0039\u002E';
  36312. t['\u2491'] = '\u0031\u0030\u002E';
  36313. t['\u2492'] = '\u0031\u0031\u002E';
  36314. t['\u2493'] = '\u0031\u0032\u002E';
  36315. t['\u2494'] = '\u0031\u0033\u002E';
  36316. t['\u2495'] = '\u0031\u0034\u002E';
  36317. t['\u2496'] = '\u0031\u0035\u002E';
  36318. t['\u2497'] = '\u0031\u0036\u002E';
  36319. t['\u2498'] = '\u0031\u0037\u002E';
  36320. t['\u2499'] = '\u0031\u0038\u002E';
  36321. t['\u249A'] = '\u0031\u0039\u002E';
  36322. t['\u249B'] = '\u0032\u0030\u002E';
  36323. t['\u249C'] = '\u0028\u0061\u0029';
  36324. t['\u249D'] = '\u0028\u0062\u0029';
  36325. t['\u249E'] = '\u0028\u0063\u0029';
  36326. t['\u249F'] = '\u0028\u0064\u0029';
  36327. t['\u24A0'] = '\u0028\u0065\u0029';
  36328. t['\u24A1'] = '\u0028\u0066\u0029';
  36329. t['\u24A2'] = '\u0028\u0067\u0029';
  36330. t['\u24A3'] = '\u0028\u0068\u0029';
  36331. t['\u24A4'] = '\u0028\u0069\u0029';
  36332. t['\u24A5'] = '\u0028\u006A\u0029';
  36333. t['\u24A6'] = '\u0028\u006B\u0029';
  36334. t['\u24A7'] = '\u0028\u006C\u0029';
  36335. t['\u24A8'] = '\u0028\u006D\u0029';
  36336. t['\u24A9'] = '\u0028\u006E\u0029';
  36337. t['\u24AA'] = '\u0028\u006F\u0029';
  36338. t['\u24AB'] = '\u0028\u0070\u0029';
  36339. t['\u24AC'] = '\u0028\u0071\u0029';
  36340. t['\u24AD'] = '\u0028\u0072\u0029';
  36341. t['\u24AE'] = '\u0028\u0073\u0029';
  36342. t['\u24AF'] = '\u0028\u0074\u0029';
  36343. t['\u24B0'] = '\u0028\u0075\u0029';
  36344. t['\u24B1'] = '\u0028\u0076\u0029';
  36345. t['\u24B2'] = '\u0028\u0077\u0029';
  36346. t['\u24B3'] = '\u0028\u0078\u0029';
  36347. t['\u24B4'] = '\u0028\u0079\u0029';
  36348. t['\u24B5'] = '\u0028\u007A\u0029';
  36349. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  36350. t['\u2A74'] = '\u003A\u003A\u003D';
  36351. t['\u2A75'] = '\u003D\u003D';
  36352. t['\u2A76'] = '\u003D\u003D\u003D';
  36353. t['\u2E9F'] = '\u6BCD';
  36354. t['\u2EF3'] = '\u9F9F';
  36355. t['\u2F00'] = '\u4E00';
  36356. t['\u2F01'] = '\u4E28';
  36357. t['\u2F02'] = '\u4E36';
  36358. t['\u2F03'] = '\u4E3F';
  36359. t['\u2F04'] = '\u4E59';
  36360. t['\u2F05'] = '\u4E85';
  36361. t['\u2F06'] = '\u4E8C';
  36362. t['\u2F07'] = '\u4EA0';
  36363. t['\u2F08'] = '\u4EBA';
  36364. t['\u2F09'] = '\u513F';
  36365. t['\u2F0A'] = '\u5165';
  36366. t['\u2F0B'] = '\u516B';
  36367. t['\u2F0C'] = '\u5182';
  36368. t['\u2F0D'] = '\u5196';
  36369. t['\u2F0E'] = '\u51AB';
  36370. t['\u2F0F'] = '\u51E0';
  36371. t['\u2F10'] = '\u51F5';
  36372. t['\u2F11'] = '\u5200';
  36373. t['\u2F12'] = '\u529B';
  36374. t['\u2F13'] = '\u52F9';
  36375. t['\u2F14'] = '\u5315';
  36376. t['\u2F15'] = '\u531A';
  36377. t['\u2F16'] = '\u5338';
  36378. t['\u2F17'] = '\u5341';
  36379. t['\u2F18'] = '\u535C';
  36380. t['\u2F19'] = '\u5369';
  36381. t['\u2F1A'] = '\u5382';
  36382. t['\u2F1B'] = '\u53B6';
  36383. t['\u2F1C'] = '\u53C8';
  36384. t['\u2F1D'] = '\u53E3';
  36385. t['\u2F1E'] = '\u56D7';
  36386. t['\u2F1F'] = '\u571F';
  36387. t['\u2F20'] = '\u58EB';
  36388. t['\u2F21'] = '\u5902';
  36389. t['\u2F22'] = '\u590A';
  36390. t['\u2F23'] = '\u5915';
  36391. t['\u2F24'] = '\u5927';
  36392. t['\u2F25'] = '\u5973';
  36393. t['\u2F26'] = '\u5B50';
  36394. t['\u2F27'] = '\u5B80';
  36395. t['\u2F28'] = '\u5BF8';
  36396. t['\u2F29'] = '\u5C0F';
  36397. t['\u2F2A'] = '\u5C22';
  36398. t['\u2F2B'] = '\u5C38';
  36399. t['\u2F2C'] = '\u5C6E';
  36400. t['\u2F2D'] = '\u5C71';
  36401. t['\u2F2E'] = '\u5DDB';
  36402. t['\u2F2F'] = '\u5DE5';
  36403. t['\u2F30'] = '\u5DF1';
  36404. t['\u2F31'] = '\u5DFE';
  36405. t['\u2F32'] = '\u5E72';
  36406. t['\u2F33'] = '\u5E7A';
  36407. t['\u2F34'] = '\u5E7F';
  36408. t['\u2F35'] = '\u5EF4';
  36409. t['\u2F36'] = '\u5EFE';
  36410. t['\u2F37'] = '\u5F0B';
  36411. t['\u2F38'] = '\u5F13';
  36412. t['\u2F39'] = '\u5F50';
  36413. t['\u2F3A'] = '\u5F61';
  36414. t['\u2F3B'] = '\u5F73';
  36415. t['\u2F3C'] = '\u5FC3';
  36416. t['\u2F3D'] = '\u6208';
  36417. t['\u2F3E'] = '\u6236';
  36418. t['\u2F3F'] = '\u624B';
  36419. t['\u2F40'] = '\u652F';
  36420. t['\u2F41'] = '\u6534';
  36421. t['\u2F42'] = '\u6587';
  36422. t['\u2F43'] = '\u6597';
  36423. t['\u2F44'] = '\u65A4';
  36424. t['\u2F45'] = '\u65B9';
  36425. t['\u2F46'] = '\u65E0';
  36426. t['\u2F47'] = '\u65E5';
  36427. t['\u2F48'] = '\u66F0';
  36428. t['\u2F49'] = '\u6708';
  36429. t['\u2F4A'] = '\u6728';
  36430. t['\u2F4B'] = '\u6B20';
  36431. t['\u2F4C'] = '\u6B62';
  36432. t['\u2F4D'] = '\u6B79';
  36433. t['\u2F4E'] = '\u6BB3';
  36434. t['\u2F4F'] = '\u6BCB';
  36435. t['\u2F50'] = '\u6BD4';
  36436. t['\u2F51'] = '\u6BDB';
  36437. t['\u2F52'] = '\u6C0F';
  36438. t['\u2F53'] = '\u6C14';
  36439. t['\u2F54'] = '\u6C34';
  36440. t['\u2F55'] = '\u706B';
  36441. t['\u2F56'] = '\u722A';
  36442. t['\u2F57'] = '\u7236';
  36443. t['\u2F58'] = '\u723B';
  36444. t['\u2F59'] = '\u723F';
  36445. t['\u2F5A'] = '\u7247';
  36446. t['\u2F5B'] = '\u7259';
  36447. t['\u2F5C'] = '\u725B';
  36448. t['\u2F5D'] = '\u72AC';
  36449. t['\u2F5E'] = '\u7384';
  36450. t['\u2F5F'] = '\u7389';
  36451. t['\u2F60'] = '\u74DC';
  36452. t['\u2F61'] = '\u74E6';
  36453. t['\u2F62'] = '\u7518';
  36454. t['\u2F63'] = '\u751F';
  36455. t['\u2F64'] = '\u7528';
  36456. t['\u2F65'] = '\u7530';
  36457. t['\u2F66'] = '\u758B';
  36458. t['\u2F67'] = '\u7592';
  36459. t['\u2F68'] = '\u7676';
  36460. t['\u2F69'] = '\u767D';
  36461. t['\u2F6A'] = '\u76AE';
  36462. t['\u2F6B'] = '\u76BF';
  36463. t['\u2F6C'] = '\u76EE';
  36464. t['\u2F6D'] = '\u77DB';
  36465. t['\u2F6E'] = '\u77E2';
  36466. t['\u2F6F'] = '\u77F3';
  36467. t['\u2F70'] = '\u793A';
  36468. t['\u2F71'] = '\u79B8';
  36469. t['\u2F72'] = '\u79BE';
  36470. t['\u2F73'] = '\u7A74';
  36471. t['\u2F74'] = '\u7ACB';
  36472. t['\u2F75'] = '\u7AF9';
  36473. t['\u2F76'] = '\u7C73';
  36474. t['\u2F77'] = '\u7CF8';
  36475. t['\u2F78'] = '\u7F36';
  36476. t['\u2F79'] = '\u7F51';
  36477. t['\u2F7A'] = '\u7F8A';
  36478. t['\u2F7B'] = '\u7FBD';
  36479. t['\u2F7C'] = '\u8001';
  36480. t['\u2F7D'] = '\u800C';
  36481. t['\u2F7E'] = '\u8012';
  36482. t['\u2F7F'] = '\u8033';
  36483. t['\u2F80'] = '\u807F';
  36484. t['\u2F81'] = '\u8089';
  36485. t['\u2F82'] = '\u81E3';
  36486. t['\u2F83'] = '\u81EA';
  36487. t['\u2F84'] = '\u81F3';
  36488. t['\u2F85'] = '\u81FC';
  36489. t['\u2F86'] = '\u820C';
  36490. t['\u2F87'] = '\u821B';
  36491. t['\u2F88'] = '\u821F';
  36492. t['\u2F89'] = '\u826E';
  36493. t['\u2F8A'] = '\u8272';
  36494. t['\u2F8B'] = '\u8278';
  36495. t['\u2F8C'] = '\u864D';
  36496. t['\u2F8D'] = '\u866B';
  36497. t['\u2F8E'] = '\u8840';
  36498. t['\u2F8F'] = '\u884C';
  36499. t['\u2F90'] = '\u8863';
  36500. t['\u2F91'] = '\u897E';
  36501. t['\u2F92'] = '\u898B';
  36502. t['\u2F93'] = '\u89D2';
  36503. t['\u2F94'] = '\u8A00';
  36504. t['\u2F95'] = '\u8C37';
  36505. t['\u2F96'] = '\u8C46';
  36506. t['\u2F97'] = '\u8C55';
  36507. t['\u2F98'] = '\u8C78';
  36508. t['\u2F99'] = '\u8C9D';
  36509. t['\u2F9A'] = '\u8D64';
  36510. t['\u2F9B'] = '\u8D70';
  36511. t['\u2F9C'] = '\u8DB3';
  36512. t['\u2F9D'] = '\u8EAB';
  36513. t['\u2F9E'] = '\u8ECA';
  36514. t['\u2F9F'] = '\u8F9B';
  36515. t['\u2FA0'] = '\u8FB0';
  36516. t['\u2FA1'] = '\u8FB5';
  36517. t['\u2FA2'] = '\u9091';
  36518. t['\u2FA3'] = '\u9149';
  36519. t['\u2FA4'] = '\u91C6';
  36520. t['\u2FA5'] = '\u91CC';
  36521. t['\u2FA6'] = '\u91D1';
  36522. t['\u2FA7'] = '\u9577';
  36523. t['\u2FA8'] = '\u9580';
  36524. t['\u2FA9'] = '\u961C';
  36525. t['\u2FAA'] = '\u96B6';
  36526. t['\u2FAB'] = '\u96B9';
  36527. t['\u2FAC'] = '\u96E8';
  36528. t['\u2FAD'] = '\u9751';
  36529. t['\u2FAE'] = '\u975E';
  36530. t['\u2FAF'] = '\u9762';
  36531. t['\u2FB0'] = '\u9769';
  36532. t['\u2FB1'] = '\u97CB';
  36533. t['\u2FB2'] = '\u97ED';
  36534. t['\u2FB3'] = '\u97F3';
  36535. t['\u2FB4'] = '\u9801';
  36536. t['\u2FB5'] = '\u98A8';
  36537. t['\u2FB6'] = '\u98DB';
  36538. t['\u2FB7'] = '\u98DF';
  36539. t['\u2FB8'] = '\u9996';
  36540. t['\u2FB9'] = '\u9999';
  36541. t['\u2FBA'] = '\u99AC';
  36542. t['\u2FBB'] = '\u9AA8';
  36543. t['\u2FBC'] = '\u9AD8';
  36544. t['\u2FBD'] = '\u9ADF';
  36545. t['\u2FBE'] = '\u9B25';
  36546. t['\u2FBF'] = '\u9B2F';
  36547. t['\u2FC0'] = '\u9B32';
  36548. t['\u2FC1'] = '\u9B3C';
  36549. t['\u2FC2'] = '\u9B5A';
  36550. t['\u2FC3'] = '\u9CE5';
  36551. t['\u2FC4'] = '\u9E75';
  36552. t['\u2FC5'] = '\u9E7F';
  36553. t['\u2FC6'] = '\u9EA5';
  36554. t['\u2FC7'] = '\u9EBB';
  36555. t['\u2FC8'] = '\u9EC3';
  36556. t['\u2FC9'] = '\u9ECD';
  36557. t['\u2FCA'] = '\u9ED1';
  36558. t['\u2FCB'] = '\u9EF9';
  36559. t['\u2FCC'] = '\u9EFD';
  36560. t['\u2FCD'] = '\u9F0E';
  36561. t['\u2FCE'] = '\u9F13';
  36562. t['\u2FCF'] = '\u9F20';
  36563. t['\u2FD0'] = '\u9F3B';
  36564. t['\u2FD1'] = '\u9F4A';
  36565. t['\u2FD2'] = '\u9F52';
  36566. t['\u2FD3'] = '\u9F8D';
  36567. t['\u2FD4'] = '\u9F9C';
  36568. t['\u2FD5'] = '\u9FA0';
  36569. t['\u3036'] = '\u3012';
  36570. t['\u3038'] = '\u5341';
  36571. t['\u3039'] = '\u5344';
  36572. t['\u303A'] = '\u5345';
  36573. t['\u309B'] = '\u0020\u3099';
  36574. t['\u309C'] = '\u0020\u309A';
  36575. t['\u3131'] = '\u1100';
  36576. t['\u3132'] = '\u1101';
  36577. t['\u3133'] = '\u11AA';
  36578. t['\u3134'] = '\u1102';
  36579. t['\u3135'] = '\u11AC';
  36580. t['\u3136'] = '\u11AD';
  36581. t['\u3137'] = '\u1103';
  36582. t['\u3138'] = '\u1104';
  36583. t['\u3139'] = '\u1105';
  36584. t['\u313A'] = '\u11B0';
  36585. t['\u313B'] = '\u11B1';
  36586. t['\u313C'] = '\u11B2';
  36587. t['\u313D'] = '\u11B3';
  36588. t['\u313E'] = '\u11B4';
  36589. t['\u313F'] = '\u11B5';
  36590. t['\u3140'] = '\u111A';
  36591. t['\u3141'] = '\u1106';
  36592. t['\u3142'] = '\u1107';
  36593. t['\u3143'] = '\u1108';
  36594. t['\u3144'] = '\u1121';
  36595. t['\u3145'] = '\u1109';
  36596. t['\u3146'] = '\u110A';
  36597. t['\u3147'] = '\u110B';
  36598. t['\u3148'] = '\u110C';
  36599. t['\u3149'] = '\u110D';
  36600. t['\u314A'] = '\u110E';
  36601. t['\u314B'] = '\u110F';
  36602. t['\u314C'] = '\u1110';
  36603. t['\u314D'] = '\u1111';
  36604. t['\u314E'] = '\u1112';
  36605. t['\u314F'] = '\u1161';
  36606. t['\u3150'] = '\u1162';
  36607. t['\u3151'] = '\u1163';
  36608. t['\u3152'] = '\u1164';
  36609. t['\u3153'] = '\u1165';
  36610. t['\u3154'] = '\u1166';
  36611. t['\u3155'] = '\u1167';
  36612. t['\u3156'] = '\u1168';
  36613. t['\u3157'] = '\u1169';
  36614. t['\u3158'] = '\u116A';
  36615. t['\u3159'] = '\u116B';
  36616. t['\u315A'] = '\u116C';
  36617. t['\u315B'] = '\u116D';
  36618. t['\u315C'] = '\u116E';
  36619. t['\u315D'] = '\u116F';
  36620. t['\u315E'] = '\u1170';
  36621. t['\u315F'] = '\u1171';
  36622. t['\u3160'] = '\u1172';
  36623. t['\u3161'] = '\u1173';
  36624. t['\u3162'] = '\u1174';
  36625. t['\u3163'] = '\u1175';
  36626. t['\u3164'] = '\u1160';
  36627. t['\u3165'] = '\u1114';
  36628. t['\u3166'] = '\u1115';
  36629. t['\u3167'] = '\u11C7';
  36630. t['\u3168'] = '\u11C8';
  36631. t['\u3169'] = '\u11CC';
  36632. t['\u316A'] = '\u11CE';
  36633. t['\u316B'] = '\u11D3';
  36634. t['\u316C'] = '\u11D7';
  36635. t['\u316D'] = '\u11D9';
  36636. t['\u316E'] = '\u111C';
  36637. t['\u316F'] = '\u11DD';
  36638. t['\u3170'] = '\u11DF';
  36639. t['\u3171'] = '\u111D';
  36640. t['\u3172'] = '\u111E';
  36641. t['\u3173'] = '\u1120';
  36642. t['\u3174'] = '\u1122';
  36643. t['\u3175'] = '\u1123';
  36644. t['\u3176'] = '\u1127';
  36645. t['\u3177'] = '\u1129';
  36646. t['\u3178'] = '\u112B';
  36647. t['\u3179'] = '\u112C';
  36648. t['\u317A'] = '\u112D';
  36649. t['\u317B'] = '\u112E';
  36650. t['\u317C'] = '\u112F';
  36651. t['\u317D'] = '\u1132';
  36652. t['\u317E'] = '\u1136';
  36653. t['\u317F'] = '\u1140';
  36654. t['\u3180'] = '\u1147';
  36655. t['\u3181'] = '\u114C';
  36656. t['\u3182'] = '\u11F1';
  36657. t['\u3183'] = '\u11F2';
  36658. t['\u3184'] = '\u1157';
  36659. t['\u3185'] = '\u1158';
  36660. t['\u3186'] = '\u1159';
  36661. t['\u3187'] = '\u1184';
  36662. t['\u3188'] = '\u1185';
  36663. t['\u3189'] = '\u1188';
  36664. t['\u318A'] = '\u1191';
  36665. t['\u318B'] = '\u1192';
  36666. t['\u318C'] = '\u1194';
  36667. t['\u318D'] = '\u119E';
  36668. t['\u318E'] = '\u11A1';
  36669. t['\u3200'] = '\u0028\u1100\u0029';
  36670. t['\u3201'] = '\u0028\u1102\u0029';
  36671. t['\u3202'] = '\u0028\u1103\u0029';
  36672. t['\u3203'] = '\u0028\u1105\u0029';
  36673. t['\u3204'] = '\u0028\u1106\u0029';
  36674. t['\u3205'] = '\u0028\u1107\u0029';
  36675. t['\u3206'] = '\u0028\u1109\u0029';
  36676. t['\u3207'] = '\u0028\u110B\u0029';
  36677. t['\u3208'] = '\u0028\u110C\u0029';
  36678. t['\u3209'] = '\u0028\u110E\u0029';
  36679. t['\u320A'] = '\u0028\u110F\u0029';
  36680. t['\u320B'] = '\u0028\u1110\u0029';
  36681. t['\u320C'] = '\u0028\u1111\u0029';
  36682. t['\u320D'] = '\u0028\u1112\u0029';
  36683. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  36684. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  36685. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  36686. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  36687. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  36688. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  36689. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  36690. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  36691. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  36692. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  36693. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  36694. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  36695. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  36696. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  36697. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  36698. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  36699. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  36700. t['\u3220'] = '\u0028\u4E00\u0029';
  36701. t['\u3221'] = '\u0028\u4E8C\u0029';
  36702. t['\u3222'] = '\u0028\u4E09\u0029';
  36703. t['\u3223'] = '\u0028\u56DB\u0029';
  36704. t['\u3224'] = '\u0028\u4E94\u0029';
  36705. t['\u3225'] = '\u0028\u516D\u0029';
  36706. t['\u3226'] = '\u0028\u4E03\u0029';
  36707. t['\u3227'] = '\u0028\u516B\u0029';
  36708. t['\u3228'] = '\u0028\u4E5D\u0029';
  36709. t['\u3229'] = '\u0028\u5341\u0029';
  36710. t['\u322A'] = '\u0028\u6708\u0029';
  36711. t['\u322B'] = '\u0028\u706B\u0029';
  36712. t['\u322C'] = '\u0028\u6C34\u0029';
  36713. t['\u322D'] = '\u0028\u6728\u0029';
  36714. t['\u322E'] = '\u0028\u91D1\u0029';
  36715. t['\u322F'] = '\u0028\u571F\u0029';
  36716. t['\u3230'] = '\u0028\u65E5\u0029';
  36717. t['\u3231'] = '\u0028\u682A\u0029';
  36718. t['\u3232'] = '\u0028\u6709\u0029';
  36719. t['\u3233'] = '\u0028\u793E\u0029';
  36720. t['\u3234'] = '\u0028\u540D\u0029';
  36721. t['\u3235'] = '\u0028\u7279\u0029';
  36722. t['\u3236'] = '\u0028\u8CA1\u0029';
  36723. t['\u3237'] = '\u0028\u795D\u0029';
  36724. t['\u3238'] = '\u0028\u52B4\u0029';
  36725. t['\u3239'] = '\u0028\u4EE3\u0029';
  36726. t['\u323A'] = '\u0028\u547C\u0029';
  36727. t['\u323B'] = '\u0028\u5B66\u0029';
  36728. t['\u323C'] = '\u0028\u76E3\u0029';
  36729. t['\u323D'] = '\u0028\u4F01\u0029';
  36730. t['\u323E'] = '\u0028\u8CC7\u0029';
  36731. t['\u323F'] = '\u0028\u5354\u0029';
  36732. t['\u3240'] = '\u0028\u796D\u0029';
  36733. t['\u3241'] = '\u0028\u4F11\u0029';
  36734. t['\u3242'] = '\u0028\u81EA\u0029';
  36735. t['\u3243'] = '\u0028\u81F3\u0029';
  36736. t['\u32C0'] = '\u0031\u6708';
  36737. t['\u32C1'] = '\u0032\u6708';
  36738. t['\u32C2'] = '\u0033\u6708';
  36739. t['\u32C3'] = '\u0034\u6708';
  36740. t['\u32C4'] = '\u0035\u6708';
  36741. t['\u32C5'] = '\u0036\u6708';
  36742. t['\u32C6'] = '\u0037\u6708';
  36743. t['\u32C7'] = '\u0038\u6708';
  36744. t['\u32C8'] = '\u0039\u6708';
  36745. t['\u32C9'] = '\u0031\u0030\u6708';
  36746. t['\u32CA'] = '\u0031\u0031\u6708';
  36747. t['\u32CB'] = '\u0031\u0032\u6708';
  36748. t['\u3358'] = '\u0030\u70B9';
  36749. t['\u3359'] = '\u0031\u70B9';
  36750. t['\u335A'] = '\u0032\u70B9';
  36751. t['\u335B'] = '\u0033\u70B9';
  36752. t['\u335C'] = '\u0034\u70B9';
  36753. t['\u335D'] = '\u0035\u70B9';
  36754. t['\u335E'] = '\u0036\u70B9';
  36755. t['\u335F'] = '\u0037\u70B9';
  36756. t['\u3360'] = '\u0038\u70B9';
  36757. t['\u3361'] = '\u0039\u70B9';
  36758. t['\u3362'] = '\u0031\u0030\u70B9';
  36759. t['\u3363'] = '\u0031\u0031\u70B9';
  36760. t['\u3364'] = '\u0031\u0032\u70B9';
  36761. t['\u3365'] = '\u0031\u0033\u70B9';
  36762. t['\u3366'] = '\u0031\u0034\u70B9';
  36763. t['\u3367'] = '\u0031\u0035\u70B9';
  36764. t['\u3368'] = '\u0031\u0036\u70B9';
  36765. t['\u3369'] = '\u0031\u0037\u70B9';
  36766. t['\u336A'] = '\u0031\u0038\u70B9';
  36767. t['\u336B'] = '\u0031\u0039\u70B9';
  36768. t['\u336C'] = '\u0032\u0030\u70B9';
  36769. t['\u336D'] = '\u0032\u0031\u70B9';
  36770. t['\u336E'] = '\u0032\u0032\u70B9';
  36771. t['\u336F'] = '\u0032\u0033\u70B9';
  36772. t['\u3370'] = '\u0032\u0034\u70B9';
  36773. t['\u33E0'] = '\u0031\u65E5';
  36774. t['\u33E1'] = '\u0032\u65E5';
  36775. t['\u33E2'] = '\u0033\u65E5';
  36776. t['\u33E3'] = '\u0034\u65E5';
  36777. t['\u33E4'] = '\u0035\u65E5';
  36778. t['\u33E5'] = '\u0036\u65E5';
  36779. t['\u33E6'] = '\u0037\u65E5';
  36780. t['\u33E7'] = '\u0038\u65E5';
  36781. t['\u33E8'] = '\u0039\u65E5';
  36782. t['\u33E9'] = '\u0031\u0030\u65E5';
  36783. t['\u33EA'] = '\u0031\u0031\u65E5';
  36784. t['\u33EB'] = '\u0031\u0032\u65E5';
  36785. t['\u33EC'] = '\u0031\u0033\u65E5';
  36786. t['\u33ED'] = '\u0031\u0034\u65E5';
  36787. t['\u33EE'] = '\u0031\u0035\u65E5';
  36788. t['\u33EF'] = '\u0031\u0036\u65E5';
  36789. t['\u33F0'] = '\u0031\u0037\u65E5';
  36790. t['\u33F1'] = '\u0031\u0038\u65E5';
  36791. t['\u33F2'] = '\u0031\u0039\u65E5';
  36792. t['\u33F3'] = '\u0032\u0030\u65E5';
  36793. t['\u33F4'] = '\u0032\u0031\u65E5';
  36794. t['\u33F5'] = '\u0032\u0032\u65E5';
  36795. t['\u33F6'] = '\u0032\u0033\u65E5';
  36796. t['\u33F7'] = '\u0032\u0034\u65E5';
  36797. t['\u33F8'] = '\u0032\u0035\u65E5';
  36798. t['\u33F9'] = '\u0032\u0036\u65E5';
  36799. t['\u33FA'] = '\u0032\u0037\u65E5';
  36800. t['\u33FB'] = '\u0032\u0038\u65E5';
  36801. t['\u33FC'] = '\u0032\u0039\u65E5';
  36802. t['\u33FD'] = '\u0033\u0030\u65E5';
  36803. t['\u33FE'] = '\u0033\u0031\u65E5';
  36804. t['\uFB00'] = '\u0066\u0066';
  36805. t['\uFB01'] = '\u0066\u0069';
  36806. t['\uFB02'] = '\u0066\u006C';
  36807. t['\uFB03'] = '\u0066\u0066\u0069';
  36808. t['\uFB04'] = '\u0066\u0066\u006C';
  36809. t['\uFB05'] = '\u017F\u0074';
  36810. t['\uFB06'] = '\u0073\u0074';
  36811. t['\uFB13'] = '\u0574\u0576';
  36812. t['\uFB14'] = '\u0574\u0565';
  36813. t['\uFB15'] = '\u0574\u056B';
  36814. t['\uFB16'] = '\u057E\u0576';
  36815. t['\uFB17'] = '\u0574\u056D';
  36816. t['\uFB4F'] = '\u05D0\u05DC';
  36817. t['\uFB50'] = '\u0671';
  36818. t['\uFB51'] = '\u0671';
  36819. t['\uFB52'] = '\u067B';
  36820. t['\uFB53'] = '\u067B';
  36821. t['\uFB54'] = '\u067B';
  36822. t['\uFB55'] = '\u067B';
  36823. t['\uFB56'] = '\u067E';
  36824. t['\uFB57'] = '\u067E';
  36825. t['\uFB58'] = '\u067E';
  36826. t['\uFB59'] = '\u067E';
  36827. t['\uFB5A'] = '\u0680';
  36828. t['\uFB5B'] = '\u0680';
  36829. t['\uFB5C'] = '\u0680';
  36830. t['\uFB5D'] = '\u0680';
  36831. t['\uFB5E'] = '\u067A';
  36832. t['\uFB5F'] = '\u067A';
  36833. t['\uFB60'] = '\u067A';
  36834. t['\uFB61'] = '\u067A';
  36835. t['\uFB62'] = '\u067F';
  36836. t['\uFB63'] = '\u067F';
  36837. t['\uFB64'] = '\u067F';
  36838. t['\uFB65'] = '\u067F';
  36839. t['\uFB66'] = '\u0679';
  36840. t['\uFB67'] = '\u0679';
  36841. t['\uFB68'] = '\u0679';
  36842. t['\uFB69'] = '\u0679';
  36843. t['\uFB6A'] = '\u06A4';
  36844. t['\uFB6B'] = '\u06A4';
  36845. t['\uFB6C'] = '\u06A4';
  36846. t['\uFB6D'] = '\u06A4';
  36847. t['\uFB6E'] = '\u06A6';
  36848. t['\uFB6F'] = '\u06A6';
  36849. t['\uFB70'] = '\u06A6';
  36850. t['\uFB71'] = '\u06A6';
  36851. t['\uFB72'] = '\u0684';
  36852. t['\uFB73'] = '\u0684';
  36853. t['\uFB74'] = '\u0684';
  36854. t['\uFB75'] = '\u0684';
  36855. t['\uFB76'] = '\u0683';
  36856. t['\uFB77'] = '\u0683';
  36857. t['\uFB78'] = '\u0683';
  36858. t['\uFB79'] = '\u0683';
  36859. t['\uFB7A'] = '\u0686';
  36860. t['\uFB7B'] = '\u0686';
  36861. t['\uFB7C'] = '\u0686';
  36862. t['\uFB7D'] = '\u0686';
  36863. t['\uFB7E'] = '\u0687';
  36864. t['\uFB7F'] = '\u0687';
  36865. t['\uFB80'] = '\u0687';
  36866. t['\uFB81'] = '\u0687';
  36867. t['\uFB82'] = '\u068D';
  36868. t['\uFB83'] = '\u068D';
  36869. t['\uFB84'] = '\u068C';
  36870. t['\uFB85'] = '\u068C';
  36871. t['\uFB86'] = '\u068E';
  36872. t['\uFB87'] = '\u068E';
  36873. t['\uFB88'] = '\u0688';
  36874. t['\uFB89'] = '\u0688';
  36875. t['\uFB8A'] = '\u0698';
  36876. t['\uFB8B'] = '\u0698';
  36877. t['\uFB8C'] = '\u0691';
  36878. t['\uFB8D'] = '\u0691';
  36879. t['\uFB8E'] = '\u06A9';
  36880. t['\uFB8F'] = '\u06A9';
  36881. t['\uFB90'] = '\u06A9';
  36882. t['\uFB91'] = '\u06A9';
  36883. t['\uFB92'] = '\u06AF';
  36884. t['\uFB93'] = '\u06AF';
  36885. t['\uFB94'] = '\u06AF';
  36886. t['\uFB95'] = '\u06AF';
  36887. t['\uFB96'] = '\u06B3';
  36888. t['\uFB97'] = '\u06B3';
  36889. t['\uFB98'] = '\u06B3';
  36890. t['\uFB99'] = '\u06B3';
  36891. t['\uFB9A'] = '\u06B1';
  36892. t['\uFB9B'] = '\u06B1';
  36893. t['\uFB9C'] = '\u06B1';
  36894. t['\uFB9D'] = '\u06B1';
  36895. t['\uFB9E'] = '\u06BA';
  36896. t['\uFB9F'] = '\u06BA';
  36897. t['\uFBA0'] = '\u06BB';
  36898. t['\uFBA1'] = '\u06BB';
  36899. t['\uFBA2'] = '\u06BB';
  36900. t['\uFBA3'] = '\u06BB';
  36901. t['\uFBA4'] = '\u06C0';
  36902. t['\uFBA5'] = '\u06C0';
  36903. t['\uFBA6'] = '\u06C1';
  36904. t['\uFBA7'] = '\u06C1';
  36905. t['\uFBA8'] = '\u06C1';
  36906. t['\uFBA9'] = '\u06C1';
  36907. t['\uFBAA'] = '\u06BE';
  36908. t['\uFBAB'] = '\u06BE';
  36909. t['\uFBAC'] = '\u06BE';
  36910. t['\uFBAD'] = '\u06BE';
  36911. t['\uFBAE'] = '\u06D2';
  36912. t['\uFBAF'] = '\u06D2';
  36913. t['\uFBB0'] = '\u06D3';
  36914. t['\uFBB1'] = '\u06D3';
  36915. t['\uFBD3'] = '\u06AD';
  36916. t['\uFBD4'] = '\u06AD';
  36917. t['\uFBD5'] = '\u06AD';
  36918. t['\uFBD6'] = '\u06AD';
  36919. t['\uFBD7'] = '\u06C7';
  36920. t['\uFBD8'] = '\u06C7';
  36921. t['\uFBD9'] = '\u06C6';
  36922. t['\uFBDA'] = '\u06C6';
  36923. t['\uFBDB'] = '\u06C8';
  36924. t['\uFBDC'] = '\u06C8';
  36925. t['\uFBDD'] = '\u0677';
  36926. t['\uFBDE'] = '\u06CB';
  36927. t['\uFBDF'] = '\u06CB';
  36928. t['\uFBE0'] = '\u06C5';
  36929. t['\uFBE1'] = '\u06C5';
  36930. t['\uFBE2'] = '\u06C9';
  36931. t['\uFBE3'] = '\u06C9';
  36932. t['\uFBE4'] = '\u06D0';
  36933. t['\uFBE5'] = '\u06D0';
  36934. t['\uFBE6'] = '\u06D0';
  36935. t['\uFBE7'] = '\u06D0';
  36936. t['\uFBE8'] = '\u0649';
  36937. t['\uFBE9'] = '\u0649';
  36938. t['\uFBEA'] = '\u0626\u0627';
  36939. t['\uFBEB'] = '\u0626\u0627';
  36940. t['\uFBEC'] = '\u0626\u06D5';
  36941. t['\uFBED'] = '\u0626\u06D5';
  36942. t['\uFBEE'] = '\u0626\u0648';
  36943. t['\uFBEF'] = '\u0626\u0648';
  36944. t['\uFBF0'] = '\u0626\u06C7';
  36945. t['\uFBF1'] = '\u0626\u06C7';
  36946. t['\uFBF2'] = '\u0626\u06C6';
  36947. t['\uFBF3'] = '\u0626\u06C6';
  36948. t['\uFBF4'] = '\u0626\u06C8';
  36949. t['\uFBF5'] = '\u0626\u06C8';
  36950. t['\uFBF6'] = '\u0626\u06D0';
  36951. t['\uFBF7'] = '\u0626\u06D0';
  36952. t['\uFBF8'] = '\u0626\u06D0';
  36953. t['\uFBF9'] = '\u0626\u0649';
  36954. t['\uFBFA'] = '\u0626\u0649';
  36955. t['\uFBFB'] = '\u0626\u0649';
  36956. t['\uFBFC'] = '\u06CC';
  36957. t['\uFBFD'] = '\u06CC';
  36958. t['\uFBFE'] = '\u06CC';
  36959. t['\uFBFF'] = '\u06CC';
  36960. t['\uFC00'] = '\u0626\u062C';
  36961. t['\uFC01'] = '\u0626\u062D';
  36962. t['\uFC02'] = '\u0626\u0645';
  36963. t['\uFC03'] = '\u0626\u0649';
  36964. t['\uFC04'] = '\u0626\u064A';
  36965. t['\uFC05'] = '\u0628\u062C';
  36966. t['\uFC06'] = '\u0628\u062D';
  36967. t['\uFC07'] = '\u0628\u062E';
  36968. t['\uFC08'] = '\u0628\u0645';
  36969. t['\uFC09'] = '\u0628\u0649';
  36970. t['\uFC0A'] = '\u0628\u064A';
  36971. t['\uFC0B'] = '\u062A\u062C';
  36972. t['\uFC0C'] = '\u062A\u062D';
  36973. t['\uFC0D'] = '\u062A\u062E';
  36974. t['\uFC0E'] = '\u062A\u0645';
  36975. t['\uFC0F'] = '\u062A\u0649';
  36976. t['\uFC10'] = '\u062A\u064A';
  36977. t['\uFC11'] = '\u062B\u062C';
  36978. t['\uFC12'] = '\u062B\u0645';
  36979. t['\uFC13'] = '\u062B\u0649';
  36980. t['\uFC14'] = '\u062B\u064A';
  36981. t['\uFC15'] = '\u062C\u062D';
  36982. t['\uFC16'] = '\u062C\u0645';
  36983. t['\uFC17'] = '\u062D\u062C';
  36984. t['\uFC18'] = '\u062D\u0645';
  36985. t['\uFC19'] = '\u062E\u062C';
  36986. t['\uFC1A'] = '\u062E\u062D';
  36987. t['\uFC1B'] = '\u062E\u0645';
  36988. t['\uFC1C'] = '\u0633\u062C';
  36989. t['\uFC1D'] = '\u0633\u062D';
  36990. t['\uFC1E'] = '\u0633\u062E';
  36991. t['\uFC1F'] = '\u0633\u0645';
  36992. t['\uFC20'] = '\u0635\u062D';
  36993. t['\uFC21'] = '\u0635\u0645';
  36994. t['\uFC22'] = '\u0636\u062C';
  36995. t['\uFC23'] = '\u0636\u062D';
  36996. t['\uFC24'] = '\u0636\u062E';
  36997. t['\uFC25'] = '\u0636\u0645';
  36998. t['\uFC26'] = '\u0637\u062D';
  36999. t['\uFC27'] = '\u0637\u0645';
  37000. t['\uFC28'] = '\u0638\u0645';
  37001. t['\uFC29'] = '\u0639\u062C';
  37002. t['\uFC2A'] = '\u0639\u0645';
  37003. t['\uFC2B'] = '\u063A\u062C';
  37004. t['\uFC2C'] = '\u063A\u0645';
  37005. t['\uFC2D'] = '\u0641\u062C';
  37006. t['\uFC2E'] = '\u0641\u062D';
  37007. t['\uFC2F'] = '\u0641\u062E';
  37008. t['\uFC30'] = '\u0641\u0645';
  37009. t['\uFC31'] = '\u0641\u0649';
  37010. t['\uFC32'] = '\u0641\u064A';
  37011. t['\uFC33'] = '\u0642\u062D';
  37012. t['\uFC34'] = '\u0642\u0645';
  37013. t['\uFC35'] = '\u0642\u0649';
  37014. t['\uFC36'] = '\u0642\u064A';
  37015. t['\uFC37'] = '\u0643\u0627';
  37016. t['\uFC38'] = '\u0643\u062C';
  37017. t['\uFC39'] = '\u0643\u062D';
  37018. t['\uFC3A'] = '\u0643\u062E';
  37019. t['\uFC3B'] = '\u0643\u0644';
  37020. t['\uFC3C'] = '\u0643\u0645';
  37021. t['\uFC3D'] = '\u0643\u0649';
  37022. t['\uFC3E'] = '\u0643\u064A';
  37023. t['\uFC3F'] = '\u0644\u062C';
  37024. t['\uFC40'] = '\u0644\u062D';
  37025. t['\uFC41'] = '\u0644\u062E';
  37026. t['\uFC42'] = '\u0644\u0645';
  37027. t['\uFC43'] = '\u0644\u0649';
  37028. t['\uFC44'] = '\u0644\u064A';
  37029. t['\uFC45'] = '\u0645\u062C';
  37030. t['\uFC46'] = '\u0645\u062D';
  37031. t['\uFC47'] = '\u0645\u062E';
  37032. t['\uFC48'] = '\u0645\u0645';
  37033. t['\uFC49'] = '\u0645\u0649';
  37034. t['\uFC4A'] = '\u0645\u064A';
  37035. t['\uFC4B'] = '\u0646\u062C';
  37036. t['\uFC4C'] = '\u0646\u062D';
  37037. t['\uFC4D'] = '\u0646\u062E';
  37038. t['\uFC4E'] = '\u0646\u0645';
  37039. t['\uFC4F'] = '\u0646\u0649';
  37040. t['\uFC50'] = '\u0646\u064A';
  37041. t['\uFC51'] = '\u0647\u062C';
  37042. t['\uFC52'] = '\u0647\u0645';
  37043. t['\uFC53'] = '\u0647\u0649';
  37044. t['\uFC54'] = '\u0647\u064A';
  37045. t['\uFC55'] = '\u064A\u062C';
  37046. t['\uFC56'] = '\u064A\u062D';
  37047. t['\uFC57'] = '\u064A\u062E';
  37048. t['\uFC58'] = '\u064A\u0645';
  37049. t['\uFC59'] = '\u064A\u0649';
  37050. t['\uFC5A'] = '\u064A\u064A';
  37051. t['\uFC5B'] = '\u0630\u0670';
  37052. t['\uFC5C'] = '\u0631\u0670';
  37053. t['\uFC5D'] = '\u0649\u0670';
  37054. t['\uFC5E'] = '\u0020\u064C\u0651';
  37055. t['\uFC5F'] = '\u0020\u064D\u0651';
  37056. t['\uFC60'] = '\u0020\u064E\u0651';
  37057. t['\uFC61'] = '\u0020\u064F\u0651';
  37058. t['\uFC62'] = '\u0020\u0650\u0651';
  37059. t['\uFC63'] = '\u0020\u0651\u0670';
  37060. t['\uFC64'] = '\u0626\u0631';
  37061. t['\uFC65'] = '\u0626\u0632';
  37062. t['\uFC66'] = '\u0626\u0645';
  37063. t['\uFC67'] = '\u0626\u0646';
  37064. t['\uFC68'] = '\u0626\u0649';
  37065. t['\uFC69'] = '\u0626\u064A';
  37066. t['\uFC6A'] = '\u0628\u0631';
  37067. t['\uFC6B'] = '\u0628\u0632';
  37068. t['\uFC6C'] = '\u0628\u0645';
  37069. t['\uFC6D'] = '\u0628\u0646';
  37070. t['\uFC6E'] = '\u0628\u0649';
  37071. t['\uFC6F'] = '\u0628\u064A';
  37072. t['\uFC70'] = '\u062A\u0631';
  37073. t['\uFC71'] = '\u062A\u0632';
  37074. t['\uFC72'] = '\u062A\u0645';
  37075. t['\uFC73'] = '\u062A\u0646';
  37076. t['\uFC74'] = '\u062A\u0649';
  37077. t['\uFC75'] = '\u062A\u064A';
  37078. t['\uFC76'] = '\u062B\u0631';
  37079. t['\uFC77'] = '\u062B\u0632';
  37080. t['\uFC78'] = '\u062B\u0645';
  37081. t['\uFC79'] = '\u062B\u0646';
  37082. t['\uFC7A'] = '\u062B\u0649';
  37083. t['\uFC7B'] = '\u062B\u064A';
  37084. t['\uFC7C'] = '\u0641\u0649';
  37085. t['\uFC7D'] = '\u0641\u064A';
  37086. t['\uFC7E'] = '\u0642\u0649';
  37087. t['\uFC7F'] = '\u0642\u064A';
  37088. t['\uFC80'] = '\u0643\u0627';
  37089. t['\uFC81'] = '\u0643\u0644';
  37090. t['\uFC82'] = '\u0643\u0645';
  37091. t['\uFC83'] = '\u0643\u0649';
  37092. t['\uFC84'] = '\u0643\u064A';
  37093. t['\uFC85'] = '\u0644\u0645';
  37094. t['\uFC86'] = '\u0644\u0649';
  37095. t['\uFC87'] = '\u0644\u064A';
  37096. t['\uFC88'] = '\u0645\u0627';
  37097. t['\uFC89'] = '\u0645\u0645';
  37098. t['\uFC8A'] = '\u0646\u0631';
  37099. t['\uFC8B'] = '\u0646\u0632';
  37100. t['\uFC8C'] = '\u0646\u0645';
  37101. t['\uFC8D'] = '\u0646\u0646';
  37102. t['\uFC8E'] = '\u0646\u0649';
  37103. t['\uFC8F'] = '\u0646\u064A';
  37104. t['\uFC90'] = '\u0649\u0670';
  37105. t['\uFC91'] = '\u064A\u0631';
  37106. t['\uFC92'] = '\u064A\u0632';
  37107. t['\uFC93'] = '\u064A\u0645';
  37108. t['\uFC94'] = '\u064A\u0646';
  37109. t['\uFC95'] = '\u064A\u0649';
  37110. t['\uFC96'] = '\u064A\u064A';
  37111. t['\uFC97'] = '\u0626\u062C';
  37112. t['\uFC98'] = '\u0626\u062D';
  37113. t['\uFC99'] = '\u0626\u062E';
  37114. t['\uFC9A'] = '\u0626\u0645';
  37115. t['\uFC9B'] = '\u0626\u0647';
  37116. t['\uFC9C'] = '\u0628\u062C';
  37117. t['\uFC9D'] = '\u0628\u062D';
  37118. t['\uFC9E'] = '\u0628\u062E';
  37119. t['\uFC9F'] = '\u0628\u0645';
  37120. t['\uFCA0'] = '\u0628\u0647';
  37121. t['\uFCA1'] = '\u062A\u062C';
  37122. t['\uFCA2'] = '\u062A\u062D';
  37123. t['\uFCA3'] = '\u062A\u062E';
  37124. t['\uFCA4'] = '\u062A\u0645';
  37125. t['\uFCA5'] = '\u062A\u0647';
  37126. t['\uFCA6'] = '\u062B\u0645';
  37127. t['\uFCA7'] = '\u062C\u062D';
  37128. t['\uFCA8'] = '\u062C\u0645';
  37129. t['\uFCA9'] = '\u062D\u062C';
  37130. t['\uFCAA'] = '\u062D\u0645';
  37131. t['\uFCAB'] = '\u062E\u062C';
  37132. t['\uFCAC'] = '\u062E\u0645';
  37133. t['\uFCAD'] = '\u0633\u062C';
  37134. t['\uFCAE'] = '\u0633\u062D';
  37135. t['\uFCAF'] = '\u0633\u062E';
  37136. t['\uFCB0'] = '\u0633\u0645';
  37137. t['\uFCB1'] = '\u0635\u062D';
  37138. t['\uFCB2'] = '\u0635\u062E';
  37139. t['\uFCB3'] = '\u0635\u0645';
  37140. t['\uFCB4'] = '\u0636\u062C';
  37141. t['\uFCB5'] = '\u0636\u062D';
  37142. t['\uFCB6'] = '\u0636\u062E';
  37143. t['\uFCB7'] = '\u0636\u0645';
  37144. t['\uFCB8'] = '\u0637\u062D';
  37145. t['\uFCB9'] = '\u0638\u0645';
  37146. t['\uFCBA'] = '\u0639\u062C';
  37147. t['\uFCBB'] = '\u0639\u0645';
  37148. t['\uFCBC'] = '\u063A\u062C';
  37149. t['\uFCBD'] = '\u063A\u0645';
  37150. t['\uFCBE'] = '\u0641\u062C';
  37151. t['\uFCBF'] = '\u0641\u062D';
  37152. t['\uFCC0'] = '\u0641\u062E';
  37153. t['\uFCC1'] = '\u0641\u0645';
  37154. t['\uFCC2'] = '\u0642\u062D';
  37155. t['\uFCC3'] = '\u0642\u0645';
  37156. t['\uFCC4'] = '\u0643\u062C';
  37157. t['\uFCC5'] = '\u0643\u062D';
  37158. t['\uFCC6'] = '\u0643\u062E';
  37159. t['\uFCC7'] = '\u0643\u0644';
  37160. t['\uFCC8'] = '\u0643\u0645';
  37161. t['\uFCC9'] = '\u0644\u062C';
  37162. t['\uFCCA'] = '\u0644\u062D';
  37163. t['\uFCCB'] = '\u0644\u062E';
  37164. t['\uFCCC'] = '\u0644\u0645';
  37165. t['\uFCCD'] = '\u0644\u0647';
  37166. t['\uFCCE'] = '\u0645\u062C';
  37167. t['\uFCCF'] = '\u0645\u062D';
  37168. t['\uFCD0'] = '\u0645\u062E';
  37169. t['\uFCD1'] = '\u0645\u0645';
  37170. t['\uFCD2'] = '\u0646\u062C';
  37171. t['\uFCD3'] = '\u0646\u062D';
  37172. t['\uFCD4'] = '\u0646\u062E';
  37173. t['\uFCD5'] = '\u0646\u0645';
  37174. t['\uFCD6'] = '\u0646\u0647';
  37175. t['\uFCD7'] = '\u0647\u062C';
  37176. t['\uFCD8'] = '\u0647\u0645';
  37177. t['\uFCD9'] = '\u0647\u0670';
  37178. t['\uFCDA'] = '\u064A\u062C';
  37179. t['\uFCDB'] = '\u064A\u062D';
  37180. t['\uFCDC'] = '\u064A\u062E';
  37181. t['\uFCDD'] = '\u064A\u0645';
  37182. t['\uFCDE'] = '\u064A\u0647';
  37183. t['\uFCDF'] = '\u0626\u0645';
  37184. t['\uFCE0'] = '\u0626\u0647';
  37185. t['\uFCE1'] = '\u0628\u0645';
  37186. t['\uFCE2'] = '\u0628\u0647';
  37187. t['\uFCE3'] = '\u062A\u0645';
  37188. t['\uFCE4'] = '\u062A\u0647';
  37189. t['\uFCE5'] = '\u062B\u0645';
  37190. t['\uFCE6'] = '\u062B\u0647';
  37191. t['\uFCE7'] = '\u0633\u0645';
  37192. t['\uFCE8'] = '\u0633\u0647';
  37193. t['\uFCE9'] = '\u0634\u0645';
  37194. t['\uFCEA'] = '\u0634\u0647';
  37195. t['\uFCEB'] = '\u0643\u0644';
  37196. t['\uFCEC'] = '\u0643\u0645';
  37197. t['\uFCED'] = '\u0644\u0645';
  37198. t['\uFCEE'] = '\u0646\u0645';
  37199. t['\uFCEF'] = '\u0646\u0647';
  37200. t['\uFCF0'] = '\u064A\u0645';
  37201. t['\uFCF1'] = '\u064A\u0647';
  37202. t['\uFCF2'] = '\u0640\u064E\u0651';
  37203. t['\uFCF3'] = '\u0640\u064F\u0651';
  37204. t['\uFCF4'] = '\u0640\u0650\u0651';
  37205. t['\uFCF5'] = '\u0637\u0649';
  37206. t['\uFCF6'] = '\u0637\u064A';
  37207. t['\uFCF7'] = '\u0639\u0649';
  37208. t['\uFCF8'] = '\u0639\u064A';
  37209. t['\uFCF9'] = '\u063A\u0649';
  37210. t['\uFCFA'] = '\u063A\u064A';
  37211. t['\uFCFB'] = '\u0633\u0649';
  37212. t['\uFCFC'] = '\u0633\u064A';
  37213. t['\uFCFD'] = '\u0634\u0649';
  37214. t['\uFCFE'] = '\u0634\u064A';
  37215. t['\uFCFF'] = '\u062D\u0649';
  37216. t['\uFD00'] = '\u062D\u064A';
  37217. t['\uFD01'] = '\u062C\u0649';
  37218. t['\uFD02'] = '\u062C\u064A';
  37219. t['\uFD03'] = '\u062E\u0649';
  37220. t['\uFD04'] = '\u062E\u064A';
  37221. t['\uFD05'] = '\u0635\u0649';
  37222. t['\uFD06'] = '\u0635\u064A';
  37223. t['\uFD07'] = '\u0636\u0649';
  37224. t['\uFD08'] = '\u0636\u064A';
  37225. t['\uFD09'] = '\u0634\u062C';
  37226. t['\uFD0A'] = '\u0634\u062D';
  37227. t['\uFD0B'] = '\u0634\u062E';
  37228. t['\uFD0C'] = '\u0634\u0645';
  37229. t['\uFD0D'] = '\u0634\u0631';
  37230. t['\uFD0E'] = '\u0633\u0631';
  37231. t['\uFD0F'] = '\u0635\u0631';
  37232. t['\uFD10'] = '\u0636\u0631';
  37233. t['\uFD11'] = '\u0637\u0649';
  37234. t['\uFD12'] = '\u0637\u064A';
  37235. t['\uFD13'] = '\u0639\u0649';
  37236. t['\uFD14'] = '\u0639\u064A';
  37237. t['\uFD15'] = '\u063A\u0649';
  37238. t['\uFD16'] = '\u063A\u064A';
  37239. t['\uFD17'] = '\u0633\u0649';
  37240. t['\uFD18'] = '\u0633\u064A';
  37241. t['\uFD19'] = '\u0634\u0649';
  37242. t['\uFD1A'] = '\u0634\u064A';
  37243. t['\uFD1B'] = '\u062D\u0649';
  37244. t['\uFD1C'] = '\u062D\u064A';
  37245. t['\uFD1D'] = '\u062C\u0649';
  37246. t['\uFD1E'] = '\u062C\u064A';
  37247. t['\uFD1F'] = '\u062E\u0649';
  37248. t['\uFD20'] = '\u062E\u064A';
  37249. t['\uFD21'] = '\u0635\u0649';
  37250. t['\uFD22'] = '\u0635\u064A';
  37251. t['\uFD23'] = '\u0636\u0649';
  37252. t['\uFD24'] = '\u0636\u064A';
  37253. t['\uFD25'] = '\u0634\u062C';
  37254. t['\uFD26'] = '\u0634\u062D';
  37255. t['\uFD27'] = '\u0634\u062E';
  37256. t['\uFD28'] = '\u0634\u0645';
  37257. t['\uFD29'] = '\u0634\u0631';
  37258. t['\uFD2A'] = '\u0633\u0631';
  37259. t['\uFD2B'] = '\u0635\u0631';
  37260. t['\uFD2C'] = '\u0636\u0631';
  37261. t['\uFD2D'] = '\u0634\u062C';
  37262. t['\uFD2E'] = '\u0634\u062D';
  37263. t['\uFD2F'] = '\u0634\u062E';
  37264. t['\uFD30'] = '\u0634\u0645';
  37265. t['\uFD31'] = '\u0633\u0647';
  37266. t['\uFD32'] = '\u0634\u0647';
  37267. t['\uFD33'] = '\u0637\u0645';
  37268. t['\uFD34'] = '\u0633\u062C';
  37269. t['\uFD35'] = '\u0633\u062D';
  37270. t['\uFD36'] = '\u0633\u062E';
  37271. t['\uFD37'] = '\u0634\u062C';
  37272. t['\uFD38'] = '\u0634\u062D';
  37273. t['\uFD39'] = '\u0634\u062E';
  37274. t['\uFD3A'] = '\u0637\u0645';
  37275. t['\uFD3B'] = '\u0638\u0645';
  37276. t['\uFD3C'] = '\u0627\u064B';
  37277. t['\uFD3D'] = '\u0627\u064B';
  37278. t['\uFD50'] = '\u062A\u062C\u0645';
  37279. t['\uFD51'] = '\u062A\u062D\u062C';
  37280. t['\uFD52'] = '\u062A\u062D\u062C';
  37281. t['\uFD53'] = '\u062A\u062D\u0645';
  37282. t['\uFD54'] = '\u062A\u062E\u0645';
  37283. t['\uFD55'] = '\u062A\u0645\u062C';
  37284. t['\uFD56'] = '\u062A\u0645\u062D';
  37285. t['\uFD57'] = '\u062A\u0645\u062E';
  37286. t['\uFD58'] = '\u062C\u0645\u062D';
  37287. t['\uFD59'] = '\u062C\u0645\u062D';
  37288. t['\uFD5A'] = '\u062D\u0645\u064A';
  37289. t['\uFD5B'] = '\u062D\u0645\u0649';
  37290. t['\uFD5C'] = '\u0633\u062D\u062C';
  37291. t['\uFD5D'] = '\u0633\u062C\u062D';
  37292. t['\uFD5E'] = '\u0633\u062C\u0649';
  37293. t['\uFD5F'] = '\u0633\u0645\u062D';
  37294. t['\uFD60'] = '\u0633\u0645\u062D';
  37295. t['\uFD61'] = '\u0633\u0645\u062C';
  37296. t['\uFD62'] = '\u0633\u0645\u0645';
  37297. t['\uFD63'] = '\u0633\u0645\u0645';
  37298. t['\uFD64'] = '\u0635\u062D\u062D';
  37299. t['\uFD65'] = '\u0635\u062D\u062D';
  37300. t['\uFD66'] = '\u0635\u0645\u0645';
  37301. t['\uFD67'] = '\u0634\u062D\u0645';
  37302. t['\uFD68'] = '\u0634\u062D\u0645';
  37303. t['\uFD69'] = '\u0634\u062C\u064A';
  37304. t['\uFD6A'] = '\u0634\u0645\u062E';
  37305. t['\uFD6B'] = '\u0634\u0645\u062E';
  37306. t['\uFD6C'] = '\u0634\u0645\u0645';
  37307. t['\uFD6D'] = '\u0634\u0645\u0645';
  37308. t['\uFD6E'] = '\u0636\u062D\u0649';
  37309. t['\uFD6F'] = '\u0636\u062E\u0645';
  37310. t['\uFD70'] = '\u0636\u062E\u0645';
  37311. t['\uFD71'] = '\u0637\u0645\u062D';
  37312. t['\uFD72'] = '\u0637\u0645\u062D';
  37313. t['\uFD73'] = '\u0637\u0645\u0645';
  37314. t['\uFD74'] = '\u0637\u0645\u064A';
  37315. t['\uFD75'] = '\u0639\u062C\u0645';
  37316. t['\uFD76'] = '\u0639\u0645\u0645';
  37317. t['\uFD77'] = '\u0639\u0645\u0645';
  37318. t['\uFD78'] = '\u0639\u0645\u0649';
  37319. t['\uFD79'] = '\u063A\u0645\u0645';
  37320. t['\uFD7A'] = '\u063A\u0645\u064A';
  37321. t['\uFD7B'] = '\u063A\u0645\u0649';
  37322. t['\uFD7C'] = '\u0641\u062E\u0645';
  37323. t['\uFD7D'] = '\u0641\u062E\u0645';
  37324. t['\uFD7E'] = '\u0642\u0645\u062D';
  37325. t['\uFD7F'] = '\u0642\u0645\u0645';
  37326. t['\uFD80'] = '\u0644\u062D\u0645';
  37327. t['\uFD81'] = '\u0644\u062D\u064A';
  37328. t['\uFD82'] = '\u0644\u062D\u0649';
  37329. t['\uFD83'] = '\u0644\u062C\u062C';
  37330. t['\uFD84'] = '\u0644\u062C\u062C';
  37331. t['\uFD85'] = '\u0644\u062E\u0645';
  37332. t['\uFD86'] = '\u0644\u062E\u0645';
  37333. t['\uFD87'] = '\u0644\u0645\u062D';
  37334. t['\uFD88'] = '\u0644\u0645\u062D';
  37335. t['\uFD89'] = '\u0645\u062D\u062C';
  37336. t['\uFD8A'] = '\u0645\u062D\u0645';
  37337. t['\uFD8B'] = '\u0645\u062D\u064A';
  37338. t['\uFD8C'] = '\u0645\u062C\u062D';
  37339. t['\uFD8D'] = '\u0645\u062C\u0645';
  37340. t['\uFD8E'] = '\u0645\u062E\u062C';
  37341. t['\uFD8F'] = '\u0645\u062E\u0645';
  37342. t['\uFD92'] = '\u0645\u062C\u062E';
  37343. t['\uFD93'] = '\u0647\u0645\u062C';
  37344. t['\uFD94'] = '\u0647\u0645\u0645';
  37345. t['\uFD95'] = '\u0646\u062D\u0645';
  37346. t['\uFD96'] = '\u0646\u062D\u0649';
  37347. t['\uFD97'] = '\u0646\u062C\u0645';
  37348. t['\uFD98'] = '\u0646\u062C\u0645';
  37349. t['\uFD99'] = '\u0646\u062C\u0649';
  37350. t['\uFD9A'] = '\u0646\u0645\u064A';
  37351. t['\uFD9B'] = '\u0646\u0645\u0649';
  37352. t['\uFD9C'] = '\u064A\u0645\u0645';
  37353. t['\uFD9D'] = '\u064A\u0645\u0645';
  37354. t['\uFD9E'] = '\u0628\u062E\u064A';
  37355. t['\uFD9F'] = '\u062A\u062C\u064A';
  37356. t['\uFDA0'] = '\u062A\u062C\u0649';
  37357. t['\uFDA1'] = '\u062A\u062E\u064A';
  37358. t['\uFDA2'] = '\u062A\u062E\u0649';
  37359. t['\uFDA3'] = '\u062A\u0645\u064A';
  37360. t['\uFDA4'] = '\u062A\u0645\u0649';
  37361. t['\uFDA5'] = '\u062C\u0645\u064A';
  37362. t['\uFDA6'] = '\u062C\u062D\u0649';
  37363. t['\uFDA7'] = '\u062C\u0645\u0649';
  37364. t['\uFDA8'] = '\u0633\u062E\u0649';
  37365. t['\uFDA9'] = '\u0635\u062D\u064A';
  37366. t['\uFDAA'] = '\u0634\u062D\u064A';
  37367. t['\uFDAB'] = '\u0636\u062D\u064A';
  37368. t['\uFDAC'] = '\u0644\u062C\u064A';
  37369. t['\uFDAD'] = '\u0644\u0645\u064A';
  37370. t['\uFDAE'] = '\u064A\u062D\u064A';
  37371. t['\uFDAF'] = '\u064A\u062C\u064A';
  37372. t['\uFDB0'] = '\u064A\u0645\u064A';
  37373. t['\uFDB1'] = '\u0645\u0645\u064A';
  37374. t['\uFDB2'] = '\u0642\u0645\u064A';
  37375. t['\uFDB3'] = '\u0646\u062D\u064A';
  37376. t['\uFDB4'] = '\u0642\u0645\u062D';
  37377. t['\uFDB5'] = '\u0644\u062D\u0645';
  37378. t['\uFDB6'] = '\u0639\u0645\u064A';
  37379. t['\uFDB7'] = '\u0643\u0645\u064A';
  37380. t['\uFDB8'] = '\u0646\u062C\u062D';
  37381. t['\uFDB9'] = '\u0645\u062E\u064A';
  37382. t['\uFDBA'] = '\u0644\u062C\u0645';
  37383. t['\uFDBB'] = '\u0643\u0645\u0645';
  37384. t['\uFDBC'] = '\u0644\u062C\u0645';
  37385. t['\uFDBD'] = '\u0646\u062C\u062D';
  37386. t['\uFDBE'] = '\u062C\u062D\u064A';
  37387. t['\uFDBF'] = '\u062D\u062C\u064A';
  37388. t['\uFDC0'] = '\u0645\u062C\u064A';
  37389. t['\uFDC1'] = '\u0641\u0645\u064A';
  37390. t['\uFDC2'] = '\u0628\u062D\u064A';
  37391. t['\uFDC3'] = '\u0643\u0645\u0645';
  37392. t['\uFDC4'] = '\u0639\u062C\u0645';
  37393. t['\uFDC5'] = '\u0635\u0645\u0645';
  37394. t['\uFDC6'] = '\u0633\u062E\u064A';
  37395. t['\uFDC7'] = '\u0646\u062C\u064A';
  37396. t['\uFE49'] = '\u203E';
  37397. t['\uFE4A'] = '\u203E';
  37398. t['\uFE4B'] = '\u203E';
  37399. t['\uFE4C'] = '\u203E';
  37400. t['\uFE4D'] = '\u005F';
  37401. t['\uFE4E'] = '\u005F';
  37402. t['\uFE4F'] = '\u005F';
  37403. t['\uFE80'] = '\u0621';
  37404. t['\uFE81'] = '\u0622';
  37405. t['\uFE82'] = '\u0622';
  37406. t['\uFE83'] = '\u0623';
  37407. t['\uFE84'] = '\u0623';
  37408. t['\uFE85'] = '\u0624';
  37409. t['\uFE86'] = '\u0624';
  37410. t['\uFE87'] = '\u0625';
  37411. t['\uFE88'] = '\u0625';
  37412. t['\uFE89'] = '\u0626';
  37413. t['\uFE8A'] = '\u0626';
  37414. t['\uFE8B'] = '\u0626';
  37415. t['\uFE8C'] = '\u0626';
  37416. t['\uFE8D'] = '\u0627';
  37417. t['\uFE8E'] = '\u0627';
  37418. t['\uFE8F'] = '\u0628';
  37419. t['\uFE90'] = '\u0628';
  37420. t['\uFE91'] = '\u0628';
  37421. t['\uFE92'] = '\u0628';
  37422. t['\uFE93'] = '\u0629';
  37423. t['\uFE94'] = '\u0629';
  37424. t['\uFE95'] = '\u062A';
  37425. t['\uFE96'] = '\u062A';
  37426. t['\uFE97'] = '\u062A';
  37427. t['\uFE98'] = '\u062A';
  37428. t['\uFE99'] = '\u062B';
  37429. t['\uFE9A'] = '\u062B';
  37430. t['\uFE9B'] = '\u062B';
  37431. t['\uFE9C'] = '\u062B';
  37432. t['\uFE9D'] = '\u062C';
  37433. t['\uFE9E'] = '\u062C';
  37434. t['\uFE9F'] = '\u062C';
  37435. t['\uFEA0'] = '\u062C';
  37436. t['\uFEA1'] = '\u062D';
  37437. t['\uFEA2'] = '\u062D';
  37438. t['\uFEA3'] = '\u062D';
  37439. t['\uFEA4'] = '\u062D';
  37440. t['\uFEA5'] = '\u062E';
  37441. t['\uFEA6'] = '\u062E';
  37442. t['\uFEA7'] = '\u062E';
  37443. t['\uFEA8'] = '\u062E';
  37444. t['\uFEA9'] = '\u062F';
  37445. t['\uFEAA'] = '\u062F';
  37446. t['\uFEAB'] = '\u0630';
  37447. t['\uFEAC'] = '\u0630';
  37448. t['\uFEAD'] = '\u0631';
  37449. t['\uFEAE'] = '\u0631';
  37450. t['\uFEAF'] = '\u0632';
  37451. t['\uFEB0'] = '\u0632';
  37452. t['\uFEB1'] = '\u0633';
  37453. t['\uFEB2'] = '\u0633';
  37454. t['\uFEB3'] = '\u0633';
  37455. t['\uFEB4'] = '\u0633';
  37456. t['\uFEB5'] = '\u0634';
  37457. t['\uFEB6'] = '\u0634';
  37458. t['\uFEB7'] = '\u0634';
  37459. t['\uFEB8'] = '\u0634';
  37460. t['\uFEB9'] = '\u0635';
  37461. t['\uFEBA'] = '\u0635';
  37462. t['\uFEBB'] = '\u0635';
  37463. t['\uFEBC'] = '\u0635';
  37464. t['\uFEBD'] = '\u0636';
  37465. t['\uFEBE'] = '\u0636';
  37466. t['\uFEBF'] = '\u0636';
  37467. t['\uFEC0'] = '\u0636';
  37468. t['\uFEC1'] = '\u0637';
  37469. t['\uFEC2'] = '\u0637';
  37470. t['\uFEC3'] = '\u0637';
  37471. t['\uFEC4'] = '\u0637';
  37472. t['\uFEC5'] = '\u0638';
  37473. t['\uFEC6'] = '\u0638';
  37474. t['\uFEC7'] = '\u0638';
  37475. t['\uFEC8'] = '\u0638';
  37476. t['\uFEC9'] = '\u0639';
  37477. t['\uFECA'] = '\u0639';
  37478. t['\uFECB'] = '\u0639';
  37479. t['\uFECC'] = '\u0639';
  37480. t['\uFECD'] = '\u063A';
  37481. t['\uFECE'] = '\u063A';
  37482. t['\uFECF'] = '\u063A';
  37483. t['\uFED0'] = '\u063A';
  37484. t['\uFED1'] = '\u0641';
  37485. t['\uFED2'] = '\u0641';
  37486. t['\uFED3'] = '\u0641';
  37487. t['\uFED4'] = '\u0641';
  37488. t['\uFED5'] = '\u0642';
  37489. t['\uFED6'] = '\u0642';
  37490. t['\uFED7'] = '\u0642';
  37491. t['\uFED8'] = '\u0642';
  37492. t['\uFED9'] = '\u0643';
  37493. t['\uFEDA'] = '\u0643';
  37494. t['\uFEDB'] = '\u0643';
  37495. t['\uFEDC'] = '\u0643';
  37496. t['\uFEDD'] = '\u0644';
  37497. t['\uFEDE'] = '\u0644';
  37498. t['\uFEDF'] = '\u0644';
  37499. t['\uFEE0'] = '\u0644';
  37500. t['\uFEE1'] = '\u0645';
  37501. t['\uFEE2'] = '\u0645';
  37502. t['\uFEE3'] = '\u0645';
  37503. t['\uFEE4'] = '\u0645';
  37504. t['\uFEE5'] = '\u0646';
  37505. t['\uFEE6'] = '\u0646';
  37506. t['\uFEE7'] = '\u0646';
  37507. t['\uFEE8'] = '\u0646';
  37508. t['\uFEE9'] = '\u0647';
  37509. t['\uFEEA'] = '\u0647';
  37510. t['\uFEEB'] = '\u0647';
  37511. t['\uFEEC'] = '\u0647';
  37512. t['\uFEED'] = '\u0648';
  37513. t['\uFEEE'] = '\u0648';
  37514. t['\uFEEF'] = '\u0649';
  37515. t['\uFEF0'] = '\u0649';
  37516. t['\uFEF1'] = '\u064A';
  37517. t['\uFEF2'] = '\u064A';
  37518. t['\uFEF3'] = '\u064A';
  37519. t['\uFEF4'] = '\u064A';
  37520. t['\uFEF5'] = '\u0644\u0622';
  37521. t['\uFEF6'] = '\u0644\u0622';
  37522. t['\uFEF7'] = '\u0644\u0623';
  37523. t['\uFEF8'] = '\u0644\u0623';
  37524. t['\uFEF9'] = '\u0644\u0625';
  37525. t['\uFEFA'] = '\u0644\u0625';
  37526. t['\uFEFB'] = '\u0644\u0627';
  37527. t['\uFEFC'] = '\u0644\u0627';
  37528. });
  37529. function reverseIfRtl(chars) {
  37530. var charsLength = chars.length;
  37531. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  37532. return chars;
  37533. }
  37534. var s = '';
  37535. for (var ii = charsLength - 1; ii >= 0; ii--) {
  37536. s += chars[ii];
  37537. }
  37538. return s;
  37539. }
  37540. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  37541. exports.reverseIfRtl = reverseIfRtl;
  37542. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  37543. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  37544. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  37545. /***/ }),
  37546. /* 23 */
  37547. /***/ (function(module, exports, __w_pdfjs_require__) {
  37548. "use strict";
  37549. var sharedUtil = __w_pdfjs_require__(0);
  37550. var corePrimitives = __w_pdfjs_require__(1);
  37551. var corePdfManager = __w_pdfjs_require__(41);
  37552. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  37553. var InvalidPDFException = sharedUtil.InvalidPDFException;
  37554. var MessageHandler = sharedUtil.MessageHandler;
  37555. var MissingPDFException = sharedUtil.MissingPDFException;
  37556. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  37557. var PasswordException = sharedUtil.PasswordException;
  37558. var UnknownErrorException = sharedUtil.UnknownErrorException;
  37559. var XRefParseException = sharedUtil.XRefParseException;
  37560. var arrayByteLength = sharedUtil.arrayByteLength;
  37561. var arraysToBytes = sharedUtil.arraysToBytes;
  37562. var assert = sharedUtil.assert;
  37563. var createPromiseCapability = sharedUtil.createPromiseCapability;
  37564. var info = sharedUtil.info;
  37565. var warn = sharedUtil.warn;
  37566. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  37567. var isNodeJS = sharedUtil.isNodeJS;
  37568. var Ref = corePrimitives.Ref;
  37569. var LocalPdfManager = corePdfManager.LocalPdfManager;
  37570. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  37571. var WorkerTask = function WorkerTaskClosure() {
  37572. function WorkerTask(name) {
  37573. this.name = name;
  37574. this.terminated = false;
  37575. this._capability = createPromiseCapability();
  37576. }
  37577. WorkerTask.prototype = {
  37578. get finished() {
  37579. return this._capability.promise;
  37580. },
  37581. finish: function () {
  37582. this._capability.resolve();
  37583. },
  37584. terminate: function () {
  37585. this.terminated = true;
  37586. },
  37587. ensureNotTerminated: function () {
  37588. if (this.terminated) {
  37589. throw new Error('Worker task was terminated');
  37590. }
  37591. }
  37592. };
  37593. return WorkerTask;
  37594. }();
  37595. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  37596. function PDFWorkerStream(params, msgHandler) {
  37597. this._queuedChunks = [];
  37598. var initialData = params.initialData;
  37599. if (initialData && initialData.length > 0) {
  37600. this._queuedChunks.push(initialData);
  37601. }
  37602. this._msgHandler = msgHandler;
  37603. this._isRangeSupported = !params.disableRange;
  37604. this._isStreamingSupported = !params.disableStream;
  37605. this._contentLength = params.length;
  37606. this._fullRequestReader = null;
  37607. this._rangeReaders = [];
  37608. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  37609. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  37610. }
  37611. PDFWorkerStream.prototype = {
  37612. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  37613. if (args.begin === undefined) {
  37614. if (this._fullRequestReader) {
  37615. this._fullRequestReader._enqueue(args.chunk);
  37616. } else {
  37617. this._queuedChunks.push(args.chunk);
  37618. }
  37619. } else {
  37620. var found = this._rangeReaders.some(function (rangeReader) {
  37621. if (rangeReader._begin !== args.begin) {
  37622. return false;
  37623. }
  37624. rangeReader._enqueue(args.chunk);
  37625. return true;
  37626. });
  37627. assert(found);
  37628. }
  37629. },
  37630. _onProgress: function PDFWorkerStream_onProgress(evt) {
  37631. if (this._rangeReaders.length > 0) {
  37632. var firstReader = this._rangeReaders[0];
  37633. if (firstReader.onProgress) {
  37634. firstReader.onProgress({ loaded: evt.loaded });
  37635. }
  37636. }
  37637. },
  37638. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  37639. var i = this._rangeReaders.indexOf(reader);
  37640. if (i >= 0) {
  37641. this._rangeReaders.splice(i, 1);
  37642. }
  37643. },
  37644. getFullReader: function PDFWorkerStream_getFullReader() {
  37645. assert(!this._fullRequestReader);
  37646. var queuedChunks = this._queuedChunks;
  37647. this._queuedChunks = null;
  37648. return new PDFWorkerStreamReader(this, queuedChunks);
  37649. },
  37650. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  37651. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  37652. this._msgHandler.send('RequestDataRange', {
  37653. begin: begin,
  37654. end: end
  37655. });
  37656. this._rangeReaders.push(reader);
  37657. return reader;
  37658. },
  37659. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  37660. if (this._fullRequestReader) {
  37661. this._fullRequestReader.cancel(reason);
  37662. }
  37663. var readers = this._rangeReaders.slice(0);
  37664. readers.forEach(function (rangeReader) {
  37665. rangeReader.cancel(reason);
  37666. });
  37667. }
  37668. };
  37669. function PDFWorkerStreamReader(stream, queuedChunks) {
  37670. this._stream = stream;
  37671. this._done = false;
  37672. this._queuedChunks = queuedChunks || [];
  37673. this._requests = [];
  37674. this._headersReady = Promise.resolve();
  37675. stream._fullRequestReader = this;
  37676. this.onProgress = null;
  37677. }
  37678. PDFWorkerStreamReader.prototype = {
  37679. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  37680. if (this._done) {
  37681. return;
  37682. }
  37683. if (this._requests.length > 0) {
  37684. var requestCapability = this._requests.shift();
  37685. requestCapability.resolve({
  37686. value: chunk,
  37687. done: false
  37688. });
  37689. return;
  37690. }
  37691. this._queuedChunks.push(chunk);
  37692. },
  37693. get headersReady() {
  37694. return this._headersReady;
  37695. },
  37696. get isRangeSupported() {
  37697. return this._stream._isRangeSupported;
  37698. },
  37699. get isStreamingSupported() {
  37700. return this._stream._isStreamingSupported;
  37701. },
  37702. get contentLength() {
  37703. return this._stream._contentLength;
  37704. },
  37705. read: function PDFWorkerStreamReader_read() {
  37706. if (this._queuedChunks.length > 0) {
  37707. var chunk = this._queuedChunks.shift();
  37708. return Promise.resolve({
  37709. value: chunk,
  37710. done: false
  37711. });
  37712. }
  37713. if (this._done) {
  37714. return Promise.resolve({
  37715. value: undefined,
  37716. done: true
  37717. });
  37718. }
  37719. var requestCapability = createPromiseCapability();
  37720. this._requests.push(requestCapability);
  37721. return requestCapability.promise;
  37722. },
  37723. cancel: function PDFWorkerStreamReader_cancel(reason) {
  37724. this._done = true;
  37725. this._requests.forEach(function (requestCapability) {
  37726. requestCapability.resolve({
  37727. value: undefined,
  37728. done: true
  37729. });
  37730. });
  37731. this._requests = [];
  37732. }
  37733. };
  37734. function PDFWorkerStreamRangeReader(stream, begin, end) {
  37735. this._stream = stream;
  37736. this._begin = begin;
  37737. this._end = end;
  37738. this._queuedChunk = null;
  37739. this._requests = [];
  37740. this._done = false;
  37741. this.onProgress = null;
  37742. }
  37743. PDFWorkerStreamRangeReader.prototype = {
  37744. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  37745. if (this._done) {
  37746. return;
  37747. }
  37748. if (this._requests.length === 0) {
  37749. this._queuedChunk = chunk;
  37750. } else {
  37751. var requestsCapability = this._requests.shift();
  37752. requestsCapability.resolve({
  37753. value: chunk,
  37754. done: false
  37755. });
  37756. this._requests.forEach(function (requestCapability) {
  37757. requestCapability.resolve({
  37758. value: undefined,
  37759. done: true
  37760. });
  37761. });
  37762. this._requests = [];
  37763. }
  37764. this._done = true;
  37765. this._stream._removeRangeReader(this);
  37766. },
  37767. get isStreamingSupported() {
  37768. return false;
  37769. },
  37770. read: function PDFWorkerStreamRangeReader_read() {
  37771. if (this._queuedChunk) {
  37772. return Promise.resolve({
  37773. value: this._queuedChunk,
  37774. done: false
  37775. });
  37776. }
  37777. if (this._done) {
  37778. return Promise.resolve({
  37779. value: undefined,
  37780. done: true
  37781. });
  37782. }
  37783. var requestCapability = createPromiseCapability();
  37784. this._requests.push(requestCapability);
  37785. return requestCapability.promise;
  37786. },
  37787. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  37788. this._done = true;
  37789. this._requests.forEach(function (requestCapability) {
  37790. requestCapability.resolve({
  37791. value: undefined,
  37792. done: true
  37793. });
  37794. });
  37795. this._requests = [];
  37796. this._stream._removeRangeReader(this);
  37797. }
  37798. };
  37799. return PDFWorkerStream;
  37800. }();
  37801. var PDFNetworkStream;
  37802. function setPDFNetworkStreamClass(cls) {
  37803. PDFNetworkStream = cls;
  37804. }
  37805. var WorkerMessageHandler = {
  37806. setup: function wphSetup(handler, port) {
  37807. var testMessageProcessed = false;
  37808. handler.on('test', function wphSetupTest(data) {
  37809. if (testMessageProcessed) {
  37810. return;
  37811. }
  37812. testMessageProcessed = true;
  37813. if (!(data instanceof Uint8Array)) {
  37814. handler.send('test', 'main', false);
  37815. return;
  37816. }
  37817. var supportTransfers = data[0] === 255;
  37818. handler.postMessageTransfers = supportTransfers;
  37819. var xhr = new XMLHttpRequest();
  37820. var responseExists = 'response' in xhr;
  37821. try {
  37822. xhr.responseType;
  37823. } catch (e) {
  37824. responseExists = false;
  37825. }
  37826. if (!responseExists) {
  37827. handler.send('test', false);
  37828. return;
  37829. }
  37830. handler.send('test', {
  37831. supportTypedArray: true,
  37832. supportTransfers: supportTransfers
  37833. });
  37834. });
  37835. handler.on('configure', function wphConfigure(data) {
  37836. setVerbosityLevel(data.verbosity);
  37837. });
  37838. handler.on('GetDocRequest', function wphSetupDoc(data) {
  37839. return WorkerMessageHandler.createDocumentHandler(data, port);
  37840. });
  37841. },
  37842. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  37843. var pdfManager;
  37844. var terminated = false;
  37845. var cancelXHRs = null;
  37846. var WorkerTasks = [];
  37847. var docId = docParams.docId;
  37848. var docBaseUrl = docParams.docBaseUrl;
  37849. var workerHandlerName = docParams.docId + '_worker';
  37850. var handler = new MessageHandler(workerHandlerName, docId, port);
  37851. handler.postMessageTransfers = docParams.postMessageTransfers;
  37852. function ensureNotTerminated() {
  37853. if (terminated) {
  37854. throw new Error('Worker was terminated');
  37855. }
  37856. }
  37857. function startWorkerTask(task) {
  37858. WorkerTasks.push(task);
  37859. }
  37860. function finishWorkerTask(task) {
  37861. task.finish();
  37862. var i = WorkerTasks.indexOf(task);
  37863. WorkerTasks.splice(i, 1);
  37864. }
  37865. function loadDocument(recoveryMode) {
  37866. var loadDocumentCapability = createPromiseCapability();
  37867. var parseSuccess = function parseSuccess() {
  37868. var numPagesPromise = pdfManager.ensureDoc('numPages');
  37869. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  37870. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  37871. Promise.all([
  37872. numPagesPromise,
  37873. fingerprintPromise,
  37874. encryptedPromise
  37875. ]).then(function onDocReady(results) {
  37876. var doc = {
  37877. numPages: results[0],
  37878. fingerprint: results[1],
  37879. encrypted: !!results[2]
  37880. };
  37881. loadDocumentCapability.resolve(doc);
  37882. }, parseFailure);
  37883. };
  37884. var parseFailure = function parseFailure(e) {
  37885. loadDocumentCapability.reject(e);
  37886. };
  37887. pdfManager.ensureDoc('checkHeader', []).then(function () {
  37888. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  37889. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  37890. }, parseFailure);
  37891. }, parseFailure);
  37892. return loadDocumentCapability.promise;
  37893. }
  37894. function getPdfManager(data, evaluatorOptions) {
  37895. var pdfManagerCapability = createPromiseCapability();
  37896. var pdfManager;
  37897. var source = data.source;
  37898. if (source.data) {
  37899. try {
  37900. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  37901. pdfManagerCapability.resolve(pdfManager);
  37902. } catch (ex) {
  37903. pdfManagerCapability.reject(ex);
  37904. }
  37905. return pdfManagerCapability.promise;
  37906. }
  37907. var pdfStream;
  37908. try {
  37909. if (source.chunkedViewerLoading) {
  37910. pdfStream = new PDFWorkerStream(source, handler);
  37911. } else {
  37912. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  37913. pdfStream = new PDFNetworkStream(data);
  37914. }
  37915. } catch (ex) {
  37916. pdfManagerCapability.reject(ex);
  37917. return pdfManagerCapability.promise;
  37918. }
  37919. var fullRequest = pdfStream.getFullReader();
  37920. fullRequest.headersReady.then(function () {
  37921. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  37922. fullRequest.onProgress = function (evt) {
  37923. handler.send('DocProgress', {
  37924. loaded: evt.loaded,
  37925. total: evt.total
  37926. });
  37927. };
  37928. }
  37929. if (!fullRequest.isRangeSupported) {
  37930. return;
  37931. }
  37932. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  37933. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  37934. msgHandler: handler,
  37935. url: source.url,
  37936. password: source.password,
  37937. length: fullRequest.contentLength,
  37938. disableAutoFetch: disableAutoFetch,
  37939. rangeChunkSize: source.rangeChunkSize
  37940. }, evaluatorOptions, docBaseUrl);
  37941. pdfManagerCapability.resolve(pdfManager);
  37942. cancelXHRs = null;
  37943. }).catch(function (reason) {
  37944. pdfManagerCapability.reject(reason);
  37945. cancelXHRs = null;
  37946. });
  37947. var cachedChunks = [], loaded = 0;
  37948. var flushChunks = function () {
  37949. var pdfFile = arraysToBytes(cachedChunks);
  37950. if (source.length && pdfFile.length !== source.length) {
  37951. warn('reported HTTP length is different from actual');
  37952. }
  37953. try {
  37954. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  37955. pdfManagerCapability.resolve(pdfManager);
  37956. } catch (ex) {
  37957. pdfManagerCapability.reject(ex);
  37958. }
  37959. cachedChunks = [];
  37960. };
  37961. var readPromise = new Promise(function (resolve, reject) {
  37962. var readChunk = function (chunk) {
  37963. try {
  37964. ensureNotTerminated();
  37965. if (chunk.done) {
  37966. if (!pdfManager) {
  37967. flushChunks();
  37968. }
  37969. cancelXHRs = null;
  37970. return;
  37971. }
  37972. var data = chunk.value;
  37973. loaded += arrayByteLength(data);
  37974. if (!fullRequest.isStreamingSupported) {
  37975. handler.send('DocProgress', {
  37976. loaded: loaded,
  37977. total: Math.max(loaded, fullRequest.contentLength || 0)
  37978. });
  37979. }
  37980. if (pdfManager) {
  37981. pdfManager.sendProgressiveData(data);
  37982. } else {
  37983. cachedChunks.push(data);
  37984. }
  37985. fullRequest.read().then(readChunk, reject);
  37986. } catch (e) {
  37987. reject(e);
  37988. }
  37989. };
  37990. fullRequest.read().then(readChunk, reject);
  37991. });
  37992. readPromise.catch(function (e) {
  37993. pdfManagerCapability.reject(e);
  37994. cancelXHRs = null;
  37995. });
  37996. cancelXHRs = function () {
  37997. pdfStream.cancelAllRequests('abort');
  37998. };
  37999. return pdfManagerCapability.promise;
  38000. }
  38001. function setupDoc(data) {
  38002. function onSuccess(doc) {
  38003. ensureNotTerminated();
  38004. handler.send('GetDoc', { pdfInfo: doc });
  38005. }
  38006. function onFailure(e) {
  38007. if (e instanceof PasswordException) {
  38008. var task = new WorkerTask('PasswordException: response ' + e.code);
  38009. startWorkerTask(task);
  38010. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38011. finishWorkerTask(task);
  38012. pdfManager.updatePassword(data.password);
  38013. pdfManagerReady();
  38014. }).catch(function (ex) {
  38015. finishWorkerTask(task);
  38016. handler.send('PasswordException', ex);
  38017. }.bind(null, e));
  38018. } else if (e instanceof InvalidPDFException) {
  38019. handler.send('InvalidPDF', e);
  38020. } else if (e instanceof MissingPDFException) {
  38021. handler.send('MissingPDF', e);
  38022. } else if (e instanceof UnexpectedResponseException) {
  38023. handler.send('UnexpectedResponse', e);
  38024. } else {
  38025. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38026. }
  38027. }
  38028. function pdfManagerReady() {
  38029. ensureNotTerminated();
  38030. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38031. ensureNotTerminated();
  38032. if (!(ex instanceof XRefParseException)) {
  38033. onFailure(ex);
  38034. return;
  38035. }
  38036. pdfManager.requestLoadedStream();
  38037. pdfManager.onLoadedStream().then(function () {
  38038. ensureNotTerminated();
  38039. loadDocument(true).then(onSuccess, onFailure);
  38040. });
  38041. }, onFailure);
  38042. }
  38043. ensureNotTerminated();
  38044. var evaluatorOptions = {
  38045. forceDataSchema: data.disableCreateObjectURL,
  38046. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38047. disableFontFace: data.disableFontFace,
  38048. disableNativeImageDecoder: data.disableNativeImageDecoder
  38049. };
  38050. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38051. if (terminated) {
  38052. newPdfManager.terminate();
  38053. throw new Error('Worker was terminated');
  38054. }
  38055. pdfManager = newPdfManager;
  38056. handler.send('PDFManagerReady', null);
  38057. pdfManager.onLoadedStream().then(function (stream) {
  38058. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38059. });
  38060. }).then(pdfManagerReady, onFailure);
  38061. }
  38062. handler.on('GetPage', function wphSetupGetPage(data) {
  38063. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38064. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38065. var refPromise = pdfManager.ensure(page, 'ref');
  38066. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38067. var viewPromise = pdfManager.ensure(page, 'view');
  38068. return Promise.all([
  38069. rotatePromise,
  38070. refPromise,
  38071. userUnitPromise,
  38072. viewPromise
  38073. ]).then(function (results) {
  38074. return {
  38075. rotate: results[0],
  38076. ref: results[1],
  38077. userUnit: results[2],
  38078. view: results[3]
  38079. };
  38080. });
  38081. });
  38082. });
  38083. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38084. var ref = new Ref(data.ref.num, data.ref.gen);
  38085. var catalog = pdfManager.pdfDocument.catalog;
  38086. return catalog.getPageIndex(ref);
  38087. });
  38088. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38089. return pdfManager.ensureCatalog('destinations');
  38090. });
  38091. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38092. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38093. });
  38094. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38095. return pdfManager.ensureCatalog('pageLabels');
  38096. });
  38097. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38098. return pdfManager.ensureCatalog('attachments');
  38099. });
  38100. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38101. return pdfManager.ensureCatalog('javaScript');
  38102. });
  38103. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38104. return pdfManager.ensureCatalog('documentOutline');
  38105. });
  38106. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38107. return Promise.all([
  38108. pdfManager.ensureDoc('documentInfo'),
  38109. pdfManager.ensureCatalog('metadata')
  38110. ]);
  38111. });
  38112. handler.on('GetData', function wphSetupGetData(data) {
  38113. pdfManager.requestLoadedStream();
  38114. return pdfManager.onLoadedStream().then(function (stream) {
  38115. return stream.bytes;
  38116. });
  38117. });
  38118. handler.on('GetStats', function wphSetupGetStats(data) {
  38119. return pdfManager.pdfDocument.xref.stats;
  38120. });
  38121. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38122. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38123. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38124. });
  38125. });
  38126. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38127. var pageIndex = data.pageIndex;
  38128. pdfManager.getPage(pageIndex).then(function (page) {
  38129. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38130. startWorkerTask(task);
  38131. var pageNum = pageIndex + 1;
  38132. var start = Date.now();
  38133. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38134. finishWorkerTask(task);
  38135. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38136. }, function (e) {
  38137. finishWorkerTask(task);
  38138. if (task.terminated) {
  38139. return;
  38140. }
  38141. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38142. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38143. var wrappedException;
  38144. if (typeof e === 'string') {
  38145. wrappedException = {
  38146. message: e,
  38147. stack: minimumStackMessage
  38148. };
  38149. } else if (typeof e === 'object') {
  38150. wrappedException = {
  38151. message: e.message || e.toString(),
  38152. stack: e.stack || minimumStackMessage
  38153. };
  38154. } else {
  38155. wrappedException = {
  38156. message: 'Unknown exception type: ' + typeof e,
  38157. stack: minimumStackMessage
  38158. };
  38159. }
  38160. handler.send('PageError', {
  38161. pageNum: pageNum,
  38162. error: wrappedException,
  38163. intent: data.intent
  38164. });
  38165. });
  38166. });
  38167. }, this);
  38168. handler.on('GetTextContent', function wphExtractText(data) {
  38169. var pageIndex = data.pageIndex;
  38170. var normalizeWhitespace = data.normalizeWhitespace;
  38171. var combineTextItems = data.combineTextItems;
  38172. return pdfManager.getPage(pageIndex).then(function (page) {
  38173. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38174. startWorkerTask(task);
  38175. var pageNum = pageIndex + 1;
  38176. var start = Date.now();
  38177. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38178. finishWorkerTask(task);
  38179. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38180. return textContent;
  38181. }, function (reason) {
  38182. finishWorkerTask(task);
  38183. if (task.terminated) {
  38184. return;
  38185. }
  38186. throw reason;
  38187. });
  38188. });
  38189. });
  38190. handler.on('Cleanup', function wphCleanup(data) {
  38191. return pdfManager.cleanup();
  38192. });
  38193. handler.on('Terminate', function wphTerminate(data) {
  38194. terminated = true;
  38195. if (pdfManager) {
  38196. pdfManager.terminate();
  38197. pdfManager = null;
  38198. }
  38199. if (cancelXHRs) {
  38200. cancelXHRs();
  38201. }
  38202. var waitOn = [];
  38203. WorkerTasks.forEach(function (task) {
  38204. waitOn.push(task.finished);
  38205. task.terminate();
  38206. });
  38207. return Promise.all(waitOn).then(function () {
  38208. handler.destroy();
  38209. handler = null;
  38210. });
  38211. });
  38212. handler.on('Ready', function wphReady(data) {
  38213. setupDoc(docParams);
  38214. docParams = null;
  38215. });
  38216. return workerHandlerName;
  38217. }
  38218. };
  38219. function initializeWorker() {
  38220. var handler = new MessageHandler('worker', 'main', self);
  38221. WorkerMessageHandler.setup(handler, self);
  38222. handler.send('ready', null);
  38223. }
  38224. if (typeof window === 'undefined' && !isNodeJS()) {
  38225. initializeWorker();
  38226. }
  38227. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38228. exports.WorkerTask = WorkerTask;
  38229. exports.WorkerMessageHandler = WorkerMessageHandler;
  38230. /***/ }),
  38231. /* 24 */
  38232. /***/ (function(module, exports, __w_pdfjs_require__) {
  38233. "use strict";
  38234. var sharedUtil = __w_pdfjs_require__(0);
  38235. var error = sharedUtil.error;
  38236. function fixMetadata(meta) {
  38237. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38238. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38239. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38240. });
  38241. var chars = '';
  38242. for (var i = 0; i < bytes.length; i += 2) {
  38243. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38244. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38245. }
  38246. return '>' + chars;
  38247. });
  38248. }
  38249. function Metadata(meta) {
  38250. if (typeof meta === 'string') {
  38251. meta = fixMetadata(meta);
  38252. var parser = new DOMParser();
  38253. meta = parser.parseFromString(meta, 'application/xml');
  38254. } else if (!(meta instanceof Document)) {
  38255. error('Metadata: Invalid metadata object');
  38256. }
  38257. this.metaDocument = meta;
  38258. this.metadata = Object.create(null);
  38259. this.parse();
  38260. }
  38261. Metadata.prototype = {
  38262. parse: function Metadata_parse() {
  38263. var doc = this.metaDocument;
  38264. var rdf = doc.documentElement;
  38265. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38266. rdf = rdf.firstChild;
  38267. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38268. rdf = rdf.nextSibling;
  38269. }
  38270. }
  38271. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  38272. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  38273. return;
  38274. }
  38275. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  38276. for (i = 0, length = children.length; i < length; i++) {
  38277. desc = children[i];
  38278. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  38279. continue;
  38280. }
  38281. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  38282. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  38283. entry = desc.childNodes[ii];
  38284. name = entry.nodeName.toLowerCase();
  38285. this.metadata[name] = entry.textContent.trim();
  38286. }
  38287. }
  38288. }
  38289. },
  38290. get: function Metadata_get(name) {
  38291. return this.metadata[name] || null;
  38292. },
  38293. has: function Metadata_has(name) {
  38294. return typeof this.metadata[name] !== 'undefined';
  38295. }
  38296. };
  38297. exports.Metadata = Metadata;
  38298. /***/ }),
  38299. /* 25 */
  38300. /***/ (function(module, exports, __w_pdfjs_require__) {
  38301. "use strict";
  38302. var sharedUtil = __w_pdfjs_require__(0);
  38303. var displayDOMUtils = __w_pdfjs_require__(3);
  38304. var shadow = sharedUtil.shadow;
  38305. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  38306. var WebGLUtils = function WebGLUtilsClosure() {
  38307. function loadShader(gl, code, shaderType) {
  38308. var shader = gl.createShader(shaderType);
  38309. gl.shaderSource(shader, code);
  38310. gl.compileShader(shader);
  38311. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  38312. if (!compiled) {
  38313. var errorMsg = gl.getShaderInfoLog(shader);
  38314. throw new Error('Error during shader compilation: ' + errorMsg);
  38315. }
  38316. return shader;
  38317. }
  38318. function createVertexShader(gl, code) {
  38319. return loadShader(gl, code, gl.VERTEX_SHADER);
  38320. }
  38321. function createFragmentShader(gl, code) {
  38322. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  38323. }
  38324. function createProgram(gl, shaders) {
  38325. var program = gl.createProgram();
  38326. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  38327. gl.attachShader(program, shaders[i]);
  38328. }
  38329. gl.linkProgram(program);
  38330. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  38331. if (!linked) {
  38332. var errorMsg = gl.getProgramInfoLog(program);
  38333. throw new Error('Error during program linking: ' + errorMsg);
  38334. }
  38335. return program;
  38336. }
  38337. function createTexture(gl, image, textureId) {
  38338. gl.activeTexture(textureId);
  38339. var texture = gl.createTexture();
  38340. gl.bindTexture(gl.TEXTURE_2D, texture);
  38341. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  38342. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  38343. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  38344. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  38345. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  38346. return texture;
  38347. }
  38348. var currentGL, currentCanvas;
  38349. function generateGL() {
  38350. if (currentGL) {
  38351. return;
  38352. }
  38353. currentCanvas = document.createElement('canvas');
  38354. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  38355. }
  38356. var smaskVertexShaderCode = '\
  38357. attribute vec2 a_position; \
  38358. attribute vec2 a_texCoord; \
  38359. \
  38360. uniform vec2 u_resolution; \
  38361. \
  38362. varying vec2 v_texCoord; \
  38363. \
  38364. void main() { \
  38365. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  38366. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38367. \
  38368. v_texCoord = a_texCoord; \
  38369. } ';
  38370. var smaskFragmentShaderCode = '\
  38371. precision mediump float; \
  38372. \
  38373. uniform vec4 u_backdrop; \
  38374. uniform int u_subtype; \
  38375. uniform sampler2D u_image; \
  38376. uniform sampler2D u_mask; \
  38377. \
  38378. varying vec2 v_texCoord; \
  38379. \
  38380. void main() { \
  38381. vec4 imageColor = texture2D(u_image, v_texCoord); \
  38382. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  38383. if (u_backdrop.a > 0.0) { \
  38384. maskColor.rgb = maskColor.rgb * maskColor.a + \
  38385. u_backdrop.rgb * (1.0 - maskColor.a); \
  38386. } \
  38387. float lum; \
  38388. if (u_subtype == 0) { \
  38389. lum = maskColor.a; \
  38390. } else { \
  38391. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  38392. maskColor.b * 0.11; \
  38393. } \
  38394. imageColor.a *= lum; \
  38395. imageColor.rgb *= imageColor.a; \
  38396. gl_FragColor = imageColor; \
  38397. } ';
  38398. var smaskCache = null;
  38399. function initSmaskGL() {
  38400. var canvas, gl;
  38401. generateGL();
  38402. canvas = currentCanvas;
  38403. currentCanvas = null;
  38404. gl = currentGL;
  38405. currentGL = null;
  38406. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  38407. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  38408. var program = createProgram(gl, [
  38409. vertexShader,
  38410. fragmentShader
  38411. ]);
  38412. gl.useProgram(program);
  38413. var cache = {};
  38414. cache.gl = gl;
  38415. cache.canvas = canvas;
  38416. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38417. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38418. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  38419. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  38420. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  38421. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  38422. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  38423. var texCoordBuffer = gl.createBuffer();
  38424. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  38425. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38426. 0.0,
  38427. 0.0,
  38428. 1.0,
  38429. 0.0,
  38430. 0.0,
  38431. 1.0,
  38432. 0.0,
  38433. 1.0,
  38434. 1.0,
  38435. 0.0,
  38436. 1.0,
  38437. 1.0
  38438. ]), gl.STATIC_DRAW);
  38439. gl.enableVertexAttribArray(texCoordLocation);
  38440. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  38441. gl.uniform1i(texLayerLocation, 0);
  38442. gl.uniform1i(texMaskLocation, 1);
  38443. smaskCache = cache;
  38444. }
  38445. function composeSMask(layer, mask, properties) {
  38446. var width = layer.width, height = layer.height;
  38447. if (!smaskCache) {
  38448. initSmaskGL();
  38449. }
  38450. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  38451. canvas.width = width;
  38452. canvas.height = height;
  38453. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38454. gl.uniform2f(cache.resolutionLocation, width, height);
  38455. if (properties.backdrop) {
  38456. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  38457. } else {
  38458. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  38459. }
  38460. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  38461. var texture = createTexture(gl, layer, gl.TEXTURE0);
  38462. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  38463. var buffer = gl.createBuffer();
  38464. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  38465. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38466. 0,
  38467. 0,
  38468. width,
  38469. 0,
  38470. 0,
  38471. height,
  38472. 0,
  38473. height,
  38474. width,
  38475. 0,
  38476. width,
  38477. height
  38478. ]), gl.STATIC_DRAW);
  38479. gl.enableVertexAttribArray(cache.positionLocation);
  38480. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38481. gl.clearColor(0, 0, 0, 0);
  38482. gl.enable(gl.BLEND);
  38483. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  38484. gl.clear(gl.COLOR_BUFFER_BIT);
  38485. gl.drawArrays(gl.TRIANGLES, 0, 6);
  38486. gl.flush();
  38487. gl.deleteTexture(texture);
  38488. gl.deleteTexture(maskTexture);
  38489. gl.deleteBuffer(buffer);
  38490. return canvas;
  38491. }
  38492. var figuresVertexShaderCode = '\
  38493. attribute vec2 a_position; \
  38494. attribute vec3 a_color; \
  38495. \
  38496. uniform vec2 u_resolution; \
  38497. uniform vec2 u_scale; \
  38498. uniform vec2 u_offset; \
  38499. \
  38500. varying vec4 v_color; \
  38501. \
  38502. void main() { \
  38503. vec2 position = (a_position + u_offset) * u_scale; \
  38504. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  38505. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38506. \
  38507. v_color = vec4(a_color / 255.0, 1.0); \
  38508. } ';
  38509. var figuresFragmentShaderCode = '\
  38510. precision mediump float; \
  38511. \
  38512. varying vec4 v_color; \
  38513. \
  38514. void main() { \
  38515. gl_FragColor = v_color; \
  38516. } ';
  38517. var figuresCache = null;
  38518. function initFiguresGL() {
  38519. var canvas, gl;
  38520. generateGL();
  38521. canvas = currentCanvas;
  38522. currentCanvas = null;
  38523. gl = currentGL;
  38524. currentGL = null;
  38525. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  38526. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  38527. var program = createProgram(gl, [
  38528. vertexShader,
  38529. fragmentShader
  38530. ]);
  38531. gl.useProgram(program);
  38532. var cache = {};
  38533. cache.gl = gl;
  38534. cache.canvas = canvas;
  38535. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38536. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  38537. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  38538. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38539. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  38540. figuresCache = cache;
  38541. }
  38542. function drawFigures(width, height, backgroundColor, figures, context) {
  38543. if (!figuresCache) {
  38544. initFiguresGL();
  38545. }
  38546. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  38547. canvas.width = width;
  38548. canvas.height = height;
  38549. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38550. gl.uniform2f(cache.resolutionLocation, width, height);
  38551. var count = 0;
  38552. var i, ii, rows;
  38553. for (i = 0, ii = figures.length; i < ii; i++) {
  38554. switch (figures[i].type) {
  38555. case 'lattice':
  38556. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  38557. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  38558. break;
  38559. case 'triangles':
  38560. count += figures[i].coords.length;
  38561. break;
  38562. }
  38563. }
  38564. var coords = new Float32Array(count * 2);
  38565. var colors = new Uint8Array(count * 3);
  38566. var coordsMap = context.coords, colorsMap = context.colors;
  38567. var pIndex = 0, cIndex = 0;
  38568. for (i = 0, ii = figures.length; i < ii; i++) {
  38569. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  38570. switch (figure.type) {
  38571. case 'lattice':
  38572. var cols = figure.verticesPerRow;
  38573. rows = ps.length / cols | 0;
  38574. for (var row = 1; row < rows; row++) {
  38575. var offset = row * cols + 1;
  38576. for (var col = 1; col < cols; col++, offset++) {
  38577. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  38578. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  38579. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  38580. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  38581. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  38582. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  38583. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  38584. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  38585. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  38586. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  38587. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  38588. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  38589. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  38590. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  38591. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  38592. coords[pIndex + 6] = coords[pIndex + 2];
  38593. coords[pIndex + 7] = coords[pIndex + 3];
  38594. coords[pIndex + 8] = coords[pIndex + 4];
  38595. coords[pIndex + 9] = coords[pIndex + 5];
  38596. coords[pIndex + 10] = coordsMap[ps[offset]];
  38597. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  38598. colors[cIndex + 9] = colors[cIndex + 3];
  38599. colors[cIndex + 10] = colors[cIndex + 4];
  38600. colors[cIndex + 11] = colors[cIndex + 5];
  38601. colors[cIndex + 12] = colors[cIndex + 6];
  38602. colors[cIndex + 13] = colors[cIndex + 7];
  38603. colors[cIndex + 14] = colors[cIndex + 8];
  38604. colors[cIndex + 15] = colorsMap[cs[offset]];
  38605. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  38606. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  38607. pIndex += 12;
  38608. cIndex += 18;
  38609. }
  38610. }
  38611. break;
  38612. case 'triangles':
  38613. for (var j = 0, jj = ps.length; j < jj; j++) {
  38614. coords[pIndex] = coordsMap[ps[j]];
  38615. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  38616. colors[cIndex] = colorsMap[cs[j]];
  38617. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  38618. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  38619. pIndex += 2;
  38620. cIndex += 3;
  38621. }
  38622. break;
  38623. }
  38624. }
  38625. if (backgroundColor) {
  38626. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  38627. } else {
  38628. gl.clearColor(0, 0, 0, 0);
  38629. }
  38630. gl.clear(gl.COLOR_BUFFER_BIT);
  38631. var coordsBuffer = gl.createBuffer();
  38632. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  38633. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  38634. gl.enableVertexAttribArray(cache.positionLocation);
  38635. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38636. var colorsBuffer = gl.createBuffer();
  38637. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  38638. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  38639. gl.enableVertexAttribArray(cache.colorLocation);
  38640. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  38641. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  38642. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  38643. gl.drawArrays(gl.TRIANGLES, 0, count);
  38644. gl.flush();
  38645. gl.deleteBuffer(coordsBuffer);
  38646. gl.deleteBuffer(colorsBuffer);
  38647. return canvas;
  38648. }
  38649. function cleanup() {
  38650. if (smaskCache && smaskCache.canvas) {
  38651. smaskCache.canvas.width = 0;
  38652. smaskCache.canvas.height = 0;
  38653. }
  38654. if (figuresCache && figuresCache.canvas) {
  38655. figuresCache.canvas.width = 0;
  38656. figuresCache.canvas.height = 0;
  38657. }
  38658. smaskCache = null;
  38659. figuresCache = null;
  38660. }
  38661. return {
  38662. get isEnabled() {
  38663. if (getDefaultSetting('disableWebGL')) {
  38664. return false;
  38665. }
  38666. var enabled = false;
  38667. try {
  38668. generateGL();
  38669. enabled = !!currentGL;
  38670. } catch (e) {
  38671. }
  38672. return shadow(this, 'isEnabled', enabled);
  38673. },
  38674. composeSMask: composeSMask,
  38675. drawFigures: drawFigures,
  38676. clear: cleanup
  38677. };
  38678. }();
  38679. exports.WebGLUtils = WebGLUtils;
  38680. /***/ }),
  38681. /* 26 */
  38682. /***/ (function(module, exports, __w_pdfjs_require__) {
  38683. "use strict";
  38684. var sharedUtil = __w_pdfjs_require__(0);
  38685. var displayDOMUtils = __w_pdfjs_require__(3);
  38686. var displayAPI = __w_pdfjs_require__(10);
  38687. var displayAnnotationLayer = __w_pdfjs_require__(9);
  38688. var displayTextLayer = __w_pdfjs_require__(12);
  38689. var displayMetadata = __w_pdfjs_require__(24);
  38690. var displaySVG = __w_pdfjs_require__(11);
  38691. var globalScope = sharedUtil.globalScope;
  38692. var deprecated = sharedUtil.deprecated;
  38693. var warn = sharedUtil.warn;
  38694. var LinkTarget = displayDOMUtils.LinkTarget;
  38695. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  38696. var isWorker = typeof window === 'undefined';
  38697. if (!globalScope.PDFJS) {
  38698. globalScope.PDFJS = {};
  38699. }
  38700. var PDFJS = globalScope.PDFJS;
  38701. PDFJS.version = '1.7.361';
  38702. PDFJS.build = '224613a5';
  38703. PDFJS.pdfBug = false;
  38704. if (PDFJS.verbosity !== undefined) {
  38705. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  38706. }
  38707. delete PDFJS.verbosity;
  38708. Object.defineProperty(PDFJS, 'verbosity', {
  38709. get: function () {
  38710. return sharedUtil.getVerbosityLevel();
  38711. },
  38712. set: function (level) {
  38713. sharedUtil.setVerbosityLevel(level);
  38714. },
  38715. enumerable: true,
  38716. configurable: true
  38717. });
  38718. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  38719. PDFJS.OPS = sharedUtil.OPS;
  38720. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38721. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  38722. PDFJS.shadow = sharedUtil.shadow;
  38723. PDFJS.createBlob = sharedUtil.createBlob;
  38724. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  38725. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  38726. };
  38727. Object.defineProperty(PDFJS, 'isLittleEndian', {
  38728. configurable: true,
  38729. get: function PDFJS_isLittleEndian() {
  38730. var value = sharedUtil.isLittleEndian();
  38731. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  38732. }
  38733. });
  38734. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  38735. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  38736. PDFJS.PasswordException = sharedUtil.PasswordException;
  38737. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  38738. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  38739. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  38740. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38741. PDFJS.Util = sharedUtil.Util;
  38742. PDFJS.PageViewport = sharedUtil.PageViewport;
  38743. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  38744. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  38745. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  38746. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  38747. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  38748. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  38749. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  38750. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  38751. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  38752. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  38753. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  38754. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  38755. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  38756. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  38757. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  38758. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  38759. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  38760. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  38761. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  38762. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  38763. delete PDFJS.openExternalLinksInNewWindow;
  38764. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  38765. get: function () {
  38766. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  38767. },
  38768. set: function (value) {
  38769. if (value) {
  38770. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  38771. }
  38772. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  38773. warn('PDFJS.externalLinkTarget is already initialized');
  38774. return;
  38775. }
  38776. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  38777. },
  38778. enumerable: true,
  38779. configurable: true
  38780. });
  38781. if (savedOpenExternalLinksInNewWindow) {
  38782. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  38783. }
  38784. PDFJS.getDocument = displayAPI.getDocument;
  38785. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  38786. PDFJS.PDFWorker = displayAPI.PDFWorker;
  38787. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  38788. configurable: true,
  38789. get: function PDFJS_hasCanvasTypedArrays() {
  38790. var value = displayDOMUtils.hasCanvasTypedArrays();
  38791. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  38792. }
  38793. });
  38794. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  38795. PDFJS.LinkTarget = LinkTarget;
  38796. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  38797. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  38798. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  38799. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  38800. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  38801. PDFJS.Metadata = displayMetadata.Metadata;
  38802. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  38803. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  38804. exports.globalScope = globalScope;
  38805. exports.isWorker = isWorker;
  38806. exports.PDFJS = globalScope.PDFJS;
  38807. /***/ }),
  38808. /* 27 */
  38809. /***/ (function(module, exports, __w_pdfjs_require__) {
  38810. "use strict";
  38811. var sharedUtil = __w_pdfjs_require__(0);
  38812. var corePrimitives = __w_pdfjs_require__(1);
  38813. var coreStream = __w_pdfjs_require__(2);
  38814. var coreColorSpace = __w_pdfjs_require__(4);
  38815. var coreObj = __w_pdfjs_require__(20);
  38816. var coreEvaluator = __w_pdfjs_require__(18);
  38817. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  38818. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  38819. var AnnotationFlag = sharedUtil.AnnotationFlag;
  38820. var AnnotationType = sharedUtil.AnnotationType;
  38821. var OPS = sharedUtil.OPS;
  38822. var Util = sharedUtil.Util;
  38823. var isArray = sharedUtil.isArray;
  38824. var isInt = sharedUtil.isInt;
  38825. var stringToBytes = sharedUtil.stringToBytes;
  38826. var stringToPDFString = sharedUtil.stringToPDFString;
  38827. var warn = sharedUtil.warn;
  38828. var Dict = corePrimitives.Dict;
  38829. var isDict = corePrimitives.isDict;
  38830. var isName = corePrimitives.isName;
  38831. var isRef = corePrimitives.isRef;
  38832. var isStream = corePrimitives.isStream;
  38833. var Stream = coreStream.Stream;
  38834. var ColorSpace = coreColorSpace.ColorSpace;
  38835. var Catalog = coreObj.Catalog;
  38836. var ObjectLoader = coreObj.ObjectLoader;
  38837. var FileSpec = coreObj.FileSpec;
  38838. var OperatorList = coreEvaluator.OperatorList;
  38839. function AnnotationFactory() {
  38840. }
  38841. AnnotationFactory.prototype = {
  38842. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  38843. var dict = xref.fetchIfRef(ref);
  38844. if (!isDict(dict)) {
  38845. return;
  38846. }
  38847. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  38848. var subtype = dict.get('Subtype');
  38849. subtype = isName(subtype) ? subtype.name : null;
  38850. var parameters = {
  38851. xref: xref,
  38852. dict: dict,
  38853. ref: isRef(ref) ? ref : null,
  38854. subtype: subtype,
  38855. id: id,
  38856. pdfManager: pdfManager
  38857. };
  38858. switch (subtype) {
  38859. case 'Link':
  38860. return new LinkAnnotation(parameters);
  38861. case 'Text':
  38862. return new TextAnnotation(parameters);
  38863. case 'Widget':
  38864. var fieldType = Util.getInheritableProperty(dict, 'FT');
  38865. fieldType = isName(fieldType) ? fieldType.name : null;
  38866. switch (fieldType) {
  38867. case 'Tx':
  38868. return new TextWidgetAnnotation(parameters);
  38869. case 'Btn':
  38870. return new ButtonWidgetAnnotation(parameters);
  38871. case 'Ch':
  38872. return new ChoiceWidgetAnnotation(parameters);
  38873. }
  38874. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  38875. return new WidgetAnnotation(parameters);
  38876. case 'Popup':
  38877. return new PopupAnnotation(parameters);
  38878. case 'Highlight':
  38879. return new HighlightAnnotation(parameters);
  38880. case 'Underline':
  38881. return new UnderlineAnnotation(parameters);
  38882. case 'Squiggly':
  38883. return new SquigglyAnnotation(parameters);
  38884. case 'StrikeOut':
  38885. return new StrikeOutAnnotation(parameters);
  38886. case 'FileAttachment':
  38887. return new FileAttachmentAnnotation(parameters);
  38888. default:
  38889. if (!subtype) {
  38890. warn('Annotation is missing the required /Subtype.');
  38891. } else {
  38892. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  38893. }
  38894. return new Annotation(parameters);
  38895. }
  38896. }
  38897. };
  38898. var Annotation = function AnnotationClosure() {
  38899. function getTransformMatrix(rect, bbox, matrix) {
  38900. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  38901. var minX = bounds[0];
  38902. var minY = bounds[1];
  38903. var maxX = bounds[2];
  38904. var maxY = bounds[3];
  38905. if (minX === maxX || minY === maxY) {
  38906. return [
  38907. 1,
  38908. 0,
  38909. 0,
  38910. 1,
  38911. rect[0],
  38912. rect[1]
  38913. ];
  38914. }
  38915. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  38916. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  38917. return [
  38918. xRatio,
  38919. 0,
  38920. 0,
  38921. yRatio,
  38922. rect[0] - minX * xRatio,
  38923. rect[1] - minY * yRatio
  38924. ];
  38925. }
  38926. function Annotation(params) {
  38927. var dict = params.dict;
  38928. this.setFlags(dict.get('F'));
  38929. this.setRectangle(dict.getArray('Rect'));
  38930. this.setColor(dict.getArray('C'));
  38931. this.setBorderStyle(dict);
  38932. this.setAppearance(dict);
  38933. this.data = {};
  38934. this.data.id = params.id;
  38935. this.data.subtype = params.subtype;
  38936. this.data.annotationFlags = this.flags;
  38937. this.data.rect = this.rectangle;
  38938. this.data.color = this.color;
  38939. this.data.borderStyle = this.borderStyle;
  38940. this.data.hasAppearance = !!this.appearance;
  38941. }
  38942. Annotation.prototype = {
  38943. _hasFlag: function Annotation_hasFlag(flags, flag) {
  38944. return !!(flags & flag);
  38945. },
  38946. _isViewable: function Annotation_isViewable(flags) {
  38947. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  38948. },
  38949. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  38950. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  38951. },
  38952. get viewable() {
  38953. if (this.flags === 0) {
  38954. return true;
  38955. }
  38956. return this._isViewable(this.flags);
  38957. },
  38958. get printable() {
  38959. if (this.flags === 0) {
  38960. return false;
  38961. }
  38962. return this._isPrintable(this.flags);
  38963. },
  38964. setFlags: function Annotation_setFlags(flags) {
  38965. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  38966. },
  38967. hasFlag: function Annotation_hasFlag(flag) {
  38968. return this._hasFlag(this.flags, flag);
  38969. },
  38970. setRectangle: function Annotation_setRectangle(rectangle) {
  38971. if (isArray(rectangle) && rectangle.length === 4) {
  38972. this.rectangle = Util.normalizeRect(rectangle);
  38973. } else {
  38974. this.rectangle = [
  38975. 0,
  38976. 0,
  38977. 0,
  38978. 0
  38979. ];
  38980. }
  38981. },
  38982. setColor: function Annotation_setColor(color) {
  38983. var rgbColor = new Uint8Array(3);
  38984. if (!isArray(color)) {
  38985. this.color = rgbColor;
  38986. return;
  38987. }
  38988. switch (color.length) {
  38989. case 0:
  38990. this.color = null;
  38991. break;
  38992. case 1:
  38993. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  38994. this.color = rgbColor;
  38995. break;
  38996. case 3:
  38997. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  38998. this.color = rgbColor;
  38999. break;
  39000. case 4:
  39001. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39002. this.color = rgbColor;
  39003. break;
  39004. default:
  39005. this.color = rgbColor;
  39006. break;
  39007. }
  39008. },
  39009. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39010. this.borderStyle = new AnnotationBorderStyle();
  39011. if (!isDict(borderStyle)) {
  39012. return;
  39013. }
  39014. if (borderStyle.has('BS')) {
  39015. var dict = borderStyle.get('BS');
  39016. var dictType = dict.get('Type');
  39017. if (!dictType || isName(dictType, 'Border')) {
  39018. this.borderStyle.setWidth(dict.get('W'));
  39019. this.borderStyle.setStyle(dict.get('S'));
  39020. this.borderStyle.setDashArray(dict.getArray('D'));
  39021. }
  39022. } else if (borderStyle.has('Border')) {
  39023. var array = borderStyle.getArray('Border');
  39024. if (isArray(array) && array.length >= 3) {
  39025. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39026. this.borderStyle.setVerticalCornerRadius(array[1]);
  39027. this.borderStyle.setWidth(array[2]);
  39028. if (array.length === 4) {
  39029. this.borderStyle.setDashArray(array[3]);
  39030. }
  39031. }
  39032. } else {
  39033. this.borderStyle.setWidth(0);
  39034. }
  39035. },
  39036. setAppearance: function Annotation_setAppearance(dict) {
  39037. this.appearance = null;
  39038. var appearanceStates = dict.get('AP');
  39039. if (!isDict(appearanceStates)) {
  39040. return;
  39041. }
  39042. var normalAppearanceState = appearanceStates.get('N');
  39043. if (isStream(normalAppearanceState)) {
  39044. this.appearance = normalAppearanceState;
  39045. return;
  39046. }
  39047. if (!isDict(normalAppearanceState)) {
  39048. return;
  39049. }
  39050. var as = dict.get('AS');
  39051. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39052. return;
  39053. }
  39054. this.appearance = normalAppearanceState.get(as.name);
  39055. },
  39056. _preparePopup: function Annotation_preparePopup(dict) {
  39057. if (!dict.has('C')) {
  39058. this.data.color = null;
  39059. }
  39060. this.data.hasPopup = dict.has('Popup');
  39061. this.data.title = stringToPDFString(dict.get('T') || '');
  39062. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39063. },
  39064. loadResources: function Annotation_loadResources(keys) {
  39065. return new Promise(function (resolve, reject) {
  39066. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39067. if (!resources) {
  39068. resolve();
  39069. return;
  39070. }
  39071. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39072. objectLoader.load().then(function () {
  39073. resolve(resources);
  39074. }, reject);
  39075. }, reject);
  39076. }.bind(this));
  39077. },
  39078. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39079. if (!this.appearance) {
  39080. return Promise.resolve(new OperatorList());
  39081. }
  39082. var data = this.data;
  39083. var appearanceDict = this.appearance.dict;
  39084. var resourcesPromise = this.loadResources([
  39085. 'ExtGState',
  39086. 'ColorSpace',
  39087. 'Pattern',
  39088. 'Shading',
  39089. 'XObject',
  39090. 'Font'
  39091. ]);
  39092. var bbox = appearanceDict.getArray('BBox') || [
  39093. 0,
  39094. 0,
  39095. 1,
  39096. 1
  39097. ];
  39098. var matrix = appearanceDict.getArray('Matrix') || [
  39099. 1,
  39100. 0,
  39101. 0,
  39102. 1,
  39103. 0,
  39104. 0
  39105. ];
  39106. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39107. var self = this;
  39108. return resourcesPromise.then(function (resources) {
  39109. var opList = new OperatorList();
  39110. opList.addOp(OPS.beginAnnotation, [
  39111. data.rect,
  39112. transform,
  39113. matrix
  39114. ]);
  39115. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39116. opList.addOp(OPS.endAnnotation, []);
  39117. self.appearance.reset();
  39118. return opList;
  39119. });
  39120. });
  39121. }
  39122. };
  39123. return Annotation;
  39124. }();
  39125. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39126. function AnnotationBorderStyle() {
  39127. this.width = 1;
  39128. this.style = AnnotationBorderStyleType.SOLID;
  39129. this.dashArray = [3];
  39130. this.horizontalCornerRadius = 0;
  39131. this.verticalCornerRadius = 0;
  39132. }
  39133. AnnotationBorderStyle.prototype = {
  39134. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39135. if (width === (width | 0)) {
  39136. this.width = width;
  39137. }
  39138. },
  39139. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39140. if (!style) {
  39141. return;
  39142. }
  39143. switch (style.name) {
  39144. case 'S':
  39145. this.style = AnnotationBorderStyleType.SOLID;
  39146. break;
  39147. case 'D':
  39148. this.style = AnnotationBorderStyleType.DASHED;
  39149. break;
  39150. case 'B':
  39151. this.style = AnnotationBorderStyleType.BEVELED;
  39152. break;
  39153. case 'I':
  39154. this.style = AnnotationBorderStyleType.INSET;
  39155. break;
  39156. case 'U':
  39157. this.style = AnnotationBorderStyleType.UNDERLINE;
  39158. break;
  39159. default:
  39160. break;
  39161. }
  39162. },
  39163. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39164. if (isArray(dashArray) && dashArray.length > 0) {
  39165. var isValid = true;
  39166. var allZeros = true;
  39167. for (var i = 0, len = dashArray.length; i < len; i++) {
  39168. var element = dashArray[i];
  39169. var validNumber = +element >= 0;
  39170. if (!validNumber) {
  39171. isValid = false;
  39172. break;
  39173. } else if (element > 0) {
  39174. allZeros = false;
  39175. }
  39176. }
  39177. if (isValid && !allZeros) {
  39178. this.dashArray = dashArray;
  39179. } else {
  39180. this.width = 0;
  39181. }
  39182. } else if (dashArray) {
  39183. this.width = 0;
  39184. }
  39185. },
  39186. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39187. if (radius === (radius | 0)) {
  39188. this.horizontalCornerRadius = radius;
  39189. }
  39190. },
  39191. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39192. if (radius === (radius | 0)) {
  39193. this.verticalCornerRadius = radius;
  39194. }
  39195. }
  39196. };
  39197. return AnnotationBorderStyle;
  39198. }();
  39199. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39200. function WidgetAnnotation(params) {
  39201. Annotation.call(this, params);
  39202. var dict = params.dict;
  39203. var data = this.data;
  39204. data.annotationType = AnnotationType.WIDGET;
  39205. data.fieldName = this._constructFieldName(dict);
  39206. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39207. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39208. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39209. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39210. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39211. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39212. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39213. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39214. data.fieldFlags = 0;
  39215. }
  39216. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39217. if (data.fieldType === 'Sig') {
  39218. this.setFlags(AnnotationFlag.HIDDEN);
  39219. }
  39220. }
  39221. Util.inherit(WidgetAnnotation, Annotation, {
  39222. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39223. if (!dict.has('T') && !dict.has('Parent')) {
  39224. warn('Unknown field name, falling back to empty field name.');
  39225. return '';
  39226. }
  39227. if (!dict.has('Parent')) {
  39228. return stringToPDFString(dict.get('T'));
  39229. }
  39230. var fieldName = [];
  39231. if (dict.has('T')) {
  39232. fieldName.unshift(stringToPDFString(dict.get('T')));
  39233. }
  39234. var loopDict = dict;
  39235. while (loopDict.has('Parent')) {
  39236. loopDict = loopDict.get('Parent');
  39237. if (!isDict(loopDict)) {
  39238. break;
  39239. }
  39240. if (loopDict.has('T')) {
  39241. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  39242. }
  39243. }
  39244. return fieldName.join('.');
  39245. },
  39246. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  39247. return !!(this.data.fieldFlags & flag);
  39248. }
  39249. });
  39250. return WidgetAnnotation;
  39251. }();
  39252. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  39253. function TextWidgetAnnotation(params) {
  39254. WidgetAnnotation.call(this, params);
  39255. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  39256. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  39257. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  39258. alignment = null;
  39259. }
  39260. this.data.textAlignment = alignment;
  39261. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  39262. if (!isInt(maximumLength) || maximumLength < 0) {
  39263. maximumLength = null;
  39264. }
  39265. this.data.maxLen = maximumLength;
  39266. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  39267. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  39268. }
  39269. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  39270. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39271. var operatorList = new OperatorList();
  39272. if (renderForms) {
  39273. return Promise.resolve(operatorList);
  39274. }
  39275. if (this.appearance) {
  39276. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39277. }
  39278. if (!this.data.defaultAppearance) {
  39279. return Promise.resolve(operatorList);
  39280. }
  39281. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  39282. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  39283. return operatorList;
  39284. });
  39285. }
  39286. });
  39287. return TextWidgetAnnotation;
  39288. }();
  39289. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  39290. function ButtonWidgetAnnotation(params) {
  39291. WidgetAnnotation.call(this, params);
  39292. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39293. if (this.data.checkBox) {
  39294. if (!isName(this.data.fieldValue)) {
  39295. return;
  39296. }
  39297. this.data.fieldValue = this.data.fieldValue.name;
  39298. }
  39299. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39300. if (this.data.radioButton) {
  39301. this.data.fieldValue = this.data.buttonValue = null;
  39302. var fieldParent = params.dict.get('Parent');
  39303. if (isDict(fieldParent) && fieldParent.has('V')) {
  39304. var fieldParentValue = fieldParent.get('V');
  39305. if (isName(fieldParentValue)) {
  39306. this.data.fieldValue = fieldParentValue.name;
  39307. }
  39308. }
  39309. var appearanceStates = params.dict.get('AP');
  39310. if (!isDict(appearanceStates)) {
  39311. return;
  39312. }
  39313. var normalAppearanceState = appearanceStates.get('N');
  39314. if (!isDict(normalAppearanceState)) {
  39315. return;
  39316. }
  39317. var keys = normalAppearanceState.getKeys();
  39318. for (var i = 0, ii = keys.length; i < ii; i++) {
  39319. if (keys[i] !== 'Off') {
  39320. this.data.buttonValue = keys[i];
  39321. break;
  39322. }
  39323. }
  39324. }
  39325. }
  39326. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  39327. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39328. var operatorList = new OperatorList();
  39329. if (renderForms) {
  39330. return Promise.resolve(operatorList);
  39331. }
  39332. if (this.appearance) {
  39333. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39334. }
  39335. return Promise.resolve(operatorList);
  39336. }
  39337. });
  39338. return ButtonWidgetAnnotation;
  39339. }();
  39340. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  39341. function ChoiceWidgetAnnotation(params) {
  39342. WidgetAnnotation.call(this, params);
  39343. this.data.options = [];
  39344. var options = Util.getInheritableProperty(params.dict, 'Opt');
  39345. if (isArray(options)) {
  39346. var xref = params.xref;
  39347. for (var i = 0, ii = options.length; i < ii; i++) {
  39348. var option = xref.fetchIfRef(options[i]);
  39349. var isOptionArray = isArray(option);
  39350. this.data.options[i] = {
  39351. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  39352. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  39353. };
  39354. }
  39355. }
  39356. if (!isArray(this.data.fieldValue)) {
  39357. this.data.fieldValue = [this.data.fieldValue];
  39358. }
  39359. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  39360. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  39361. }
  39362. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  39363. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39364. var operatorList = new OperatorList();
  39365. if (renderForms) {
  39366. return Promise.resolve(operatorList);
  39367. }
  39368. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39369. }
  39370. });
  39371. return ChoiceWidgetAnnotation;
  39372. }();
  39373. var TextAnnotation = function TextAnnotationClosure() {
  39374. var DEFAULT_ICON_SIZE = 22;
  39375. function TextAnnotation(parameters) {
  39376. Annotation.call(this, parameters);
  39377. this.data.annotationType = AnnotationType.TEXT;
  39378. if (this.data.hasAppearance) {
  39379. this.data.name = 'NoIcon';
  39380. } else {
  39381. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  39382. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  39383. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  39384. }
  39385. this._preparePopup(parameters.dict);
  39386. }
  39387. Util.inherit(TextAnnotation, Annotation, {});
  39388. return TextAnnotation;
  39389. }();
  39390. var LinkAnnotation = function LinkAnnotationClosure() {
  39391. function LinkAnnotation(params) {
  39392. Annotation.call(this, params);
  39393. var data = this.data;
  39394. data.annotationType = AnnotationType.LINK;
  39395. Catalog.parseDestDictionary({
  39396. destDict: params.dict,
  39397. resultObj: data,
  39398. docBaseUrl: params.pdfManager.docBaseUrl
  39399. });
  39400. }
  39401. Util.inherit(LinkAnnotation, Annotation, {});
  39402. return LinkAnnotation;
  39403. }();
  39404. var PopupAnnotation = function PopupAnnotationClosure() {
  39405. function PopupAnnotation(parameters) {
  39406. Annotation.call(this, parameters);
  39407. this.data.annotationType = AnnotationType.POPUP;
  39408. var dict = parameters.dict;
  39409. var parentItem = dict.get('Parent');
  39410. if (!parentItem) {
  39411. warn('Popup annotation has a missing or invalid parent annotation.');
  39412. return;
  39413. }
  39414. this.data.parentId = dict.getRaw('Parent').toString();
  39415. this.data.title = stringToPDFString(parentItem.get('T') || '');
  39416. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  39417. if (!parentItem.has('C')) {
  39418. this.data.color = null;
  39419. } else {
  39420. this.setColor(parentItem.getArray('C'));
  39421. this.data.color = this.color;
  39422. }
  39423. if (!this.viewable) {
  39424. var parentFlags = parentItem.get('F');
  39425. if (this._isViewable(parentFlags)) {
  39426. this.setFlags(parentFlags);
  39427. }
  39428. }
  39429. }
  39430. Util.inherit(PopupAnnotation, Annotation, {});
  39431. return PopupAnnotation;
  39432. }();
  39433. var HighlightAnnotation = function HighlightAnnotationClosure() {
  39434. function HighlightAnnotation(parameters) {
  39435. Annotation.call(this, parameters);
  39436. this.data.annotationType = AnnotationType.HIGHLIGHT;
  39437. this._preparePopup(parameters.dict);
  39438. this.data.borderStyle.setWidth(0);
  39439. }
  39440. Util.inherit(HighlightAnnotation, Annotation, {});
  39441. return HighlightAnnotation;
  39442. }();
  39443. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  39444. function UnderlineAnnotation(parameters) {
  39445. Annotation.call(this, parameters);
  39446. this.data.annotationType = AnnotationType.UNDERLINE;
  39447. this._preparePopup(parameters.dict);
  39448. this.data.borderStyle.setWidth(0);
  39449. }
  39450. Util.inherit(UnderlineAnnotation, Annotation, {});
  39451. return UnderlineAnnotation;
  39452. }();
  39453. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  39454. function SquigglyAnnotation(parameters) {
  39455. Annotation.call(this, parameters);
  39456. this.data.annotationType = AnnotationType.SQUIGGLY;
  39457. this._preparePopup(parameters.dict);
  39458. this.data.borderStyle.setWidth(0);
  39459. }
  39460. Util.inherit(SquigglyAnnotation, Annotation, {});
  39461. return SquigglyAnnotation;
  39462. }();
  39463. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  39464. function StrikeOutAnnotation(parameters) {
  39465. Annotation.call(this, parameters);
  39466. this.data.annotationType = AnnotationType.STRIKEOUT;
  39467. this._preparePopup(parameters.dict);
  39468. this.data.borderStyle.setWidth(0);
  39469. }
  39470. Util.inherit(StrikeOutAnnotation, Annotation, {});
  39471. return StrikeOutAnnotation;
  39472. }();
  39473. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  39474. function FileAttachmentAnnotation(parameters) {
  39475. Annotation.call(this, parameters);
  39476. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  39477. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  39478. this.data.file = file.serializable;
  39479. this._preparePopup(parameters.dict);
  39480. }
  39481. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  39482. return FileAttachmentAnnotation;
  39483. }();
  39484. exports.Annotation = Annotation;
  39485. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  39486. exports.AnnotationFactory = AnnotationFactory;
  39487. /***/ }),
  39488. /* 28 */
  39489. /***/ (function(module, exports, __w_pdfjs_require__) {
  39490. "use strict";
  39491. var sharedUtil = __w_pdfjs_require__(0);
  39492. var warn = sharedUtil.warn;
  39493. var baseTypes = [
  39494. 'BN',
  39495. 'BN',
  39496. 'BN',
  39497. 'BN',
  39498. 'BN',
  39499. 'BN',
  39500. 'BN',
  39501. 'BN',
  39502. 'BN',
  39503. 'S',
  39504. 'B',
  39505. 'S',
  39506. 'WS',
  39507. 'B',
  39508. 'BN',
  39509. 'BN',
  39510. 'BN',
  39511. 'BN',
  39512. 'BN',
  39513. 'BN',
  39514. 'BN',
  39515. 'BN',
  39516. 'BN',
  39517. 'BN',
  39518. 'BN',
  39519. 'BN',
  39520. 'BN',
  39521. 'BN',
  39522. 'B',
  39523. 'B',
  39524. 'B',
  39525. 'S',
  39526. 'WS',
  39527. 'ON',
  39528. 'ON',
  39529. 'ET',
  39530. 'ET',
  39531. 'ET',
  39532. 'ON',
  39533. 'ON',
  39534. 'ON',
  39535. 'ON',
  39536. 'ON',
  39537. 'ES',
  39538. 'CS',
  39539. 'ES',
  39540. 'CS',
  39541. 'CS',
  39542. 'EN',
  39543. 'EN',
  39544. 'EN',
  39545. 'EN',
  39546. 'EN',
  39547. 'EN',
  39548. 'EN',
  39549. 'EN',
  39550. 'EN',
  39551. 'EN',
  39552. 'CS',
  39553. 'ON',
  39554. 'ON',
  39555. 'ON',
  39556. 'ON',
  39557. 'ON',
  39558. 'ON',
  39559. 'L',
  39560. 'L',
  39561. 'L',
  39562. 'L',
  39563. 'L',
  39564. 'L',
  39565. 'L',
  39566. 'L',
  39567. 'L',
  39568. 'L',
  39569. 'L',
  39570. 'L',
  39571. 'L',
  39572. 'L',
  39573. 'L',
  39574. 'L',
  39575. 'L',
  39576. 'L',
  39577. 'L',
  39578. 'L',
  39579. 'L',
  39580. 'L',
  39581. 'L',
  39582. 'L',
  39583. 'L',
  39584. 'L',
  39585. 'ON',
  39586. 'ON',
  39587. 'ON',
  39588. 'ON',
  39589. 'ON',
  39590. 'ON',
  39591. 'L',
  39592. 'L',
  39593. 'L',
  39594. 'L',
  39595. 'L',
  39596. 'L',
  39597. 'L',
  39598. 'L',
  39599. 'L',
  39600. 'L',
  39601. 'L',
  39602. 'L',
  39603. 'L',
  39604. 'L',
  39605. 'L',
  39606. 'L',
  39607. 'L',
  39608. 'L',
  39609. 'L',
  39610. 'L',
  39611. 'L',
  39612. 'L',
  39613. 'L',
  39614. 'L',
  39615. 'L',
  39616. 'L',
  39617. 'ON',
  39618. 'ON',
  39619. 'ON',
  39620. 'ON',
  39621. 'BN',
  39622. 'BN',
  39623. 'BN',
  39624. 'BN',
  39625. 'BN',
  39626. 'BN',
  39627. 'B',
  39628. 'BN',
  39629. 'BN',
  39630. 'BN',
  39631. 'BN',
  39632. 'BN',
  39633. 'BN',
  39634. 'BN',
  39635. 'BN',
  39636. 'BN',
  39637. 'BN',
  39638. 'BN',
  39639. 'BN',
  39640. 'BN',
  39641. 'BN',
  39642. 'BN',
  39643. 'BN',
  39644. 'BN',
  39645. 'BN',
  39646. 'BN',
  39647. 'BN',
  39648. 'BN',
  39649. 'BN',
  39650. 'BN',
  39651. 'BN',
  39652. 'BN',
  39653. 'BN',
  39654. 'CS',
  39655. 'ON',
  39656. 'ET',
  39657. 'ET',
  39658. 'ET',
  39659. 'ET',
  39660. 'ON',
  39661. 'ON',
  39662. 'ON',
  39663. 'ON',
  39664. 'L',
  39665. 'ON',
  39666. 'ON',
  39667. 'BN',
  39668. 'ON',
  39669. 'ON',
  39670. 'ET',
  39671. 'ET',
  39672. 'EN',
  39673. 'EN',
  39674. 'ON',
  39675. 'L',
  39676. 'ON',
  39677. 'ON',
  39678. 'ON',
  39679. 'EN',
  39680. 'L',
  39681. 'ON',
  39682. 'ON',
  39683. 'ON',
  39684. 'ON',
  39685. 'ON',
  39686. 'L',
  39687. 'L',
  39688. 'L',
  39689. 'L',
  39690. 'L',
  39691. 'L',
  39692. 'L',
  39693. 'L',
  39694. 'L',
  39695. 'L',
  39696. 'L',
  39697. 'L',
  39698. 'L',
  39699. 'L',
  39700. 'L',
  39701. 'L',
  39702. 'L',
  39703. 'L',
  39704. 'L',
  39705. 'L',
  39706. 'L',
  39707. 'L',
  39708. 'L',
  39709. 'ON',
  39710. 'L',
  39711. 'L',
  39712. 'L',
  39713. 'L',
  39714. 'L',
  39715. 'L',
  39716. 'L',
  39717. 'L',
  39718. 'L',
  39719. 'L',
  39720. 'L',
  39721. 'L',
  39722. 'L',
  39723. 'L',
  39724. 'L',
  39725. 'L',
  39726. 'L',
  39727. 'L',
  39728. 'L',
  39729. 'L',
  39730. 'L',
  39731. 'L',
  39732. 'L',
  39733. 'L',
  39734. 'L',
  39735. 'L',
  39736. 'L',
  39737. 'L',
  39738. 'L',
  39739. 'L',
  39740. 'L',
  39741. 'ON',
  39742. 'L',
  39743. 'L',
  39744. 'L',
  39745. 'L',
  39746. 'L',
  39747. 'L',
  39748. 'L',
  39749. 'L'
  39750. ];
  39751. var arabicTypes = [
  39752. 'AN',
  39753. 'AN',
  39754. 'AN',
  39755. 'AN',
  39756. 'AN',
  39757. 'AN',
  39758. 'ON',
  39759. 'ON',
  39760. 'AL',
  39761. 'ET',
  39762. 'ET',
  39763. 'AL',
  39764. 'CS',
  39765. 'AL',
  39766. 'ON',
  39767. 'ON',
  39768. 'NSM',
  39769. 'NSM',
  39770. 'NSM',
  39771. 'NSM',
  39772. 'NSM',
  39773. 'NSM',
  39774. 'NSM',
  39775. 'NSM',
  39776. 'NSM',
  39777. 'NSM',
  39778. 'NSM',
  39779. 'AL',
  39780. 'AL',
  39781. '',
  39782. 'AL',
  39783. 'AL',
  39784. 'AL',
  39785. 'AL',
  39786. 'AL',
  39787. 'AL',
  39788. 'AL',
  39789. 'AL',
  39790. 'AL',
  39791. 'AL',
  39792. 'AL',
  39793. 'AL',
  39794. 'AL',
  39795. 'AL',
  39796. 'AL',
  39797. 'AL',
  39798. 'AL',
  39799. 'AL',
  39800. 'AL',
  39801. 'AL',
  39802. 'AL',
  39803. 'AL',
  39804. 'AL',
  39805. 'AL',
  39806. 'AL',
  39807. 'AL',
  39808. 'AL',
  39809. 'AL',
  39810. 'AL',
  39811. 'AL',
  39812. 'AL',
  39813. 'AL',
  39814. 'AL',
  39815. 'AL',
  39816. 'AL',
  39817. 'AL',
  39818. 'AL',
  39819. 'AL',
  39820. 'AL',
  39821. 'AL',
  39822. 'AL',
  39823. 'AL',
  39824. 'AL',
  39825. 'AL',
  39826. 'AL',
  39827. 'NSM',
  39828. 'NSM',
  39829. 'NSM',
  39830. 'NSM',
  39831. 'NSM',
  39832. 'NSM',
  39833. 'NSM',
  39834. 'NSM',
  39835. 'NSM',
  39836. 'NSM',
  39837. 'NSM',
  39838. 'NSM',
  39839. 'NSM',
  39840. 'NSM',
  39841. 'NSM',
  39842. 'NSM',
  39843. 'NSM',
  39844. 'NSM',
  39845. 'NSM',
  39846. 'NSM',
  39847. 'NSM',
  39848. 'AN',
  39849. 'AN',
  39850. 'AN',
  39851. 'AN',
  39852. 'AN',
  39853. 'AN',
  39854. 'AN',
  39855. 'AN',
  39856. 'AN',
  39857. 'AN',
  39858. 'ET',
  39859. 'AN',
  39860. 'AN',
  39861. 'AL',
  39862. 'AL',
  39863. 'AL',
  39864. 'NSM',
  39865. 'AL',
  39866. 'AL',
  39867. 'AL',
  39868. 'AL',
  39869. 'AL',
  39870. 'AL',
  39871. 'AL',
  39872. 'AL',
  39873. 'AL',
  39874. 'AL',
  39875. 'AL',
  39876. 'AL',
  39877. 'AL',
  39878. 'AL',
  39879. 'AL',
  39880. 'AL',
  39881. 'AL',
  39882. 'AL',
  39883. 'AL',
  39884. 'AL',
  39885. 'AL',
  39886. 'AL',
  39887. 'AL',
  39888. 'AL',
  39889. 'AL',
  39890. 'AL',
  39891. 'AL',
  39892. 'AL',
  39893. 'AL',
  39894. 'AL',
  39895. 'AL',
  39896. 'AL',
  39897. 'AL',
  39898. 'AL',
  39899. 'AL',
  39900. 'AL',
  39901. 'AL',
  39902. 'AL',
  39903. 'AL',
  39904. 'AL',
  39905. 'AL',
  39906. 'AL',
  39907. 'AL',
  39908. 'AL',
  39909. 'AL',
  39910. 'AL',
  39911. 'AL',
  39912. 'AL',
  39913. 'AL',
  39914. 'AL',
  39915. 'AL',
  39916. 'AL',
  39917. 'AL',
  39918. 'AL',
  39919. 'AL',
  39920. 'AL',
  39921. 'AL',
  39922. 'AL',
  39923. 'AL',
  39924. 'AL',
  39925. 'AL',
  39926. 'AL',
  39927. 'AL',
  39928. 'AL',
  39929. 'AL',
  39930. 'AL',
  39931. 'AL',
  39932. 'AL',
  39933. 'AL',
  39934. 'AL',
  39935. 'AL',
  39936. 'AL',
  39937. 'AL',
  39938. 'AL',
  39939. 'AL',
  39940. 'AL',
  39941. 'AL',
  39942. 'AL',
  39943. 'AL',
  39944. 'AL',
  39945. 'AL',
  39946. 'AL',
  39947. 'AL',
  39948. 'AL',
  39949. 'AL',
  39950. 'AL',
  39951. 'AL',
  39952. 'AL',
  39953. 'AL',
  39954. 'AL',
  39955. 'AL',
  39956. 'AL',
  39957. 'AL',
  39958. 'AL',
  39959. 'AL',
  39960. 'AL',
  39961. 'AL',
  39962. 'AL',
  39963. 'AL',
  39964. 'AL',
  39965. 'AL',
  39966. 'NSM',
  39967. 'NSM',
  39968. 'NSM',
  39969. 'NSM',
  39970. 'NSM',
  39971. 'NSM',
  39972. 'NSM',
  39973. 'AN',
  39974. 'ON',
  39975. 'NSM',
  39976. 'NSM',
  39977. 'NSM',
  39978. 'NSM',
  39979. 'NSM',
  39980. 'NSM',
  39981. 'AL',
  39982. 'AL',
  39983. 'NSM',
  39984. 'NSM',
  39985. 'ON',
  39986. 'NSM',
  39987. 'NSM',
  39988. 'NSM',
  39989. 'NSM',
  39990. 'AL',
  39991. 'AL',
  39992. 'EN',
  39993. 'EN',
  39994. 'EN',
  39995. 'EN',
  39996. 'EN',
  39997. 'EN',
  39998. 'EN',
  39999. 'EN',
  40000. 'EN',
  40001. 'EN',
  40002. 'AL',
  40003. 'AL',
  40004. 'AL',
  40005. 'AL',
  40006. 'AL',
  40007. 'AL'
  40008. ];
  40009. function isOdd(i) {
  40010. return (i & 1) !== 0;
  40011. }
  40012. function isEven(i) {
  40013. return (i & 1) === 0;
  40014. }
  40015. function findUnequal(arr, start, value) {
  40016. for (var j = start, jj = arr.length; j < jj; ++j) {
  40017. if (arr[j] !== value) {
  40018. return j;
  40019. }
  40020. }
  40021. return j;
  40022. }
  40023. function setValues(arr, start, end, value) {
  40024. for (var j = start; j < end; ++j) {
  40025. arr[j] = value;
  40026. }
  40027. }
  40028. function reverseValues(arr, start, end) {
  40029. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40030. var temp = arr[i];
  40031. arr[i] = arr[j];
  40032. arr[j] = temp;
  40033. }
  40034. }
  40035. function createBidiText(str, isLTR, vertical) {
  40036. return {
  40037. str: str,
  40038. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40039. };
  40040. }
  40041. var chars = [];
  40042. var types = [];
  40043. function bidi(str, startLevel, vertical) {
  40044. var isLTR = true;
  40045. var strLength = str.length;
  40046. if (strLength === 0 || vertical) {
  40047. return createBidiText(str, isLTR, vertical);
  40048. }
  40049. chars.length = strLength;
  40050. types.length = strLength;
  40051. var numBidi = 0;
  40052. var i, ii;
  40053. for (i = 0; i < strLength; ++i) {
  40054. chars[i] = str.charAt(i);
  40055. var charCode = str.charCodeAt(i);
  40056. var charType = 'L';
  40057. if (charCode <= 0x00ff) {
  40058. charType = baseTypes[charCode];
  40059. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40060. charType = 'R';
  40061. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40062. charType = arabicTypes[charCode & 0xff];
  40063. if (!charType) {
  40064. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40065. }
  40066. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40067. charType = 'AL';
  40068. }
  40069. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40070. numBidi++;
  40071. }
  40072. types[i] = charType;
  40073. }
  40074. if (numBidi === 0) {
  40075. isLTR = true;
  40076. return createBidiText(str, isLTR);
  40077. }
  40078. if (startLevel === -1) {
  40079. if (numBidi / strLength < 0.3) {
  40080. isLTR = true;
  40081. startLevel = 0;
  40082. } else {
  40083. isLTR = false;
  40084. startLevel = 1;
  40085. }
  40086. }
  40087. var levels = [];
  40088. for (i = 0; i < strLength; ++i) {
  40089. levels[i] = startLevel;
  40090. }
  40091. var e = isOdd(startLevel) ? 'R' : 'L';
  40092. var sor = e;
  40093. var eor = sor;
  40094. var lastType = sor;
  40095. for (i = 0; i < strLength; ++i) {
  40096. if (types[i] === 'NSM') {
  40097. types[i] = lastType;
  40098. } else {
  40099. lastType = types[i];
  40100. }
  40101. }
  40102. lastType = sor;
  40103. var t;
  40104. for (i = 0; i < strLength; ++i) {
  40105. t = types[i];
  40106. if (t === 'EN') {
  40107. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40108. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40109. lastType = t;
  40110. }
  40111. }
  40112. for (i = 0; i < strLength; ++i) {
  40113. t = types[i];
  40114. if (t === 'AL') {
  40115. types[i] = 'R';
  40116. }
  40117. }
  40118. for (i = 1; i < strLength - 1; ++i) {
  40119. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40120. types[i] = 'EN';
  40121. }
  40122. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40123. types[i] = types[i - 1];
  40124. }
  40125. }
  40126. for (i = 0; i < strLength; ++i) {
  40127. if (types[i] === 'EN') {
  40128. var j;
  40129. for (j = i - 1; j >= 0; --j) {
  40130. if (types[j] !== 'ET') {
  40131. break;
  40132. }
  40133. types[j] = 'EN';
  40134. }
  40135. for (j = i + 1; j < strLength; ++j) {
  40136. if (types[j] !== 'ET') {
  40137. break;
  40138. }
  40139. types[j] = 'EN';
  40140. }
  40141. }
  40142. }
  40143. for (i = 0; i < strLength; ++i) {
  40144. t = types[i];
  40145. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40146. types[i] = 'ON';
  40147. }
  40148. }
  40149. lastType = sor;
  40150. for (i = 0; i < strLength; ++i) {
  40151. t = types[i];
  40152. if (t === 'EN') {
  40153. types[i] = lastType === 'L' ? 'L' : 'EN';
  40154. } else if (t === 'R' || t === 'L') {
  40155. lastType = t;
  40156. }
  40157. }
  40158. for (i = 0; i < strLength; ++i) {
  40159. if (types[i] === 'ON') {
  40160. var end = findUnequal(types, i + 1, 'ON');
  40161. var before = sor;
  40162. if (i > 0) {
  40163. before = types[i - 1];
  40164. }
  40165. var after = eor;
  40166. if (end + 1 < strLength) {
  40167. after = types[end + 1];
  40168. }
  40169. if (before !== 'L') {
  40170. before = 'R';
  40171. }
  40172. if (after !== 'L') {
  40173. after = 'R';
  40174. }
  40175. if (before === after) {
  40176. setValues(types, i, end, before);
  40177. }
  40178. i = end - 1;
  40179. }
  40180. }
  40181. for (i = 0; i < strLength; ++i) {
  40182. if (types[i] === 'ON') {
  40183. types[i] = e;
  40184. }
  40185. }
  40186. for (i = 0; i < strLength; ++i) {
  40187. t = types[i];
  40188. if (isEven(levels[i])) {
  40189. if (t === 'R') {
  40190. levels[i] += 1;
  40191. } else if (t === 'AN' || t === 'EN') {
  40192. levels[i] += 2;
  40193. }
  40194. } else {
  40195. if (t === 'L' || t === 'AN' || t === 'EN') {
  40196. levels[i] += 1;
  40197. }
  40198. }
  40199. }
  40200. var highestLevel = -1;
  40201. var lowestOddLevel = 99;
  40202. var level;
  40203. for (i = 0, ii = levels.length; i < ii; ++i) {
  40204. level = levels[i];
  40205. if (highestLevel < level) {
  40206. highestLevel = level;
  40207. }
  40208. if (lowestOddLevel > level && isOdd(level)) {
  40209. lowestOddLevel = level;
  40210. }
  40211. }
  40212. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40213. var start = -1;
  40214. for (i = 0, ii = levels.length; i < ii; ++i) {
  40215. if (levels[i] < level) {
  40216. if (start >= 0) {
  40217. reverseValues(chars, start, i);
  40218. start = -1;
  40219. }
  40220. } else if (start < 0) {
  40221. start = i;
  40222. }
  40223. }
  40224. if (start >= 0) {
  40225. reverseValues(chars, start, levels.length);
  40226. }
  40227. }
  40228. for (i = 0, ii = chars.length; i < ii; ++i) {
  40229. var ch = chars[i];
  40230. if (ch === '<' || ch === '>') {
  40231. chars[i] = '';
  40232. }
  40233. }
  40234. return createBidiText(chars.join(''), isLTR);
  40235. }
  40236. exports.bidi = bidi;
  40237. /***/ }),
  40238. /* 29 */
  40239. /***/ (function(module, exports, __w_pdfjs_require__) {
  40240. "use strict";
  40241. var ISOAdobeCharset = [
  40242. '.notdef',
  40243. 'space',
  40244. 'exclam',
  40245. 'quotedbl',
  40246. 'numbersign',
  40247. 'dollar',
  40248. 'percent',
  40249. 'ampersand',
  40250. 'quoteright',
  40251. 'parenleft',
  40252. 'parenright',
  40253. 'asterisk',
  40254. 'plus',
  40255. 'comma',
  40256. 'hyphen',
  40257. 'period',
  40258. 'slash',
  40259. 'zero',
  40260. 'one',
  40261. 'two',
  40262. 'three',
  40263. 'four',
  40264. 'five',
  40265. 'six',
  40266. 'seven',
  40267. 'eight',
  40268. 'nine',
  40269. 'colon',
  40270. 'semicolon',
  40271. 'less',
  40272. 'equal',
  40273. 'greater',
  40274. 'question',
  40275. 'at',
  40276. 'A',
  40277. 'B',
  40278. 'C',
  40279. 'D',
  40280. 'E',
  40281. 'F',
  40282. 'G',
  40283. 'H',
  40284. 'I',
  40285. 'J',
  40286. 'K',
  40287. 'L',
  40288. 'M',
  40289. 'N',
  40290. 'O',
  40291. 'P',
  40292. 'Q',
  40293. 'R',
  40294. 'S',
  40295. 'T',
  40296. 'U',
  40297. 'V',
  40298. 'W',
  40299. 'X',
  40300. 'Y',
  40301. 'Z',
  40302. 'bracketleft',
  40303. 'backslash',
  40304. 'bracketright',
  40305. 'asciicircum',
  40306. 'underscore',
  40307. 'quoteleft',
  40308. 'a',
  40309. 'b',
  40310. 'c',
  40311. 'd',
  40312. 'e',
  40313. 'f',
  40314. 'g',
  40315. 'h',
  40316. 'i',
  40317. 'j',
  40318. 'k',
  40319. 'l',
  40320. 'm',
  40321. 'n',
  40322. 'o',
  40323. 'p',
  40324. 'q',
  40325. 'r',
  40326. 's',
  40327. 't',
  40328. 'u',
  40329. 'v',
  40330. 'w',
  40331. 'x',
  40332. 'y',
  40333. 'z',
  40334. 'braceleft',
  40335. 'bar',
  40336. 'braceright',
  40337. 'asciitilde',
  40338. 'exclamdown',
  40339. 'cent',
  40340. 'sterling',
  40341. 'fraction',
  40342. 'yen',
  40343. 'florin',
  40344. 'section',
  40345. 'currency',
  40346. 'quotesingle',
  40347. 'quotedblleft',
  40348. 'guillemotleft',
  40349. 'guilsinglleft',
  40350. 'guilsinglright',
  40351. 'fi',
  40352. 'fl',
  40353. 'endash',
  40354. 'dagger',
  40355. 'daggerdbl',
  40356. 'periodcentered',
  40357. 'paragraph',
  40358. 'bullet',
  40359. 'quotesinglbase',
  40360. 'quotedblbase',
  40361. 'quotedblright',
  40362. 'guillemotright',
  40363. 'ellipsis',
  40364. 'perthousand',
  40365. 'questiondown',
  40366. 'grave',
  40367. 'acute',
  40368. 'circumflex',
  40369. 'tilde',
  40370. 'macron',
  40371. 'breve',
  40372. 'dotaccent',
  40373. 'dieresis',
  40374. 'ring',
  40375. 'cedilla',
  40376. 'hungarumlaut',
  40377. 'ogonek',
  40378. 'caron',
  40379. 'emdash',
  40380. 'AE',
  40381. 'ordfeminine',
  40382. 'Lslash',
  40383. 'Oslash',
  40384. 'OE',
  40385. 'ordmasculine',
  40386. 'ae',
  40387. 'dotlessi',
  40388. 'lslash',
  40389. 'oslash',
  40390. 'oe',
  40391. 'germandbls',
  40392. 'onesuperior',
  40393. 'logicalnot',
  40394. 'mu',
  40395. 'trademark',
  40396. 'Eth',
  40397. 'onehalf',
  40398. 'plusminus',
  40399. 'Thorn',
  40400. 'onequarter',
  40401. 'divide',
  40402. 'brokenbar',
  40403. 'degree',
  40404. 'thorn',
  40405. 'threequarters',
  40406. 'twosuperior',
  40407. 'registered',
  40408. 'minus',
  40409. 'eth',
  40410. 'multiply',
  40411. 'threesuperior',
  40412. 'copyright',
  40413. 'Aacute',
  40414. 'Acircumflex',
  40415. 'Adieresis',
  40416. 'Agrave',
  40417. 'Aring',
  40418. 'Atilde',
  40419. 'Ccedilla',
  40420. 'Eacute',
  40421. 'Ecircumflex',
  40422. 'Edieresis',
  40423. 'Egrave',
  40424. 'Iacute',
  40425. 'Icircumflex',
  40426. 'Idieresis',
  40427. 'Igrave',
  40428. 'Ntilde',
  40429. 'Oacute',
  40430. 'Ocircumflex',
  40431. 'Odieresis',
  40432. 'Ograve',
  40433. 'Otilde',
  40434. 'Scaron',
  40435. 'Uacute',
  40436. 'Ucircumflex',
  40437. 'Udieresis',
  40438. 'Ugrave',
  40439. 'Yacute',
  40440. 'Ydieresis',
  40441. 'Zcaron',
  40442. 'aacute',
  40443. 'acircumflex',
  40444. 'adieresis',
  40445. 'agrave',
  40446. 'aring',
  40447. 'atilde',
  40448. 'ccedilla',
  40449. 'eacute',
  40450. 'ecircumflex',
  40451. 'edieresis',
  40452. 'egrave',
  40453. 'iacute',
  40454. 'icircumflex',
  40455. 'idieresis',
  40456. 'igrave',
  40457. 'ntilde',
  40458. 'oacute',
  40459. 'ocircumflex',
  40460. 'odieresis',
  40461. 'ograve',
  40462. 'otilde',
  40463. 'scaron',
  40464. 'uacute',
  40465. 'ucircumflex',
  40466. 'udieresis',
  40467. 'ugrave',
  40468. 'yacute',
  40469. 'ydieresis',
  40470. 'zcaron'
  40471. ];
  40472. var ExpertCharset = [
  40473. '.notdef',
  40474. 'space',
  40475. 'exclamsmall',
  40476. 'Hungarumlautsmall',
  40477. 'dollaroldstyle',
  40478. 'dollarsuperior',
  40479. 'ampersandsmall',
  40480. 'Acutesmall',
  40481. 'parenleftsuperior',
  40482. 'parenrightsuperior',
  40483. 'twodotenleader',
  40484. 'onedotenleader',
  40485. 'comma',
  40486. 'hyphen',
  40487. 'period',
  40488. 'fraction',
  40489. 'zerooldstyle',
  40490. 'oneoldstyle',
  40491. 'twooldstyle',
  40492. 'threeoldstyle',
  40493. 'fouroldstyle',
  40494. 'fiveoldstyle',
  40495. 'sixoldstyle',
  40496. 'sevenoldstyle',
  40497. 'eightoldstyle',
  40498. 'nineoldstyle',
  40499. 'colon',
  40500. 'semicolon',
  40501. 'commasuperior',
  40502. 'threequartersemdash',
  40503. 'periodsuperior',
  40504. 'questionsmall',
  40505. 'asuperior',
  40506. 'bsuperior',
  40507. 'centsuperior',
  40508. 'dsuperior',
  40509. 'esuperior',
  40510. 'isuperior',
  40511. 'lsuperior',
  40512. 'msuperior',
  40513. 'nsuperior',
  40514. 'osuperior',
  40515. 'rsuperior',
  40516. 'ssuperior',
  40517. 'tsuperior',
  40518. 'ff',
  40519. 'fi',
  40520. 'fl',
  40521. 'ffi',
  40522. 'ffl',
  40523. 'parenleftinferior',
  40524. 'parenrightinferior',
  40525. 'Circumflexsmall',
  40526. 'hyphensuperior',
  40527. 'Gravesmall',
  40528. 'Asmall',
  40529. 'Bsmall',
  40530. 'Csmall',
  40531. 'Dsmall',
  40532. 'Esmall',
  40533. 'Fsmall',
  40534. 'Gsmall',
  40535. 'Hsmall',
  40536. 'Ismall',
  40537. 'Jsmall',
  40538. 'Ksmall',
  40539. 'Lsmall',
  40540. 'Msmall',
  40541. 'Nsmall',
  40542. 'Osmall',
  40543. 'Psmall',
  40544. 'Qsmall',
  40545. 'Rsmall',
  40546. 'Ssmall',
  40547. 'Tsmall',
  40548. 'Usmall',
  40549. 'Vsmall',
  40550. 'Wsmall',
  40551. 'Xsmall',
  40552. 'Ysmall',
  40553. 'Zsmall',
  40554. 'colonmonetary',
  40555. 'onefitted',
  40556. 'rupiah',
  40557. 'Tildesmall',
  40558. 'exclamdownsmall',
  40559. 'centoldstyle',
  40560. 'Lslashsmall',
  40561. 'Scaronsmall',
  40562. 'Zcaronsmall',
  40563. 'Dieresissmall',
  40564. 'Brevesmall',
  40565. 'Caronsmall',
  40566. 'Dotaccentsmall',
  40567. 'Macronsmall',
  40568. 'figuredash',
  40569. 'hypheninferior',
  40570. 'Ogoneksmall',
  40571. 'Ringsmall',
  40572. 'Cedillasmall',
  40573. 'onequarter',
  40574. 'onehalf',
  40575. 'threequarters',
  40576. 'questiondownsmall',
  40577. 'oneeighth',
  40578. 'threeeighths',
  40579. 'fiveeighths',
  40580. 'seveneighths',
  40581. 'onethird',
  40582. 'twothirds',
  40583. 'zerosuperior',
  40584. 'onesuperior',
  40585. 'twosuperior',
  40586. 'threesuperior',
  40587. 'foursuperior',
  40588. 'fivesuperior',
  40589. 'sixsuperior',
  40590. 'sevensuperior',
  40591. 'eightsuperior',
  40592. 'ninesuperior',
  40593. 'zeroinferior',
  40594. 'oneinferior',
  40595. 'twoinferior',
  40596. 'threeinferior',
  40597. 'fourinferior',
  40598. 'fiveinferior',
  40599. 'sixinferior',
  40600. 'seveninferior',
  40601. 'eightinferior',
  40602. 'nineinferior',
  40603. 'centinferior',
  40604. 'dollarinferior',
  40605. 'periodinferior',
  40606. 'commainferior',
  40607. 'Agravesmall',
  40608. 'Aacutesmall',
  40609. 'Acircumflexsmall',
  40610. 'Atildesmall',
  40611. 'Adieresissmall',
  40612. 'Aringsmall',
  40613. 'AEsmall',
  40614. 'Ccedillasmall',
  40615. 'Egravesmall',
  40616. 'Eacutesmall',
  40617. 'Ecircumflexsmall',
  40618. 'Edieresissmall',
  40619. 'Igravesmall',
  40620. 'Iacutesmall',
  40621. 'Icircumflexsmall',
  40622. 'Idieresissmall',
  40623. 'Ethsmall',
  40624. 'Ntildesmall',
  40625. 'Ogravesmall',
  40626. 'Oacutesmall',
  40627. 'Ocircumflexsmall',
  40628. 'Otildesmall',
  40629. 'Odieresissmall',
  40630. 'OEsmall',
  40631. 'Oslashsmall',
  40632. 'Ugravesmall',
  40633. 'Uacutesmall',
  40634. 'Ucircumflexsmall',
  40635. 'Udieresissmall',
  40636. 'Yacutesmall',
  40637. 'Thornsmall',
  40638. 'Ydieresissmall'
  40639. ];
  40640. var ExpertSubsetCharset = [
  40641. '.notdef',
  40642. 'space',
  40643. 'dollaroldstyle',
  40644. 'dollarsuperior',
  40645. 'parenleftsuperior',
  40646. 'parenrightsuperior',
  40647. 'twodotenleader',
  40648. 'onedotenleader',
  40649. 'comma',
  40650. 'hyphen',
  40651. 'period',
  40652. 'fraction',
  40653. 'zerooldstyle',
  40654. 'oneoldstyle',
  40655. 'twooldstyle',
  40656. 'threeoldstyle',
  40657. 'fouroldstyle',
  40658. 'fiveoldstyle',
  40659. 'sixoldstyle',
  40660. 'sevenoldstyle',
  40661. 'eightoldstyle',
  40662. 'nineoldstyle',
  40663. 'colon',
  40664. 'semicolon',
  40665. 'commasuperior',
  40666. 'threequartersemdash',
  40667. 'periodsuperior',
  40668. 'asuperior',
  40669. 'bsuperior',
  40670. 'centsuperior',
  40671. 'dsuperior',
  40672. 'esuperior',
  40673. 'isuperior',
  40674. 'lsuperior',
  40675. 'msuperior',
  40676. 'nsuperior',
  40677. 'osuperior',
  40678. 'rsuperior',
  40679. 'ssuperior',
  40680. 'tsuperior',
  40681. 'ff',
  40682. 'fi',
  40683. 'fl',
  40684. 'ffi',
  40685. 'ffl',
  40686. 'parenleftinferior',
  40687. 'parenrightinferior',
  40688. 'hyphensuperior',
  40689. 'colonmonetary',
  40690. 'onefitted',
  40691. 'rupiah',
  40692. 'centoldstyle',
  40693. 'figuredash',
  40694. 'hypheninferior',
  40695. 'onequarter',
  40696. 'onehalf',
  40697. 'threequarters',
  40698. 'oneeighth',
  40699. 'threeeighths',
  40700. 'fiveeighths',
  40701. 'seveneighths',
  40702. 'onethird',
  40703. 'twothirds',
  40704. 'zerosuperior',
  40705. 'onesuperior',
  40706. 'twosuperior',
  40707. 'threesuperior',
  40708. 'foursuperior',
  40709. 'fivesuperior',
  40710. 'sixsuperior',
  40711. 'sevensuperior',
  40712. 'eightsuperior',
  40713. 'ninesuperior',
  40714. 'zeroinferior',
  40715. 'oneinferior',
  40716. 'twoinferior',
  40717. 'threeinferior',
  40718. 'fourinferior',
  40719. 'fiveinferior',
  40720. 'sixinferior',
  40721. 'seveninferior',
  40722. 'eightinferior',
  40723. 'nineinferior',
  40724. 'centinferior',
  40725. 'dollarinferior',
  40726. 'periodinferior',
  40727. 'commainferior'
  40728. ];
  40729. exports.ISOAdobeCharset = ISOAdobeCharset;
  40730. exports.ExpertCharset = ExpertCharset;
  40731. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  40732. /***/ }),
  40733. /* 30 */
  40734. /***/ (function(module, exports, __w_pdfjs_require__) {
  40735. "use strict";
  40736. var sharedUtil = __w_pdfjs_require__(0);
  40737. var corePrimitives = __w_pdfjs_require__(1);
  40738. var coreStream = __w_pdfjs_require__(2);
  40739. var coreParser = __w_pdfjs_require__(6);
  40740. var Util = sharedUtil.Util;
  40741. var assert = sharedUtil.assert;
  40742. var warn = sharedUtil.warn;
  40743. var error = sharedUtil.error;
  40744. var isInt = sharedUtil.isInt;
  40745. var isString = sharedUtil.isString;
  40746. var MissingDataException = sharedUtil.MissingDataException;
  40747. var CMapCompressionType = sharedUtil.CMapCompressionType;
  40748. var isEOF = corePrimitives.isEOF;
  40749. var isName = corePrimitives.isName;
  40750. var isCmd = corePrimitives.isCmd;
  40751. var isStream = corePrimitives.isStream;
  40752. var Stream = coreStream.Stream;
  40753. var Lexer = coreParser.Lexer;
  40754. var BUILT_IN_CMAPS = [
  40755. 'Adobe-GB1-UCS2',
  40756. 'Adobe-CNS1-UCS2',
  40757. 'Adobe-Japan1-UCS2',
  40758. 'Adobe-Korea1-UCS2',
  40759. '78-EUC-H',
  40760. '78-EUC-V',
  40761. '78-H',
  40762. '78-RKSJ-H',
  40763. '78-RKSJ-V',
  40764. '78-V',
  40765. '78ms-RKSJ-H',
  40766. '78ms-RKSJ-V',
  40767. '83pv-RKSJ-H',
  40768. '90ms-RKSJ-H',
  40769. '90ms-RKSJ-V',
  40770. '90msp-RKSJ-H',
  40771. '90msp-RKSJ-V',
  40772. '90pv-RKSJ-H',
  40773. '90pv-RKSJ-V',
  40774. 'Add-H',
  40775. 'Add-RKSJ-H',
  40776. 'Add-RKSJ-V',
  40777. 'Add-V',
  40778. 'Adobe-CNS1-0',
  40779. 'Adobe-CNS1-1',
  40780. 'Adobe-CNS1-2',
  40781. 'Adobe-CNS1-3',
  40782. 'Adobe-CNS1-4',
  40783. 'Adobe-CNS1-5',
  40784. 'Adobe-CNS1-6',
  40785. 'Adobe-GB1-0',
  40786. 'Adobe-GB1-1',
  40787. 'Adobe-GB1-2',
  40788. 'Adobe-GB1-3',
  40789. 'Adobe-GB1-4',
  40790. 'Adobe-GB1-5',
  40791. 'Adobe-Japan1-0',
  40792. 'Adobe-Japan1-1',
  40793. 'Adobe-Japan1-2',
  40794. 'Adobe-Japan1-3',
  40795. 'Adobe-Japan1-4',
  40796. 'Adobe-Japan1-5',
  40797. 'Adobe-Japan1-6',
  40798. 'Adobe-Korea1-0',
  40799. 'Adobe-Korea1-1',
  40800. 'Adobe-Korea1-2',
  40801. 'B5-H',
  40802. 'B5-V',
  40803. 'B5pc-H',
  40804. 'B5pc-V',
  40805. 'CNS-EUC-H',
  40806. 'CNS-EUC-V',
  40807. 'CNS1-H',
  40808. 'CNS1-V',
  40809. 'CNS2-H',
  40810. 'CNS2-V',
  40811. 'ETHK-B5-H',
  40812. 'ETHK-B5-V',
  40813. 'ETen-B5-H',
  40814. 'ETen-B5-V',
  40815. 'ETenms-B5-H',
  40816. 'ETenms-B5-V',
  40817. 'EUC-H',
  40818. 'EUC-V',
  40819. 'Ext-H',
  40820. 'Ext-RKSJ-H',
  40821. 'Ext-RKSJ-V',
  40822. 'Ext-V',
  40823. 'GB-EUC-H',
  40824. 'GB-EUC-V',
  40825. 'GB-H',
  40826. 'GB-V',
  40827. 'GBK-EUC-H',
  40828. 'GBK-EUC-V',
  40829. 'GBK2K-H',
  40830. 'GBK2K-V',
  40831. 'GBKp-EUC-H',
  40832. 'GBKp-EUC-V',
  40833. 'GBT-EUC-H',
  40834. 'GBT-EUC-V',
  40835. 'GBT-H',
  40836. 'GBT-V',
  40837. 'GBTpc-EUC-H',
  40838. 'GBTpc-EUC-V',
  40839. 'GBpc-EUC-H',
  40840. 'GBpc-EUC-V',
  40841. 'H',
  40842. 'HKdla-B5-H',
  40843. 'HKdla-B5-V',
  40844. 'HKdlb-B5-H',
  40845. 'HKdlb-B5-V',
  40846. 'HKgccs-B5-H',
  40847. 'HKgccs-B5-V',
  40848. 'HKm314-B5-H',
  40849. 'HKm314-B5-V',
  40850. 'HKm471-B5-H',
  40851. 'HKm471-B5-V',
  40852. 'HKscs-B5-H',
  40853. 'HKscs-B5-V',
  40854. 'Hankaku',
  40855. 'Hiragana',
  40856. 'KSC-EUC-H',
  40857. 'KSC-EUC-V',
  40858. 'KSC-H',
  40859. 'KSC-Johab-H',
  40860. 'KSC-Johab-V',
  40861. 'KSC-V',
  40862. 'KSCms-UHC-H',
  40863. 'KSCms-UHC-HW-H',
  40864. 'KSCms-UHC-HW-V',
  40865. 'KSCms-UHC-V',
  40866. 'KSCpc-EUC-H',
  40867. 'KSCpc-EUC-V',
  40868. 'Katakana',
  40869. 'NWP-H',
  40870. 'NWP-V',
  40871. 'RKSJ-H',
  40872. 'RKSJ-V',
  40873. 'Roman',
  40874. 'UniCNS-UCS2-H',
  40875. 'UniCNS-UCS2-V',
  40876. 'UniCNS-UTF16-H',
  40877. 'UniCNS-UTF16-V',
  40878. 'UniCNS-UTF32-H',
  40879. 'UniCNS-UTF32-V',
  40880. 'UniCNS-UTF8-H',
  40881. 'UniCNS-UTF8-V',
  40882. 'UniGB-UCS2-H',
  40883. 'UniGB-UCS2-V',
  40884. 'UniGB-UTF16-H',
  40885. 'UniGB-UTF16-V',
  40886. 'UniGB-UTF32-H',
  40887. 'UniGB-UTF32-V',
  40888. 'UniGB-UTF8-H',
  40889. 'UniGB-UTF8-V',
  40890. 'UniJIS-UCS2-H',
  40891. 'UniJIS-UCS2-HW-H',
  40892. 'UniJIS-UCS2-HW-V',
  40893. 'UniJIS-UCS2-V',
  40894. 'UniJIS-UTF16-H',
  40895. 'UniJIS-UTF16-V',
  40896. 'UniJIS-UTF32-H',
  40897. 'UniJIS-UTF32-V',
  40898. 'UniJIS-UTF8-H',
  40899. 'UniJIS-UTF8-V',
  40900. 'UniJIS2004-UTF16-H',
  40901. 'UniJIS2004-UTF16-V',
  40902. 'UniJIS2004-UTF32-H',
  40903. 'UniJIS2004-UTF32-V',
  40904. 'UniJIS2004-UTF8-H',
  40905. 'UniJIS2004-UTF8-V',
  40906. 'UniJISPro-UCS2-HW-V',
  40907. 'UniJISPro-UCS2-V',
  40908. 'UniJISPro-UTF8-V',
  40909. 'UniJISX0213-UTF32-H',
  40910. 'UniJISX0213-UTF32-V',
  40911. 'UniJISX02132004-UTF32-H',
  40912. 'UniJISX02132004-UTF32-V',
  40913. 'UniKS-UCS2-H',
  40914. 'UniKS-UCS2-V',
  40915. 'UniKS-UTF16-H',
  40916. 'UniKS-UTF16-V',
  40917. 'UniKS-UTF32-H',
  40918. 'UniKS-UTF32-V',
  40919. 'UniKS-UTF8-H',
  40920. 'UniKS-UTF8-V',
  40921. 'V',
  40922. 'WP-Symbol'
  40923. ];
  40924. var CMap = function CMapClosure() {
  40925. function CMap(builtInCMap) {
  40926. this.codespaceRanges = [
  40927. [],
  40928. [],
  40929. [],
  40930. []
  40931. ];
  40932. this.numCodespaceRanges = 0;
  40933. this._map = [];
  40934. this.name = '';
  40935. this.vertical = false;
  40936. this.useCMap = null;
  40937. this.builtInCMap = builtInCMap;
  40938. }
  40939. CMap.prototype = {
  40940. addCodespaceRange: function (n, low, high) {
  40941. this.codespaceRanges[n - 1].push(low, high);
  40942. this.numCodespaceRanges++;
  40943. },
  40944. mapCidRange: function (low, high, dstLow) {
  40945. while (low <= high) {
  40946. this._map[low++] = dstLow++;
  40947. }
  40948. },
  40949. mapBfRange: function (low, high, dstLow) {
  40950. var lastByte = dstLow.length - 1;
  40951. while (low <= high) {
  40952. this._map[low++] = dstLow;
  40953. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40954. }
  40955. },
  40956. mapBfRangeToArray: function (low, high, array) {
  40957. var i = 0, ii = array.length;
  40958. while (low <= high && i < ii) {
  40959. this._map[low] = array[i++];
  40960. ++low;
  40961. }
  40962. },
  40963. mapOne: function (src, dst) {
  40964. this._map[src] = dst;
  40965. },
  40966. lookup: function (code) {
  40967. return this._map[code];
  40968. },
  40969. contains: function (code) {
  40970. return this._map[code] !== undefined;
  40971. },
  40972. forEach: function (callback) {
  40973. var map = this._map;
  40974. var length = map.length;
  40975. var i;
  40976. if (length <= 0x10000) {
  40977. for (i = 0; i < length; i++) {
  40978. if (map[i] !== undefined) {
  40979. callback(i, map[i]);
  40980. }
  40981. }
  40982. } else {
  40983. for (i in this._map) {
  40984. callback(i, map[i]);
  40985. }
  40986. }
  40987. },
  40988. charCodeOf: function (value) {
  40989. return this._map.indexOf(value);
  40990. },
  40991. getMap: function () {
  40992. return this._map;
  40993. },
  40994. readCharCode: function (str, offset, out) {
  40995. var c = 0;
  40996. var codespaceRanges = this.codespaceRanges;
  40997. var codespaceRangesLen = this.codespaceRanges.length;
  40998. for (var n = 0; n < codespaceRangesLen; n++) {
  40999. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41000. var codespaceRange = codespaceRanges[n];
  41001. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41002. var low = codespaceRange[k++];
  41003. var high = codespaceRange[k++];
  41004. if (c >= low && c <= high) {
  41005. out.charcode = c;
  41006. out.length = n + 1;
  41007. return;
  41008. }
  41009. }
  41010. }
  41011. out.charcode = 0;
  41012. out.length = 1;
  41013. },
  41014. get length() {
  41015. return this._map.length;
  41016. },
  41017. get isIdentityCMap() {
  41018. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41019. return false;
  41020. }
  41021. if (this._map.length !== 0x10000) {
  41022. return false;
  41023. }
  41024. for (var i = 0; i < 0x10000; i++) {
  41025. if (this._map[i] !== i) {
  41026. return false;
  41027. }
  41028. }
  41029. return true;
  41030. }
  41031. };
  41032. return CMap;
  41033. }();
  41034. var IdentityCMap = function IdentityCMapClosure() {
  41035. function IdentityCMap(vertical, n) {
  41036. CMap.call(this);
  41037. this.vertical = vertical;
  41038. this.addCodespaceRange(n, 0, 0xffff);
  41039. }
  41040. Util.inherit(IdentityCMap, CMap, {});
  41041. IdentityCMap.prototype = {
  41042. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41043. mapCidRange: function (low, high, dstLow) {
  41044. error('should not call mapCidRange');
  41045. },
  41046. mapBfRange: function (low, high, dstLow) {
  41047. error('should not call mapBfRange');
  41048. },
  41049. mapBfRangeToArray: function (low, high, array) {
  41050. error('should not call mapBfRangeToArray');
  41051. },
  41052. mapOne: function (src, dst) {
  41053. error('should not call mapCidOne');
  41054. },
  41055. lookup: function (code) {
  41056. return isInt(code) && code <= 0xffff ? code : undefined;
  41057. },
  41058. contains: function (code) {
  41059. return isInt(code) && code <= 0xffff;
  41060. },
  41061. forEach: function (callback) {
  41062. for (var i = 0; i <= 0xffff; i++) {
  41063. callback(i, i);
  41064. }
  41065. },
  41066. charCodeOf: function (value) {
  41067. return isInt(value) && value <= 0xffff ? value : -1;
  41068. },
  41069. getMap: function () {
  41070. var map = new Array(0x10000);
  41071. for (var i = 0; i <= 0xffff; i++) {
  41072. map[i] = i;
  41073. }
  41074. return map;
  41075. },
  41076. readCharCode: CMap.prototype.readCharCode,
  41077. get length() {
  41078. return 0x10000;
  41079. },
  41080. get isIdentityCMap() {
  41081. error('should not access .isIdentityCMap');
  41082. }
  41083. };
  41084. return IdentityCMap;
  41085. }();
  41086. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41087. function hexToInt(a, size) {
  41088. var n = 0;
  41089. for (var i = 0; i <= size; i++) {
  41090. n = n << 8 | a[i];
  41091. }
  41092. return n >>> 0;
  41093. }
  41094. function hexToStr(a, size) {
  41095. if (size === 1) {
  41096. return String.fromCharCode(a[0], a[1]);
  41097. }
  41098. if (size === 3) {
  41099. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41100. }
  41101. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41102. }
  41103. function addHex(a, b, size) {
  41104. var c = 0;
  41105. for (var i = size; i >= 0; i--) {
  41106. c += a[i] + b[i];
  41107. a[i] = c & 255;
  41108. c >>= 8;
  41109. }
  41110. }
  41111. function incHex(a, size) {
  41112. var c = 1;
  41113. for (var i = size; i >= 0 && c > 0; i--) {
  41114. c += a[i];
  41115. a[i] = c & 255;
  41116. c >>= 8;
  41117. }
  41118. }
  41119. var MAX_NUM_SIZE = 16;
  41120. var MAX_ENCODED_NUM_SIZE = 19;
  41121. function BinaryCMapStream(data) {
  41122. this.buffer = data;
  41123. this.pos = 0;
  41124. this.end = data.length;
  41125. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41126. }
  41127. BinaryCMapStream.prototype = {
  41128. readByte: function () {
  41129. if (this.pos >= this.end) {
  41130. return -1;
  41131. }
  41132. return this.buffer[this.pos++];
  41133. },
  41134. readNumber: function () {
  41135. var n = 0;
  41136. var last;
  41137. do {
  41138. var b = this.readByte();
  41139. if (b < 0) {
  41140. error('unexpected EOF in bcmap');
  41141. }
  41142. last = !(b & 0x80);
  41143. n = n << 7 | b & 0x7F;
  41144. } while (!last);
  41145. return n;
  41146. },
  41147. readSigned: function () {
  41148. var n = this.readNumber();
  41149. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41150. },
  41151. readHex: function (num, size) {
  41152. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41153. this.pos += size + 1;
  41154. },
  41155. readHexNumber: function (num, size) {
  41156. var last;
  41157. var stack = this.tmpBuf, sp = 0;
  41158. do {
  41159. var b = this.readByte();
  41160. if (b < 0) {
  41161. error('unexpected EOF in bcmap');
  41162. }
  41163. last = !(b & 0x80);
  41164. stack[sp++] = b & 0x7F;
  41165. } while (!last);
  41166. var i = size, buffer = 0, bufferSize = 0;
  41167. while (i >= 0) {
  41168. while (bufferSize < 8 && stack.length > 0) {
  41169. buffer = stack[--sp] << bufferSize | buffer;
  41170. bufferSize += 7;
  41171. }
  41172. num[i] = buffer & 255;
  41173. i--;
  41174. buffer >>= 8;
  41175. bufferSize -= 8;
  41176. }
  41177. },
  41178. readHexSigned: function (num, size) {
  41179. this.readHexNumber(num, size);
  41180. var sign = num[size] & 1 ? 255 : 0;
  41181. var c = 0;
  41182. for (var i = 0; i <= size; i++) {
  41183. c = (c & 1) << 8 | num[i];
  41184. num[i] = c >> 1 ^ sign;
  41185. }
  41186. },
  41187. readString: function () {
  41188. var len = this.readNumber();
  41189. var s = '';
  41190. for (var i = 0; i < len; i++) {
  41191. s += String.fromCharCode(this.readNumber());
  41192. }
  41193. return s;
  41194. }
  41195. };
  41196. function processBinaryCMap(data, cMap, extend) {
  41197. return new Promise(function (resolve, reject) {
  41198. var stream = new BinaryCMapStream(data);
  41199. var header = stream.readByte();
  41200. cMap.vertical = !!(header & 1);
  41201. var useCMap = null;
  41202. var start = new Uint8Array(MAX_NUM_SIZE);
  41203. var end = new Uint8Array(MAX_NUM_SIZE);
  41204. var char = new Uint8Array(MAX_NUM_SIZE);
  41205. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41206. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41207. var code;
  41208. var b;
  41209. while ((b = stream.readByte()) >= 0) {
  41210. var type = b >> 5;
  41211. if (type === 7) {
  41212. switch (b & 0x1F) {
  41213. case 0:
  41214. stream.readString();
  41215. break;
  41216. case 1:
  41217. useCMap = stream.readString();
  41218. break;
  41219. }
  41220. continue;
  41221. }
  41222. var sequence = !!(b & 0x10);
  41223. var dataSize = b & 15;
  41224. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41225. var ucs2DataSize = 1;
  41226. var subitemsCount = stream.readNumber();
  41227. var i;
  41228. switch (type) {
  41229. case 0:
  41230. stream.readHex(start, dataSize);
  41231. stream.readHexNumber(end, dataSize);
  41232. addHex(end, start, dataSize);
  41233. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41234. for (i = 1; i < subitemsCount; i++) {
  41235. incHex(end, dataSize);
  41236. stream.readHexNumber(start, dataSize);
  41237. addHex(start, end, dataSize);
  41238. stream.readHexNumber(end, dataSize);
  41239. addHex(end, start, dataSize);
  41240. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41241. }
  41242. break;
  41243. case 1:
  41244. stream.readHex(start, dataSize);
  41245. stream.readHexNumber(end, dataSize);
  41246. addHex(end, start, dataSize);
  41247. code = stream.readNumber();
  41248. for (i = 1; i < subitemsCount; i++) {
  41249. incHex(end, dataSize);
  41250. stream.readHexNumber(start, dataSize);
  41251. addHex(start, end, dataSize);
  41252. stream.readHexNumber(end, dataSize);
  41253. addHex(end, start, dataSize);
  41254. code = stream.readNumber();
  41255. }
  41256. break;
  41257. case 2:
  41258. stream.readHex(char, dataSize);
  41259. code = stream.readNumber();
  41260. cMap.mapOne(hexToInt(char, dataSize), code);
  41261. for (i = 1; i < subitemsCount; i++) {
  41262. incHex(char, dataSize);
  41263. if (!sequence) {
  41264. stream.readHexNumber(tmp, dataSize);
  41265. addHex(char, tmp, dataSize);
  41266. }
  41267. code = stream.readSigned() + (code + 1);
  41268. cMap.mapOne(hexToInt(char, dataSize), code);
  41269. }
  41270. break;
  41271. case 3:
  41272. stream.readHex(start, dataSize);
  41273. stream.readHexNumber(end, dataSize);
  41274. addHex(end, start, dataSize);
  41275. code = stream.readNumber();
  41276. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41277. for (i = 1; i < subitemsCount; i++) {
  41278. incHex(end, dataSize);
  41279. if (!sequence) {
  41280. stream.readHexNumber(start, dataSize);
  41281. addHex(start, end, dataSize);
  41282. } else {
  41283. start.set(end);
  41284. }
  41285. stream.readHexNumber(end, dataSize);
  41286. addHex(end, start, dataSize);
  41287. code = stream.readNumber();
  41288. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41289. }
  41290. break;
  41291. case 4:
  41292. stream.readHex(char, ucs2DataSize);
  41293. stream.readHex(charCode, dataSize);
  41294. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41295. for (i = 1; i < subitemsCount; i++) {
  41296. incHex(char, ucs2DataSize);
  41297. if (!sequence) {
  41298. stream.readHexNumber(tmp, ucs2DataSize);
  41299. addHex(char, tmp, ucs2DataSize);
  41300. }
  41301. incHex(charCode, dataSize);
  41302. stream.readHexSigned(tmp, dataSize);
  41303. addHex(charCode, tmp, dataSize);
  41304. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41305. }
  41306. break;
  41307. case 5:
  41308. stream.readHex(start, ucs2DataSize);
  41309. stream.readHexNumber(end, ucs2DataSize);
  41310. addHex(end, start, ucs2DataSize);
  41311. stream.readHex(charCode, dataSize);
  41312. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41313. for (i = 1; i < subitemsCount; i++) {
  41314. incHex(end, ucs2DataSize);
  41315. if (!sequence) {
  41316. stream.readHexNumber(start, ucs2DataSize);
  41317. addHex(start, end, ucs2DataSize);
  41318. } else {
  41319. start.set(end);
  41320. }
  41321. stream.readHexNumber(end, ucs2DataSize);
  41322. addHex(end, start, ucs2DataSize);
  41323. stream.readHex(charCode, dataSize);
  41324. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41325. }
  41326. break;
  41327. default:
  41328. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  41329. return;
  41330. }
  41331. }
  41332. if (useCMap) {
  41333. resolve(extend(useCMap));
  41334. return;
  41335. }
  41336. resolve(cMap);
  41337. });
  41338. }
  41339. function BinaryCMapReader() {
  41340. }
  41341. BinaryCMapReader.prototype = { process: processBinaryCMap };
  41342. return BinaryCMapReader;
  41343. }();
  41344. var CMapFactory = function CMapFactoryClosure() {
  41345. function strToInt(str) {
  41346. var a = 0;
  41347. for (var i = 0; i < str.length; i++) {
  41348. a = a << 8 | str.charCodeAt(i);
  41349. }
  41350. return a >>> 0;
  41351. }
  41352. function expectString(obj) {
  41353. if (!isString(obj)) {
  41354. error('Malformed CMap: expected string.');
  41355. }
  41356. }
  41357. function expectInt(obj) {
  41358. if (!isInt(obj)) {
  41359. error('Malformed CMap: expected int.');
  41360. }
  41361. }
  41362. function parseBfChar(cMap, lexer) {
  41363. while (true) {
  41364. var obj = lexer.getObj();
  41365. if (isEOF(obj)) {
  41366. break;
  41367. }
  41368. if (isCmd(obj, 'endbfchar')) {
  41369. return;
  41370. }
  41371. expectString(obj);
  41372. var src = strToInt(obj);
  41373. obj = lexer.getObj();
  41374. expectString(obj);
  41375. var dst = obj;
  41376. cMap.mapOne(src, dst);
  41377. }
  41378. }
  41379. function parseBfRange(cMap, lexer) {
  41380. while (true) {
  41381. var obj = lexer.getObj();
  41382. if (isEOF(obj)) {
  41383. break;
  41384. }
  41385. if (isCmd(obj, 'endbfrange')) {
  41386. return;
  41387. }
  41388. expectString(obj);
  41389. var low = strToInt(obj);
  41390. obj = lexer.getObj();
  41391. expectString(obj);
  41392. var high = strToInt(obj);
  41393. obj = lexer.getObj();
  41394. if (isInt(obj) || isString(obj)) {
  41395. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41396. cMap.mapBfRange(low, high, dstLow);
  41397. } else if (isCmd(obj, '[')) {
  41398. obj = lexer.getObj();
  41399. var array = [];
  41400. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41401. array.push(obj);
  41402. obj = lexer.getObj();
  41403. }
  41404. cMap.mapBfRangeToArray(low, high, array);
  41405. } else {
  41406. break;
  41407. }
  41408. }
  41409. error('Invalid bf range.');
  41410. }
  41411. function parseCidChar(cMap, lexer) {
  41412. while (true) {
  41413. var obj = lexer.getObj();
  41414. if (isEOF(obj)) {
  41415. break;
  41416. }
  41417. if (isCmd(obj, 'endcidchar')) {
  41418. return;
  41419. }
  41420. expectString(obj);
  41421. var src = strToInt(obj);
  41422. obj = lexer.getObj();
  41423. expectInt(obj);
  41424. var dst = obj;
  41425. cMap.mapOne(src, dst);
  41426. }
  41427. }
  41428. function parseCidRange(cMap, lexer) {
  41429. while (true) {
  41430. var obj = lexer.getObj();
  41431. if (isEOF(obj)) {
  41432. break;
  41433. }
  41434. if (isCmd(obj, 'endcidrange')) {
  41435. return;
  41436. }
  41437. expectString(obj);
  41438. var low = strToInt(obj);
  41439. obj = lexer.getObj();
  41440. expectString(obj);
  41441. var high = strToInt(obj);
  41442. obj = lexer.getObj();
  41443. expectInt(obj);
  41444. var dstLow = obj;
  41445. cMap.mapCidRange(low, high, dstLow);
  41446. }
  41447. }
  41448. function parseCodespaceRange(cMap, lexer) {
  41449. while (true) {
  41450. var obj = lexer.getObj();
  41451. if (isEOF(obj)) {
  41452. break;
  41453. }
  41454. if (isCmd(obj, 'endcodespacerange')) {
  41455. return;
  41456. }
  41457. if (!isString(obj)) {
  41458. break;
  41459. }
  41460. var low = strToInt(obj);
  41461. obj = lexer.getObj();
  41462. if (!isString(obj)) {
  41463. break;
  41464. }
  41465. var high = strToInt(obj);
  41466. cMap.addCodespaceRange(obj.length, low, high);
  41467. }
  41468. error('Invalid codespace range.');
  41469. }
  41470. function parseWMode(cMap, lexer) {
  41471. var obj = lexer.getObj();
  41472. if (isInt(obj)) {
  41473. cMap.vertical = !!obj;
  41474. }
  41475. }
  41476. function parseCMapName(cMap, lexer) {
  41477. var obj = lexer.getObj();
  41478. if (isName(obj) && isString(obj.name)) {
  41479. cMap.name = obj.name;
  41480. }
  41481. }
  41482. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  41483. var previous;
  41484. var embededUseCMap;
  41485. objLoop:
  41486. while (true) {
  41487. try {
  41488. var obj = lexer.getObj();
  41489. if (isEOF(obj)) {
  41490. break;
  41491. } else if (isName(obj)) {
  41492. if (obj.name === 'WMode') {
  41493. parseWMode(cMap, lexer);
  41494. } else if (obj.name === 'CMapName') {
  41495. parseCMapName(cMap, lexer);
  41496. }
  41497. previous = obj;
  41498. } else if (isCmd(obj)) {
  41499. switch (obj.cmd) {
  41500. case 'endcmap':
  41501. break objLoop;
  41502. case 'usecmap':
  41503. if (isName(previous)) {
  41504. embededUseCMap = previous.name;
  41505. }
  41506. break;
  41507. case 'begincodespacerange':
  41508. parseCodespaceRange(cMap, lexer);
  41509. break;
  41510. case 'beginbfchar':
  41511. parseBfChar(cMap, lexer);
  41512. break;
  41513. case 'begincidchar':
  41514. parseCidChar(cMap, lexer);
  41515. break;
  41516. case 'beginbfrange':
  41517. parseBfRange(cMap, lexer);
  41518. break;
  41519. case 'begincidrange':
  41520. parseCidRange(cMap, lexer);
  41521. break;
  41522. }
  41523. }
  41524. } catch (ex) {
  41525. if (ex instanceof MissingDataException) {
  41526. throw ex;
  41527. }
  41528. warn('Invalid cMap data: ' + ex);
  41529. continue;
  41530. }
  41531. }
  41532. if (!useCMap && embededUseCMap) {
  41533. useCMap = embededUseCMap;
  41534. }
  41535. if (useCMap) {
  41536. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41537. }
  41538. return Promise.resolve(cMap);
  41539. }
  41540. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  41541. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  41542. cMap.useCMap = newCMap;
  41543. if (cMap.numCodespaceRanges === 0) {
  41544. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41545. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41546. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41547. }
  41548. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41549. }
  41550. cMap.useCMap.forEach(function (key, value) {
  41551. if (!cMap.contains(key)) {
  41552. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41553. }
  41554. });
  41555. return cMap;
  41556. });
  41557. }
  41558. function createBuiltInCMap(name, fetchBuiltInCMap) {
  41559. if (name === 'Identity-H') {
  41560. return Promise.resolve(new IdentityCMap(false, 2));
  41561. } else if (name === 'Identity-V') {
  41562. return Promise.resolve(new IdentityCMap(true, 2));
  41563. }
  41564. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41565. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41566. }
  41567. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  41568. return fetchBuiltInCMap(name).then(function (data) {
  41569. var cMapData = data.cMapData, compressionType = data.compressionType;
  41570. var cMap = new CMap(true);
  41571. if (compressionType === CMapCompressionType.BINARY) {
  41572. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  41573. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41574. });
  41575. }
  41576. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  41577. var lexer = new Lexer(new Stream(cMapData));
  41578. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  41579. });
  41580. }
  41581. return {
  41582. create: function (params) {
  41583. var encoding = params.encoding;
  41584. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  41585. var useCMap = params.useCMap;
  41586. if (isName(encoding)) {
  41587. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  41588. } else if (isStream(encoding)) {
  41589. var cMap = new CMap();
  41590. var lexer = new Lexer(encoding);
  41591. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  41592. if (parsedCMap.isIdentityCMap) {
  41593. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  41594. }
  41595. return parsedCMap;
  41596. });
  41597. }
  41598. return Promise.reject(new Error('Encoding required.'));
  41599. }
  41600. };
  41601. }();
  41602. exports.CMap = CMap;
  41603. exports.CMapFactory = CMapFactory;
  41604. exports.IdentityCMap = IdentityCMap;
  41605. /***/ }),
  41606. /* 31 */
  41607. /***/ (function(module, exports, __w_pdfjs_require__) {
  41608. "use strict";
  41609. var sharedUtil = __w_pdfjs_require__(0);
  41610. var corePrimitives = __w_pdfjs_require__(1);
  41611. var coreStream = __w_pdfjs_require__(2);
  41612. var coreObj = __w_pdfjs_require__(20);
  41613. var coreParser = __w_pdfjs_require__(6);
  41614. var coreCrypto = __w_pdfjs_require__(17);
  41615. var coreEvaluator = __w_pdfjs_require__(18);
  41616. var coreAnnotation = __w_pdfjs_require__(27);
  41617. var OPS = sharedUtil.OPS;
  41618. var MissingDataException = sharedUtil.MissingDataException;
  41619. var Util = sharedUtil.Util;
  41620. var assert = sharedUtil.assert;
  41621. var error = sharedUtil.error;
  41622. var info = sharedUtil.info;
  41623. var isArray = sharedUtil.isArray;
  41624. var isArrayBuffer = sharedUtil.isArrayBuffer;
  41625. var isNum = sharedUtil.isNum;
  41626. var isString = sharedUtil.isString;
  41627. var shadow = sharedUtil.shadow;
  41628. var stringToBytes = sharedUtil.stringToBytes;
  41629. var stringToPDFString = sharedUtil.stringToPDFString;
  41630. var warn = sharedUtil.warn;
  41631. var isSpace = sharedUtil.isSpace;
  41632. var Dict = corePrimitives.Dict;
  41633. var isDict = corePrimitives.isDict;
  41634. var isName = corePrimitives.isName;
  41635. var isStream = corePrimitives.isStream;
  41636. var NullStream = coreStream.NullStream;
  41637. var Stream = coreStream.Stream;
  41638. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  41639. var Catalog = coreObj.Catalog;
  41640. var ObjectLoader = coreObj.ObjectLoader;
  41641. var XRef = coreObj.XRef;
  41642. var Linearization = coreParser.Linearization;
  41643. var calculateMD5 = coreCrypto.calculateMD5;
  41644. var OperatorList = coreEvaluator.OperatorList;
  41645. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  41646. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  41647. var Page = function PageClosure() {
  41648. var DEFAULT_USER_UNIT = 1.0;
  41649. var LETTER_SIZE_MEDIABOX = [
  41650. 0,
  41651. 0,
  41652. 612,
  41653. 792
  41654. ];
  41655. function isAnnotationRenderable(annotation, intent) {
  41656. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  41657. }
  41658. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  41659. this.pdfManager = pdfManager;
  41660. this.pageIndex = pageIndex;
  41661. this.pageDict = pageDict;
  41662. this.xref = xref;
  41663. this.ref = ref;
  41664. this.fontCache = fontCache;
  41665. this.builtInCMapCache = builtInCMapCache;
  41666. this.evaluatorOptions = pdfManager.evaluatorOptions;
  41667. this.resourcesPromise = null;
  41668. var uniquePrefix = 'p' + this.pageIndex + '_';
  41669. var idCounters = { obj: 0 };
  41670. this.idFactory = {
  41671. createObjId: function () {
  41672. return uniquePrefix + ++idCounters.obj;
  41673. }
  41674. };
  41675. }
  41676. Page.prototype = {
  41677. getPageProp: function Page_getPageProp(key) {
  41678. return this.pageDict.get(key);
  41679. },
  41680. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  41681. var dict = this.pageDict, valueArray = null, loopCount = 0;
  41682. var MAX_LOOP_COUNT = 100;
  41683. getArray = getArray || false;
  41684. while (dict) {
  41685. var value = getArray ? dict.getArray(key) : dict.get(key);
  41686. if (value !== undefined) {
  41687. if (!valueArray) {
  41688. valueArray = [];
  41689. }
  41690. valueArray.push(value);
  41691. }
  41692. if (++loopCount > MAX_LOOP_COUNT) {
  41693. warn('getInheritedPageProp: maximum loop count exceeded for ' + key);
  41694. return valueArray ? valueArray[0] : undefined;
  41695. }
  41696. dict = dict.get('Parent');
  41697. }
  41698. if (!valueArray) {
  41699. return undefined;
  41700. }
  41701. if (valueArray.length === 1 || !isDict(valueArray[0])) {
  41702. return valueArray[0];
  41703. }
  41704. return Dict.merge(this.xref, valueArray);
  41705. },
  41706. get content() {
  41707. return this.getPageProp('Contents');
  41708. },
  41709. get resources() {
  41710. return shadow(this, 'resources', this.getInheritedPageProp('Resources') || Dict.empty);
  41711. },
  41712. get mediaBox() {
  41713. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  41714. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  41715. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  41716. }
  41717. return shadow(this, 'mediaBox', mediaBox);
  41718. },
  41719. get cropBox() {
  41720. var cropBox = this.getInheritedPageProp('CropBox', true);
  41721. if (!isArray(cropBox) || cropBox.length !== 4) {
  41722. return shadow(this, 'cropBox', this.mediaBox);
  41723. }
  41724. return shadow(this, 'cropBox', cropBox);
  41725. },
  41726. get userUnit() {
  41727. var obj = this.getPageProp('UserUnit');
  41728. if (!isNum(obj) || obj <= 0) {
  41729. obj = DEFAULT_USER_UNIT;
  41730. }
  41731. return shadow(this, 'userUnit', obj);
  41732. },
  41733. get view() {
  41734. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  41735. if (mediaBox === cropBox) {
  41736. return shadow(this, 'view', mediaBox);
  41737. }
  41738. var intersection = Util.intersect(cropBox, mediaBox);
  41739. return shadow(this, 'view', intersection || mediaBox);
  41740. },
  41741. get rotate() {
  41742. var rotate = this.getInheritedPageProp('Rotate') || 0;
  41743. if (rotate % 90 !== 0) {
  41744. rotate = 0;
  41745. } else if (rotate >= 360) {
  41746. rotate = rotate % 360;
  41747. } else if (rotate < 0) {
  41748. rotate = (rotate % 360 + 360) % 360;
  41749. }
  41750. return shadow(this, 'rotate', rotate);
  41751. },
  41752. getContentStream: function Page_getContentStream() {
  41753. var content = this.content;
  41754. var stream;
  41755. if (isArray(content)) {
  41756. var xref = this.xref;
  41757. var i, n = content.length;
  41758. var streams = [];
  41759. for (i = 0; i < n; ++i) {
  41760. streams.push(xref.fetchIfRef(content[i]));
  41761. }
  41762. stream = new StreamsSequenceStream(streams);
  41763. } else if (isStream(content)) {
  41764. stream = content;
  41765. } else {
  41766. stream = new NullStream();
  41767. }
  41768. return stream;
  41769. },
  41770. loadResources: function Page_loadResources(keys) {
  41771. if (!this.resourcesPromise) {
  41772. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  41773. }
  41774. return this.resourcesPromise.then(function resourceSuccess() {
  41775. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  41776. return objectLoader.load();
  41777. }.bind(this));
  41778. },
  41779. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  41780. var self = this;
  41781. var pdfManager = this.pdfManager;
  41782. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41783. var resourcesPromise = this.loadResources([
  41784. 'ExtGState',
  41785. 'ColorSpace',
  41786. 'Pattern',
  41787. 'Shading',
  41788. 'XObject',
  41789. 'Font'
  41790. ]);
  41791. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  41792. var dataPromises = Promise.all([
  41793. contentStreamPromise,
  41794. resourcesPromise
  41795. ]);
  41796. var pageListPromise = dataPromises.then(function (data) {
  41797. var contentStream = data[0];
  41798. var opList = new OperatorList(intent, handler, self.pageIndex);
  41799. handler.send('StartRenderPage', {
  41800. transparency: partialEvaluator.hasBlendModes(self.resources),
  41801. pageIndex: self.pageIndex,
  41802. intent: intent
  41803. });
  41804. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  41805. return opList;
  41806. });
  41807. });
  41808. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  41809. return Promise.all([
  41810. pageListPromise,
  41811. annotationsPromise
  41812. ]).then(function (datas) {
  41813. var pageOpList = datas[0];
  41814. var annotations = datas[1];
  41815. if (annotations.length === 0) {
  41816. pageOpList.flush(true);
  41817. return pageOpList;
  41818. }
  41819. var i, ii, opListPromises = [];
  41820. for (i = 0, ii = annotations.length; i < ii; i++) {
  41821. if (isAnnotationRenderable(annotations[i], intent)) {
  41822. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  41823. }
  41824. }
  41825. return Promise.all(opListPromises).then(function (opLists) {
  41826. pageOpList.addOp(OPS.beginAnnotations, []);
  41827. for (i = 0, ii = opLists.length; i < ii; i++) {
  41828. pageOpList.addOpList(opLists[i]);
  41829. }
  41830. pageOpList.addOp(OPS.endAnnotations, []);
  41831. pageOpList.flush(true);
  41832. return pageOpList;
  41833. });
  41834. });
  41835. },
  41836. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  41837. var handler = {
  41838. on: function nullHandlerOn() {
  41839. },
  41840. send: function nullHandlerSend() {
  41841. }
  41842. };
  41843. var self = this;
  41844. var pdfManager = this.pdfManager;
  41845. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41846. var resourcesPromise = this.loadResources([
  41847. 'ExtGState',
  41848. 'XObject',
  41849. 'Font'
  41850. ]);
  41851. var dataPromises = Promise.all([
  41852. contentStreamPromise,
  41853. resourcesPromise
  41854. ]);
  41855. return dataPromises.then(function (data) {
  41856. var contentStream = data[0];
  41857. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  41858. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  41859. });
  41860. },
  41861. getAnnotationsData: function Page_getAnnotationsData(intent) {
  41862. var annotations = this.annotations;
  41863. var annotationsData = [];
  41864. for (var i = 0, n = annotations.length; i < n; ++i) {
  41865. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  41866. annotationsData.push(annotations[i].data);
  41867. }
  41868. }
  41869. return annotationsData;
  41870. },
  41871. get annotations() {
  41872. var annotations = [];
  41873. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  41874. var annotationFactory = new AnnotationFactory();
  41875. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  41876. var annotationRef = annotationRefs[i];
  41877. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  41878. if (annotation) {
  41879. annotations.push(annotation);
  41880. }
  41881. }
  41882. return shadow(this, 'annotations', annotations);
  41883. }
  41884. };
  41885. return Page;
  41886. }();
  41887. var PDFDocument = function PDFDocumentClosure() {
  41888. var FINGERPRINT_FIRST_BYTES = 1024;
  41889. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  41890. function PDFDocument(pdfManager, arg) {
  41891. var stream;
  41892. if (isStream(arg)) {
  41893. stream = arg;
  41894. } else if (isArrayBuffer(arg)) {
  41895. stream = new Stream(arg);
  41896. } else {
  41897. error('PDFDocument: Unknown argument type');
  41898. }
  41899. assert(stream.length > 0, 'stream must have data');
  41900. this.pdfManager = pdfManager;
  41901. this.stream = stream;
  41902. this.xref = new XRef(stream, pdfManager);
  41903. }
  41904. function find(stream, needle, limit, backwards) {
  41905. var pos = stream.pos;
  41906. var end = stream.end;
  41907. var strBuf = [];
  41908. if (pos + limit > end) {
  41909. limit = end - pos;
  41910. }
  41911. for (var n = 0; n < limit; ++n) {
  41912. strBuf.push(String.fromCharCode(stream.getByte()));
  41913. }
  41914. var str = strBuf.join('');
  41915. stream.pos = pos;
  41916. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  41917. if (index === -1) {
  41918. return false;
  41919. }
  41920. stream.pos += index;
  41921. return true;
  41922. }
  41923. var DocumentInfoValidators = {
  41924. get entries() {
  41925. return shadow(this, 'entries', {
  41926. Title: isString,
  41927. Author: isString,
  41928. Subject: isString,
  41929. Keywords: isString,
  41930. Creator: isString,
  41931. Producer: isString,
  41932. CreationDate: isString,
  41933. ModDate: isString,
  41934. Trapped: isName
  41935. });
  41936. }
  41937. };
  41938. PDFDocument.prototype = {
  41939. parse: function PDFDocument_parse(recoveryMode) {
  41940. this.setup(recoveryMode);
  41941. var version = this.catalog.catDict.get('Version');
  41942. if (isName(version)) {
  41943. this.pdfFormatVersion = version.name;
  41944. }
  41945. try {
  41946. this.acroForm = this.catalog.catDict.get('AcroForm');
  41947. if (this.acroForm) {
  41948. this.xfa = this.acroForm.get('XFA');
  41949. var fields = this.acroForm.get('Fields');
  41950. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  41951. this.acroForm = null;
  41952. }
  41953. }
  41954. } catch (ex) {
  41955. info('Something wrong with AcroForm entry');
  41956. this.acroForm = null;
  41957. }
  41958. },
  41959. get linearization() {
  41960. var linearization = null;
  41961. if (this.stream.length) {
  41962. try {
  41963. linearization = Linearization.create(this.stream);
  41964. } catch (err) {
  41965. if (err instanceof MissingDataException) {
  41966. throw err;
  41967. }
  41968. info(err);
  41969. }
  41970. }
  41971. return shadow(this, 'linearization', linearization);
  41972. },
  41973. get startXRef() {
  41974. var stream = this.stream;
  41975. var startXRef = 0;
  41976. var linearization = this.linearization;
  41977. if (linearization) {
  41978. stream.reset();
  41979. if (find(stream, 'endobj', 1024)) {
  41980. startXRef = stream.pos + 6;
  41981. }
  41982. } else {
  41983. var step = 1024;
  41984. var found = false, pos = stream.end;
  41985. while (!found && pos > 0) {
  41986. pos -= step - 'startxref'.length;
  41987. if (pos < 0) {
  41988. pos = 0;
  41989. }
  41990. stream.pos = pos;
  41991. found = find(stream, 'startxref', step, true);
  41992. }
  41993. if (found) {
  41994. stream.skip(9);
  41995. var ch;
  41996. do {
  41997. ch = stream.getByte();
  41998. } while (isSpace(ch));
  41999. var str = '';
  42000. while (ch >= 0x20 && ch <= 0x39) {
  42001. str += String.fromCharCode(ch);
  42002. ch = stream.getByte();
  42003. }
  42004. startXRef = parseInt(str, 10);
  42005. if (isNaN(startXRef)) {
  42006. startXRef = 0;
  42007. }
  42008. }
  42009. }
  42010. return shadow(this, 'startXRef', startXRef);
  42011. },
  42012. get mainXRefEntriesOffset() {
  42013. var mainXRefEntriesOffset = 0;
  42014. var linearization = this.linearization;
  42015. if (linearization) {
  42016. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42017. }
  42018. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42019. },
  42020. checkHeader: function PDFDocument_checkHeader() {
  42021. var stream = this.stream;
  42022. stream.reset();
  42023. if (find(stream, '%PDF-', 1024)) {
  42024. stream.moveStart();
  42025. var MAX_VERSION_LENGTH = 12;
  42026. var version = '', ch;
  42027. while ((ch = stream.getByte()) > 0x20) {
  42028. if (version.length >= MAX_VERSION_LENGTH) {
  42029. break;
  42030. }
  42031. version += String.fromCharCode(ch);
  42032. }
  42033. if (!this.pdfFormatVersion) {
  42034. this.pdfFormatVersion = version.substring(5);
  42035. }
  42036. return;
  42037. }
  42038. },
  42039. parseStartXRef: function PDFDocument_parseStartXRef() {
  42040. var startXRef = this.startXRef;
  42041. this.xref.setStartXRef(startXRef);
  42042. },
  42043. setup: function PDFDocument_setup(recoveryMode) {
  42044. this.xref.parse(recoveryMode);
  42045. var self = this;
  42046. var pageFactory = {
  42047. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42048. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42049. }
  42050. };
  42051. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42052. },
  42053. get numPages() {
  42054. var linearization = this.linearization;
  42055. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42056. return shadow(this, 'numPages', num);
  42057. },
  42058. get documentInfo() {
  42059. var docInfo = {
  42060. PDFFormatVersion: this.pdfFormatVersion,
  42061. IsAcroFormPresent: !!this.acroForm,
  42062. IsXFAPresent: !!this.xfa
  42063. };
  42064. var infoDict;
  42065. try {
  42066. infoDict = this.xref.trailer.get('Info');
  42067. } catch (err) {
  42068. info('The document information dictionary is invalid.');
  42069. }
  42070. if (infoDict) {
  42071. var validEntries = DocumentInfoValidators.entries;
  42072. for (var key in validEntries) {
  42073. if (infoDict.has(key)) {
  42074. var value = infoDict.get(key);
  42075. if (validEntries[key](value)) {
  42076. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42077. } else {
  42078. info('Bad value in document info for "' + key + '"');
  42079. }
  42080. }
  42081. }
  42082. }
  42083. return shadow(this, 'documentInfo', docInfo);
  42084. },
  42085. get fingerprint() {
  42086. var xref = this.xref, hash, fileID = '';
  42087. var idArray = xref.trailer.get('ID');
  42088. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42089. hash = stringToBytes(idArray[0]);
  42090. } else {
  42091. if (this.stream.ensureRange) {
  42092. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42093. }
  42094. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42095. }
  42096. for (var i = 0, n = hash.length; i < n; i++) {
  42097. var hex = hash[i].toString(16);
  42098. fileID += hex.length === 1 ? '0' + hex : hex;
  42099. }
  42100. return shadow(this, 'fingerprint', fileID);
  42101. },
  42102. getPage: function PDFDocument_getPage(pageIndex) {
  42103. return this.catalog.getPage(pageIndex);
  42104. },
  42105. cleanup: function PDFDocument_cleanup() {
  42106. return this.catalog.cleanup();
  42107. }
  42108. };
  42109. return PDFDocument;
  42110. }();
  42111. exports.Page = Page;
  42112. exports.PDFDocument = PDFDocument;
  42113. /***/ }),
  42114. /* 32 */
  42115. /***/ (function(module, exports, __w_pdfjs_require__) {
  42116. "use strict";
  42117. var sharedUtil = __w_pdfjs_require__(0);
  42118. var coreStream = __w_pdfjs_require__(2);
  42119. var coreGlyphList = __w_pdfjs_require__(8);
  42120. var coreEncodings = __w_pdfjs_require__(5);
  42121. var coreCFFParser = __w_pdfjs_require__(15);
  42122. var Util = sharedUtil.Util;
  42123. var bytesToString = sharedUtil.bytesToString;
  42124. var error = sharedUtil.error;
  42125. var Stream = coreStream.Stream;
  42126. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42127. var StandardEncoding = coreEncodings.StandardEncoding;
  42128. var CFFParser = coreCFFParser.CFFParser;
  42129. var FontRendererFactory = function FontRendererFactoryClosure() {
  42130. function getLong(data, offset) {
  42131. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42132. }
  42133. function getUshort(data, offset) {
  42134. return data[offset] << 8 | data[offset + 1];
  42135. }
  42136. function parseCmap(data, start, end) {
  42137. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42138. var format = getUshort(data, start + offset);
  42139. var ranges, p, i;
  42140. if (format === 4) {
  42141. getUshort(data, start + offset + 2);
  42142. var segCount = getUshort(data, start + offset + 6) >> 1;
  42143. p = start + offset + 14;
  42144. ranges = [];
  42145. for (i = 0; i < segCount; i++, p += 2) {
  42146. ranges[i] = { end: getUshort(data, p) };
  42147. }
  42148. p += 2;
  42149. for (i = 0; i < segCount; i++, p += 2) {
  42150. ranges[i].start = getUshort(data, p);
  42151. }
  42152. for (i = 0; i < segCount; i++, p += 2) {
  42153. ranges[i].idDelta = getUshort(data, p);
  42154. }
  42155. for (i = 0; i < segCount; i++, p += 2) {
  42156. var idOffset = getUshort(data, p);
  42157. if (idOffset === 0) {
  42158. continue;
  42159. }
  42160. ranges[i].ids = [];
  42161. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42162. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42163. idOffset += 2;
  42164. }
  42165. }
  42166. return ranges;
  42167. } else if (format === 12) {
  42168. getLong(data, start + offset + 4);
  42169. var groups = getLong(data, start + offset + 12);
  42170. p = start + offset + 16;
  42171. ranges = [];
  42172. for (i = 0; i < groups; i++) {
  42173. ranges.push({
  42174. start: getLong(data, p),
  42175. end: getLong(data, p + 4),
  42176. idDelta: getLong(data, p + 8) - getLong(data, p)
  42177. });
  42178. p += 12;
  42179. }
  42180. return ranges;
  42181. }
  42182. error('not supported cmap: ' + format);
  42183. }
  42184. function parseCff(data, start, end, seacAnalysisEnabled) {
  42185. var properties = {};
  42186. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42187. var cff = parser.parse();
  42188. return {
  42189. glyphs: cff.charStrings.objects,
  42190. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42191. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42192. };
  42193. }
  42194. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42195. var itemSize, itemDecode;
  42196. if (isGlyphLocationsLong) {
  42197. itemSize = 4;
  42198. itemDecode = function fontItemDecodeLong(data, offset) {
  42199. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42200. };
  42201. } else {
  42202. itemSize = 2;
  42203. itemDecode = function fontItemDecode(data, offset) {
  42204. return data[offset] << 9 | data[offset + 1] << 1;
  42205. };
  42206. }
  42207. var glyphs = [];
  42208. var startOffset = itemDecode(loca, 0);
  42209. for (var j = itemSize; j < loca.length; j += itemSize) {
  42210. var endOffset = itemDecode(loca, j);
  42211. glyphs.push(glyf.subarray(startOffset, endOffset));
  42212. startOffset = endOffset;
  42213. }
  42214. return glyphs;
  42215. }
  42216. function lookupCmap(ranges, unicode) {
  42217. var code = unicode.charCodeAt(0), gid = 0;
  42218. var l = 0, r = ranges.length - 1;
  42219. while (l < r) {
  42220. var c = l + r + 1 >> 1;
  42221. if (code < ranges[c].start) {
  42222. r = c - 1;
  42223. } else {
  42224. l = c;
  42225. }
  42226. }
  42227. if (ranges[l].start <= code && code <= ranges[l].end) {
  42228. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  42229. }
  42230. return {
  42231. charCode: code,
  42232. glyphId: gid
  42233. };
  42234. }
  42235. function compileGlyf(code, cmds, font) {
  42236. function moveTo(x, y) {
  42237. cmds.push({
  42238. cmd: 'moveTo',
  42239. args: [
  42240. x,
  42241. y
  42242. ]
  42243. });
  42244. }
  42245. function lineTo(x, y) {
  42246. cmds.push({
  42247. cmd: 'lineTo',
  42248. args: [
  42249. x,
  42250. y
  42251. ]
  42252. });
  42253. }
  42254. function quadraticCurveTo(xa, ya, x, y) {
  42255. cmds.push({
  42256. cmd: 'quadraticCurveTo',
  42257. args: [
  42258. xa,
  42259. ya,
  42260. x,
  42261. y
  42262. ]
  42263. });
  42264. }
  42265. var i = 0;
  42266. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42267. var flags;
  42268. var x = 0, y = 0;
  42269. i += 10;
  42270. if (numberOfContours < 0) {
  42271. do {
  42272. flags = code[i] << 8 | code[i + 1];
  42273. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  42274. i += 4;
  42275. var arg1, arg2;
  42276. if (flags & 0x01) {
  42277. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42278. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  42279. i += 4;
  42280. } else {
  42281. arg1 = code[i++];
  42282. arg2 = code[i++];
  42283. }
  42284. if (flags & 0x02) {
  42285. x = arg1;
  42286. y = arg2;
  42287. } else {
  42288. x = 0;
  42289. y = 0;
  42290. }
  42291. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  42292. if (flags & 0x08) {
  42293. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42294. i += 2;
  42295. } else if (flags & 0x40) {
  42296. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42297. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42298. i += 4;
  42299. } else if (flags & 0x80) {
  42300. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42301. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42302. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  42303. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  42304. i += 8;
  42305. }
  42306. var subglyph = font.glyphs[glyphIndex];
  42307. if (subglyph) {
  42308. cmds.push({ cmd: 'save' });
  42309. cmds.push({
  42310. cmd: 'transform',
  42311. args: [
  42312. scaleX,
  42313. scale01,
  42314. scale10,
  42315. scaleY,
  42316. x,
  42317. y
  42318. ]
  42319. });
  42320. compileGlyf(subglyph, cmds, font);
  42321. cmds.push({ cmd: 'restore' });
  42322. }
  42323. } while (flags & 0x20);
  42324. } else {
  42325. var endPtsOfContours = [];
  42326. var j, jj;
  42327. for (j = 0; j < numberOfContours; j++) {
  42328. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  42329. i += 2;
  42330. }
  42331. var instructionLength = code[i] << 8 | code[i + 1];
  42332. i += 2 + instructionLength;
  42333. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  42334. var points = [];
  42335. while (points.length < numberOfPoints) {
  42336. flags = code[i++];
  42337. var repeat = 1;
  42338. if (flags & 0x08) {
  42339. repeat += code[i++];
  42340. }
  42341. while (repeat-- > 0) {
  42342. points.push({ flags: flags });
  42343. }
  42344. }
  42345. for (j = 0; j < numberOfPoints; j++) {
  42346. switch (points[j].flags & 0x12) {
  42347. case 0x00:
  42348. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42349. i += 2;
  42350. break;
  42351. case 0x02:
  42352. x -= code[i++];
  42353. break;
  42354. case 0x12:
  42355. x += code[i++];
  42356. break;
  42357. }
  42358. points[j].x = x;
  42359. }
  42360. for (j = 0; j < numberOfPoints; j++) {
  42361. switch (points[j].flags & 0x24) {
  42362. case 0x00:
  42363. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42364. i += 2;
  42365. break;
  42366. case 0x04:
  42367. y -= code[i++];
  42368. break;
  42369. case 0x24:
  42370. y += code[i++];
  42371. break;
  42372. }
  42373. points[j].y = y;
  42374. }
  42375. var startPoint = 0;
  42376. for (i = 0; i < numberOfContours; i++) {
  42377. var endPoint = endPtsOfContours[i];
  42378. var contour = points.slice(startPoint, endPoint + 1);
  42379. if (contour[0].flags & 1) {
  42380. contour.push(contour[0]);
  42381. } else if (contour[contour.length - 1].flags & 1) {
  42382. contour.unshift(contour[contour.length - 1]);
  42383. } else {
  42384. var p = {
  42385. flags: 1,
  42386. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  42387. y: (contour[0].y + contour[contour.length - 1].y) / 2
  42388. };
  42389. contour.unshift(p);
  42390. contour.push(p);
  42391. }
  42392. moveTo(contour[0].x, contour[0].y);
  42393. for (j = 1, jj = contour.length; j < jj; j++) {
  42394. if (contour[j].flags & 1) {
  42395. lineTo(contour[j].x, contour[j].y);
  42396. } else if (contour[j + 1].flags & 1) {
  42397. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  42398. j++;
  42399. } else {
  42400. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  42401. }
  42402. }
  42403. startPoint = endPoint + 1;
  42404. }
  42405. }
  42406. }
  42407. function compileCharString(code, cmds, font) {
  42408. var stack = [];
  42409. var x = 0, y = 0;
  42410. var stems = 0;
  42411. function moveTo(x, y) {
  42412. cmds.push({
  42413. cmd: 'moveTo',
  42414. args: [
  42415. x,
  42416. y
  42417. ]
  42418. });
  42419. }
  42420. function lineTo(x, y) {
  42421. cmds.push({
  42422. cmd: 'lineTo',
  42423. args: [
  42424. x,
  42425. y
  42426. ]
  42427. });
  42428. }
  42429. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  42430. cmds.push({
  42431. cmd: 'bezierCurveTo',
  42432. args: [
  42433. x1,
  42434. y1,
  42435. x2,
  42436. y2,
  42437. x,
  42438. y
  42439. ]
  42440. });
  42441. }
  42442. function parse(code) {
  42443. var i = 0;
  42444. while (i < code.length) {
  42445. var stackClean = false;
  42446. var v = code[i++];
  42447. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  42448. switch (v) {
  42449. case 1:
  42450. stems += stack.length >> 1;
  42451. stackClean = true;
  42452. break;
  42453. case 3:
  42454. stems += stack.length >> 1;
  42455. stackClean = true;
  42456. break;
  42457. case 4:
  42458. y += stack.pop();
  42459. moveTo(x, y);
  42460. stackClean = true;
  42461. break;
  42462. case 5:
  42463. while (stack.length > 0) {
  42464. x += stack.shift();
  42465. y += stack.shift();
  42466. lineTo(x, y);
  42467. }
  42468. break;
  42469. case 6:
  42470. while (stack.length > 0) {
  42471. x += stack.shift();
  42472. lineTo(x, y);
  42473. if (stack.length === 0) {
  42474. break;
  42475. }
  42476. y += stack.shift();
  42477. lineTo(x, y);
  42478. }
  42479. break;
  42480. case 7:
  42481. while (stack.length > 0) {
  42482. y += stack.shift();
  42483. lineTo(x, y);
  42484. if (stack.length === 0) {
  42485. break;
  42486. }
  42487. x += stack.shift();
  42488. lineTo(x, y);
  42489. }
  42490. break;
  42491. case 8:
  42492. while (stack.length > 0) {
  42493. xa = x + stack.shift();
  42494. ya = y + stack.shift();
  42495. xb = xa + stack.shift();
  42496. yb = ya + stack.shift();
  42497. x = xb + stack.shift();
  42498. y = yb + stack.shift();
  42499. bezierCurveTo(xa, ya, xb, yb, x, y);
  42500. }
  42501. break;
  42502. case 10:
  42503. n = stack.pop() + font.subrsBias;
  42504. subrCode = font.subrs[n];
  42505. if (subrCode) {
  42506. parse(subrCode);
  42507. }
  42508. break;
  42509. case 11:
  42510. return;
  42511. case 12:
  42512. v = code[i++];
  42513. switch (v) {
  42514. case 34:
  42515. xa = x + stack.shift();
  42516. xb = xa + stack.shift();
  42517. y1 = y + stack.shift();
  42518. x = xb + stack.shift();
  42519. bezierCurveTo(xa, y, xb, y1, x, y1);
  42520. xa = x + stack.shift();
  42521. xb = xa + stack.shift();
  42522. x = xb + stack.shift();
  42523. bezierCurveTo(xa, y1, xb, y, x, y);
  42524. break;
  42525. case 35:
  42526. xa = x + stack.shift();
  42527. ya = y + stack.shift();
  42528. xb = xa + stack.shift();
  42529. yb = ya + stack.shift();
  42530. x = xb + stack.shift();
  42531. y = yb + stack.shift();
  42532. bezierCurveTo(xa, ya, xb, yb, x, y);
  42533. xa = x + stack.shift();
  42534. ya = y + stack.shift();
  42535. xb = xa + stack.shift();
  42536. yb = ya + stack.shift();
  42537. x = xb + stack.shift();
  42538. y = yb + stack.shift();
  42539. bezierCurveTo(xa, ya, xb, yb, x, y);
  42540. stack.pop();
  42541. break;
  42542. case 36:
  42543. xa = x + stack.shift();
  42544. y1 = y + stack.shift();
  42545. xb = xa + stack.shift();
  42546. y2 = y1 + stack.shift();
  42547. x = xb + stack.shift();
  42548. bezierCurveTo(xa, y1, xb, y2, x, y2);
  42549. xa = x + stack.shift();
  42550. xb = xa + stack.shift();
  42551. y3 = y2 + stack.shift();
  42552. x = xb + stack.shift();
  42553. bezierCurveTo(xa, y2, xb, y3, x, y);
  42554. break;
  42555. case 37:
  42556. var x0 = x, y0 = y;
  42557. xa = x + stack.shift();
  42558. ya = y + stack.shift();
  42559. xb = xa + stack.shift();
  42560. yb = ya + stack.shift();
  42561. x = xb + stack.shift();
  42562. y = yb + stack.shift();
  42563. bezierCurveTo(xa, ya, xb, yb, x, y);
  42564. xa = x + stack.shift();
  42565. ya = y + stack.shift();
  42566. xb = xa + stack.shift();
  42567. yb = ya + stack.shift();
  42568. x = xb;
  42569. y = yb;
  42570. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  42571. x += stack.shift();
  42572. } else {
  42573. y += stack.shift();
  42574. }
  42575. bezierCurveTo(xa, ya, xb, yb, x, y);
  42576. break;
  42577. default:
  42578. error('unknown operator: 12 ' + v);
  42579. }
  42580. break;
  42581. case 14:
  42582. if (stack.length >= 4) {
  42583. var achar = stack.pop();
  42584. var bchar = stack.pop();
  42585. y = stack.pop();
  42586. x = stack.pop();
  42587. cmds.push({ cmd: 'save' });
  42588. cmds.push({
  42589. cmd: 'translate',
  42590. args: [
  42591. x,
  42592. y
  42593. ]
  42594. });
  42595. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  42596. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42597. cmds.push({ cmd: 'restore' });
  42598. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  42599. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42600. }
  42601. return;
  42602. case 18:
  42603. stems += stack.length >> 1;
  42604. stackClean = true;
  42605. break;
  42606. case 19:
  42607. stems += stack.length >> 1;
  42608. i += stems + 7 >> 3;
  42609. stackClean = true;
  42610. break;
  42611. case 20:
  42612. stems += stack.length >> 1;
  42613. i += stems + 7 >> 3;
  42614. stackClean = true;
  42615. break;
  42616. case 21:
  42617. y += stack.pop();
  42618. x += stack.pop();
  42619. moveTo(x, y);
  42620. stackClean = true;
  42621. break;
  42622. case 22:
  42623. x += stack.pop();
  42624. moveTo(x, y);
  42625. stackClean = true;
  42626. break;
  42627. case 23:
  42628. stems += stack.length >> 1;
  42629. stackClean = true;
  42630. break;
  42631. case 24:
  42632. while (stack.length > 2) {
  42633. xa = x + stack.shift();
  42634. ya = y + stack.shift();
  42635. xb = xa + stack.shift();
  42636. yb = ya + stack.shift();
  42637. x = xb + stack.shift();
  42638. y = yb + stack.shift();
  42639. bezierCurveTo(xa, ya, xb, yb, x, y);
  42640. }
  42641. x += stack.shift();
  42642. y += stack.shift();
  42643. lineTo(x, y);
  42644. break;
  42645. case 25:
  42646. while (stack.length > 6) {
  42647. x += stack.shift();
  42648. y += stack.shift();
  42649. lineTo(x, y);
  42650. }
  42651. xa = x + stack.shift();
  42652. ya = y + stack.shift();
  42653. xb = xa + stack.shift();
  42654. yb = ya + stack.shift();
  42655. x = xb + stack.shift();
  42656. y = yb + stack.shift();
  42657. bezierCurveTo(xa, ya, xb, yb, x, y);
  42658. break;
  42659. case 26:
  42660. if (stack.length % 2) {
  42661. x += stack.shift();
  42662. }
  42663. while (stack.length > 0) {
  42664. xa = x;
  42665. ya = y + stack.shift();
  42666. xb = xa + stack.shift();
  42667. yb = ya + stack.shift();
  42668. x = xb;
  42669. y = yb + stack.shift();
  42670. bezierCurveTo(xa, ya, xb, yb, x, y);
  42671. }
  42672. break;
  42673. case 27:
  42674. if (stack.length % 2) {
  42675. y += stack.shift();
  42676. }
  42677. while (stack.length > 0) {
  42678. xa = x + stack.shift();
  42679. ya = y;
  42680. xb = xa + stack.shift();
  42681. yb = ya + stack.shift();
  42682. x = xb + stack.shift();
  42683. y = yb;
  42684. bezierCurveTo(xa, ya, xb, yb, x, y);
  42685. }
  42686. break;
  42687. case 28:
  42688. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  42689. i += 2;
  42690. break;
  42691. case 29:
  42692. n = stack.pop() + font.gsubrsBias;
  42693. subrCode = font.gsubrs[n];
  42694. if (subrCode) {
  42695. parse(subrCode);
  42696. }
  42697. break;
  42698. case 30:
  42699. while (stack.length > 0) {
  42700. xa = x;
  42701. ya = y + stack.shift();
  42702. xb = xa + stack.shift();
  42703. yb = ya + stack.shift();
  42704. x = xb + stack.shift();
  42705. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42706. bezierCurveTo(xa, ya, xb, yb, x, y);
  42707. if (stack.length === 0) {
  42708. break;
  42709. }
  42710. xa = x + stack.shift();
  42711. ya = y;
  42712. xb = xa + stack.shift();
  42713. yb = ya + stack.shift();
  42714. y = yb + stack.shift();
  42715. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42716. bezierCurveTo(xa, ya, xb, yb, x, y);
  42717. }
  42718. break;
  42719. case 31:
  42720. while (stack.length > 0) {
  42721. xa = x + stack.shift();
  42722. ya = y;
  42723. xb = xa + stack.shift();
  42724. yb = ya + stack.shift();
  42725. y = yb + stack.shift();
  42726. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42727. bezierCurveTo(xa, ya, xb, yb, x, y);
  42728. if (stack.length === 0) {
  42729. break;
  42730. }
  42731. xa = x;
  42732. ya = y + stack.shift();
  42733. xb = xa + stack.shift();
  42734. yb = ya + stack.shift();
  42735. x = xb + stack.shift();
  42736. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42737. bezierCurveTo(xa, ya, xb, yb, x, y);
  42738. }
  42739. break;
  42740. default:
  42741. if (v < 32) {
  42742. error('unknown operator: ' + v);
  42743. }
  42744. if (v < 247) {
  42745. stack.push(v - 139);
  42746. } else if (v < 251) {
  42747. stack.push((v - 247) * 256 + code[i++] + 108);
  42748. } else if (v < 255) {
  42749. stack.push(-(v - 251) * 256 - code[i++] - 108);
  42750. } else {
  42751. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  42752. i += 4;
  42753. }
  42754. break;
  42755. }
  42756. if (stackClean) {
  42757. stack.length = 0;
  42758. }
  42759. }
  42760. }
  42761. parse(code);
  42762. }
  42763. var noop = '';
  42764. function CompiledFont(fontMatrix) {
  42765. this.compiledGlyphs = Object.create(null);
  42766. this.compiledCharCodeToGlyphId = Object.create(null);
  42767. this.fontMatrix = fontMatrix;
  42768. }
  42769. CompiledFont.prototype = {
  42770. getPathJs: function (unicode) {
  42771. var cmap = lookupCmap(this.cmap, unicode);
  42772. var fn = this.compiledGlyphs[cmap.glyphId];
  42773. if (!fn) {
  42774. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  42775. this.compiledGlyphs[cmap.glyphId] = fn;
  42776. }
  42777. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  42778. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  42779. }
  42780. return fn;
  42781. },
  42782. compileGlyph: function (code) {
  42783. if (!code || code.length === 0 || code[0] === 14) {
  42784. return noop;
  42785. }
  42786. var cmds = [];
  42787. cmds.push({ cmd: 'save' });
  42788. cmds.push({
  42789. cmd: 'transform',
  42790. args: this.fontMatrix.slice()
  42791. });
  42792. cmds.push({
  42793. cmd: 'scale',
  42794. args: [
  42795. 'size',
  42796. '-size'
  42797. ]
  42798. });
  42799. this.compileGlyphImpl(code, cmds);
  42800. cmds.push({ cmd: 'restore' });
  42801. return cmds;
  42802. },
  42803. compileGlyphImpl: function () {
  42804. error('Children classes should implement this.');
  42805. },
  42806. hasBuiltPath: function (unicode) {
  42807. var cmap = lookupCmap(this.cmap, unicode);
  42808. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  42809. }
  42810. };
  42811. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  42812. fontMatrix = fontMatrix || [
  42813. 0.000488,
  42814. 0,
  42815. 0,
  42816. 0.000488,
  42817. 0,
  42818. 0
  42819. ];
  42820. CompiledFont.call(this, fontMatrix);
  42821. this.glyphs = glyphs;
  42822. this.cmap = cmap;
  42823. }
  42824. Util.inherit(TrueTypeCompiled, CompiledFont, {
  42825. compileGlyphImpl: function (code, cmds) {
  42826. compileGlyf(code, cmds, this);
  42827. }
  42828. });
  42829. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  42830. fontMatrix = fontMatrix || [
  42831. 0.001,
  42832. 0,
  42833. 0,
  42834. 0.001,
  42835. 0,
  42836. 0
  42837. ];
  42838. CompiledFont.call(this, fontMatrix);
  42839. this.glyphs = cffInfo.glyphs;
  42840. this.gsubrs = cffInfo.gsubrs || [];
  42841. this.subrs = cffInfo.subrs || [];
  42842. this.cmap = cmap;
  42843. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  42844. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  42845. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  42846. }
  42847. Util.inherit(Type2Compiled, CompiledFont, {
  42848. compileGlyphImpl: function (code, cmds) {
  42849. compileCharString(code, cmds, this);
  42850. }
  42851. });
  42852. return {
  42853. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  42854. var data = new Uint8Array(font.data);
  42855. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  42856. var numTables = getUshort(data, 4);
  42857. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  42858. var tag = bytesToString(data.subarray(p, p + 4));
  42859. var offset = getLong(data, p + 8);
  42860. var length = getLong(data, p + 12);
  42861. switch (tag) {
  42862. case 'cmap':
  42863. cmap = parseCmap(data, offset, offset + length);
  42864. break;
  42865. case 'glyf':
  42866. glyf = data.subarray(offset, offset + length);
  42867. break;
  42868. case 'loca':
  42869. loca = data.subarray(offset, offset + length);
  42870. break;
  42871. case 'head':
  42872. unitsPerEm = getUshort(data, offset + 18);
  42873. indexToLocFormat = getUshort(data, offset + 50);
  42874. break;
  42875. case 'CFF ':
  42876. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  42877. break;
  42878. }
  42879. }
  42880. if (glyf) {
  42881. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  42882. 1 / unitsPerEm,
  42883. 0,
  42884. 0,
  42885. 1 / unitsPerEm,
  42886. 0,
  42887. 0
  42888. ];
  42889. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  42890. }
  42891. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  42892. }
  42893. };
  42894. }();
  42895. exports.FontRendererFactory = FontRendererFactory;
  42896. /***/ }),
  42897. /* 33 */
  42898. /***/ (function(module, exports, __w_pdfjs_require__) {
  42899. "use strict";
  42900. var sharedUtil = __w_pdfjs_require__(0);
  42901. var corePrimitives = __w_pdfjs_require__(1);
  42902. var coreStream = __w_pdfjs_require__(2);
  42903. var coreGlyphList = __w_pdfjs_require__(8);
  42904. var coreFontRenderer = __w_pdfjs_require__(32);
  42905. var coreEncodings = __w_pdfjs_require__(5);
  42906. var coreStandardFonts = __w_pdfjs_require__(21);
  42907. var coreUnicode = __w_pdfjs_require__(22);
  42908. var coreType1Parser = __w_pdfjs_require__(43);
  42909. var coreCFFParser = __w_pdfjs_require__(15);
  42910. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42911. var FontType = sharedUtil.FontType;
  42912. var assert = sharedUtil.assert;
  42913. var bytesToString = sharedUtil.bytesToString;
  42914. var error = sharedUtil.error;
  42915. var info = sharedUtil.info;
  42916. var isArray = sharedUtil.isArray;
  42917. var isInt = sharedUtil.isInt;
  42918. var isNum = sharedUtil.isNum;
  42919. var readUint32 = sharedUtil.readUint32;
  42920. var shadow = sharedUtil.shadow;
  42921. var string32 = sharedUtil.string32;
  42922. var warn = sharedUtil.warn;
  42923. var MissingDataException = sharedUtil.MissingDataException;
  42924. var isSpace = sharedUtil.isSpace;
  42925. var Stream = coreStream.Stream;
  42926. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42927. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42928. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42929. var StandardEncoding = coreEncodings.StandardEncoding;
  42930. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42931. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42932. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42933. var getEncoding = coreEncodings.getEncoding;
  42934. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42935. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42936. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42937. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42938. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42939. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42940. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42941. var Type1Parser = coreType1Parser.Type1Parser;
  42942. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42943. var CFFParser = coreCFFParser.CFFParser;
  42944. var CFFCompiler = coreCFFParser.CFFCompiler;
  42945. var CFF = coreCFFParser.CFF;
  42946. var CFFHeader = coreCFFParser.CFFHeader;
  42947. var CFFTopDict = coreCFFParser.CFFTopDict;
  42948. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42949. var CFFStrings = coreCFFParser.CFFStrings;
  42950. var CFFIndex = coreCFFParser.CFFIndex;
  42951. var CFFCharset = coreCFFParser.CFFCharset;
  42952. var PRIVATE_USE_OFFSET_START = 0xE000;
  42953. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42954. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42955. var PDF_GLYPH_SPACE_UNITS = 1000;
  42956. var SEAC_ANALYSIS_ENABLED = false;
  42957. var FontFlags = {
  42958. FixedPitch: 1,
  42959. Serif: 2,
  42960. Symbolic: 4,
  42961. Script: 8,
  42962. Nonsymbolic: 32,
  42963. Italic: 64,
  42964. AllCap: 65536,
  42965. SmallCap: 131072,
  42966. ForceBold: 262144
  42967. };
  42968. var MacStandardGlyphOrdering = [
  42969. '.notdef',
  42970. '.null',
  42971. 'nonmarkingreturn',
  42972. 'space',
  42973. 'exclam',
  42974. 'quotedbl',
  42975. 'numbersign',
  42976. 'dollar',
  42977. 'percent',
  42978. 'ampersand',
  42979. 'quotesingle',
  42980. 'parenleft',
  42981. 'parenright',
  42982. 'asterisk',
  42983. 'plus',
  42984. 'comma',
  42985. 'hyphen',
  42986. 'period',
  42987. 'slash',
  42988. 'zero',
  42989. 'one',
  42990. 'two',
  42991. 'three',
  42992. 'four',
  42993. 'five',
  42994. 'six',
  42995. 'seven',
  42996. 'eight',
  42997. 'nine',
  42998. 'colon',
  42999. 'semicolon',
  43000. 'less',
  43001. 'equal',
  43002. 'greater',
  43003. 'question',
  43004. 'at',
  43005. 'A',
  43006. 'B',
  43007. 'C',
  43008. 'D',
  43009. 'E',
  43010. 'F',
  43011. 'G',
  43012. 'H',
  43013. 'I',
  43014. 'J',
  43015. 'K',
  43016. 'L',
  43017. 'M',
  43018. 'N',
  43019. 'O',
  43020. 'P',
  43021. 'Q',
  43022. 'R',
  43023. 'S',
  43024. 'T',
  43025. 'U',
  43026. 'V',
  43027. 'W',
  43028. 'X',
  43029. 'Y',
  43030. 'Z',
  43031. 'bracketleft',
  43032. 'backslash',
  43033. 'bracketright',
  43034. 'asciicircum',
  43035. 'underscore',
  43036. 'grave',
  43037. 'a',
  43038. 'b',
  43039. 'c',
  43040. 'd',
  43041. 'e',
  43042. 'f',
  43043. 'g',
  43044. 'h',
  43045. 'i',
  43046. 'j',
  43047. 'k',
  43048. 'l',
  43049. 'm',
  43050. 'n',
  43051. 'o',
  43052. 'p',
  43053. 'q',
  43054. 'r',
  43055. 's',
  43056. 't',
  43057. 'u',
  43058. 'v',
  43059. 'w',
  43060. 'x',
  43061. 'y',
  43062. 'z',
  43063. 'braceleft',
  43064. 'bar',
  43065. 'braceright',
  43066. 'asciitilde',
  43067. 'Adieresis',
  43068. 'Aring',
  43069. 'Ccedilla',
  43070. 'Eacute',
  43071. 'Ntilde',
  43072. 'Odieresis',
  43073. 'Udieresis',
  43074. 'aacute',
  43075. 'agrave',
  43076. 'acircumflex',
  43077. 'adieresis',
  43078. 'atilde',
  43079. 'aring',
  43080. 'ccedilla',
  43081. 'eacute',
  43082. 'egrave',
  43083. 'ecircumflex',
  43084. 'edieresis',
  43085. 'iacute',
  43086. 'igrave',
  43087. 'icircumflex',
  43088. 'idieresis',
  43089. 'ntilde',
  43090. 'oacute',
  43091. 'ograve',
  43092. 'ocircumflex',
  43093. 'odieresis',
  43094. 'otilde',
  43095. 'uacute',
  43096. 'ugrave',
  43097. 'ucircumflex',
  43098. 'udieresis',
  43099. 'dagger',
  43100. 'degree',
  43101. 'cent',
  43102. 'sterling',
  43103. 'section',
  43104. 'bullet',
  43105. 'paragraph',
  43106. 'germandbls',
  43107. 'registered',
  43108. 'copyright',
  43109. 'trademark',
  43110. 'acute',
  43111. 'dieresis',
  43112. 'notequal',
  43113. 'AE',
  43114. 'Oslash',
  43115. 'infinity',
  43116. 'plusminus',
  43117. 'lessequal',
  43118. 'greaterequal',
  43119. 'yen',
  43120. 'mu',
  43121. 'partialdiff',
  43122. 'summation',
  43123. 'product',
  43124. 'pi',
  43125. 'integral',
  43126. 'ordfeminine',
  43127. 'ordmasculine',
  43128. 'Omega',
  43129. 'ae',
  43130. 'oslash',
  43131. 'questiondown',
  43132. 'exclamdown',
  43133. 'logicalnot',
  43134. 'radical',
  43135. 'florin',
  43136. 'approxequal',
  43137. 'Delta',
  43138. 'guillemotleft',
  43139. 'guillemotright',
  43140. 'ellipsis',
  43141. 'nonbreakingspace',
  43142. 'Agrave',
  43143. 'Atilde',
  43144. 'Otilde',
  43145. 'OE',
  43146. 'oe',
  43147. 'endash',
  43148. 'emdash',
  43149. 'quotedblleft',
  43150. 'quotedblright',
  43151. 'quoteleft',
  43152. 'quoteright',
  43153. 'divide',
  43154. 'lozenge',
  43155. 'ydieresis',
  43156. 'Ydieresis',
  43157. 'fraction',
  43158. 'currency',
  43159. 'guilsinglleft',
  43160. 'guilsinglright',
  43161. 'fi',
  43162. 'fl',
  43163. 'daggerdbl',
  43164. 'periodcentered',
  43165. 'quotesinglbase',
  43166. 'quotedblbase',
  43167. 'perthousand',
  43168. 'Acircumflex',
  43169. 'Ecircumflex',
  43170. 'Aacute',
  43171. 'Edieresis',
  43172. 'Egrave',
  43173. 'Iacute',
  43174. 'Icircumflex',
  43175. 'Idieresis',
  43176. 'Igrave',
  43177. 'Oacute',
  43178. 'Ocircumflex',
  43179. 'apple',
  43180. 'Ograve',
  43181. 'Uacute',
  43182. 'Ucircumflex',
  43183. 'Ugrave',
  43184. 'dotlessi',
  43185. 'circumflex',
  43186. 'tilde',
  43187. 'macron',
  43188. 'breve',
  43189. 'dotaccent',
  43190. 'ring',
  43191. 'cedilla',
  43192. 'hungarumlaut',
  43193. 'ogonek',
  43194. 'caron',
  43195. 'Lslash',
  43196. 'lslash',
  43197. 'Scaron',
  43198. 'scaron',
  43199. 'Zcaron',
  43200. 'zcaron',
  43201. 'brokenbar',
  43202. 'Eth',
  43203. 'eth',
  43204. 'Yacute',
  43205. 'yacute',
  43206. 'Thorn',
  43207. 'thorn',
  43208. 'minus',
  43209. 'multiply',
  43210. 'onesuperior',
  43211. 'twosuperior',
  43212. 'threesuperior',
  43213. 'onehalf',
  43214. 'onequarter',
  43215. 'threequarters',
  43216. 'franc',
  43217. 'Gbreve',
  43218. 'gbreve',
  43219. 'Idotaccent',
  43220. 'Scedilla',
  43221. 'scedilla',
  43222. 'Cacute',
  43223. 'cacute',
  43224. 'Ccaron',
  43225. 'ccaron',
  43226. 'dcroat'
  43227. ];
  43228. function adjustWidths(properties) {
  43229. if (!properties.fontMatrix) {
  43230. return;
  43231. }
  43232. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  43233. return;
  43234. }
  43235. var scale = 0.001 / properties.fontMatrix[0];
  43236. var glyphsWidths = properties.widths;
  43237. for (var glyph in glyphsWidths) {
  43238. glyphsWidths[glyph] *= scale;
  43239. }
  43240. properties.defaultWidth *= scale;
  43241. }
  43242. function adjustToUnicode(properties, builtInEncoding) {
  43243. if (properties.hasIncludedToUnicodeMap) {
  43244. return;
  43245. }
  43246. if (properties.hasEncoding) {
  43247. return;
  43248. }
  43249. if (builtInEncoding === properties.defaultEncoding) {
  43250. return;
  43251. }
  43252. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  43253. return;
  43254. }
  43255. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  43256. for (var charCode in builtInEncoding) {
  43257. var glyphName = builtInEncoding[charCode];
  43258. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43259. if (unicode !== -1) {
  43260. toUnicode[charCode] = String.fromCharCode(unicode);
  43261. }
  43262. }
  43263. properties.toUnicode.amend(toUnicode);
  43264. }
  43265. function getFontType(type, subtype) {
  43266. switch (type) {
  43267. case 'Type1':
  43268. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  43269. case 'CIDFontType0':
  43270. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  43271. case 'OpenType':
  43272. return FontType.OPENTYPE;
  43273. case 'TrueType':
  43274. return FontType.TRUETYPE;
  43275. case 'CIDFontType2':
  43276. return FontType.CIDFONTTYPE2;
  43277. case 'MMType1':
  43278. return FontType.MMTYPE1;
  43279. case 'Type0':
  43280. return FontType.TYPE0;
  43281. default:
  43282. return FontType.UNKNOWN;
  43283. }
  43284. }
  43285. function recoverGlyphName(name, glyphsUnicodeMap) {
  43286. if (glyphsUnicodeMap[name] !== undefined) {
  43287. return name;
  43288. }
  43289. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  43290. if (unicode !== -1) {
  43291. for (var key in glyphsUnicodeMap) {
  43292. if (glyphsUnicodeMap[key] === unicode) {
  43293. return key;
  43294. }
  43295. }
  43296. }
  43297. info('Unable to recover a standard glyph name for: ' + name);
  43298. return name;
  43299. }
  43300. var Glyph = function GlyphClosure() {
  43301. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43302. this.fontChar = fontChar;
  43303. this.unicode = unicode;
  43304. this.accent = accent;
  43305. this.width = width;
  43306. this.vmetric = vmetric;
  43307. this.operatorListId = operatorListId;
  43308. this.isSpace = isSpace;
  43309. this.isInFont = isInFont;
  43310. }
  43311. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43312. return this.fontChar === fontChar && this.unicode === unicode && this.accent === accent && this.width === width && this.vmetric === vmetric && this.operatorListId === operatorListId && this.isSpace === isSpace && this.isInFont === isInFont;
  43313. };
  43314. return Glyph;
  43315. }();
  43316. var ToUnicodeMap = function ToUnicodeMapClosure() {
  43317. function ToUnicodeMap(cmap) {
  43318. this._map = cmap;
  43319. }
  43320. ToUnicodeMap.prototype = {
  43321. get length() {
  43322. return this._map.length;
  43323. },
  43324. forEach: function (callback) {
  43325. for (var charCode in this._map) {
  43326. callback(charCode, this._map[charCode].charCodeAt(0));
  43327. }
  43328. },
  43329. has: function (i) {
  43330. return this._map[i] !== undefined;
  43331. },
  43332. get: function (i) {
  43333. return this._map[i];
  43334. },
  43335. charCodeOf: function (v) {
  43336. return this._map.indexOf(v);
  43337. },
  43338. amend: function (map) {
  43339. for (var charCode in map) {
  43340. this._map[charCode] = map[charCode];
  43341. }
  43342. }
  43343. };
  43344. return ToUnicodeMap;
  43345. }();
  43346. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  43347. function IdentityToUnicodeMap(firstChar, lastChar) {
  43348. this.firstChar = firstChar;
  43349. this.lastChar = lastChar;
  43350. }
  43351. IdentityToUnicodeMap.prototype = {
  43352. get length() {
  43353. return this.lastChar + 1 - this.firstChar;
  43354. },
  43355. forEach: function (callback) {
  43356. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  43357. callback(i, i);
  43358. }
  43359. },
  43360. has: function (i) {
  43361. return this.firstChar <= i && i <= this.lastChar;
  43362. },
  43363. get: function (i) {
  43364. if (this.firstChar <= i && i <= this.lastChar) {
  43365. return String.fromCharCode(i);
  43366. }
  43367. return undefined;
  43368. },
  43369. charCodeOf: function (v) {
  43370. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  43371. },
  43372. amend: function (map) {
  43373. error('Should not call amend()');
  43374. }
  43375. };
  43376. return IdentityToUnicodeMap;
  43377. }();
  43378. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  43379. function writeInt16(dest, offset, num) {
  43380. dest[offset] = num >> 8 & 0xFF;
  43381. dest[offset + 1] = num & 0xFF;
  43382. }
  43383. function writeInt32(dest, offset, num) {
  43384. dest[offset] = num >> 24 & 0xFF;
  43385. dest[offset + 1] = num >> 16 & 0xFF;
  43386. dest[offset + 2] = num >> 8 & 0xFF;
  43387. dest[offset + 3] = num & 0xFF;
  43388. }
  43389. function writeData(dest, offset, data) {
  43390. var i, ii;
  43391. if (data instanceof Uint8Array) {
  43392. dest.set(data, offset);
  43393. } else if (typeof data === 'string') {
  43394. for (i = 0, ii = data.length; i < ii; i++) {
  43395. dest[offset++] = data.charCodeAt(i) & 0xFF;
  43396. }
  43397. } else {
  43398. for (i = 0, ii = data.length; i < ii; i++) {
  43399. dest[offset++] = data[i] & 0xFF;
  43400. }
  43401. }
  43402. }
  43403. function OpenTypeFileBuilder(sfnt) {
  43404. this.sfnt = sfnt;
  43405. this.tables = Object.create(null);
  43406. }
  43407. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  43408. var maxPower2 = 1, log2 = 0;
  43409. while ((maxPower2 ^ entriesCount) > maxPower2) {
  43410. maxPower2 <<= 1;
  43411. log2++;
  43412. }
  43413. var searchRange = maxPower2 * entrySize;
  43414. return {
  43415. range: searchRange,
  43416. entry: log2,
  43417. rangeShift: entrySize * entriesCount - searchRange
  43418. };
  43419. };
  43420. var OTF_HEADER_SIZE = 12;
  43421. var OTF_TABLE_ENTRY_SIZE = 16;
  43422. OpenTypeFileBuilder.prototype = {
  43423. toArray: function OpenTypeFileBuilder_toArray() {
  43424. var sfnt = this.sfnt;
  43425. var tables = this.tables;
  43426. var tablesNames = Object.keys(tables);
  43427. tablesNames.sort();
  43428. var numTables = tablesNames.length;
  43429. var i, j, jj, table, tableName;
  43430. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  43431. var tableOffsets = [offset];
  43432. for (i = 0; i < numTables; i++) {
  43433. table = tables[tablesNames[i]];
  43434. var paddedLength = (table.length + 3 & ~3) >>> 0;
  43435. offset += paddedLength;
  43436. tableOffsets.push(offset);
  43437. }
  43438. var file = new Uint8Array(offset);
  43439. for (i = 0; i < numTables; i++) {
  43440. table = tables[tablesNames[i]];
  43441. writeData(file, tableOffsets[i], table);
  43442. }
  43443. if (sfnt === 'true') {
  43444. sfnt = string32(0x00010000);
  43445. }
  43446. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43447. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43448. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43449. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43450. writeInt16(file, 4, numTables);
  43451. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43452. writeInt16(file, 6, searchParams.range);
  43453. writeInt16(file, 8, searchParams.entry);
  43454. writeInt16(file, 10, searchParams.rangeShift);
  43455. offset = OTF_HEADER_SIZE;
  43456. for (i = 0; i < numTables; i++) {
  43457. tableName = tablesNames[i];
  43458. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43459. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43460. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43461. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43462. var checksum = 0;
  43463. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43464. var quad = readUint32(file, j);
  43465. checksum = checksum + quad >>> 0;
  43466. }
  43467. writeInt32(file, offset + 4, checksum);
  43468. writeInt32(file, offset + 8, tableOffsets[i]);
  43469. writeInt32(file, offset + 12, tables[tableName].length);
  43470. offset += OTF_TABLE_ENTRY_SIZE;
  43471. }
  43472. return file;
  43473. },
  43474. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43475. if (tag in this.tables) {
  43476. throw new Error('Table ' + tag + ' already exists');
  43477. }
  43478. this.tables[tag] = data;
  43479. }
  43480. };
  43481. return OpenTypeFileBuilder;
  43482. }();
  43483. var ProblematicCharRanges = new Int32Array([
  43484. 0x0000,
  43485. 0x0020,
  43486. 0x007F,
  43487. 0x00A1,
  43488. 0x00AD,
  43489. 0x00AE,
  43490. 0x0600,
  43491. 0x0780,
  43492. 0x08A0,
  43493. 0x10A0,
  43494. 0x1780,
  43495. 0x1800,
  43496. 0x1C00,
  43497. 0x1C50,
  43498. 0x2000,
  43499. 0x2010,
  43500. 0x2011,
  43501. 0x2012,
  43502. 0x2028,
  43503. 0x2030,
  43504. 0x205F,
  43505. 0x2070,
  43506. 0x25CC,
  43507. 0x25CD,
  43508. 0x3000,
  43509. 0x3001,
  43510. 0xAA60,
  43511. 0xAA80,
  43512. 0xFFF0,
  43513. 0x10000
  43514. ]);
  43515. var Font = function FontClosure() {
  43516. function Font(name, file, properties) {
  43517. var charCode, glyphName, unicode;
  43518. this.name = name;
  43519. this.loadedName = properties.loadedName;
  43520. this.isType3Font = properties.isType3Font;
  43521. this.sizes = [];
  43522. this.missingFile = false;
  43523. this.glyphCache = Object.create(null);
  43524. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43525. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43526. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43527. var type = properties.type;
  43528. var subtype = properties.subtype;
  43529. this.type = type;
  43530. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43531. this.differences = properties.differences;
  43532. this.widths = properties.widths;
  43533. this.defaultWidth = properties.defaultWidth;
  43534. this.composite = properties.composite;
  43535. this.wideChars = properties.wideChars;
  43536. this.cMap = properties.cMap;
  43537. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43538. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43539. this.fontMatrix = properties.fontMatrix;
  43540. this.bbox = properties.bbox;
  43541. this.toUnicode = properties.toUnicode;
  43542. this.toFontChar = [];
  43543. if (properties.type === 'Type3') {
  43544. for (charCode = 0; charCode < 256; charCode++) {
  43545. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43546. }
  43547. this.fontType = FontType.TYPE3;
  43548. return;
  43549. }
  43550. this.cidEncoding = properties.cidEncoding;
  43551. this.vertical = properties.vertical;
  43552. if (this.vertical) {
  43553. this.vmetrics = properties.vmetrics;
  43554. this.defaultVMetrics = properties.defaultVMetrics;
  43555. }
  43556. var glyphsUnicodeMap;
  43557. if (!file || file.isEmpty) {
  43558. if (file) {
  43559. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43560. }
  43561. this.missingFile = true;
  43562. var fontName = name.replace(/[,_]/g, '-');
  43563. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43564. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43565. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43566. this.bold = fontName.search(/bold/gi) !== -1;
  43567. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43568. this.black = name.search(/Black/g) !== -1;
  43569. this.remeasure = Object.keys(this.widths).length > 0;
  43570. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43571. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43572. var map = [];
  43573. for (charCode in GlyphMapForStandardFonts) {
  43574. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43575. }
  43576. if (/Arial-?Black/i.test(name)) {
  43577. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43578. for (charCode in SupplementalGlyphMapForArialBlack) {
  43579. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43580. }
  43581. }
  43582. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43583. if (!isIdentityUnicode) {
  43584. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43585. map[+charCode] = unicodeCharCode;
  43586. });
  43587. }
  43588. this.toFontChar = map;
  43589. this.toUnicode = new ToUnicodeMap(map);
  43590. } else if (/Symbol/i.test(fontName)) {
  43591. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43592. } else if (/Dingbats/i.test(fontName)) {
  43593. if (/Wingdings/i.test(name)) {
  43594. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43595. }
  43596. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43597. } else if (isStandardFont) {
  43598. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43599. } else {
  43600. glyphsUnicodeMap = getGlyphsUnicode();
  43601. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43602. if (!this.composite) {
  43603. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43604. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43605. if (unicode !== -1) {
  43606. unicodeCharCode = unicode;
  43607. }
  43608. }
  43609. this.toFontChar[charCode] = unicodeCharCode;
  43610. }.bind(this));
  43611. }
  43612. this.loadedName = fontName.split('-')[0];
  43613. this.loading = false;
  43614. this.fontType = getFontType(type, subtype);
  43615. return;
  43616. }
  43617. if (subtype === 'Type1C') {
  43618. if (type !== 'Type1' && type !== 'MMType1') {
  43619. if (isTrueTypeFile(file)) {
  43620. subtype = 'TrueType';
  43621. } else {
  43622. type = 'Type1';
  43623. }
  43624. } else if (isOpenTypeFile(file)) {
  43625. type = subtype = 'OpenType';
  43626. }
  43627. }
  43628. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43629. type = 'CIDFontType0';
  43630. }
  43631. if (subtype === 'OpenType') {
  43632. type = 'OpenType';
  43633. }
  43634. if (type === 'CIDFontType0') {
  43635. if (isType1File(file)) {
  43636. subtype = 'CIDFontType0';
  43637. } else if (isOpenTypeFile(file)) {
  43638. type = subtype = 'OpenType';
  43639. } else {
  43640. subtype = 'CIDFontType0C';
  43641. }
  43642. }
  43643. var data;
  43644. switch (type) {
  43645. case 'MMType1':
  43646. info('MMType1 font (' + name + '), falling back to Type1.');
  43647. case 'Type1':
  43648. case 'CIDFontType0':
  43649. this.mimetype = 'font/opentype';
  43650. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43651. adjustWidths(properties);
  43652. data = this.convert(name, cff, properties);
  43653. break;
  43654. case 'OpenType':
  43655. case 'TrueType':
  43656. case 'CIDFontType2':
  43657. this.mimetype = 'font/opentype';
  43658. data = this.checkAndRepair(name, file, properties);
  43659. if (this.isOpenType) {
  43660. adjustWidths(properties);
  43661. type = 'OpenType';
  43662. }
  43663. break;
  43664. default:
  43665. error('Font ' + type + ' is not supported');
  43666. break;
  43667. }
  43668. this.data = data;
  43669. this.fontType = getFontType(type, subtype);
  43670. this.fontMatrix = properties.fontMatrix;
  43671. this.widths = properties.widths;
  43672. this.defaultWidth = properties.defaultWidth;
  43673. this.toUnicode = properties.toUnicode;
  43674. this.encoding = properties.baseEncoding;
  43675. this.seacMap = properties.seacMap;
  43676. this.loading = true;
  43677. }
  43678. Font.getFontID = function () {
  43679. var ID = 1;
  43680. return function Font_getFontID() {
  43681. return String(ID++);
  43682. };
  43683. }();
  43684. function int16(b0, b1) {
  43685. return (b0 << 8) + b1;
  43686. }
  43687. function signedInt16(b0, b1) {
  43688. var value = (b0 << 8) + b1;
  43689. return value & 1 << 15 ? value - 0x10000 : value;
  43690. }
  43691. function int32(b0, b1, b2, b3) {
  43692. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43693. }
  43694. function string16(value) {
  43695. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43696. }
  43697. function safeString16(value) {
  43698. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43699. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43700. }
  43701. function isTrueTypeFile(file) {
  43702. var header = file.peekBytes(4);
  43703. return readUint32(header, 0) === 0x00010000;
  43704. }
  43705. function isOpenTypeFile(file) {
  43706. var header = file.peekBytes(4);
  43707. return bytesToString(header) === 'OTTO';
  43708. }
  43709. function isType1File(file) {
  43710. var header = file.peekBytes(2);
  43711. if (header[0] === 0x25 && header[1] === 0x21) {
  43712. return true;
  43713. }
  43714. if (header[0] === 0x80 && header[1] === 0x01) {
  43715. return true;
  43716. }
  43717. return false;
  43718. }
  43719. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43720. var toFontChar = [], unicode;
  43721. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43722. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43723. if (unicode !== -1) {
  43724. toFontChar[i] = unicode;
  43725. }
  43726. }
  43727. for (var charCode in differences) {
  43728. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43729. if (unicode !== -1) {
  43730. toFontChar[+charCode] = unicode;
  43731. }
  43732. }
  43733. return toFontChar;
  43734. }
  43735. function isProblematicUnicodeLocation(code) {
  43736. var i = 0, j = ProblematicCharRanges.length - 1;
  43737. while (i < j) {
  43738. var c = i + j + 1 >> 1;
  43739. if (code < ProblematicCharRanges[c]) {
  43740. j = c - 1;
  43741. } else {
  43742. i = c;
  43743. }
  43744. }
  43745. return !(i & 1);
  43746. }
  43747. function adjustMapping(charCodeToGlyphId, properties) {
  43748. var toUnicode = properties.toUnicode;
  43749. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43750. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43751. var newMap = Object.create(null);
  43752. var toFontChar = [];
  43753. var usedFontCharCodes = [];
  43754. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43755. for (var originalCharCode in charCodeToGlyphId) {
  43756. originalCharCode |= 0;
  43757. var glyphId = charCodeToGlyphId[originalCharCode];
  43758. var fontCharCode = originalCharCode;
  43759. var hasUnicodeValue = false;
  43760. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43761. hasUnicodeValue = true;
  43762. var unicode = toUnicode.get(fontCharCode);
  43763. if (unicode.length === 1) {
  43764. fontCharCode = unicode.charCodeAt(0);
  43765. }
  43766. }
  43767. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43768. do {
  43769. fontCharCode = nextAvailableFontCharCode++;
  43770. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43771. fontCharCode = 0xF020;
  43772. nextAvailableFontCharCode = fontCharCode + 1;
  43773. }
  43774. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43775. }
  43776. newMap[fontCharCode] = glyphId;
  43777. toFontChar[originalCharCode] = fontCharCode;
  43778. usedFontCharCodes[fontCharCode] = true;
  43779. }
  43780. return {
  43781. toFontChar: toFontChar,
  43782. charCodeToGlyphId: newMap,
  43783. nextAvailableFontCharCode: nextAvailableFontCharCode
  43784. };
  43785. }
  43786. function getRanges(glyphs, numGlyphs) {
  43787. var codes = [];
  43788. for (var charCode in glyphs) {
  43789. if (glyphs[charCode] >= numGlyphs) {
  43790. continue;
  43791. }
  43792. codes.push({
  43793. fontCharCode: charCode | 0,
  43794. glyphId: glyphs[charCode]
  43795. });
  43796. }
  43797. codes.sort(function fontGetRangesSort(a, b) {
  43798. return a.fontCharCode - b.fontCharCode;
  43799. });
  43800. var ranges = [];
  43801. var length = codes.length;
  43802. for (var n = 0; n < length;) {
  43803. var start = codes[n].fontCharCode;
  43804. var codeIndices = [codes[n].glyphId];
  43805. ++n;
  43806. var end = start;
  43807. while (n < length && end + 1 === codes[n].fontCharCode) {
  43808. codeIndices.push(codes[n].glyphId);
  43809. ++end;
  43810. ++n;
  43811. if (end === 0xFFFF) {
  43812. break;
  43813. }
  43814. }
  43815. ranges.push([
  43816. start,
  43817. end,
  43818. codeIndices
  43819. ]);
  43820. }
  43821. return ranges;
  43822. }
  43823. function createCmapTable(glyphs, numGlyphs) {
  43824. var ranges = getRanges(glyphs, numGlyphs);
  43825. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43826. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43827. var i, ii, j, jj;
  43828. for (i = ranges.length - 1; i >= 0; --i) {
  43829. if (ranges[i][0] <= 0xFFFF) {
  43830. break;
  43831. }
  43832. }
  43833. var bmpLength = i + 1;
  43834. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43835. ranges[i][1] = 0xFFFE;
  43836. }
  43837. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43838. var segCount = bmpLength + trailingRangesCount;
  43839. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43840. var startCount = '';
  43841. var endCount = '';
  43842. var idDeltas = '';
  43843. var idRangeOffsets = '';
  43844. var glyphsIds = '';
  43845. var bias = 0;
  43846. var range, start, end, codes;
  43847. for (i = 0, ii = bmpLength; i < ii; i++) {
  43848. range = ranges[i];
  43849. start = range[0];
  43850. end = range[1];
  43851. startCount += string16(start);
  43852. endCount += string16(end);
  43853. codes = range[2];
  43854. var contiguous = true;
  43855. for (j = 1, jj = codes.length; j < jj; ++j) {
  43856. if (codes[j] !== codes[j - 1] + 1) {
  43857. contiguous = false;
  43858. break;
  43859. }
  43860. }
  43861. if (!contiguous) {
  43862. var offset = (segCount - i) * 2 + bias * 2;
  43863. bias += end - start + 1;
  43864. idDeltas += string16(0);
  43865. idRangeOffsets += string16(offset);
  43866. for (j = 0, jj = codes.length; j < jj; ++j) {
  43867. glyphsIds += string16(codes[j]);
  43868. }
  43869. } else {
  43870. var startCode = codes[0];
  43871. idDeltas += string16(startCode - start & 0xFFFF);
  43872. idRangeOffsets += string16(0);
  43873. }
  43874. }
  43875. if (trailingRangesCount > 0) {
  43876. endCount += '\xFF\xFF';
  43877. startCount += '\xFF\xFF';
  43878. idDeltas += '\x00\x01';
  43879. idRangeOffsets += '\x00\x00';
  43880. }
  43881. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43882. var format31012 = '';
  43883. var header31012 = '';
  43884. if (numTables > 1) {
  43885. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43886. format31012 = '';
  43887. for (i = 0, ii = ranges.length; i < ii; i++) {
  43888. range = ranges[i];
  43889. start = range[0];
  43890. codes = range[2];
  43891. var code = codes[0];
  43892. for (j = 1, jj = codes.length; j < jj; ++j) {
  43893. if (codes[j] !== codes[j - 1] + 1) {
  43894. end = range[0] + j - 1;
  43895. format31012 += string32(start) + string32(end) + string32(code);
  43896. start = end + 1;
  43897. code = codes[j];
  43898. }
  43899. }
  43900. format31012 += string32(start) + string32(range[1]) + string32(code);
  43901. }
  43902. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43903. }
  43904. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43905. }
  43906. function validateOS2Table(os2) {
  43907. var stream = new Stream(os2.data);
  43908. var version = stream.getUint16();
  43909. stream.getBytes(60);
  43910. var selection = stream.getUint16();
  43911. if (version < 4 && selection & 0x0300) {
  43912. return false;
  43913. }
  43914. var firstChar = stream.getUint16();
  43915. var lastChar = stream.getUint16();
  43916. if (firstChar > lastChar) {
  43917. return false;
  43918. }
  43919. stream.getBytes(6);
  43920. var usWinAscent = stream.getUint16();
  43921. if (usWinAscent === 0) {
  43922. return false;
  43923. }
  43924. os2.data[8] = os2.data[9] = 0;
  43925. return true;
  43926. }
  43927. function createOS2Table(properties, charstrings, override) {
  43928. override = override || {
  43929. unitsPerEm: 0,
  43930. yMax: 0,
  43931. yMin: 0,
  43932. ascent: 0,
  43933. descent: 0
  43934. };
  43935. var ulUnicodeRange1 = 0;
  43936. var ulUnicodeRange2 = 0;
  43937. var ulUnicodeRange3 = 0;
  43938. var ulUnicodeRange4 = 0;
  43939. var firstCharIndex = null;
  43940. var lastCharIndex = 0;
  43941. if (charstrings) {
  43942. for (var code in charstrings) {
  43943. code |= 0;
  43944. if (firstCharIndex > code || !firstCharIndex) {
  43945. firstCharIndex = code;
  43946. }
  43947. if (lastCharIndex < code) {
  43948. lastCharIndex = code;
  43949. }
  43950. var position = getUnicodeRangeFor(code);
  43951. if (position < 32) {
  43952. ulUnicodeRange1 |= 1 << position;
  43953. } else if (position < 64) {
  43954. ulUnicodeRange2 |= 1 << position - 32;
  43955. } else if (position < 96) {
  43956. ulUnicodeRange3 |= 1 << position - 64;
  43957. } else if (position < 123) {
  43958. ulUnicodeRange4 |= 1 << position - 96;
  43959. } else {
  43960. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43961. }
  43962. }
  43963. } else {
  43964. firstCharIndex = 0;
  43965. lastCharIndex = 255;
  43966. }
  43967. var bbox = properties.bbox || [
  43968. 0,
  43969. 0,
  43970. 0,
  43971. 0
  43972. ];
  43973. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43974. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43975. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43976. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43977. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43978. typoDescent = -typoDescent;
  43979. }
  43980. var winAscent = override.yMax || typoAscent;
  43981. var winDescent = -override.yMin || -typoDescent;
  43982. return '\x00\x03' + '\x02\x24' + '\x01\xF4' + '\x00\x05' + '\x00\x00' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x00\x8C' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x01\xDF' + '\x00\x31' + '\x01\x02' + '\x00\x00' + '\x00\x00\x06' + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + '\x00\x00\x00\x00\x00\x00' + string32(ulUnicodeRange1) + string32(ulUnicodeRange2) + string32(ulUnicodeRange3) + string32(ulUnicodeRange4) + '\x2A\x32\x31\x2A' + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + '\x00\x64' + string16(winAscent) + string16(winDescent) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + '\x00\x03';
  43983. }
  43984. function createPostTable(properties) {
  43985. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43986. return '\x00\x03\x00\x00' + string32(angle) + '\x00\x00' + '\x00\x00' + string32(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
  43987. }
  43988. function createNameTable(name, proto) {
  43989. if (!proto) {
  43990. proto = [
  43991. [],
  43992. []
  43993. ];
  43994. }
  43995. var strings = [
  43996. proto[0][0] || 'Original licence',
  43997. proto[0][1] || name,
  43998. proto[0][2] || 'Unknown',
  43999. proto[0][3] || 'uniqueID',
  44000. proto[0][4] || name,
  44001. proto[0][5] || 'Version 0.11',
  44002. proto[0][6] || '',
  44003. proto[0][7] || 'Unknown',
  44004. proto[0][8] || 'Unknown',
  44005. proto[0][9] || 'Unknown'
  44006. ];
  44007. var stringsUnicode = [];
  44008. var i, ii, j, jj, str;
  44009. for (i = 0, ii = strings.length; i < ii; i++) {
  44010. str = proto[1][i] || strings[i];
  44011. var strBufUnicode = [];
  44012. for (j = 0, jj = str.length; j < jj; j++) {
  44013. strBufUnicode.push(string16(str.charCodeAt(j)));
  44014. }
  44015. stringsUnicode.push(strBufUnicode.join(''));
  44016. }
  44017. var names = [
  44018. strings,
  44019. stringsUnicode
  44020. ];
  44021. var platforms = [
  44022. '\x00\x01',
  44023. '\x00\x03'
  44024. ];
  44025. var encodings = [
  44026. '\x00\x00',
  44027. '\x00\x01'
  44028. ];
  44029. var languages = [
  44030. '\x00\x00',
  44031. '\x04\x09'
  44032. ];
  44033. var namesRecordCount = strings.length * platforms.length;
  44034. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44035. var strOffset = 0;
  44036. for (i = 0, ii = platforms.length; i < ii; i++) {
  44037. var strs = names[i];
  44038. for (j = 0, jj = strs.length; j < jj; j++) {
  44039. str = strs[j];
  44040. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44041. nameTable += nameRecord;
  44042. strOffset += str.length;
  44043. }
  44044. }
  44045. nameTable += strings.join('') + stringsUnicode.join('');
  44046. return nameTable;
  44047. }
  44048. Font.prototype = {
  44049. name: null,
  44050. font: null,
  44051. mimetype: null,
  44052. encoding: null,
  44053. get renderer() {
  44054. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44055. return shadow(this, 'renderer', renderer);
  44056. },
  44057. exportData: function Font_exportData() {
  44058. var data = {};
  44059. for (var i in this) {
  44060. if (this.hasOwnProperty(i)) {
  44061. data[i] = this[i];
  44062. }
  44063. }
  44064. return data;
  44065. },
  44066. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44067. function readTableEntry(file) {
  44068. var tag = bytesToString(file.getBytes(4));
  44069. var checksum = file.getInt32() >>> 0;
  44070. var offset = file.getInt32() >>> 0;
  44071. var length = file.getInt32() >>> 0;
  44072. var previousPosition = file.pos;
  44073. file.pos = file.start ? file.start : 0;
  44074. file.skip(offset);
  44075. var data = file.getBytes(length);
  44076. file.pos = previousPosition;
  44077. if (tag === 'head') {
  44078. data[8] = data[9] = data[10] = data[11] = 0;
  44079. data[17] |= 0x20;
  44080. }
  44081. return {
  44082. tag: tag,
  44083. checksum: checksum,
  44084. length: length,
  44085. offset: offset,
  44086. data: data
  44087. };
  44088. }
  44089. function readOpenTypeHeader(ttf) {
  44090. return {
  44091. version: bytesToString(ttf.getBytes(4)),
  44092. numTables: ttf.getUint16(),
  44093. searchRange: ttf.getUint16(),
  44094. entrySelector: ttf.getUint16(),
  44095. rangeShift: ttf.getUint16()
  44096. };
  44097. }
  44098. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44099. if (!cmap) {
  44100. warn('No cmap table available.');
  44101. return {
  44102. platformId: -1,
  44103. encodingId: -1,
  44104. mappings: [],
  44105. hasShortCmap: false
  44106. };
  44107. }
  44108. var segment;
  44109. var start = (font.start ? font.start : 0) + cmap.offset;
  44110. font.pos = start;
  44111. font.getUint16();
  44112. var numTables = font.getUint16();
  44113. var potentialTable;
  44114. var canBreak = false;
  44115. for (var i = 0; i < numTables; i++) {
  44116. var platformId = font.getUint16();
  44117. var encodingId = font.getUint16();
  44118. var offset = font.getInt32() >>> 0;
  44119. var useTable = false;
  44120. if (platformId === 0 && encodingId === 0) {
  44121. useTable = true;
  44122. } else if (platformId === 1 && encodingId === 0) {
  44123. useTable = true;
  44124. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44125. useTable = true;
  44126. if (!isSymbolicFont) {
  44127. canBreak = true;
  44128. }
  44129. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44130. useTable = true;
  44131. canBreak = true;
  44132. }
  44133. if (useTable) {
  44134. potentialTable = {
  44135. platformId: platformId,
  44136. encodingId: encodingId,
  44137. offset: offset
  44138. };
  44139. }
  44140. if (canBreak) {
  44141. break;
  44142. }
  44143. }
  44144. if (potentialTable) {
  44145. font.pos = start + potentialTable.offset;
  44146. }
  44147. if (!potentialTable || font.peekByte() === -1) {
  44148. warn('Could not find a preferred cmap table.');
  44149. return {
  44150. platformId: -1,
  44151. encodingId: -1,
  44152. mappings: [],
  44153. hasShortCmap: false
  44154. };
  44155. }
  44156. var format = font.getUint16();
  44157. font.getUint16();
  44158. font.getUint16();
  44159. var hasShortCmap = false;
  44160. var mappings = [];
  44161. var j, glyphId;
  44162. if (format === 0) {
  44163. for (j = 0; j < 256; j++) {
  44164. var index = font.getByte();
  44165. if (!index) {
  44166. continue;
  44167. }
  44168. mappings.push({
  44169. charCode: j,
  44170. glyphId: index
  44171. });
  44172. }
  44173. hasShortCmap = true;
  44174. } else if (format === 4) {
  44175. var segCount = font.getUint16() >> 1;
  44176. font.getBytes(6);
  44177. var segIndex, segments = [];
  44178. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44179. segments.push({ end: font.getUint16() });
  44180. }
  44181. font.getUint16();
  44182. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44183. segments[segIndex].start = font.getUint16();
  44184. }
  44185. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44186. segments[segIndex].delta = font.getUint16();
  44187. }
  44188. var offsetsCount = 0;
  44189. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44190. segment = segments[segIndex];
  44191. var rangeOffset = font.getUint16();
  44192. if (!rangeOffset) {
  44193. segment.offsetIndex = -1;
  44194. continue;
  44195. }
  44196. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44197. segment.offsetIndex = offsetIndex;
  44198. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44199. }
  44200. var offsets = [];
  44201. for (j = 0; j < offsetsCount; j++) {
  44202. offsets.push(font.getUint16());
  44203. }
  44204. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44205. segment = segments[segIndex];
  44206. start = segment.start;
  44207. var end = segment.end;
  44208. var delta = segment.delta;
  44209. offsetIndex = segment.offsetIndex;
  44210. for (j = start; j <= end; j++) {
  44211. if (j === 0xFFFF) {
  44212. continue;
  44213. }
  44214. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  44215. glyphId = glyphId + delta & 0xFFFF;
  44216. if (glyphId === 0) {
  44217. continue;
  44218. }
  44219. mappings.push({
  44220. charCode: j,
  44221. glyphId: glyphId
  44222. });
  44223. }
  44224. }
  44225. } else if (format === 6) {
  44226. var firstCode = font.getUint16();
  44227. var entryCount = font.getUint16();
  44228. for (j = 0; j < entryCount; j++) {
  44229. glyphId = font.getUint16();
  44230. var charCode = firstCode + j;
  44231. mappings.push({
  44232. charCode: charCode,
  44233. glyphId: glyphId
  44234. });
  44235. }
  44236. } else {
  44237. warn('cmap table has unsupported format: ' + format);
  44238. return {
  44239. platformId: -1,
  44240. encodingId: -1,
  44241. mappings: [],
  44242. hasShortCmap: false
  44243. };
  44244. }
  44245. mappings.sort(function (a, b) {
  44246. return a.charCode - b.charCode;
  44247. });
  44248. for (i = 1; i < mappings.length; i++) {
  44249. if (mappings[i - 1].charCode === mappings[i].charCode) {
  44250. mappings.splice(i, 1);
  44251. i--;
  44252. }
  44253. }
  44254. return {
  44255. platformId: potentialTable.platformId,
  44256. encodingId: potentialTable.encodingId,
  44257. mappings: mappings,
  44258. hasShortCmap: hasShortCmap
  44259. };
  44260. }
  44261. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  44262. if (!header) {
  44263. if (metrics) {
  44264. metrics.data = null;
  44265. }
  44266. return;
  44267. }
  44268. font.pos = (font.start ? font.start : 0) + header.offset;
  44269. font.pos += header.length - 2;
  44270. var numOfMetrics = font.getUint16();
  44271. if (numOfMetrics > numGlyphs) {
  44272. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  44273. numOfMetrics = numGlyphs;
  44274. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  44275. header.data[35] = numOfMetrics & 0x00ff;
  44276. }
  44277. var numOfSidebearings = numGlyphs - numOfMetrics;
  44278. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  44279. if (numMissing > 0) {
  44280. var entries = new Uint8Array(metrics.length + numMissing * 2);
  44281. entries.set(metrics.data);
  44282. metrics.data = entries;
  44283. }
  44284. }
  44285. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  44286. if (sourceEnd - sourceStart <= 12) {
  44287. return 0;
  44288. }
  44289. var glyf = source.subarray(sourceStart, sourceEnd);
  44290. var contoursCount = glyf[0] << 8 | glyf[1];
  44291. if (contoursCount & 0x8000) {
  44292. dest.set(glyf, destStart);
  44293. return glyf.length;
  44294. }
  44295. var i, j = 10, flagsCount = 0;
  44296. for (i = 0; i < contoursCount; i++) {
  44297. var endPoint = glyf[j] << 8 | glyf[j + 1];
  44298. flagsCount = endPoint + 1;
  44299. j += 2;
  44300. }
  44301. var instructionsStart = j;
  44302. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  44303. j += 2 + instructionsLength;
  44304. var instructionsEnd = j;
  44305. var coordinatesLength = 0;
  44306. for (i = 0; i < flagsCount; i++) {
  44307. var flag = glyf[j++];
  44308. if (flag & 0xC0) {
  44309. glyf[j - 1] = flag & 0x3F;
  44310. }
  44311. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  44312. coordinatesLength += xyLength;
  44313. if (flag & 8) {
  44314. var repeat = glyf[j++];
  44315. i += repeat;
  44316. coordinatesLength += repeat * xyLength;
  44317. }
  44318. }
  44319. if (coordinatesLength === 0) {
  44320. return 0;
  44321. }
  44322. var glyphDataLength = j + coordinatesLength;
  44323. if (glyphDataLength > glyf.length) {
  44324. return 0;
  44325. }
  44326. if (!hintsValid && instructionsLength > 0) {
  44327. dest.set(glyf.subarray(0, instructionsStart), destStart);
  44328. dest.set([
  44329. 0,
  44330. 0
  44331. ], destStart + instructionsStart);
  44332. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  44333. glyphDataLength -= instructionsLength;
  44334. if (glyf.length - glyphDataLength > 3) {
  44335. glyphDataLength = glyphDataLength + 3 & ~3;
  44336. }
  44337. return glyphDataLength;
  44338. }
  44339. if (glyf.length - glyphDataLength > 3) {
  44340. glyphDataLength = glyphDataLength + 3 & ~3;
  44341. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  44342. return glyphDataLength;
  44343. }
  44344. dest.set(glyf, destStart);
  44345. return glyf.length;
  44346. }
  44347. function sanitizeHead(head, numGlyphs, locaLength) {
  44348. var data = head.data;
  44349. var version = int32(data[0], data[1], data[2], data[3]);
  44350. if (version >> 16 !== 1) {
  44351. info('Attempting to fix invalid version in head table: ' + version);
  44352. data[0] = 0;
  44353. data[1] = 1;
  44354. data[2] = 0;
  44355. data[3] = 0;
  44356. }
  44357. var indexToLocFormat = int16(data[50], data[51]);
  44358. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  44359. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  44360. var numGlyphsPlusOne = numGlyphs + 1;
  44361. if (locaLength === numGlyphsPlusOne << 1) {
  44362. data[50] = 0;
  44363. data[51] = 0;
  44364. } else if (locaLength === numGlyphsPlusOne << 2) {
  44365. data[50] = 0;
  44366. data[51] = 1;
  44367. } else {
  44368. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  44369. }
  44370. }
  44371. }
  44372. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  44373. var itemSize, itemDecode, itemEncode;
  44374. if (isGlyphLocationsLong) {
  44375. itemSize = 4;
  44376. itemDecode = function fontItemDecodeLong(data, offset) {
  44377. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  44378. };
  44379. itemEncode = function fontItemEncodeLong(data, offset, value) {
  44380. data[offset] = value >>> 24 & 0xFF;
  44381. data[offset + 1] = value >> 16 & 0xFF;
  44382. data[offset + 2] = value >> 8 & 0xFF;
  44383. data[offset + 3] = value & 0xFF;
  44384. };
  44385. } else {
  44386. itemSize = 2;
  44387. itemDecode = function fontItemDecode(data, offset) {
  44388. return data[offset] << 9 | data[offset + 1] << 1;
  44389. };
  44390. itemEncode = function fontItemEncode(data, offset, value) {
  44391. data[offset] = value >> 9 & 0xFF;
  44392. data[offset + 1] = value >> 1 & 0xFF;
  44393. };
  44394. }
  44395. var locaData = loca.data;
  44396. var locaDataSize = itemSize * (1 + numGlyphs);
  44397. if (locaData.length !== locaDataSize) {
  44398. locaData = new Uint8Array(locaDataSize);
  44399. locaData.set(loca.data.subarray(0, locaDataSize));
  44400. loca.data = locaData;
  44401. }
  44402. var oldGlyfData = glyf.data;
  44403. var oldGlyfDataLength = oldGlyfData.length;
  44404. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  44405. var startOffset = itemDecode(locaData, 0);
  44406. var writeOffset = 0;
  44407. var missingGlyphData = Object.create(null);
  44408. itemEncode(locaData, 0, writeOffset);
  44409. var i, j;
  44410. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44411. var endOffset = itemDecode(locaData, j);
  44412. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  44413. endOffset = oldGlyfDataLength;
  44414. }
  44415. if (endOffset > oldGlyfDataLength) {
  44416. itemEncode(locaData, j, writeOffset);
  44417. startOffset = endOffset;
  44418. continue;
  44419. }
  44420. if (startOffset === endOffset) {
  44421. missingGlyphData[i] = true;
  44422. }
  44423. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  44424. writeOffset += newLength;
  44425. itemEncode(locaData, j, writeOffset);
  44426. startOffset = endOffset;
  44427. }
  44428. if (writeOffset === 0) {
  44429. var simpleGlyph = new Uint8Array([
  44430. 0,
  44431. 1,
  44432. 0,
  44433. 0,
  44434. 0,
  44435. 0,
  44436. 0,
  44437. 0,
  44438. 0,
  44439. 0,
  44440. 0,
  44441. 0,
  44442. 0,
  44443. 0,
  44444. 49,
  44445. 0
  44446. ]);
  44447. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44448. itemEncode(locaData, j, simpleGlyph.length);
  44449. }
  44450. glyf.data = simpleGlyph;
  44451. return missingGlyphData;
  44452. }
  44453. if (dupFirstEntry) {
  44454. var firstEntryLength = itemDecode(locaData, itemSize);
  44455. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44456. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44457. } else {
  44458. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44459. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44460. }
  44461. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44462. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44463. } else {
  44464. glyf.data = newGlyfData.subarray(0, writeOffset);
  44465. }
  44466. return missingGlyphData;
  44467. }
  44468. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44469. var start = (font.start ? font.start : 0) + post.offset;
  44470. font.pos = start;
  44471. var length = post.length, end = start + length;
  44472. var version = font.getInt32();
  44473. font.getBytes(28);
  44474. var glyphNames;
  44475. var valid = true;
  44476. var i;
  44477. switch (version) {
  44478. case 0x00010000:
  44479. glyphNames = MacStandardGlyphOrdering;
  44480. break;
  44481. case 0x00020000:
  44482. var numGlyphs = font.getUint16();
  44483. if (numGlyphs !== maxpNumGlyphs) {
  44484. valid = false;
  44485. break;
  44486. }
  44487. var glyphNameIndexes = [];
  44488. for (i = 0; i < numGlyphs; ++i) {
  44489. var index = font.getUint16();
  44490. if (index >= 32768) {
  44491. valid = false;
  44492. break;
  44493. }
  44494. glyphNameIndexes.push(index);
  44495. }
  44496. if (!valid) {
  44497. break;
  44498. }
  44499. var customNames = [];
  44500. var strBuf = [];
  44501. while (font.pos < end) {
  44502. var stringLength = font.getByte();
  44503. strBuf.length = stringLength;
  44504. for (i = 0; i < stringLength; ++i) {
  44505. strBuf[i] = String.fromCharCode(font.getByte());
  44506. }
  44507. customNames.push(strBuf.join(''));
  44508. }
  44509. glyphNames = [];
  44510. for (i = 0; i < numGlyphs; ++i) {
  44511. var j = glyphNameIndexes[i];
  44512. if (j < 258) {
  44513. glyphNames.push(MacStandardGlyphOrdering[j]);
  44514. continue;
  44515. }
  44516. glyphNames.push(customNames[j - 258]);
  44517. }
  44518. break;
  44519. case 0x00030000:
  44520. break;
  44521. default:
  44522. warn('Unknown/unsupported post table version ' + version);
  44523. valid = false;
  44524. if (properties.defaultEncoding) {
  44525. glyphNames = properties.defaultEncoding;
  44526. }
  44527. break;
  44528. }
  44529. properties.glyphNames = glyphNames;
  44530. return valid;
  44531. }
  44532. function readNameTable(nameTable) {
  44533. var start = (font.start ? font.start : 0) + nameTable.offset;
  44534. font.pos = start;
  44535. var names = [
  44536. [],
  44537. []
  44538. ];
  44539. var length = nameTable.length, end = start + length;
  44540. var format = font.getUint16();
  44541. var FORMAT_0_HEADER_LENGTH = 6;
  44542. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44543. return names;
  44544. }
  44545. var numRecords = font.getUint16();
  44546. var stringsStart = font.getUint16();
  44547. var records = [];
  44548. var NAME_RECORD_LENGTH = 12;
  44549. var i, ii;
  44550. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44551. var r = {
  44552. platform: font.getUint16(),
  44553. encoding: font.getUint16(),
  44554. language: font.getUint16(),
  44555. name: font.getUint16(),
  44556. length: font.getUint16(),
  44557. offset: font.getUint16()
  44558. };
  44559. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44560. records.push(r);
  44561. }
  44562. }
  44563. for (i = 0, ii = records.length; i < ii; i++) {
  44564. var record = records[i];
  44565. if (record.length <= 0) {
  44566. continue;
  44567. }
  44568. var pos = start + stringsStart + record.offset;
  44569. if (pos + record.length > end) {
  44570. continue;
  44571. }
  44572. font.pos = pos;
  44573. var nameIndex = record.name;
  44574. if (record.encoding) {
  44575. var str = '';
  44576. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44577. str += String.fromCharCode(font.getUint16());
  44578. }
  44579. names[1][nameIndex] = str;
  44580. } else {
  44581. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44582. }
  44583. }
  44584. return names;
  44585. }
  44586. var TTOpsStackDeltas = [
  44587. 0,
  44588. 0,
  44589. 0,
  44590. 0,
  44591. 0,
  44592. 0,
  44593. 0,
  44594. 0,
  44595. -2,
  44596. -2,
  44597. -2,
  44598. -2,
  44599. 0,
  44600. 0,
  44601. -2,
  44602. -5,
  44603. -1,
  44604. -1,
  44605. -1,
  44606. -1,
  44607. -1,
  44608. -1,
  44609. -1,
  44610. -1,
  44611. 0,
  44612. 0,
  44613. -1,
  44614. 0,
  44615. -1,
  44616. -1,
  44617. -1,
  44618. -1,
  44619. 1,
  44620. -1,
  44621. -999,
  44622. 0,
  44623. 1,
  44624. 0,
  44625. -1,
  44626. -2,
  44627. 0,
  44628. -1,
  44629. -2,
  44630. -1,
  44631. -1,
  44632. 0,
  44633. -1,
  44634. -1,
  44635. 0,
  44636. 0,
  44637. -999,
  44638. -999,
  44639. -1,
  44640. -1,
  44641. -1,
  44642. -1,
  44643. -2,
  44644. -999,
  44645. -2,
  44646. -2,
  44647. -999,
  44648. 0,
  44649. -2,
  44650. -2,
  44651. 0,
  44652. 0,
  44653. -2,
  44654. 0,
  44655. -2,
  44656. 0,
  44657. 0,
  44658. 0,
  44659. -2,
  44660. -1,
  44661. -1,
  44662. 1,
  44663. 1,
  44664. 0,
  44665. 0,
  44666. -1,
  44667. -1,
  44668. -1,
  44669. -1,
  44670. -1,
  44671. -1,
  44672. -1,
  44673. 0,
  44674. 0,
  44675. -1,
  44676. 0,
  44677. -1,
  44678. -1,
  44679. 0,
  44680. -999,
  44681. -1,
  44682. -1,
  44683. -1,
  44684. -1,
  44685. -1,
  44686. -1,
  44687. 0,
  44688. 0,
  44689. 0,
  44690. 0,
  44691. 0,
  44692. 0,
  44693. 0,
  44694. 0,
  44695. 0,
  44696. 0,
  44697. 0,
  44698. 0,
  44699. -2,
  44700. -999,
  44701. -999,
  44702. -999,
  44703. -999,
  44704. -999,
  44705. -1,
  44706. -1,
  44707. -2,
  44708. -2,
  44709. 0,
  44710. 0,
  44711. 0,
  44712. 0,
  44713. -1,
  44714. -1,
  44715. -999,
  44716. -2,
  44717. -2,
  44718. 0,
  44719. 0,
  44720. -1,
  44721. -2,
  44722. -2,
  44723. 0,
  44724. 0,
  44725. 0,
  44726. -1,
  44727. -1,
  44728. -1,
  44729. -2
  44730. ];
  44731. function sanitizeTTProgram(table, ttContext) {
  44732. var data = table.data;
  44733. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44734. var stack = [];
  44735. var callstack = [];
  44736. var functionsCalled = [];
  44737. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44738. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44739. for (var ii = data.length; i < ii;) {
  44740. var op = data[i++];
  44741. if (op === 0x40) {
  44742. n = data[i++];
  44743. if (inFDEF || inELSE) {
  44744. i += n;
  44745. } else {
  44746. for (j = 0; j < n; j++) {
  44747. stack.push(data[i++]);
  44748. }
  44749. }
  44750. } else if (op === 0x41) {
  44751. n = data[i++];
  44752. if (inFDEF || inELSE) {
  44753. i += n * 2;
  44754. } else {
  44755. for (j = 0; j < n; j++) {
  44756. b = data[i++];
  44757. stack.push(b << 8 | data[i++]);
  44758. }
  44759. }
  44760. } else if ((op & 0xF8) === 0xB0) {
  44761. n = op - 0xB0 + 1;
  44762. if (inFDEF || inELSE) {
  44763. i += n;
  44764. } else {
  44765. for (j = 0; j < n; j++) {
  44766. stack.push(data[i++]);
  44767. }
  44768. }
  44769. } else if ((op & 0xF8) === 0xB8) {
  44770. n = op - 0xB8 + 1;
  44771. if (inFDEF || inELSE) {
  44772. i += n * 2;
  44773. } else {
  44774. for (j = 0; j < n; j++) {
  44775. b = data[i++];
  44776. stack.push(b << 8 | data[i++]);
  44777. }
  44778. }
  44779. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44780. if (!inFDEF && !inELSE) {
  44781. funcId = stack[stack.length - 1];
  44782. ttContext.functionsUsed[funcId] = true;
  44783. if (funcId in ttContext.functionsStackDeltas) {
  44784. stack.length += ttContext.functionsStackDeltas[funcId];
  44785. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44786. callstack.push({
  44787. data: data,
  44788. i: i,
  44789. stackTop: stack.length - 1
  44790. });
  44791. functionsCalled.push(funcId);
  44792. pc = ttContext.functionsDefined[funcId];
  44793. if (!pc) {
  44794. warn('TT: CALL non-existent function');
  44795. ttContext.hintsValid = false;
  44796. return;
  44797. }
  44798. data = pc.data;
  44799. i = pc.i;
  44800. }
  44801. }
  44802. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44803. if (inFDEF || inELSE) {
  44804. warn('TT: nested FDEFs not allowed');
  44805. tooComplexToFollowFunctions = true;
  44806. }
  44807. inFDEF = true;
  44808. lastDeff = i;
  44809. funcId = stack.pop();
  44810. ttContext.functionsDefined[funcId] = {
  44811. data: data,
  44812. i: i
  44813. };
  44814. } else if (op === 0x2D) {
  44815. if (inFDEF) {
  44816. inFDEF = false;
  44817. lastEndf = i;
  44818. } else {
  44819. pc = callstack.pop();
  44820. if (!pc) {
  44821. warn('TT: ENDF bad stack');
  44822. ttContext.hintsValid = false;
  44823. return;
  44824. }
  44825. funcId = functionsCalled.pop();
  44826. data = pc.data;
  44827. i = pc.i;
  44828. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44829. }
  44830. } else if (op === 0x89) {
  44831. if (inFDEF || inELSE) {
  44832. warn('TT: nested IDEFs not allowed');
  44833. tooComplexToFollowFunctions = true;
  44834. }
  44835. inFDEF = true;
  44836. lastDeff = i;
  44837. } else if (op === 0x58) {
  44838. ++ifLevel;
  44839. } else if (op === 0x1B) {
  44840. inELSE = ifLevel;
  44841. } else if (op === 0x59) {
  44842. if (inELSE === ifLevel) {
  44843. inELSE = 0;
  44844. }
  44845. --ifLevel;
  44846. } else if (op === 0x1C) {
  44847. if (!inFDEF && !inELSE) {
  44848. var offset = stack[stack.length - 1];
  44849. if (offset > 0) {
  44850. i += offset - 1;
  44851. }
  44852. }
  44853. }
  44854. if (!inFDEF && !inELSE) {
  44855. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44856. if (op >= 0x71 && op <= 0x75) {
  44857. n = stack.pop();
  44858. if (!isNaN(n)) {
  44859. stackDelta = -n * 2;
  44860. }
  44861. }
  44862. while (stackDelta < 0 && stack.length > 0) {
  44863. stack.pop();
  44864. stackDelta++;
  44865. }
  44866. while (stackDelta > 0) {
  44867. stack.push(NaN);
  44868. stackDelta--;
  44869. }
  44870. }
  44871. }
  44872. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44873. var content = [data];
  44874. if (i > data.length) {
  44875. content.push(new Uint8Array(i - data.length));
  44876. }
  44877. if (lastDeff > lastEndf) {
  44878. warn('TT: complementing a missing function tail');
  44879. content.push(new Uint8Array([
  44880. 0x22,
  44881. 0x2D
  44882. ]));
  44883. }
  44884. foldTTTable(table, content);
  44885. }
  44886. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44887. if (ttContext.tooComplexToFollowFunctions) {
  44888. return;
  44889. }
  44890. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44891. warn('TT: more functions defined than expected');
  44892. ttContext.hintsValid = false;
  44893. return;
  44894. }
  44895. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44896. if (j > maxFunctionDefs) {
  44897. warn('TT: invalid function id: ' + j);
  44898. ttContext.hintsValid = false;
  44899. return;
  44900. }
  44901. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44902. warn('TT: undefined function: ' + j);
  44903. ttContext.hintsValid = false;
  44904. return;
  44905. }
  44906. }
  44907. }
  44908. function foldTTTable(table, content) {
  44909. if (content.length > 1) {
  44910. var newLength = 0;
  44911. var j, jj;
  44912. for (j = 0, jj = content.length; j < jj; j++) {
  44913. newLength += content[j].length;
  44914. }
  44915. newLength = newLength + 3 & ~3;
  44916. var result = new Uint8Array(newLength);
  44917. var pos = 0;
  44918. for (j = 0, jj = content.length; j < jj; j++) {
  44919. result.set(content[j], pos);
  44920. pos += content[j].length;
  44921. }
  44922. table.data = result;
  44923. table.length = newLength;
  44924. }
  44925. }
  44926. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44927. var ttContext = {
  44928. functionsDefined: [],
  44929. functionsUsed: [],
  44930. functionsStackDeltas: [],
  44931. tooComplexToFollowFunctions: false,
  44932. hintsValid: true
  44933. };
  44934. if (fpgm) {
  44935. sanitizeTTProgram(fpgm, ttContext);
  44936. }
  44937. if (prep) {
  44938. sanitizeTTProgram(prep, ttContext);
  44939. }
  44940. if (fpgm) {
  44941. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44942. }
  44943. if (cvt && cvt.length & 1) {
  44944. var cvtData = new Uint8Array(cvt.length + 1);
  44945. cvtData.set(cvt.data);
  44946. cvt.data = cvtData;
  44947. }
  44948. return ttContext.hintsValid;
  44949. }
  44950. font = new Stream(new Uint8Array(font.getBytes()));
  44951. var VALID_TABLES = [
  44952. 'OS/2',
  44953. 'cmap',
  44954. 'head',
  44955. 'hhea',
  44956. 'hmtx',
  44957. 'maxp',
  44958. 'name',
  44959. 'post',
  44960. 'loca',
  44961. 'glyf',
  44962. 'fpgm',
  44963. 'prep',
  44964. 'cvt ',
  44965. 'CFF '
  44966. ];
  44967. var header = readOpenTypeHeader(font);
  44968. var numTables = header.numTables;
  44969. var cff, cffFile;
  44970. var tables = Object.create(null);
  44971. tables['OS/2'] = null;
  44972. tables['cmap'] = null;
  44973. tables['head'] = null;
  44974. tables['hhea'] = null;
  44975. tables['hmtx'] = null;
  44976. tables['maxp'] = null;
  44977. tables['name'] = null;
  44978. tables['post'] = null;
  44979. var table;
  44980. for (var i = 0; i < numTables; i++) {
  44981. table = readTableEntry(font);
  44982. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44983. continue;
  44984. }
  44985. if (table.length === 0) {
  44986. continue;
  44987. }
  44988. tables[table.tag] = table;
  44989. }
  44990. var isTrueType = !tables['CFF '];
  44991. if (!isTrueType) {
  44992. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44993. cffFile = new Stream(tables['CFF '].data);
  44994. cff = new CFFFont(cffFile, properties);
  44995. adjustWidths(properties);
  44996. return this.convert(name, cff, properties);
  44997. }
  44998. delete tables['glyf'];
  44999. delete tables['loca'];
  45000. delete tables['fpgm'];
  45001. delete tables['prep'];
  45002. delete tables['cvt '];
  45003. this.isOpenType = true;
  45004. } else {
  45005. if (!tables['loca']) {
  45006. error('Required "loca" table is not found');
  45007. }
  45008. if (!tables['glyf']) {
  45009. warn('Required "glyf" table is not found -- trying to recover.');
  45010. tables['glyf'] = {
  45011. tag: 'glyf',
  45012. data: new Uint8Array(0)
  45013. };
  45014. }
  45015. this.isOpenType = false;
  45016. }
  45017. if (!tables['maxp']) {
  45018. error('Required "maxp" table is not found');
  45019. }
  45020. font.pos = (font.start || 0) + tables['maxp'].offset;
  45021. var version = font.getInt32();
  45022. var numGlyphs = font.getUint16();
  45023. var maxFunctionDefs = 0;
  45024. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45025. font.pos += 8;
  45026. var maxZones = font.getUint16();
  45027. if (maxZones > 2) {
  45028. tables['maxp'].data[14] = 0;
  45029. tables['maxp'].data[15] = 2;
  45030. }
  45031. font.pos += 4;
  45032. maxFunctionDefs = font.getUint16();
  45033. }
  45034. var dupFirstEntry = false;
  45035. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45036. dupFirstEntry = true;
  45037. numGlyphs++;
  45038. tables['maxp'].data[4] = numGlyphs >> 8;
  45039. tables['maxp'].data[5] = numGlyphs & 255;
  45040. }
  45041. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45042. if (!hintsValid) {
  45043. delete tables['fpgm'];
  45044. delete tables['prep'];
  45045. delete tables['cvt '];
  45046. }
  45047. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45048. if (!tables['head']) {
  45049. error('Required "head" table is not found');
  45050. }
  45051. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45052. var missingGlyphs = Object.create(null);
  45053. if (isTrueType) {
  45054. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45055. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45056. }
  45057. if (!tables['hhea']) {
  45058. error('Required "hhea" table is not found');
  45059. }
  45060. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45061. tables['hhea'].data[10] = 0xFF;
  45062. tables['hhea'].data[11] = 0xFF;
  45063. }
  45064. var metricsOverride = {
  45065. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45066. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45067. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45068. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45069. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45070. };
  45071. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45072. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45073. if (tables['post']) {
  45074. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45075. if (!valid) {
  45076. tables['post'] = null;
  45077. }
  45078. }
  45079. var charCodeToGlyphId = [], charCode;
  45080. var toUnicode = properties.toUnicode, widths = properties.widths;
  45081. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45082. function hasGlyph(glyphId, charCode, widthCode) {
  45083. if (!missingGlyphs[glyphId]) {
  45084. return true;
  45085. }
  45086. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45087. return true;
  45088. }
  45089. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45090. return true;
  45091. }
  45092. return false;
  45093. }
  45094. if (properties.composite) {
  45095. var cidToGidMap = properties.cidToGidMap || [];
  45096. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45097. properties.cMap.forEach(function (charCode, cid) {
  45098. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45099. var glyphId = -1;
  45100. if (isCidToGidMapEmpty) {
  45101. glyphId = cid;
  45102. } else if (cidToGidMap[cid] !== undefined) {
  45103. glyphId = cidToGidMap[cid];
  45104. }
  45105. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45106. charCodeToGlyphId[charCode] = glyphId;
  45107. }
  45108. });
  45109. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45110. charCodeToGlyphId[0] = numGlyphs - 1;
  45111. }
  45112. } else {
  45113. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45114. var cmapPlatformId = cmapTable.platformId;
  45115. var cmapEncodingId = cmapTable.encodingId;
  45116. var cmapMappings = cmapTable.mappings;
  45117. var cmapMappingsLength = cmapMappings.length;
  45118. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45119. var baseEncoding = [];
  45120. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45121. baseEncoding = getEncoding(properties.baseEncodingName);
  45122. }
  45123. var glyphsUnicodeMap = getGlyphsUnicode();
  45124. for (charCode = 0; charCode < 256; charCode++) {
  45125. var glyphName, standardGlyphName;
  45126. if (this.differences && charCode in this.differences) {
  45127. glyphName = this.differences[charCode];
  45128. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45129. glyphName = baseEncoding[charCode];
  45130. } else {
  45131. glyphName = StandardEncoding[charCode];
  45132. }
  45133. if (!glyphName) {
  45134. continue;
  45135. }
  45136. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45137. var unicodeOrCharCode, isUnicode = false;
  45138. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45139. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45140. isUnicode = true;
  45141. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45142. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45143. }
  45144. var found = false;
  45145. for (i = 0; i < cmapMappingsLength; ++i) {
  45146. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45147. continue;
  45148. }
  45149. var code = isUnicode ? charCode : unicodeOrCharCode;
  45150. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45151. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45152. found = true;
  45153. break;
  45154. }
  45155. }
  45156. if (!found && properties.glyphNames) {
  45157. var glyphId = properties.glyphNames.indexOf(glyphName);
  45158. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45159. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45160. }
  45161. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45162. charCodeToGlyphId[charCode] = glyphId;
  45163. found = true;
  45164. }
  45165. }
  45166. if (!found) {
  45167. charCodeToGlyphId[charCode] = 0;
  45168. }
  45169. }
  45170. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45171. for (i = 0; i < cmapMappingsLength; ++i) {
  45172. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45173. }
  45174. } else {
  45175. for (i = 0; i < cmapMappingsLength; ++i) {
  45176. charCode = cmapMappings[i].charCode & 0xFF;
  45177. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45178. }
  45179. }
  45180. }
  45181. if (charCodeToGlyphId.length === 0) {
  45182. charCodeToGlyphId[0] = 0;
  45183. }
  45184. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45185. this.toFontChar = newMapping.toFontChar;
  45186. tables['cmap'] = {
  45187. tag: 'cmap',
  45188. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45189. };
  45190. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45191. tables['OS/2'] = {
  45192. tag: 'OS/2',
  45193. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45194. };
  45195. }
  45196. if (!tables['post']) {
  45197. tables['post'] = {
  45198. tag: 'post',
  45199. data: createPostTable(properties)
  45200. };
  45201. }
  45202. if (!isTrueType) {
  45203. try {
  45204. cffFile = new Stream(tables['CFF '].data);
  45205. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45206. cff = parser.parse();
  45207. var compiler = new CFFCompiler(cff);
  45208. tables['CFF '].data = compiler.compile();
  45209. } catch (e) {
  45210. warn('Failed to compile font ' + properties.loadedName);
  45211. }
  45212. }
  45213. if (!tables['name']) {
  45214. tables['name'] = {
  45215. tag: 'name',
  45216. data: createNameTable(this.name)
  45217. };
  45218. } else {
  45219. var namePrototype = readNameTable(tables['name']);
  45220. tables['name'].data = createNameTable(name, namePrototype);
  45221. }
  45222. var builder = new OpenTypeFileBuilder(header.version);
  45223. for (var tableTag in tables) {
  45224. builder.addTable(tableTag, tables[tableTag].data);
  45225. }
  45226. return builder.toArray();
  45227. },
  45228. convert: function Font_convert(fontName, font, properties) {
  45229. properties.fixedPitch = false;
  45230. if (properties.builtInEncoding) {
  45231. adjustToUnicode(properties, properties.builtInEncoding);
  45232. }
  45233. var mapping = font.getGlyphMapping(properties);
  45234. var newMapping = adjustMapping(mapping, properties);
  45235. this.toFontChar = newMapping.toFontChar;
  45236. var numGlyphs = font.numGlyphs;
  45237. function getCharCodes(charCodeToGlyphId, glyphId) {
  45238. var charCodes = null;
  45239. for (var charCode in charCodeToGlyphId) {
  45240. if (glyphId === charCodeToGlyphId[charCode]) {
  45241. if (!charCodes) {
  45242. charCodes = [];
  45243. }
  45244. charCodes.push(charCode | 0);
  45245. }
  45246. }
  45247. return charCodes;
  45248. }
  45249. function createCharCode(charCodeToGlyphId, glyphId) {
  45250. for (var charCode in charCodeToGlyphId) {
  45251. if (glyphId === charCodeToGlyphId[charCode]) {
  45252. return charCode | 0;
  45253. }
  45254. }
  45255. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  45256. return newMapping.nextAvailableFontCharCode++;
  45257. }
  45258. var seacs = font.seacs;
  45259. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  45260. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  45261. var charset = font.getCharset();
  45262. var seacMap = Object.create(null);
  45263. for (var glyphId in seacs) {
  45264. glyphId |= 0;
  45265. var seac = seacs[glyphId];
  45266. var baseGlyphName = StandardEncoding[seac[2]];
  45267. var accentGlyphName = StandardEncoding[seac[3]];
  45268. var baseGlyphId = charset.indexOf(baseGlyphName);
  45269. var accentGlyphId = charset.indexOf(accentGlyphName);
  45270. if (baseGlyphId < 0 || accentGlyphId < 0) {
  45271. continue;
  45272. }
  45273. var accentOffset = {
  45274. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  45275. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  45276. };
  45277. var charCodes = getCharCodes(mapping, glyphId);
  45278. if (!charCodes) {
  45279. continue;
  45280. }
  45281. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  45282. var charCode = charCodes[i];
  45283. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  45284. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  45285. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  45286. seacMap[charCode] = {
  45287. baseFontCharCode: baseFontCharCode,
  45288. accentFontCharCode: accentFontCharCode,
  45289. accentOffset: accentOffset
  45290. };
  45291. }
  45292. }
  45293. properties.seacMap = seacMap;
  45294. }
  45295. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45296. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  45297. builder.addTable('CFF ', font.data);
  45298. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  45299. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  45300. builder.addTable('head', '\x00\x01\x00\x00' + '\x00\x00\x10\x00' + '\x00\x00\x00\x00' + '\x5F\x0F\x3C\xF5' + '\x00\x00' + safeString16(unitsPerEm) + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00' + safeString16(properties.descent) + '\x0F\xFF' + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + '\x00\x11' + '\x00\x00' + '\x00\x00' + '\x00\x00');
  45301. builder.addTable('hhea', '\x00\x01\x00\x00' + safeString16(properties.ascent) + safeString16(properties.descent) + '\x00\x00' + '\xFF\xFF' + '\x00\x00' + '\x00\x00' + '\x00\x00' + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + string16(numGlyphs));
  45302. builder.addTable('hmtx', function fontFieldsHmtx() {
  45303. var charstrings = font.charstrings;
  45304. var cffWidths = font.cff ? font.cff.widths : null;
  45305. var hmtx = '\x00\x00\x00\x00';
  45306. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  45307. var width = 0;
  45308. if (charstrings) {
  45309. var charstring = charstrings[i - 1];
  45310. width = 'width' in charstring ? charstring.width : 0;
  45311. } else if (cffWidths) {
  45312. width = Math.ceil(cffWidths[i] || 0);
  45313. }
  45314. hmtx += string16(width) + string16(0);
  45315. }
  45316. return hmtx;
  45317. }());
  45318. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  45319. builder.addTable('name', createNameTable(fontName));
  45320. builder.addTable('post', createPostTable(properties));
  45321. return builder.toArray();
  45322. },
  45323. get spaceWidth() {
  45324. if ('_shadowWidth' in this) {
  45325. return this._shadowWidth;
  45326. }
  45327. var possibleSpaceReplacements = [
  45328. 'space',
  45329. 'minus',
  45330. 'one',
  45331. 'i',
  45332. 'I'
  45333. ];
  45334. var width;
  45335. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  45336. var glyphName = possibleSpaceReplacements[i];
  45337. if (glyphName in this.widths) {
  45338. width = this.widths[glyphName];
  45339. break;
  45340. }
  45341. var glyphsUnicodeMap = getGlyphsUnicode();
  45342. var glyphUnicode = glyphsUnicodeMap[glyphName];
  45343. var charcode = 0;
  45344. if (this.composite) {
  45345. if (this.cMap.contains(glyphUnicode)) {
  45346. charcode = this.cMap.lookup(glyphUnicode);
  45347. }
  45348. }
  45349. if (!charcode && this.toUnicode) {
  45350. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  45351. }
  45352. if (charcode <= 0) {
  45353. charcode = glyphUnicode;
  45354. }
  45355. width = this.widths[charcode];
  45356. if (width) {
  45357. break;
  45358. }
  45359. }
  45360. width = width || this.defaultWidth;
  45361. this._shadowWidth = width;
  45362. return width;
  45363. },
  45364. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  45365. var fontCharCode, width, operatorListId;
  45366. var widthCode = charcode;
  45367. if (this.cMap && this.cMap.contains(charcode)) {
  45368. widthCode = this.cMap.lookup(charcode);
  45369. }
  45370. width = this.widths[widthCode];
  45371. width = isNum(width) ? width : this.defaultWidth;
  45372. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  45373. var unicode = this.toUnicode.get(charcode) || charcode;
  45374. if (typeof unicode === 'number') {
  45375. unicode = String.fromCharCode(unicode);
  45376. }
  45377. var isInFont = charcode in this.toFontChar;
  45378. fontCharCode = this.toFontChar[charcode] || charcode;
  45379. if (this.missingFile) {
  45380. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  45381. }
  45382. if (this.isType3Font) {
  45383. operatorListId = fontCharCode;
  45384. }
  45385. var accent = null;
  45386. if (this.seacMap && this.seacMap[charcode]) {
  45387. isInFont = true;
  45388. var seac = this.seacMap[charcode];
  45389. fontCharCode = seac.baseFontCharCode;
  45390. accent = {
  45391. fontChar: String.fromCharCode(seac.accentFontCharCode),
  45392. offset: seac.accentOffset
  45393. };
  45394. }
  45395. var fontChar = String.fromCharCode(fontCharCode);
  45396. var glyph = this.glyphCache[charcode];
  45397. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  45398. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  45399. this.glyphCache[charcode] = glyph;
  45400. }
  45401. return glyph;
  45402. },
  45403. charsToGlyphs: function Font_charsToGlyphs(chars) {
  45404. var charsCache = this.charsCache;
  45405. var glyphs, glyph, charcode;
  45406. if (charsCache) {
  45407. glyphs = charsCache[chars];
  45408. if (glyphs) {
  45409. return glyphs;
  45410. }
  45411. }
  45412. if (!charsCache) {
  45413. charsCache = this.charsCache = Object.create(null);
  45414. }
  45415. glyphs = [];
  45416. var charsCacheKey = chars;
  45417. var i = 0, ii;
  45418. if (this.cMap) {
  45419. var c = Object.create(null);
  45420. while (i < chars.length) {
  45421. this.cMap.readCharCode(chars, i, c);
  45422. charcode = c.charcode;
  45423. var length = c.length;
  45424. i += length;
  45425. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  45426. glyph = this.charToGlyph(charcode, isSpace);
  45427. glyphs.push(glyph);
  45428. }
  45429. } else {
  45430. for (i = 0, ii = chars.length; i < ii; ++i) {
  45431. charcode = chars.charCodeAt(i);
  45432. glyph = this.charToGlyph(charcode, charcode === 0x20);
  45433. glyphs.push(glyph);
  45434. }
  45435. }
  45436. return charsCache[charsCacheKey] = glyphs;
  45437. }
  45438. };
  45439. return Font;
  45440. }();
  45441. var ErrorFont = function ErrorFontClosure() {
  45442. function ErrorFont(error) {
  45443. this.error = error;
  45444. this.loadedName = 'g_font_error';
  45445. this.loading = false;
  45446. }
  45447. ErrorFont.prototype = {
  45448. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45449. return [];
  45450. },
  45451. exportData: function ErrorFont_exportData() {
  45452. return { error: this.error };
  45453. }
  45454. };
  45455. return ErrorFont;
  45456. }();
  45457. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45458. var charCodeToGlyphId = Object.create(null);
  45459. var glyphId, charCode, baseEncoding;
  45460. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45461. if (properties.baseEncodingName) {
  45462. baseEncoding = getEncoding(properties.baseEncodingName);
  45463. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45464. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45465. if (glyphId >= 0) {
  45466. charCodeToGlyphId[charCode] = glyphId;
  45467. } else {
  45468. charCodeToGlyphId[charCode] = 0;
  45469. }
  45470. }
  45471. } else if (isSymbolicFont) {
  45472. for (charCode in builtInEncoding) {
  45473. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45474. }
  45475. } else {
  45476. baseEncoding = StandardEncoding;
  45477. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45478. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45479. if (glyphId >= 0) {
  45480. charCodeToGlyphId[charCode] = glyphId;
  45481. } else {
  45482. charCodeToGlyphId[charCode] = 0;
  45483. }
  45484. }
  45485. }
  45486. var differences = properties.differences, glyphsUnicodeMap;
  45487. if (differences) {
  45488. for (charCode in differences) {
  45489. var glyphName = differences[charCode];
  45490. glyphId = glyphNames.indexOf(glyphName);
  45491. if (glyphId === -1) {
  45492. if (!glyphsUnicodeMap) {
  45493. glyphsUnicodeMap = getGlyphsUnicode();
  45494. }
  45495. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45496. if (standardGlyphName !== glyphName) {
  45497. glyphId = glyphNames.indexOf(standardGlyphName);
  45498. }
  45499. }
  45500. if (glyphId >= 0) {
  45501. charCodeToGlyphId[charCode] = glyphId;
  45502. } else {
  45503. charCodeToGlyphId[charCode] = 0;
  45504. }
  45505. }
  45506. }
  45507. return charCodeToGlyphId;
  45508. }
  45509. var Type1Font = function Type1FontClosure() {
  45510. function findBlock(streamBytes, signature, startIndex) {
  45511. var streamBytesLength = streamBytes.length;
  45512. var signatureLength = signature.length;
  45513. var scanLength = streamBytesLength - signatureLength;
  45514. var i = startIndex, j, found = false;
  45515. while (i < scanLength) {
  45516. j = 0;
  45517. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45518. j++;
  45519. }
  45520. if (j >= signatureLength) {
  45521. i += j;
  45522. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45523. i++;
  45524. }
  45525. found = true;
  45526. break;
  45527. }
  45528. i++;
  45529. }
  45530. return {
  45531. found: found,
  45532. length: i
  45533. };
  45534. }
  45535. function getHeaderBlock(stream, suggestedLength) {
  45536. var EEXEC_SIGNATURE = [
  45537. 0x65,
  45538. 0x65,
  45539. 0x78,
  45540. 0x65,
  45541. 0x63
  45542. ];
  45543. var streamStartPos = stream.pos;
  45544. var headerBytes, headerBytesLength, block;
  45545. try {
  45546. headerBytes = stream.getBytes(suggestedLength);
  45547. headerBytesLength = headerBytes.length;
  45548. } catch (ex) {
  45549. if (ex instanceof MissingDataException) {
  45550. throw ex;
  45551. }
  45552. }
  45553. if (headerBytesLength === suggestedLength) {
  45554. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45555. if (block.found && block.length === suggestedLength) {
  45556. return {
  45557. stream: new Stream(headerBytes),
  45558. length: suggestedLength
  45559. };
  45560. }
  45561. }
  45562. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45563. stream.pos = streamStartPos;
  45564. var SCAN_BLOCK_LENGTH = 2048;
  45565. var actualLength;
  45566. while (true) {
  45567. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45568. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45569. if (block.length === 0) {
  45570. break;
  45571. }
  45572. stream.pos += block.length;
  45573. if (block.found) {
  45574. actualLength = stream.pos - streamStartPos;
  45575. break;
  45576. }
  45577. }
  45578. stream.pos = streamStartPos;
  45579. if (actualLength) {
  45580. return {
  45581. stream: new Stream(stream.getBytes(actualLength)),
  45582. length: actualLength
  45583. };
  45584. }
  45585. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45586. return {
  45587. stream: new Stream(stream.getBytes(suggestedLength)),
  45588. length: suggestedLength
  45589. };
  45590. }
  45591. function getEexecBlock(stream, suggestedLength) {
  45592. var eexecBytes = stream.getBytes();
  45593. return {
  45594. stream: new Stream(eexecBytes),
  45595. length: eexecBytes.length
  45596. };
  45597. }
  45598. function Type1Font(name, file, properties) {
  45599. var PFB_HEADER_SIZE = 6;
  45600. var headerBlockLength = properties.length1;
  45601. var eexecBlockLength = properties.length2;
  45602. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45603. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45604. if (pfbHeaderPresent) {
  45605. file.skip(PFB_HEADER_SIZE);
  45606. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45607. }
  45608. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45609. headerBlockLength = headerBlock.length;
  45610. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45611. headerBlockParser.extractFontHeader(properties);
  45612. if (pfbHeaderPresent) {
  45613. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45614. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45615. }
  45616. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45617. eexecBlockLength = eexecBlock.length;
  45618. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45619. var data = eexecBlockParser.extractFontProgram();
  45620. for (var info in data.properties) {
  45621. properties[info] = data.properties[info];
  45622. }
  45623. var charstrings = data.charstrings;
  45624. var type2Charstrings = this.getType2Charstrings(charstrings);
  45625. var subrs = this.getType2Subrs(data.subrs);
  45626. this.charstrings = charstrings;
  45627. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45628. this.seacs = this.getSeacs(data.charstrings);
  45629. }
  45630. Type1Font.prototype = {
  45631. get numGlyphs() {
  45632. return this.charstrings.length + 1;
  45633. },
  45634. getCharset: function Type1Font_getCharset() {
  45635. var charset = ['.notdef'];
  45636. var charstrings = this.charstrings;
  45637. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45638. charset.push(charstrings[glyphId].glyphName);
  45639. }
  45640. return charset;
  45641. },
  45642. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45643. var charstrings = this.charstrings;
  45644. var glyphNames = ['.notdef'], glyphId;
  45645. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45646. glyphNames.push(charstrings[glyphId].glyphName);
  45647. }
  45648. var encoding = properties.builtInEncoding;
  45649. if (encoding) {
  45650. var builtInEncoding = Object.create(null);
  45651. for (var charCode in encoding) {
  45652. glyphId = glyphNames.indexOf(encoding[charCode]);
  45653. if (glyphId >= 0) {
  45654. builtInEncoding[charCode] = glyphId;
  45655. }
  45656. }
  45657. }
  45658. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45659. },
  45660. getSeacs: function Type1Font_getSeacs(charstrings) {
  45661. var i, ii;
  45662. var seacMap = [];
  45663. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45664. var charstring = charstrings[i];
  45665. if (charstring.seac) {
  45666. seacMap[i + 1] = charstring.seac;
  45667. }
  45668. }
  45669. return seacMap;
  45670. },
  45671. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45672. var type2Charstrings = [];
  45673. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45674. type2Charstrings.push(type1Charstrings[i].charstring);
  45675. }
  45676. return type2Charstrings;
  45677. },
  45678. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45679. var bias = 0;
  45680. var count = type1Subrs.length;
  45681. if (count < 1133) {
  45682. bias = 107;
  45683. } else if (count < 33769) {
  45684. bias = 1131;
  45685. } else {
  45686. bias = 32768;
  45687. }
  45688. var type2Subrs = [];
  45689. var i;
  45690. for (i = 0; i < bias; i++) {
  45691. type2Subrs.push([0x0B]);
  45692. }
  45693. for (i = 0; i < count; i++) {
  45694. type2Subrs.push(type1Subrs[i]);
  45695. }
  45696. return type2Subrs;
  45697. },
  45698. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45699. var cff = new CFF();
  45700. cff.header = new CFFHeader(1, 0, 4, 4);
  45701. cff.names = [name];
  45702. var topDict = new CFFTopDict();
  45703. topDict.setByName('version', 391);
  45704. topDict.setByName('Notice', 392);
  45705. topDict.setByName('FullName', 393);
  45706. topDict.setByName('FamilyName', 394);
  45707. topDict.setByName('Weight', 395);
  45708. topDict.setByName('Encoding', null);
  45709. topDict.setByName('FontMatrix', properties.fontMatrix);
  45710. topDict.setByName('FontBBox', properties.bbox);
  45711. topDict.setByName('charset', null);
  45712. topDict.setByName('CharStrings', null);
  45713. topDict.setByName('Private', null);
  45714. cff.topDict = topDict;
  45715. var strings = new CFFStrings();
  45716. strings.add('Version 0.11');
  45717. strings.add('See original notice');
  45718. strings.add(name);
  45719. strings.add(name);
  45720. strings.add('Medium');
  45721. cff.strings = strings;
  45722. cff.globalSubrIndex = new CFFIndex();
  45723. var count = glyphs.length;
  45724. var charsetArray = [0];
  45725. var i, ii;
  45726. for (i = 0; i < count; i++) {
  45727. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45728. if (index === -1) {
  45729. index = 0;
  45730. }
  45731. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45732. }
  45733. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45734. var charStringsIndex = new CFFIndex();
  45735. charStringsIndex.add([
  45736. 0x8B,
  45737. 0x0E
  45738. ]);
  45739. for (i = 0; i < count; i++) {
  45740. var glyph = glyphs[i];
  45741. if (glyph.length === 0) {
  45742. charStringsIndex.add([
  45743. 0x8B,
  45744. 0x0E
  45745. ]);
  45746. continue;
  45747. }
  45748. charStringsIndex.add(glyph);
  45749. }
  45750. cff.charStrings = charStringsIndex;
  45751. var privateDict = new CFFPrivateDict();
  45752. privateDict.setByName('Subrs', null);
  45753. var fields = [
  45754. 'BlueValues',
  45755. 'OtherBlues',
  45756. 'FamilyBlues',
  45757. 'FamilyOtherBlues',
  45758. 'StemSnapH',
  45759. 'StemSnapV',
  45760. 'BlueShift',
  45761. 'BlueFuzz',
  45762. 'BlueScale',
  45763. 'LanguageGroup',
  45764. 'ExpansionFactor',
  45765. 'ForceBold',
  45766. 'StdHW',
  45767. 'StdVW'
  45768. ];
  45769. for (i = 0, ii = fields.length; i < ii; i++) {
  45770. var field = fields[i];
  45771. if (!(field in properties.privateData)) {
  45772. continue;
  45773. }
  45774. var value = properties.privateData[field];
  45775. if (isArray(value)) {
  45776. for (var j = value.length - 1; j > 0; j--) {
  45777. value[j] -= value[j - 1];
  45778. }
  45779. }
  45780. privateDict.setByName(field, value);
  45781. }
  45782. cff.topDict.privateDict = privateDict;
  45783. var subrIndex = new CFFIndex();
  45784. for (i = 0, ii = subrs.length; i < ii; i++) {
  45785. subrIndex.add(subrs[i]);
  45786. }
  45787. privateDict.subrsIndex = subrIndex;
  45788. var compiler = new CFFCompiler(cff);
  45789. return compiler.compile();
  45790. }
  45791. };
  45792. return Type1Font;
  45793. }();
  45794. var CFFFont = function CFFFontClosure() {
  45795. function CFFFont(file, properties) {
  45796. this.properties = properties;
  45797. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45798. this.cff = parser.parse();
  45799. var compiler = new CFFCompiler(this.cff);
  45800. this.seacs = this.cff.seacs;
  45801. try {
  45802. this.data = compiler.compile();
  45803. } catch (e) {
  45804. warn('Failed to compile font ' + properties.loadedName);
  45805. this.data = file;
  45806. }
  45807. }
  45808. CFFFont.prototype = {
  45809. get numGlyphs() {
  45810. return this.cff.charStrings.count;
  45811. },
  45812. getCharset: function CFFFont_getCharset() {
  45813. return this.cff.charset.charset;
  45814. },
  45815. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45816. var cff = this.cff;
  45817. var properties = this.properties;
  45818. var charsets = cff.charset.charset;
  45819. var charCodeToGlyphId;
  45820. var glyphId;
  45821. if (properties.composite) {
  45822. charCodeToGlyphId = Object.create(null);
  45823. if (cff.isCIDFont) {
  45824. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45825. var cid = charsets[glyphId];
  45826. var charCode = properties.cMap.charCodeOf(cid);
  45827. charCodeToGlyphId[charCode] = glyphId;
  45828. }
  45829. } else {
  45830. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45831. charCodeToGlyphId[glyphId] = glyphId;
  45832. }
  45833. }
  45834. return charCodeToGlyphId;
  45835. }
  45836. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45837. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45838. return charCodeToGlyphId;
  45839. }
  45840. };
  45841. return CFFFont;
  45842. }();
  45843. (function checkSeacSupport() {
  45844. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45845. SEAC_ANALYSIS_ENABLED = true;
  45846. }
  45847. }());
  45848. (function checkChromeWindows() {
  45849. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45850. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45851. }
  45852. }());
  45853. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  45854. exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START;
  45855. exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
  45856. exports.ErrorFont = ErrorFont;
  45857. exports.Font = Font;
  45858. exports.FontFlags = FontFlags;
  45859. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45860. exports.ProblematicCharRanges = ProblematicCharRanges;
  45861. exports.ToUnicodeMap = ToUnicodeMap;
  45862. exports.getFontType = getFontType;
  45863. /***/ }),
  45864. /* 34 */
  45865. /***/ (function(module, exports, __w_pdfjs_require__) {
  45866. "use strict";
  45867. var sharedUtil = __w_pdfjs_require__(0);
  45868. var corePrimitives = __w_pdfjs_require__(1);
  45869. var coreColorSpace = __w_pdfjs_require__(4);
  45870. var coreStream = __w_pdfjs_require__(2);
  45871. var coreJpx = __w_pdfjs_require__(19);
  45872. var ImageKind = sharedUtil.ImageKind;
  45873. var assert = sharedUtil.assert;
  45874. var error = sharedUtil.error;
  45875. var info = sharedUtil.info;
  45876. var isArray = sharedUtil.isArray;
  45877. var warn = sharedUtil.warn;
  45878. var Name = corePrimitives.Name;
  45879. var isStream = corePrimitives.isStream;
  45880. var ColorSpace = coreColorSpace.ColorSpace;
  45881. var DecodeStream = coreStream.DecodeStream;
  45882. var JpegStream = coreStream.JpegStream;
  45883. var JpxImage = coreJpx.JpxImage;
  45884. var PDFImage = function PDFImageClosure() {
  45885. function handleImageData(image, nativeDecoder) {
  45886. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  45887. return nativeDecoder.decode(image);
  45888. }
  45889. return Promise.resolve(image);
  45890. }
  45891. function decodeAndClamp(value, addend, coefficient, max) {
  45892. value = addend + value * coefficient;
  45893. return value < 0 ? 0 : value > max ? max : value;
  45894. }
  45895. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  45896. var length = w2 * h2;
  45897. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  45898. var xRatio = w1 / w2;
  45899. var yRatio = h1 / h2;
  45900. var i, j, py, newIndex = 0, oldIndex;
  45901. var xScaled = new Uint16Array(w2);
  45902. var w1Scanline = w1;
  45903. for (i = 0; i < w2; i++) {
  45904. xScaled[i] = Math.floor(i * xRatio);
  45905. }
  45906. for (i = 0; i < h2; i++) {
  45907. py = Math.floor(i * yRatio) * w1Scanline;
  45908. for (j = 0; j < w2; j++) {
  45909. oldIndex = py + xScaled[j];
  45910. dest[newIndex++] = src[oldIndex];
  45911. }
  45912. }
  45913. return dest;
  45914. }
  45915. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  45916. this.image = image;
  45917. var dict = image.dict;
  45918. if (dict.has('Filter')) {
  45919. var filter = dict.get('Filter').name;
  45920. if (filter === 'JPXDecode') {
  45921. var jpxImage = new JpxImage();
  45922. jpxImage.parseImageProperties(image.stream);
  45923. image.stream.reset();
  45924. image.bitsPerComponent = jpxImage.bitsPerComponent;
  45925. image.numComps = jpxImage.componentsCount;
  45926. } else if (filter === 'JBIG2Decode') {
  45927. image.bitsPerComponent = 1;
  45928. image.numComps = 1;
  45929. }
  45930. }
  45931. this.width = dict.get('Width', 'W');
  45932. this.height = dict.get('Height', 'H');
  45933. if (this.width < 1 || this.height < 1) {
  45934. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  45935. }
  45936. this.interpolate = dict.get('Interpolate', 'I') || false;
  45937. this.imageMask = dict.get('ImageMask', 'IM') || false;
  45938. this.matte = dict.get('Matte') || false;
  45939. var bitsPerComponent = image.bitsPerComponent;
  45940. if (!bitsPerComponent) {
  45941. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  45942. if (!bitsPerComponent) {
  45943. if (this.imageMask) {
  45944. bitsPerComponent = 1;
  45945. } else {
  45946. error('Bits per component missing in image: ' + this.imageMask);
  45947. }
  45948. }
  45949. }
  45950. this.bpc = bitsPerComponent;
  45951. if (!this.imageMask) {
  45952. var colorSpace = dict.get('ColorSpace', 'CS');
  45953. if (!colorSpace) {
  45954. info('JPX images (which do not require color spaces)');
  45955. switch (image.numComps) {
  45956. case 1:
  45957. colorSpace = Name.get('DeviceGray');
  45958. break;
  45959. case 3:
  45960. colorSpace = Name.get('DeviceRGB');
  45961. break;
  45962. case 4:
  45963. colorSpace = Name.get('DeviceCMYK');
  45964. break;
  45965. default:
  45966. error('JPX images with ' + this.numComps + ' color components not supported.');
  45967. }
  45968. }
  45969. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  45970. this.numComps = this.colorSpace.numComps;
  45971. }
  45972. this.decode = dict.getArray('Decode', 'D');
  45973. this.needsDecode = false;
  45974. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  45975. this.needsDecode = true;
  45976. var max = (1 << bitsPerComponent) - 1;
  45977. this.decodeCoefficients = [];
  45978. this.decodeAddends = [];
  45979. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  45980. var dmin = this.decode[i];
  45981. var dmax = this.decode[i + 1];
  45982. this.decodeCoefficients[j] = dmax - dmin;
  45983. this.decodeAddends[j] = max * dmin;
  45984. }
  45985. }
  45986. if (smask) {
  45987. this.smask = new PDFImage(xref, res, smask, false);
  45988. } else if (mask) {
  45989. if (isStream(mask)) {
  45990. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  45991. if (!imageMask) {
  45992. warn('Ignoring /Mask in image without /ImageMask.');
  45993. } else {
  45994. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  45995. }
  45996. } else {
  45997. this.mask = mask;
  45998. }
  45999. }
  46000. }
  46001. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46002. var imagePromise = handleImageData(image, nativeDecoder);
  46003. var smaskPromise;
  46004. var maskPromise;
  46005. var smask = image.dict.get('SMask');
  46006. var mask = image.dict.get('Mask');
  46007. if (smask) {
  46008. smaskPromise = handleImageData(smask, nativeDecoder);
  46009. maskPromise = Promise.resolve(null);
  46010. } else {
  46011. smaskPromise = Promise.resolve(null);
  46012. if (mask) {
  46013. if (isStream(mask)) {
  46014. maskPromise = handleImageData(mask, nativeDecoder);
  46015. } else if (isArray(mask)) {
  46016. maskPromise = Promise.resolve(mask);
  46017. } else {
  46018. warn('Unsupported mask format.');
  46019. maskPromise = Promise.resolve(null);
  46020. }
  46021. } else {
  46022. maskPromise = Promise.resolve(null);
  46023. }
  46024. }
  46025. return Promise.all([
  46026. imagePromise,
  46027. smaskPromise,
  46028. maskPromise
  46029. ]).then(function (results) {
  46030. var imageData = results[0];
  46031. var smaskData = results[1];
  46032. var maskData = results[2];
  46033. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46034. });
  46035. };
  46036. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46037. var computedLength = (width + 7 >> 3) * height;
  46038. var actualLength = imgArray.byteLength;
  46039. var haveFullData = computedLength === actualLength;
  46040. var data, i;
  46041. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46042. data = imgArray;
  46043. } else if (!inverseDecode) {
  46044. data = new Uint8Array(actualLength);
  46045. data.set(imgArray);
  46046. } else {
  46047. data = new Uint8Array(computedLength);
  46048. data.set(imgArray);
  46049. for (i = actualLength; i < computedLength; i++) {
  46050. data[i] = 0xff;
  46051. }
  46052. }
  46053. if (inverseDecode) {
  46054. for (i = 0; i < actualLength; i++) {
  46055. data[i] = ~data[i];
  46056. }
  46057. }
  46058. return {
  46059. data: data,
  46060. width: width,
  46061. height: height
  46062. };
  46063. };
  46064. PDFImage.prototype = {
  46065. get drawWidth() {
  46066. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46067. },
  46068. get drawHeight() {
  46069. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46070. },
  46071. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46072. var bpc = this.bpc;
  46073. var numComps = this.numComps;
  46074. var decodeAddends = this.decodeAddends;
  46075. var decodeCoefficients = this.decodeCoefficients;
  46076. var max = (1 << bpc) - 1;
  46077. var i, ii;
  46078. if (bpc === 1) {
  46079. for (i = 0, ii = buffer.length; i < ii; i++) {
  46080. buffer[i] = +!buffer[i];
  46081. }
  46082. return;
  46083. }
  46084. var index = 0;
  46085. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46086. for (var j = 0; j < numComps; j++) {
  46087. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46088. index++;
  46089. }
  46090. }
  46091. },
  46092. getComponents: function PDFImage_getComponents(buffer) {
  46093. var bpc = this.bpc;
  46094. if (bpc === 8) {
  46095. return buffer;
  46096. }
  46097. var width = this.width;
  46098. var height = this.height;
  46099. var numComps = this.numComps;
  46100. var length = width * height * numComps;
  46101. var bufferPos = 0;
  46102. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46103. var rowComps = width * numComps;
  46104. var max = (1 << bpc) - 1;
  46105. var i = 0, ii, buf;
  46106. if (bpc === 1) {
  46107. var mask, loop1End, loop2End;
  46108. for (var j = 0; j < height; j++) {
  46109. loop1End = i + (rowComps & ~7);
  46110. loop2End = i + rowComps;
  46111. while (i < loop1End) {
  46112. buf = buffer[bufferPos++];
  46113. output[i] = buf >> 7 & 1;
  46114. output[i + 1] = buf >> 6 & 1;
  46115. output[i + 2] = buf >> 5 & 1;
  46116. output[i + 3] = buf >> 4 & 1;
  46117. output[i + 4] = buf >> 3 & 1;
  46118. output[i + 5] = buf >> 2 & 1;
  46119. output[i + 6] = buf >> 1 & 1;
  46120. output[i + 7] = buf & 1;
  46121. i += 8;
  46122. }
  46123. if (i < loop2End) {
  46124. buf = buffer[bufferPos++];
  46125. mask = 128;
  46126. while (i < loop2End) {
  46127. output[i++] = +!!(buf & mask);
  46128. mask >>= 1;
  46129. }
  46130. }
  46131. }
  46132. } else {
  46133. var bits = 0;
  46134. buf = 0;
  46135. for (i = 0, ii = length; i < ii; ++i) {
  46136. if (i % rowComps === 0) {
  46137. buf = 0;
  46138. bits = 0;
  46139. }
  46140. while (bits < bpc) {
  46141. buf = buf << 8 | buffer[bufferPos++];
  46142. bits += 8;
  46143. }
  46144. var remainingBits = bits - bpc;
  46145. var value = buf >> remainingBits;
  46146. output[i] = value < 0 ? 0 : value > max ? max : value;
  46147. buf = buf & (1 << remainingBits) - 1;
  46148. bits = remainingBits;
  46149. }
  46150. }
  46151. return output;
  46152. },
  46153. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46154. var smask = this.smask;
  46155. var mask = this.mask;
  46156. var alphaBuf, sw, sh, i, ii, j;
  46157. if (smask) {
  46158. sw = smask.width;
  46159. sh = smask.height;
  46160. alphaBuf = new Uint8Array(sw * sh);
  46161. smask.fillGrayBuffer(alphaBuf);
  46162. if (sw !== width || sh !== height) {
  46163. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46164. }
  46165. } else if (mask) {
  46166. if (mask instanceof PDFImage) {
  46167. sw = mask.width;
  46168. sh = mask.height;
  46169. alphaBuf = new Uint8Array(sw * sh);
  46170. mask.numComps = 1;
  46171. mask.fillGrayBuffer(alphaBuf);
  46172. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46173. alphaBuf[i] = 255 - alphaBuf[i];
  46174. }
  46175. if (sw !== width || sh !== height) {
  46176. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46177. }
  46178. } else if (isArray(mask)) {
  46179. alphaBuf = new Uint8Array(width * height);
  46180. var numComps = this.numComps;
  46181. for (i = 0, ii = width * height; i < ii; ++i) {
  46182. var opacity = 0;
  46183. var imageOffset = i * numComps;
  46184. for (j = 0; j < numComps; ++j) {
  46185. var color = image[imageOffset + j];
  46186. var maskOffset = j * 2;
  46187. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46188. opacity = 255;
  46189. break;
  46190. }
  46191. }
  46192. alphaBuf[i] = opacity;
  46193. }
  46194. } else {
  46195. error('Unknown mask format.');
  46196. }
  46197. }
  46198. if (alphaBuf) {
  46199. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46200. rgbaBuf[j] = alphaBuf[i];
  46201. }
  46202. } else {
  46203. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46204. rgbaBuf[j] = 255;
  46205. }
  46206. }
  46207. },
  46208. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46209. var matte = this.smask && this.smask.matte;
  46210. if (!matte) {
  46211. return;
  46212. }
  46213. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46214. var matteR = matteRgb[0];
  46215. var matteG = matteRgb[1];
  46216. var matteB = matteRgb[2];
  46217. var length = width * height * 4;
  46218. var r, g, b;
  46219. for (var i = 0; i < length; i += 4) {
  46220. var alpha = buffer[i + 3];
  46221. if (alpha === 0) {
  46222. buffer[i] = 255;
  46223. buffer[i + 1] = 255;
  46224. buffer[i + 2] = 255;
  46225. continue;
  46226. }
  46227. var k = 255 / alpha;
  46228. r = (buffer[i] - matteR) * k + matteR;
  46229. g = (buffer[i + 1] - matteG) * k + matteG;
  46230. b = (buffer[i + 2] - matteB) * k + matteB;
  46231. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  46232. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  46233. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  46234. }
  46235. },
  46236. createImageData: function PDFImage_createImageData(forceRGBA) {
  46237. var drawWidth = this.drawWidth;
  46238. var drawHeight = this.drawHeight;
  46239. var imgData = {
  46240. width: drawWidth,
  46241. height: drawHeight
  46242. };
  46243. var numComps = this.numComps;
  46244. var originalWidth = this.width;
  46245. var originalHeight = this.height;
  46246. var bpc = this.bpc;
  46247. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  46248. var imgArray;
  46249. if (!forceRGBA) {
  46250. var kind;
  46251. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  46252. kind = ImageKind.GRAYSCALE_1BPP;
  46253. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  46254. kind = ImageKind.RGB_24BPP;
  46255. }
  46256. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  46257. imgData.kind = kind;
  46258. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46259. if (this.image instanceof DecodeStream) {
  46260. imgData.data = imgArray;
  46261. } else {
  46262. var newArray = new Uint8Array(imgArray.length);
  46263. newArray.set(imgArray);
  46264. imgData.data = newArray;
  46265. }
  46266. if (this.needsDecode) {
  46267. assert(kind === ImageKind.GRAYSCALE_1BPP);
  46268. var buffer = imgData.data;
  46269. for (var i = 0, ii = buffer.length; i < ii; i++) {
  46270. buffer[i] ^= 0xff;
  46271. }
  46272. }
  46273. return imgData;
  46274. }
  46275. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  46276. imgData.kind = ImageKind.RGB_24BPP;
  46277. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  46278. return imgData;
  46279. }
  46280. }
  46281. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46282. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  46283. var comps = this.getComponents(imgArray);
  46284. var alpha01, maybeUndoPreblend;
  46285. if (!forceRGBA && !this.smask && !this.mask) {
  46286. imgData.kind = ImageKind.RGB_24BPP;
  46287. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  46288. alpha01 = 0;
  46289. maybeUndoPreblend = false;
  46290. } else {
  46291. imgData.kind = ImageKind.RGBA_32BPP;
  46292. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  46293. alpha01 = 1;
  46294. maybeUndoPreblend = true;
  46295. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  46296. }
  46297. if (this.needsDecode) {
  46298. this.decodeBuffer(comps);
  46299. }
  46300. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  46301. if (maybeUndoPreblend) {
  46302. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  46303. }
  46304. return imgData;
  46305. },
  46306. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  46307. var numComps = this.numComps;
  46308. if (numComps !== 1) {
  46309. error('Reading gray scale from a color image: ' + numComps);
  46310. }
  46311. var width = this.width;
  46312. var height = this.height;
  46313. var bpc = this.bpc;
  46314. var rowBytes = width * numComps * bpc + 7 >> 3;
  46315. var imgArray = this.getImageBytes(height * rowBytes);
  46316. var comps = this.getComponents(imgArray);
  46317. var i, length;
  46318. if (bpc === 1) {
  46319. length = width * height;
  46320. if (this.needsDecode) {
  46321. for (i = 0; i < length; ++i) {
  46322. buffer[i] = comps[i] - 1 & 255;
  46323. }
  46324. } else {
  46325. for (i = 0; i < length; ++i) {
  46326. buffer[i] = -comps[i] & 255;
  46327. }
  46328. }
  46329. return;
  46330. }
  46331. if (this.needsDecode) {
  46332. this.decodeBuffer(comps);
  46333. }
  46334. length = width * height;
  46335. var scale = 255 / ((1 << bpc) - 1);
  46336. for (i = 0; i < length; ++i) {
  46337. buffer[i] = scale * comps[i] | 0;
  46338. }
  46339. },
  46340. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  46341. this.image.reset();
  46342. this.image.drawWidth = drawWidth || this.width;
  46343. this.image.drawHeight = drawHeight || this.height;
  46344. this.image.forceRGB = !!forceRGB;
  46345. return this.image.getBytes(length);
  46346. }
  46347. };
  46348. return PDFImage;
  46349. }();
  46350. exports.PDFImage = PDFImage;
  46351. /***/ }),
  46352. /* 35 */
  46353. /***/ (function(module, exports, __w_pdfjs_require__) {
  46354. "use strict";
  46355. var sharedUtil = __w_pdfjs_require__(0);
  46356. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  46357. var error = sharedUtil.error;
  46358. var log2 = sharedUtil.log2;
  46359. var readInt8 = sharedUtil.readInt8;
  46360. var readUint16 = sharedUtil.readUint16;
  46361. var readUint32 = sharedUtil.readUint32;
  46362. var shadow = sharedUtil.shadow;
  46363. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  46364. var Jbig2Image = function Jbig2ImageClosure() {
  46365. function ContextCache() {
  46366. }
  46367. ContextCache.prototype = {
  46368. getContexts: function (id) {
  46369. if (id in this) {
  46370. return this[id];
  46371. }
  46372. return this[id] = new Int8Array(1 << 16);
  46373. }
  46374. };
  46375. function DecodingContext(data, start, end) {
  46376. this.data = data;
  46377. this.start = start;
  46378. this.end = end;
  46379. }
  46380. DecodingContext.prototype = {
  46381. get decoder() {
  46382. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  46383. return shadow(this, 'decoder', decoder);
  46384. },
  46385. get contextCache() {
  46386. var cache = new ContextCache();
  46387. return shadow(this, 'contextCache', cache);
  46388. }
  46389. };
  46390. function decodeInteger(contextCache, procedure, decoder) {
  46391. var contexts = contextCache.getContexts(procedure);
  46392. var prev = 1;
  46393. function readBits(length) {
  46394. var v = 0;
  46395. for (var i = 0; i < length; i++) {
  46396. var bit = decoder.readBit(contexts, prev);
  46397. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  46398. v = v << 1 | bit;
  46399. }
  46400. return v >>> 0;
  46401. }
  46402. var sign = readBits(1);
  46403. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  46404. return sign === 0 ? value : value > 0 ? -value : null;
  46405. }
  46406. function decodeIAID(contextCache, decoder, codeLength) {
  46407. var contexts = contextCache.getContexts('IAID');
  46408. var prev = 1;
  46409. for (var i = 0; i < codeLength; i++) {
  46410. var bit = decoder.readBit(contexts, prev);
  46411. prev = prev << 1 | bit;
  46412. }
  46413. if (codeLength < 31) {
  46414. return prev & (1 << codeLength) - 1;
  46415. }
  46416. return prev & 0x7FFFFFFF;
  46417. }
  46418. var SegmentTypes = [
  46419. 'SymbolDictionary',
  46420. null,
  46421. null,
  46422. null,
  46423. 'IntermediateTextRegion',
  46424. null,
  46425. 'ImmediateTextRegion',
  46426. 'ImmediateLosslessTextRegion',
  46427. null,
  46428. null,
  46429. null,
  46430. null,
  46431. null,
  46432. null,
  46433. null,
  46434. null,
  46435. 'patternDictionary',
  46436. null,
  46437. null,
  46438. null,
  46439. 'IntermediateHalftoneRegion',
  46440. null,
  46441. 'ImmediateHalftoneRegion',
  46442. 'ImmediateLosslessHalftoneRegion',
  46443. null,
  46444. null,
  46445. null,
  46446. null,
  46447. null,
  46448. null,
  46449. null,
  46450. null,
  46451. null,
  46452. null,
  46453. null,
  46454. null,
  46455. 'IntermediateGenericRegion',
  46456. null,
  46457. 'ImmediateGenericRegion',
  46458. 'ImmediateLosslessGenericRegion',
  46459. 'IntermediateGenericRefinementRegion',
  46460. null,
  46461. 'ImmediateGenericRefinementRegion',
  46462. 'ImmediateLosslessGenericRefinementRegion',
  46463. null,
  46464. null,
  46465. null,
  46466. null,
  46467. 'PageInformation',
  46468. 'EndOfPage',
  46469. 'EndOfStripe',
  46470. 'EndOfFile',
  46471. 'Profiles',
  46472. 'Tables',
  46473. null,
  46474. null,
  46475. null,
  46476. null,
  46477. null,
  46478. null,
  46479. null,
  46480. null,
  46481. 'Extension'
  46482. ];
  46483. var CodingTemplates = [
  46484. [
  46485. {
  46486. x: -1,
  46487. y: -2
  46488. },
  46489. {
  46490. x: 0,
  46491. y: -2
  46492. },
  46493. {
  46494. x: 1,
  46495. y: -2
  46496. },
  46497. {
  46498. x: -2,
  46499. y: -1
  46500. },
  46501. {
  46502. x: -1,
  46503. y: -1
  46504. },
  46505. {
  46506. x: 0,
  46507. y: -1
  46508. },
  46509. {
  46510. x: 1,
  46511. y: -1
  46512. },
  46513. {
  46514. x: 2,
  46515. y: -1
  46516. },
  46517. {
  46518. x: -4,
  46519. y: 0
  46520. },
  46521. {
  46522. x: -3,
  46523. y: 0
  46524. },
  46525. {
  46526. x: -2,
  46527. y: 0
  46528. },
  46529. {
  46530. x: -1,
  46531. y: 0
  46532. }
  46533. ],
  46534. [
  46535. {
  46536. x: -1,
  46537. y: -2
  46538. },
  46539. {
  46540. x: 0,
  46541. y: -2
  46542. },
  46543. {
  46544. x: 1,
  46545. y: -2
  46546. },
  46547. {
  46548. x: 2,
  46549. y: -2
  46550. },
  46551. {
  46552. x: -2,
  46553. y: -1
  46554. },
  46555. {
  46556. x: -1,
  46557. y: -1
  46558. },
  46559. {
  46560. x: 0,
  46561. y: -1
  46562. },
  46563. {
  46564. x: 1,
  46565. y: -1
  46566. },
  46567. {
  46568. x: 2,
  46569. y: -1
  46570. },
  46571. {
  46572. x: -3,
  46573. y: 0
  46574. },
  46575. {
  46576. x: -2,
  46577. y: 0
  46578. },
  46579. {
  46580. x: -1,
  46581. y: 0
  46582. }
  46583. ],
  46584. [
  46585. {
  46586. x: -1,
  46587. y: -2
  46588. },
  46589. {
  46590. x: 0,
  46591. y: -2
  46592. },
  46593. {
  46594. x: 1,
  46595. y: -2
  46596. },
  46597. {
  46598. x: -2,
  46599. y: -1
  46600. },
  46601. {
  46602. x: -1,
  46603. y: -1
  46604. },
  46605. {
  46606. x: 0,
  46607. y: -1
  46608. },
  46609. {
  46610. x: 1,
  46611. y: -1
  46612. },
  46613. {
  46614. x: -2,
  46615. y: 0
  46616. },
  46617. {
  46618. x: -1,
  46619. y: 0
  46620. }
  46621. ],
  46622. [
  46623. {
  46624. x: -3,
  46625. y: -1
  46626. },
  46627. {
  46628. x: -2,
  46629. y: -1
  46630. },
  46631. {
  46632. x: -1,
  46633. y: -1
  46634. },
  46635. {
  46636. x: 0,
  46637. y: -1
  46638. },
  46639. {
  46640. x: 1,
  46641. y: -1
  46642. },
  46643. {
  46644. x: -4,
  46645. y: 0
  46646. },
  46647. {
  46648. x: -3,
  46649. y: 0
  46650. },
  46651. {
  46652. x: -2,
  46653. y: 0
  46654. },
  46655. {
  46656. x: -1,
  46657. y: 0
  46658. }
  46659. ]
  46660. ];
  46661. var RefinementTemplates = [
  46662. {
  46663. coding: [
  46664. {
  46665. x: 0,
  46666. y: -1
  46667. },
  46668. {
  46669. x: 1,
  46670. y: -1
  46671. },
  46672. {
  46673. x: -1,
  46674. y: 0
  46675. }
  46676. ],
  46677. reference: [
  46678. {
  46679. x: 0,
  46680. y: -1
  46681. },
  46682. {
  46683. x: 1,
  46684. y: -1
  46685. },
  46686. {
  46687. x: -1,
  46688. y: 0
  46689. },
  46690. {
  46691. x: 0,
  46692. y: 0
  46693. },
  46694. {
  46695. x: 1,
  46696. y: 0
  46697. },
  46698. {
  46699. x: -1,
  46700. y: 1
  46701. },
  46702. {
  46703. x: 0,
  46704. y: 1
  46705. },
  46706. {
  46707. x: 1,
  46708. y: 1
  46709. }
  46710. ]
  46711. },
  46712. {
  46713. coding: [
  46714. {
  46715. x: -1,
  46716. y: -1
  46717. },
  46718. {
  46719. x: 0,
  46720. y: -1
  46721. },
  46722. {
  46723. x: 1,
  46724. y: -1
  46725. },
  46726. {
  46727. x: -1,
  46728. y: 0
  46729. }
  46730. ],
  46731. reference: [
  46732. {
  46733. x: 0,
  46734. y: -1
  46735. },
  46736. {
  46737. x: -1,
  46738. y: 0
  46739. },
  46740. {
  46741. x: 0,
  46742. y: 0
  46743. },
  46744. {
  46745. x: 1,
  46746. y: 0
  46747. },
  46748. {
  46749. x: 0,
  46750. y: 1
  46751. },
  46752. {
  46753. x: 1,
  46754. y: 1
  46755. }
  46756. ]
  46757. }
  46758. ];
  46759. var ReusedContexts = [
  46760. 0x9B25,
  46761. 0x0795,
  46762. 0x00E5,
  46763. 0x0195
  46764. ];
  46765. var RefinementReusedContexts = [
  46766. 0x0020,
  46767. 0x0008
  46768. ];
  46769. function decodeBitmapTemplate0(width, height, decodingContext) {
  46770. var decoder = decodingContext.decoder;
  46771. var contexts = decodingContext.contextCache.getContexts('GB');
  46772. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  46773. var OLD_PIXEL_MASK = 0x7BF7;
  46774. for (i = 0; i < height; i++) {
  46775. row = bitmap[i] = new Uint8Array(width);
  46776. row1 = i < 1 ? row : bitmap[i - 1];
  46777. row2 = i < 2 ? row : bitmap[i - 2];
  46778. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  46779. for (j = 0; j < width; j++) {
  46780. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  46781. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  46782. }
  46783. }
  46784. return bitmap;
  46785. }
  46786. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  46787. if (mmr) {
  46788. error('JBIG2 error: MMR encoding is not supported');
  46789. }
  46790. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  46791. return decodeBitmapTemplate0(width, height, decodingContext);
  46792. }
  46793. var useskip = !!skip;
  46794. var template = CodingTemplates[templateIndex].concat(at);
  46795. template.sort(function (a, b) {
  46796. return a.y - b.y || a.x - b.x;
  46797. });
  46798. var templateLength = template.length;
  46799. var templateX = new Int8Array(templateLength);
  46800. var templateY = new Int8Array(templateLength);
  46801. var changingTemplateEntries = [];
  46802. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  46803. var c, k;
  46804. for (k = 0; k < templateLength; k++) {
  46805. templateX[k] = template[k].x;
  46806. templateY[k] = template[k].y;
  46807. minX = Math.min(minX, template[k].x);
  46808. maxX = Math.max(maxX, template[k].x);
  46809. minY = Math.min(minY, template[k].y);
  46810. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  46811. reuseMask |= 1 << templateLength - 1 - k;
  46812. } else {
  46813. changingTemplateEntries.push(k);
  46814. }
  46815. }
  46816. var changingEntriesLength = changingTemplateEntries.length;
  46817. var changingTemplateX = new Int8Array(changingEntriesLength);
  46818. var changingTemplateY = new Int8Array(changingEntriesLength);
  46819. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  46820. for (c = 0; c < changingEntriesLength; c++) {
  46821. k = changingTemplateEntries[c];
  46822. changingTemplateX[c] = template[k].x;
  46823. changingTemplateY[c] = template[k].y;
  46824. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  46825. }
  46826. var sbb_left = -minX;
  46827. var sbb_top = -minY;
  46828. var sbb_right = width - maxX;
  46829. var pseudoPixelContext = ReusedContexts[templateIndex];
  46830. var row = new Uint8Array(width);
  46831. var bitmap = [];
  46832. var decoder = decodingContext.decoder;
  46833. var contexts = decodingContext.contextCache.getContexts('GB');
  46834. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  46835. for (var i = 0; i < height; i++) {
  46836. if (prediction) {
  46837. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46838. ltp ^= sltp;
  46839. if (ltp) {
  46840. bitmap.push(row);
  46841. continue;
  46842. }
  46843. }
  46844. row = new Uint8Array(row);
  46845. bitmap.push(row);
  46846. for (j = 0; j < width; j++) {
  46847. if (useskip && skip[i][j]) {
  46848. row[j] = 0;
  46849. continue;
  46850. }
  46851. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  46852. contextLabel = contextLabel << 1 & reuseMask;
  46853. for (k = 0; k < changingEntriesLength; k++) {
  46854. i0 = i + changingTemplateY[k];
  46855. j0 = j + changingTemplateX[k];
  46856. bit = bitmap[i0][j0];
  46857. if (bit) {
  46858. bit = changingTemplateBit[k];
  46859. contextLabel |= bit;
  46860. }
  46861. }
  46862. } else {
  46863. contextLabel = 0;
  46864. shift = templateLength - 1;
  46865. for (k = 0; k < templateLength; k++, shift--) {
  46866. j0 = j + templateX[k];
  46867. if (j0 >= 0 && j0 < width) {
  46868. i0 = i + templateY[k];
  46869. if (i0 >= 0) {
  46870. bit = bitmap[i0][j0];
  46871. if (bit) {
  46872. contextLabel |= bit << shift;
  46873. }
  46874. }
  46875. }
  46876. }
  46877. }
  46878. var pixel = decoder.readBit(contexts, contextLabel);
  46879. row[j] = pixel;
  46880. }
  46881. }
  46882. return bitmap;
  46883. }
  46884. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  46885. var codingTemplate = RefinementTemplates[templateIndex].coding;
  46886. if (templateIndex === 0) {
  46887. codingTemplate = codingTemplate.concat([at[0]]);
  46888. }
  46889. var codingTemplateLength = codingTemplate.length;
  46890. var codingTemplateX = new Int32Array(codingTemplateLength);
  46891. var codingTemplateY = new Int32Array(codingTemplateLength);
  46892. var k;
  46893. for (k = 0; k < codingTemplateLength; k++) {
  46894. codingTemplateX[k] = codingTemplate[k].x;
  46895. codingTemplateY[k] = codingTemplate[k].y;
  46896. }
  46897. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  46898. if (templateIndex === 0) {
  46899. referenceTemplate = referenceTemplate.concat([at[1]]);
  46900. }
  46901. var referenceTemplateLength = referenceTemplate.length;
  46902. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  46903. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  46904. for (k = 0; k < referenceTemplateLength; k++) {
  46905. referenceTemplateX[k] = referenceTemplate[k].x;
  46906. referenceTemplateY[k] = referenceTemplate[k].y;
  46907. }
  46908. var referenceWidth = referenceBitmap[0].length;
  46909. var referenceHeight = referenceBitmap.length;
  46910. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  46911. var bitmap = [];
  46912. var decoder = decodingContext.decoder;
  46913. var contexts = decodingContext.contextCache.getContexts('GR');
  46914. var ltp = 0;
  46915. for (var i = 0; i < height; i++) {
  46916. if (prediction) {
  46917. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46918. ltp ^= sltp;
  46919. if (ltp) {
  46920. error('JBIG2 error: prediction is not supported');
  46921. }
  46922. }
  46923. var row = new Uint8Array(width);
  46924. bitmap.push(row);
  46925. for (var j = 0; j < width; j++) {
  46926. var i0, j0;
  46927. var contextLabel = 0;
  46928. for (k = 0; k < codingTemplateLength; k++) {
  46929. i0 = i + codingTemplateY[k];
  46930. j0 = j + codingTemplateX[k];
  46931. if (i0 < 0 || j0 < 0 || j0 >= width) {
  46932. contextLabel <<= 1;
  46933. } else {
  46934. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  46935. }
  46936. }
  46937. for (k = 0; k < referenceTemplateLength; k++) {
  46938. i0 = i + referenceTemplateY[k] + offsetY;
  46939. j0 = j + referenceTemplateX[k] + offsetX;
  46940. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  46941. contextLabel <<= 1;
  46942. } else {
  46943. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  46944. }
  46945. }
  46946. var pixel = decoder.readBit(contexts, contextLabel);
  46947. row[j] = pixel;
  46948. }
  46949. }
  46950. return bitmap;
  46951. }
  46952. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  46953. if (huffman) {
  46954. error('JBIG2 error: huffman is not supported');
  46955. }
  46956. var newSymbols = [];
  46957. var currentHeight = 0;
  46958. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  46959. var decoder = decodingContext.decoder;
  46960. var contextCache = decodingContext.contextCache;
  46961. while (newSymbols.length < numberOfNewSymbols) {
  46962. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  46963. currentHeight += deltaHeight;
  46964. var currentWidth = 0;
  46965. while (true) {
  46966. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  46967. if (deltaWidth === null) {
  46968. break;
  46969. }
  46970. currentWidth += deltaWidth;
  46971. var bitmap;
  46972. if (refinement) {
  46973. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  46974. if (numberOfInstances > 1) {
  46975. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  46976. } else {
  46977. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  46978. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  46979. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  46980. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  46981. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  46982. }
  46983. } else {
  46984. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  46985. }
  46986. newSymbols.push(bitmap);
  46987. }
  46988. }
  46989. var exportedSymbols = [];
  46990. var flags = [], currentFlag = false;
  46991. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  46992. while (flags.length < totalSymbolsLength) {
  46993. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  46994. while (runLength--) {
  46995. flags.push(currentFlag);
  46996. }
  46997. currentFlag = !currentFlag;
  46998. }
  46999. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47000. if (flags[i]) {
  47001. exportedSymbols.push(symbols[i]);
  47002. }
  47003. }
  47004. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47005. if (flags[i]) {
  47006. exportedSymbols.push(newSymbols[j]);
  47007. }
  47008. }
  47009. return exportedSymbols;
  47010. }
  47011. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47012. if (huffman) {
  47013. error('JBIG2 error: huffman is not supported');
  47014. }
  47015. var bitmap = [];
  47016. var i, row;
  47017. for (i = 0; i < height; i++) {
  47018. row = new Uint8Array(width);
  47019. if (defaultPixelValue) {
  47020. for (var j = 0; j < width; j++) {
  47021. row[j] = defaultPixelValue;
  47022. }
  47023. }
  47024. bitmap.push(row);
  47025. }
  47026. var decoder = decodingContext.decoder;
  47027. var contextCache = decodingContext.contextCache;
  47028. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47029. var firstS = 0;
  47030. i = 0;
  47031. while (i < numberOfSymbolInstances) {
  47032. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47033. stripT += deltaT;
  47034. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47035. firstS += deltaFirstS;
  47036. var currentS = firstS;
  47037. do {
  47038. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47039. var t = stripSize * stripT + currentT;
  47040. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47041. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47042. var symbolBitmap = inputSymbols[symbolId];
  47043. var symbolWidth = symbolBitmap[0].length;
  47044. var symbolHeight = symbolBitmap.length;
  47045. if (applyRefinement) {
  47046. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47047. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47048. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47049. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47050. symbolWidth += rdw;
  47051. symbolHeight += rdh;
  47052. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47053. }
  47054. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47055. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47056. var s2, t2, symbolRow;
  47057. if (transposed) {
  47058. for (s2 = 0; s2 < symbolHeight; s2++) {
  47059. row = bitmap[offsetS + s2];
  47060. if (!row) {
  47061. continue;
  47062. }
  47063. symbolRow = symbolBitmap[s2];
  47064. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47065. switch (combinationOperator) {
  47066. case 0:
  47067. for (t2 = 0; t2 < maxWidth; t2++) {
  47068. row[offsetT + t2] |= symbolRow[t2];
  47069. }
  47070. break;
  47071. case 2:
  47072. for (t2 = 0; t2 < maxWidth; t2++) {
  47073. row[offsetT + t2] ^= symbolRow[t2];
  47074. }
  47075. break;
  47076. default:
  47077. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47078. }
  47079. }
  47080. currentS += symbolHeight - 1;
  47081. } else {
  47082. for (t2 = 0; t2 < symbolHeight; t2++) {
  47083. row = bitmap[offsetT + t2];
  47084. if (!row) {
  47085. continue;
  47086. }
  47087. symbolRow = symbolBitmap[t2];
  47088. switch (combinationOperator) {
  47089. case 0:
  47090. for (s2 = 0; s2 < symbolWidth; s2++) {
  47091. row[offsetS + s2] |= symbolRow[s2];
  47092. }
  47093. break;
  47094. case 2:
  47095. for (s2 = 0; s2 < symbolWidth; s2++) {
  47096. row[offsetS + s2] ^= symbolRow[s2];
  47097. }
  47098. break;
  47099. default:
  47100. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47101. }
  47102. }
  47103. currentS += symbolWidth - 1;
  47104. }
  47105. i++;
  47106. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47107. if (deltaS === null) {
  47108. break;
  47109. }
  47110. currentS += deltaS + dsOffset;
  47111. } while (true);
  47112. }
  47113. return bitmap;
  47114. }
  47115. function readSegmentHeader(data, start) {
  47116. var segmentHeader = {};
  47117. segmentHeader.number = readUint32(data, start);
  47118. var flags = data[start + 4];
  47119. var segmentType = flags & 0x3F;
  47120. if (!SegmentTypes[segmentType]) {
  47121. error('JBIG2 error: invalid segment type: ' + segmentType);
  47122. }
  47123. segmentHeader.type = segmentType;
  47124. segmentHeader.typeName = SegmentTypes[segmentType];
  47125. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47126. var pageAssociationFieldSize = !!(flags & 0x40);
  47127. var referredFlags = data[start + 5];
  47128. var referredToCount = referredFlags >> 5 & 7;
  47129. var retainBits = [referredFlags & 31];
  47130. var position = start + 6;
  47131. if (referredFlags === 7) {
  47132. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47133. position += 3;
  47134. var bytes = referredToCount + 7 >> 3;
  47135. retainBits[0] = data[position++];
  47136. while (--bytes > 0) {
  47137. retainBits.push(data[position++]);
  47138. }
  47139. } else if (referredFlags === 5 || referredFlags === 6) {
  47140. error('JBIG2 error: invalid referred-to flags');
  47141. }
  47142. segmentHeader.retainBits = retainBits;
  47143. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47144. var referredTo = [];
  47145. var i, ii;
  47146. for (i = 0; i < referredToCount; i++) {
  47147. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47148. referredTo.push(number);
  47149. position += referredToSegmentNumberSize;
  47150. }
  47151. segmentHeader.referredTo = referredTo;
  47152. if (!pageAssociationFieldSize) {
  47153. segmentHeader.pageAssociation = data[position++];
  47154. } else {
  47155. segmentHeader.pageAssociation = readUint32(data, position);
  47156. position += 4;
  47157. }
  47158. segmentHeader.length = readUint32(data, position);
  47159. position += 4;
  47160. if (segmentHeader.length === 0xFFFFFFFF) {
  47161. if (segmentType === 38) {
  47162. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47163. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47164. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47165. var searchPatternLength = 6;
  47166. var searchPattern = new Uint8Array(searchPatternLength);
  47167. if (!genericRegionMmr) {
  47168. searchPattern[0] = 0xFF;
  47169. searchPattern[1] = 0xAC;
  47170. }
  47171. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47172. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47173. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47174. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47175. for (i = position, ii = data.length; i < ii; i++) {
  47176. var j = 0;
  47177. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47178. j++;
  47179. }
  47180. if (j === searchPatternLength) {
  47181. segmentHeader.length = i + searchPatternLength;
  47182. break;
  47183. }
  47184. }
  47185. if (segmentHeader.length === 0xFFFFFFFF) {
  47186. error('JBIG2 error: segment end was not found');
  47187. }
  47188. } else {
  47189. error('JBIG2 error: invalid unknown segment length');
  47190. }
  47191. }
  47192. segmentHeader.headerEnd = position;
  47193. return segmentHeader;
  47194. }
  47195. function readSegments(header, data, start, end) {
  47196. var segments = [];
  47197. var position = start;
  47198. while (position < end) {
  47199. var segmentHeader = readSegmentHeader(data, position);
  47200. position = segmentHeader.headerEnd;
  47201. var segment = {
  47202. header: segmentHeader,
  47203. data: data
  47204. };
  47205. if (!header.randomAccess) {
  47206. segment.start = position;
  47207. position += segmentHeader.length;
  47208. segment.end = position;
  47209. }
  47210. segments.push(segment);
  47211. if (segmentHeader.type === 51) {
  47212. break;
  47213. }
  47214. }
  47215. if (header.randomAccess) {
  47216. for (var i = 0, ii = segments.length; i < ii; i++) {
  47217. segments[i].start = position;
  47218. position += segments[i].header.length;
  47219. segments[i].end = position;
  47220. }
  47221. }
  47222. return segments;
  47223. }
  47224. function readRegionSegmentInformation(data, start) {
  47225. return {
  47226. width: readUint32(data, start),
  47227. height: readUint32(data, start + 4),
  47228. x: readUint32(data, start + 8),
  47229. y: readUint32(data, start + 12),
  47230. combinationOperator: data[start + 16] & 7
  47231. };
  47232. }
  47233. var RegionSegmentInformationFieldLength = 17;
  47234. function processSegment(segment, visitor) {
  47235. var header = segment.header;
  47236. var data = segment.data, position = segment.start, end = segment.end;
  47237. var args, at, i, atLength;
  47238. switch (header.type) {
  47239. case 0:
  47240. var dictionary = {};
  47241. var dictionaryFlags = readUint16(data, position);
  47242. dictionary.huffman = !!(dictionaryFlags & 1);
  47243. dictionary.refinement = !!(dictionaryFlags & 2);
  47244. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  47245. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  47246. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  47247. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  47248. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  47249. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  47250. dictionary.template = dictionaryFlags >> 10 & 3;
  47251. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  47252. position += 2;
  47253. if (!dictionary.huffman) {
  47254. atLength = dictionary.template === 0 ? 4 : 1;
  47255. at = [];
  47256. for (i = 0; i < atLength; i++) {
  47257. at.push({
  47258. x: readInt8(data, position),
  47259. y: readInt8(data, position + 1)
  47260. });
  47261. position += 2;
  47262. }
  47263. dictionary.at = at;
  47264. }
  47265. if (dictionary.refinement && !dictionary.refinementTemplate) {
  47266. at = [];
  47267. for (i = 0; i < 2; i++) {
  47268. at.push({
  47269. x: readInt8(data, position),
  47270. y: readInt8(data, position + 1)
  47271. });
  47272. position += 2;
  47273. }
  47274. dictionary.refinementAt = at;
  47275. }
  47276. dictionary.numberOfExportedSymbols = readUint32(data, position);
  47277. position += 4;
  47278. dictionary.numberOfNewSymbols = readUint32(data, position);
  47279. position += 4;
  47280. args = [
  47281. dictionary,
  47282. header.number,
  47283. header.referredTo,
  47284. data,
  47285. position,
  47286. end
  47287. ];
  47288. break;
  47289. case 6:
  47290. case 7:
  47291. var textRegion = {};
  47292. textRegion.info = readRegionSegmentInformation(data, position);
  47293. position += RegionSegmentInformationFieldLength;
  47294. var textRegionSegmentFlags = readUint16(data, position);
  47295. position += 2;
  47296. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  47297. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  47298. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  47299. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  47300. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  47301. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  47302. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  47303. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  47304. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  47305. if (textRegion.huffman) {
  47306. var textRegionHuffmanFlags = readUint16(data, position);
  47307. position += 2;
  47308. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  47309. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  47310. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  47311. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  47312. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  47313. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  47314. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  47315. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  47316. }
  47317. if (textRegion.refinement && !textRegion.refinementTemplate) {
  47318. at = [];
  47319. for (i = 0; i < 2; i++) {
  47320. at.push({
  47321. x: readInt8(data, position),
  47322. y: readInt8(data, position + 1)
  47323. });
  47324. position += 2;
  47325. }
  47326. textRegion.refinementAt = at;
  47327. }
  47328. textRegion.numberOfSymbolInstances = readUint32(data, position);
  47329. position += 4;
  47330. if (textRegion.huffman) {
  47331. error('JBIG2 error: huffman is not supported');
  47332. }
  47333. args = [
  47334. textRegion,
  47335. header.referredTo,
  47336. data,
  47337. position,
  47338. end
  47339. ];
  47340. break;
  47341. case 38:
  47342. case 39:
  47343. var genericRegion = {};
  47344. genericRegion.info = readRegionSegmentInformation(data, position);
  47345. position += RegionSegmentInformationFieldLength;
  47346. var genericRegionSegmentFlags = data[position++];
  47347. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  47348. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  47349. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  47350. if (!genericRegion.mmr) {
  47351. atLength = genericRegion.template === 0 ? 4 : 1;
  47352. at = [];
  47353. for (i = 0; i < atLength; i++) {
  47354. at.push({
  47355. x: readInt8(data, position),
  47356. y: readInt8(data, position + 1)
  47357. });
  47358. position += 2;
  47359. }
  47360. genericRegion.at = at;
  47361. }
  47362. args = [
  47363. genericRegion,
  47364. data,
  47365. position,
  47366. end
  47367. ];
  47368. break;
  47369. case 48:
  47370. var pageInfo = {
  47371. width: readUint32(data, position),
  47372. height: readUint32(data, position + 4),
  47373. resolutionX: readUint32(data, position + 8),
  47374. resolutionY: readUint32(data, position + 12)
  47375. };
  47376. if (pageInfo.height === 0xFFFFFFFF) {
  47377. delete pageInfo.height;
  47378. }
  47379. var pageSegmentFlags = data[position + 16];
  47380. readUint16(data, position + 17);
  47381. pageInfo.lossless = !!(pageSegmentFlags & 1);
  47382. pageInfo.refinement = !!(pageSegmentFlags & 2);
  47383. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  47384. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  47385. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  47386. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  47387. args = [pageInfo];
  47388. break;
  47389. case 49:
  47390. break;
  47391. case 50:
  47392. break;
  47393. case 51:
  47394. break;
  47395. case 62:
  47396. break;
  47397. default:
  47398. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  47399. }
  47400. var callbackName = 'on' + header.typeName;
  47401. if (callbackName in visitor) {
  47402. visitor[callbackName].apply(visitor, args);
  47403. }
  47404. }
  47405. function processSegments(segments, visitor) {
  47406. for (var i = 0, ii = segments.length; i < ii; i++) {
  47407. processSegment(segments[i], visitor);
  47408. }
  47409. }
  47410. function parseJbig2(data, start, end) {
  47411. var position = start;
  47412. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  47413. error('JBIG2 error: invalid header');
  47414. }
  47415. var header = {};
  47416. position += 8;
  47417. var flags = data[position++];
  47418. header.randomAccess = !(flags & 1);
  47419. if (!(flags & 2)) {
  47420. header.numberOfPages = readUint32(data, position);
  47421. position += 4;
  47422. }
  47423. readSegments(header, data, position, end);
  47424. error('Not implemented');
  47425. }
  47426. function parseJbig2Chunks(chunks) {
  47427. var visitor = new SimpleSegmentVisitor();
  47428. for (var i = 0, ii = chunks.length; i < ii; i++) {
  47429. var chunk = chunks[i];
  47430. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  47431. processSegments(segments, visitor);
  47432. }
  47433. return visitor.buffer;
  47434. }
  47435. function SimpleSegmentVisitor() {
  47436. }
  47437. SimpleSegmentVisitor.prototype = {
  47438. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  47439. this.currentPageInfo = info;
  47440. var rowSize = info.width + 7 >> 3;
  47441. var buffer = new Uint8Array(rowSize * info.height);
  47442. if (info.defaultPixelValue) {
  47443. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47444. buffer[i] = 0xFF;
  47445. }
  47446. }
  47447. this.buffer = buffer;
  47448. },
  47449. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  47450. var pageInfo = this.currentPageInfo;
  47451. var width = regionInfo.width, height = regionInfo.height;
  47452. var rowSize = pageInfo.width + 7 >> 3;
  47453. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  47454. var buffer = this.buffer;
  47455. var mask0 = 128 >> (regionInfo.x & 7);
  47456. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  47457. var i, j, mask, offset;
  47458. switch (combinationOperator) {
  47459. case 0:
  47460. for (i = 0; i < height; i++) {
  47461. mask = mask0;
  47462. offset = offset0;
  47463. for (j = 0; j < width; j++) {
  47464. if (bitmap[i][j]) {
  47465. buffer[offset] |= mask;
  47466. }
  47467. mask >>= 1;
  47468. if (!mask) {
  47469. mask = 128;
  47470. offset++;
  47471. }
  47472. }
  47473. offset0 += rowSize;
  47474. }
  47475. break;
  47476. case 2:
  47477. for (i = 0; i < height; i++) {
  47478. mask = mask0;
  47479. offset = offset0;
  47480. for (j = 0; j < width; j++) {
  47481. if (bitmap[i][j]) {
  47482. buffer[offset] ^= mask;
  47483. }
  47484. mask >>= 1;
  47485. if (!mask) {
  47486. mask = 128;
  47487. offset++;
  47488. }
  47489. }
  47490. offset0 += rowSize;
  47491. }
  47492. break;
  47493. default:
  47494. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47495. }
  47496. },
  47497. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  47498. var regionInfo = region.info;
  47499. var decodingContext = new DecodingContext(data, start, end);
  47500. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  47501. this.drawBitmap(regionInfo, bitmap);
  47502. },
  47503. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  47504. this.onImmediateGenericRegion.apply(this, arguments);
  47505. },
  47506. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  47507. var huffmanTables;
  47508. if (dictionary.huffman) {
  47509. error('JBIG2 error: huffman is not supported');
  47510. }
  47511. var symbols = this.symbols;
  47512. if (!symbols) {
  47513. this.symbols = symbols = {};
  47514. }
  47515. var inputSymbols = [];
  47516. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47517. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47518. }
  47519. var decodingContext = new DecodingContext(data, start, end);
  47520. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  47521. },
  47522. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  47523. var regionInfo = region.info;
  47524. var huffmanTables;
  47525. var symbols = this.symbols;
  47526. var inputSymbols = [];
  47527. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47528. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47529. }
  47530. var symbolCodeLength = log2(inputSymbols.length);
  47531. var decodingContext = new DecodingContext(data, start, end);
  47532. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext);
  47533. this.drawBitmap(regionInfo, bitmap);
  47534. },
  47535. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  47536. this.onImmediateTextRegion.apply(this, arguments);
  47537. }
  47538. };
  47539. function Jbig2Image() {
  47540. }
  47541. Jbig2Image.prototype = {
  47542. parseChunks: function Jbig2Image_parseChunks(chunks) {
  47543. return parseJbig2Chunks(chunks);
  47544. }
  47545. };
  47546. return Jbig2Image;
  47547. }();
  47548. exports.Jbig2Image = Jbig2Image;
  47549. /***/ }),
  47550. /* 36 */
  47551. /***/ (function(module, exports, __w_pdfjs_require__) {
  47552. "use strict";
  47553. var sharedUtil = __w_pdfjs_require__(0);
  47554. var error = sharedUtil.error;
  47555. var JpegImage = function JpegImageClosure() {
  47556. var dctZigZag = new Uint8Array([
  47557. 0,
  47558. 1,
  47559. 8,
  47560. 16,
  47561. 9,
  47562. 2,
  47563. 3,
  47564. 10,
  47565. 17,
  47566. 24,
  47567. 32,
  47568. 25,
  47569. 18,
  47570. 11,
  47571. 4,
  47572. 5,
  47573. 12,
  47574. 19,
  47575. 26,
  47576. 33,
  47577. 40,
  47578. 48,
  47579. 41,
  47580. 34,
  47581. 27,
  47582. 20,
  47583. 13,
  47584. 6,
  47585. 7,
  47586. 14,
  47587. 21,
  47588. 28,
  47589. 35,
  47590. 42,
  47591. 49,
  47592. 56,
  47593. 57,
  47594. 50,
  47595. 43,
  47596. 36,
  47597. 29,
  47598. 22,
  47599. 15,
  47600. 23,
  47601. 30,
  47602. 37,
  47603. 44,
  47604. 51,
  47605. 58,
  47606. 59,
  47607. 52,
  47608. 45,
  47609. 38,
  47610. 31,
  47611. 39,
  47612. 46,
  47613. 53,
  47614. 60,
  47615. 61,
  47616. 54,
  47617. 47,
  47618. 55,
  47619. 62,
  47620. 63
  47621. ]);
  47622. var dctCos1 = 4017;
  47623. var dctSin1 = 799;
  47624. var dctCos3 = 3406;
  47625. var dctSin3 = 2276;
  47626. var dctCos6 = 1567;
  47627. var dctSin6 = 3784;
  47628. var dctSqrt2 = 5793;
  47629. var dctSqrt1d2 = 2896;
  47630. function JpegImage() {
  47631. this.decodeTransform = null;
  47632. this.colorTransform = -1;
  47633. }
  47634. function buildHuffmanTable(codeLengths, values) {
  47635. var k = 0, code = [], i, j, length = 16;
  47636. while (length > 0 && !codeLengths[length - 1]) {
  47637. length--;
  47638. }
  47639. code.push({
  47640. children: [],
  47641. index: 0
  47642. });
  47643. var p = code[0], q;
  47644. for (i = 0; i < length; i++) {
  47645. for (j = 0; j < codeLengths[i]; j++) {
  47646. p = code.pop();
  47647. p.children[p.index] = values[k];
  47648. while (p.index > 0) {
  47649. p = code.pop();
  47650. }
  47651. p.index++;
  47652. code.push(p);
  47653. while (code.length <= i) {
  47654. code.push(q = {
  47655. children: [],
  47656. index: 0
  47657. });
  47658. p.children[p.index] = q.children;
  47659. p = q;
  47660. }
  47661. k++;
  47662. }
  47663. if (i + 1 < length) {
  47664. code.push(q = {
  47665. children: [],
  47666. index: 0
  47667. });
  47668. p.children[p.index] = q.children;
  47669. p = q;
  47670. }
  47671. }
  47672. return code[0].children;
  47673. }
  47674. function getBlockBufferOffset(component, row, col) {
  47675. return 64 * ((component.blocksPerLine + 1) * row + col);
  47676. }
  47677. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  47678. var mcusPerLine = frame.mcusPerLine;
  47679. var progressive = frame.progressive;
  47680. var startOffset = offset, bitsData = 0, bitsCount = 0;
  47681. function readBit() {
  47682. if (bitsCount > 0) {
  47683. bitsCount--;
  47684. return bitsData >> bitsCount & 1;
  47685. }
  47686. bitsData = data[offset++];
  47687. if (bitsData === 0xFF) {
  47688. var nextByte = data[offset++];
  47689. if (nextByte) {
  47690. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  47691. }
  47692. }
  47693. bitsCount = 7;
  47694. return bitsData >>> 7;
  47695. }
  47696. function decodeHuffman(tree) {
  47697. var node = tree;
  47698. while (true) {
  47699. node = node[readBit()];
  47700. if (typeof node === 'number') {
  47701. return node;
  47702. }
  47703. if (typeof node !== 'object') {
  47704. error('JPEG error: invalid huffman sequence');
  47705. }
  47706. }
  47707. }
  47708. function receive(length) {
  47709. var n = 0;
  47710. while (length > 0) {
  47711. n = n << 1 | readBit();
  47712. length--;
  47713. }
  47714. return n;
  47715. }
  47716. function receiveAndExtend(length) {
  47717. if (length === 1) {
  47718. return readBit() === 1 ? 1 : -1;
  47719. }
  47720. var n = receive(length);
  47721. if (n >= 1 << length - 1) {
  47722. return n;
  47723. }
  47724. return n + (-1 << length) + 1;
  47725. }
  47726. function decodeBaseline(component, offset) {
  47727. var t = decodeHuffman(component.huffmanTableDC);
  47728. var diff = t === 0 ? 0 : receiveAndExtend(t);
  47729. component.blockData[offset] = component.pred += diff;
  47730. var k = 1;
  47731. while (k < 64) {
  47732. var rs = decodeHuffman(component.huffmanTableAC);
  47733. var s = rs & 15, r = rs >> 4;
  47734. if (s === 0) {
  47735. if (r < 15) {
  47736. break;
  47737. }
  47738. k += 16;
  47739. continue;
  47740. }
  47741. k += r;
  47742. var z = dctZigZag[k];
  47743. component.blockData[offset + z] = receiveAndExtend(s);
  47744. k++;
  47745. }
  47746. }
  47747. function decodeDCFirst(component, offset) {
  47748. var t = decodeHuffman(component.huffmanTableDC);
  47749. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  47750. component.blockData[offset] = component.pred += diff;
  47751. }
  47752. function decodeDCSuccessive(component, offset) {
  47753. component.blockData[offset] |= readBit() << successive;
  47754. }
  47755. var eobrun = 0;
  47756. function decodeACFirst(component, offset) {
  47757. if (eobrun > 0) {
  47758. eobrun--;
  47759. return;
  47760. }
  47761. var k = spectralStart, e = spectralEnd;
  47762. while (k <= e) {
  47763. var rs = decodeHuffman(component.huffmanTableAC);
  47764. var s = rs & 15, r = rs >> 4;
  47765. if (s === 0) {
  47766. if (r < 15) {
  47767. eobrun = receive(r) + (1 << r) - 1;
  47768. break;
  47769. }
  47770. k += 16;
  47771. continue;
  47772. }
  47773. k += r;
  47774. var z = dctZigZag[k];
  47775. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  47776. k++;
  47777. }
  47778. }
  47779. var successiveACState = 0, successiveACNextValue;
  47780. function decodeACSuccessive(component, offset) {
  47781. var k = spectralStart;
  47782. var e = spectralEnd;
  47783. var r = 0;
  47784. var s;
  47785. var rs;
  47786. while (k <= e) {
  47787. var z = dctZigZag[k];
  47788. switch (successiveACState) {
  47789. case 0:
  47790. rs = decodeHuffman(component.huffmanTableAC);
  47791. s = rs & 15;
  47792. r = rs >> 4;
  47793. if (s === 0) {
  47794. if (r < 15) {
  47795. eobrun = receive(r) + (1 << r);
  47796. successiveACState = 4;
  47797. } else {
  47798. r = 16;
  47799. successiveACState = 1;
  47800. }
  47801. } else {
  47802. if (s !== 1) {
  47803. error('JPEG error: invalid ACn encoding');
  47804. }
  47805. successiveACNextValue = receiveAndExtend(s);
  47806. successiveACState = r ? 2 : 3;
  47807. }
  47808. continue;
  47809. case 1:
  47810. case 2:
  47811. if (component.blockData[offset + z]) {
  47812. component.blockData[offset + z] += readBit() << successive;
  47813. } else {
  47814. r--;
  47815. if (r === 0) {
  47816. successiveACState = successiveACState === 2 ? 3 : 0;
  47817. }
  47818. }
  47819. break;
  47820. case 3:
  47821. if (component.blockData[offset + z]) {
  47822. component.blockData[offset + z] += readBit() << successive;
  47823. } else {
  47824. component.blockData[offset + z] = successiveACNextValue << successive;
  47825. successiveACState = 0;
  47826. }
  47827. break;
  47828. case 4:
  47829. if (component.blockData[offset + z]) {
  47830. component.blockData[offset + z] += readBit() << successive;
  47831. }
  47832. break;
  47833. }
  47834. k++;
  47835. }
  47836. if (successiveACState === 4) {
  47837. eobrun--;
  47838. if (eobrun === 0) {
  47839. successiveACState = 0;
  47840. }
  47841. }
  47842. }
  47843. function decodeMcu(component, decode, mcu, row, col) {
  47844. var mcuRow = mcu / mcusPerLine | 0;
  47845. var mcuCol = mcu % mcusPerLine;
  47846. var blockRow = mcuRow * component.v + row;
  47847. var blockCol = mcuCol * component.h + col;
  47848. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47849. decode(component, offset);
  47850. }
  47851. function decodeBlock(component, decode, mcu) {
  47852. var blockRow = mcu / component.blocksPerLine | 0;
  47853. var blockCol = mcu % component.blocksPerLine;
  47854. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47855. decode(component, offset);
  47856. }
  47857. var componentsLength = components.length;
  47858. var component, i, j, k, n;
  47859. var decodeFn;
  47860. if (progressive) {
  47861. if (spectralStart === 0) {
  47862. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  47863. } else {
  47864. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  47865. }
  47866. } else {
  47867. decodeFn = decodeBaseline;
  47868. }
  47869. var mcu = 0, marker;
  47870. var mcuExpected;
  47871. if (componentsLength === 1) {
  47872. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  47873. } else {
  47874. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  47875. }
  47876. if (!resetInterval) {
  47877. resetInterval = mcuExpected;
  47878. }
  47879. var h, v;
  47880. while (mcu < mcuExpected) {
  47881. for (i = 0; i < componentsLength; i++) {
  47882. components[i].pred = 0;
  47883. }
  47884. eobrun = 0;
  47885. if (componentsLength === 1) {
  47886. component = components[0];
  47887. for (n = 0; n < resetInterval; n++) {
  47888. decodeBlock(component, decodeFn, mcu);
  47889. mcu++;
  47890. }
  47891. } else {
  47892. for (n = 0; n < resetInterval; n++) {
  47893. for (i = 0; i < componentsLength; i++) {
  47894. component = components[i];
  47895. h = component.h;
  47896. v = component.v;
  47897. for (j = 0; j < v; j++) {
  47898. for (k = 0; k < h; k++) {
  47899. decodeMcu(component, decodeFn, mcu, j, k);
  47900. }
  47901. }
  47902. }
  47903. mcu++;
  47904. }
  47905. }
  47906. bitsCount = 0;
  47907. marker = data[offset] << 8 | data[offset + 1];
  47908. while (data[offset] === 0x00 && offset < data.length - 1) {
  47909. offset++;
  47910. marker = data[offset] << 8 | data[offset + 1];
  47911. }
  47912. if (marker <= 0xFF00) {
  47913. error('JPEG error: marker was not found');
  47914. }
  47915. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  47916. offset += 2;
  47917. } else {
  47918. break;
  47919. }
  47920. }
  47921. return offset - startOffset;
  47922. }
  47923. function quantizeAndInverse(component, blockBufferOffset, p) {
  47924. var qt = component.quantizationTable, blockData = component.blockData;
  47925. var v0, v1, v2, v3, v4, v5, v6, v7;
  47926. var p0, p1, p2, p3, p4, p5, p6, p7;
  47927. var t;
  47928. if (!qt) {
  47929. error('JPEG error: missing required Quantization Table.');
  47930. }
  47931. for (var row = 0; row < 64; row += 8) {
  47932. p0 = blockData[blockBufferOffset + row];
  47933. p1 = blockData[blockBufferOffset + row + 1];
  47934. p2 = blockData[blockBufferOffset + row + 2];
  47935. p3 = blockData[blockBufferOffset + row + 3];
  47936. p4 = blockData[blockBufferOffset + row + 4];
  47937. p5 = blockData[blockBufferOffset + row + 5];
  47938. p6 = blockData[blockBufferOffset + row + 6];
  47939. p7 = blockData[blockBufferOffset + row + 7];
  47940. p0 *= qt[row];
  47941. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47942. t = dctSqrt2 * p0 + 512 >> 10;
  47943. p[row] = t;
  47944. p[row + 1] = t;
  47945. p[row + 2] = t;
  47946. p[row + 3] = t;
  47947. p[row + 4] = t;
  47948. p[row + 5] = t;
  47949. p[row + 6] = t;
  47950. p[row + 7] = t;
  47951. continue;
  47952. }
  47953. p1 *= qt[row + 1];
  47954. p2 *= qt[row + 2];
  47955. p3 *= qt[row + 3];
  47956. p4 *= qt[row + 4];
  47957. p5 *= qt[row + 5];
  47958. p6 *= qt[row + 6];
  47959. p7 *= qt[row + 7];
  47960. v0 = dctSqrt2 * p0 + 128 >> 8;
  47961. v1 = dctSqrt2 * p4 + 128 >> 8;
  47962. v2 = p2;
  47963. v3 = p6;
  47964. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  47965. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  47966. v5 = p3 << 4;
  47967. v6 = p5 << 4;
  47968. v0 = v0 + v1 + 1 >> 1;
  47969. v1 = v0 - v1;
  47970. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  47971. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  47972. v3 = t;
  47973. v4 = v4 + v6 + 1 >> 1;
  47974. v6 = v4 - v6;
  47975. v7 = v7 + v5 + 1 >> 1;
  47976. v5 = v7 - v5;
  47977. v0 = v0 + v3 + 1 >> 1;
  47978. v3 = v0 - v3;
  47979. v1 = v1 + v2 + 1 >> 1;
  47980. v2 = v1 - v2;
  47981. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  47982. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  47983. v7 = t;
  47984. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  47985. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  47986. v6 = t;
  47987. p[row] = v0 + v7;
  47988. p[row + 7] = v0 - v7;
  47989. p[row + 1] = v1 + v6;
  47990. p[row + 6] = v1 - v6;
  47991. p[row + 2] = v2 + v5;
  47992. p[row + 5] = v2 - v5;
  47993. p[row + 3] = v3 + v4;
  47994. p[row + 4] = v3 - v4;
  47995. }
  47996. for (var col = 0; col < 8; ++col) {
  47997. p0 = p[col];
  47998. p1 = p[col + 8];
  47999. p2 = p[col + 16];
  48000. p3 = p[col + 24];
  48001. p4 = p[col + 32];
  48002. p5 = p[col + 40];
  48003. p6 = p[col + 48];
  48004. p7 = p[col + 56];
  48005. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48006. t = dctSqrt2 * p0 + 8192 >> 14;
  48007. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48008. blockData[blockBufferOffset + col] = t;
  48009. blockData[blockBufferOffset + col + 8] = t;
  48010. blockData[blockBufferOffset + col + 16] = t;
  48011. blockData[blockBufferOffset + col + 24] = t;
  48012. blockData[blockBufferOffset + col + 32] = t;
  48013. blockData[blockBufferOffset + col + 40] = t;
  48014. blockData[blockBufferOffset + col + 48] = t;
  48015. blockData[blockBufferOffset + col + 56] = t;
  48016. continue;
  48017. }
  48018. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48019. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48020. v2 = p2;
  48021. v3 = p6;
  48022. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48023. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48024. v5 = p3;
  48025. v6 = p5;
  48026. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48027. v1 = v0 - v1;
  48028. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48029. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48030. v3 = t;
  48031. v4 = v4 + v6 + 1 >> 1;
  48032. v6 = v4 - v6;
  48033. v7 = v7 + v5 + 1 >> 1;
  48034. v5 = v7 - v5;
  48035. v0 = v0 + v3 + 1 >> 1;
  48036. v3 = v0 - v3;
  48037. v1 = v1 + v2 + 1 >> 1;
  48038. v2 = v1 - v2;
  48039. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48040. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48041. v7 = t;
  48042. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48043. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48044. v6 = t;
  48045. p0 = v0 + v7;
  48046. p7 = v0 - v7;
  48047. p1 = v1 + v6;
  48048. p6 = v1 - v6;
  48049. p2 = v2 + v5;
  48050. p5 = v2 - v5;
  48051. p3 = v3 + v4;
  48052. p4 = v3 - v4;
  48053. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48054. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48055. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48056. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48057. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48058. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48059. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48060. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48061. blockData[blockBufferOffset + col] = p0;
  48062. blockData[blockBufferOffset + col + 8] = p1;
  48063. blockData[blockBufferOffset + col + 16] = p2;
  48064. blockData[blockBufferOffset + col + 24] = p3;
  48065. blockData[blockBufferOffset + col + 32] = p4;
  48066. blockData[blockBufferOffset + col + 40] = p5;
  48067. blockData[blockBufferOffset + col + 48] = p6;
  48068. blockData[blockBufferOffset + col + 56] = p7;
  48069. }
  48070. }
  48071. function buildComponentData(frame, component) {
  48072. var blocksPerLine = component.blocksPerLine;
  48073. var blocksPerColumn = component.blocksPerColumn;
  48074. var computationBuffer = new Int16Array(64);
  48075. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48076. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48077. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48078. quantizeAndInverse(component, offset, computationBuffer);
  48079. }
  48080. }
  48081. return component.blockData;
  48082. }
  48083. function clamp0to255(a) {
  48084. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48085. }
  48086. JpegImage.prototype = {
  48087. parse: function parse(data) {
  48088. function readUint16() {
  48089. var value = data[offset] << 8 | data[offset + 1];
  48090. offset += 2;
  48091. return value;
  48092. }
  48093. function readDataBlock() {
  48094. var length = readUint16();
  48095. var array = data.subarray(offset, offset + length - 2);
  48096. offset += array.length;
  48097. return array;
  48098. }
  48099. function prepareComponents(frame) {
  48100. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48101. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48102. for (var i = 0; i < frame.components.length; i++) {
  48103. component = frame.components[i];
  48104. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48105. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48106. var blocksPerLineForMcu = mcusPerLine * component.h;
  48107. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48108. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48109. component.blockData = new Int16Array(blocksBufferSize);
  48110. component.blocksPerLine = blocksPerLine;
  48111. component.blocksPerColumn = blocksPerColumn;
  48112. }
  48113. frame.mcusPerLine = mcusPerLine;
  48114. frame.mcusPerColumn = mcusPerColumn;
  48115. }
  48116. var offset = 0;
  48117. var jfif = null;
  48118. var adobe = null;
  48119. var frame, resetInterval;
  48120. var quantizationTables = [];
  48121. var huffmanTablesAC = [], huffmanTablesDC = [];
  48122. var fileMarker = readUint16();
  48123. if (fileMarker !== 0xFFD8) {
  48124. error('JPEG error: SOI not found');
  48125. }
  48126. fileMarker = readUint16();
  48127. while (fileMarker !== 0xFFD9) {
  48128. var i, j, l;
  48129. switch (fileMarker) {
  48130. case 0xFFE0:
  48131. case 0xFFE1:
  48132. case 0xFFE2:
  48133. case 0xFFE3:
  48134. case 0xFFE4:
  48135. case 0xFFE5:
  48136. case 0xFFE6:
  48137. case 0xFFE7:
  48138. case 0xFFE8:
  48139. case 0xFFE9:
  48140. case 0xFFEA:
  48141. case 0xFFEB:
  48142. case 0xFFEC:
  48143. case 0xFFED:
  48144. case 0xFFEE:
  48145. case 0xFFEF:
  48146. case 0xFFFE:
  48147. var appData = readDataBlock();
  48148. if (fileMarker === 0xFFE0) {
  48149. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48150. jfif = {
  48151. version: {
  48152. major: appData[5],
  48153. minor: appData[6]
  48154. },
  48155. densityUnits: appData[7],
  48156. xDensity: appData[8] << 8 | appData[9],
  48157. yDensity: appData[10] << 8 | appData[11],
  48158. thumbWidth: appData[12],
  48159. thumbHeight: appData[13],
  48160. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48161. };
  48162. }
  48163. }
  48164. if (fileMarker === 0xFFEE) {
  48165. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48166. adobe = {
  48167. version: appData[5] << 8 | appData[6],
  48168. flags0: appData[7] << 8 | appData[8],
  48169. flags1: appData[9] << 8 | appData[10],
  48170. transformCode: appData[11]
  48171. };
  48172. }
  48173. }
  48174. break;
  48175. case 0xFFDB:
  48176. var quantizationTablesLength = readUint16();
  48177. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48178. var z;
  48179. while (offset < quantizationTablesEnd) {
  48180. var quantizationTableSpec = data[offset++];
  48181. var tableData = new Uint16Array(64);
  48182. if (quantizationTableSpec >> 4 === 0) {
  48183. for (j = 0; j < 64; j++) {
  48184. z = dctZigZag[j];
  48185. tableData[z] = data[offset++];
  48186. }
  48187. } else if (quantizationTableSpec >> 4 === 1) {
  48188. for (j = 0; j < 64; j++) {
  48189. z = dctZigZag[j];
  48190. tableData[z] = readUint16();
  48191. }
  48192. } else {
  48193. error('JPEG error: DQT - invalid table spec');
  48194. }
  48195. quantizationTables[quantizationTableSpec & 15] = tableData;
  48196. }
  48197. break;
  48198. case 0xFFC0:
  48199. case 0xFFC1:
  48200. case 0xFFC2:
  48201. if (frame) {
  48202. error('JPEG error: Only single frame JPEGs supported');
  48203. }
  48204. readUint16();
  48205. frame = {};
  48206. frame.extended = fileMarker === 0xFFC1;
  48207. frame.progressive = fileMarker === 0xFFC2;
  48208. frame.precision = data[offset++];
  48209. frame.scanLines = readUint16();
  48210. frame.samplesPerLine = readUint16();
  48211. frame.components = [];
  48212. frame.componentIds = {};
  48213. var componentsCount = data[offset++], componentId;
  48214. var maxH = 0, maxV = 0;
  48215. for (i = 0; i < componentsCount; i++) {
  48216. componentId = data[offset];
  48217. var h = data[offset + 1] >> 4;
  48218. var v = data[offset + 1] & 15;
  48219. if (maxH < h) {
  48220. maxH = h;
  48221. }
  48222. if (maxV < v) {
  48223. maxV = v;
  48224. }
  48225. var qId = data[offset + 2];
  48226. l = frame.components.push({
  48227. h: h,
  48228. v: v,
  48229. quantizationId: qId,
  48230. quantizationTable: null
  48231. });
  48232. frame.componentIds[componentId] = l - 1;
  48233. offset += 3;
  48234. }
  48235. frame.maxH = maxH;
  48236. frame.maxV = maxV;
  48237. prepareComponents(frame);
  48238. break;
  48239. case 0xFFC4:
  48240. var huffmanLength = readUint16();
  48241. for (i = 2; i < huffmanLength;) {
  48242. var huffmanTableSpec = data[offset++];
  48243. var codeLengths = new Uint8Array(16);
  48244. var codeLengthSum = 0;
  48245. for (j = 0; j < 16; j++, offset++) {
  48246. codeLengthSum += codeLengths[j] = data[offset];
  48247. }
  48248. var huffmanValues = new Uint8Array(codeLengthSum);
  48249. for (j = 0; j < codeLengthSum; j++, offset++) {
  48250. huffmanValues[j] = data[offset];
  48251. }
  48252. i += 17 + codeLengthSum;
  48253. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  48254. }
  48255. break;
  48256. case 0xFFDD:
  48257. readUint16();
  48258. resetInterval = readUint16();
  48259. break;
  48260. case 0xFFDA:
  48261. readUint16();
  48262. var selectorsCount = data[offset++];
  48263. var components = [], component;
  48264. for (i = 0; i < selectorsCount; i++) {
  48265. var componentIndex = frame.componentIds[data[offset++]];
  48266. component = frame.components[componentIndex];
  48267. var tableSpec = data[offset++];
  48268. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  48269. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  48270. components.push(component);
  48271. }
  48272. var spectralStart = data[offset++];
  48273. var spectralEnd = data[offset++];
  48274. var successiveApproximation = data[offset++];
  48275. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  48276. offset += processed;
  48277. break;
  48278. case 0xFFFF:
  48279. if (data[offset] !== 0xFF) {
  48280. offset--;
  48281. }
  48282. break;
  48283. default:
  48284. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  48285. offset -= 3;
  48286. break;
  48287. }
  48288. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  48289. }
  48290. fileMarker = readUint16();
  48291. }
  48292. this.width = frame.samplesPerLine;
  48293. this.height = frame.scanLines;
  48294. this.jfif = jfif;
  48295. this.adobe = adobe;
  48296. this.components = [];
  48297. for (i = 0; i < frame.components.length; i++) {
  48298. component = frame.components[i];
  48299. var quantizationTable = quantizationTables[component.quantizationId];
  48300. if (quantizationTable) {
  48301. component.quantizationTable = quantizationTable;
  48302. }
  48303. this.components.push({
  48304. output: buildComponentData(frame, component),
  48305. scaleX: component.h / frame.maxH,
  48306. scaleY: component.v / frame.maxV,
  48307. blocksPerLine: component.blocksPerLine,
  48308. blocksPerColumn: component.blocksPerColumn
  48309. });
  48310. }
  48311. this.numComponents = this.components.length;
  48312. },
  48313. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  48314. var scaleX = this.width / width, scaleY = this.height / height;
  48315. var component, componentScaleX, componentScaleY, blocksPerScanline;
  48316. var x, y, i, j, k;
  48317. var index;
  48318. var offset = 0;
  48319. var output;
  48320. var numComponents = this.components.length;
  48321. var dataLength = width * height * numComponents;
  48322. var data = new Uint8Array(dataLength);
  48323. var xScaleBlockOffset = new Uint32Array(width);
  48324. var mask3LSB = 0xfffffff8;
  48325. for (i = 0; i < numComponents; i++) {
  48326. component = this.components[i];
  48327. componentScaleX = component.scaleX * scaleX;
  48328. componentScaleY = component.scaleY * scaleY;
  48329. offset = i;
  48330. output = component.output;
  48331. blocksPerScanline = component.blocksPerLine + 1 << 3;
  48332. for (x = 0; x < width; x++) {
  48333. j = 0 | x * componentScaleX;
  48334. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  48335. }
  48336. for (y = 0; y < height; y++) {
  48337. j = 0 | y * componentScaleY;
  48338. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  48339. for (x = 0; x < width; x++) {
  48340. data[offset] = output[index + xScaleBlockOffset[x]];
  48341. offset += numComponents;
  48342. }
  48343. }
  48344. }
  48345. var transform = this.decodeTransform;
  48346. if (transform) {
  48347. for (i = 0; i < dataLength;) {
  48348. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  48349. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  48350. }
  48351. }
  48352. }
  48353. return data;
  48354. },
  48355. _isColorConversionNeeded: function isColorConversionNeeded() {
  48356. if (this.adobe && this.adobe.transformCode) {
  48357. return true;
  48358. } else if (this.numComponents === 3) {
  48359. if (!this.adobe && this.colorTransform === 0) {
  48360. return false;
  48361. }
  48362. return true;
  48363. }
  48364. if (!this.adobe && this.colorTransform === 1) {
  48365. return true;
  48366. }
  48367. return false;
  48368. },
  48369. _convertYccToRgb: function convertYccToRgb(data) {
  48370. var Y, Cb, Cr;
  48371. for (var i = 0, length = data.length; i < length; i += 3) {
  48372. Y = data[i];
  48373. Cb = data[i + 1];
  48374. Cr = data[i + 2];
  48375. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  48376. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  48377. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  48378. }
  48379. return data;
  48380. },
  48381. _convertYcckToRgb: function convertYcckToRgb(data) {
  48382. var Y, Cb, Cr, k;
  48383. var offset = 0;
  48384. for (var i = 0, length = data.length; i < length; i += 4) {
  48385. Y = data[i];
  48386. Cb = data[i + 1];
  48387. Cr = data[i + 2];
  48388. k = data[i + 3];
  48389. 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);
  48390. 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);
  48391. 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);
  48392. data[offset++] = clamp0to255(r);
  48393. data[offset++] = clamp0to255(g);
  48394. data[offset++] = clamp0to255(b);
  48395. }
  48396. return data;
  48397. },
  48398. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  48399. var Y, Cb, Cr;
  48400. for (var i = 0, length = data.length; i < length; i += 4) {
  48401. Y = data[i];
  48402. Cb = data[i + 1];
  48403. Cr = data[i + 2];
  48404. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  48405. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  48406. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  48407. }
  48408. return data;
  48409. },
  48410. _convertCmykToRgb: function convertCmykToRgb(data) {
  48411. var c, m, y, k;
  48412. var offset = 0;
  48413. var min = -255 * 255 * 255;
  48414. var scale = 1 / 255 / 255;
  48415. for (var i = 0, length = data.length; i < length; i += 4) {
  48416. c = data[i];
  48417. m = data[i + 1];
  48418. y = data[i + 2];
  48419. k = data[i + 3];
  48420. 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);
  48421. 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);
  48422. 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);
  48423. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  48424. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  48425. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  48426. }
  48427. return data;
  48428. },
  48429. getData: function getData(width, height, forceRGBoutput) {
  48430. if (this.numComponents > 4) {
  48431. error('JPEG error: Unsupported color mode');
  48432. }
  48433. var data = this._getLinearizedBlockData(width, height);
  48434. if (this.numComponents === 1 && forceRGBoutput) {
  48435. var dataLength = data.length;
  48436. var rgbData = new Uint8Array(dataLength * 3);
  48437. var offset = 0;
  48438. for (var i = 0; i < dataLength; i++) {
  48439. var grayColor = data[i];
  48440. rgbData[offset++] = grayColor;
  48441. rgbData[offset++] = grayColor;
  48442. rgbData[offset++] = grayColor;
  48443. }
  48444. return rgbData;
  48445. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  48446. return this._convertYccToRgb(data);
  48447. } else if (this.numComponents === 4) {
  48448. if (this._isColorConversionNeeded()) {
  48449. if (forceRGBoutput) {
  48450. return this._convertYcckToRgb(data);
  48451. }
  48452. return this._convertYcckToCmyk(data);
  48453. } else if (forceRGBoutput) {
  48454. return this._convertCmykToRgb(data);
  48455. }
  48456. }
  48457. return data;
  48458. }
  48459. };
  48460. return JpegImage;
  48461. }();
  48462. exports.JpegImage = JpegImage;
  48463. /***/ }),
  48464. /* 37 */
  48465. /***/ (function(module, exports, __w_pdfjs_require__) {
  48466. "use strict";
  48467. var sharedUtil = __w_pdfjs_require__(0);
  48468. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  48469. var getMetrics = getLookupTableFactory(function (t) {
  48470. t['Courier'] = 600;
  48471. t['Courier-Bold'] = 600;
  48472. t['Courier-BoldOblique'] = 600;
  48473. t['Courier-Oblique'] = 600;
  48474. t['Helvetica'] = getLookupTableFactory(function (t) {
  48475. t['space'] = 278;
  48476. t['exclam'] = 278;
  48477. t['quotedbl'] = 355;
  48478. t['numbersign'] = 556;
  48479. t['dollar'] = 556;
  48480. t['percent'] = 889;
  48481. t['ampersand'] = 667;
  48482. t['quoteright'] = 222;
  48483. t['parenleft'] = 333;
  48484. t['parenright'] = 333;
  48485. t['asterisk'] = 389;
  48486. t['plus'] = 584;
  48487. t['comma'] = 278;
  48488. t['hyphen'] = 333;
  48489. t['period'] = 278;
  48490. t['slash'] = 278;
  48491. t['zero'] = 556;
  48492. t['one'] = 556;
  48493. t['two'] = 556;
  48494. t['three'] = 556;
  48495. t['four'] = 556;
  48496. t['five'] = 556;
  48497. t['six'] = 556;
  48498. t['seven'] = 556;
  48499. t['eight'] = 556;
  48500. t['nine'] = 556;
  48501. t['colon'] = 278;
  48502. t['semicolon'] = 278;
  48503. t['less'] = 584;
  48504. t['equal'] = 584;
  48505. t['greater'] = 584;
  48506. t['question'] = 556;
  48507. t['at'] = 1015;
  48508. t['A'] = 667;
  48509. t['B'] = 667;
  48510. t['C'] = 722;
  48511. t['D'] = 722;
  48512. t['E'] = 667;
  48513. t['F'] = 611;
  48514. t['G'] = 778;
  48515. t['H'] = 722;
  48516. t['I'] = 278;
  48517. t['J'] = 500;
  48518. t['K'] = 667;
  48519. t['L'] = 556;
  48520. t['M'] = 833;
  48521. t['N'] = 722;
  48522. t['O'] = 778;
  48523. t['P'] = 667;
  48524. t['Q'] = 778;
  48525. t['R'] = 722;
  48526. t['S'] = 667;
  48527. t['T'] = 611;
  48528. t['U'] = 722;
  48529. t['V'] = 667;
  48530. t['W'] = 944;
  48531. t['X'] = 667;
  48532. t['Y'] = 667;
  48533. t['Z'] = 611;
  48534. t['bracketleft'] = 278;
  48535. t['backslash'] = 278;
  48536. t['bracketright'] = 278;
  48537. t['asciicircum'] = 469;
  48538. t['underscore'] = 556;
  48539. t['quoteleft'] = 222;
  48540. t['a'] = 556;
  48541. t['b'] = 556;
  48542. t['c'] = 500;
  48543. t['d'] = 556;
  48544. t['e'] = 556;
  48545. t['f'] = 278;
  48546. t['g'] = 556;
  48547. t['h'] = 556;
  48548. t['i'] = 222;
  48549. t['j'] = 222;
  48550. t['k'] = 500;
  48551. t['l'] = 222;
  48552. t['m'] = 833;
  48553. t['n'] = 556;
  48554. t['o'] = 556;
  48555. t['p'] = 556;
  48556. t['q'] = 556;
  48557. t['r'] = 333;
  48558. t['s'] = 500;
  48559. t['t'] = 278;
  48560. t['u'] = 556;
  48561. t['v'] = 500;
  48562. t['w'] = 722;
  48563. t['x'] = 500;
  48564. t['y'] = 500;
  48565. t['z'] = 500;
  48566. t['braceleft'] = 334;
  48567. t['bar'] = 260;
  48568. t['braceright'] = 334;
  48569. t['asciitilde'] = 584;
  48570. t['exclamdown'] = 333;
  48571. t['cent'] = 556;
  48572. t['sterling'] = 556;
  48573. t['fraction'] = 167;
  48574. t['yen'] = 556;
  48575. t['florin'] = 556;
  48576. t['section'] = 556;
  48577. t['currency'] = 556;
  48578. t['quotesingle'] = 191;
  48579. t['quotedblleft'] = 333;
  48580. t['guillemotleft'] = 556;
  48581. t['guilsinglleft'] = 333;
  48582. t['guilsinglright'] = 333;
  48583. t['fi'] = 500;
  48584. t['fl'] = 500;
  48585. t['endash'] = 556;
  48586. t['dagger'] = 556;
  48587. t['daggerdbl'] = 556;
  48588. t['periodcentered'] = 278;
  48589. t['paragraph'] = 537;
  48590. t['bullet'] = 350;
  48591. t['quotesinglbase'] = 222;
  48592. t['quotedblbase'] = 333;
  48593. t['quotedblright'] = 333;
  48594. t['guillemotright'] = 556;
  48595. t['ellipsis'] = 1000;
  48596. t['perthousand'] = 1000;
  48597. t['questiondown'] = 611;
  48598. t['grave'] = 333;
  48599. t['acute'] = 333;
  48600. t['circumflex'] = 333;
  48601. t['tilde'] = 333;
  48602. t['macron'] = 333;
  48603. t['breve'] = 333;
  48604. t['dotaccent'] = 333;
  48605. t['dieresis'] = 333;
  48606. t['ring'] = 333;
  48607. t['cedilla'] = 333;
  48608. t['hungarumlaut'] = 333;
  48609. t['ogonek'] = 333;
  48610. t['caron'] = 333;
  48611. t['emdash'] = 1000;
  48612. t['AE'] = 1000;
  48613. t['ordfeminine'] = 370;
  48614. t['Lslash'] = 556;
  48615. t['Oslash'] = 778;
  48616. t['OE'] = 1000;
  48617. t['ordmasculine'] = 365;
  48618. t['ae'] = 889;
  48619. t['dotlessi'] = 278;
  48620. t['lslash'] = 222;
  48621. t['oslash'] = 611;
  48622. t['oe'] = 944;
  48623. t['germandbls'] = 611;
  48624. t['Idieresis'] = 278;
  48625. t['eacute'] = 556;
  48626. t['abreve'] = 556;
  48627. t['uhungarumlaut'] = 556;
  48628. t['ecaron'] = 556;
  48629. t['Ydieresis'] = 667;
  48630. t['divide'] = 584;
  48631. t['Yacute'] = 667;
  48632. t['Acircumflex'] = 667;
  48633. t['aacute'] = 556;
  48634. t['Ucircumflex'] = 722;
  48635. t['yacute'] = 500;
  48636. t['scommaaccent'] = 500;
  48637. t['ecircumflex'] = 556;
  48638. t['Uring'] = 722;
  48639. t['Udieresis'] = 722;
  48640. t['aogonek'] = 556;
  48641. t['Uacute'] = 722;
  48642. t['uogonek'] = 556;
  48643. t['Edieresis'] = 667;
  48644. t['Dcroat'] = 722;
  48645. t['commaaccent'] = 250;
  48646. t['copyright'] = 737;
  48647. t['Emacron'] = 667;
  48648. t['ccaron'] = 500;
  48649. t['aring'] = 556;
  48650. t['Ncommaaccent'] = 722;
  48651. t['lacute'] = 222;
  48652. t['agrave'] = 556;
  48653. t['Tcommaaccent'] = 611;
  48654. t['Cacute'] = 722;
  48655. t['atilde'] = 556;
  48656. t['Edotaccent'] = 667;
  48657. t['scaron'] = 500;
  48658. t['scedilla'] = 500;
  48659. t['iacute'] = 278;
  48660. t['lozenge'] = 471;
  48661. t['Rcaron'] = 722;
  48662. t['Gcommaaccent'] = 778;
  48663. t['ucircumflex'] = 556;
  48664. t['acircumflex'] = 556;
  48665. t['Amacron'] = 667;
  48666. t['rcaron'] = 333;
  48667. t['ccedilla'] = 500;
  48668. t['Zdotaccent'] = 611;
  48669. t['Thorn'] = 667;
  48670. t['Omacron'] = 778;
  48671. t['Racute'] = 722;
  48672. t['Sacute'] = 667;
  48673. t['dcaron'] = 643;
  48674. t['Umacron'] = 722;
  48675. t['uring'] = 556;
  48676. t['threesuperior'] = 333;
  48677. t['Ograve'] = 778;
  48678. t['Agrave'] = 667;
  48679. t['Abreve'] = 667;
  48680. t['multiply'] = 584;
  48681. t['uacute'] = 556;
  48682. t['Tcaron'] = 611;
  48683. t['partialdiff'] = 476;
  48684. t['ydieresis'] = 500;
  48685. t['Nacute'] = 722;
  48686. t['icircumflex'] = 278;
  48687. t['Ecircumflex'] = 667;
  48688. t['adieresis'] = 556;
  48689. t['edieresis'] = 556;
  48690. t['cacute'] = 500;
  48691. t['nacute'] = 556;
  48692. t['umacron'] = 556;
  48693. t['Ncaron'] = 722;
  48694. t['Iacute'] = 278;
  48695. t['plusminus'] = 584;
  48696. t['brokenbar'] = 260;
  48697. t['registered'] = 737;
  48698. t['Gbreve'] = 778;
  48699. t['Idotaccent'] = 278;
  48700. t['summation'] = 600;
  48701. t['Egrave'] = 667;
  48702. t['racute'] = 333;
  48703. t['omacron'] = 556;
  48704. t['Zacute'] = 611;
  48705. t['Zcaron'] = 611;
  48706. t['greaterequal'] = 549;
  48707. t['Eth'] = 722;
  48708. t['Ccedilla'] = 722;
  48709. t['lcommaaccent'] = 222;
  48710. t['tcaron'] = 317;
  48711. t['eogonek'] = 556;
  48712. t['Uogonek'] = 722;
  48713. t['Aacute'] = 667;
  48714. t['Adieresis'] = 667;
  48715. t['egrave'] = 556;
  48716. t['zacute'] = 500;
  48717. t['iogonek'] = 222;
  48718. t['Oacute'] = 778;
  48719. t['oacute'] = 556;
  48720. t['amacron'] = 556;
  48721. t['sacute'] = 500;
  48722. t['idieresis'] = 278;
  48723. t['Ocircumflex'] = 778;
  48724. t['Ugrave'] = 722;
  48725. t['Delta'] = 612;
  48726. t['thorn'] = 556;
  48727. t['twosuperior'] = 333;
  48728. t['Odieresis'] = 778;
  48729. t['mu'] = 556;
  48730. t['igrave'] = 278;
  48731. t['ohungarumlaut'] = 556;
  48732. t['Eogonek'] = 667;
  48733. t['dcroat'] = 556;
  48734. t['threequarters'] = 834;
  48735. t['Scedilla'] = 667;
  48736. t['lcaron'] = 299;
  48737. t['Kcommaaccent'] = 667;
  48738. t['Lacute'] = 556;
  48739. t['trademark'] = 1000;
  48740. t['edotaccent'] = 556;
  48741. t['Igrave'] = 278;
  48742. t['Imacron'] = 278;
  48743. t['Lcaron'] = 556;
  48744. t['onehalf'] = 834;
  48745. t['lessequal'] = 549;
  48746. t['ocircumflex'] = 556;
  48747. t['ntilde'] = 556;
  48748. t['Uhungarumlaut'] = 722;
  48749. t['Eacute'] = 667;
  48750. t['emacron'] = 556;
  48751. t['gbreve'] = 556;
  48752. t['onequarter'] = 834;
  48753. t['Scaron'] = 667;
  48754. t['Scommaaccent'] = 667;
  48755. t['Ohungarumlaut'] = 778;
  48756. t['degree'] = 400;
  48757. t['ograve'] = 556;
  48758. t['Ccaron'] = 722;
  48759. t['ugrave'] = 556;
  48760. t['radical'] = 453;
  48761. t['Dcaron'] = 722;
  48762. t['rcommaaccent'] = 333;
  48763. t['Ntilde'] = 722;
  48764. t['otilde'] = 556;
  48765. t['Rcommaaccent'] = 722;
  48766. t['Lcommaaccent'] = 556;
  48767. t['Atilde'] = 667;
  48768. t['Aogonek'] = 667;
  48769. t['Aring'] = 667;
  48770. t['Otilde'] = 778;
  48771. t['zdotaccent'] = 500;
  48772. t['Ecaron'] = 667;
  48773. t['Iogonek'] = 278;
  48774. t['kcommaaccent'] = 500;
  48775. t['minus'] = 584;
  48776. t['Icircumflex'] = 278;
  48777. t['ncaron'] = 556;
  48778. t['tcommaaccent'] = 278;
  48779. t['logicalnot'] = 584;
  48780. t['odieresis'] = 556;
  48781. t['udieresis'] = 556;
  48782. t['notequal'] = 549;
  48783. t['gcommaaccent'] = 556;
  48784. t['eth'] = 556;
  48785. t['zcaron'] = 500;
  48786. t['ncommaaccent'] = 556;
  48787. t['onesuperior'] = 333;
  48788. t['imacron'] = 278;
  48789. t['Euro'] = 556;
  48790. });
  48791. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  48792. t['space'] = 278;
  48793. t['exclam'] = 333;
  48794. t['quotedbl'] = 474;
  48795. t['numbersign'] = 556;
  48796. t['dollar'] = 556;
  48797. t['percent'] = 889;
  48798. t['ampersand'] = 722;
  48799. t['quoteright'] = 278;
  48800. t['parenleft'] = 333;
  48801. t['parenright'] = 333;
  48802. t['asterisk'] = 389;
  48803. t['plus'] = 584;
  48804. t['comma'] = 278;
  48805. t['hyphen'] = 333;
  48806. t['period'] = 278;
  48807. t['slash'] = 278;
  48808. t['zero'] = 556;
  48809. t['one'] = 556;
  48810. t['two'] = 556;
  48811. t['three'] = 556;
  48812. t['four'] = 556;
  48813. t['five'] = 556;
  48814. t['six'] = 556;
  48815. t['seven'] = 556;
  48816. t['eight'] = 556;
  48817. t['nine'] = 556;
  48818. t['colon'] = 333;
  48819. t['semicolon'] = 333;
  48820. t['less'] = 584;
  48821. t['equal'] = 584;
  48822. t['greater'] = 584;
  48823. t['question'] = 611;
  48824. t['at'] = 975;
  48825. t['A'] = 722;
  48826. t['B'] = 722;
  48827. t['C'] = 722;
  48828. t['D'] = 722;
  48829. t['E'] = 667;
  48830. t['F'] = 611;
  48831. t['G'] = 778;
  48832. t['H'] = 722;
  48833. t['I'] = 278;
  48834. t['J'] = 556;
  48835. t['K'] = 722;
  48836. t['L'] = 611;
  48837. t['M'] = 833;
  48838. t['N'] = 722;
  48839. t['O'] = 778;
  48840. t['P'] = 667;
  48841. t['Q'] = 778;
  48842. t['R'] = 722;
  48843. t['S'] = 667;
  48844. t['T'] = 611;
  48845. t['U'] = 722;
  48846. t['V'] = 667;
  48847. t['W'] = 944;
  48848. t['X'] = 667;
  48849. t['Y'] = 667;
  48850. t['Z'] = 611;
  48851. t['bracketleft'] = 333;
  48852. t['backslash'] = 278;
  48853. t['bracketright'] = 333;
  48854. t['asciicircum'] = 584;
  48855. t['underscore'] = 556;
  48856. t['quoteleft'] = 278;
  48857. t['a'] = 556;
  48858. t['b'] = 611;
  48859. t['c'] = 556;
  48860. t['d'] = 611;
  48861. t['e'] = 556;
  48862. t['f'] = 333;
  48863. t['g'] = 611;
  48864. t['h'] = 611;
  48865. t['i'] = 278;
  48866. t['j'] = 278;
  48867. t['k'] = 556;
  48868. t['l'] = 278;
  48869. t['m'] = 889;
  48870. t['n'] = 611;
  48871. t['o'] = 611;
  48872. t['p'] = 611;
  48873. t['q'] = 611;
  48874. t['r'] = 389;
  48875. t['s'] = 556;
  48876. t['t'] = 333;
  48877. t['u'] = 611;
  48878. t['v'] = 556;
  48879. t['w'] = 778;
  48880. t['x'] = 556;
  48881. t['y'] = 556;
  48882. t['z'] = 500;
  48883. t['braceleft'] = 389;
  48884. t['bar'] = 280;
  48885. t['braceright'] = 389;
  48886. t['asciitilde'] = 584;
  48887. t['exclamdown'] = 333;
  48888. t['cent'] = 556;
  48889. t['sterling'] = 556;
  48890. t['fraction'] = 167;
  48891. t['yen'] = 556;
  48892. t['florin'] = 556;
  48893. t['section'] = 556;
  48894. t['currency'] = 556;
  48895. t['quotesingle'] = 238;
  48896. t['quotedblleft'] = 500;
  48897. t['guillemotleft'] = 556;
  48898. t['guilsinglleft'] = 333;
  48899. t['guilsinglright'] = 333;
  48900. t['fi'] = 611;
  48901. t['fl'] = 611;
  48902. t['endash'] = 556;
  48903. t['dagger'] = 556;
  48904. t['daggerdbl'] = 556;
  48905. t['periodcentered'] = 278;
  48906. t['paragraph'] = 556;
  48907. t['bullet'] = 350;
  48908. t['quotesinglbase'] = 278;
  48909. t['quotedblbase'] = 500;
  48910. t['quotedblright'] = 500;
  48911. t['guillemotright'] = 556;
  48912. t['ellipsis'] = 1000;
  48913. t['perthousand'] = 1000;
  48914. t['questiondown'] = 611;
  48915. t['grave'] = 333;
  48916. t['acute'] = 333;
  48917. t['circumflex'] = 333;
  48918. t['tilde'] = 333;
  48919. t['macron'] = 333;
  48920. t['breve'] = 333;
  48921. t['dotaccent'] = 333;
  48922. t['dieresis'] = 333;
  48923. t['ring'] = 333;
  48924. t['cedilla'] = 333;
  48925. t['hungarumlaut'] = 333;
  48926. t['ogonek'] = 333;
  48927. t['caron'] = 333;
  48928. t['emdash'] = 1000;
  48929. t['AE'] = 1000;
  48930. t['ordfeminine'] = 370;
  48931. t['Lslash'] = 611;
  48932. t['Oslash'] = 778;
  48933. t['OE'] = 1000;
  48934. t['ordmasculine'] = 365;
  48935. t['ae'] = 889;
  48936. t['dotlessi'] = 278;
  48937. t['lslash'] = 278;
  48938. t['oslash'] = 611;
  48939. t['oe'] = 944;
  48940. t['germandbls'] = 611;
  48941. t['Idieresis'] = 278;
  48942. t['eacute'] = 556;
  48943. t['abreve'] = 556;
  48944. t['uhungarumlaut'] = 611;
  48945. t['ecaron'] = 556;
  48946. t['Ydieresis'] = 667;
  48947. t['divide'] = 584;
  48948. t['Yacute'] = 667;
  48949. t['Acircumflex'] = 722;
  48950. t['aacute'] = 556;
  48951. t['Ucircumflex'] = 722;
  48952. t['yacute'] = 556;
  48953. t['scommaaccent'] = 556;
  48954. t['ecircumflex'] = 556;
  48955. t['Uring'] = 722;
  48956. t['Udieresis'] = 722;
  48957. t['aogonek'] = 556;
  48958. t['Uacute'] = 722;
  48959. t['uogonek'] = 611;
  48960. t['Edieresis'] = 667;
  48961. t['Dcroat'] = 722;
  48962. t['commaaccent'] = 250;
  48963. t['copyright'] = 737;
  48964. t['Emacron'] = 667;
  48965. t['ccaron'] = 556;
  48966. t['aring'] = 556;
  48967. t['Ncommaaccent'] = 722;
  48968. t['lacute'] = 278;
  48969. t['agrave'] = 556;
  48970. t['Tcommaaccent'] = 611;
  48971. t['Cacute'] = 722;
  48972. t['atilde'] = 556;
  48973. t['Edotaccent'] = 667;
  48974. t['scaron'] = 556;
  48975. t['scedilla'] = 556;
  48976. t['iacute'] = 278;
  48977. t['lozenge'] = 494;
  48978. t['Rcaron'] = 722;
  48979. t['Gcommaaccent'] = 778;
  48980. t['ucircumflex'] = 611;
  48981. t['acircumflex'] = 556;
  48982. t['Amacron'] = 722;
  48983. t['rcaron'] = 389;
  48984. t['ccedilla'] = 556;
  48985. t['Zdotaccent'] = 611;
  48986. t['Thorn'] = 667;
  48987. t['Omacron'] = 778;
  48988. t['Racute'] = 722;
  48989. t['Sacute'] = 667;
  48990. t['dcaron'] = 743;
  48991. t['Umacron'] = 722;
  48992. t['uring'] = 611;
  48993. t['threesuperior'] = 333;
  48994. t['Ograve'] = 778;
  48995. t['Agrave'] = 722;
  48996. t['Abreve'] = 722;
  48997. t['multiply'] = 584;
  48998. t['uacute'] = 611;
  48999. t['Tcaron'] = 611;
  49000. t['partialdiff'] = 494;
  49001. t['ydieresis'] = 556;
  49002. t['Nacute'] = 722;
  49003. t['icircumflex'] = 278;
  49004. t['Ecircumflex'] = 667;
  49005. t['adieresis'] = 556;
  49006. t['edieresis'] = 556;
  49007. t['cacute'] = 556;
  49008. t['nacute'] = 611;
  49009. t['umacron'] = 611;
  49010. t['Ncaron'] = 722;
  49011. t['Iacute'] = 278;
  49012. t['plusminus'] = 584;
  49013. t['brokenbar'] = 280;
  49014. t['registered'] = 737;
  49015. t['Gbreve'] = 778;
  49016. t['Idotaccent'] = 278;
  49017. t['summation'] = 600;
  49018. t['Egrave'] = 667;
  49019. t['racute'] = 389;
  49020. t['omacron'] = 611;
  49021. t['Zacute'] = 611;
  49022. t['Zcaron'] = 611;
  49023. t['greaterequal'] = 549;
  49024. t['Eth'] = 722;
  49025. t['Ccedilla'] = 722;
  49026. t['lcommaaccent'] = 278;
  49027. t['tcaron'] = 389;
  49028. t['eogonek'] = 556;
  49029. t['Uogonek'] = 722;
  49030. t['Aacute'] = 722;
  49031. t['Adieresis'] = 722;
  49032. t['egrave'] = 556;
  49033. t['zacute'] = 500;
  49034. t['iogonek'] = 278;
  49035. t['Oacute'] = 778;
  49036. t['oacute'] = 611;
  49037. t['amacron'] = 556;
  49038. t['sacute'] = 556;
  49039. t['idieresis'] = 278;
  49040. t['Ocircumflex'] = 778;
  49041. t['Ugrave'] = 722;
  49042. t['Delta'] = 612;
  49043. t['thorn'] = 611;
  49044. t['twosuperior'] = 333;
  49045. t['Odieresis'] = 778;
  49046. t['mu'] = 611;
  49047. t['igrave'] = 278;
  49048. t['ohungarumlaut'] = 611;
  49049. t['Eogonek'] = 667;
  49050. t['dcroat'] = 611;
  49051. t['threequarters'] = 834;
  49052. t['Scedilla'] = 667;
  49053. t['lcaron'] = 400;
  49054. t['Kcommaaccent'] = 722;
  49055. t['Lacute'] = 611;
  49056. t['trademark'] = 1000;
  49057. t['edotaccent'] = 556;
  49058. t['Igrave'] = 278;
  49059. t['Imacron'] = 278;
  49060. t['Lcaron'] = 611;
  49061. t['onehalf'] = 834;
  49062. t['lessequal'] = 549;
  49063. t['ocircumflex'] = 611;
  49064. t['ntilde'] = 611;
  49065. t['Uhungarumlaut'] = 722;
  49066. t['Eacute'] = 667;
  49067. t['emacron'] = 556;
  49068. t['gbreve'] = 611;
  49069. t['onequarter'] = 834;
  49070. t['Scaron'] = 667;
  49071. t['Scommaaccent'] = 667;
  49072. t['Ohungarumlaut'] = 778;
  49073. t['degree'] = 400;
  49074. t['ograve'] = 611;
  49075. t['Ccaron'] = 722;
  49076. t['ugrave'] = 611;
  49077. t['radical'] = 549;
  49078. t['Dcaron'] = 722;
  49079. t['rcommaaccent'] = 389;
  49080. t['Ntilde'] = 722;
  49081. t['otilde'] = 611;
  49082. t['Rcommaaccent'] = 722;
  49083. t['Lcommaaccent'] = 611;
  49084. t['Atilde'] = 722;
  49085. t['Aogonek'] = 722;
  49086. t['Aring'] = 722;
  49087. t['Otilde'] = 778;
  49088. t['zdotaccent'] = 500;
  49089. t['Ecaron'] = 667;
  49090. t['Iogonek'] = 278;
  49091. t['kcommaaccent'] = 556;
  49092. t['minus'] = 584;
  49093. t['Icircumflex'] = 278;
  49094. t['ncaron'] = 611;
  49095. t['tcommaaccent'] = 333;
  49096. t['logicalnot'] = 584;
  49097. t['odieresis'] = 611;
  49098. t['udieresis'] = 611;
  49099. t['notequal'] = 549;
  49100. t['gcommaaccent'] = 611;
  49101. t['eth'] = 611;
  49102. t['zcaron'] = 500;
  49103. t['ncommaaccent'] = 611;
  49104. t['onesuperior'] = 333;
  49105. t['imacron'] = 278;
  49106. t['Euro'] = 556;
  49107. });
  49108. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49109. t['space'] = 278;
  49110. t['exclam'] = 333;
  49111. t['quotedbl'] = 474;
  49112. t['numbersign'] = 556;
  49113. t['dollar'] = 556;
  49114. t['percent'] = 889;
  49115. t['ampersand'] = 722;
  49116. t['quoteright'] = 278;
  49117. t['parenleft'] = 333;
  49118. t['parenright'] = 333;
  49119. t['asterisk'] = 389;
  49120. t['plus'] = 584;
  49121. t['comma'] = 278;
  49122. t['hyphen'] = 333;
  49123. t['period'] = 278;
  49124. t['slash'] = 278;
  49125. t['zero'] = 556;
  49126. t['one'] = 556;
  49127. t['two'] = 556;
  49128. t['three'] = 556;
  49129. t['four'] = 556;
  49130. t['five'] = 556;
  49131. t['six'] = 556;
  49132. t['seven'] = 556;
  49133. t['eight'] = 556;
  49134. t['nine'] = 556;
  49135. t['colon'] = 333;
  49136. t['semicolon'] = 333;
  49137. t['less'] = 584;
  49138. t['equal'] = 584;
  49139. t['greater'] = 584;
  49140. t['question'] = 611;
  49141. t['at'] = 975;
  49142. t['A'] = 722;
  49143. t['B'] = 722;
  49144. t['C'] = 722;
  49145. t['D'] = 722;
  49146. t['E'] = 667;
  49147. t['F'] = 611;
  49148. t['G'] = 778;
  49149. t['H'] = 722;
  49150. t['I'] = 278;
  49151. t['J'] = 556;
  49152. t['K'] = 722;
  49153. t['L'] = 611;
  49154. t['M'] = 833;
  49155. t['N'] = 722;
  49156. t['O'] = 778;
  49157. t['P'] = 667;
  49158. t['Q'] = 778;
  49159. t['R'] = 722;
  49160. t['S'] = 667;
  49161. t['T'] = 611;
  49162. t['U'] = 722;
  49163. t['V'] = 667;
  49164. t['W'] = 944;
  49165. t['X'] = 667;
  49166. t['Y'] = 667;
  49167. t['Z'] = 611;
  49168. t['bracketleft'] = 333;
  49169. t['backslash'] = 278;
  49170. t['bracketright'] = 333;
  49171. t['asciicircum'] = 584;
  49172. t['underscore'] = 556;
  49173. t['quoteleft'] = 278;
  49174. t['a'] = 556;
  49175. t['b'] = 611;
  49176. t['c'] = 556;
  49177. t['d'] = 611;
  49178. t['e'] = 556;
  49179. t['f'] = 333;
  49180. t['g'] = 611;
  49181. t['h'] = 611;
  49182. t['i'] = 278;
  49183. t['j'] = 278;
  49184. t['k'] = 556;
  49185. t['l'] = 278;
  49186. t['m'] = 889;
  49187. t['n'] = 611;
  49188. t['o'] = 611;
  49189. t['p'] = 611;
  49190. t['q'] = 611;
  49191. t['r'] = 389;
  49192. t['s'] = 556;
  49193. t['t'] = 333;
  49194. t['u'] = 611;
  49195. t['v'] = 556;
  49196. t['w'] = 778;
  49197. t['x'] = 556;
  49198. t['y'] = 556;
  49199. t['z'] = 500;
  49200. t['braceleft'] = 389;
  49201. t['bar'] = 280;
  49202. t['braceright'] = 389;
  49203. t['asciitilde'] = 584;
  49204. t['exclamdown'] = 333;
  49205. t['cent'] = 556;
  49206. t['sterling'] = 556;
  49207. t['fraction'] = 167;
  49208. t['yen'] = 556;
  49209. t['florin'] = 556;
  49210. t['section'] = 556;
  49211. t['currency'] = 556;
  49212. t['quotesingle'] = 238;
  49213. t['quotedblleft'] = 500;
  49214. t['guillemotleft'] = 556;
  49215. t['guilsinglleft'] = 333;
  49216. t['guilsinglright'] = 333;
  49217. t['fi'] = 611;
  49218. t['fl'] = 611;
  49219. t['endash'] = 556;
  49220. t['dagger'] = 556;
  49221. t['daggerdbl'] = 556;
  49222. t['periodcentered'] = 278;
  49223. t['paragraph'] = 556;
  49224. t['bullet'] = 350;
  49225. t['quotesinglbase'] = 278;
  49226. t['quotedblbase'] = 500;
  49227. t['quotedblright'] = 500;
  49228. t['guillemotright'] = 556;
  49229. t['ellipsis'] = 1000;
  49230. t['perthousand'] = 1000;
  49231. t['questiondown'] = 611;
  49232. t['grave'] = 333;
  49233. t['acute'] = 333;
  49234. t['circumflex'] = 333;
  49235. t['tilde'] = 333;
  49236. t['macron'] = 333;
  49237. t['breve'] = 333;
  49238. t['dotaccent'] = 333;
  49239. t['dieresis'] = 333;
  49240. t['ring'] = 333;
  49241. t['cedilla'] = 333;
  49242. t['hungarumlaut'] = 333;
  49243. t['ogonek'] = 333;
  49244. t['caron'] = 333;
  49245. t['emdash'] = 1000;
  49246. t['AE'] = 1000;
  49247. t['ordfeminine'] = 370;
  49248. t['Lslash'] = 611;
  49249. t['Oslash'] = 778;
  49250. t['OE'] = 1000;
  49251. t['ordmasculine'] = 365;
  49252. t['ae'] = 889;
  49253. t['dotlessi'] = 278;
  49254. t['lslash'] = 278;
  49255. t['oslash'] = 611;
  49256. t['oe'] = 944;
  49257. t['germandbls'] = 611;
  49258. t['Idieresis'] = 278;
  49259. t['eacute'] = 556;
  49260. t['abreve'] = 556;
  49261. t['uhungarumlaut'] = 611;
  49262. t['ecaron'] = 556;
  49263. t['Ydieresis'] = 667;
  49264. t['divide'] = 584;
  49265. t['Yacute'] = 667;
  49266. t['Acircumflex'] = 722;
  49267. t['aacute'] = 556;
  49268. t['Ucircumflex'] = 722;
  49269. t['yacute'] = 556;
  49270. t['scommaaccent'] = 556;
  49271. t['ecircumflex'] = 556;
  49272. t['Uring'] = 722;
  49273. t['Udieresis'] = 722;
  49274. t['aogonek'] = 556;
  49275. t['Uacute'] = 722;
  49276. t['uogonek'] = 611;
  49277. t['Edieresis'] = 667;
  49278. t['Dcroat'] = 722;
  49279. t['commaaccent'] = 250;
  49280. t['copyright'] = 737;
  49281. t['Emacron'] = 667;
  49282. t['ccaron'] = 556;
  49283. t['aring'] = 556;
  49284. t['Ncommaaccent'] = 722;
  49285. t['lacute'] = 278;
  49286. t['agrave'] = 556;
  49287. t['Tcommaaccent'] = 611;
  49288. t['Cacute'] = 722;
  49289. t['atilde'] = 556;
  49290. t['Edotaccent'] = 667;
  49291. t['scaron'] = 556;
  49292. t['scedilla'] = 556;
  49293. t['iacute'] = 278;
  49294. t['lozenge'] = 494;
  49295. t['Rcaron'] = 722;
  49296. t['Gcommaaccent'] = 778;
  49297. t['ucircumflex'] = 611;
  49298. t['acircumflex'] = 556;
  49299. t['Amacron'] = 722;
  49300. t['rcaron'] = 389;
  49301. t['ccedilla'] = 556;
  49302. t['Zdotaccent'] = 611;
  49303. t['Thorn'] = 667;
  49304. t['Omacron'] = 778;
  49305. t['Racute'] = 722;
  49306. t['Sacute'] = 667;
  49307. t['dcaron'] = 743;
  49308. t['Umacron'] = 722;
  49309. t['uring'] = 611;
  49310. t['threesuperior'] = 333;
  49311. t['Ograve'] = 778;
  49312. t['Agrave'] = 722;
  49313. t['Abreve'] = 722;
  49314. t['multiply'] = 584;
  49315. t['uacute'] = 611;
  49316. t['Tcaron'] = 611;
  49317. t['partialdiff'] = 494;
  49318. t['ydieresis'] = 556;
  49319. t['Nacute'] = 722;
  49320. t['icircumflex'] = 278;
  49321. t['Ecircumflex'] = 667;
  49322. t['adieresis'] = 556;
  49323. t['edieresis'] = 556;
  49324. t['cacute'] = 556;
  49325. t['nacute'] = 611;
  49326. t['umacron'] = 611;
  49327. t['Ncaron'] = 722;
  49328. t['Iacute'] = 278;
  49329. t['plusminus'] = 584;
  49330. t['brokenbar'] = 280;
  49331. t['registered'] = 737;
  49332. t['Gbreve'] = 778;
  49333. t['Idotaccent'] = 278;
  49334. t['summation'] = 600;
  49335. t['Egrave'] = 667;
  49336. t['racute'] = 389;
  49337. t['omacron'] = 611;
  49338. t['Zacute'] = 611;
  49339. t['Zcaron'] = 611;
  49340. t['greaterequal'] = 549;
  49341. t['Eth'] = 722;
  49342. t['Ccedilla'] = 722;
  49343. t['lcommaaccent'] = 278;
  49344. t['tcaron'] = 389;
  49345. t['eogonek'] = 556;
  49346. t['Uogonek'] = 722;
  49347. t['Aacute'] = 722;
  49348. t['Adieresis'] = 722;
  49349. t['egrave'] = 556;
  49350. t['zacute'] = 500;
  49351. t['iogonek'] = 278;
  49352. t['Oacute'] = 778;
  49353. t['oacute'] = 611;
  49354. t['amacron'] = 556;
  49355. t['sacute'] = 556;
  49356. t['idieresis'] = 278;
  49357. t['Ocircumflex'] = 778;
  49358. t['Ugrave'] = 722;
  49359. t['Delta'] = 612;
  49360. t['thorn'] = 611;
  49361. t['twosuperior'] = 333;
  49362. t['Odieresis'] = 778;
  49363. t['mu'] = 611;
  49364. t['igrave'] = 278;
  49365. t['ohungarumlaut'] = 611;
  49366. t['Eogonek'] = 667;
  49367. t['dcroat'] = 611;
  49368. t['threequarters'] = 834;
  49369. t['Scedilla'] = 667;
  49370. t['lcaron'] = 400;
  49371. t['Kcommaaccent'] = 722;
  49372. t['Lacute'] = 611;
  49373. t['trademark'] = 1000;
  49374. t['edotaccent'] = 556;
  49375. t['Igrave'] = 278;
  49376. t['Imacron'] = 278;
  49377. t['Lcaron'] = 611;
  49378. t['onehalf'] = 834;
  49379. t['lessequal'] = 549;
  49380. t['ocircumflex'] = 611;
  49381. t['ntilde'] = 611;
  49382. t['Uhungarumlaut'] = 722;
  49383. t['Eacute'] = 667;
  49384. t['emacron'] = 556;
  49385. t['gbreve'] = 611;
  49386. t['onequarter'] = 834;
  49387. t['Scaron'] = 667;
  49388. t['Scommaaccent'] = 667;
  49389. t['Ohungarumlaut'] = 778;
  49390. t['degree'] = 400;
  49391. t['ograve'] = 611;
  49392. t['Ccaron'] = 722;
  49393. t['ugrave'] = 611;
  49394. t['radical'] = 549;
  49395. t['Dcaron'] = 722;
  49396. t['rcommaaccent'] = 389;
  49397. t['Ntilde'] = 722;
  49398. t['otilde'] = 611;
  49399. t['Rcommaaccent'] = 722;
  49400. t['Lcommaaccent'] = 611;
  49401. t['Atilde'] = 722;
  49402. t['Aogonek'] = 722;
  49403. t['Aring'] = 722;
  49404. t['Otilde'] = 778;
  49405. t['zdotaccent'] = 500;
  49406. t['Ecaron'] = 667;
  49407. t['Iogonek'] = 278;
  49408. t['kcommaaccent'] = 556;
  49409. t['minus'] = 584;
  49410. t['Icircumflex'] = 278;
  49411. t['ncaron'] = 611;
  49412. t['tcommaaccent'] = 333;
  49413. t['logicalnot'] = 584;
  49414. t['odieresis'] = 611;
  49415. t['udieresis'] = 611;
  49416. t['notequal'] = 549;
  49417. t['gcommaaccent'] = 611;
  49418. t['eth'] = 611;
  49419. t['zcaron'] = 500;
  49420. t['ncommaaccent'] = 611;
  49421. t['onesuperior'] = 333;
  49422. t['imacron'] = 278;
  49423. t['Euro'] = 556;
  49424. });
  49425. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  49426. t['space'] = 278;
  49427. t['exclam'] = 278;
  49428. t['quotedbl'] = 355;
  49429. t['numbersign'] = 556;
  49430. t['dollar'] = 556;
  49431. t['percent'] = 889;
  49432. t['ampersand'] = 667;
  49433. t['quoteright'] = 222;
  49434. t['parenleft'] = 333;
  49435. t['parenright'] = 333;
  49436. t['asterisk'] = 389;
  49437. t['plus'] = 584;
  49438. t['comma'] = 278;
  49439. t['hyphen'] = 333;
  49440. t['period'] = 278;
  49441. t['slash'] = 278;
  49442. t['zero'] = 556;
  49443. t['one'] = 556;
  49444. t['two'] = 556;
  49445. t['three'] = 556;
  49446. t['four'] = 556;
  49447. t['five'] = 556;
  49448. t['six'] = 556;
  49449. t['seven'] = 556;
  49450. t['eight'] = 556;
  49451. t['nine'] = 556;
  49452. t['colon'] = 278;
  49453. t['semicolon'] = 278;
  49454. t['less'] = 584;
  49455. t['equal'] = 584;
  49456. t['greater'] = 584;
  49457. t['question'] = 556;
  49458. t['at'] = 1015;
  49459. t['A'] = 667;
  49460. t['B'] = 667;
  49461. t['C'] = 722;
  49462. t['D'] = 722;
  49463. t['E'] = 667;
  49464. t['F'] = 611;
  49465. t['G'] = 778;
  49466. t['H'] = 722;
  49467. t['I'] = 278;
  49468. t['J'] = 500;
  49469. t['K'] = 667;
  49470. t['L'] = 556;
  49471. t['M'] = 833;
  49472. t['N'] = 722;
  49473. t['O'] = 778;
  49474. t['P'] = 667;
  49475. t['Q'] = 778;
  49476. t['R'] = 722;
  49477. t['S'] = 667;
  49478. t['T'] = 611;
  49479. t['U'] = 722;
  49480. t['V'] = 667;
  49481. t['W'] = 944;
  49482. t['X'] = 667;
  49483. t['Y'] = 667;
  49484. t['Z'] = 611;
  49485. t['bracketleft'] = 278;
  49486. t['backslash'] = 278;
  49487. t['bracketright'] = 278;
  49488. t['asciicircum'] = 469;
  49489. t['underscore'] = 556;
  49490. t['quoteleft'] = 222;
  49491. t['a'] = 556;
  49492. t['b'] = 556;
  49493. t['c'] = 500;
  49494. t['d'] = 556;
  49495. t['e'] = 556;
  49496. t['f'] = 278;
  49497. t['g'] = 556;
  49498. t['h'] = 556;
  49499. t['i'] = 222;
  49500. t['j'] = 222;
  49501. t['k'] = 500;
  49502. t['l'] = 222;
  49503. t['m'] = 833;
  49504. t['n'] = 556;
  49505. t['o'] = 556;
  49506. t['p'] = 556;
  49507. t['q'] = 556;
  49508. t['r'] = 333;
  49509. t['s'] = 500;
  49510. t['t'] = 278;
  49511. t['u'] = 556;
  49512. t['v'] = 500;
  49513. t['w'] = 722;
  49514. t['x'] = 500;
  49515. t['y'] = 500;
  49516. t['z'] = 500;
  49517. t['braceleft'] = 334;
  49518. t['bar'] = 260;
  49519. t['braceright'] = 334;
  49520. t['asciitilde'] = 584;
  49521. t['exclamdown'] = 333;
  49522. t['cent'] = 556;
  49523. t['sterling'] = 556;
  49524. t['fraction'] = 167;
  49525. t['yen'] = 556;
  49526. t['florin'] = 556;
  49527. t['section'] = 556;
  49528. t['currency'] = 556;
  49529. t['quotesingle'] = 191;
  49530. t['quotedblleft'] = 333;
  49531. t['guillemotleft'] = 556;
  49532. t['guilsinglleft'] = 333;
  49533. t['guilsinglright'] = 333;
  49534. t['fi'] = 500;
  49535. t['fl'] = 500;
  49536. t['endash'] = 556;
  49537. t['dagger'] = 556;
  49538. t['daggerdbl'] = 556;
  49539. t['periodcentered'] = 278;
  49540. t['paragraph'] = 537;
  49541. t['bullet'] = 350;
  49542. t['quotesinglbase'] = 222;
  49543. t['quotedblbase'] = 333;
  49544. t['quotedblright'] = 333;
  49545. t['guillemotright'] = 556;
  49546. t['ellipsis'] = 1000;
  49547. t['perthousand'] = 1000;
  49548. t['questiondown'] = 611;
  49549. t['grave'] = 333;
  49550. t['acute'] = 333;
  49551. t['circumflex'] = 333;
  49552. t['tilde'] = 333;
  49553. t['macron'] = 333;
  49554. t['breve'] = 333;
  49555. t['dotaccent'] = 333;
  49556. t['dieresis'] = 333;
  49557. t['ring'] = 333;
  49558. t['cedilla'] = 333;
  49559. t['hungarumlaut'] = 333;
  49560. t['ogonek'] = 333;
  49561. t['caron'] = 333;
  49562. t['emdash'] = 1000;
  49563. t['AE'] = 1000;
  49564. t['ordfeminine'] = 370;
  49565. t['Lslash'] = 556;
  49566. t['Oslash'] = 778;
  49567. t['OE'] = 1000;
  49568. t['ordmasculine'] = 365;
  49569. t['ae'] = 889;
  49570. t['dotlessi'] = 278;
  49571. t['lslash'] = 222;
  49572. t['oslash'] = 611;
  49573. t['oe'] = 944;
  49574. t['germandbls'] = 611;
  49575. t['Idieresis'] = 278;
  49576. t['eacute'] = 556;
  49577. t['abreve'] = 556;
  49578. t['uhungarumlaut'] = 556;
  49579. t['ecaron'] = 556;
  49580. t['Ydieresis'] = 667;
  49581. t['divide'] = 584;
  49582. t['Yacute'] = 667;
  49583. t['Acircumflex'] = 667;
  49584. t['aacute'] = 556;
  49585. t['Ucircumflex'] = 722;
  49586. t['yacute'] = 500;
  49587. t['scommaaccent'] = 500;
  49588. t['ecircumflex'] = 556;
  49589. t['Uring'] = 722;
  49590. t['Udieresis'] = 722;
  49591. t['aogonek'] = 556;
  49592. t['Uacute'] = 722;
  49593. t['uogonek'] = 556;
  49594. t['Edieresis'] = 667;
  49595. t['Dcroat'] = 722;
  49596. t['commaaccent'] = 250;
  49597. t['copyright'] = 737;
  49598. t['Emacron'] = 667;
  49599. t['ccaron'] = 500;
  49600. t['aring'] = 556;
  49601. t['Ncommaaccent'] = 722;
  49602. t['lacute'] = 222;
  49603. t['agrave'] = 556;
  49604. t['Tcommaaccent'] = 611;
  49605. t['Cacute'] = 722;
  49606. t['atilde'] = 556;
  49607. t['Edotaccent'] = 667;
  49608. t['scaron'] = 500;
  49609. t['scedilla'] = 500;
  49610. t['iacute'] = 278;
  49611. t['lozenge'] = 471;
  49612. t['Rcaron'] = 722;
  49613. t['Gcommaaccent'] = 778;
  49614. t['ucircumflex'] = 556;
  49615. t['acircumflex'] = 556;
  49616. t['Amacron'] = 667;
  49617. t['rcaron'] = 333;
  49618. t['ccedilla'] = 500;
  49619. t['Zdotaccent'] = 611;
  49620. t['Thorn'] = 667;
  49621. t['Omacron'] = 778;
  49622. t['Racute'] = 722;
  49623. t['Sacute'] = 667;
  49624. t['dcaron'] = 643;
  49625. t['Umacron'] = 722;
  49626. t['uring'] = 556;
  49627. t['threesuperior'] = 333;
  49628. t['Ograve'] = 778;
  49629. t['Agrave'] = 667;
  49630. t['Abreve'] = 667;
  49631. t['multiply'] = 584;
  49632. t['uacute'] = 556;
  49633. t['Tcaron'] = 611;
  49634. t['partialdiff'] = 476;
  49635. t['ydieresis'] = 500;
  49636. t['Nacute'] = 722;
  49637. t['icircumflex'] = 278;
  49638. t['Ecircumflex'] = 667;
  49639. t['adieresis'] = 556;
  49640. t['edieresis'] = 556;
  49641. t['cacute'] = 500;
  49642. t['nacute'] = 556;
  49643. t['umacron'] = 556;
  49644. t['Ncaron'] = 722;
  49645. t['Iacute'] = 278;
  49646. t['plusminus'] = 584;
  49647. t['brokenbar'] = 260;
  49648. t['registered'] = 737;
  49649. t['Gbreve'] = 778;
  49650. t['Idotaccent'] = 278;
  49651. t['summation'] = 600;
  49652. t['Egrave'] = 667;
  49653. t['racute'] = 333;
  49654. t['omacron'] = 556;
  49655. t['Zacute'] = 611;
  49656. t['Zcaron'] = 611;
  49657. t['greaterequal'] = 549;
  49658. t['Eth'] = 722;
  49659. t['Ccedilla'] = 722;
  49660. t['lcommaaccent'] = 222;
  49661. t['tcaron'] = 317;
  49662. t['eogonek'] = 556;
  49663. t['Uogonek'] = 722;
  49664. t['Aacute'] = 667;
  49665. t['Adieresis'] = 667;
  49666. t['egrave'] = 556;
  49667. t['zacute'] = 500;
  49668. t['iogonek'] = 222;
  49669. t['Oacute'] = 778;
  49670. t['oacute'] = 556;
  49671. t['amacron'] = 556;
  49672. t['sacute'] = 500;
  49673. t['idieresis'] = 278;
  49674. t['Ocircumflex'] = 778;
  49675. t['Ugrave'] = 722;
  49676. t['Delta'] = 612;
  49677. t['thorn'] = 556;
  49678. t['twosuperior'] = 333;
  49679. t['Odieresis'] = 778;
  49680. t['mu'] = 556;
  49681. t['igrave'] = 278;
  49682. t['ohungarumlaut'] = 556;
  49683. t['Eogonek'] = 667;
  49684. t['dcroat'] = 556;
  49685. t['threequarters'] = 834;
  49686. t['Scedilla'] = 667;
  49687. t['lcaron'] = 299;
  49688. t['Kcommaaccent'] = 667;
  49689. t['Lacute'] = 556;
  49690. t['trademark'] = 1000;
  49691. t['edotaccent'] = 556;
  49692. t['Igrave'] = 278;
  49693. t['Imacron'] = 278;
  49694. t['Lcaron'] = 556;
  49695. t['onehalf'] = 834;
  49696. t['lessequal'] = 549;
  49697. t['ocircumflex'] = 556;
  49698. t['ntilde'] = 556;
  49699. t['Uhungarumlaut'] = 722;
  49700. t['Eacute'] = 667;
  49701. t['emacron'] = 556;
  49702. t['gbreve'] = 556;
  49703. t['onequarter'] = 834;
  49704. t['Scaron'] = 667;
  49705. t['Scommaaccent'] = 667;
  49706. t['Ohungarumlaut'] = 778;
  49707. t['degree'] = 400;
  49708. t['ograve'] = 556;
  49709. t['Ccaron'] = 722;
  49710. t['ugrave'] = 556;
  49711. t['radical'] = 453;
  49712. t['Dcaron'] = 722;
  49713. t['rcommaaccent'] = 333;
  49714. t['Ntilde'] = 722;
  49715. t['otilde'] = 556;
  49716. t['Rcommaaccent'] = 722;
  49717. t['Lcommaaccent'] = 556;
  49718. t['Atilde'] = 667;
  49719. t['Aogonek'] = 667;
  49720. t['Aring'] = 667;
  49721. t['Otilde'] = 778;
  49722. t['zdotaccent'] = 500;
  49723. t['Ecaron'] = 667;
  49724. t['Iogonek'] = 278;
  49725. t['kcommaaccent'] = 500;
  49726. t['minus'] = 584;
  49727. t['Icircumflex'] = 278;
  49728. t['ncaron'] = 556;
  49729. t['tcommaaccent'] = 278;
  49730. t['logicalnot'] = 584;
  49731. t['odieresis'] = 556;
  49732. t['udieresis'] = 556;
  49733. t['notequal'] = 549;
  49734. t['gcommaaccent'] = 556;
  49735. t['eth'] = 556;
  49736. t['zcaron'] = 500;
  49737. t['ncommaaccent'] = 556;
  49738. t['onesuperior'] = 333;
  49739. t['imacron'] = 278;
  49740. t['Euro'] = 556;
  49741. });
  49742. t['Symbol'] = getLookupTableFactory(function (t) {
  49743. t['space'] = 250;
  49744. t['exclam'] = 333;
  49745. t['universal'] = 713;
  49746. t['numbersign'] = 500;
  49747. t['existential'] = 549;
  49748. t['percent'] = 833;
  49749. t['ampersand'] = 778;
  49750. t['suchthat'] = 439;
  49751. t['parenleft'] = 333;
  49752. t['parenright'] = 333;
  49753. t['asteriskmath'] = 500;
  49754. t['plus'] = 549;
  49755. t['comma'] = 250;
  49756. t['minus'] = 549;
  49757. t['period'] = 250;
  49758. t['slash'] = 278;
  49759. t['zero'] = 500;
  49760. t['one'] = 500;
  49761. t['two'] = 500;
  49762. t['three'] = 500;
  49763. t['four'] = 500;
  49764. t['five'] = 500;
  49765. t['six'] = 500;
  49766. t['seven'] = 500;
  49767. t['eight'] = 500;
  49768. t['nine'] = 500;
  49769. t['colon'] = 278;
  49770. t['semicolon'] = 278;
  49771. t['less'] = 549;
  49772. t['equal'] = 549;
  49773. t['greater'] = 549;
  49774. t['question'] = 444;
  49775. t['congruent'] = 549;
  49776. t['Alpha'] = 722;
  49777. t['Beta'] = 667;
  49778. t['Chi'] = 722;
  49779. t['Delta'] = 612;
  49780. t['Epsilon'] = 611;
  49781. t['Phi'] = 763;
  49782. t['Gamma'] = 603;
  49783. t['Eta'] = 722;
  49784. t['Iota'] = 333;
  49785. t['theta1'] = 631;
  49786. t['Kappa'] = 722;
  49787. t['Lambda'] = 686;
  49788. t['Mu'] = 889;
  49789. t['Nu'] = 722;
  49790. t['Omicron'] = 722;
  49791. t['Pi'] = 768;
  49792. t['Theta'] = 741;
  49793. t['Rho'] = 556;
  49794. t['Sigma'] = 592;
  49795. t['Tau'] = 611;
  49796. t['Upsilon'] = 690;
  49797. t['sigma1'] = 439;
  49798. t['Omega'] = 768;
  49799. t['Xi'] = 645;
  49800. t['Psi'] = 795;
  49801. t['Zeta'] = 611;
  49802. t['bracketleft'] = 333;
  49803. t['therefore'] = 863;
  49804. t['bracketright'] = 333;
  49805. t['perpendicular'] = 658;
  49806. t['underscore'] = 500;
  49807. t['radicalex'] = 500;
  49808. t['alpha'] = 631;
  49809. t['beta'] = 549;
  49810. t['chi'] = 549;
  49811. t['delta'] = 494;
  49812. t['epsilon'] = 439;
  49813. t['phi'] = 521;
  49814. t['gamma'] = 411;
  49815. t['eta'] = 603;
  49816. t['iota'] = 329;
  49817. t['phi1'] = 603;
  49818. t['kappa'] = 549;
  49819. t['lambda'] = 549;
  49820. t['mu'] = 576;
  49821. t['nu'] = 521;
  49822. t['omicron'] = 549;
  49823. t['pi'] = 549;
  49824. t['theta'] = 521;
  49825. t['rho'] = 549;
  49826. t['sigma'] = 603;
  49827. t['tau'] = 439;
  49828. t['upsilon'] = 576;
  49829. t['omega1'] = 713;
  49830. t['omega'] = 686;
  49831. t['xi'] = 493;
  49832. t['psi'] = 686;
  49833. t['zeta'] = 494;
  49834. t['braceleft'] = 480;
  49835. t['bar'] = 200;
  49836. t['braceright'] = 480;
  49837. t['similar'] = 549;
  49838. t['Euro'] = 750;
  49839. t['Upsilon1'] = 620;
  49840. t['minute'] = 247;
  49841. t['lessequal'] = 549;
  49842. t['fraction'] = 167;
  49843. t['infinity'] = 713;
  49844. t['florin'] = 500;
  49845. t['club'] = 753;
  49846. t['diamond'] = 753;
  49847. t['heart'] = 753;
  49848. t['spade'] = 753;
  49849. t['arrowboth'] = 1042;
  49850. t['arrowleft'] = 987;
  49851. t['arrowup'] = 603;
  49852. t['arrowright'] = 987;
  49853. t['arrowdown'] = 603;
  49854. t['degree'] = 400;
  49855. t['plusminus'] = 549;
  49856. t['second'] = 411;
  49857. t['greaterequal'] = 549;
  49858. t['multiply'] = 549;
  49859. t['proportional'] = 713;
  49860. t['partialdiff'] = 494;
  49861. t['bullet'] = 460;
  49862. t['divide'] = 549;
  49863. t['notequal'] = 549;
  49864. t['equivalence'] = 549;
  49865. t['approxequal'] = 549;
  49866. t['ellipsis'] = 1000;
  49867. t['arrowvertex'] = 603;
  49868. t['arrowhorizex'] = 1000;
  49869. t['carriagereturn'] = 658;
  49870. t['aleph'] = 823;
  49871. t['Ifraktur'] = 686;
  49872. t['Rfraktur'] = 795;
  49873. t['weierstrass'] = 987;
  49874. t['circlemultiply'] = 768;
  49875. t['circleplus'] = 768;
  49876. t['emptyset'] = 823;
  49877. t['intersection'] = 768;
  49878. t['union'] = 768;
  49879. t['propersuperset'] = 713;
  49880. t['reflexsuperset'] = 713;
  49881. t['notsubset'] = 713;
  49882. t['propersubset'] = 713;
  49883. t['reflexsubset'] = 713;
  49884. t['element'] = 713;
  49885. t['notelement'] = 713;
  49886. t['angle'] = 768;
  49887. t['gradient'] = 713;
  49888. t['registerserif'] = 790;
  49889. t['copyrightserif'] = 790;
  49890. t['trademarkserif'] = 890;
  49891. t['product'] = 823;
  49892. t['radical'] = 549;
  49893. t['dotmath'] = 250;
  49894. t['logicalnot'] = 713;
  49895. t['logicaland'] = 603;
  49896. t['logicalor'] = 603;
  49897. t['arrowdblboth'] = 1042;
  49898. t['arrowdblleft'] = 987;
  49899. t['arrowdblup'] = 603;
  49900. t['arrowdblright'] = 987;
  49901. t['arrowdbldown'] = 603;
  49902. t['lozenge'] = 494;
  49903. t['angleleft'] = 329;
  49904. t['registersans'] = 790;
  49905. t['copyrightsans'] = 790;
  49906. t['trademarksans'] = 786;
  49907. t['summation'] = 713;
  49908. t['parenlefttp'] = 384;
  49909. t['parenleftex'] = 384;
  49910. t['parenleftbt'] = 384;
  49911. t['bracketlefttp'] = 384;
  49912. t['bracketleftex'] = 384;
  49913. t['bracketleftbt'] = 384;
  49914. t['bracelefttp'] = 494;
  49915. t['braceleftmid'] = 494;
  49916. t['braceleftbt'] = 494;
  49917. t['braceex'] = 494;
  49918. t['angleright'] = 329;
  49919. t['integral'] = 274;
  49920. t['integraltp'] = 686;
  49921. t['integralex'] = 686;
  49922. t['integralbt'] = 686;
  49923. t['parenrighttp'] = 384;
  49924. t['parenrightex'] = 384;
  49925. t['parenrightbt'] = 384;
  49926. t['bracketrighttp'] = 384;
  49927. t['bracketrightex'] = 384;
  49928. t['bracketrightbt'] = 384;
  49929. t['bracerighttp'] = 494;
  49930. t['bracerightmid'] = 494;
  49931. t['bracerightbt'] = 494;
  49932. t['apple'] = 790;
  49933. });
  49934. t['Times-Roman'] = getLookupTableFactory(function (t) {
  49935. t['space'] = 250;
  49936. t['exclam'] = 333;
  49937. t['quotedbl'] = 408;
  49938. t['numbersign'] = 500;
  49939. t['dollar'] = 500;
  49940. t['percent'] = 833;
  49941. t['ampersand'] = 778;
  49942. t['quoteright'] = 333;
  49943. t['parenleft'] = 333;
  49944. t['parenright'] = 333;
  49945. t['asterisk'] = 500;
  49946. t['plus'] = 564;
  49947. t['comma'] = 250;
  49948. t['hyphen'] = 333;
  49949. t['period'] = 250;
  49950. t['slash'] = 278;
  49951. t['zero'] = 500;
  49952. t['one'] = 500;
  49953. t['two'] = 500;
  49954. t['three'] = 500;
  49955. t['four'] = 500;
  49956. t['five'] = 500;
  49957. t['six'] = 500;
  49958. t['seven'] = 500;
  49959. t['eight'] = 500;
  49960. t['nine'] = 500;
  49961. t['colon'] = 278;
  49962. t['semicolon'] = 278;
  49963. t['less'] = 564;
  49964. t['equal'] = 564;
  49965. t['greater'] = 564;
  49966. t['question'] = 444;
  49967. t['at'] = 921;
  49968. t['A'] = 722;
  49969. t['B'] = 667;
  49970. t['C'] = 667;
  49971. t['D'] = 722;
  49972. t['E'] = 611;
  49973. t['F'] = 556;
  49974. t['G'] = 722;
  49975. t['H'] = 722;
  49976. t['I'] = 333;
  49977. t['J'] = 389;
  49978. t['K'] = 722;
  49979. t['L'] = 611;
  49980. t['M'] = 889;
  49981. t['N'] = 722;
  49982. t['O'] = 722;
  49983. t['P'] = 556;
  49984. t['Q'] = 722;
  49985. t['R'] = 667;
  49986. t['S'] = 556;
  49987. t['T'] = 611;
  49988. t['U'] = 722;
  49989. t['V'] = 722;
  49990. t['W'] = 944;
  49991. t['X'] = 722;
  49992. t['Y'] = 722;
  49993. t['Z'] = 611;
  49994. t['bracketleft'] = 333;
  49995. t['backslash'] = 278;
  49996. t['bracketright'] = 333;
  49997. t['asciicircum'] = 469;
  49998. t['underscore'] = 500;
  49999. t['quoteleft'] = 333;
  50000. t['a'] = 444;
  50001. t['b'] = 500;
  50002. t['c'] = 444;
  50003. t['d'] = 500;
  50004. t['e'] = 444;
  50005. t['f'] = 333;
  50006. t['g'] = 500;
  50007. t['h'] = 500;
  50008. t['i'] = 278;
  50009. t['j'] = 278;
  50010. t['k'] = 500;
  50011. t['l'] = 278;
  50012. t['m'] = 778;
  50013. t['n'] = 500;
  50014. t['o'] = 500;
  50015. t['p'] = 500;
  50016. t['q'] = 500;
  50017. t['r'] = 333;
  50018. t['s'] = 389;
  50019. t['t'] = 278;
  50020. t['u'] = 500;
  50021. t['v'] = 500;
  50022. t['w'] = 722;
  50023. t['x'] = 500;
  50024. t['y'] = 500;
  50025. t['z'] = 444;
  50026. t['braceleft'] = 480;
  50027. t['bar'] = 200;
  50028. t['braceright'] = 480;
  50029. t['asciitilde'] = 541;
  50030. t['exclamdown'] = 333;
  50031. t['cent'] = 500;
  50032. t['sterling'] = 500;
  50033. t['fraction'] = 167;
  50034. t['yen'] = 500;
  50035. t['florin'] = 500;
  50036. t['section'] = 500;
  50037. t['currency'] = 500;
  50038. t['quotesingle'] = 180;
  50039. t['quotedblleft'] = 444;
  50040. t['guillemotleft'] = 500;
  50041. t['guilsinglleft'] = 333;
  50042. t['guilsinglright'] = 333;
  50043. t['fi'] = 556;
  50044. t['fl'] = 556;
  50045. t['endash'] = 500;
  50046. t['dagger'] = 500;
  50047. t['daggerdbl'] = 500;
  50048. t['periodcentered'] = 250;
  50049. t['paragraph'] = 453;
  50050. t['bullet'] = 350;
  50051. t['quotesinglbase'] = 333;
  50052. t['quotedblbase'] = 444;
  50053. t['quotedblright'] = 444;
  50054. t['guillemotright'] = 500;
  50055. t['ellipsis'] = 1000;
  50056. t['perthousand'] = 1000;
  50057. t['questiondown'] = 444;
  50058. t['grave'] = 333;
  50059. t['acute'] = 333;
  50060. t['circumflex'] = 333;
  50061. t['tilde'] = 333;
  50062. t['macron'] = 333;
  50063. t['breve'] = 333;
  50064. t['dotaccent'] = 333;
  50065. t['dieresis'] = 333;
  50066. t['ring'] = 333;
  50067. t['cedilla'] = 333;
  50068. t['hungarumlaut'] = 333;
  50069. t['ogonek'] = 333;
  50070. t['caron'] = 333;
  50071. t['emdash'] = 1000;
  50072. t['AE'] = 889;
  50073. t['ordfeminine'] = 276;
  50074. t['Lslash'] = 611;
  50075. t['Oslash'] = 722;
  50076. t['OE'] = 889;
  50077. t['ordmasculine'] = 310;
  50078. t['ae'] = 667;
  50079. t['dotlessi'] = 278;
  50080. t['lslash'] = 278;
  50081. t['oslash'] = 500;
  50082. t['oe'] = 722;
  50083. t['germandbls'] = 500;
  50084. t['Idieresis'] = 333;
  50085. t['eacute'] = 444;
  50086. t['abreve'] = 444;
  50087. t['uhungarumlaut'] = 500;
  50088. t['ecaron'] = 444;
  50089. t['Ydieresis'] = 722;
  50090. t['divide'] = 564;
  50091. t['Yacute'] = 722;
  50092. t['Acircumflex'] = 722;
  50093. t['aacute'] = 444;
  50094. t['Ucircumflex'] = 722;
  50095. t['yacute'] = 500;
  50096. t['scommaaccent'] = 389;
  50097. t['ecircumflex'] = 444;
  50098. t['Uring'] = 722;
  50099. t['Udieresis'] = 722;
  50100. t['aogonek'] = 444;
  50101. t['Uacute'] = 722;
  50102. t['uogonek'] = 500;
  50103. t['Edieresis'] = 611;
  50104. t['Dcroat'] = 722;
  50105. t['commaaccent'] = 250;
  50106. t['copyright'] = 760;
  50107. t['Emacron'] = 611;
  50108. t['ccaron'] = 444;
  50109. t['aring'] = 444;
  50110. t['Ncommaaccent'] = 722;
  50111. t['lacute'] = 278;
  50112. t['agrave'] = 444;
  50113. t['Tcommaaccent'] = 611;
  50114. t['Cacute'] = 667;
  50115. t['atilde'] = 444;
  50116. t['Edotaccent'] = 611;
  50117. t['scaron'] = 389;
  50118. t['scedilla'] = 389;
  50119. t['iacute'] = 278;
  50120. t['lozenge'] = 471;
  50121. t['Rcaron'] = 667;
  50122. t['Gcommaaccent'] = 722;
  50123. t['ucircumflex'] = 500;
  50124. t['acircumflex'] = 444;
  50125. t['Amacron'] = 722;
  50126. t['rcaron'] = 333;
  50127. t['ccedilla'] = 444;
  50128. t['Zdotaccent'] = 611;
  50129. t['Thorn'] = 556;
  50130. t['Omacron'] = 722;
  50131. t['Racute'] = 667;
  50132. t['Sacute'] = 556;
  50133. t['dcaron'] = 588;
  50134. t['Umacron'] = 722;
  50135. t['uring'] = 500;
  50136. t['threesuperior'] = 300;
  50137. t['Ograve'] = 722;
  50138. t['Agrave'] = 722;
  50139. t['Abreve'] = 722;
  50140. t['multiply'] = 564;
  50141. t['uacute'] = 500;
  50142. t['Tcaron'] = 611;
  50143. t['partialdiff'] = 476;
  50144. t['ydieresis'] = 500;
  50145. t['Nacute'] = 722;
  50146. t['icircumflex'] = 278;
  50147. t['Ecircumflex'] = 611;
  50148. t['adieresis'] = 444;
  50149. t['edieresis'] = 444;
  50150. t['cacute'] = 444;
  50151. t['nacute'] = 500;
  50152. t['umacron'] = 500;
  50153. t['Ncaron'] = 722;
  50154. t['Iacute'] = 333;
  50155. t['plusminus'] = 564;
  50156. t['brokenbar'] = 200;
  50157. t['registered'] = 760;
  50158. t['Gbreve'] = 722;
  50159. t['Idotaccent'] = 333;
  50160. t['summation'] = 600;
  50161. t['Egrave'] = 611;
  50162. t['racute'] = 333;
  50163. t['omacron'] = 500;
  50164. t['Zacute'] = 611;
  50165. t['Zcaron'] = 611;
  50166. t['greaterequal'] = 549;
  50167. t['Eth'] = 722;
  50168. t['Ccedilla'] = 667;
  50169. t['lcommaaccent'] = 278;
  50170. t['tcaron'] = 326;
  50171. t['eogonek'] = 444;
  50172. t['Uogonek'] = 722;
  50173. t['Aacute'] = 722;
  50174. t['Adieresis'] = 722;
  50175. t['egrave'] = 444;
  50176. t['zacute'] = 444;
  50177. t['iogonek'] = 278;
  50178. t['Oacute'] = 722;
  50179. t['oacute'] = 500;
  50180. t['amacron'] = 444;
  50181. t['sacute'] = 389;
  50182. t['idieresis'] = 278;
  50183. t['Ocircumflex'] = 722;
  50184. t['Ugrave'] = 722;
  50185. t['Delta'] = 612;
  50186. t['thorn'] = 500;
  50187. t['twosuperior'] = 300;
  50188. t['Odieresis'] = 722;
  50189. t['mu'] = 500;
  50190. t['igrave'] = 278;
  50191. t['ohungarumlaut'] = 500;
  50192. t['Eogonek'] = 611;
  50193. t['dcroat'] = 500;
  50194. t['threequarters'] = 750;
  50195. t['Scedilla'] = 556;
  50196. t['lcaron'] = 344;
  50197. t['Kcommaaccent'] = 722;
  50198. t['Lacute'] = 611;
  50199. t['trademark'] = 980;
  50200. t['edotaccent'] = 444;
  50201. t['Igrave'] = 333;
  50202. t['Imacron'] = 333;
  50203. t['Lcaron'] = 611;
  50204. t['onehalf'] = 750;
  50205. t['lessequal'] = 549;
  50206. t['ocircumflex'] = 500;
  50207. t['ntilde'] = 500;
  50208. t['Uhungarumlaut'] = 722;
  50209. t['Eacute'] = 611;
  50210. t['emacron'] = 444;
  50211. t['gbreve'] = 500;
  50212. t['onequarter'] = 750;
  50213. t['Scaron'] = 556;
  50214. t['Scommaaccent'] = 556;
  50215. t['Ohungarumlaut'] = 722;
  50216. t['degree'] = 400;
  50217. t['ograve'] = 500;
  50218. t['Ccaron'] = 667;
  50219. t['ugrave'] = 500;
  50220. t['radical'] = 453;
  50221. t['Dcaron'] = 722;
  50222. t['rcommaaccent'] = 333;
  50223. t['Ntilde'] = 722;
  50224. t['otilde'] = 500;
  50225. t['Rcommaaccent'] = 667;
  50226. t['Lcommaaccent'] = 611;
  50227. t['Atilde'] = 722;
  50228. t['Aogonek'] = 722;
  50229. t['Aring'] = 722;
  50230. t['Otilde'] = 722;
  50231. t['zdotaccent'] = 444;
  50232. t['Ecaron'] = 611;
  50233. t['Iogonek'] = 333;
  50234. t['kcommaaccent'] = 500;
  50235. t['minus'] = 564;
  50236. t['Icircumflex'] = 333;
  50237. t['ncaron'] = 500;
  50238. t['tcommaaccent'] = 278;
  50239. t['logicalnot'] = 564;
  50240. t['odieresis'] = 500;
  50241. t['udieresis'] = 500;
  50242. t['notequal'] = 549;
  50243. t['gcommaaccent'] = 500;
  50244. t['eth'] = 500;
  50245. t['zcaron'] = 444;
  50246. t['ncommaaccent'] = 500;
  50247. t['onesuperior'] = 300;
  50248. t['imacron'] = 278;
  50249. t['Euro'] = 500;
  50250. });
  50251. t['Times-Bold'] = getLookupTableFactory(function (t) {
  50252. t['space'] = 250;
  50253. t['exclam'] = 333;
  50254. t['quotedbl'] = 555;
  50255. t['numbersign'] = 500;
  50256. t['dollar'] = 500;
  50257. t['percent'] = 1000;
  50258. t['ampersand'] = 833;
  50259. t['quoteright'] = 333;
  50260. t['parenleft'] = 333;
  50261. t['parenright'] = 333;
  50262. t['asterisk'] = 500;
  50263. t['plus'] = 570;
  50264. t['comma'] = 250;
  50265. t['hyphen'] = 333;
  50266. t['period'] = 250;
  50267. t['slash'] = 278;
  50268. t['zero'] = 500;
  50269. t['one'] = 500;
  50270. t['two'] = 500;
  50271. t['three'] = 500;
  50272. t['four'] = 500;
  50273. t['five'] = 500;
  50274. t['six'] = 500;
  50275. t['seven'] = 500;
  50276. t['eight'] = 500;
  50277. t['nine'] = 500;
  50278. t['colon'] = 333;
  50279. t['semicolon'] = 333;
  50280. t['less'] = 570;
  50281. t['equal'] = 570;
  50282. t['greater'] = 570;
  50283. t['question'] = 500;
  50284. t['at'] = 930;
  50285. t['A'] = 722;
  50286. t['B'] = 667;
  50287. t['C'] = 722;
  50288. t['D'] = 722;
  50289. t['E'] = 667;
  50290. t['F'] = 611;
  50291. t['G'] = 778;
  50292. t['H'] = 778;
  50293. t['I'] = 389;
  50294. t['J'] = 500;
  50295. t['K'] = 778;
  50296. t['L'] = 667;
  50297. t['M'] = 944;
  50298. t['N'] = 722;
  50299. t['O'] = 778;
  50300. t['P'] = 611;
  50301. t['Q'] = 778;
  50302. t['R'] = 722;
  50303. t['S'] = 556;
  50304. t['T'] = 667;
  50305. t['U'] = 722;
  50306. t['V'] = 722;
  50307. t['W'] = 1000;
  50308. t['X'] = 722;
  50309. t['Y'] = 722;
  50310. t['Z'] = 667;
  50311. t['bracketleft'] = 333;
  50312. t['backslash'] = 278;
  50313. t['bracketright'] = 333;
  50314. t['asciicircum'] = 581;
  50315. t['underscore'] = 500;
  50316. t['quoteleft'] = 333;
  50317. t['a'] = 500;
  50318. t['b'] = 556;
  50319. t['c'] = 444;
  50320. t['d'] = 556;
  50321. t['e'] = 444;
  50322. t['f'] = 333;
  50323. t['g'] = 500;
  50324. t['h'] = 556;
  50325. t['i'] = 278;
  50326. t['j'] = 333;
  50327. t['k'] = 556;
  50328. t['l'] = 278;
  50329. t['m'] = 833;
  50330. t['n'] = 556;
  50331. t['o'] = 500;
  50332. t['p'] = 556;
  50333. t['q'] = 556;
  50334. t['r'] = 444;
  50335. t['s'] = 389;
  50336. t['t'] = 333;
  50337. t['u'] = 556;
  50338. t['v'] = 500;
  50339. t['w'] = 722;
  50340. t['x'] = 500;
  50341. t['y'] = 500;
  50342. t['z'] = 444;
  50343. t['braceleft'] = 394;
  50344. t['bar'] = 220;
  50345. t['braceright'] = 394;
  50346. t['asciitilde'] = 520;
  50347. t['exclamdown'] = 333;
  50348. t['cent'] = 500;
  50349. t['sterling'] = 500;
  50350. t['fraction'] = 167;
  50351. t['yen'] = 500;
  50352. t['florin'] = 500;
  50353. t['section'] = 500;
  50354. t['currency'] = 500;
  50355. t['quotesingle'] = 278;
  50356. t['quotedblleft'] = 500;
  50357. t['guillemotleft'] = 500;
  50358. t['guilsinglleft'] = 333;
  50359. t['guilsinglright'] = 333;
  50360. t['fi'] = 556;
  50361. t['fl'] = 556;
  50362. t['endash'] = 500;
  50363. t['dagger'] = 500;
  50364. t['daggerdbl'] = 500;
  50365. t['periodcentered'] = 250;
  50366. t['paragraph'] = 540;
  50367. t['bullet'] = 350;
  50368. t['quotesinglbase'] = 333;
  50369. t['quotedblbase'] = 500;
  50370. t['quotedblright'] = 500;
  50371. t['guillemotright'] = 500;
  50372. t['ellipsis'] = 1000;
  50373. t['perthousand'] = 1000;
  50374. t['questiondown'] = 500;
  50375. t['grave'] = 333;
  50376. t['acute'] = 333;
  50377. t['circumflex'] = 333;
  50378. t['tilde'] = 333;
  50379. t['macron'] = 333;
  50380. t['breve'] = 333;
  50381. t['dotaccent'] = 333;
  50382. t['dieresis'] = 333;
  50383. t['ring'] = 333;
  50384. t['cedilla'] = 333;
  50385. t['hungarumlaut'] = 333;
  50386. t['ogonek'] = 333;
  50387. t['caron'] = 333;
  50388. t['emdash'] = 1000;
  50389. t['AE'] = 1000;
  50390. t['ordfeminine'] = 300;
  50391. t['Lslash'] = 667;
  50392. t['Oslash'] = 778;
  50393. t['OE'] = 1000;
  50394. t['ordmasculine'] = 330;
  50395. t['ae'] = 722;
  50396. t['dotlessi'] = 278;
  50397. t['lslash'] = 278;
  50398. t['oslash'] = 500;
  50399. t['oe'] = 722;
  50400. t['germandbls'] = 556;
  50401. t['Idieresis'] = 389;
  50402. t['eacute'] = 444;
  50403. t['abreve'] = 500;
  50404. t['uhungarumlaut'] = 556;
  50405. t['ecaron'] = 444;
  50406. t['Ydieresis'] = 722;
  50407. t['divide'] = 570;
  50408. t['Yacute'] = 722;
  50409. t['Acircumflex'] = 722;
  50410. t['aacute'] = 500;
  50411. t['Ucircumflex'] = 722;
  50412. t['yacute'] = 500;
  50413. t['scommaaccent'] = 389;
  50414. t['ecircumflex'] = 444;
  50415. t['Uring'] = 722;
  50416. t['Udieresis'] = 722;
  50417. t['aogonek'] = 500;
  50418. t['Uacute'] = 722;
  50419. t['uogonek'] = 556;
  50420. t['Edieresis'] = 667;
  50421. t['Dcroat'] = 722;
  50422. t['commaaccent'] = 250;
  50423. t['copyright'] = 747;
  50424. t['Emacron'] = 667;
  50425. t['ccaron'] = 444;
  50426. t['aring'] = 500;
  50427. t['Ncommaaccent'] = 722;
  50428. t['lacute'] = 278;
  50429. t['agrave'] = 500;
  50430. t['Tcommaaccent'] = 667;
  50431. t['Cacute'] = 722;
  50432. t['atilde'] = 500;
  50433. t['Edotaccent'] = 667;
  50434. t['scaron'] = 389;
  50435. t['scedilla'] = 389;
  50436. t['iacute'] = 278;
  50437. t['lozenge'] = 494;
  50438. t['Rcaron'] = 722;
  50439. t['Gcommaaccent'] = 778;
  50440. t['ucircumflex'] = 556;
  50441. t['acircumflex'] = 500;
  50442. t['Amacron'] = 722;
  50443. t['rcaron'] = 444;
  50444. t['ccedilla'] = 444;
  50445. t['Zdotaccent'] = 667;
  50446. t['Thorn'] = 611;
  50447. t['Omacron'] = 778;
  50448. t['Racute'] = 722;
  50449. t['Sacute'] = 556;
  50450. t['dcaron'] = 672;
  50451. t['Umacron'] = 722;
  50452. t['uring'] = 556;
  50453. t['threesuperior'] = 300;
  50454. t['Ograve'] = 778;
  50455. t['Agrave'] = 722;
  50456. t['Abreve'] = 722;
  50457. t['multiply'] = 570;
  50458. t['uacute'] = 556;
  50459. t['Tcaron'] = 667;
  50460. t['partialdiff'] = 494;
  50461. t['ydieresis'] = 500;
  50462. t['Nacute'] = 722;
  50463. t['icircumflex'] = 278;
  50464. t['Ecircumflex'] = 667;
  50465. t['adieresis'] = 500;
  50466. t['edieresis'] = 444;
  50467. t['cacute'] = 444;
  50468. t['nacute'] = 556;
  50469. t['umacron'] = 556;
  50470. t['Ncaron'] = 722;
  50471. t['Iacute'] = 389;
  50472. t['plusminus'] = 570;
  50473. t['brokenbar'] = 220;
  50474. t['registered'] = 747;
  50475. t['Gbreve'] = 778;
  50476. t['Idotaccent'] = 389;
  50477. t['summation'] = 600;
  50478. t['Egrave'] = 667;
  50479. t['racute'] = 444;
  50480. t['omacron'] = 500;
  50481. t['Zacute'] = 667;
  50482. t['Zcaron'] = 667;
  50483. t['greaterequal'] = 549;
  50484. t['Eth'] = 722;
  50485. t['Ccedilla'] = 722;
  50486. t['lcommaaccent'] = 278;
  50487. t['tcaron'] = 416;
  50488. t['eogonek'] = 444;
  50489. t['Uogonek'] = 722;
  50490. t['Aacute'] = 722;
  50491. t['Adieresis'] = 722;
  50492. t['egrave'] = 444;
  50493. t['zacute'] = 444;
  50494. t['iogonek'] = 278;
  50495. t['Oacute'] = 778;
  50496. t['oacute'] = 500;
  50497. t['amacron'] = 500;
  50498. t['sacute'] = 389;
  50499. t['idieresis'] = 278;
  50500. t['Ocircumflex'] = 778;
  50501. t['Ugrave'] = 722;
  50502. t['Delta'] = 612;
  50503. t['thorn'] = 556;
  50504. t['twosuperior'] = 300;
  50505. t['Odieresis'] = 778;
  50506. t['mu'] = 556;
  50507. t['igrave'] = 278;
  50508. t['ohungarumlaut'] = 500;
  50509. t['Eogonek'] = 667;
  50510. t['dcroat'] = 556;
  50511. t['threequarters'] = 750;
  50512. t['Scedilla'] = 556;
  50513. t['lcaron'] = 394;
  50514. t['Kcommaaccent'] = 778;
  50515. t['Lacute'] = 667;
  50516. t['trademark'] = 1000;
  50517. t['edotaccent'] = 444;
  50518. t['Igrave'] = 389;
  50519. t['Imacron'] = 389;
  50520. t['Lcaron'] = 667;
  50521. t['onehalf'] = 750;
  50522. t['lessequal'] = 549;
  50523. t['ocircumflex'] = 500;
  50524. t['ntilde'] = 556;
  50525. t['Uhungarumlaut'] = 722;
  50526. t['Eacute'] = 667;
  50527. t['emacron'] = 444;
  50528. t['gbreve'] = 500;
  50529. t['onequarter'] = 750;
  50530. t['Scaron'] = 556;
  50531. t['Scommaaccent'] = 556;
  50532. t['Ohungarumlaut'] = 778;
  50533. t['degree'] = 400;
  50534. t['ograve'] = 500;
  50535. t['Ccaron'] = 722;
  50536. t['ugrave'] = 556;
  50537. t['radical'] = 549;
  50538. t['Dcaron'] = 722;
  50539. t['rcommaaccent'] = 444;
  50540. t['Ntilde'] = 722;
  50541. t['otilde'] = 500;
  50542. t['Rcommaaccent'] = 722;
  50543. t['Lcommaaccent'] = 667;
  50544. t['Atilde'] = 722;
  50545. t['Aogonek'] = 722;
  50546. t['Aring'] = 722;
  50547. t['Otilde'] = 778;
  50548. t['zdotaccent'] = 444;
  50549. t['Ecaron'] = 667;
  50550. t['Iogonek'] = 389;
  50551. t['kcommaaccent'] = 556;
  50552. t['minus'] = 570;
  50553. t['Icircumflex'] = 389;
  50554. t['ncaron'] = 556;
  50555. t['tcommaaccent'] = 333;
  50556. t['logicalnot'] = 570;
  50557. t['odieresis'] = 500;
  50558. t['udieresis'] = 556;
  50559. t['notequal'] = 549;
  50560. t['gcommaaccent'] = 500;
  50561. t['eth'] = 500;
  50562. t['zcaron'] = 444;
  50563. t['ncommaaccent'] = 556;
  50564. t['onesuperior'] = 300;
  50565. t['imacron'] = 278;
  50566. t['Euro'] = 500;
  50567. });
  50568. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  50569. t['space'] = 250;
  50570. t['exclam'] = 389;
  50571. t['quotedbl'] = 555;
  50572. t['numbersign'] = 500;
  50573. t['dollar'] = 500;
  50574. t['percent'] = 833;
  50575. t['ampersand'] = 778;
  50576. t['quoteright'] = 333;
  50577. t['parenleft'] = 333;
  50578. t['parenright'] = 333;
  50579. t['asterisk'] = 500;
  50580. t['plus'] = 570;
  50581. t['comma'] = 250;
  50582. t['hyphen'] = 333;
  50583. t['period'] = 250;
  50584. t['slash'] = 278;
  50585. t['zero'] = 500;
  50586. t['one'] = 500;
  50587. t['two'] = 500;
  50588. t['three'] = 500;
  50589. t['four'] = 500;
  50590. t['five'] = 500;
  50591. t['six'] = 500;
  50592. t['seven'] = 500;
  50593. t['eight'] = 500;
  50594. t['nine'] = 500;
  50595. t['colon'] = 333;
  50596. t['semicolon'] = 333;
  50597. t['less'] = 570;
  50598. t['equal'] = 570;
  50599. t['greater'] = 570;
  50600. t['question'] = 500;
  50601. t['at'] = 832;
  50602. t['A'] = 667;
  50603. t['B'] = 667;
  50604. t['C'] = 667;
  50605. t['D'] = 722;
  50606. t['E'] = 667;
  50607. t['F'] = 667;
  50608. t['G'] = 722;
  50609. t['H'] = 778;
  50610. t['I'] = 389;
  50611. t['J'] = 500;
  50612. t['K'] = 667;
  50613. t['L'] = 611;
  50614. t['M'] = 889;
  50615. t['N'] = 722;
  50616. t['O'] = 722;
  50617. t['P'] = 611;
  50618. t['Q'] = 722;
  50619. t['R'] = 667;
  50620. t['S'] = 556;
  50621. t['T'] = 611;
  50622. t['U'] = 722;
  50623. t['V'] = 667;
  50624. t['W'] = 889;
  50625. t['X'] = 667;
  50626. t['Y'] = 611;
  50627. t['Z'] = 611;
  50628. t['bracketleft'] = 333;
  50629. t['backslash'] = 278;
  50630. t['bracketright'] = 333;
  50631. t['asciicircum'] = 570;
  50632. t['underscore'] = 500;
  50633. t['quoteleft'] = 333;
  50634. t['a'] = 500;
  50635. t['b'] = 500;
  50636. t['c'] = 444;
  50637. t['d'] = 500;
  50638. t['e'] = 444;
  50639. t['f'] = 333;
  50640. t['g'] = 500;
  50641. t['h'] = 556;
  50642. t['i'] = 278;
  50643. t['j'] = 278;
  50644. t['k'] = 500;
  50645. t['l'] = 278;
  50646. t['m'] = 778;
  50647. t['n'] = 556;
  50648. t['o'] = 500;
  50649. t['p'] = 500;
  50650. t['q'] = 500;
  50651. t['r'] = 389;
  50652. t['s'] = 389;
  50653. t['t'] = 278;
  50654. t['u'] = 556;
  50655. t['v'] = 444;
  50656. t['w'] = 667;
  50657. t['x'] = 500;
  50658. t['y'] = 444;
  50659. t['z'] = 389;
  50660. t['braceleft'] = 348;
  50661. t['bar'] = 220;
  50662. t['braceright'] = 348;
  50663. t['asciitilde'] = 570;
  50664. t['exclamdown'] = 389;
  50665. t['cent'] = 500;
  50666. t['sterling'] = 500;
  50667. t['fraction'] = 167;
  50668. t['yen'] = 500;
  50669. t['florin'] = 500;
  50670. t['section'] = 500;
  50671. t['currency'] = 500;
  50672. t['quotesingle'] = 278;
  50673. t['quotedblleft'] = 500;
  50674. t['guillemotleft'] = 500;
  50675. t['guilsinglleft'] = 333;
  50676. t['guilsinglright'] = 333;
  50677. t['fi'] = 556;
  50678. t['fl'] = 556;
  50679. t['endash'] = 500;
  50680. t['dagger'] = 500;
  50681. t['daggerdbl'] = 500;
  50682. t['periodcentered'] = 250;
  50683. t['paragraph'] = 500;
  50684. t['bullet'] = 350;
  50685. t['quotesinglbase'] = 333;
  50686. t['quotedblbase'] = 500;
  50687. t['quotedblright'] = 500;
  50688. t['guillemotright'] = 500;
  50689. t['ellipsis'] = 1000;
  50690. t['perthousand'] = 1000;
  50691. t['questiondown'] = 500;
  50692. t['grave'] = 333;
  50693. t['acute'] = 333;
  50694. t['circumflex'] = 333;
  50695. t['tilde'] = 333;
  50696. t['macron'] = 333;
  50697. t['breve'] = 333;
  50698. t['dotaccent'] = 333;
  50699. t['dieresis'] = 333;
  50700. t['ring'] = 333;
  50701. t['cedilla'] = 333;
  50702. t['hungarumlaut'] = 333;
  50703. t['ogonek'] = 333;
  50704. t['caron'] = 333;
  50705. t['emdash'] = 1000;
  50706. t['AE'] = 944;
  50707. t['ordfeminine'] = 266;
  50708. t['Lslash'] = 611;
  50709. t['Oslash'] = 722;
  50710. t['OE'] = 944;
  50711. t['ordmasculine'] = 300;
  50712. t['ae'] = 722;
  50713. t['dotlessi'] = 278;
  50714. t['lslash'] = 278;
  50715. t['oslash'] = 500;
  50716. t['oe'] = 722;
  50717. t['germandbls'] = 500;
  50718. t['Idieresis'] = 389;
  50719. t['eacute'] = 444;
  50720. t['abreve'] = 500;
  50721. t['uhungarumlaut'] = 556;
  50722. t['ecaron'] = 444;
  50723. t['Ydieresis'] = 611;
  50724. t['divide'] = 570;
  50725. t['Yacute'] = 611;
  50726. t['Acircumflex'] = 667;
  50727. t['aacute'] = 500;
  50728. t['Ucircumflex'] = 722;
  50729. t['yacute'] = 444;
  50730. t['scommaaccent'] = 389;
  50731. t['ecircumflex'] = 444;
  50732. t['Uring'] = 722;
  50733. t['Udieresis'] = 722;
  50734. t['aogonek'] = 500;
  50735. t['Uacute'] = 722;
  50736. t['uogonek'] = 556;
  50737. t['Edieresis'] = 667;
  50738. t['Dcroat'] = 722;
  50739. t['commaaccent'] = 250;
  50740. t['copyright'] = 747;
  50741. t['Emacron'] = 667;
  50742. t['ccaron'] = 444;
  50743. t['aring'] = 500;
  50744. t['Ncommaaccent'] = 722;
  50745. t['lacute'] = 278;
  50746. t['agrave'] = 500;
  50747. t['Tcommaaccent'] = 611;
  50748. t['Cacute'] = 667;
  50749. t['atilde'] = 500;
  50750. t['Edotaccent'] = 667;
  50751. t['scaron'] = 389;
  50752. t['scedilla'] = 389;
  50753. t['iacute'] = 278;
  50754. t['lozenge'] = 494;
  50755. t['Rcaron'] = 667;
  50756. t['Gcommaaccent'] = 722;
  50757. t['ucircumflex'] = 556;
  50758. t['acircumflex'] = 500;
  50759. t['Amacron'] = 667;
  50760. t['rcaron'] = 389;
  50761. t['ccedilla'] = 444;
  50762. t['Zdotaccent'] = 611;
  50763. t['Thorn'] = 611;
  50764. t['Omacron'] = 722;
  50765. t['Racute'] = 667;
  50766. t['Sacute'] = 556;
  50767. t['dcaron'] = 608;
  50768. t['Umacron'] = 722;
  50769. t['uring'] = 556;
  50770. t['threesuperior'] = 300;
  50771. t['Ograve'] = 722;
  50772. t['Agrave'] = 667;
  50773. t['Abreve'] = 667;
  50774. t['multiply'] = 570;
  50775. t['uacute'] = 556;
  50776. t['Tcaron'] = 611;
  50777. t['partialdiff'] = 494;
  50778. t['ydieresis'] = 444;
  50779. t['Nacute'] = 722;
  50780. t['icircumflex'] = 278;
  50781. t['Ecircumflex'] = 667;
  50782. t['adieresis'] = 500;
  50783. t['edieresis'] = 444;
  50784. t['cacute'] = 444;
  50785. t['nacute'] = 556;
  50786. t['umacron'] = 556;
  50787. t['Ncaron'] = 722;
  50788. t['Iacute'] = 389;
  50789. t['plusminus'] = 570;
  50790. t['brokenbar'] = 220;
  50791. t['registered'] = 747;
  50792. t['Gbreve'] = 722;
  50793. t['Idotaccent'] = 389;
  50794. t['summation'] = 600;
  50795. t['Egrave'] = 667;
  50796. t['racute'] = 389;
  50797. t['omacron'] = 500;
  50798. t['Zacute'] = 611;
  50799. t['Zcaron'] = 611;
  50800. t['greaterequal'] = 549;
  50801. t['Eth'] = 722;
  50802. t['Ccedilla'] = 667;
  50803. t['lcommaaccent'] = 278;
  50804. t['tcaron'] = 366;
  50805. t['eogonek'] = 444;
  50806. t['Uogonek'] = 722;
  50807. t['Aacute'] = 667;
  50808. t['Adieresis'] = 667;
  50809. t['egrave'] = 444;
  50810. t['zacute'] = 389;
  50811. t['iogonek'] = 278;
  50812. t['Oacute'] = 722;
  50813. t['oacute'] = 500;
  50814. t['amacron'] = 500;
  50815. t['sacute'] = 389;
  50816. t['idieresis'] = 278;
  50817. t['Ocircumflex'] = 722;
  50818. t['Ugrave'] = 722;
  50819. t['Delta'] = 612;
  50820. t['thorn'] = 500;
  50821. t['twosuperior'] = 300;
  50822. t['Odieresis'] = 722;
  50823. t['mu'] = 576;
  50824. t['igrave'] = 278;
  50825. t['ohungarumlaut'] = 500;
  50826. t['Eogonek'] = 667;
  50827. t['dcroat'] = 500;
  50828. t['threequarters'] = 750;
  50829. t['Scedilla'] = 556;
  50830. t['lcaron'] = 382;
  50831. t['Kcommaaccent'] = 667;
  50832. t['Lacute'] = 611;
  50833. t['trademark'] = 1000;
  50834. t['edotaccent'] = 444;
  50835. t['Igrave'] = 389;
  50836. t['Imacron'] = 389;
  50837. t['Lcaron'] = 611;
  50838. t['onehalf'] = 750;
  50839. t['lessequal'] = 549;
  50840. t['ocircumflex'] = 500;
  50841. t['ntilde'] = 556;
  50842. t['Uhungarumlaut'] = 722;
  50843. t['Eacute'] = 667;
  50844. t['emacron'] = 444;
  50845. t['gbreve'] = 500;
  50846. t['onequarter'] = 750;
  50847. t['Scaron'] = 556;
  50848. t['Scommaaccent'] = 556;
  50849. t['Ohungarumlaut'] = 722;
  50850. t['degree'] = 400;
  50851. t['ograve'] = 500;
  50852. t['Ccaron'] = 667;
  50853. t['ugrave'] = 556;
  50854. t['radical'] = 549;
  50855. t['Dcaron'] = 722;
  50856. t['rcommaaccent'] = 389;
  50857. t['Ntilde'] = 722;
  50858. t['otilde'] = 500;
  50859. t['Rcommaaccent'] = 667;
  50860. t['Lcommaaccent'] = 611;
  50861. t['Atilde'] = 667;
  50862. t['Aogonek'] = 667;
  50863. t['Aring'] = 667;
  50864. t['Otilde'] = 722;
  50865. t['zdotaccent'] = 389;
  50866. t['Ecaron'] = 667;
  50867. t['Iogonek'] = 389;
  50868. t['kcommaaccent'] = 500;
  50869. t['minus'] = 606;
  50870. t['Icircumflex'] = 389;
  50871. t['ncaron'] = 556;
  50872. t['tcommaaccent'] = 278;
  50873. t['logicalnot'] = 606;
  50874. t['odieresis'] = 500;
  50875. t['udieresis'] = 556;
  50876. t['notequal'] = 549;
  50877. t['gcommaaccent'] = 500;
  50878. t['eth'] = 500;
  50879. t['zcaron'] = 389;
  50880. t['ncommaaccent'] = 556;
  50881. t['onesuperior'] = 300;
  50882. t['imacron'] = 278;
  50883. t['Euro'] = 500;
  50884. });
  50885. t['Times-Italic'] = getLookupTableFactory(function (t) {
  50886. t['space'] = 250;
  50887. t['exclam'] = 333;
  50888. t['quotedbl'] = 420;
  50889. t['numbersign'] = 500;
  50890. t['dollar'] = 500;
  50891. t['percent'] = 833;
  50892. t['ampersand'] = 778;
  50893. t['quoteright'] = 333;
  50894. t['parenleft'] = 333;
  50895. t['parenright'] = 333;
  50896. t['asterisk'] = 500;
  50897. t['plus'] = 675;
  50898. t['comma'] = 250;
  50899. t['hyphen'] = 333;
  50900. t['period'] = 250;
  50901. t['slash'] = 278;
  50902. t['zero'] = 500;
  50903. t['one'] = 500;
  50904. t['two'] = 500;
  50905. t['three'] = 500;
  50906. t['four'] = 500;
  50907. t['five'] = 500;
  50908. t['six'] = 500;
  50909. t['seven'] = 500;
  50910. t['eight'] = 500;
  50911. t['nine'] = 500;
  50912. t['colon'] = 333;
  50913. t['semicolon'] = 333;
  50914. t['less'] = 675;
  50915. t['equal'] = 675;
  50916. t['greater'] = 675;
  50917. t['question'] = 500;
  50918. t['at'] = 920;
  50919. t['A'] = 611;
  50920. t['B'] = 611;
  50921. t['C'] = 667;
  50922. t['D'] = 722;
  50923. t['E'] = 611;
  50924. t['F'] = 611;
  50925. t['G'] = 722;
  50926. t['H'] = 722;
  50927. t['I'] = 333;
  50928. t['J'] = 444;
  50929. t['K'] = 667;
  50930. t['L'] = 556;
  50931. t['M'] = 833;
  50932. t['N'] = 667;
  50933. t['O'] = 722;
  50934. t['P'] = 611;
  50935. t['Q'] = 722;
  50936. t['R'] = 611;
  50937. t['S'] = 500;
  50938. t['T'] = 556;
  50939. t['U'] = 722;
  50940. t['V'] = 611;
  50941. t['W'] = 833;
  50942. t['X'] = 611;
  50943. t['Y'] = 556;
  50944. t['Z'] = 556;
  50945. t['bracketleft'] = 389;
  50946. t['backslash'] = 278;
  50947. t['bracketright'] = 389;
  50948. t['asciicircum'] = 422;
  50949. t['underscore'] = 500;
  50950. t['quoteleft'] = 333;
  50951. t['a'] = 500;
  50952. t['b'] = 500;
  50953. t['c'] = 444;
  50954. t['d'] = 500;
  50955. t['e'] = 444;
  50956. t['f'] = 278;
  50957. t['g'] = 500;
  50958. t['h'] = 500;
  50959. t['i'] = 278;
  50960. t['j'] = 278;
  50961. t['k'] = 444;
  50962. t['l'] = 278;
  50963. t['m'] = 722;
  50964. t['n'] = 500;
  50965. t['o'] = 500;
  50966. t['p'] = 500;
  50967. t['q'] = 500;
  50968. t['r'] = 389;
  50969. t['s'] = 389;
  50970. t['t'] = 278;
  50971. t['u'] = 500;
  50972. t['v'] = 444;
  50973. t['w'] = 667;
  50974. t['x'] = 444;
  50975. t['y'] = 444;
  50976. t['z'] = 389;
  50977. t['braceleft'] = 400;
  50978. t['bar'] = 275;
  50979. t['braceright'] = 400;
  50980. t['asciitilde'] = 541;
  50981. t['exclamdown'] = 389;
  50982. t['cent'] = 500;
  50983. t['sterling'] = 500;
  50984. t['fraction'] = 167;
  50985. t['yen'] = 500;
  50986. t['florin'] = 500;
  50987. t['section'] = 500;
  50988. t['currency'] = 500;
  50989. t['quotesingle'] = 214;
  50990. t['quotedblleft'] = 556;
  50991. t['guillemotleft'] = 500;
  50992. t['guilsinglleft'] = 333;
  50993. t['guilsinglright'] = 333;
  50994. t['fi'] = 500;
  50995. t['fl'] = 500;
  50996. t['endash'] = 500;
  50997. t['dagger'] = 500;
  50998. t['daggerdbl'] = 500;
  50999. t['periodcentered'] = 250;
  51000. t['paragraph'] = 523;
  51001. t['bullet'] = 350;
  51002. t['quotesinglbase'] = 333;
  51003. t['quotedblbase'] = 556;
  51004. t['quotedblright'] = 556;
  51005. t['guillemotright'] = 500;
  51006. t['ellipsis'] = 889;
  51007. t['perthousand'] = 1000;
  51008. t['questiondown'] = 500;
  51009. t['grave'] = 333;
  51010. t['acute'] = 333;
  51011. t['circumflex'] = 333;
  51012. t['tilde'] = 333;
  51013. t['macron'] = 333;
  51014. t['breve'] = 333;
  51015. t['dotaccent'] = 333;
  51016. t['dieresis'] = 333;
  51017. t['ring'] = 333;
  51018. t['cedilla'] = 333;
  51019. t['hungarumlaut'] = 333;
  51020. t['ogonek'] = 333;
  51021. t['caron'] = 333;
  51022. t['emdash'] = 889;
  51023. t['AE'] = 889;
  51024. t['ordfeminine'] = 276;
  51025. t['Lslash'] = 556;
  51026. t['Oslash'] = 722;
  51027. t['OE'] = 944;
  51028. t['ordmasculine'] = 310;
  51029. t['ae'] = 667;
  51030. t['dotlessi'] = 278;
  51031. t['lslash'] = 278;
  51032. t['oslash'] = 500;
  51033. t['oe'] = 667;
  51034. t['germandbls'] = 500;
  51035. t['Idieresis'] = 333;
  51036. t['eacute'] = 444;
  51037. t['abreve'] = 500;
  51038. t['uhungarumlaut'] = 500;
  51039. t['ecaron'] = 444;
  51040. t['Ydieresis'] = 556;
  51041. t['divide'] = 675;
  51042. t['Yacute'] = 556;
  51043. t['Acircumflex'] = 611;
  51044. t['aacute'] = 500;
  51045. t['Ucircumflex'] = 722;
  51046. t['yacute'] = 444;
  51047. t['scommaaccent'] = 389;
  51048. t['ecircumflex'] = 444;
  51049. t['Uring'] = 722;
  51050. t['Udieresis'] = 722;
  51051. t['aogonek'] = 500;
  51052. t['Uacute'] = 722;
  51053. t['uogonek'] = 500;
  51054. t['Edieresis'] = 611;
  51055. t['Dcroat'] = 722;
  51056. t['commaaccent'] = 250;
  51057. t['copyright'] = 760;
  51058. t['Emacron'] = 611;
  51059. t['ccaron'] = 444;
  51060. t['aring'] = 500;
  51061. t['Ncommaaccent'] = 667;
  51062. t['lacute'] = 278;
  51063. t['agrave'] = 500;
  51064. t['Tcommaaccent'] = 556;
  51065. t['Cacute'] = 667;
  51066. t['atilde'] = 500;
  51067. t['Edotaccent'] = 611;
  51068. t['scaron'] = 389;
  51069. t['scedilla'] = 389;
  51070. t['iacute'] = 278;
  51071. t['lozenge'] = 471;
  51072. t['Rcaron'] = 611;
  51073. t['Gcommaaccent'] = 722;
  51074. t['ucircumflex'] = 500;
  51075. t['acircumflex'] = 500;
  51076. t['Amacron'] = 611;
  51077. t['rcaron'] = 389;
  51078. t['ccedilla'] = 444;
  51079. t['Zdotaccent'] = 556;
  51080. t['Thorn'] = 611;
  51081. t['Omacron'] = 722;
  51082. t['Racute'] = 611;
  51083. t['Sacute'] = 500;
  51084. t['dcaron'] = 544;
  51085. t['Umacron'] = 722;
  51086. t['uring'] = 500;
  51087. t['threesuperior'] = 300;
  51088. t['Ograve'] = 722;
  51089. t['Agrave'] = 611;
  51090. t['Abreve'] = 611;
  51091. t['multiply'] = 675;
  51092. t['uacute'] = 500;
  51093. t['Tcaron'] = 556;
  51094. t['partialdiff'] = 476;
  51095. t['ydieresis'] = 444;
  51096. t['Nacute'] = 667;
  51097. t['icircumflex'] = 278;
  51098. t['Ecircumflex'] = 611;
  51099. t['adieresis'] = 500;
  51100. t['edieresis'] = 444;
  51101. t['cacute'] = 444;
  51102. t['nacute'] = 500;
  51103. t['umacron'] = 500;
  51104. t['Ncaron'] = 667;
  51105. t['Iacute'] = 333;
  51106. t['plusminus'] = 675;
  51107. t['brokenbar'] = 275;
  51108. t['registered'] = 760;
  51109. t['Gbreve'] = 722;
  51110. t['Idotaccent'] = 333;
  51111. t['summation'] = 600;
  51112. t['Egrave'] = 611;
  51113. t['racute'] = 389;
  51114. t['omacron'] = 500;
  51115. t['Zacute'] = 556;
  51116. t['Zcaron'] = 556;
  51117. t['greaterequal'] = 549;
  51118. t['Eth'] = 722;
  51119. t['Ccedilla'] = 667;
  51120. t['lcommaaccent'] = 278;
  51121. t['tcaron'] = 300;
  51122. t['eogonek'] = 444;
  51123. t['Uogonek'] = 722;
  51124. t['Aacute'] = 611;
  51125. t['Adieresis'] = 611;
  51126. t['egrave'] = 444;
  51127. t['zacute'] = 389;
  51128. t['iogonek'] = 278;
  51129. t['Oacute'] = 722;
  51130. t['oacute'] = 500;
  51131. t['amacron'] = 500;
  51132. t['sacute'] = 389;
  51133. t['idieresis'] = 278;
  51134. t['Ocircumflex'] = 722;
  51135. t['Ugrave'] = 722;
  51136. t['Delta'] = 612;
  51137. t['thorn'] = 500;
  51138. t['twosuperior'] = 300;
  51139. t['Odieresis'] = 722;
  51140. t['mu'] = 500;
  51141. t['igrave'] = 278;
  51142. t['ohungarumlaut'] = 500;
  51143. t['Eogonek'] = 611;
  51144. t['dcroat'] = 500;
  51145. t['threequarters'] = 750;
  51146. t['Scedilla'] = 500;
  51147. t['lcaron'] = 300;
  51148. t['Kcommaaccent'] = 667;
  51149. t['Lacute'] = 556;
  51150. t['trademark'] = 980;
  51151. t['edotaccent'] = 444;
  51152. t['Igrave'] = 333;
  51153. t['Imacron'] = 333;
  51154. t['Lcaron'] = 611;
  51155. t['onehalf'] = 750;
  51156. t['lessequal'] = 549;
  51157. t['ocircumflex'] = 500;
  51158. t['ntilde'] = 500;
  51159. t['Uhungarumlaut'] = 722;
  51160. t['Eacute'] = 611;
  51161. t['emacron'] = 444;
  51162. t['gbreve'] = 500;
  51163. t['onequarter'] = 750;
  51164. t['Scaron'] = 500;
  51165. t['Scommaaccent'] = 500;
  51166. t['Ohungarumlaut'] = 722;
  51167. t['degree'] = 400;
  51168. t['ograve'] = 500;
  51169. t['Ccaron'] = 667;
  51170. t['ugrave'] = 500;
  51171. t['radical'] = 453;
  51172. t['Dcaron'] = 722;
  51173. t['rcommaaccent'] = 389;
  51174. t['Ntilde'] = 667;
  51175. t['otilde'] = 500;
  51176. t['Rcommaaccent'] = 611;
  51177. t['Lcommaaccent'] = 556;
  51178. t['Atilde'] = 611;
  51179. t['Aogonek'] = 611;
  51180. t['Aring'] = 611;
  51181. t['Otilde'] = 722;
  51182. t['zdotaccent'] = 389;
  51183. t['Ecaron'] = 611;
  51184. t['Iogonek'] = 333;
  51185. t['kcommaaccent'] = 444;
  51186. t['minus'] = 675;
  51187. t['Icircumflex'] = 333;
  51188. t['ncaron'] = 500;
  51189. t['tcommaaccent'] = 278;
  51190. t['logicalnot'] = 675;
  51191. t['odieresis'] = 500;
  51192. t['udieresis'] = 500;
  51193. t['notequal'] = 549;
  51194. t['gcommaaccent'] = 500;
  51195. t['eth'] = 500;
  51196. t['zcaron'] = 389;
  51197. t['ncommaaccent'] = 500;
  51198. t['onesuperior'] = 300;
  51199. t['imacron'] = 278;
  51200. t['Euro'] = 500;
  51201. });
  51202. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51203. t['space'] = 278;
  51204. t['a1'] = 974;
  51205. t['a2'] = 961;
  51206. t['a202'] = 974;
  51207. t['a3'] = 980;
  51208. t['a4'] = 719;
  51209. t['a5'] = 789;
  51210. t['a119'] = 790;
  51211. t['a118'] = 791;
  51212. t['a117'] = 690;
  51213. t['a11'] = 960;
  51214. t['a12'] = 939;
  51215. t['a13'] = 549;
  51216. t['a14'] = 855;
  51217. t['a15'] = 911;
  51218. t['a16'] = 933;
  51219. t['a105'] = 911;
  51220. t['a17'] = 945;
  51221. t['a18'] = 974;
  51222. t['a19'] = 755;
  51223. t['a20'] = 846;
  51224. t['a21'] = 762;
  51225. t['a22'] = 761;
  51226. t['a23'] = 571;
  51227. t['a24'] = 677;
  51228. t['a25'] = 763;
  51229. t['a26'] = 760;
  51230. t['a27'] = 759;
  51231. t['a28'] = 754;
  51232. t['a6'] = 494;
  51233. t['a7'] = 552;
  51234. t['a8'] = 537;
  51235. t['a9'] = 577;
  51236. t['a10'] = 692;
  51237. t['a29'] = 786;
  51238. t['a30'] = 788;
  51239. t['a31'] = 788;
  51240. t['a32'] = 790;
  51241. t['a33'] = 793;
  51242. t['a34'] = 794;
  51243. t['a35'] = 816;
  51244. t['a36'] = 823;
  51245. t['a37'] = 789;
  51246. t['a38'] = 841;
  51247. t['a39'] = 823;
  51248. t['a40'] = 833;
  51249. t['a41'] = 816;
  51250. t['a42'] = 831;
  51251. t['a43'] = 923;
  51252. t['a44'] = 744;
  51253. t['a45'] = 723;
  51254. t['a46'] = 749;
  51255. t['a47'] = 790;
  51256. t['a48'] = 792;
  51257. t['a49'] = 695;
  51258. t['a50'] = 776;
  51259. t['a51'] = 768;
  51260. t['a52'] = 792;
  51261. t['a53'] = 759;
  51262. t['a54'] = 707;
  51263. t['a55'] = 708;
  51264. t['a56'] = 682;
  51265. t['a57'] = 701;
  51266. t['a58'] = 826;
  51267. t['a59'] = 815;
  51268. t['a60'] = 789;
  51269. t['a61'] = 789;
  51270. t['a62'] = 707;
  51271. t['a63'] = 687;
  51272. t['a64'] = 696;
  51273. t['a65'] = 689;
  51274. t['a66'] = 786;
  51275. t['a67'] = 787;
  51276. t['a68'] = 713;
  51277. t['a69'] = 791;
  51278. t['a70'] = 785;
  51279. t['a71'] = 791;
  51280. t['a72'] = 873;
  51281. t['a73'] = 761;
  51282. t['a74'] = 762;
  51283. t['a203'] = 762;
  51284. t['a75'] = 759;
  51285. t['a204'] = 759;
  51286. t['a76'] = 892;
  51287. t['a77'] = 892;
  51288. t['a78'] = 788;
  51289. t['a79'] = 784;
  51290. t['a81'] = 438;
  51291. t['a82'] = 138;
  51292. t['a83'] = 277;
  51293. t['a84'] = 415;
  51294. t['a97'] = 392;
  51295. t['a98'] = 392;
  51296. t['a99'] = 668;
  51297. t['a100'] = 668;
  51298. t['a89'] = 390;
  51299. t['a90'] = 390;
  51300. t['a93'] = 317;
  51301. t['a94'] = 317;
  51302. t['a91'] = 276;
  51303. t['a92'] = 276;
  51304. t['a205'] = 509;
  51305. t['a85'] = 509;
  51306. t['a206'] = 410;
  51307. t['a86'] = 410;
  51308. t['a87'] = 234;
  51309. t['a88'] = 234;
  51310. t['a95'] = 334;
  51311. t['a96'] = 334;
  51312. t['a101'] = 732;
  51313. t['a102'] = 544;
  51314. t['a103'] = 544;
  51315. t['a104'] = 910;
  51316. t['a106'] = 667;
  51317. t['a107'] = 760;
  51318. t['a108'] = 760;
  51319. t['a112'] = 776;
  51320. t['a111'] = 595;
  51321. t['a110'] = 694;
  51322. t['a109'] = 626;
  51323. t['a120'] = 788;
  51324. t['a121'] = 788;
  51325. t['a122'] = 788;
  51326. t['a123'] = 788;
  51327. t['a124'] = 788;
  51328. t['a125'] = 788;
  51329. t['a126'] = 788;
  51330. t['a127'] = 788;
  51331. t['a128'] = 788;
  51332. t['a129'] = 788;
  51333. t['a130'] = 788;
  51334. t['a131'] = 788;
  51335. t['a132'] = 788;
  51336. t['a133'] = 788;
  51337. t['a134'] = 788;
  51338. t['a135'] = 788;
  51339. t['a136'] = 788;
  51340. t['a137'] = 788;
  51341. t['a138'] = 788;
  51342. t['a139'] = 788;
  51343. t['a140'] = 788;
  51344. t['a141'] = 788;
  51345. t['a142'] = 788;
  51346. t['a143'] = 788;
  51347. t['a144'] = 788;
  51348. t['a145'] = 788;
  51349. t['a146'] = 788;
  51350. t['a147'] = 788;
  51351. t['a148'] = 788;
  51352. t['a149'] = 788;
  51353. t['a150'] = 788;
  51354. t['a151'] = 788;
  51355. t['a152'] = 788;
  51356. t['a153'] = 788;
  51357. t['a154'] = 788;
  51358. t['a155'] = 788;
  51359. t['a156'] = 788;
  51360. t['a157'] = 788;
  51361. t['a158'] = 788;
  51362. t['a159'] = 788;
  51363. t['a160'] = 894;
  51364. t['a161'] = 838;
  51365. t['a163'] = 1016;
  51366. t['a164'] = 458;
  51367. t['a196'] = 748;
  51368. t['a165'] = 924;
  51369. t['a192'] = 748;
  51370. t['a166'] = 918;
  51371. t['a167'] = 927;
  51372. t['a168'] = 928;
  51373. t['a169'] = 928;
  51374. t['a170'] = 834;
  51375. t['a171'] = 873;
  51376. t['a172'] = 828;
  51377. t['a173'] = 924;
  51378. t['a162'] = 924;
  51379. t['a174'] = 917;
  51380. t['a175'] = 930;
  51381. t['a176'] = 931;
  51382. t['a177'] = 463;
  51383. t['a178'] = 883;
  51384. t['a179'] = 836;
  51385. t['a193'] = 836;
  51386. t['a180'] = 867;
  51387. t['a199'] = 867;
  51388. t['a181'] = 696;
  51389. t['a200'] = 696;
  51390. t['a182'] = 874;
  51391. t['a201'] = 874;
  51392. t['a183'] = 760;
  51393. t['a184'] = 946;
  51394. t['a197'] = 771;
  51395. t['a185'] = 865;
  51396. t['a194'] = 771;
  51397. t['a198'] = 888;
  51398. t['a186'] = 967;
  51399. t['a195'] = 888;
  51400. t['a187'] = 831;
  51401. t['a188'] = 873;
  51402. t['a189'] = 927;
  51403. t['a190'] = 970;
  51404. t['a191'] = 918;
  51405. });
  51406. });
  51407. exports.getMetrics = getMetrics;
  51408. /***/ }),
  51409. /* 38 */
  51410. /***/ (function(module, exports, __w_pdfjs_require__) {
  51411. "use strict";
  51412. var sharedUtil = __w_pdfjs_require__(0);
  51413. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  51414. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  51415. var MASK_HIGH = 0xffff0000;
  51416. var MASK_LOW = 0xffff;
  51417. function MurmurHash3_64(seed) {
  51418. var SEED = 0xc3d2e1f0;
  51419. this.h1 = seed ? seed & 0xffffffff : SEED;
  51420. this.h2 = seed ? seed & 0xffffffff : SEED;
  51421. }
  51422. var alwaysUseUint32ArrayView = false;
  51423. try {
  51424. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  51425. } catch (e) {
  51426. alwaysUseUint32ArrayView = true;
  51427. }
  51428. MurmurHash3_64.prototype = {
  51429. update: function MurmurHash3_64_update(input) {
  51430. var useUint32ArrayView = alwaysUseUint32ArrayView;
  51431. var i;
  51432. if (typeof input === 'string') {
  51433. var data = new Uint8Array(input.length * 2);
  51434. var length = 0;
  51435. for (i = 0; i < input.length; i++) {
  51436. var code = input.charCodeAt(i);
  51437. if (code <= 0xff) {
  51438. data[length++] = code;
  51439. } else {
  51440. data[length++] = code >>> 8;
  51441. data[length++] = code & 0xff;
  51442. }
  51443. }
  51444. } else if (input instanceof Uint8Array) {
  51445. data = input;
  51446. length = data.length;
  51447. } else if (typeof input === 'object' && 'length' in input) {
  51448. data = input;
  51449. length = data.length;
  51450. useUint32ArrayView = true;
  51451. } else {
  51452. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  51453. }
  51454. var blockCounts = length >> 2;
  51455. var tailLength = length - blockCounts * 4;
  51456. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  51457. var k1 = 0;
  51458. var k2 = 0;
  51459. var h1 = this.h1;
  51460. var h2 = this.h2;
  51461. var C1 = 0xcc9e2d51;
  51462. var C2 = 0x1b873593;
  51463. var C1_LOW = C1 & MASK_LOW;
  51464. var C2_LOW = C2 & MASK_LOW;
  51465. for (i = 0; i < blockCounts; i++) {
  51466. if (i & 1) {
  51467. k1 = dataUint32[i];
  51468. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51469. k1 = k1 << 15 | k1 >>> 17;
  51470. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51471. h1 ^= k1;
  51472. h1 = h1 << 13 | h1 >>> 19;
  51473. h1 = h1 * 5 + 0xe6546b64;
  51474. } else {
  51475. k2 = dataUint32[i];
  51476. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  51477. k2 = k2 << 15 | k2 >>> 17;
  51478. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  51479. h2 ^= k2;
  51480. h2 = h2 << 13 | h2 >>> 19;
  51481. h2 = h2 * 5 + 0xe6546b64;
  51482. }
  51483. }
  51484. k1 = 0;
  51485. switch (tailLength) {
  51486. case 3:
  51487. k1 ^= data[blockCounts * 4 + 2] << 16;
  51488. case 2:
  51489. k1 ^= data[blockCounts * 4 + 1] << 8;
  51490. case 1:
  51491. k1 ^= data[blockCounts * 4];
  51492. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51493. k1 = k1 << 15 | k1 >>> 17;
  51494. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51495. if (blockCounts & 1) {
  51496. h1 ^= k1;
  51497. } else {
  51498. h2 ^= k1;
  51499. }
  51500. }
  51501. this.h1 = h1;
  51502. this.h2 = h2;
  51503. return this;
  51504. },
  51505. hexdigest: function MurmurHash3_64_hexdigest() {
  51506. var h1 = this.h1;
  51507. var h2 = this.h2;
  51508. h1 ^= h2 >>> 1;
  51509. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  51510. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  51511. h1 ^= h2 >>> 1;
  51512. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  51513. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  51514. h1 ^= h2 >>> 1;
  51515. for (var i = 0, arr = [
  51516. h1,
  51517. h2
  51518. ], str = ''; i < arr.length; i++) {
  51519. var hex = (arr[i] >>> 0).toString(16);
  51520. while (hex.length < 8) {
  51521. hex = '0' + hex;
  51522. }
  51523. str += hex;
  51524. }
  51525. return str;
  51526. }
  51527. };
  51528. return MurmurHash3_64;
  51529. }();
  51530. exports.MurmurHash3_64 = MurmurHash3_64;
  51531. /***/ }),
  51532. /* 39 */
  51533. /***/ (function(module, exports, __w_pdfjs_require__) {
  51534. "use strict";
  51535. var sharedUtil = __w_pdfjs_require__(0);
  51536. var coreWorker = __w_pdfjs_require__(23);
  51537. var globalScope = sharedUtil.globalScope;
  51538. var OK_RESPONSE = 200;
  51539. var PARTIAL_CONTENT_RESPONSE = 206;
  51540. function NetworkManager(url, args) {
  51541. this.url = url;
  51542. args = args || {};
  51543. this.isHttp = /^https?:/i.test(url);
  51544. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  51545. this.withCredentials = args.withCredentials || false;
  51546. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  51547. return new XMLHttpRequest();
  51548. };
  51549. this.currXhrId = 0;
  51550. this.pendingRequests = Object.create(null);
  51551. this.loadedRequests = Object.create(null);
  51552. }
  51553. function getArrayBuffer(xhr) {
  51554. var data = xhr.response;
  51555. if (typeof data !== 'string') {
  51556. return data;
  51557. }
  51558. var length = data.length;
  51559. var array = new Uint8Array(length);
  51560. for (var i = 0; i < length; i++) {
  51561. array[i] = data.charCodeAt(i) & 0xFF;
  51562. }
  51563. return array.buffer;
  51564. }
  51565. var supportsMozChunked = function supportsMozChunkedClosure() {
  51566. try {
  51567. var x = new XMLHttpRequest();
  51568. x.open('GET', globalScope.location.href);
  51569. x.responseType = 'moz-chunked-arraybuffer';
  51570. return x.responseType === 'moz-chunked-arraybuffer';
  51571. } catch (e) {
  51572. return false;
  51573. }
  51574. }();
  51575. NetworkManager.prototype = {
  51576. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  51577. var args = {
  51578. begin: begin,
  51579. end: end
  51580. };
  51581. for (var prop in listeners) {
  51582. args[prop] = listeners[prop];
  51583. }
  51584. return this.request(args);
  51585. },
  51586. requestFull: function NetworkManager_requestFull(listeners) {
  51587. return this.request(listeners);
  51588. },
  51589. request: function NetworkManager_request(args) {
  51590. var xhr = this.getXhr();
  51591. var xhrId = this.currXhrId++;
  51592. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  51593. xhr.open('GET', this.url);
  51594. xhr.withCredentials = this.withCredentials;
  51595. for (var property in this.httpHeaders) {
  51596. var value = this.httpHeaders[property];
  51597. if (typeof value === 'undefined') {
  51598. continue;
  51599. }
  51600. xhr.setRequestHeader(property, value);
  51601. }
  51602. if (this.isHttp && 'begin' in args && 'end' in args) {
  51603. var rangeStr = args.begin + '-' + (args.end - 1);
  51604. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  51605. pendingRequest.expectedStatus = 206;
  51606. } else {
  51607. pendingRequest.expectedStatus = 200;
  51608. }
  51609. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  51610. if (useMozChunkedLoading) {
  51611. xhr.responseType = 'moz-chunked-arraybuffer';
  51612. pendingRequest.onProgressiveData = args.onProgressiveData;
  51613. pendingRequest.mozChunked = true;
  51614. } else {
  51615. xhr.responseType = 'arraybuffer';
  51616. }
  51617. if (args.onError) {
  51618. xhr.onerror = function (evt) {
  51619. args.onError(xhr.status);
  51620. };
  51621. }
  51622. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  51623. xhr.onprogress = this.onProgress.bind(this, xhrId);
  51624. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  51625. pendingRequest.onDone = args.onDone;
  51626. pendingRequest.onError = args.onError;
  51627. pendingRequest.onProgress = args.onProgress;
  51628. xhr.send(null);
  51629. return xhrId;
  51630. },
  51631. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  51632. var pendingRequest = this.pendingRequests[xhrId];
  51633. if (!pendingRequest) {
  51634. return;
  51635. }
  51636. if (pendingRequest.mozChunked) {
  51637. var chunk = getArrayBuffer(pendingRequest.xhr);
  51638. pendingRequest.onProgressiveData(chunk);
  51639. }
  51640. var onProgress = pendingRequest.onProgress;
  51641. if (onProgress) {
  51642. onProgress(evt);
  51643. }
  51644. },
  51645. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  51646. var pendingRequest = this.pendingRequests[xhrId];
  51647. if (!pendingRequest) {
  51648. return;
  51649. }
  51650. var xhr = pendingRequest.xhr;
  51651. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  51652. pendingRequest.onHeadersReceived();
  51653. delete pendingRequest.onHeadersReceived;
  51654. }
  51655. if (xhr.readyState !== 4) {
  51656. return;
  51657. }
  51658. if (!(xhrId in this.pendingRequests)) {
  51659. return;
  51660. }
  51661. delete this.pendingRequests[xhrId];
  51662. if (xhr.status === 0 && this.isHttp) {
  51663. if (pendingRequest.onError) {
  51664. pendingRequest.onError(xhr.status);
  51665. }
  51666. return;
  51667. }
  51668. var xhrStatus = xhr.status || OK_RESPONSE;
  51669. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  51670. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  51671. if (pendingRequest.onError) {
  51672. pendingRequest.onError(xhr.status);
  51673. }
  51674. return;
  51675. }
  51676. this.loadedRequests[xhrId] = true;
  51677. var chunk = getArrayBuffer(xhr);
  51678. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  51679. var rangeHeader = xhr.getResponseHeader('Content-Range');
  51680. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  51681. var begin = parseInt(matches[1], 10);
  51682. pendingRequest.onDone({
  51683. begin: begin,
  51684. chunk: chunk
  51685. });
  51686. } else if (pendingRequest.onProgressiveData) {
  51687. pendingRequest.onDone(null);
  51688. } else if (chunk) {
  51689. pendingRequest.onDone({
  51690. begin: 0,
  51691. chunk: chunk
  51692. });
  51693. } else if (pendingRequest.onError) {
  51694. pendingRequest.onError(xhr.status);
  51695. }
  51696. },
  51697. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  51698. for (var xhrId in this.pendingRequests) {
  51699. return true;
  51700. }
  51701. return false;
  51702. },
  51703. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  51704. return this.pendingRequests[xhrId].xhr;
  51705. },
  51706. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  51707. return !!this.pendingRequests[xhrId].onProgressiveData;
  51708. },
  51709. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  51710. return xhrId in this.pendingRequests;
  51711. },
  51712. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  51713. return xhrId in this.loadedRequests;
  51714. },
  51715. abortAllRequests: function NetworkManager_abortAllRequests() {
  51716. for (var xhrId in this.pendingRequests) {
  51717. this.abortRequest(xhrId | 0);
  51718. }
  51719. },
  51720. abortRequest: function NetworkManager_abortRequest(xhrId) {
  51721. var xhr = this.pendingRequests[xhrId].xhr;
  51722. delete this.pendingRequests[xhrId];
  51723. xhr.abort();
  51724. }
  51725. };
  51726. var assert = sharedUtil.assert;
  51727. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51728. var isInt = sharedUtil.isInt;
  51729. var MissingPDFException = sharedUtil.MissingPDFException;
  51730. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  51731. function PDFNetworkStream(options) {
  51732. this._options = options;
  51733. var source = options.source;
  51734. this._manager = new NetworkManager(source.url, {
  51735. httpHeaders: source.httpHeaders,
  51736. withCredentials: source.withCredentials
  51737. });
  51738. this._rangeChunkSize = source.rangeChunkSize;
  51739. this._fullRequestReader = null;
  51740. this._rangeRequestReaders = [];
  51741. }
  51742. PDFNetworkStream.prototype = {
  51743. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  51744. var i = this._rangeRequestReaders.indexOf(reader);
  51745. if (i >= 0) {
  51746. this._rangeRequestReaders.splice(i, 1);
  51747. }
  51748. },
  51749. getFullReader: function PDFNetworkStream_getFullReader() {
  51750. assert(!this._fullRequestReader);
  51751. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  51752. return this._fullRequestReader;
  51753. },
  51754. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  51755. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  51756. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  51757. this._rangeRequestReaders.push(reader);
  51758. return reader;
  51759. },
  51760. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  51761. if (this._fullRequestReader) {
  51762. this._fullRequestReader.cancel(reason);
  51763. }
  51764. var readers = this._rangeRequestReaders.slice(0);
  51765. readers.forEach(function (reader) {
  51766. reader.cancel(reason);
  51767. });
  51768. }
  51769. };
  51770. function PDFNetworkStreamFullRequestReader(manager, options) {
  51771. this._manager = manager;
  51772. var source = options.source;
  51773. var args = {
  51774. onHeadersReceived: this._onHeadersReceived.bind(this),
  51775. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  51776. onDone: this._onDone.bind(this),
  51777. onError: this._onError.bind(this),
  51778. onProgress: this._onProgress.bind(this)
  51779. };
  51780. this._url = source.url;
  51781. this._fullRequestId = manager.requestFull(args);
  51782. this._headersReceivedCapability = createPromiseCapability();
  51783. this._disableRange = options.disableRange || false;
  51784. this._contentLength = source.length;
  51785. this._rangeChunkSize = source.rangeChunkSize;
  51786. if (!this._rangeChunkSize && !this._disableRange) {
  51787. this._disableRange = true;
  51788. }
  51789. this._isStreamingSupported = false;
  51790. this._isRangeSupported = false;
  51791. this._cachedChunks = [];
  51792. this._requests = [];
  51793. this._done = false;
  51794. this._storedError = undefined;
  51795. this.onProgress = null;
  51796. }
  51797. PDFNetworkStreamFullRequestReader.prototype = {
  51798. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  51799. if (this._disableRange) {
  51800. return false;
  51801. }
  51802. var networkManager = this._manager;
  51803. if (!networkManager.isHttp) {
  51804. return false;
  51805. }
  51806. var fullRequestXhrId = this._fullRequestId;
  51807. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  51808. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  51809. return false;
  51810. }
  51811. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  51812. if (contentEncoding !== 'identity') {
  51813. return false;
  51814. }
  51815. var length = fullRequestXhr.getResponseHeader('Content-Length');
  51816. length = parseInt(length, 10);
  51817. if (!isInt(length)) {
  51818. return false;
  51819. }
  51820. this._contentLength = length;
  51821. if (length <= 2 * this._rangeChunkSize) {
  51822. return false;
  51823. }
  51824. return true;
  51825. },
  51826. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  51827. if (this._validateRangeRequestCapabilities()) {
  51828. this._isRangeSupported = true;
  51829. }
  51830. var networkManager = this._manager;
  51831. var fullRequestXhrId = this._fullRequestId;
  51832. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  51833. this._isStreamingSupported = true;
  51834. } else if (this._isRangeSupported) {
  51835. networkManager.abortRequest(fullRequestXhrId);
  51836. }
  51837. this._headersReceivedCapability.resolve();
  51838. },
  51839. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  51840. if (this._requests.length > 0) {
  51841. var requestCapability = this._requests.shift();
  51842. requestCapability.resolve({
  51843. value: chunk,
  51844. done: false
  51845. });
  51846. } else {
  51847. this._cachedChunks.push(chunk);
  51848. }
  51849. },
  51850. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  51851. if (args) {
  51852. this._onProgressiveData(args.chunk);
  51853. }
  51854. this._done = true;
  51855. if (this._cachedChunks.length > 0) {
  51856. return;
  51857. }
  51858. this._requests.forEach(function (requestCapability) {
  51859. requestCapability.resolve({
  51860. value: undefined,
  51861. done: true
  51862. });
  51863. });
  51864. this._requests = [];
  51865. },
  51866. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  51867. var url = this._url;
  51868. var exception;
  51869. if (status === 404 || status === 0 && /^file:/.test(url)) {
  51870. exception = new MissingPDFException('Missing PDF "' + url + '".');
  51871. } else {
  51872. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  51873. }
  51874. this._storedError = exception;
  51875. this._headersReceivedCapability.reject(exception);
  51876. this._requests.forEach(function (requestCapability) {
  51877. requestCapability.reject(exception);
  51878. });
  51879. this._requests = [];
  51880. this._cachedChunks = [];
  51881. },
  51882. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  51883. if (this.onProgress) {
  51884. this.onProgress({
  51885. loaded: data.loaded,
  51886. total: data.lengthComputable ? data.total : this._contentLength
  51887. });
  51888. }
  51889. },
  51890. get isRangeSupported() {
  51891. return this._isRangeSupported;
  51892. },
  51893. get isStreamingSupported() {
  51894. return this._isStreamingSupported;
  51895. },
  51896. get contentLength() {
  51897. return this._contentLength;
  51898. },
  51899. get headersReady() {
  51900. return this._headersReceivedCapability.promise;
  51901. },
  51902. read: function PDFNetworkStreamFullRequestReader_read() {
  51903. if (this._storedError) {
  51904. return Promise.reject(this._storedError);
  51905. }
  51906. if (this._cachedChunks.length > 0) {
  51907. var chunk = this._cachedChunks.shift();
  51908. return Promise.resolve(chunk);
  51909. }
  51910. if (this._done) {
  51911. return Promise.resolve({
  51912. value: undefined,
  51913. done: true
  51914. });
  51915. }
  51916. var requestCapability = createPromiseCapability();
  51917. this._requests.push(requestCapability);
  51918. return requestCapability.promise;
  51919. },
  51920. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  51921. this._done = true;
  51922. this._headersReceivedCapability.reject(reason);
  51923. this._requests.forEach(function (requestCapability) {
  51924. requestCapability.resolve({
  51925. value: undefined,
  51926. done: true
  51927. });
  51928. });
  51929. this._requests = [];
  51930. if (this._manager.isPendingRequest(this._fullRequestId)) {
  51931. this._manager.abortRequest(this._fullRequestId);
  51932. }
  51933. this._fullRequestReader = null;
  51934. }
  51935. };
  51936. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  51937. this._manager = manager;
  51938. var args = {
  51939. onDone: this._onDone.bind(this),
  51940. onProgress: this._onProgress.bind(this)
  51941. };
  51942. this._requestId = manager.requestRange(begin, end, args);
  51943. this._requests = [];
  51944. this._queuedChunk = null;
  51945. this._done = false;
  51946. this.onProgress = null;
  51947. this.onClosed = null;
  51948. }
  51949. PDFNetworkStreamRangeRequestReader.prototype = {
  51950. _close: function PDFNetworkStreamRangeRequestReader_close() {
  51951. if (this.onClosed) {
  51952. this.onClosed(this);
  51953. }
  51954. },
  51955. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  51956. var chunk = data.chunk;
  51957. if (this._requests.length > 0) {
  51958. var requestCapability = this._requests.shift();
  51959. requestCapability.resolve({
  51960. value: chunk,
  51961. done: false
  51962. });
  51963. } else {
  51964. this._queuedChunk = chunk;
  51965. }
  51966. this._done = true;
  51967. this._requests.forEach(function (requestCapability) {
  51968. requestCapability.resolve({
  51969. value: undefined,
  51970. done: true
  51971. });
  51972. });
  51973. this._requests = [];
  51974. this._close();
  51975. },
  51976. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  51977. if (!this.isStreamingSupported && this.onProgress) {
  51978. this.onProgress({ loaded: evt.loaded });
  51979. }
  51980. },
  51981. get isStreamingSupported() {
  51982. return false;
  51983. },
  51984. read: function PDFNetworkStreamRangeRequestReader_read() {
  51985. if (this._queuedChunk !== null) {
  51986. var chunk = this._queuedChunk;
  51987. this._queuedChunk = null;
  51988. return Promise.resolve({
  51989. value: chunk,
  51990. done: false
  51991. });
  51992. }
  51993. if (this._done) {
  51994. return Promise.resolve({
  51995. value: undefined,
  51996. done: true
  51997. });
  51998. }
  51999. var requestCapability = createPromiseCapability();
  52000. this._requests.push(requestCapability);
  52001. return requestCapability.promise;
  52002. },
  52003. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52004. this._done = true;
  52005. this._requests.forEach(function (requestCapability) {
  52006. requestCapability.resolve({
  52007. value: undefined,
  52008. done: true
  52009. });
  52010. });
  52011. this._requests = [];
  52012. if (this._manager.isPendingRequest(this._requestId)) {
  52013. this._manager.abortRequest(this._requestId);
  52014. }
  52015. this._close();
  52016. }
  52017. };
  52018. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52019. exports.PDFNetworkStream = PDFNetworkStream;
  52020. exports.NetworkManager = NetworkManager;
  52021. /***/ }),
  52022. /* 40 */
  52023. /***/ (function(module, exports, __w_pdfjs_require__) {
  52024. "use strict";
  52025. var sharedUtil = __w_pdfjs_require__(0);
  52026. var corePrimitives = __w_pdfjs_require__(1);
  52027. var coreFunction = __w_pdfjs_require__(7);
  52028. var coreColorSpace = __w_pdfjs_require__(4);
  52029. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52030. var MissingDataException = sharedUtil.MissingDataException;
  52031. var Util = sharedUtil.Util;
  52032. var assert = sharedUtil.assert;
  52033. var error = sharedUtil.error;
  52034. var info = sharedUtil.info;
  52035. var warn = sharedUtil.warn;
  52036. var isStream = corePrimitives.isStream;
  52037. var PDFFunction = coreFunction.PDFFunction;
  52038. var ColorSpace = coreColorSpace.ColorSpace;
  52039. var ShadingType = {
  52040. FUNCTION_BASED: 1,
  52041. AXIAL: 2,
  52042. RADIAL: 3,
  52043. FREE_FORM_MESH: 4,
  52044. LATTICE_FORM_MESH: 5,
  52045. COONS_PATCH_MESH: 6,
  52046. TENSOR_PATCH_MESH: 7
  52047. };
  52048. var Pattern = function PatternClosure() {
  52049. function Pattern() {
  52050. error('should not call Pattern constructor');
  52051. }
  52052. Pattern.prototype = {
  52053. getPattern: function Pattern_getPattern(ctx) {
  52054. error('Should not call Pattern.getStyle: ' + ctx);
  52055. }
  52056. };
  52057. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52058. var dict = isStream(shading) ? shading.dict : shading;
  52059. var type = dict.get('ShadingType');
  52060. try {
  52061. switch (type) {
  52062. case ShadingType.AXIAL:
  52063. case ShadingType.RADIAL:
  52064. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52065. case ShadingType.FREE_FORM_MESH:
  52066. case ShadingType.LATTICE_FORM_MESH:
  52067. case ShadingType.COONS_PATCH_MESH:
  52068. case ShadingType.TENSOR_PATCH_MESH:
  52069. return new Shadings.Mesh(shading, matrix, xref, res);
  52070. default:
  52071. throw new Error('Unsupported ShadingType: ' + type);
  52072. }
  52073. } catch (ex) {
  52074. if (ex instanceof MissingDataException) {
  52075. throw ex;
  52076. }
  52077. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52078. warn(ex);
  52079. return new Shadings.Dummy();
  52080. }
  52081. };
  52082. return Pattern;
  52083. }();
  52084. var Shadings = {};
  52085. Shadings.SMALL_NUMBER = 1e-6;
  52086. Shadings.RadialAxial = function RadialAxialClosure() {
  52087. function RadialAxial(dict, matrix, xref, res) {
  52088. this.matrix = matrix;
  52089. this.coordsArr = dict.getArray('Coords');
  52090. this.shadingType = dict.get('ShadingType');
  52091. this.type = 'Pattern';
  52092. var cs = dict.get('ColorSpace', 'CS');
  52093. cs = ColorSpace.parse(cs, xref, res);
  52094. this.cs = cs;
  52095. var t0 = 0.0, t1 = 1.0;
  52096. if (dict.has('Domain')) {
  52097. var domainArr = dict.getArray('Domain');
  52098. t0 = domainArr[0];
  52099. t1 = domainArr[1];
  52100. }
  52101. var extendStart = false, extendEnd = false;
  52102. if (dict.has('Extend')) {
  52103. var extendArr = dict.getArray('Extend');
  52104. extendStart = extendArr[0];
  52105. extendEnd = extendArr[1];
  52106. }
  52107. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52108. var x1 = this.coordsArr[0];
  52109. var y1 = this.coordsArr[1];
  52110. var r1 = this.coordsArr[2];
  52111. var x2 = this.coordsArr[3];
  52112. var y2 = this.coordsArr[4];
  52113. var r2 = this.coordsArr[5];
  52114. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52115. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52116. warn('Unsupported radial gradient.');
  52117. }
  52118. }
  52119. this.extendStart = extendStart;
  52120. this.extendEnd = extendEnd;
  52121. var fnObj = dict.get('Function');
  52122. var fn = PDFFunction.parseArray(xref, fnObj);
  52123. var diff = t1 - t0;
  52124. var step = diff / 10;
  52125. var colorStops = this.colorStops = [];
  52126. if (t0 >= t1 || step <= 0) {
  52127. info('Bad shading domain.');
  52128. return;
  52129. }
  52130. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52131. var rgbColor;
  52132. for (var i = t0; i <= t1; i += step) {
  52133. ratio[0] = i;
  52134. fn(ratio, 0, color, 0);
  52135. rgbColor = cs.getRgb(color, 0);
  52136. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52137. colorStops.push([
  52138. (i - t0) / diff,
  52139. cssColor
  52140. ]);
  52141. }
  52142. var background = 'transparent';
  52143. if (dict.has('Background')) {
  52144. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52145. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52146. }
  52147. if (!extendStart) {
  52148. colorStops.unshift([
  52149. 0,
  52150. background
  52151. ]);
  52152. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52153. }
  52154. if (!extendEnd) {
  52155. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52156. colorStops.push([
  52157. 1,
  52158. background
  52159. ]);
  52160. }
  52161. this.colorStops = colorStops;
  52162. }
  52163. RadialAxial.prototype = {
  52164. getIR: function RadialAxial_getIR() {
  52165. var coordsArr = this.coordsArr;
  52166. var shadingType = this.shadingType;
  52167. var type, p0, p1, r0, r1;
  52168. if (shadingType === ShadingType.AXIAL) {
  52169. p0 = [
  52170. coordsArr[0],
  52171. coordsArr[1]
  52172. ];
  52173. p1 = [
  52174. coordsArr[2],
  52175. coordsArr[3]
  52176. ];
  52177. r0 = null;
  52178. r1 = null;
  52179. type = 'axial';
  52180. } else if (shadingType === ShadingType.RADIAL) {
  52181. p0 = [
  52182. coordsArr[0],
  52183. coordsArr[1]
  52184. ];
  52185. p1 = [
  52186. coordsArr[3],
  52187. coordsArr[4]
  52188. ];
  52189. r0 = coordsArr[2];
  52190. r1 = coordsArr[5];
  52191. type = 'radial';
  52192. } else {
  52193. error('getPattern type unknown: ' + shadingType);
  52194. }
  52195. var matrix = this.matrix;
  52196. if (matrix) {
  52197. p0 = Util.applyTransform(p0, matrix);
  52198. p1 = Util.applyTransform(p1, matrix);
  52199. if (shadingType === ShadingType.RADIAL) {
  52200. var scale = Util.singularValueDecompose2dScale(matrix);
  52201. r0 *= scale[0];
  52202. r1 *= scale[1];
  52203. }
  52204. }
  52205. return [
  52206. 'RadialAxial',
  52207. type,
  52208. this.colorStops,
  52209. p0,
  52210. p1,
  52211. r0,
  52212. r1
  52213. ];
  52214. }
  52215. };
  52216. return RadialAxial;
  52217. }();
  52218. Shadings.Mesh = function MeshClosure() {
  52219. function MeshStreamReader(stream, context) {
  52220. this.stream = stream;
  52221. this.context = context;
  52222. this.buffer = 0;
  52223. this.bufferLength = 0;
  52224. var numComps = context.numComps;
  52225. this.tmpCompsBuf = new Float32Array(numComps);
  52226. var csNumComps = context.colorSpace.numComps;
  52227. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  52228. }
  52229. MeshStreamReader.prototype = {
  52230. get hasData() {
  52231. if (this.stream.end) {
  52232. return this.stream.pos < this.stream.end;
  52233. }
  52234. if (this.bufferLength > 0) {
  52235. return true;
  52236. }
  52237. var nextByte = this.stream.getByte();
  52238. if (nextByte < 0) {
  52239. return false;
  52240. }
  52241. this.buffer = nextByte;
  52242. this.bufferLength = 8;
  52243. return true;
  52244. },
  52245. readBits: function MeshStreamReader_readBits(n) {
  52246. var buffer = this.buffer;
  52247. var bufferLength = this.bufferLength;
  52248. if (n === 32) {
  52249. if (bufferLength === 0) {
  52250. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  52251. }
  52252. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  52253. var nextByte = this.stream.getByte();
  52254. this.buffer = nextByte & (1 << bufferLength) - 1;
  52255. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  52256. }
  52257. if (n === 8 && bufferLength === 0) {
  52258. return this.stream.getByte();
  52259. }
  52260. while (bufferLength < n) {
  52261. buffer = buffer << 8 | this.stream.getByte();
  52262. bufferLength += 8;
  52263. }
  52264. bufferLength -= n;
  52265. this.bufferLength = bufferLength;
  52266. this.buffer = buffer & (1 << bufferLength) - 1;
  52267. return buffer >> bufferLength;
  52268. },
  52269. align: function MeshStreamReader_align() {
  52270. this.buffer = 0;
  52271. this.bufferLength = 0;
  52272. },
  52273. readFlag: function MeshStreamReader_readFlag() {
  52274. return this.readBits(this.context.bitsPerFlag);
  52275. },
  52276. readCoordinate: function MeshStreamReader_readCoordinate() {
  52277. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  52278. var xi = this.readBits(bitsPerCoordinate);
  52279. var yi = this.readBits(bitsPerCoordinate);
  52280. var decode = this.context.decode;
  52281. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  52282. return [
  52283. xi * scale * (decode[1] - decode[0]) + decode[0],
  52284. yi * scale * (decode[3] - decode[2]) + decode[2]
  52285. ];
  52286. },
  52287. readComponents: function MeshStreamReader_readComponents() {
  52288. var numComps = this.context.numComps;
  52289. var bitsPerComponent = this.context.bitsPerComponent;
  52290. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  52291. var decode = this.context.decode;
  52292. var components = this.tmpCompsBuf;
  52293. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  52294. var ci = this.readBits(bitsPerComponent);
  52295. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  52296. }
  52297. var color = this.tmpCsCompsBuf;
  52298. if (this.context.colorFn) {
  52299. this.context.colorFn(components, 0, color, 0);
  52300. }
  52301. return this.context.colorSpace.getRgb(color, 0);
  52302. }
  52303. };
  52304. function decodeType4Shading(mesh, reader) {
  52305. var coords = mesh.coords;
  52306. var colors = mesh.colors;
  52307. var operators = [];
  52308. var ps = [];
  52309. var verticesLeft = 0;
  52310. while (reader.hasData) {
  52311. var f = reader.readFlag();
  52312. var coord = reader.readCoordinate();
  52313. var color = reader.readComponents();
  52314. if (verticesLeft === 0) {
  52315. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  52316. switch (f) {
  52317. case 0:
  52318. verticesLeft = 3;
  52319. break;
  52320. case 1:
  52321. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  52322. verticesLeft = 1;
  52323. break;
  52324. case 2:
  52325. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  52326. verticesLeft = 1;
  52327. break;
  52328. }
  52329. operators.push(f);
  52330. }
  52331. ps.push(coords.length);
  52332. coords.push(coord);
  52333. colors.push(color);
  52334. verticesLeft--;
  52335. reader.align();
  52336. }
  52337. mesh.figures.push({
  52338. type: 'triangles',
  52339. coords: new Int32Array(ps),
  52340. colors: new Int32Array(ps)
  52341. });
  52342. }
  52343. function decodeType5Shading(mesh, reader, verticesPerRow) {
  52344. var coords = mesh.coords;
  52345. var colors = mesh.colors;
  52346. var ps = [];
  52347. while (reader.hasData) {
  52348. var coord = reader.readCoordinate();
  52349. var color = reader.readComponents();
  52350. ps.push(coords.length);
  52351. coords.push(coord);
  52352. colors.push(color);
  52353. }
  52354. mesh.figures.push({
  52355. type: 'lattice',
  52356. coords: new Int32Array(ps),
  52357. colors: new Int32Array(ps),
  52358. verticesPerRow: verticesPerRow
  52359. });
  52360. }
  52361. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  52362. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  52363. var TRIANGLE_DENSITY = 20;
  52364. var getB = function getBClosure() {
  52365. function buildB(count) {
  52366. var lut = [];
  52367. for (var i = 0; i <= count; i++) {
  52368. var t = i / count, t_ = 1 - t;
  52369. lut.push(new Float32Array([
  52370. t_ * t_ * t_,
  52371. 3 * t * t_ * t_,
  52372. 3 * t * t * t_,
  52373. t * t * t
  52374. ]));
  52375. }
  52376. return lut;
  52377. }
  52378. var cache = [];
  52379. return function getB(count) {
  52380. if (!cache[count]) {
  52381. cache[count] = buildB(count);
  52382. }
  52383. return cache[count];
  52384. };
  52385. }();
  52386. function buildFigureFromPatch(mesh, index) {
  52387. var figure = mesh.figures[index];
  52388. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  52389. var coords = mesh.coords, colors = mesh.colors;
  52390. var pi = figure.coords;
  52391. var ci = figure.colors;
  52392. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52393. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52394. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52395. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52396. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  52397. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  52398. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  52399. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  52400. var verticesPerRow = splitXBy + 1;
  52401. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  52402. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  52403. var k = 0;
  52404. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  52405. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  52406. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  52407. for (var row = 0; row <= splitYBy; row++) {
  52408. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  52409. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  52410. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  52411. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  52412. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  52413. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  52414. for (var col = 0; col <= splitXBy; col++, k++) {
  52415. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  52416. continue;
  52417. }
  52418. var x = 0, y = 0;
  52419. var q = 0;
  52420. for (var i = 0; i <= 3; i++) {
  52421. for (var j = 0; j <= 3; j++, q++) {
  52422. var m = bRow[row][i] * bCol[col][j];
  52423. x += coords[pi[q]][0] * m;
  52424. y += coords[pi[q]][1] * m;
  52425. }
  52426. }
  52427. figureCoords[k] = coords.length;
  52428. coords.push([
  52429. x,
  52430. y
  52431. ]);
  52432. figureColors[k] = colors.length;
  52433. var newColor = new Uint8Array(3);
  52434. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  52435. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  52436. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  52437. colors.push(newColor);
  52438. }
  52439. }
  52440. figureCoords[0] = pi[0];
  52441. figureColors[0] = ci[0];
  52442. figureCoords[splitXBy] = pi[3];
  52443. figureColors[splitXBy] = ci[1];
  52444. figureCoords[verticesPerRow * splitYBy] = pi[12];
  52445. figureColors[verticesPerRow * splitYBy] = ci[2];
  52446. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  52447. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  52448. mesh.figures[index] = {
  52449. type: 'lattice',
  52450. coords: figureCoords,
  52451. colors: figureColors,
  52452. verticesPerRow: verticesPerRow
  52453. };
  52454. }
  52455. function decodeType6Shading(mesh, reader) {
  52456. var coords = mesh.coords;
  52457. var colors = mesh.colors;
  52458. var ps = new Int32Array(16);
  52459. var cs = new Int32Array(4);
  52460. while (reader.hasData) {
  52461. var f = reader.readFlag();
  52462. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  52463. var i, ii;
  52464. var pi = coords.length;
  52465. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  52466. coords.push(reader.readCoordinate());
  52467. }
  52468. var ci = colors.length;
  52469. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52470. colors.push(reader.readComponents());
  52471. }
  52472. var tmp1, tmp2, tmp3, tmp4;
  52473. switch (f) {
  52474. case 0:
  52475. ps[12] = pi + 3;
  52476. ps[13] = pi + 4;
  52477. ps[14] = pi + 5;
  52478. ps[15] = pi + 6;
  52479. ps[8] = pi + 2;
  52480. ps[11] = pi + 7;
  52481. ps[4] = pi + 1;
  52482. ps[7] = pi + 8;
  52483. ps[0] = pi;
  52484. ps[1] = pi + 11;
  52485. ps[2] = pi + 10;
  52486. ps[3] = pi + 9;
  52487. cs[2] = ci + 1;
  52488. cs[3] = ci + 2;
  52489. cs[0] = ci;
  52490. cs[1] = ci + 3;
  52491. break;
  52492. case 1:
  52493. tmp1 = ps[12];
  52494. tmp2 = ps[13];
  52495. tmp3 = ps[14];
  52496. tmp4 = ps[15];
  52497. ps[12] = tmp4;
  52498. ps[13] = pi + 0;
  52499. ps[14] = pi + 1;
  52500. ps[15] = pi + 2;
  52501. ps[8] = tmp3;
  52502. ps[11] = pi + 3;
  52503. ps[4] = tmp2;
  52504. ps[7] = pi + 4;
  52505. ps[0] = tmp1;
  52506. ps[1] = pi + 7;
  52507. ps[2] = pi + 6;
  52508. ps[3] = pi + 5;
  52509. tmp1 = cs[2];
  52510. tmp2 = cs[3];
  52511. cs[2] = tmp2;
  52512. cs[3] = ci;
  52513. cs[0] = tmp1;
  52514. cs[1] = ci + 1;
  52515. break;
  52516. case 2:
  52517. tmp1 = ps[15];
  52518. tmp2 = ps[11];
  52519. ps[12] = ps[3];
  52520. ps[13] = pi + 0;
  52521. ps[14] = pi + 1;
  52522. ps[15] = pi + 2;
  52523. ps[8] = ps[7];
  52524. ps[11] = pi + 3;
  52525. ps[4] = tmp2;
  52526. ps[7] = pi + 4;
  52527. ps[0] = tmp1;
  52528. ps[1] = pi + 7;
  52529. ps[2] = pi + 6;
  52530. ps[3] = pi + 5;
  52531. tmp1 = cs[3];
  52532. cs[2] = cs[1];
  52533. cs[3] = ci;
  52534. cs[0] = tmp1;
  52535. cs[1] = ci + 1;
  52536. break;
  52537. case 3:
  52538. ps[12] = ps[0];
  52539. ps[13] = pi + 0;
  52540. ps[14] = pi + 1;
  52541. ps[15] = pi + 2;
  52542. ps[8] = ps[1];
  52543. ps[11] = pi + 3;
  52544. ps[4] = ps[2];
  52545. ps[7] = pi + 4;
  52546. ps[0] = ps[3];
  52547. ps[1] = pi + 7;
  52548. ps[2] = pi + 6;
  52549. ps[3] = pi + 5;
  52550. cs[2] = cs[0];
  52551. cs[3] = ci;
  52552. cs[0] = cs[1];
  52553. cs[1] = ci + 1;
  52554. break;
  52555. }
  52556. ps[5] = coords.length;
  52557. coords.push([
  52558. (-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,
  52559. (-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
  52560. ]);
  52561. ps[6] = coords.length;
  52562. coords.push([
  52563. (-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,
  52564. (-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
  52565. ]);
  52566. ps[9] = coords.length;
  52567. coords.push([
  52568. (-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,
  52569. (-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
  52570. ]);
  52571. ps[10] = coords.length;
  52572. coords.push([
  52573. (-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,
  52574. (-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
  52575. ]);
  52576. mesh.figures.push({
  52577. type: 'patch',
  52578. coords: new Int32Array(ps),
  52579. colors: new Int32Array(cs)
  52580. });
  52581. }
  52582. }
  52583. function decodeType7Shading(mesh, reader) {
  52584. var coords = mesh.coords;
  52585. var colors = mesh.colors;
  52586. var ps = new Int32Array(16);
  52587. var cs = new Int32Array(4);
  52588. while (reader.hasData) {
  52589. var f = reader.readFlag();
  52590. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  52591. var i, ii;
  52592. var pi = coords.length;
  52593. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  52594. coords.push(reader.readCoordinate());
  52595. }
  52596. var ci = colors.length;
  52597. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52598. colors.push(reader.readComponents());
  52599. }
  52600. var tmp1, tmp2, tmp3, tmp4;
  52601. switch (f) {
  52602. case 0:
  52603. ps[12] = pi + 3;
  52604. ps[13] = pi + 4;
  52605. ps[14] = pi + 5;
  52606. ps[15] = pi + 6;
  52607. ps[8] = pi + 2;
  52608. ps[9] = pi + 13;
  52609. ps[10] = pi + 14;
  52610. ps[11] = pi + 7;
  52611. ps[4] = pi + 1;
  52612. ps[5] = pi + 12;
  52613. ps[6] = pi + 15;
  52614. ps[7] = pi + 8;
  52615. ps[0] = pi;
  52616. ps[1] = pi + 11;
  52617. ps[2] = pi + 10;
  52618. ps[3] = pi + 9;
  52619. cs[2] = ci + 1;
  52620. cs[3] = ci + 2;
  52621. cs[0] = ci;
  52622. cs[1] = ci + 3;
  52623. break;
  52624. case 1:
  52625. tmp1 = ps[12];
  52626. tmp2 = ps[13];
  52627. tmp3 = ps[14];
  52628. tmp4 = ps[15];
  52629. ps[12] = tmp4;
  52630. ps[13] = pi + 0;
  52631. ps[14] = pi + 1;
  52632. ps[15] = pi + 2;
  52633. ps[8] = tmp3;
  52634. ps[9] = pi + 9;
  52635. ps[10] = pi + 10;
  52636. ps[11] = pi + 3;
  52637. ps[4] = tmp2;
  52638. ps[5] = pi + 8;
  52639. ps[6] = pi + 11;
  52640. ps[7] = pi + 4;
  52641. ps[0] = tmp1;
  52642. ps[1] = pi + 7;
  52643. ps[2] = pi + 6;
  52644. ps[3] = pi + 5;
  52645. tmp1 = cs[2];
  52646. tmp2 = cs[3];
  52647. cs[2] = tmp2;
  52648. cs[3] = ci;
  52649. cs[0] = tmp1;
  52650. cs[1] = ci + 1;
  52651. break;
  52652. case 2:
  52653. tmp1 = ps[15];
  52654. tmp2 = ps[11];
  52655. ps[12] = ps[3];
  52656. ps[13] = pi + 0;
  52657. ps[14] = pi + 1;
  52658. ps[15] = pi + 2;
  52659. ps[8] = ps[7];
  52660. ps[9] = pi + 9;
  52661. ps[10] = pi + 10;
  52662. ps[11] = pi + 3;
  52663. ps[4] = tmp2;
  52664. ps[5] = pi + 8;
  52665. ps[6] = pi + 11;
  52666. ps[7] = pi + 4;
  52667. ps[0] = tmp1;
  52668. ps[1] = pi + 7;
  52669. ps[2] = pi + 6;
  52670. ps[3] = pi + 5;
  52671. tmp1 = cs[3];
  52672. cs[2] = cs[1];
  52673. cs[3] = ci;
  52674. cs[0] = tmp1;
  52675. cs[1] = ci + 1;
  52676. break;
  52677. case 3:
  52678. ps[12] = ps[0];
  52679. ps[13] = pi + 0;
  52680. ps[14] = pi + 1;
  52681. ps[15] = pi + 2;
  52682. ps[8] = ps[1];
  52683. ps[9] = pi + 9;
  52684. ps[10] = pi + 10;
  52685. ps[11] = pi + 3;
  52686. ps[4] = ps[2];
  52687. ps[5] = pi + 8;
  52688. ps[6] = pi + 11;
  52689. ps[7] = pi + 4;
  52690. ps[0] = ps[3];
  52691. ps[1] = pi + 7;
  52692. ps[2] = pi + 6;
  52693. ps[3] = pi + 5;
  52694. cs[2] = cs[0];
  52695. cs[3] = ci;
  52696. cs[0] = cs[1];
  52697. cs[1] = ci + 1;
  52698. break;
  52699. }
  52700. mesh.figures.push({
  52701. type: 'patch',
  52702. coords: new Int32Array(ps),
  52703. colors: new Int32Array(cs)
  52704. });
  52705. }
  52706. }
  52707. function updateBounds(mesh) {
  52708. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  52709. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  52710. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  52711. minX = minX > x ? x : minX;
  52712. minY = minY > y ? y : minY;
  52713. maxX = maxX < x ? x : maxX;
  52714. maxY = maxY < y ? y : maxY;
  52715. }
  52716. mesh.bounds = [
  52717. minX,
  52718. minY,
  52719. maxX,
  52720. maxY
  52721. ];
  52722. }
  52723. function packData(mesh) {
  52724. var i, ii, j, jj;
  52725. var coords = mesh.coords;
  52726. var coordsPacked = new Float32Array(coords.length * 2);
  52727. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  52728. var xy = coords[i];
  52729. coordsPacked[j++] = xy[0];
  52730. coordsPacked[j++] = xy[1];
  52731. }
  52732. mesh.coords = coordsPacked;
  52733. var colors = mesh.colors;
  52734. var colorsPacked = new Uint8Array(colors.length * 3);
  52735. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  52736. var c = colors[i];
  52737. colorsPacked[j++] = c[0];
  52738. colorsPacked[j++] = c[1];
  52739. colorsPacked[j++] = c[2];
  52740. }
  52741. mesh.colors = colorsPacked;
  52742. var figures = mesh.figures;
  52743. for (i = 0, ii = figures.length; i < ii; i++) {
  52744. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  52745. for (j = 0, jj = ps.length; j < jj; j++) {
  52746. ps[j] *= 2;
  52747. cs[j] *= 3;
  52748. }
  52749. }
  52750. }
  52751. function Mesh(stream, matrix, xref, res) {
  52752. assert(isStream(stream), 'Mesh data is not a stream');
  52753. var dict = stream.dict;
  52754. this.matrix = matrix;
  52755. this.shadingType = dict.get('ShadingType');
  52756. this.type = 'Pattern';
  52757. this.bbox = dict.getArray('BBox');
  52758. var cs = dict.get('ColorSpace', 'CS');
  52759. cs = ColorSpace.parse(cs, xref, res);
  52760. this.cs = cs;
  52761. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  52762. var fnObj = dict.get('Function');
  52763. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  52764. this.coords = [];
  52765. this.colors = [];
  52766. this.figures = [];
  52767. var decodeContext = {
  52768. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  52769. bitsPerComponent: dict.get('BitsPerComponent'),
  52770. bitsPerFlag: dict.get('BitsPerFlag'),
  52771. decode: dict.getArray('Decode'),
  52772. colorFn: fn,
  52773. colorSpace: cs,
  52774. numComps: fn ? 1 : cs.numComps
  52775. };
  52776. var reader = new MeshStreamReader(stream, decodeContext);
  52777. var patchMesh = false;
  52778. switch (this.shadingType) {
  52779. case ShadingType.FREE_FORM_MESH:
  52780. decodeType4Shading(this, reader);
  52781. break;
  52782. case ShadingType.LATTICE_FORM_MESH:
  52783. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  52784. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  52785. decodeType5Shading(this, reader, verticesPerRow);
  52786. break;
  52787. case ShadingType.COONS_PATCH_MESH:
  52788. decodeType6Shading(this, reader);
  52789. patchMesh = true;
  52790. break;
  52791. case ShadingType.TENSOR_PATCH_MESH:
  52792. decodeType7Shading(this, reader);
  52793. patchMesh = true;
  52794. break;
  52795. default:
  52796. error('Unsupported mesh type.');
  52797. break;
  52798. }
  52799. if (patchMesh) {
  52800. updateBounds(this);
  52801. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  52802. buildFigureFromPatch(this, i);
  52803. }
  52804. }
  52805. updateBounds(this);
  52806. packData(this);
  52807. }
  52808. Mesh.prototype = {
  52809. getIR: function Mesh_getIR() {
  52810. return [
  52811. 'Mesh',
  52812. this.shadingType,
  52813. this.coords,
  52814. this.colors,
  52815. this.figures,
  52816. this.bounds,
  52817. this.matrix,
  52818. this.bbox,
  52819. this.background
  52820. ];
  52821. }
  52822. };
  52823. return Mesh;
  52824. }();
  52825. Shadings.Dummy = function DummyClosure() {
  52826. function Dummy() {
  52827. this.type = 'Pattern';
  52828. }
  52829. Dummy.prototype = {
  52830. getIR: function Dummy_getIR() {
  52831. return ['Dummy'];
  52832. }
  52833. };
  52834. return Dummy;
  52835. }();
  52836. function getTilingPatternIR(operatorList, dict, args) {
  52837. var matrix = dict.getArray('Matrix');
  52838. var bbox = dict.getArray('BBox');
  52839. var xstep = dict.get('XStep');
  52840. var ystep = dict.get('YStep');
  52841. var paintType = dict.get('PaintType');
  52842. var tilingType = dict.get('TilingType');
  52843. return [
  52844. 'TilingPattern',
  52845. args,
  52846. operatorList,
  52847. matrix,
  52848. bbox,
  52849. xstep,
  52850. ystep,
  52851. paintType,
  52852. tilingType
  52853. ];
  52854. }
  52855. exports.Pattern = Pattern;
  52856. exports.getTilingPatternIR = getTilingPatternIR;
  52857. /***/ }),
  52858. /* 41 */
  52859. /***/ (function(module, exports, __w_pdfjs_require__) {
  52860. "use strict";
  52861. var sharedUtil = __w_pdfjs_require__(0);
  52862. var coreStream = __w_pdfjs_require__(2);
  52863. var coreChunkedStream = __w_pdfjs_require__(16);
  52864. var coreDocument = __w_pdfjs_require__(31);
  52865. var warn = sharedUtil.warn;
  52866. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  52867. var shadow = sharedUtil.shadow;
  52868. var NotImplementedException = sharedUtil.NotImplementedException;
  52869. var MissingDataException = sharedUtil.MissingDataException;
  52870. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52871. var Util = sharedUtil.Util;
  52872. var Stream = coreStream.Stream;
  52873. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  52874. var PDFDocument = coreDocument.PDFDocument;
  52875. var BasePdfManager = function BasePdfManagerClosure() {
  52876. function BasePdfManager() {
  52877. throw new Error('Cannot initialize BaseManagerManager');
  52878. }
  52879. BasePdfManager.prototype = {
  52880. get docId() {
  52881. return this._docId;
  52882. },
  52883. get password() {
  52884. return this._password;
  52885. },
  52886. get docBaseUrl() {
  52887. var docBaseUrl = null;
  52888. if (this._docBaseUrl) {
  52889. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  52890. if (absoluteUrl) {
  52891. docBaseUrl = absoluteUrl.href;
  52892. } else {
  52893. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  52894. }
  52895. }
  52896. return shadow(this, 'docBaseUrl', docBaseUrl);
  52897. },
  52898. onLoadedStream: function BasePdfManager_onLoadedStream() {
  52899. throw new NotImplementedException();
  52900. },
  52901. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  52902. return this.ensure(this.pdfDocument, prop, args);
  52903. },
  52904. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  52905. return this.ensure(this.pdfDocument.xref, prop, args);
  52906. },
  52907. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  52908. return this.ensure(this.pdfDocument.catalog, prop, args);
  52909. },
  52910. getPage: function BasePdfManager_getPage(pageIndex) {
  52911. return this.pdfDocument.getPage(pageIndex);
  52912. },
  52913. cleanup: function BasePdfManager_cleanup() {
  52914. return this.pdfDocument.cleanup();
  52915. },
  52916. ensure: function BasePdfManager_ensure(obj, prop, args) {
  52917. return new NotImplementedException();
  52918. },
  52919. requestRange: function BasePdfManager_requestRange(begin, end) {
  52920. return new NotImplementedException();
  52921. },
  52922. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  52923. return new NotImplementedException();
  52924. },
  52925. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  52926. return new NotImplementedException();
  52927. },
  52928. updatePassword: function BasePdfManager_updatePassword(password) {
  52929. this._password = password;
  52930. },
  52931. terminate: function BasePdfManager_terminate() {
  52932. return new NotImplementedException();
  52933. }
  52934. };
  52935. return BasePdfManager;
  52936. }();
  52937. var LocalPdfManager = function LocalPdfManagerClosure() {
  52938. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  52939. this._docId = docId;
  52940. this._password = password;
  52941. this._docBaseUrl = docBaseUrl;
  52942. this.evaluatorOptions = evaluatorOptions;
  52943. var stream = new Stream(data);
  52944. this.pdfDocument = new PDFDocument(this, stream);
  52945. this._loadedStreamCapability = createPromiseCapability();
  52946. this._loadedStreamCapability.resolve(stream);
  52947. }
  52948. Util.inherit(LocalPdfManager, BasePdfManager, {
  52949. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  52950. return new Promise(function (resolve, reject) {
  52951. try {
  52952. var value = obj[prop];
  52953. var result;
  52954. if (typeof value === 'function') {
  52955. result = value.apply(obj, args);
  52956. } else {
  52957. result = value;
  52958. }
  52959. resolve(result);
  52960. } catch (e) {
  52961. reject(e);
  52962. }
  52963. });
  52964. },
  52965. requestRange: function LocalPdfManager_requestRange(begin, end) {
  52966. return Promise.resolve();
  52967. },
  52968. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  52969. },
  52970. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  52971. return this._loadedStreamCapability.promise;
  52972. },
  52973. terminate: function LocalPdfManager_terminate() {
  52974. }
  52975. });
  52976. return LocalPdfManager;
  52977. }();
  52978. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  52979. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  52980. this._docId = docId;
  52981. this._password = args.password;
  52982. this._docBaseUrl = docBaseUrl;
  52983. this.msgHandler = args.msgHandler;
  52984. this.evaluatorOptions = evaluatorOptions;
  52985. var params = {
  52986. msgHandler: args.msgHandler,
  52987. url: args.url,
  52988. length: args.length,
  52989. disableAutoFetch: args.disableAutoFetch,
  52990. rangeChunkSize: args.rangeChunkSize
  52991. };
  52992. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  52993. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  52994. }
  52995. Util.inherit(NetworkPdfManager, BasePdfManager, {
  52996. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  52997. var pdfManager = this;
  52998. return new Promise(function (resolve, reject) {
  52999. function ensureHelper() {
  53000. try {
  53001. var result;
  53002. var value = obj[prop];
  53003. if (typeof value === 'function') {
  53004. result = value.apply(obj, args);
  53005. } else {
  53006. result = value;
  53007. }
  53008. resolve(result);
  53009. } catch (e) {
  53010. if (!(e instanceof MissingDataException)) {
  53011. reject(e);
  53012. return;
  53013. }
  53014. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53015. }
  53016. }
  53017. ensureHelper();
  53018. });
  53019. },
  53020. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53021. return this.streamManager.requestRange(begin, end);
  53022. },
  53023. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53024. this.streamManager.requestAllChunks();
  53025. },
  53026. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53027. this.streamManager.onReceiveData({ chunk: chunk });
  53028. },
  53029. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53030. return this.streamManager.onLoadedStream();
  53031. },
  53032. terminate: function NetworkPdfManager_terminate() {
  53033. this.streamManager.abort();
  53034. }
  53035. });
  53036. return NetworkPdfManager;
  53037. }();
  53038. exports.LocalPdfManager = LocalPdfManager;
  53039. exports.NetworkPdfManager = NetworkPdfManager;
  53040. /***/ }),
  53041. /* 42 */
  53042. /***/ (function(module, exports, __w_pdfjs_require__) {
  53043. "use strict";
  53044. var sharedUtil = __w_pdfjs_require__(0);
  53045. var corePrimitives = __w_pdfjs_require__(1);
  53046. var error = sharedUtil.error;
  53047. var isSpace = sharedUtil.isSpace;
  53048. var EOF = corePrimitives.EOF;
  53049. var PostScriptParser = function PostScriptParserClosure() {
  53050. function PostScriptParser(lexer) {
  53051. this.lexer = lexer;
  53052. this.operators = [];
  53053. this.token = null;
  53054. this.prev = null;
  53055. }
  53056. PostScriptParser.prototype = {
  53057. nextToken: function PostScriptParser_nextToken() {
  53058. this.prev = this.token;
  53059. this.token = this.lexer.getToken();
  53060. },
  53061. accept: function PostScriptParser_accept(type) {
  53062. if (this.token.type === type) {
  53063. this.nextToken();
  53064. return true;
  53065. }
  53066. return false;
  53067. },
  53068. expect: function PostScriptParser_expect(type) {
  53069. if (this.accept(type)) {
  53070. return true;
  53071. }
  53072. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53073. },
  53074. parse: function PostScriptParser_parse() {
  53075. this.nextToken();
  53076. this.expect(PostScriptTokenTypes.LBRACE);
  53077. this.parseBlock();
  53078. this.expect(PostScriptTokenTypes.RBRACE);
  53079. return this.operators;
  53080. },
  53081. parseBlock: function PostScriptParser_parseBlock() {
  53082. while (true) {
  53083. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53084. this.operators.push(this.prev.value);
  53085. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53086. this.operators.push(this.prev.value);
  53087. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53088. this.parseCondition();
  53089. } else {
  53090. return;
  53091. }
  53092. }
  53093. },
  53094. parseCondition: function PostScriptParser_parseCondition() {
  53095. var conditionLocation = this.operators.length;
  53096. this.operators.push(null, null);
  53097. this.parseBlock();
  53098. this.expect(PostScriptTokenTypes.RBRACE);
  53099. if (this.accept(PostScriptTokenTypes.IF)) {
  53100. this.operators[conditionLocation] = this.operators.length;
  53101. this.operators[conditionLocation + 1] = 'jz';
  53102. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53103. var jumpLocation = this.operators.length;
  53104. this.operators.push(null, null);
  53105. var endOfTrue = this.operators.length;
  53106. this.parseBlock();
  53107. this.expect(PostScriptTokenTypes.RBRACE);
  53108. this.expect(PostScriptTokenTypes.IFELSE);
  53109. this.operators[jumpLocation] = this.operators.length;
  53110. this.operators[jumpLocation + 1] = 'j';
  53111. this.operators[conditionLocation] = endOfTrue;
  53112. this.operators[conditionLocation + 1] = 'jz';
  53113. } else {
  53114. error('PS Function: error parsing conditional.');
  53115. }
  53116. }
  53117. };
  53118. return PostScriptParser;
  53119. }();
  53120. var PostScriptTokenTypes = {
  53121. LBRACE: 0,
  53122. RBRACE: 1,
  53123. NUMBER: 2,
  53124. OPERATOR: 3,
  53125. IF: 4,
  53126. IFELSE: 5
  53127. };
  53128. var PostScriptToken = function PostScriptTokenClosure() {
  53129. function PostScriptToken(type, value) {
  53130. this.type = type;
  53131. this.value = value;
  53132. }
  53133. var opCache = Object.create(null);
  53134. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53135. var opValue = opCache[op];
  53136. if (opValue) {
  53137. return opValue;
  53138. }
  53139. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53140. };
  53141. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53142. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53143. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53144. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53145. return PostScriptToken;
  53146. }();
  53147. var PostScriptLexer = function PostScriptLexerClosure() {
  53148. function PostScriptLexer(stream) {
  53149. this.stream = stream;
  53150. this.nextChar();
  53151. this.strBuf = [];
  53152. }
  53153. PostScriptLexer.prototype = {
  53154. nextChar: function PostScriptLexer_nextChar() {
  53155. return this.currentChar = this.stream.getByte();
  53156. },
  53157. getToken: function PostScriptLexer_getToken() {
  53158. var comment = false;
  53159. var ch = this.currentChar;
  53160. while (true) {
  53161. if (ch < 0) {
  53162. return EOF;
  53163. }
  53164. if (comment) {
  53165. if (ch === 0x0A || ch === 0x0D) {
  53166. comment = false;
  53167. }
  53168. } else if (ch === 0x25) {
  53169. comment = true;
  53170. } else if (!isSpace(ch)) {
  53171. break;
  53172. }
  53173. ch = this.nextChar();
  53174. }
  53175. switch (ch | 0) {
  53176. case 0x30:
  53177. case 0x31:
  53178. case 0x32:
  53179. case 0x33:
  53180. case 0x34:
  53181. case 0x35:
  53182. case 0x36:
  53183. case 0x37:
  53184. case 0x38:
  53185. case 0x39:
  53186. case 0x2B:
  53187. case 0x2D:
  53188. case 0x2E:
  53189. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53190. case 0x7B:
  53191. this.nextChar();
  53192. return PostScriptToken.LBRACE;
  53193. case 0x7D:
  53194. this.nextChar();
  53195. return PostScriptToken.RBRACE;
  53196. }
  53197. var strBuf = this.strBuf;
  53198. strBuf.length = 0;
  53199. strBuf[0] = String.fromCharCode(ch);
  53200. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53201. strBuf.push(String.fromCharCode(ch));
  53202. }
  53203. var str = strBuf.join('');
  53204. switch (str.toLowerCase()) {
  53205. case 'if':
  53206. return PostScriptToken.IF;
  53207. case 'ifelse':
  53208. return PostScriptToken.IFELSE;
  53209. default:
  53210. return PostScriptToken.getOperator(str);
  53211. }
  53212. },
  53213. getNumber: function PostScriptLexer_getNumber() {
  53214. var ch = this.currentChar;
  53215. var strBuf = this.strBuf;
  53216. strBuf.length = 0;
  53217. strBuf[0] = String.fromCharCode(ch);
  53218. while ((ch = this.nextChar()) >= 0) {
  53219. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  53220. strBuf.push(String.fromCharCode(ch));
  53221. } else {
  53222. break;
  53223. }
  53224. }
  53225. var value = parseFloat(strBuf.join(''));
  53226. if (isNaN(value)) {
  53227. error('Invalid floating point number: ' + value);
  53228. }
  53229. return value;
  53230. }
  53231. };
  53232. return PostScriptLexer;
  53233. }();
  53234. exports.PostScriptLexer = PostScriptLexer;
  53235. exports.PostScriptParser = PostScriptParser;
  53236. /***/ }),
  53237. /* 43 */
  53238. /***/ (function(module, exports, __w_pdfjs_require__) {
  53239. "use strict";
  53240. var sharedUtil = __w_pdfjs_require__(0);
  53241. var coreStream = __w_pdfjs_require__(2);
  53242. var coreEncodings = __w_pdfjs_require__(5);
  53243. var warn = sharedUtil.warn;
  53244. var isSpace = sharedUtil.isSpace;
  53245. var Stream = coreStream.Stream;
  53246. var getEncoding = coreEncodings.getEncoding;
  53247. var HINTING_ENABLED = false;
  53248. var Type1CharString = function Type1CharStringClosure() {
  53249. var COMMAND_MAP = {
  53250. 'hstem': [1],
  53251. 'vstem': [3],
  53252. 'vmoveto': [4],
  53253. 'rlineto': [5],
  53254. 'hlineto': [6],
  53255. 'vlineto': [7],
  53256. 'rrcurveto': [8],
  53257. 'callsubr': [10],
  53258. 'flex': [
  53259. 12,
  53260. 35
  53261. ],
  53262. 'drop': [
  53263. 12,
  53264. 18
  53265. ],
  53266. 'endchar': [14],
  53267. 'rmoveto': [21],
  53268. 'hmoveto': [22],
  53269. 'vhcurveto': [30],
  53270. 'hvcurveto': [31]
  53271. };
  53272. function Type1CharString() {
  53273. this.width = 0;
  53274. this.lsb = 0;
  53275. this.flexing = false;
  53276. this.output = [];
  53277. this.stack = [];
  53278. }
  53279. Type1CharString.prototype = {
  53280. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  53281. var count = encoded.length;
  53282. var error = false;
  53283. var wx, sbx, subrNumber;
  53284. for (var i = 0; i < count; i++) {
  53285. var value = encoded[i];
  53286. if (value < 32) {
  53287. if (value === 12) {
  53288. value = (value << 8) + encoded[++i];
  53289. }
  53290. switch (value) {
  53291. case 1:
  53292. if (!HINTING_ENABLED) {
  53293. this.stack = [];
  53294. break;
  53295. }
  53296. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53297. break;
  53298. case 3:
  53299. if (!HINTING_ENABLED) {
  53300. this.stack = [];
  53301. break;
  53302. }
  53303. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53304. break;
  53305. case 4:
  53306. if (this.flexing) {
  53307. if (this.stack.length < 1) {
  53308. error = true;
  53309. break;
  53310. }
  53311. var dy = this.stack.pop();
  53312. this.stack.push(0, dy);
  53313. break;
  53314. }
  53315. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  53316. break;
  53317. case 5:
  53318. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  53319. break;
  53320. case 6:
  53321. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  53322. break;
  53323. case 7:
  53324. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  53325. break;
  53326. case 8:
  53327. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  53328. break;
  53329. case 9:
  53330. this.stack = [];
  53331. break;
  53332. case 10:
  53333. if (this.stack.length < 1) {
  53334. error = true;
  53335. break;
  53336. }
  53337. subrNumber = this.stack.pop();
  53338. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  53339. break;
  53340. case 11:
  53341. return error;
  53342. case 13:
  53343. if (this.stack.length < 2) {
  53344. error = true;
  53345. break;
  53346. }
  53347. wx = this.stack.pop();
  53348. sbx = this.stack.pop();
  53349. this.lsb = sbx;
  53350. this.width = wx;
  53351. this.stack.push(wx, sbx);
  53352. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  53353. break;
  53354. case 14:
  53355. this.output.push(COMMAND_MAP.endchar[0]);
  53356. break;
  53357. case 21:
  53358. if (this.flexing) {
  53359. break;
  53360. }
  53361. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  53362. break;
  53363. case 22:
  53364. if (this.flexing) {
  53365. this.stack.push(0);
  53366. break;
  53367. }
  53368. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  53369. break;
  53370. case 30:
  53371. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  53372. break;
  53373. case 31:
  53374. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  53375. break;
  53376. case (12 << 8) + 0:
  53377. this.stack = [];
  53378. break;
  53379. case (12 << 8) + 1:
  53380. if (!HINTING_ENABLED) {
  53381. this.stack = [];
  53382. break;
  53383. }
  53384. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53385. break;
  53386. case (12 << 8) + 2:
  53387. if (!HINTING_ENABLED) {
  53388. this.stack = [];
  53389. break;
  53390. }
  53391. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53392. break;
  53393. case (12 << 8) + 6:
  53394. if (seacAnalysisEnabled) {
  53395. this.seac = this.stack.splice(-4, 4);
  53396. error = this.executeCommand(0, COMMAND_MAP.endchar);
  53397. } else {
  53398. error = this.executeCommand(4, COMMAND_MAP.endchar);
  53399. }
  53400. break;
  53401. case (12 << 8) + 7:
  53402. if (this.stack.length < 4) {
  53403. error = true;
  53404. break;
  53405. }
  53406. this.stack.pop();
  53407. wx = this.stack.pop();
  53408. var sby = this.stack.pop();
  53409. sbx = this.stack.pop();
  53410. this.lsb = sbx;
  53411. this.width = wx;
  53412. this.stack.push(wx, sbx, sby);
  53413. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  53414. break;
  53415. case (12 << 8) + 12:
  53416. if (this.stack.length < 2) {
  53417. error = true;
  53418. break;
  53419. }
  53420. var num2 = this.stack.pop();
  53421. var num1 = this.stack.pop();
  53422. this.stack.push(num1 / num2);
  53423. break;
  53424. case (12 << 8) + 16:
  53425. if (this.stack.length < 2) {
  53426. error = true;
  53427. break;
  53428. }
  53429. subrNumber = this.stack.pop();
  53430. var numArgs = this.stack.pop();
  53431. if (subrNumber === 0 && numArgs === 3) {
  53432. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  53433. 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]);
  53434. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  53435. this.flexing = false;
  53436. this.stack.push(flexArgs[15], flexArgs[16]);
  53437. } else if (subrNumber === 1 && numArgs === 0) {
  53438. this.flexing = true;
  53439. }
  53440. break;
  53441. case (12 << 8) + 17:
  53442. break;
  53443. case (12 << 8) + 33:
  53444. this.stack = [];
  53445. break;
  53446. default:
  53447. warn('Unknown type 1 charstring command of "' + value + '"');
  53448. break;
  53449. }
  53450. if (error) {
  53451. break;
  53452. }
  53453. continue;
  53454. } else if (value <= 246) {
  53455. value = value - 139;
  53456. } else if (value <= 250) {
  53457. value = (value - 247) * 256 + encoded[++i] + 108;
  53458. } else if (value <= 254) {
  53459. value = -((value - 251) * 256) - encoded[++i] - 108;
  53460. } else {
  53461. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  53462. }
  53463. this.stack.push(value);
  53464. }
  53465. return error;
  53466. },
  53467. executeCommand: function (howManyArgs, command, keepStack) {
  53468. var stackLength = this.stack.length;
  53469. if (howManyArgs > stackLength) {
  53470. return true;
  53471. }
  53472. var start = stackLength - howManyArgs;
  53473. for (var i = start; i < stackLength; i++) {
  53474. var value = this.stack[i];
  53475. if (value === (value | 0)) {
  53476. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  53477. } else {
  53478. value = 65536 * value | 0;
  53479. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  53480. }
  53481. }
  53482. this.output.push.apply(this.output, command);
  53483. if (keepStack) {
  53484. this.stack.splice(start, howManyArgs);
  53485. } else {
  53486. this.stack.length = 0;
  53487. }
  53488. return false;
  53489. }
  53490. };
  53491. return Type1CharString;
  53492. }();
  53493. var Type1Parser = function Type1ParserClosure() {
  53494. var EEXEC_ENCRYPT_KEY = 55665;
  53495. var CHAR_STRS_ENCRYPT_KEY = 4330;
  53496. function isHexDigit(code) {
  53497. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  53498. }
  53499. function decrypt(data, key, discardNumber) {
  53500. if (discardNumber >= data.length) {
  53501. return new Uint8Array(0);
  53502. }
  53503. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  53504. for (i = 0; i < discardNumber; i++) {
  53505. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  53506. }
  53507. var count = data.length - discardNumber;
  53508. var decrypted = new Uint8Array(count);
  53509. for (i = discardNumber, j = 0; j < count; i++, j++) {
  53510. var value = data[i];
  53511. decrypted[j] = value ^ r >> 8;
  53512. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53513. }
  53514. return decrypted;
  53515. }
  53516. function decryptAscii(data, key, discardNumber) {
  53517. var r = key | 0, c1 = 52845, c2 = 22719;
  53518. var count = data.length, maybeLength = count >>> 1;
  53519. var decrypted = new Uint8Array(maybeLength);
  53520. var i, j;
  53521. for (i = 0, j = 0; i < count; i++) {
  53522. var digit1 = data[i];
  53523. if (!isHexDigit(digit1)) {
  53524. continue;
  53525. }
  53526. i++;
  53527. var digit2;
  53528. while (i < count && !isHexDigit(digit2 = data[i])) {
  53529. i++;
  53530. }
  53531. if (i < count) {
  53532. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  53533. decrypted[j++] = value ^ r >> 8;
  53534. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53535. }
  53536. }
  53537. return Array.prototype.slice.call(decrypted, discardNumber, j);
  53538. }
  53539. function isSpecial(c) {
  53540. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  53541. }
  53542. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  53543. if (encrypted) {
  53544. var data = stream.getBytes();
  53545. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  53546. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  53547. }
  53548. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  53549. this.stream = stream;
  53550. this.nextChar();
  53551. }
  53552. Type1Parser.prototype = {
  53553. readNumberArray: function Type1Parser_readNumberArray() {
  53554. this.getToken();
  53555. var array = [];
  53556. while (true) {
  53557. var token = this.getToken();
  53558. if (token === null || token === ']' || token === '}') {
  53559. break;
  53560. }
  53561. array.push(parseFloat(token || 0));
  53562. }
  53563. return array;
  53564. },
  53565. readNumber: function Type1Parser_readNumber() {
  53566. var token = this.getToken();
  53567. return parseFloat(token || 0);
  53568. },
  53569. readInt: function Type1Parser_readInt() {
  53570. var token = this.getToken();
  53571. return parseInt(token || 0, 10) | 0;
  53572. },
  53573. readBoolean: function Type1Parser_readBoolean() {
  53574. var token = this.getToken();
  53575. return token === 'true' ? 1 : 0;
  53576. },
  53577. nextChar: function Type1_nextChar() {
  53578. return this.currentChar = this.stream.getByte();
  53579. },
  53580. getToken: function Type1Parser_getToken() {
  53581. var comment = false;
  53582. var ch = this.currentChar;
  53583. while (true) {
  53584. if (ch === -1) {
  53585. return null;
  53586. }
  53587. if (comment) {
  53588. if (ch === 0x0A || ch === 0x0D) {
  53589. comment = false;
  53590. }
  53591. } else if (ch === 0x25) {
  53592. comment = true;
  53593. } else if (!isSpace(ch)) {
  53594. break;
  53595. }
  53596. ch = this.nextChar();
  53597. }
  53598. if (isSpecial(ch)) {
  53599. this.nextChar();
  53600. return String.fromCharCode(ch);
  53601. }
  53602. var token = '';
  53603. do {
  53604. token += String.fromCharCode(ch);
  53605. ch = this.nextChar();
  53606. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  53607. return token;
  53608. },
  53609. extractFontProgram: function Type1Parser_extractFontProgram() {
  53610. var stream = this.stream;
  53611. var subrs = [], charstrings = [];
  53612. var privateData = Object.create(null);
  53613. privateData['lenIV'] = 4;
  53614. var program = {
  53615. subrs: [],
  53616. charstrings: [],
  53617. properties: { 'privateData': privateData }
  53618. };
  53619. var token, length, data, lenIV, encoded;
  53620. while ((token = this.getToken()) !== null) {
  53621. if (token !== '/') {
  53622. continue;
  53623. }
  53624. token = this.getToken();
  53625. switch (token) {
  53626. case 'CharStrings':
  53627. this.getToken();
  53628. this.getToken();
  53629. this.getToken();
  53630. this.getToken();
  53631. while (true) {
  53632. token = this.getToken();
  53633. if (token === null || token === 'end') {
  53634. break;
  53635. }
  53636. if (token !== '/') {
  53637. continue;
  53638. }
  53639. var glyph = this.getToken();
  53640. length = this.readInt();
  53641. this.getToken();
  53642. data = stream.makeSubStream(stream.pos, length);
  53643. lenIV = program.properties.privateData['lenIV'];
  53644. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53645. stream.skip(length);
  53646. this.nextChar();
  53647. token = this.getToken();
  53648. if (token === 'noaccess') {
  53649. this.getToken();
  53650. }
  53651. charstrings.push({
  53652. glyph: glyph,
  53653. encoded: encoded
  53654. });
  53655. }
  53656. break;
  53657. case 'Subrs':
  53658. this.readInt();
  53659. this.getToken();
  53660. while ((token = this.getToken()) === 'dup') {
  53661. var index = this.readInt();
  53662. length = this.readInt();
  53663. this.getToken();
  53664. data = stream.makeSubStream(stream.pos, length);
  53665. lenIV = program.properties.privateData['lenIV'];
  53666. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53667. stream.skip(length);
  53668. this.nextChar();
  53669. token = this.getToken();
  53670. if (token === 'noaccess') {
  53671. this.getToken();
  53672. }
  53673. subrs[index] = encoded;
  53674. }
  53675. break;
  53676. case 'BlueValues':
  53677. case 'OtherBlues':
  53678. case 'FamilyBlues':
  53679. case 'FamilyOtherBlues':
  53680. var blueArray = this.readNumberArray();
  53681. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  53682. program.properties.privateData[token] = blueArray;
  53683. }
  53684. break;
  53685. case 'StemSnapH':
  53686. case 'StemSnapV':
  53687. program.properties.privateData[token] = this.readNumberArray();
  53688. break;
  53689. case 'StdHW':
  53690. case 'StdVW':
  53691. program.properties.privateData[token] = this.readNumberArray()[0];
  53692. break;
  53693. case 'BlueShift':
  53694. case 'lenIV':
  53695. case 'BlueFuzz':
  53696. case 'BlueScale':
  53697. case 'LanguageGroup':
  53698. case 'ExpansionFactor':
  53699. program.properties.privateData[token] = this.readNumber();
  53700. break;
  53701. case 'ForceBold':
  53702. program.properties.privateData[token] = this.readBoolean();
  53703. break;
  53704. }
  53705. }
  53706. for (var i = 0; i < charstrings.length; i++) {
  53707. glyph = charstrings[i].glyph;
  53708. encoded = charstrings[i].encoded;
  53709. var charString = new Type1CharString();
  53710. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  53711. var output = charString.output;
  53712. if (error) {
  53713. output = [14];
  53714. }
  53715. program.charstrings.push({
  53716. glyphName: glyph,
  53717. charstring: output,
  53718. width: charString.width,
  53719. lsb: charString.lsb,
  53720. seac: charString.seac
  53721. });
  53722. }
  53723. return program;
  53724. },
  53725. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  53726. var token;
  53727. while ((token = this.getToken()) !== null) {
  53728. if (token !== '/') {
  53729. continue;
  53730. }
  53731. token = this.getToken();
  53732. switch (token) {
  53733. case 'FontMatrix':
  53734. var matrix = this.readNumberArray();
  53735. properties.fontMatrix = matrix;
  53736. break;
  53737. case 'Encoding':
  53738. var encodingArg = this.getToken();
  53739. var encoding;
  53740. if (!/^\d+$/.test(encodingArg)) {
  53741. encoding = getEncoding(encodingArg);
  53742. } else {
  53743. encoding = [];
  53744. var size = parseInt(encodingArg, 10) | 0;
  53745. this.getToken();
  53746. for (var j = 0; j < size; j++) {
  53747. token = this.getToken();
  53748. while (token !== 'dup' && token !== 'def') {
  53749. token = this.getToken();
  53750. if (token === null) {
  53751. return;
  53752. }
  53753. }
  53754. if (token === 'def') {
  53755. break;
  53756. }
  53757. var index = this.readInt();
  53758. this.getToken();
  53759. var glyph = this.getToken();
  53760. encoding[index] = glyph;
  53761. this.getToken();
  53762. }
  53763. }
  53764. properties.builtInEncoding = encoding;
  53765. break;
  53766. case 'FontBBox':
  53767. var fontBBox = this.readNumberArray();
  53768. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  53769. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  53770. properties.ascentScaled = true;
  53771. break;
  53772. }
  53773. }
  53774. }
  53775. };
  53776. return Type1Parser;
  53777. }();
  53778. exports.Type1Parser = Type1Parser;
  53779. /***/ }),
  53780. /* 44 */
  53781. /***/ (function(module, exports, __w_pdfjs_require__) {
  53782. "use strict";
  53783. var sharedUtil = __w_pdfjs_require__(0);
  53784. var displayDOMUtils = __w_pdfjs_require__(3);
  53785. var displayPatternHelper = __w_pdfjs_require__(46);
  53786. var displayWebGL = __w_pdfjs_require__(25);
  53787. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  53788. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  53789. var ImageKind = sharedUtil.ImageKind;
  53790. var OPS = sharedUtil.OPS;
  53791. var TextRenderingMode = sharedUtil.TextRenderingMode;
  53792. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  53793. var Util = sharedUtil.Util;
  53794. var assert = sharedUtil.assert;
  53795. var info = sharedUtil.info;
  53796. var isNum = sharedUtil.isNum;
  53797. var isArray = sharedUtil.isArray;
  53798. var isLittleEndian = sharedUtil.isLittleEndian;
  53799. var error = sharedUtil.error;
  53800. var shadow = sharedUtil.shadow;
  53801. var warn = sharedUtil.warn;
  53802. var TilingPattern = displayPatternHelper.TilingPattern;
  53803. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  53804. var WebGLUtils = displayWebGL.WebGLUtils;
  53805. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  53806. var MIN_FONT_SIZE = 16;
  53807. var MAX_FONT_SIZE = 100;
  53808. var MAX_GROUP_SIZE = 4096;
  53809. var MIN_WIDTH_FACTOR = 0.65;
  53810. var COMPILE_TYPE3_GLYPHS = true;
  53811. var MAX_SIZE_TO_COMPILE = 1000;
  53812. var FULL_CHUNK_HEIGHT = 16;
  53813. var HasCanvasTypedArraysCached = {
  53814. get value() {
  53815. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  53816. }
  53817. };
  53818. var IsLittleEndianCached = {
  53819. get value() {
  53820. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  53821. }
  53822. };
  53823. function addContextCurrentTransform(ctx) {
  53824. if (!ctx.mozCurrentTransform) {
  53825. ctx._originalSave = ctx.save;
  53826. ctx._originalRestore = ctx.restore;
  53827. ctx._originalRotate = ctx.rotate;
  53828. ctx._originalScale = ctx.scale;
  53829. ctx._originalTranslate = ctx.translate;
  53830. ctx._originalTransform = ctx.transform;
  53831. ctx._originalSetTransform = ctx.setTransform;
  53832. ctx._transformMatrix = ctx._transformMatrix || [
  53833. 1,
  53834. 0,
  53835. 0,
  53836. 1,
  53837. 0,
  53838. 0
  53839. ];
  53840. ctx._transformStack = [];
  53841. Object.defineProperty(ctx, 'mozCurrentTransform', {
  53842. get: function getCurrentTransform() {
  53843. return this._transformMatrix;
  53844. }
  53845. });
  53846. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  53847. get: function getCurrentTransformInverse() {
  53848. var m = this._transformMatrix;
  53849. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  53850. var ad_bc = a * d - b * c;
  53851. var bc_ad = b * c - a * d;
  53852. return [
  53853. d / ad_bc,
  53854. b / bc_ad,
  53855. c / bc_ad,
  53856. a / ad_bc,
  53857. (d * e - c * f) / bc_ad,
  53858. (b * e - a * f) / ad_bc
  53859. ];
  53860. }
  53861. });
  53862. ctx.save = function ctxSave() {
  53863. var old = this._transformMatrix;
  53864. this._transformStack.push(old);
  53865. this._transformMatrix = old.slice(0, 6);
  53866. this._originalSave();
  53867. };
  53868. ctx.restore = function ctxRestore() {
  53869. var prev = this._transformStack.pop();
  53870. if (prev) {
  53871. this._transformMatrix = prev;
  53872. this._originalRestore();
  53873. }
  53874. };
  53875. ctx.translate = function ctxTranslate(x, y) {
  53876. var m = this._transformMatrix;
  53877. m[4] = m[0] * x + m[2] * y + m[4];
  53878. m[5] = m[1] * x + m[3] * y + m[5];
  53879. this._originalTranslate(x, y);
  53880. };
  53881. ctx.scale = function ctxScale(x, y) {
  53882. var m = this._transformMatrix;
  53883. m[0] = m[0] * x;
  53884. m[1] = m[1] * x;
  53885. m[2] = m[2] * y;
  53886. m[3] = m[3] * y;
  53887. this._originalScale(x, y);
  53888. };
  53889. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  53890. var m = this._transformMatrix;
  53891. this._transformMatrix = [
  53892. m[0] * a + m[2] * b,
  53893. m[1] * a + m[3] * b,
  53894. m[0] * c + m[2] * d,
  53895. m[1] * c + m[3] * d,
  53896. m[0] * e + m[2] * f + m[4],
  53897. m[1] * e + m[3] * f + m[5]
  53898. ];
  53899. ctx._originalTransform(a, b, c, d, e, f);
  53900. };
  53901. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  53902. this._transformMatrix = [
  53903. a,
  53904. b,
  53905. c,
  53906. d,
  53907. e,
  53908. f
  53909. ];
  53910. ctx._originalSetTransform(a, b, c, d, e, f);
  53911. };
  53912. ctx.rotate = function ctxRotate(angle) {
  53913. var cosValue = Math.cos(angle);
  53914. var sinValue = Math.sin(angle);
  53915. var m = this._transformMatrix;
  53916. this._transformMatrix = [
  53917. m[0] * cosValue + m[2] * sinValue,
  53918. m[1] * cosValue + m[3] * sinValue,
  53919. m[0] * -sinValue + m[2] * cosValue,
  53920. m[1] * -sinValue + m[3] * cosValue,
  53921. m[4],
  53922. m[5]
  53923. ];
  53924. this._originalRotate(angle);
  53925. };
  53926. }
  53927. }
  53928. var CachedCanvases = function CachedCanvasesClosure() {
  53929. function CachedCanvases(canvasFactory) {
  53930. this.canvasFactory = canvasFactory;
  53931. this.cache = Object.create(null);
  53932. }
  53933. CachedCanvases.prototype = {
  53934. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  53935. var canvasEntry;
  53936. if (this.cache[id] !== undefined) {
  53937. canvasEntry = this.cache[id];
  53938. this.canvasFactory.reset(canvasEntry, width, height);
  53939. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  53940. } else {
  53941. canvasEntry = this.canvasFactory.create(width, height);
  53942. this.cache[id] = canvasEntry;
  53943. }
  53944. if (trackTransform) {
  53945. addContextCurrentTransform(canvasEntry.context);
  53946. }
  53947. return canvasEntry;
  53948. },
  53949. clear: function () {
  53950. for (var id in this.cache) {
  53951. var canvasEntry = this.cache[id];
  53952. this.canvasFactory.destroy(canvasEntry);
  53953. delete this.cache[id];
  53954. }
  53955. }
  53956. };
  53957. return CachedCanvases;
  53958. }();
  53959. function compileType3Glyph(imgData) {
  53960. var POINT_TO_PROCESS_LIMIT = 1000;
  53961. var width = imgData.width, height = imgData.height;
  53962. var i, j, j0, width1 = width + 1;
  53963. var points = new Uint8Array(width1 * (height + 1));
  53964. var POINT_TYPES = new Uint8Array([
  53965. 0,
  53966. 2,
  53967. 4,
  53968. 0,
  53969. 1,
  53970. 0,
  53971. 5,
  53972. 4,
  53973. 8,
  53974. 10,
  53975. 0,
  53976. 8,
  53977. 0,
  53978. 2,
  53979. 1,
  53980. 0
  53981. ]);
  53982. var lineSize = width + 7 & ~7, data0 = imgData.data;
  53983. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  53984. for (i = 0, ii = data0.length; i < ii; i++) {
  53985. var mask = 128, elem = data0[i];
  53986. while (mask > 0) {
  53987. data[pos++] = elem & mask ? 0 : 255;
  53988. mask >>= 1;
  53989. }
  53990. }
  53991. var count = 0;
  53992. pos = 0;
  53993. if (data[pos] !== 0) {
  53994. points[0] = 1;
  53995. ++count;
  53996. }
  53997. for (j = 1; j < width; j++) {
  53998. if (data[pos] !== data[pos + 1]) {
  53999. points[j] = data[pos] ? 2 : 1;
  54000. ++count;
  54001. }
  54002. pos++;
  54003. }
  54004. if (data[pos] !== 0) {
  54005. points[j] = 2;
  54006. ++count;
  54007. }
  54008. for (i = 1; i < height; i++) {
  54009. pos = i * lineSize;
  54010. j0 = i * width1;
  54011. if (data[pos - lineSize] !== data[pos]) {
  54012. points[j0] = data[pos] ? 1 : 8;
  54013. ++count;
  54014. }
  54015. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54016. for (j = 1; j < width; j++) {
  54017. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54018. if (POINT_TYPES[sum]) {
  54019. points[j0 + j] = POINT_TYPES[sum];
  54020. ++count;
  54021. }
  54022. pos++;
  54023. }
  54024. if (data[pos - lineSize] !== data[pos]) {
  54025. points[j0 + j] = data[pos] ? 2 : 4;
  54026. ++count;
  54027. }
  54028. if (count > POINT_TO_PROCESS_LIMIT) {
  54029. return null;
  54030. }
  54031. }
  54032. pos = lineSize * (height - 1);
  54033. j0 = i * width1;
  54034. if (data[pos] !== 0) {
  54035. points[j0] = 8;
  54036. ++count;
  54037. }
  54038. for (j = 1; j < width; j++) {
  54039. if (data[pos] !== data[pos + 1]) {
  54040. points[j0 + j] = data[pos] ? 4 : 8;
  54041. ++count;
  54042. }
  54043. pos++;
  54044. }
  54045. if (data[pos] !== 0) {
  54046. points[j0 + j] = 4;
  54047. ++count;
  54048. }
  54049. if (count > POINT_TO_PROCESS_LIMIT) {
  54050. return null;
  54051. }
  54052. var steps = new Int32Array([
  54053. 0,
  54054. width1,
  54055. -1,
  54056. 0,
  54057. -width1,
  54058. 0,
  54059. 0,
  54060. 0,
  54061. 1
  54062. ]);
  54063. var outlines = [];
  54064. for (i = 0; count && i <= height; i++) {
  54065. var p = i * width1;
  54066. var end = p + width;
  54067. while (p < end && !points[p]) {
  54068. p++;
  54069. }
  54070. if (p === end) {
  54071. continue;
  54072. }
  54073. var coords = [
  54074. p % width1,
  54075. i
  54076. ];
  54077. var type = points[p], p0 = p, pp;
  54078. do {
  54079. var step = steps[type];
  54080. do {
  54081. p += step;
  54082. } while (!points[p]);
  54083. pp = points[p];
  54084. if (pp !== 5 && pp !== 10) {
  54085. type = pp;
  54086. points[p] = 0;
  54087. } else {
  54088. type = pp & 0x33 * type >> 4;
  54089. points[p] &= type >> 2 | type << 2;
  54090. }
  54091. coords.push(p % width1);
  54092. coords.push(p / width1 | 0);
  54093. --count;
  54094. } while (p0 !== p);
  54095. outlines.push(coords);
  54096. --i;
  54097. }
  54098. var drawOutline = function (c) {
  54099. c.save();
  54100. c.scale(1 / width, -1 / height);
  54101. c.translate(0, -height);
  54102. c.beginPath();
  54103. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54104. var o = outlines[i];
  54105. c.moveTo(o[0], o[1]);
  54106. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54107. c.lineTo(o[j], o[j + 1]);
  54108. }
  54109. }
  54110. c.fill();
  54111. c.beginPath();
  54112. c.restore();
  54113. };
  54114. return drawOutline;
  54115. }
  54116. var CanvasExtraState = function CanvasExtraStateClosure() {
  54117. function CanvasExtraState(old) {
  54118. this.alphaIsShape = false;
  54119. this.fontSize = 0;
  54120. this.fontSizeScale = 1;
  54121. this.textMatrix = IDENTITY_MATRIX;
  54122. this.textMatrixScale = 1;
  54123. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54124. this.leading = 0;
  54125. this.x = 0;
  54126. this.y = 0;
  54127. this.lineX = 0;
  54128. this.lineY = 0;
  54129. this.charSpacing = 0;
  54130. this.wordSpacing = 0;
  54131. this.textHScale = 1;
  54132. this.textRenderingMode = TextRenderingMode.FILL;
  54133. this.textRise = 0;
  54134. this.fillColor = '#000000';
  54135. this.strokeColor = '#000000';
  54136. this.patternFill = false;
  54137. this.fillAlpha = 1;
  54138. this.strokeAlpha = 1;
  54139. this.lineWidth = 1;
  54140. this.activeSMask = null;
  54141. this.resumeSMaskCtx = null;
  54142. this.old = old;
  54143. }
  54144. CanvasExtraState.prototype = {
  54145. clone: function CanvasExtraState_clone() {
  54146. return Object.create(this);
  54147. },
  54148. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54149. this.x = x;
  54150. this.y = y;
  54151. }
  54152. };
  54153. return CanvasExtraState;
  54154. }();
  54155. var CanvasGraphics = function CanvasGraphicsClosure() {
  54156. var EXECUTION_TIME = 15;
  54157. var EXECUTION_STEPS = 10;
  54158. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54159. this.ctx = canvasCtx;
  54160. this.current = new CanvasExtraState();
  54161. this.stateStack = [];
  54162. this.pendingClip = null;
  54163. this.pendingEOFill = false;
  54164. this.res = null;
  54165. this.xobjs = null;
  54166. this.commonObjs = commonObjs;
  54167. this.objs = objs;
  54168. this.canvasFactory = canvasFactory;
  54169. this.imageLayer = imageLayer;
  54170. this.groupStack = [];
  54171. this.processingType3 = null;
  54172. this.baseTransform = null;
  54173. this.baseTransformStack = [];
  54174. this.groupLevel = 0;
  54175. this.smaskStack = [];
  54176. this.smaskCounter = 0;
  54177. this.tempSMask = null;
  54178. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54179. if (canvasCtx) {
  54180. addContextCurrentTransform(canvasCtx);
  54181. }
  54182. this.cachedGetSinglePixelWidth = null;
  54183. }
  54184. function putBinaryImageData(ctx, imgData) {
  54185. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54186. ctx.putImageData(imgData, 0, 0);
  54187. return;
  54188. }
  54189. var height = imgData.height, width = imgData.width;
  54190. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54191. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54192. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54193. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54194. var srcPos = 0, destPos;
  54195. var src = imgData.data;
  54196. var dest = chunkImgData.data;
  54197. var i, j, thisChunkHeight, elemsInThisChunk;
  54198. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54199. var srcLength = src.byteLength;
  54200. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54201. var dest32DataLength = dest32.length;
  54202. var fullSrcDiff = width + 7 >> 3;
  54203. var white = 0xFFFFFFFF;
  54204. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54205. for (i = 0; i < totalChunks; i++) {
  54206. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54207. destPos = 0;
  54208. for (j = 0; j < thisChunkHeight; j++) {
  54209. var srcDiff = srcLength - srcPos;
  54210. var k = 0;
  54211. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54212. var kEndUnrolled = kEnd & ~7;
  54213. var mask = 0;
  54214. var srcByte = 0;
  54215. for (; k < kEndUnrolled; k += 8) {
  54216. srcByte = src[srcPos++];
  54217. dest32[destPos++] = srcByte & 128 ? white : black;
  54218. dest32[destPos++] = srcByte & 64 ? white : black;
  54219. dest32[destPos++] = srcByte & 32 ? white : black;
  54220. dest32[destPos++] = srcByte & 16 ? white : black;
  54221. dest32[destPos++] = srcByte & 8 ? white : black;
  54222. dest32[destPos++] = srcByte & 4 ? white : black;
  54223. dest32[destPos++] = srcByte & 2 ? white : black;
  54224. dest32[destPos++] = srcByte & 1 ? white : black;
  54225. }
  54226. for (; k < kEnd; k++) {
  54227. if (mask === 0) {
  54228. srcByte = src[srcPos++];
  54229. mask = 128;
  54230. }
  54231. dest32[destPos++] = srcByte & mask ? white : black;
  54232. mask >>= 1;
  54233. }
  54234. }
  54235. while (destPos < dest32DataLength) {
  54236. dest32[destPos++] = 0;
  54237. }
  54238. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54239. }
  54240. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  54241. j = 0;
  54242. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  54243. for (i = 0; i < fullChunks; i++) {
  54244. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54245. srcPos += elemsInThisChunk;
  54246. ctx.putImageData(chunkImgData, 0, j);
  54247. j += FULL_CHUNK_HEIGHT;
  54248. }
  54249. if (i < totalChunks) {
  54250. elemsInThisChunk = width * partialChunkHeight * 4;
  54251. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54252. ctx.putImageData(chunkImgData, 0, j);
  54253. }
  54254. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  54255. thisChunkHeight = FULL_CHUNK_HEIGHT;
  54256. elemsInThisChunk = width * thisChunkHeight;
  54257. for (i = 0; i < totalChunks; i++) {
  54258. if (i >= fullChunks) {
  54259. thisChunkHeight = partialChunkHeight;
  54260. elemsInThisChunk = width * thisChunkHeight;
  54261. }
  54262. destPos = 0;
  54263. for (j = elemsInThisChunk; j--;) {
  54264. dest[destPos++] = src[srcPos++];
  54265. dest[destPos++] = src[srcPos++];
  54266. dest[destPos++] = src[srcPos++];
  54267. dest[destPos++] = 255;
  54268. }
  54269. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54270. }
  54271. } else {
  54272. error('bad image kind: ' + imgData.kind);
  54273. }
  54274. }
  54275. function putBinaryImageMask(ctx, imgData) {
  54276. var height = imgData.height, width = imgData.width;
  54277. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54278. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54279. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54280. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54281. var srcPos = 0;
  54282. var src = imgData.data;
  54283. var dest = chunkImgData.data;
  54284. for (var i = 0; i < totalChunks; i++) {
  54285. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54286. var destPos = 3;
  54287. for (var j = 0; j < thisChunkHeight; j++) {
  54288. var mask = 0;
  54289. for (var k = 0; k < width; k++) {
  54290. if (!mask) {
  54291. var elem = src[srcPos++];
  54292. mask = 128;
  54293. }
  54294. dest[destPos] = elem & mask ? 0 : 255;
  54295. destPos += 4;
  54296. mask >>= 1;
  54297. }
  54298. }
  54299. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54300. }
  54301. }
  54302. function copyCtxState(sourceCtx, destCtx) {
  54303. var properties = [
  54304. 'strokeStyle',
  54305. 'fillStyle',
  54306. 'fillRule',
  54307. 'globalAlpha',
  54308. 'lineWidth',
  54309. 'lineCap',
  54310. 'lineJoin',
  54311. 'miterLimit',
  54312. 'globalCompositeOperation',
  54313. 'font'
  54314. ];
  54315. for (var i = 0, ii = properties.length; i < ii; i++) {
  54316. var property = properties[i];
  54317. if (sourceCtx[property] !== undefined) {
  54318. destCtx[property] = sourceCtx[property];
  54319. }
  54320. }
  54321. if (sourceCtx.setLineDash !== undefined) {
  54322. destCtx.setLineDash(sourceCtx.getLineDash());
  54323. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  54324. }
  54325. }
  54326. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  54327. var length = bytes.length;
  54328. for (var i = 3; i < length; i += 4) {
  54329. var alpha = bytes[i];
  54330. if (alpha === 0) {
  54331. bytes[i - 3] = r0;
  54332. bytes[i - 2] = g0;
  54333. bytes[i - 1] = b0;
  54334. } else if (alpha < 255) {
  54335. var alpha_ = 255 - alpha;
  54336. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  54337. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  54338. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  54339. }
  54340. }
  54341. }
  54342. function composeSMaskAlpha(maskData, layerData, transferMap) {
  54343. var length = maskData.length;
  54344. var scale = 1 / 255;
  54345. for (var i = 3; i < length; i += 4) {
  54346. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  54347. layerData[i] = layerData[i] * alpha * scale | 0;
  54348. }
  54349. }
  54350. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  54351. var length = maskData.length;
  54352. for (var i = 3; i < length; i += 4) {
  54353. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  54354. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  54355. }
  54356. }
  54357. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  54358. var hasBackdrop = !!backdrop;
  54359. var r0 = hasBackdrop ? backdrop[0] : 0;
  54360. var g0 = hasBackdrop ? backdrop[1] : 0;
  54361. var b0 = hasBackdrop ? backdrop[2] : 0;
  54362. var composeFn;
  54363. if (subtype === 'Luminosity') {
  54364. composeFn = composeSMaskLuminosity;
  54365. } else {
  54366. composeFn = composeSMaskAlpha;
  54367. }
  54368. var PIXELS_TO_PROCESS = 1048576;
  54369. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  54370. for (var row = 0; row < height; row += chunkSize) {
  54371. var chunkHeight = Math.min(chunkSize, height - row);
  54372. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  54373. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  54374. if (hasBackdrop) {
  54375. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  54376. }
  54377. composeFn(maskData.data, layerData.data, transferMap);
  54378. maskCtx.putImageData(layerData, 0, row);
  54379. }
  54380. }
  54381. function composeSMask(ctx, smask, layerCtx) {
  54382. var mask = smask.canvas;
  54383. var maskCtx = smask.context;
  54384. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  54385. var backdrop = smask.backdrop || null;
  54386. if (!smask.transferMap && WebGLUtils.isEnabled) {
  54387. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  54388. subtype: smask.subtype,
  54389. backdrop: backdrop
  54390. });
  54391. ctx.setTransform(1, 0, 0, 1, 0, 0);
  54392. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  54393. return;
  54394. }
  54395. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  54396. ctx.drawImage(mask, 0, 0);
  54397. }
  54398. var LINE_CAP_STYLES = [
  54399. 'butt',
  54400. 'round',
  54401. 'square'
  54402. ];
  54403. var LINE_JOIN_STYLES = [
  54404. 'miter',
  54405. 'round',
  54406. 'bevel'
  54407. ];
  54408. var NORMAL_CLIP = {};
  54409. var EO_CLIP = {};
  54410. CanvasGraphics.prototype = {
  54411. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  54412. var width = this.ctx.canvas.width;
  54413. var height = this.ctx.canvas.height;
  54414. this.ctx.save();
  54415. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  54416. this.ctx.fillRect(0, 0, width, height);
  54417. this.ctx.restore();
  54418. if (transparency) {
  54419. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  54420. this.compositeCtx = this.ctx;
  54421. this.transparentCanvas = transparentCanvas.canvas;
  54422. this.ctx = transparentCanvas.context;
  54423. this.ctx.save();
  54424. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  54425. }
  54426. this.ctx.save();
  54427. if (transform) {
  54428. this.ctx.transform.apply(this.ctx, transform);
  54429. }
  54430. this.ctx.transform.apply(this.ctx, viewport.transform);
  54431. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  54432. if (this.imageLayer) {
  54433. this.imageLayer.beginLayout();
  54434. }
  54435. },
  54436. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  54437. var argsArray = operatorList.argsArray;
  54438. var fnArray = operatorList.fnArray;
  54439. var i = executionStartIdx || 0;
  54440. var argsArrayLen = argsArray.length;
  54441. if (argsArrayLen === i) {
  54442. return i;
  54443. }
  54444. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  54445. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  54446. var steps = 0;
  54447. var commonObjs = this.commonObjs;
  54448. var objs = this.objs;
  54449. var fnId;
  54450. while (true) {
  54451. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  54452. stepper.breakIt(i, continueCallback);
  54453. return i;
  54454. }
  54455. fnId = fnArray[i];
  54456. if (fnId !== OPS.dependency) {
  54457. this[fnId].apply(this, argsArray[i]);
  54458. } else {
  54459. var deps = argsArray[i];
  54460. for (var n = 0, nn = deps.length; n < nn; n++) {
  54461. var depObjId = deps[n];
  54462. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  54463. var objsPool = common ? commonObjs : objs;
  54464. if (!objsPool.isResolved(depObjId)) {
  54465. objsPool.get(depObjId, continueCallback);
  54466. return i;
  54467. }
  54468. }
  54469. }
  54470. i++;
  54471. if (i === argsArrayLen) {
  54472. return i;
  54473. }
  54474. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  54475. if (Date.now() > endTime) {
  54476. continueCallback();
  54477. return i;
  54478. }
  54479. steps = 0;
  54480. }
  54481. }
  54482. },
  54483. endDrawing: function CanvasGraphics_endDrawing() {
  54484. if (this.current.activeSMask !== null) {
  54485. this.endSMaskGroup();
  54486. }
  54487. this.ctx.restore();
  54488. if (this.transparentCanvas) {
  54489. this.ctx = this.compositeCtx;
  54490. this.ctx.save();
  54491. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  54492. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  54493. this.ctx.restore();
  54494. this.transparentCanvas = null;
  54495. }
  54496. this.cachedCanvases.clear();
  54497. WebGLUtils.clear();
  54498. if (this.imageLayer) {
  54499. this.imageLayer.endLayout();
  54500. }
  54501. },
  54502. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  54503. this.current.lineWidth = width;
  54504. this.ctx.lineWidth = width;
  54505. },
  54506. setLineCap: function CanvasGraphics_setLineCap(style) {
  54507. this.ctx.lineCap = LINE_CAP_STYLES[style];
  54508. },
  54509. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  54510. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  54511. },
  54512. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  54513. this.ctx.miterLimit = limit;
  54514. },
  54515. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  54516. var ctx = this.ctx;
  54517. if (ctx.setLineDash !== undefined) {
  54518. ctx.setLineDash(dashArray);
  54519. ctx.lineDashOffset = dashPhase;
  54520. }
  54521. },
  54522. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  54523. },
  54524. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  54525. },
  54526. setGState: function CanvasGraphics_setGState(states) {
  54527. for (var i = 0, ii = states.length; i < ii; i++) {
  54528. var state = states[i];
  54529. var key = state[0];
  54530. var value = state[1];
  54531. switch (key) {
  54532. case 'LW':
  54533. this.setLineWidth(value);
  54534. break;
  54535. case 'LC':
  54536. this.setLineCap(value);
  54537. break;
  54538. case 'LJ':
  54539. this.setLineJoin(value);
  54540. break;
  54541. case 'ML':
  54542. this.setMiterLimit(value);
  54543. break;
  54544. case 'D':
  54545. this.setDash(value[0], value[1]);
  54546. break;
  54547. case 'RI':
  54548. this.setRenderingIntent(value);
  54549. break;
  54550. case 'FL':
  54551. this.setFlatness(value);
  54552. break;
  54553. case 'Font':
  54554. this.setFont(value[0], value[1]);
  54555. break;
  54556. case 'CA':
  54557. this.current.strokeAlpha = state[1];
  54558. break;
  54559. case 'ca':
  54560. this.current.fillAlpha = state[1];
  54561. this.ctx.globalAlpha = state[1];
  54562. break;
  54563. case 'BM':
  54564. if (value && value.name && value.name !== 'Normal') {
  54565. var mode = value.name.replace(/([A-Z])/g, function (c) {
  54566. return '-' + c.toLowerCase();
  54567. }).substring(1);
  54568. this.ctx.globalCompositeOperation = mode;
  54569. if (this.ctx.globalCompositeOperation !== mode) {
  54570. warn('globalCompositeOperation "' + mode + '" is not supported');
  54571. }
  54572. } else {
  54573. this.ctx.globalCompositeOperation = 'source-over';
  54574. }
  54575. break;
  54576. case 'SMask':
  54577. if (this.current.activeSMask) {
  54578. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  54579. this.suspendSMaskGroup();
  54580. } else {
  54581. this.endSMaskGroup();
  54582. }
  54583. }
  54584. this.current.activeSMask = value ? this.tempSMask : null;
  54585. if (this.current.activeSMask) {
  54586. this.beginSMaskGroup();
  54587. }
  54588. this.tempSMask = null;
  54589. break;
  54590. }
  54591. }
  54592. },
  54593. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  54594. var activeSMask = this.current.activeSMask;
  54595. var drawnWidth = activeSMask.canvas.width;
  54596. var drawnHeight = activeSMask.canvas.height;
  54597. var cacheId = 'smaskGroupAt' + this.groupLevel;
  54598. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  54599. var currentCtx = this.ctx;
  54600. var currentTransform = currentCtx.mozCurrentTransform;
  54601. this.ctx.save();
  54602. var groupCtx = scratchCanvas.context;
  54603. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  54604. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  54605. groupCtx.transform.apply(groupCtx, currentTransform);
  54606. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  54607. copyCtxState(currentCtx, groupCtx);
  54608. this.ctx = groupCtx;
  54609. this.setGState([
  54610. [
  54611. 'BM',
  54612. 'Normal'
  54613. ],
  54614. [
  54615. 'ca',
  54616. 1
  54617. ],
  54618. [
  54619. 'CA',
  54620. 1
  54621. ]
  54622. ]);
  54623. this.groupStack.push(currentCtx);
  54624. this.groupLevel++;
  54625. },
  54626. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54627. var groupCtx = this.ctx;
  54628. this.groupLevel--;
  54629. this.ctx = this.groupStack.pop();
  54630. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54631. this.ctx.restore();
  54632. this.ctx.save();
  54633. copyCtxState(groupCtx, this.ctx);
  54634. this.current.resumeSMaskCtx = groupCtx;
  54635. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54636. this.ctx.transform.apply(this.ctx, deltaTransform);
  54637. groupCtx.save();
  54638. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  54639. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  54640. groupCtx.restore();
  54641. },
  54642. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54643. var groupCtx = this.current.resumeSMaskCtx;
  54644. var currentCtx = this.ctx;
  54645. this.ctx = groupCtx;
  54646. this.groupStack.push(currentCtx);
  54647. this.groupLevel++;
  54648. },
  54649. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54650. var groupCtx = this.ctx;
  54651. this.groupLevel--;
  54652. this.ctx = this.groupStack.pop();
  54653. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54654. this.ctx.restore();
  54655. copyCtxState(groupCtx, this.ctx);
  54656. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54657. this.ctx.transform.apply(this.ctx, deltaTransform);
  54658. },
  54659. save: function CanvasGraphics_save() {
  54660. this.ctx.save();
  54661. var old = this.current;
  54662. this.stateStack.push(old);
  54663. this.current = old.clone();
  54664. this.current.resumeSMaskCtx = null;
  54665. },
  54666. restore: function CanvasGraphics_restore() {
  54667. if (this.current.resumeSMaskCtx) {
  54668. this.resumeSMaskGroup();
  54669. }
  54670. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  54671. this.endSMaskGroup();
  54672. }
  54673. if (this.stateStack.length !== 0) {
  54674. this.current = this.stateStack.pop();
  54675. this.ctx.restore();
  54676. this.pendingClip = null;
  54677. this.cachedGetSinglePixelWidth = null;
  54678. }
  54679. },
  54680. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  54681. this.ctx.transform(a, b, c, d, e, f);
  54682. this.cachedGetSinglePixelWidth = null;
  54683. },
  54684. constructPath: function CanvasGraphics_constructPath(ops, args) {
  54685. var ctx = this.ctx;
  54686. var current = this.current;
  54687. var x = current.x, y = current.y;
  54688. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  54689. switch (ops[i] | 0) {
  54690. case OPS.rectangle:
  54691. x = args[j++];
  54692. y = args[j++];
  54693. var width = args[j++];
  54694. var height = args[j++];
  54695. if (width === 0) {
  54696. width = this.getSinglePixelWidth();
  54697. }
  54698. if (height === 0) {
  54699. height = this.getSinglePixelWidth();
  54700. }
  54701. var xw = x + width;
  54702. var yh = y + height;
  54703. this.ctx.moveTo(x, y);
  54704. this.ctx.lineTo(xw, y);
  54705. this.ctx.lineTo(xw, yh);
  54706. this.ctx.lineTo(x, yh);
  54707. this.ctx.lineTo(x, y);
  54708. this.ctx.closePath();
  54709. break;
  54710. case OPS.moveTo:
  54711. x = args[j++];
  54712. y = args[j++];
  54713. ctx.moveTo(x, y);
  54714. break;
  54715. case OPS.lineTo:
  54716. x = args[j++];
  54717. y = args[j++];
  54718. ctx.lineTo(x, y);
  54719. break;
  54720. case OPS.curveTo:
  54721. x = args[j + 4];
  54722. y = args[j + 5];
  54723. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  54724. j += 6;
  54725. break;
  54726. case OPS.curveTo2:
  54727. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  54728. x = args[j + 2];
  54729. y = args[j + 3];
  54730. j += 4;
  54731. break;
  54732. case OPS.curveTo3:
  54733. x = args[j + 2];
  54734. y = args[j + 3];
  54735. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  54736. j += 4;
  54737. break;
  54738. case OPS.closePath:
  54739. ctx.closePath();
  54740. break;
  54741. }
  54742. }
  54743. current.setCurrentPoint(x, y);
  54744. },
  54745. closePath: function CanvasGraphics_closePath() {
  54746. this.ctx.closePath();
  54747. },
  54748. stroke: function CanvasGraphics_stroke(consumePath) {
  54749. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54750. var ctx = this.ctx;
  54751. var strokeColor = this.current.strokeColor;
  54752. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  54753. ctx.globalAlpha = this.current.strokeAlpha;
  54754. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  54755. ctx.save();
  54756. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  54757. ctx.stroke();
  54758. ctx.restore();
  54759. } else {
  54760. ctx.stroke();
  54761. }
  54762. if (consumePath) {
  54763. this.consumePath();
  54764. }
  54765. ctx.globalAlpha = this.current.fillAlpha;
  54766. },
  54767. closeStroke: function CanvasGraphics_closeStroke() {
  54768. this.closePath();
  54769. this.stroke();
  54770. },
  54771. fill: function CanvasGraphics_fill(consumePath) {
  54772. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54773. var ctx = this.ctx;
  54774. var fillColor = this.current.fillColor;
  54775. var isPatternFill = this.current.patternFill;
  54776. var needRestore = false;
  54777. if (isPatternFill) {
  54778. ctx.save();
  54779. if (this.baseTransform) {
  54780. ctx.setTransform.apply(ctx, this.baseTransform);
  54781. }
  54782. ctx.fillStyle = fillColor.getPattern(ctx, this);
  54783. needRestore = true;
  54784. }
  54785. if (this.pendingEOFill) {
  54786. ctx.fill('evenodd');
  54787. this.pendingEOFill = false;
  54788. } else {
  54789. ctx.fill();
  54790. }
  54791. if (needRestore) {
  54792. ctx.restore();
  54793. }
  54794. if (consumePath) {
  54795. this.consumePath();
  54796. }
  54797. },
  54798. eoFill: function CanvasGraphics_eoFill() {
  54799. this.pendingEOFill = true;
  54800. this.fill();
  54801. },
  54802. fillStroke: function CanvasGraphics_fillStroke() {
  54803. this.fill(false);
  54804. this.stroke(false);
  54805. this.consumePath();
  54806. },
  54807. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  54808. this.pendingEOFill = true;
  54809. this.fillStroke();
  54810. },
  54811. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  54812. this.closePath();
  54813. this.fillStroke();
  54814. },
  54815. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  54816. this.pendingEOFill = true;
  54817. this.closePath();
  54818. this.fillStroke();
  54819. },
  54820. endPath: function CanvasGraphics_endPath() {
  54821. this.consumePath();
  54822. },
  54823. clip: function CanvasGraphics_clip() {
  54824. this.pendingClip = NORMAL_CLIP;
  54825. },
  54826. eoClip: function CanvasGraphics_eoClip() {
  54827. this.pendingClip = EO_CLIP;
  54828. },
  54829. beginText: function CanvasGraphics_beginText() {
  54830. this.current.textMatrix = IDENTITY_MATRIX;
  54831. this.current.textMatrixScale = 1;
  54832. this.current.x = this.current.lineX = 0;
  54833. this.current.y = this.current.lineY = 0;
  54834. },
  54835. endText: function CanvasGraphics_endText() {
  54836. var paths = this.pendingTextPaths;
  54837. var ctx = this.ctx;
  54838. if (paths === undefined) {
  54839. ctx.beginPath();
  54840. return;
  54841. }
  54842. ctx.save();
  54843. ctx.beginPath();
  54844. for (var i = 0; i < paths.length; i++) {
  54845. var path = paths[i];
  54846. ctx.setTransform.apply(ctx, path.transform);
  54847. ctx.translate(path.x, path.y);
  54848. path.addToPath(ctx, path.fontSize);
  54849. }
  54850. ctx.restore();
  54851. ctx.clip();
  54852. ctx.beginPath();
  54853. delete this.pendingTextPaths;
  54854. },
  54855. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  54856. this.current.charSpacing = spacing;
  54857. },
  54858. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  54859. this.current.wordSpacing = spacing;
  54860. },
  54861. setHScale: function CanvasGraphics_setHScale(scale) {
  54862. this.current.textHScale = scale / 100;
  54863. },
  54864. setLeading: function CanvasGraphics_setLeading(leading) {
  54865. this.current.leading = -leading;
  54866. },
  54867. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  54868. var fontObj = this.commonObjs.get(fontRefName);
  54869. var current = this.current;
  54870. if (!fontObj) {
  54871. error('Can\'t find font for ' + fontRefName);
  54872. }
  54873. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  54874. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  54875. warn('Invalid font matrix for font ' + fontRefName);
  54876. }
  54877. if (size < 0) {
  54878. size = -size;
  54879. current.fontDirection = -1;
  54880. } else {
  54881. current.fontDirection = 1;
  54882. }
  54883. this.current.font = fontObj;
  54884. this.current.fontSize = size;
  54885. if (fontObj.isType3Font) {
  54886. return;
  54887. }
  54888. var name = fontObj.loadedName || 'sans-serif';
  54889. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  54890. var italic = fontObj.italic ? 'italic' : 'normal';
  54891. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  54892. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  54893. this.current.fontSizeScale = size / browserFontSize;
  54894. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  54895. this.ctx.font = rule;
  54896. },
  54897. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  54898. this.current.textRenderingMode = mode;
  54899. },
  54900. setTextRise: function CanvasGraphics_setTextRise(rise) {
  54901. this.current.textRise = rise;
  54902. },
  54903. moveText: function CanvasGraphics_moveText(x, y) {
  54904. this.current.x = this.current.lineX += x;
  54905. this.current.y = this.current.lineY += y;
  54906. },
  54907. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  54908. this.setLeading(-y);
  54909. this.moveText(x, y);
  54910. },
  54911. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  54912. this.current.textMatrix = [
  54913. a,
  54914. b,
  54915. c,
  54916. d,
  54917. e,
  54918. f
  54919. ];
  54920. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  54921. this.current.x = this.current.lineX = 0;
  54922. this.current.y = this.current.lineY = 0;
  54923. },
  54924. nextLine: function CanvasGraphics_nextLine() {
  54925. this.moveText(0, this.current.leading);
  54926. },
  54927. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  54928. var ctx = this.ctx;
  54929. var current = this.current;
  54930. var font = current.font;
  54931. var textRenderingMode = current.textRenderingMode;
  54932. var fontSize = current.fontSize / current.fontSizeScale;
  54933. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54934. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  54935. var addToPath;
  54936. if (font.disableFontFace || isAddToPathSet) {
  54937. addToPath = font.getPathGenerator(this.commonObjs, character);
  54938. }
  54939. if (font.disableFontFace) {
  54940. ctx.save();
  54941. ctx.translate(x, y);
  54942. ctx.beginPath();
  54943. addToPath(ctx, fontSize);
  54944. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54945. ctx.fill();
  54946. }
  54947. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54948. ctx.stroke();
  54949. }
  54950. ctx.restore();
  54951. } else {
  54952. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54953. ctx.fillText(character, x, y);
  54954. }
  54955. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54956. ctx.strokeText(character, x, y);
  54957. }
  54958. }
  54959. if (isAddToPathSet) {
  54960. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  54961. paths.push({
  54962. transform: ctx.mozCurrentTransform,
  54963. x: x,
  54964. y: y,
  54965. fontSize: fontSize,
  54966. addToPath: addToPath
  54967. });
  54968. }
  54969. },
  54970. get isFontSubpixelAAEnabled() {
  54971. var ctx = this.canvasFactory.create(10, 10).context;
  54972. ctx.scale(1.5, 1);
  54973. ctx.fillText('I', 0, 10);
  54974. var data = ctx.getImageData(0, 0, 10, 10).data;
  54975. var enabled = false;
  54976. for (var i = 3; i < data.length; i += 4) {
  54977. if (data[i] > 0 && data[i] < 255) {
  54978. enabled = true;
  54979. break;
  54980. }
  54981. }
  54982. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  54983. },
  54984. showText: function CanvasGraphics_showText(glyphs) {
  54985. var current = this.current;
  54986. var font = current.font;
  54987. if (font.isType3Font) {
  54988. return this.showType3Text(glyphs);
  54989. }
  54990. var fontSize = current.fontSize;
  54991. if (fontSize === 0) {
  54992. return;
  54993. }
  54994. var ctx = this.ctx;
  54995. var fontSizeScale = current.fontSizeScale;
  54996. var charSpacing = current.charSpacing;
  54997. var wordSpacing = current.wordSpacing;
  54998. var fontDirection = current.fontDirection;
  54999. var textHScale = current.textHScale * fontDirection;
  55000. var glyphsLength = glyphs.length;
  55001. var vertical = font.vertical;
  55002. var spacingDir = vertical ? 1 : -1;
  55003. var defaultVMetrics = font.defaultVMetrics;
  55004. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55005. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55006. ctx.save();
  55007. ctx.transform.apply(ctx, current.textMatrix);
  55008. ctx.translate(current.x, current.y + current.textRise);
  55009. if (current.patternFill) {
  55010. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55011. }
  55012. if (fontDirection > 0) {
  55013. ctx.scale(textHScale, -1);
  55014. } else {
  55015. ctx.scale(textHScale, 1);
  55016. }
  55017. var lineWidth = current.lineWidth;
  55018. var scale = current.textMatrixScale;
  55019. if (scale === 0 || lineWidth === 0) {
  55020. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55021. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55022. this.cachedGetSinglePixelWidth = null;
  55023. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55024. }
  55025. } else {
  55026. lineWidth /= scale;
  55027. }
  55028. if (fontSizeScale !== 1.0) {
  55029. ctx.scale(fontSizeScale, fontSizeScale);
  55030. lineWidth /= fontSizeScale;
  55031. }
  55032. ctx.lineWidth = lineWidth;
  55033. var x = 0, i;
  55034. for (i = 0; i < glyphsLength; ++i) {
  55035. var glyph = glyphs[i];
  55036. if (isNum(glyph)) {
  55037. x += spacingDir * glyph * fontSize / 1000;
  55038. continue;
  55039. }
  55040. var restoreNeeded = false;
  55041. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55042. var character = glyph.fontChar;
  55043. var accent = glyph.accent;
  55044. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55045. var width = glyph.width;
  55046. if (vertical) {
  55047. var vmetric, vx, vy;
  55048. vmetric = glyph.vmetric || defaultVMetrics;
  55049. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55050. vx = -vx * widthAdvanceScale;
  55051. vy = vmetric[2] * widthAdvanceScale;
  55052. width = vmetric ? -vmetric[0] : width;
  55053. scaledX = vx / fontSizeScale;
  55054. scaledY = (x + vy) / fontSizeScale;
  55055. } else {
  55056. scaledX = x / fontSizeScale;
  55057. scaledY = 0;
  55058. }
  55059. if (font.remeasure && width > 0) {
  55060. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55061. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55062. var characterScaleX = width / measuredWidth;
  55063. restoreNeeded = true;
  55064. ctx.save();
  55065. ctx.scale(characterScaleX, 1);
  55066. scaledX /= characterScaleX;
  55067. } else if (width !== measuredWidth) {
  55068. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55069. }
  55070. }
  55071. if (glyph.isInFont || font.missingFile) {
  55072. if (simpleFillText && !accent) {
  55073. ctx.fillText(character, scaledX, scaledY);
  55074. } else {
  55075. this.paintChar(character, scaledX, scaledY);
  55076. if (accent) {
  55077. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55078. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55079. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55080. }
  55081. }
  55082. }
  55083. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55084. x += charWidth;
  55085. if (restoreNeeded) {
  55086. ctx.restore();
  55087. }
  55088. }
  55089. if (vertical) {
  55090. current.y -= x * textHScale;
  55091. } else {
  55092. current.x += x * textHScale;
  55093. }
  55094. ctx.restore();
  55095. },
  55096. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55097. var ctx = this.ctx;
  55098. var current = this.current;
  55099. var font = current.font;
  55100. var fontSize = current.fontSize;
  55101. var fontDirection = current.fontDirection;
  55102. var spacingDir = font.vertical ? 1 : -1;
  55103. var charSpacing = current.charSpacing;
  55104. var wordSpacing = current.wordSpacing;
  55105. var textHScale = current.textHScale * fontDirection;
  55106. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55107. var glyphsLength = glyphs.length;
  55108. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55109. var i, glyph, width, spacingLength;
  55110. if (isTextInvisible || fontSize === 0) {
  55111. return;
  55112. }
  55113. this.cachedGetSinglePixelWidth = null;
  55114. ctx.save();
  55115. ctx.transform.apply(ctx, current.textMatrix);
  55116. ctx.translate(current.x, current.y);
  55117. ctx.scale(textHScale, fontDirection);
  55118. for (i = 0; i < glyphsLength; ++i) {
  55119. glyph = glyphs[i];
  55120. if (isNum(glyph)) {
  55121. spacingLength = spacingDir * glyph * fontSize / 1000;
  55122. this.ctx.translate(spacingLength, 0);
  55123. current.x += spacingLength * textHScale;
  55124. continue;
  55125. }
  55126. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55127. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55128. if (!operatorList) {
  55129. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55130. continue;
  55131. }
  55132. this.processingType3 = glyph;
  55133. this.save();
  55134. ctx.scale(fontSize, fontSize);
  55135. ctx.transform.apply(ctx, fontMatrix);
  55136. this.executeOperatorList(operatorList);
  55137. this.restore();
  55138. var transformed = Util.applyTransform([
  55139. glyph.width,
  55140. 0
  55141. ], fontMatrix);
  55142. width = transformed[0] * fontSize + spacing;
  55143. ctx.translate(width, 0);
  55144. current.x += width * textHScale;
  55145. }
  55146. ctx.restore();
  55147. this.processingType3 = null;
  55148. },
  55149. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55150. },
  55151. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55152. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55153. this.clip();
  55154. this.endPath();
  55155. },
  55156. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55157. var pattern;
  55158. if (IR[0] === 'TilingPattern') {
  55159. var color = IR[1];
  55160. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55161. var self = this;
  55162. var canvasGraphicsFactory = {
  55163. createCanvasGraphics: function (ctx) {
  55164. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55165. }
  55166. };
  55167. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55168. } else {
  55169. pattern = getShadingPatternFromIR(IR);
  55170. }
  55171. return pattern;
  55172. },
  55173. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55174. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55175. },
  55176. setFillColorN: function CanvasGraphics_setFillColorN() {
  55177. this.current.fillColor = this.getColorN_Pattern(arguments);
  55178. this.current.patternFill = true;
  55179. },
  55180. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55181. var color = Util.makeCssRgb(r, g, b);
  55182. this.ctx.strokeStyle = color;
  55183. this.current.strokeColor = color;
  55184. },
  55185. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55186. var color = Util.makeCssRgb(r, g, b);
  55187. this.ctx.fillStyle = color;
  55188. this.current.fillColor = color;
  55189. this.current.patternFill = false;
  55190. },
  55191. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55192. var ctx = this.ctx;
  55193. this.save();
  55194. var pattern = getShadingPatternFromIR(patternIR);
  55195. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55196. var inv = ctx.mozCurrentTransformInverse;
  55197. if (inv) {
  55198. var canvas = ctx.canvas;
  55199. var width = canvas.width;
  55200. var height = canvas.height;
  55201. var bl = Util.applyTransform([
  55202. 0,
  55203. 0
  55204. ], inv);
  55205. var br = Util.applyTransform([
  55206. 0,
  55207. height
  55208. ], inv);
  55209. var ul = Util.applyTransform([
  55210. width,
  55211. 0
  55212. ], inv);
  55213. var ur = Util.applyTransform([
  55214. width,
  55215. height
  55216. ], inv);
  55217. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55218. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  55219. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  55220. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  55221. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  55222. } else {
  55223. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  55224. }
  55225. this.restore();
  55226. },
  55227. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  55228. error('Should not call beginInlineImage');
  55229. },
  55230. beginImageData: function CanvasGraphics_beginImageData() {
  55231. error('Should not call beginImageData');
  55232. },
  55233. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  55234. this.save();
  55235. this.baseTransformStack.push(this.baseTransform);
  55236. if (isArray(matrix) && matrix.length === 6) {
  55237. this.transform.apply(this, matrix);
  55238. }
  55239. this.baseTransform = this.ctx.mozCurrentTransform;
  55240. if (isArray(bbox) && bbox.length === 4) {
  55241. var width = bbox[2] - bbox[0];
  55242. var height = bbox[3] - bbox[1];
  55243. this.ctx.rect(bbox[0], bbox[1], width, height);
  55244. this.clip();
  55245. this.endPath();
  55246. }
  55247. },
  55248. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  55249. this.restore();
  55250. this.baseTransform = this.baseTransformStack.pop();
  55251. },
  55252. beginGroup: function CanvasGraphics_beginGroup(group) {
  55253. this.save();
  55254. var currentCtx = this.ctx;
  55255. if (!group.isolated) {
  55256. info('TODO: Support non-isolated groups.');
  55257. }
  55258. if (group.knockout) {
  55259. warn('Knockout groups not supported.');
  55260. }
  55261. var currentTransform = currentCtx.mozCurrentTransform;
  55262. if (group.matrix) {
  55263. currentCtx.transform.apply(currentCtx, group.matrix);
  55264. }
  55265. assert(group.bbox, 'Bounding box is required.');
  55266. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  55267. var canvasBounds = [
  55268. 0,
  55269. 0,
  55270. currentCtx.canvas.width,
  55271. currentCtx.canvas.height
  55272. ];
  55273. bounds = Util.intersect(bounds, canvasBounds) || [
  55274. 0,
  55275. 0,
  55276. 0,
  55277. 0
  55278. ];
  55279. var offsetX = Math.floor(bounds[0]);
  55280. var offsetY = Math.floor(bounds[1]);
  55281. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  55282. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  55283. var scaleX = 1, scaleY = 1;
  55284. if (drawnWidth > MAX_GROUP_SIZE) {
  55285. scaleX = drawnWidth / MAX_GROUP_SIZE;
  55286. drawnWidth = MAX_GROUP_SIZE;
  55287. }
  55288. if (drawnHeight > MAX_GROUP_SIZE) {
  55289. scaleY = drawnHeight / MAX_GROUP_SIZE;
  55290. drawnHeight = MAX_GROUP_SIZE;
  55291. }
  55292. var cacheId = 'groupAt' + this.groupLevel;
  55293. if (group.smask) {
  55294. cacheId += '_smask_' + this.smaskCounter++ % 2;
  55295. }
  55296. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55297. var groupCtx = scratchCanvas.context;
  55298. groupCtx.scale(1 / scaleX, 1 / scaleY);
  55299. groupCtx.translate(-offsetX, -offsetY);
  55300. groupCtx.transform.apply(groupCtx, currentTransform);
  55301. if (group.smask) {
  55302. this.smaskStack.push({
  55303. canvas: scratchCanvas.canvas,
  55304. context: groupCtx,
  55305. offsetX: offsetX,
  55306. offsetY: offsetY,
  55307. scaleX: scaleX,
  55308. scaleY: scaleY,
  55309. subtype: group.smask.subtype,
  55310. backdrop: group.smask.backdrop,
  55311. transferMap: group.smask.transferMap || null,
  55312. startTransformInverse: null
  55313. });
  55314. } else {
  55315. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  55316. currentCtx.translate(offsetX, offsetY);
  55317. currentCtx.scale(scaleX, scaleY);
  55318. }
  55319. copyCtxState(currentCtx, groupCtx);
  55320. this.ctx = groupCtx;
  55321. this.setGState([
  55322. [
  55323. 'BM',
  55324. 'Normal'
  55325. ],
  55326. [
  55327. 'ca',
  55328. 1
  55329. ],
  55330. [
  55331. 'CA',
  55332. 1
  55333. ]
  55334. ]);
  55335. this.groupStack.push(currentCtx);
  55336. this.groupLevel++;
  55337. this.current.activeSMask = null;
  55338. },
  55339. endGroup: function CanvasGraphics_endGroup(group) {
  55340. this.groupLevel--;
  55341. var groupCtx = this.ctx;
  55342. this.ctx = this.groupStack.pop();
  55343. if (this.ctx.imageSmoothingEnabled !== undefined) {
  55344. this.ctx.imageSmoothingEnabled = false;
  55345. } else {
  55346. this.ctx.mozImageSmoothingEnabled = false;
  55347. }
  55348. if (group.smask) {
  55349. this.tempSMask = this.smaskStack.pop();
  55350. } else {
  55351. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  55352. }
  55353. this.restore();
  55354. },
  55355. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  55356. this.save();
  55357. this.current = new CanvasExtraState();
  55358. if (this.baseTransform) {
  55359. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  55360. }
  55361. },
  55362. endAnnotations: function CanvasGraphics_endAnnotations() {
  55363. this.restore();
  55364. },
  55365. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  55366. this.save();
  55367. if (isArray(rect) && rect.length === 4) {
  55368. var width = rect[2] - rect[0];
  55369. var height = rect[3] - rect[1];
  55370. this.ctx.rect(rect[0], rect[1], width, height);
  55371. this.clip();
  55372. this.endPath();
  55373. }
  55374. this.transform.apply(this, transform);
  55375. this.transform.apply(this, matrix);
  55376. },
  55377. endAnnotation: function CanvasGraphics_endAnnotation() {
  55378. this.restore();
  55379. },
  55380. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  55381. var domImage = this.objs.get(objId);
  55382. if (!domImage) {
  55383. warn('Dependent image isn\'t ready yet');
  55384. return;
  55385. }
  55386. this.save();
  55387. var ctx = this.ctx;
  55388. ctx.scale(1 / w, -1 / h);
  55389. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  55390. if (this.imageLayer) {
  55391. var currentTransform = ctx.mozCurrentTransformInverse;
  55392. var position = this.getCanvasPosition(0, 0);
  55393. this.imageLayer.appendImage({
  55394. objId: objId,
  55395. left: position[0],
  55396. top: position[1],
  55397. width: w / currentTransform[0],
  55398. height: h / currentTransform[3]
  55399. });
  55400. }
  55401. this.restore();
  55402. },
  55403. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  55404. var ctx = this.ctx;
  55405. var width = img.width, height = img.height;
  55406. var fillColor = this.current.fillColor;
  55407. var isPatternFill = this.current.patternFill;
  55408. var glyph = this.processingType3;
  55409. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  55410. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  55411. glyph.compiled = compileType3Glyph({
  55412. data: img.data,
  55413. width: width,
  55414. height: height
  55415. });
  55416. } else {
  55417. glyph.compiled = null;
  55418. }
  55419. }
  55420. if (glyph && glyph.compiled) {
  55421. glyph.compiled(ctx);
  55422. return;
  55423. }
  55424. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55425. var maskCtx = maskCanvas.context;
  55426. maskCtx.save();
  55427. putBinaryImageMask(maskCtx, img);
  55428. maskCtx.globalCompositeOperation = 'source-in';
  55429. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55430. maskCtx.fillRect(0, 0, width, height);
  55431. maskCtx.restore();
  55432. this.paintInlineImageXObject(maskCanvas.canvas);
  55433. },
  55434. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  55435. var width = imgData.width;
  55436. var height = imgData.height;
  55437. var fillColor = this.current.fillColor;
  55438. var isPatternFill = this.current.patternFill;
  55439. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55440. var maskCtx = maskCanvas.context;
  55441. maskCtx.save();
  55442. putBinaryImageMask(maskCtx, imgData);
  55443. maskCtx.globalCompositeOperation = 'source-in';
  55444. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55445. maskCtx.fillRect(0, 0, width, height);
  55446. maskCtx.restore();
  55447. var ctx = this.ctx;
  55448. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55449. ctx.save();
  55450. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  55451. ctx.scale(1, -1);
  55452. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55453. ctx.restore();
  55454. }
  55455. },
  55456. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  55457. var ctx = this.ctx;
  55458. var fillColor = this.current.fillColor;
  55459. var isPatternFill = this.current.patternFill;
  55460. for (var i = 0, ii = images.length; i < ii; i++) {
  55461. var image = images[i];
  55462. var width = image.width, height = image.height;
  55463. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55464. var maskCtx = maskCanvas.context;
  55465. maskCtx.save();
  55466. putBinaryImageMask(maskCtx, image);
  55467. maskCtx.globalCompositeOperation = 'source-in';
  55468. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55469. maskCtx.fillRect(0, 0, width, height);
  55470. maskCtx.restore();
  55471. ctx.save();
  55472. ctx.transform.apply(ctx, image.transform);
  55473. ctx.scale(1, -1);
  55474. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55475. ctx.restore();
  55476. }
  55477. },
  55478. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  55479. var imgData = this.objs.get(objId);
  55480. if (!imgData) {
  55481. warn('Dependent image isn\'t ready yet');
  55482. return;
  55483. }
  55484. this.paintInlineImageXObject(imgData);
  55485. },
  55486. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  55487. var imgData = this.objs.get(objId);
  55488. if (!imgData) {
  55489. warn('Dependent image isn\'t ready yet');
  55490. return;
  55491. }
  55492. var width = imgData.width;
  55493. var height = imgData.height;
  55494. var map = [];
  55495. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55496. map.push({
  55497. transform: [
  55498. scaleX,
  55499. 0,
  55500. 0,
  55501. scaleY,
  55502. positions[i],
  55503. positions[i + 1]
  55504. ],
  55505. x: 0,
  55506. y: 0,
  55507. w: width,
  55508. h: height
  55509. });
  55510. }
  55511. this.paintInlineImageXObjectGroup(imgData, map);
  55512. },
  55513. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  55514. var width = imgData.width;
  55515. var height = imgData.height;
  55516. var ctx = this.ctx;
  55517. this.save();
  55518. ctx.scale(1 / width, -1 / height);
  55519. var currentTransform = ctx.mozCurrentTransformInverse;
  55520. var a = currentTransform[0], b = currentTransform[1];
  55521. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  55522. var c = currentTransform[2], d = currentTransform[3];
  55523. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  55524. var imgToPaint, tmpCanvas;
  55525. if (imgData instanceof HTMLElement || !imgData.data) {
  55526. imgToPaint = imgData;
  55527. } else {
  55528. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  55529. var tmpCtx = tmpCanvas.context;
  55530. putBinaryImageData(tmpCtx, imgData);
  55531. imgToPaint = tmpCanvas.canvas;
  55532. }
  55533. var paintWidth = width, paintHeight = height;
  55534. var tmpCanvasId = 'prescale1';
  55535. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  55536. var newWidth = paintWidth, newHeight = paintHeight;
  55537. if (widthScale > 2 && paintWidth > 1) {
  55538. newWidth = Math.ceil(paintWidth / 2);
  55539. widthScale /= paintWidth / newWidth;
  55540. }
  55541. if (heightScale > 2 && paintHeight > 1) {
  55542. newHeight = Math.ceil(paintHeight / 2);
  55543. heightScale /= paintHeight / newHeight;
  55544. }
  55545. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  55546. tmpCtx = tmpCanvas.context;
  55547. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  55548. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  55549. imgToPaint = tmpCanvas.canvas;
  55550. paintWidth = newWidth;
  55551. paintHeight = newHeight;
  55552. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  55553. }
  55554. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  55555. if (this.imageLayer) {
  55556. var position = this.getCanvasPosition(0, -height);
  55557. this.imageLayer.appendImage({
  55558. imgData: imgData,
  55559. left: position[0],
  55560. top: position[1],
  55561. width: width / currentTransform[0],
  55562. height: height / currentTransform[3]
  55563. });
  55564. }
  55565. this.restore();
  55566. },
  55567. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  55568. var ctx = this.ctx;
  55569. var w = imgData.width;
  55570. var h = imgData.height;
  55571. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  55572. var tmpCtx = tmpCanvas.context;
  55573. putBinaryImageData(tmpCtx, imgData);
  55574. for (var i = 0, ii = map.length; i < ii; i++) {
  55575. var entry = map[i];
  55576. ctx.save();
  55577. ctx.transform.apply(ctx, entry.transform);
  55578. ctx.scale(1, -1);
  55579. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  55580. if (this.imageLayer) {
  55581. var position = this.getCanvasPosition(entry.x, entry.y);
  55582. this.imageLayer.appendImage({
  55583. imgData: imgData,
  55584. left: position[0],
  55585. top: position[1],
  55586. width: w,
  55587. height: h
  55588. });
  55589. }
  55590. ctx.restore();
  55591. }
  55592. },
  55593. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  55594. this.ctx.fillRect(0, 0, 1, 1);
  55595. },
  55596. paintXObject: function CanvasGraphics_paintXObject() {
  55597. warn('Unsupported \'paintXObject\' command.');
  55598. },
  55599. markPoint: function CanvasGraphics_markPoint(tag) {
  55600. },
  55601. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  55602. },
  55603. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  55604. },
  55605. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  55606. },
  55607. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  55608. },
  55609. beginCompat: function CanvasGraphics_beginCompat() {
  55610. },
  55611. endCompat: function CanvasGraphics_endCompat() {
  55612. },
  55613. consumePath: function CanvasGraphics_consumePath() {
  55614. var ctx = this.ctx;
  55615. if (this.pendingClip) {
  55616. if (this.pendingClip === EO_CLIP) {
  55617. ctx.clip('evenodd');
  55618. } else {
  55619. ctx.clip();
  55620. }
  55621. this.pendingClip = null;
  55622. }
  55623. ctx.beginPath();
  55624. },
  55625. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  55626. if (this.cachedGetSinglePixelWidth === null) {
  55627. this.ctx.save();
  55628. var inverse = this.ctx.mozCurrentTransformInverse;
  55629. this.ctx.restore();
  55630. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  55631. }
  55632. return this.cachedGetSinglePixelWidth;
  55633. },
  55634. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  55635. var transform = this.ctx.mozCurrentTransform;
  55636. return [
  55637. transform[0] * x + transform[2] * y + transform[4],
  55638. transform[1] * x + transform[3] * y + transform[5]
  55639. ];
  55640. }
  55641. };
  55642. for (var op in OPS) {
  55643. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  55644. }
  55645. return CanvasGraphics;
  55646. }();
  55647. exports.CanvasGraphics = CanvasGraphics;
  55648. /***/ }),
  55649. /* 45 */
  55650. /***/ (function(module, exports, __w_pdfjs_require__) {
  55651. "use strict";
  55652. var sharedUtil = __w_pdfjs_require__(0);
  55653. var assert = sharedUtil.assert;
  55654. var bytesToString = sharedUtil.bytesToString;
  55655. var string32 = sharedUtil.string32;
  55656. var shadow = sharedUtil.shadow;
  55657. var warn = sharedUtil.warn;
  55658. function FontLoader(docId) {
  55659. this.docId = docId;
  55660. this.styleElement = null;
  55661. this.nativeFontFaces = [];
  55662. this.loadTestFontId = 0;
  55663. this.loadingContext = {
  55664. requests: [],
  55665. nextRequestId: 0
  55666. };
  55667. }
  55668. FontLoader.prototype = {
  55669. insertRule: function fontLoaderInsertRule(rule) {
  55670. var styleElement = this.styleElement;
  55671. if (!styleElement) {
  55672. styleElement = this.styleElement = document.createElement('style');
  55673. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  55674. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  55675. }
  55676. var styleSheet = styleElement.sheet;
  55677. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  55678. },
  55679. clear: function fontLoaderClear() {
  55680. if (this.styleElement) {
  55681. this.styleElement.remove();
  55682. this.styleElement = null;
  55683. }
  55684. this.nativeFontFaces.forEach(function (nativeFontFace) {
  55685. document.fonts.delete(nativeFontFace);
  55686. });
  55687. this.nativeFontFaces.length = 0;
  55688. }
  55689. };
  55690. var getLoadTestFont = function () {
  55691. 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==');
  55692. };
  55693. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  55694. get: function () {
  55695. return shadow(this, 'loadTestFont', getLoadTestFont());
  55696. },
  55697. configurable: true
  55698. });
  55699. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  55700. this.nativeFontFaces.push(nativeFontFace);
  55701. document.fonts.add(nativeFontFace);
  55702. };
  55703. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  55704. var rules = [];
  55705. var fontsToLoad = [];
  55706. var fontLoadPromises = [];
  55707. var getNativeFontPromise = function (nativeFontFace) {
  55708. return nativeFontFace.loaded.catch(function (e) {
  55709. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  55710. });
  55711. };
  55712. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  55713. for (var i = 0, ii = fonts.length; i < ii; i++) {
  55714. var font = fonts[i];
  55715. if (font.attached || font.loading === false) {
  55716. continue;
  55717. }
  55718. font.attached = true;
  55719. if (isFontLoadingAPISupported) {
  55720. var nativeFontFace = font.createNativeFontFace();
  55721. if (nativeFontFace) {
  55722. this.addNativeFontFace(nativeFontFace);
  55723. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  55724. }
  55725. } else {
  55726. var rule = font.createFontFaceRule();
  55727. if (rule) {
  55728. this.insertRule(rule);
  55729. rules.push(rule);
  55730. fontsToLoad.push(font);
  55731. }
  55732. }
  55733. }
  55734. var request = this.queueLoadingCallback(callback);
  55735. if (isFontLoadingAPISupported) {
  55736. Promise.all(fontLoadPromises).then(function () {
  55737. request.complete();
  55738. });
  55739. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  55740. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  55741. } else {
  55742. request.complete();
  55743. }
  55744. };
  55745. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  55746. function LoadLoader_completeRequest() {
  55747. assert(!request.end, 'completeRequest() cannot be called twice');
  55748. request.end = Date.now();
  55749. while (context.requests.length > 0 && context.requests[0].end) {
  55750. var otherRequest = context.requests.shift();
  55751. setTimeout(otherRequest.callback, 0);
  55752. }
  55753. }
  55754. var context = this.loadingContext;
  55755. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  55756. var request = {
  55757. id: requestId,
  55758. complete: LoadLoader_completeRequest,
  55759. callback: callback,
  55760. started: Date.now()
  55761. };
  55762. context.requests.push(request);
  55763. return request;
  55764. };
  55765. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  55766. function int32(data, offset) {
  55767. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  55768. }
  55769. function spliceString(s, offset, remove, insert) {
  55770. var chunk1 = s.substr(0, offset);
  55771. var chunk2 = s.substr(offset + remove);
  55772. return chunk1 + insert + chunk2;
  55773. }
  55774. var i, ii;
  55775. var canvas = document.createElement('canvas');
  55776. canvas.width = 1;
  55777. canvas.height = 1;
  55778. var ctx = canvas.getContext('2d');
  55779. var called = 0;
  55780. function isFontReady(name, callback) {
  55781. called++;
  55782. if (called > 30) {
  55783. warn('Load test font never loaded.');
  55784. callback();
  55785. return;
  55786. }
  55787. ctx.font = '30px ' + name;
  55788. ctx.fillText('.', 0, 20);
  55789. var imageData = ctx.getImageData(0, 0, 1, 1);
  55790. if (imageData.data[3] > 0) {
  55791. callback();
  55792. return;
  55793. }
  55794. setTimeout(isFontReady.bind(null, name, callback));
  55795. }
  55796. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  55797. var data = this.loadTestFont;
  55798. var COMMENT_OFFSET = 976;
  55799. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  55800. var CFF_CHECKSUM_OFFSET = 16;
  55801. var XXXX_VALUE = 0x58585858;
  55802. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  55803. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  55804. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  55805. }
  55806. if (i < loadTestFontId.length) {
  55807. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  55808. }
  55809. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  55810. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  55811. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  55812. this.insertRule(rule);
  55813. var names = [];
  55814. for (i = 0, ii = fonts.length; i < ii; i++) {
  55815. names.push(fonts[i].loadedName);
  55816. }
  55817. names.push(loadTestFontId);
  55818. var div = document.createElement('div');
  55819. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  55820. for (i = 0, ii = names.length; i < ii; ++i) {
  55821. var span = document.createElement('span');
  55822. span.textContent = 'Hi';
  55823. span.style.fontFamily = names[i];
  55824. div.appendChild(span);
  55825. }
  55826. document.body.appendChild(div);
  55827. isFontReady(loadTestFontId, function () {
  55828. document.body.removeChild(div);
  55829. request.complete();
  55830. });
  55831. };
  55832. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  55833. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  55834. if (typeof navigator === 'undefined') {
  55835. return true;
  55836. }
  55837. var supported = false;
  55838. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  55839. if (m && m[1] >= 14) {
  55840. supported = true;
  55841. }
  55842. return supported;
  55843. };
  55844. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  55845. get: function () {
  55846. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  55847. },
  55848. enumerable: true,
  55849. configurable: true
  55850. });
  55851. var IsEvalSupportedCached = {
  55852. get value() {
  55853. return shadow(this, 'value', sharedUtil.isEvalSupported());
  55854. }
  55855. };
  55856. var FontFaceObject = function FontFaceObjectClosure() {
  55857. function FontFaceObject(translatedData, options) {
  55858. this.compiledGlyphs = Object.create(null);
  55859. for (var i in translatedData) {
  55860. this[i] = translatedData[i];
  55861. }
  55862. this.options = options;
  55863. }
  55864. FontFaceObject.prototype = {
  55865. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  55866. if (!this.data) {
  55867. return null;
  55868. }
  55869. if (this.options.disableFontFace) {
  55870. this.disableFontFace = true;
  55871. return null;
  55872. }
  55873. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  55874. if (this.options.fontRegistry) {
  55875. this.options.fontRegistry.registerFont(this);
  55876. }
  55877. return nativeFontFace;
  55878. },
  55879. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  55880. if (!this.data) {
  55881. return null;
  55882. }
  55883. if (this.options.disableFontFace) {
  55884. this.disableFontFace = true;
  55885. return null;
  55886. }
  55887. var data = bytesToString(new Uint8Array(this.data));
  55888. var fontName = this.loadedName;
  55889. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  55890. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  55891. if (this.options.fontRegistry) {
  55892. this.options.fontRegistry.registerFont(this, url);
  55893. }
  55894. return rule;
  55895. },
  55896. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  55897. if (!(character in this.compiledGlyphs)) {
  55898. var cmds = objs.get(this.loadedName + '_path_' + character);
  55899. var current, i, len;
  55900. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  55901. var args, js = '';
  55902. for (i = 0, len = cmds.length; i < len; i++) {
  55903. current = cmds[i];
  55904. if (current.args !== undefined) {
  55905. args = current.args.join(',');
  55906. } else {
  55907. args = '';
  55908. }
  55909. js += 'c.' + current.cmd + '(' + args + ');\n';
  55910. }
  55911. this.compiledGlyphs[character] = new Function('c', 'size', js);
  55912. } else {
  55913. this.compiledGlyphs[character] = function (c, size) {
  55914. for (i = 0, len = cmds.length; i < len; i++) {
  55915. current = cmds[i];
  55916. if (current.cmd === 'scale') {
  55917. current.args = [
  55918. size,
  55919. -size
  55920. ];
  55921. }
  55922. c[current.cmd].apply(c, current.args);
  55923. }
  55924. };
  55925. }
  55926. }
  55927. return this.compiledGlyphs[character];
  55928. }
  55929. };
  55930. return FontFaceObject;
  55931. }();
  55932. exports.FontFaceObject = FontFaceObject;
  55933. exports.FontLoader = FontLoader;
  55934. /***/ }),
  55935. /* 46 */
  55936. /***/ (function(module, exports, __w_pdfjs_require__) {
  55937. "use strict";
  55938. var sharedUtil = __w_pdfjs_require__(0);
  55939. var displayWebGL = __w_pdfjs_require__(25);
  55940. var Util = sharedUtil.Util;
  55941. var info = sharedUtil.info;
  55942. var isArray = sharedUtil.isArray;
  55943. var error = sharedUtil.error;
  55944. var WebGLUtils = displayWebGL.WebGLUtils;
  55945. var ShadingIRs = {};
  55946. ShadingIRs.RadialAxial = {
  55947. fromIR: function RadialAxial_fromIR(raw) {
  55948. var type = raw[1];
  55949. var colorStops = raw[2];
  55950. var p0 = raw[3];
  55951. var p1 = raw[4];
  55952. var r0 = raw[5];
  55953. var r1 = raw[6];
  55954. return {
  55955. type: 'Pattern',
  55956. getPattern: function RadialAxial_getPattern(ctx) {
  55957. var grad;
  55958. if (type === 'axial') {
  55959. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  55960. } else if (type === 'radial') {
  55961. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  55962. }
  55963. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  55964. var c = colorStops[i];
  55965. grad.addColorStop(c[0], c[1]);
  55966. }
  55967. return grad;
  55968. }
  55969. };
  55970. }
  55971. };
  55972. var createMeshCanvas = function createMeshCanvasClosure() {
  55973. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  55974. var coords = context.coords, colors = context.colors;
  55975. var bytes = data.data, rowSize = data.width * 4;
  55976. var tmp;
  55977. if (coords[p1 + 1] > coords[p2 + 1]) {
  55978. tmp = p1;
  55979. p1 = p2;
  55980. p2 = tmp;
  55981. tmp = c1;
  55982. c1 = c2;
  55983. c2 = tmp;
  55984. }
  55985. if (coords[p2 + 1] > coords[p3 + 1]) {
  55986. tmp = p2;
  55987. p2 = p3;
  55988. p3 = tmp;
  55989. tmp = c2;
  55990. c2 = c3;
  55991. c3 = tmp;
  55992. }
  55993. if (coords[p1 + 1] > coords[p2 + 1]) {
  55994. tmp = p1;
  55995. p1 = p2;
  55996. p2 = tmp;
  55997. tmp = c1;
  55998. c1 = c2;
  55999. c2 = tmp;
  56000. }
  56001. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56002. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56003. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56004. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56005. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56006. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56007. if (y1 >= y3) {
  56008. return;
  56009. }
  56010. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56011. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56012. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56013. var minY = Math.round(y1), maxY = Math.round(y3);
  56014. var xa, car, cag, cab;
  56015. var xb, cbr, cbg, cbb;
  56016. var k;
  56017. for (var y = minY; y <= maxY; y++) {
  56018. if (y < y2) {
  56019. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56020. xa = x1 - (x1 - x2) * k;
  56021. car = c1r - (c1r - c2r) * k;
  56022. cag = c1g - (c1g - c2g) * k;
  56023. cab = c1b - (c1b - c2b) * k;
  56024. } else {
  56025. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56026. xa = x2 - (x2 - x3) * k;
  56027. car = c2r - (c2r - c3r) * k;
  56028. cag = c2g - (c2g - c3g) * k;
  56029. cab = c2b - (c2b - c3b) * k;
  56030. }
  56031. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56032. xb = x1 - (x1 - x3) * k;
  56033. cbr = c1r - (c1r - c3r) * k;
  56034. cbg = c1g - (c1g - c3g) * k;
  56035. cbb = c1b - (c1b - c3b) * k;
  56036. var x1_ = Math.round(Math.min(xa, xb));
  56037. var x2_ = Math.round(Math.max(xa, xb));
  56038. var j = rowSize * y + x1_ * 4;
  56039. for (var x = x1_; x <= x2_; x++) {
  56040. k = (xa - x) / (xa - xb);
  56041. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56042. bytes[j++] = car - (car - cbr) * k | 0;
  56043. bytes[j++] = cag - (cag - cbg) * k | 0;
  56044. bytes[j++] = cab - (cab - cbb) * k | 0;
  56045. bytes[j++] = 255;
  56046. }
  56047. }
  56048. }
  56049. function drawFigure(data, figure, context) {
  56050. var ps = figure.coords;
  56051. var cs = figure.colors;
  56052. var i, ii;
  56053. switch (figure.type) {
  56054. case 'lattice':
  56055. var verticesPerRow = figure.verticesPerRow;
  56056. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56057. var cols = verticesPerRow - 1;
  56058. for (i = 0; i < rows; i++) {
  56059. var q = i * verticesPerRow;
  56060. for (var j = 0; j < cols; j++, q++) {
  56061. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56062. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56063. }
  56064. }
  56065. break;
  56066. case 'triangles':
  56067. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56068. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56069. }
  56070. break;
  56071. default:
  56072. error('illigal figure');
  56073. break;
  56074. }
  56075. }
  56076. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56077. var EXPECTED_SCALE = 1.1;
  56078. var MAX_PATTERN_SIZE = 3000;
  56079. var BORDER_SIZE = 2;
  56080. var offsetX = Math.floor(bounds[0]);
  56081. var offsetY = Math.floor(bounds[1]);
  56082. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56083. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56084. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56085. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56086. var scaleX = boundsWidth / width;
  56087. var scaleY = boundsHeight / height;
  56088. var context = {
  56089. coords: coords,
  56090. colors: colors,
  56091. offsetX: -offsetX,
  56092. offsetY: -offsetY,
  56093. scaleX: 1 / scaleX,
  56094. scaleY: 1 / scaleY
  56095. };
  56096. var paddedWidth = width + BORDER_SIZE * 2;
  56097. var paddedHeight = height + BORDER_SIZE * 2;
  56098. var canvas, tmpCanvas, i, ii;
  56099. if (WebGLUtils.isEnabled) {
  56100. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56101. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56102. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56103. canvas = tmpCanvas.canvas;
  56104. } else {
  56105. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56106. var tmpCtx = tmpCanvas.context;
  56107. var data = tmpCtx.createImageData(width, height);
  56108. if (backgroundColor) {
  56109. var bytes = data.data;
  56110. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56111. bytes[i] = backgroundColor[0];
  56112. bytes[i + 1] = backgroundColor[1];
  56113. bytes[i + 2] = backgroundColor[2];
  56114. bytes[i + 3] = 255;
  56115. }
  56116. }
  56117. for (i = 0; i < figures.length; i++) {
  56118. drawFigure(data, figures[i], context);
  56119. }
  56120. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56121. canvas = tmpCanvas.canvas;
  56122. }
  56123. return {
  56124. canvas: canvas,
  56125. offsetX: offsetX - BORDER_SIZE * scaleX,
  56126. offsetY: offsetY - BORDER_SIZE * scaleY,
  56127. scaleX: scaleX,
  56128. scaleY: scaleY
  56129. };
  56130. }
  56131. return createMeshCanvas;
  56132. }();
  56133. ShadingIRs.Mesh = {
  56134. fromIR: function Mesh_fromIR(raw) {
  56135. var coords = raw[2];
  56136. var colors = raw[3];
  56137. var figures = raw[4];
  56138. var bounds = raw[5];
  56139. var matrix = raw[6];
  56140. var background = raw[8];
  56141. return {
  56142. type: 'Pattern',
  56143. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56144. var scale;
  56145. if (shadingFill) {
  56146. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56147. } else {
  56148. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56149. if (matrix) {
  56150. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56151. scale = [
  56152. scale[0] * matrixScale[0],
  56153. scale[1] * matrixScale[1]
  56154. ];
  56155. }
  56156. }
  56157. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56158. if (!shadingFill) {
  56159. ctx.setTransform.apply(ctx, owner.baseTransform);
  56160. if (matrix) {
  56161. ctx.transform.apply(ctx, matrix);
  56162. }
  56163. }
  56164. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56165. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56166. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56167. }
  56168. };
  56169. }
  56170. };
  56171. ShadingIRs.Dummy = {
  56172. fromIR: function Dummy_fromIR() {
  56173. return {
  56174. type: 'Pattern',
  56175. getPattern: function Dummy_fromIR_getPattern() {
  56176. return 'hotpink';
  56177. }
  56178. };
  56179. }
  56180. };
  56181. function getShadingPatternFromIR(raw) {
  56182. var shadingIR = ShadingIRs[raw[0]];
  56183. if (!shadingIR) {
  56184. error('Unknown IR type: ' + raw[0]);
  56185. }
  56186. return shadingIR.fromIR(raw);
  56187. }
  56188. var TilingPattern = function TilingPatternClosure() {
  56189. var PaintType = {
  56190. COLORED: 1,
  56191. UNCOLORED: 2
  56192. };
  56193. var MAX_PATTERN_SIZE = 3000;
  56194. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56195. this.operatorList = IR[2];
  56196. this.matrix = IR[3] || [
  56197. 1,
  56198. 0,
  56199. 0,
  56200. 1,
  56201. 0,
  56202. 0
  56203. ];
  56204. this.bbox = IR[4];
  56205. this.xstep = IR[5];
  56206. this.ystep = IR[6];
  56207. this.paintType = IR[7];
  56208. this.tilingType = IR[8];
  56209. this.color = color;
  56210. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56211. this.baseTransform = baseTransform;
  56212. this.type = 'Pattern';
  56213. this.ctx = ctx;
  56214. }
  56215. TilingPattern.prototype = {
  56216. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56217. var operatorList = this.operatorList;
  56218. var bbox = this.bbox;
  56219. var xstep = this.xstep;
  56220. var ystep = this.ystep;
  56221. var paintType = this.paintType;
  56222. var tilingType = this.tilingType;
  56223. var color = this.color;
  56224. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  56225. info('TilingType: ' + tilingType);
  56226. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  56227. var topLeft = [
  56228. x0,
  56229. y0
  56230. ];
  56231. var botRight = [
  56232. x0 + xstep,
  56233. y0 + ystep
  56234. ];
  56235. var width = botRight[0] - topLeft[0];
  56236. var height = botRight[1] - topLeft[1];
  56237. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  56238. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  56239. var combinedScale = [
  56240. matrixScale[0] * curMatrixScale[0],
  56241. matrixScale[1] * curMatrixScale[1]
  56242. ];
  56243. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  56244. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  56245. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  56246. var tmpCtx = tmpCanvas.context;
  56247. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  56248. graphics.groupLevel = owner.groupLevel;
  56249. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  56250. this.setScale(width, height, xstep, ystep);
  56251. this.transformToScale(graphics);
  56252. var tmpTranslate = [
  56253. 1,
  56254. 0,
  56255. 0,
  56256. 1,
  56257. -topLeft[0],
  56258. -topLeft[1]
  56259. ];
  56260. graphics.transform.apply(graphics, tmpTranslate);
  56261. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  56262. graphics.executeOperatorList(operatorList);
  56263. return tmpCanvas.canvas;
  56264. },
  56265. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  56266. this.scale = [
  56267. width / xstep,
  56268. height / ystep
  56269. ];
  56270. },
  56271. transformToScale: function TilingPattern_transformToScale(graphics) {
  56272. var scale = this.scale;
  56273. var tmpScale = [
  56274. scale[0],
  56275. 0,
  56276. 0,
  56277. scale[1],
  56278. 0,
  56279. 0
  56280. ];
  56281. graphics.transform.apply(graphics, tmpScale);
  56282. },
  56283. scaleToContext: function TilingPattern_scaleToContext() {
  56284. var scale = this.scale;
  56285. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  56286. },
  56287. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  56288. if (bbox && isArray(bbox) && bbox.length === 4) {
  56289. var bboxWidth = x1 - x0;
  56290. var bboxHeight = y1 - y0;
  56291. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  56292. graphics.clip();
  56293. graphics.endPath();
  56294. }
  56295. },
  56296. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  56297. switch (paintType) {
  56298. case PaintType.COLORED:
  56299. var ctx = this.ctx;
  56300. context.fillStyle = ctx.fillStyle;
  56301. context.strokeStyle = ctx.strokeStyle;
  56302. break;
  56303. case PaintType.UNCOLORED:
  56304. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  56305. context.fillStyle = cssColor;
  56306. context.strokeStyle = cssColor;
  56307. break;
  56308. default:
  56309. error('Unsupported paint type: ' + paintType);
  56310. }
  56311. },
  56312. getPattern: function TilingPattern_getPattern(ctx, owner) {
  56313. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  56314. ctx = this.ctx;
  56315. ctx.setTransform.apply(ctx, this.baseTransform);
  56316. ctx.transform.apply(ctx, this.matrix);
  56317. this.scaleToContext();
  56318. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  56319. }
  56320. };
  56321. return TilingPattern;
  56322. }();
  56323. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  56324. exports.TilingPattern = TilingPattern;
  56325. /***/ }),
  56326. /* 47 */
  56327. /***/ (function(module, exports, __w_pdfjs_require__) {
  56328. "use strict";
  56329. /* WEBPACK VAR INJECTION */(function(global) {
  56330. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  56331. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  56332. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  56333. var isAndroid = /Android/.test(userAgent);
  56334. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  56335. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  56336. var isChrome = userAgent.indexOf('Chrom') >= 0;
  56337. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  56338. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  56339. var isIE = userAgent.indexOf('Trident') >= 0;
  56340. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  56341. var isOpera = userAgent.indexOf('Opera') >= 0;
  56342. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  56343. var hasDOM = typeof window === 'object' && typeof document === 'object';
  56344. if (typeof PDFJS === 'undefined') {
  56345. globalScope.PDFJS = {};
  56346. }
  56347. PDFJS.compatibilityChecked = true;
  56348. (function checkTypedArrayCompatibility() {
  56349. if (typeof Uint8Array !== 'undefined') {
  56350. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  56351. Uint8Array.prototype.subarray = function subarray(start, end) {
  56352. return new Uint8Array(this.slice(start, end));
  56353. };
  56354. Float32Array.prototype.subarray = function subarray(start, end) {
  56355. return new Float32Array(this.slice(start, end));
  56356. };
  56357. }
  56358. if (typeof Float64Array === 'undefined') {
  56359. globalScope.Float64Array = Float32Array;
  56360. }
  56361. return;
  56362. }
  56363. function subarray(start, end) {
  56364. return new TypedArray(this.slice(start, end));
  56365. }
  56366. function setArrayOffset(array, offset) {
  56367. if (arguments.length < 2) {
  56368. offset = 0;
  56369. }
  56370. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  56371. this[offset] = array[i] & 0xFF;
  56372. }
  56373. }
  56374. function TypedArray(arg1) {
  56375. var result, i, n;
  56376. if (typeof arg1 === 'number') {
  56377. result = [];
  56378. for (i = 0; i < arg1; ++i) {
  56379. result[i] = 0;
  56380. }
  56381. } else if ('slice' in arg1) {
  56382. result = arg1.slice(0);
  56383. } else {
  56384. result = [];
  56385. for (i = 0, n = arg1.length; i < n; ++i) {
  56386. result[i] = arg1[i];
  56387. }
  56388. }
  56389. result.subarray = subarray;
  56390. result.buffer = result;
  56391. result.byteLength = result.length;
  56392. result.set = setArrayOffset;
  56393. if (typeof arg1 === 'object' && arg1.buffer) {
  56394. result.buffer = arg1.buffer;
  56395. }
  56396. return result;
  56397. }
  56398. globalScope.Uint8Array = TypedArray;
  56399. globalScope.Int8Array = TypedArray;
  56400. globalScope.Uint32Array = TypedArray;
  56401. globalScope.Int32Array = TypedArray;
  56402. globalScope.Uint16Array = TypedArray;
  56403. globalScope.Float32Array = TypedArray;
  56404. globalScope.Float64Array = TypedArray;
  56405. }());
  56406. (function normalizeURLObject() {
  56407. if (!globalScope.URL) {
  56408. globalScope.URL = globalScope.webkitURL;
  56409. }
  56410. }());
  56411. (function checkObjectDefinePropertyCompatibility() {
  56412. if (typeof Object.defineProperty !== 'undefined') {
  56413. var definePropertyPossible = true;
  56414. try {
  56415. if (hasDOM) {
  56416. Object.defineProperty(new Image(), 'id', { value: 'test' });
  56417. }
  56418. var Test = function Test() {
  56419. };
  56420. Test.prototype = {
  56421. get id() {
  56422. }
  56423. };
  56424. Object.defineProperty(new Test(), 'id', {
  56425. value: '',
  56426. configurable: true,
  56427. enumerable: true,
  56428. writable: false
  56429. });
  56430. } catch (e) {
  56431. definePropertyPossible = false;
  56432. }
  56433. if (definePropertyPossible) {
  56434. return;
  56435. }
  56436. }
  56437. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  56438. delete obj[name];
  56439. if ('get' in def) {
  56440. obj.__defineGetter__(name, def['get']);
  56441. }
  56442. if ('set' in def) {
  56443. obj.__defineSetter__(name, def['set']);
  56444. }
  56445. if ('value' in def) {
  56446. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  56447. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  56448. return value;
  56449. });
  56450. return value;
  56451. });
  56452. obj[name] = def.value;
  56453. }
  56454. };
  56455. }());
  56456. (function checkXMLHttpRequestResponseCompatibility() {
  56457. if (typeof XMLHttpRequest === 'undefined') {
  56458. return;
  56459. }
  56460. var xhrPrototype = XMLHttpRequest.prototype;
  56461. var xhr = new XMLHttpRequest();
  56462. if (!('overrideMimeType' in xhr)) {
  56463. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  56464. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  56465. }
  56466. });
  56467. }
  56468. if ('responseType' in xhr) {
  56469. return;
  56470. }
  56471. Object.defineProperty(xhrPrototype, 'responseType', {
  56472. get: function xmlHttpRequestGetResponseType() {
  56473. return this._responseType || 'text';
  56474. },
  56475. set: function xmlHttpRequestSetResponseType(value) {
  56476. if (value === 'text' || value === 'arraybuffer') {
  56477. this._responseType = value;
  56478. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  56479. this.overrideMimeType('text/plain; charset=x-user-defined');
  56480. }
  56481. }
  56482. }
  56483. });
  56484. if (typeof VBArray !== 'undefined') {
  56485. Object.defineProperty(xhrPrototype, 'response', {
  56486. get: function xmlHttpRequestResponseGet() {
  56487. if (this.responseType === 'arraybuffer') {
  56488. return new Uint8Array(new VBArray(this.responseBody).toArray());
  56489. }
  56490. return this.responseText;
  56491. }
  56492. });
  56493. return;
  56494. }
  56495. Object.defineProperty(xhrPrototype, 'response', {
  56496. get: function xmlHttpRequestResponseGet() {
  56497. if (this.responseType !== 'arraybuffer') {
  56498. return this.responseText;
  56499. }
  56500. var text = this.responseText;
  56501. var i, n = text.length;
  56502. var result = new Uint8Array(n);
  56503. for (i = 0; i < n; ++i) {
  56504. result[i] = text.charCodeAt(i) & 0xFF;
  56505. }
  56506. return result.buffer;
  56507. }
  56508. });
  56509. }());
  56510. (function checkWindowBtoaCompatibility() {
  56511. if ('btoa' in globalScope) {
  56512. return;
  56513. }
  56514. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56515. globalScope.btoa = function (chars) {
  56516. var buffer = '';
  56517. var i, n;
  56518. for (i = 0, n = chars.length; i < n; i += 3) {
  56519. var b1 = chars.charCodeAt(i) & 0xFF;
  56520. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  56521. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  56522. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  56523. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  56524. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  56525. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  56526. }
  56527. return buffer;
  56528. };
  56529. }());
  56530. (function checkWindowAtobCompatibility() {
  56531. if ('atob' in globalScope) {
  56532. return;
  56533. }
  56534. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56535. globalScope.atob = function (input) {
  56536. input = input.replace(/=+$/, '');
  56537. if (input.length % 4 === 1) {
  56538. throw new Error('bad atob input');
  56539. }
  56540. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  56541. buffer = digits.indexOf(buffer);
  56542. }
  56543. return output;
  56544. };
  56545. }());
  56546. (function checkFunctionPrototypeBindCompatibility() {
  56547. if (typeof Function.prototype.bind !== 'undefined') {
  56548. return;
  56549. }
  56550. Function.prototype.bind = function functionPrototypeBind(obj) {
  56551. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  56552. var bound = function functionPrototypeBindBound() {
  56553. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  56554. return fn.apply(obj, args);
  56555. };
  56556. return bound;
  56557. };
  56558. }());
  56559. (function checkDatasetProperty() {
  56560. if (!hasDOM) {
  56561. return;
  56562. }
  56563. var div = document.createElement('div');
  56564. if ('dataset' in div) {
  56565. return;
  56566. }
  56567. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  56568. get: function () {
  56569. if (this._dataset) {
  56570. return this._dataset;
  56571. }
  56572. var dataset = {};
  56573. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  56574. var attribute = this.attributes[j];
  56575. if (attribute.name.substring(0, 5) !== 'data-') {
  56576. continue;
  56577. }
  56578. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  56579. return ch.toUpperCase();
  56580. });
  56581. dataset[key] = attribute.value;
  56582. }
  56583. Object.defineProperty(this, '_dataset', {
  56584. value: dataset,
  56585. writable: false,
  56586. enumerable: false
  56587. });
  56588. return dataset;
  56589. },
  56590. enumerable: true
  56591. });
  56592. }());
  56593. (function checkClassListProperty() {
  56594. function changeList(element, itemName, add, remove) {
  56595. var s = element.className || '';
  56596. var list = s.split(/\s+/g);
  56597. if (list[0] === '') {
  56598. list.shift();
  56599. }
  56600. var index = list.indexOf(itemName);
  56601. if (index < 0 && add) {
  56602. list.push(itemName);
  56603. }
  56604. if (index >= 0 && remove) {
  56605. list.splice(index, 1);
  56606. }
  56607. element.className = list.join(' ');
  56608. return index >= 0;
  56609. }
  56610. if (!hasDOM) {
  56611. return;
  56612. }
  56613. var div = document.createElement('div');
  56614. if ('classList' in div) {
  56615. return;
  56616. }
  56617. var classListPrototype = {
  56618. add: function (name) {
  56619. changeList(this.element, name, true, false);
  56620. },
  56621. contains: function (name) {
  56622. return changeList(this.element, name, false, false);
  56623. },
  56624. remove: function (name) {
  56625. changeList(this.element, name, false, true);
  56626. },
  56627. toggle: function (name) {
  56628. changeList(this.element, name, true, true);
  56629. }
  56630. };
  56631. Object.defineProperty(HTMLElement.prototype, 'classList', {
  56632. get: function () {
  56633. if (this._classList) {
  56634. return this._classList;
  56635. }
  56636. var classList = Object.create(classListPrototype, {
  56637. element: {
  56638. value: this,
  56639. writable: false,
  56640. enumerable: true
  56641. }
  56642. });
  56643. Object.defineProperty(this, '_classList', {
  56644. value: classList,
  56645. writable: false,
  56646. enumerable: false
  56647. });
  56648. return classList;
  56649. },
  56650. enumerable: true
  56651. });
  56652. }());
  56653. (function checkWorkerConsoleCompatibility() {
  56654. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  56655. return;
  56656. }
  56657. var consoleTimer = {};
  56658. var workerConsole = {
  56659. log: function log() {
  56660. var args = Array.prototype.slice.call(arguments);
  56661. globalScope.postMessage({
  56662. targetName: 'main',
  56663. action: 'console_log',
  56664. data: args
  56665. });
  56666. },
  56667. error: function error() {
  56668. var args = Array.prototype.slice.call(arguments);
  56669. globalScope.postMessage({
  56670. targetName: 'main',
  56671. action: 'console_error',
  56672. data: args
  56673. });
  56674. },
  56675. time: function time(name) {
  56676. consoleTimer[name] = Date.now();
  56677. },
  56678. timeEnd: function timeEnd(name) {
  56679. var time = consoleTimer[name];
  56680. if (!time) {
  56681. throw new Error('Unknown timer name ' + name);
  56682. }
  56683. this.log('Timer:', name, Date.now() - time);
  56684. }
  56685. };
  56686. globalScope.console = workerConsole;
  56687. }());
  56688. (function checkConsoleCompatibility() {
  56689. if (!hasDOM) {
  56690. return;
  56691. }
  56692. if (!('console' in window)) {
  56693. window.console = {
  56694. log: function () {
  56695. },
  56696. error: function () {
  56697. },
  56698. warn: function () {
  56699. }
  56700. };
  56701. return;
  56702. }
  56703. if (!('bind' in console.log)) {
  56704. console.log = function (fn) {
  56705. return function (msg) {
  56706. return fn(msg);
  56707. };
  56708. }(console.log);
  56709. console.error = function (fn) {
  56710. return function (msg) {
  56711. return fn(msg);
  56712. };
  56713. }(console.error);
  56714. console.warn = function (fn) {
  56715. return function (msg) {
  56716. return fn(msg);
  56717. };
  56718. }(console.warn);
  56719. return;
  56720. }
  56721. }());
  56722. (function checkOnClickCompatibility() {
  56723. function ignoreIfTargetDisabled(event) {
  56724. if (isDisabled(event.target)) {
  56725. event.stopPropagation();
  56726. }
  56727. }
  56728. function isDisabled(node) {
  56729. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  56730. }
  56731. if (isOpera) {
  56732. document.addEventListener('click', ignoreIfTargetDisabled, true);
  56733. }
  56734. }());
  56735. (function checkOnBlobSupport() {
  56736. if (isIE || isIOSChrome) {
  56737. PDFJS.disableCreateObjectURL = true;
  56738. }
  56739. }());
  56740. (function checkNavigatorLanguage() {
  56741. if (typeof navigator === 'undefined') {
  56742. return;
  56743. }
  56744. if ('language' in navigator) {
  56745. return;
  56746. }
  56747. PDFJS.locale = navigator.userLanguage || 'en-US';
  56748. }());
  56749. (function checkRangeRequests() {
  56750. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  56751. PDFJS.disableRange = true;
  56752. PDFJS.disableStream = true;
  56753. }
  56754. }());
  56755. (function checkHistoryManipulation() {
  56756. if (!hasDOM) {
  56757. return;
  56758. }
  56759. if (!history.pushState || isAndroidPre3) {
  56760. PDFJS.disableHistory = true;
  56761. }
  56762. }());
  56763. (function checkSetPresenceInImageData() {
  56764. if (!hasDOM) {
  56765. return;
  56766. }
  56767. if (window.CanvasPixelArray) {
  56768. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  56769. window.CanvasPixelArray.prototype.set = function (arr) {
  56770. for (var i = 0, ii = this.length; i < ii; i++) {
  56771. this[i] = arr[i];
  56772. }
  56773. };
  56774. }
  56775. } else {
  56776. var polyfill = false, versionMatch;
  56777. if (isChrome) {
  56778. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  56779. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  56780. } else if (isAndroid) {
  56781. polyfill = isAndroidPre5;
  56782. } else if (isSafari) {
  56783. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  56784. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  56785. }
  56786. if (polyfill) {
  56787. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  56788. var createImageData = contextPrototype.createImageData;
  56789. contextPrototype.createImageData = function (w, h) {
  56790. var imageData = createImageData.call(this, w, h);
  56791. imageData.data.set = function (arr) {
  56792. for (var i = 0, ii = this.length; i < ii; i++) {
  56793. this[i] = arr[i];
  56794. }
  56795. };
  56796. return imageData;
  56797. };
  56798. contextPrototype = null;
  56799. }
  56800. }
  56801. }());
  56802. (function checkRequestAnimationFrame() {
  56803. function fakeRequestAnimationFrame(callback) {
  56804. window.setTimeout(callback, 20);
  56805. }
  56806. if (!hasDOM) {
  56807. return;
  56808. }
  56809. if (isIOS) {
  56810. window.requestAnimationFrame = fakeRequestAnimationFrame;
  56811. return;
  56812. }
  56813. if ('requestAnimationFrame' in window) {
  56814. return;
  56815. }
  56816. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  56817. }());
  56818. (function checkCanvasSizeLimitation() {
  56819. if (isIOS || isAndroid) {
  56820. PDFJS.maxCanvasPixels = 5242880;
  56821. }
  56822. }());
  56823. (function checkFullscreenSupport() {
  56824. if (!hasDOM) {
  56825. return;
  56826. }
  56827. if (isIE && window.parent !== window) {
  56828. PDFJS.disableFullscreen = true;
  56829. }
  56830. }());
  56831. (function checkCurrentScript() {
  56832. if (!hasDOM) {
  56833. return;
  56834. }
  56835. if ('currentScript' in document) {
  56836. return;
  56837. }
  56838. Object.defineProperty(document, 'currentScript', {
  56839. get: function () {
  56840. var scripts = document.getElementsByTagName('script');
  56841. return scripts[scripts.length - 1];
  56842. },
  56843. enumerable: true,
  56844. configurable: true
  56845. });
  56846. }());
  56847. (function checkInputTypeNumberAssign() {
  56848. if (!hasDOM) {
  56849. return;
  56850. }
  56851. var el = document.createElement('input');
  56852. try {
  56853. el.type = 'number';
  56854. } catch (ex) {
  56855. var inputProto = el.constructor.prototype;
  56856. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  56857. Object.defineProperty(inputProto, 'type', {
  56858. get: function () {
  56859. return typeProperty.get.call(this);
  56860. },
  56861. set: function (value) {
  56862. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  56863. },
  56864. enumerable: true,
  56865. configurable: true
  56866. });
  56867. }
  56868. }());
  56869. (function checkDocumentReadyState() {
  56870. if (!hasDOM) {
  56871. return;
  56872. }
  56873. if (!document.attachEvent) {
  56874. return;
  56875. }
  56876. var documentProto = document.constructor.prototype;
  56877. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  56878. Object.defineProperty(documentProto, 'readyState', {
  56879. get: function () {
  56880. var value = readyStateProto.get.call(this);
  56881. return value === 'interactive' ? 'loading' : value;
  56882. },
  56883. set: function (value) {
  56884. readyStateProto.set.call(this, value);
  56885. },
  56886. enumerable: true,
  56887. configurable: true
  56888. });
  56889. }());
  56890. (function checkChildNodeRemove() {
  56891. if (!hasDOM) {
  56892. return;
  56893. }
  56894. if (typeof Element.prototype.remove !== 'undefined') {
  56895. return;
  56896. }
  56897. Element.prototype.remove = function () {
  56898. if (this.parentNode) {
  56899. this.parentNode.removeChild(this);
  56900. }
  56901. };
  56902. }());
  56903. (function checkPromise() {
  56904. if (globalScope.Promise) {
  56905. if (typeof globalScope.Promise.all !== 'function') {
  56906. globalScope.Promise.all = function (iterable) {
  56907. var count = 0, results = [], resolve, reject;
  56908. var promise = new globalScope.Promise(function (resolve_, reject_) {
  56909. resolve = resolve_;
  56910. reject = reject_;
  56911. });
  56912. iterable.forEach(function (p, i) {
  56913. count++;
  56914. p.then(function (result) {
  56915. results[i] = result;
  56916. count--;
  56917. if (count === 0) {
  56918. resolve(results);
  56919. }
  56920. }, reject);
  56921. });
  56922. if (count === 0) {
  56923. resolve(results);
  56924. }
  56925. return promise;
  56926. };
  56927. }
  56928. if (typeof globalScope.Promise.resolve !== 'function') {
  56929. globalScope.Promise.resolve = function (value) {
  56930. return new globalScope.Promise(function (resolve) {
  56931. resolve(value);
  56932. });
  56933. };
  56934. }
  56935. if (typeof globalScope.Promise.reject !== 'function') {
  56936. globalScope.Promise.reject = function (reason) {
  56937. return new globalScope.Promise(function (resolve, reject) {
  56938. reject(reason);
  56939. });
  56940. };
  56941. }
  56942. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  56943. globalScope.Promise.prototype.catch = function (onReject) {
  56944. return globalScope.Promise.prototype.then(undefined, onReject);
  56945. };
  56946. }
  56947. return;
  56948. }
  56949. var STATUS_PENDING = 0;
  56950. var STATUS_RESOLVED = 1;
  56951. var STATUS_REJECTED = 2;
  56952. var REJECTION_TIMEOUT = 500;
  56953. var HandlerManager = {
  56954. handlers: [],
  56955. running: false,
  56956. unhandledRejections: [],
  56957. pendingRejectionCheck: false,
  56958. scheduleHandlers: function scheduleHandlers(promise) {
  56959. if (promise._status === STATUS_PENDING) {
  56960. return;
  56961. }
  56962. this.handlers = this.handlers.concat(promise._handlers);
  56963. promise._handlers = [];
  56964. if (this.running) {
  56965. return;
  56966. }
  56967. this.running = true;
  56968. setTimeout(this.runHandlers.bind(this), 0);
  56969. },
  56970. runHandlers: function runHandlers() {
  56971. var RUN_TIMEOUT = 1;
  56972. var timeoutAt = Date.now() + RUN_TIMEOUT;
  56973. while (this.handlers.length > 0) {
  56974. var handler = this.handlers.shift();
  56975. var nextStatus = handler.thisPromise._status;
  56976. var nextValue = handler.thisPromise._value;
  56977. try {
  56978. if (nextStatus === STATUS_RESOLVED) {
  56979. if (typeof handler.onResolve === 'function') {
  56980. nextValue = handler.onResolve(nextValue);
  56981. }
  56982. } else if (typeof handler.onReject === 'function') {
  56983. nextValue = handler.onReject(nextValue);
  56984. nextStatus = STATUS_RESOLVED;
  56985. if (handler.thisPromise._unhandledRejection) {
  56986. this.removeUnhandeledRejection(handler.thisPromise);
  56987. }
  56988. }
  56989. } catch (ex) {
  56990. nextStatus = STATUS_REJECTED;
  56991. nextValue = ex;
  56992. }
  56993. handler.nextPromise._updateStatus(nextStatus, nextValue);
  56994. if (Date.now() >= timeoutAt) {
  56995. break;
  56996. }
  56997. }
  56998. if (this.handlers.length > 0) {
  56999. setTimeout(this.runHandlers.bind(this), 0);
  57000. return;
  57001. }
  57002. this.running = false;
  57003. },
  57004. addUnhandledRejection: function addUnhandledRejection(promise) {
  57005. this.unhandledRejections.push({
  57006. promise: promise,
  57007. time: Date.now()
  57008. });
  57009. this.scheduleRejectionCheck();
  57010. },
  57011. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  57012. promise._unhandledRejection = false;
  57013. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57014. if (this.unhandledRejections[i].promise === promise) {
  57015. this.unhandledRejections.splice(i);
  57016. i--;
  57017. }
  57018. }
  57019. },
  57020. scheduleRejectionCheck: function scheduleRejectionCheck() {
  57021. if (this.pendingRejectionCheck) {
  57022. return;
  57023. }
  57024. this.pendingRejectionCheck = true;
  57025. setTimeout(function rejectionCheck() {
  57026. this.pendingRejectionCheck = false;
  57027. var now = Date.now();
  57028. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57029. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  57030. var unhandled = this.unhandledRejections[i].promise._value;
  57031. var msg = 'Unhandled rejection: ' + unhandled;
  57032. if (unhandled.stack) {
  57033. msg += '\n' + unhandled.stack;
  57034. }
  57035. try {
  57036. throw new Error(msg);
  57037. } catch (_) {
  57038. console.warn(msg);
  57039. }
  57040. this.unhandledRejections.splice(i);
  57041. i--;
  57042. }
  57043. }
  57044. if (this.unhandledRejections.length) {
  57045. this.scheduleRejectionCheck();
  57046. }
  57047. }.bind(this), REJECTION_TIMEOUT);
  57048. }
  57049. };
  57050. var Promise = function Promise(resolver) {
  57051. this._status = STATUS_PENDING;
  57052. this._handlers = [];
  57053. try {
  57054. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  57055. } catch (e) {
  57056. this._reject(e);
  57057. }
  57058. };
  57059. Promise.all = function Promise_all(promises) {
  57060. var resolveAll, rejectAll;
  57061. var deferred = new Promise(function (resolve, reject) {
  57062. resolveAll = resolve;
  57063. rejectAll = reject;
  57064. });
  57065. var unresolved = promises.length;
  57066. var results = [];
  57067. if (unresolved === 0) {
  57068. resolveAll(results);
  57069. return deferred;
  57070. }
  57071. function reject(reason) {
  57072. if (deferred._status === STATUS_REJECTED) {
  57073. return;
  57074. }
  57075. results = [];
  57076. rejectAll(reason);
  57077. }
  57078. for (var i = 0, ii = promises.length; i < ii; ++i) {
  57079. var promise = promises[i];
  57080. var resolve = function (i) {
  57081. return function (value) {
  57082. if (deferred._status === STATUS_REJECTED) {
  57083. return;
  57084. }
  57085. results[i] = value;
  57086. unresolved--;
  57087. if (unresolved === 0) {
  57088. resolveAll(results);
  57089. }
  57090. };
  57091. }(i);
  57092. if (Promise.isPromise(promise)) {
  57093. promise.then(resolve, reject);
  57094. } else {
  57095. resolve(promise);
  57096. }
  57097. }
  57098. return deferred;
  57099. };
  57100. Promise.isPromise = function Promise_isPromise(value) {
  57101. return value && typeof value.then === 'function';
  57102. };
  57103. Promise.resolve = function Promise_resolve(value) {
  57104. return new Promise(function (resolve) {
  57105. resolve(value);
  57106. });
  57107. };
  57108. Promise.reject = function Promise_reject(reason) {
  57109. return new Promise(function (resolve, reject) {
  57110. reject(reason);
  57111. });
  57112. };
  57113. Promise.prototype = {
  57114. _status: null,
  57115. _value: null,
  57116. _handlers: null,
  57117. _unhandledRejection: null,
  57118. _updateStatus: function Promise__updateStatus(status, value) {
  57119. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  57120. return;
  57121. }
  57122. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  57123. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  57124. return;
  57125. }
  57126. this._status = status;
  57127. this._value = value;
  57128. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  57129. this._unhandledRejection = true;
  57130. HandlerManager.addUnhandledRejection(this);
  57131. }
  57132. HandlerManager.scheduleHandlers(this);
  57133. },
  57134. _resolve: function Promise_resolve(value) {
  57135. this._updateStatus(STATUS_RESOLVED, value);
  57136. },
  57137. _reject: function Promise_reject(reason) {
  57138. this._updateStatus(STATUS_REJECTED, reason);
  57139. },
  57140. then: function Promise_then(onResolve, onReject) {
  57141. var nextPromise = new Promise(function (resolve, reject) {
  57142. this.resolve = resolve;
  57143. this.reject = reject;
  57144. });
  57145. this._handlers.push({
  57146. thisPromise: this,
  57147. onResolve: onResolve,
  57148. onReject: onReject,
  57149. nextPromise: nextPromise
  57150. });
  57151. HandlerManager.scheduleHandlers(this);
  57152. return nextPromise;
  57153. },
  57154. catch: function Promise_catch(onReject) {
  57155. return this.then(undefined, onReject);
  57156. }
  57157. };
  57158. globalScope.Promise = Promise;
  57159. }());
  57160. (function checkWeakMap() {
  57161. if (globalScope.WeakMap) {
  57162. return;
  57163. }
  57164. var id = 0;
  57165. function WeakMap() {
  57166. this.id = '$weakmap' + id++;
  57167. }
  57168. WeakMap.prototype = {
  57169. has: function (obj) {
  57170. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  57171. },
  57172. get: function (obj, defaultValue) {
  57173. return this.has(obj) ? obj[this.id] : defaultValue;
  57174. },
  57175. set: function (obj, value) {
  57176. Object.defineProperty(obj, this.id, {
  57177. value: value,
  57178. enumerable: false,
  57179. configurable: true
  57180. });
  57181. },
  57182. delete: function (obj) {
  57183. delete obj[this.id];
  57184. }
  57185. };
  57186. globalScope.WeakMap = WeakMap;
  57187. }());
  57188. (function checkURLConstructor() {
  57189. var hasWorkingUrl = false;
  57190. try {
  57191. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  57192. var u = new URL('b', 'http://a');
  57193. u.pathname = 'c%20d';
  57194. hasWorkingUrl = u.href === 'http://a/c%20d';
  57195. }
  57196. } catch (e) {
  57197. }
  57198. if (hasWorkingUrl) {
  57199. return;
  57200. }
  57201. var relative = Object.create(null);
  57202. relative['ftp'] = 21;
  57203. relative['file'] = 0;
  57204. relative['gopher'] = 70;
  57205. relative['http'] = 80;
  57206. relative['https'] = 443;
  57207. relative['ws'] = 80;
  57208. relative['wss'] = 443;
  57209. var relativePathDotMapping = Object.create(null);
  57210. relativePathDotMapping['%2e'] = '.';
  57211. relativePathDotMapping['.%2e'] = '..';
  57212. relativePathDotMapping['%2e.'] = '..';
  57213. relativePathDotMapping['%2e%2e'] = '..';
  57214. function isRelativeScheme(scheme) {
  57215. return relative[scheme] !== undefined;
  57216. }
  57217. function invalid() {
  57218. clear.call(this);
  57219. this._isInvalid = true;
  57220. }
  57221. function IDNAToASCII(h) {
  57222. if (h === '') {
  57223. invalid.call(this);
  57224. }
  57225. return h.toLowerCase();
  57226. }
  57227. function percentEscape(c) {
  57228. var unicode = c.charCodeAt(0);
  57229. if (unicode > 0x20 && unicode < 0x7F && [
  57230. 0x22,
  57231. 0x23,
  57232. 0x3C,
  57233. 0x3E,
  57234. 0x3F,
  57235. 0x60
  57236. ].indexOf(unicode) === -1) {
  57237. return c;
  57238. }
  57239. return encodeURIComponent(c);
  57240. }
  57241. function percentEscapeQuery(c) {
  57242. var unicode = c.charCodeAt(0);
  57243. if (unicode > 0x20 && unicode < 0x7F && [
  57244. 0x22,
  57245. 0x23,
  57246. 0x3C,
  57247. 0x3E,
  57248. 0x60
  57249. ].indexOf(unicode) === -1) {
  57250. return c;
  57251. }
  57252. return encodeURIComponent(c);
  57253. }
  57254. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  57255. function parse(input, stateOverride, base) {
  57256. function err(message) {
  57257. errors.push(message);
  57258. }
  57259. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  57260. loop:
  57261. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  57262. var c = input[cursor];
  57263. switch (state) {
  57264. case 'scheme start':
  57265. if (c && ALPHA.test(c)) {
  57266. buffer += c.toLowerCase();
  57267. state = 'scheme';
  57268. } else if (!stateOverride) {
  57269. buffer = '';
  57270. state = 'no scheme';
  57271. continue;
  57272. } else {
  57273. err('Invalid scheme.');
  57274. break loop;
  57275. }
  57276. break;
  57277. case 'scheme':
  57278. if (c && ALPHANUMERIC.test(c)) {
  57279. buffer += c.toLowerCase();
  57280. } else if (c === ':') {
  57281. this._scheme = buffer;
  57282. buffer = '';
  57283. if (stateOverride) {
  57284. break loop;
  57285. }
  57286. if (isRelativeScheme(this._scheme)) {
  57287. this._isRelative = true;
  57288. }
  57289. if (this._scheme === 'file') {
  57290. state = 'relative';
  57291. } else if (this._isRelative && base && base._scheme === this._scheme) {
  57292. state = 'relative or authority';
  57293. } else if (this._isRelative) {
  57294. state = 'authority first slash';
  57295. } else {
  57296. state = 'scheme data';
  57297. }
  57298. } else if (!stateOverride) {
  57299. buffer = '';
  57300. cursor = 0;
  57301. state = 'no scheme';
  57302. continue;
  57303. } else if (EOF === c) {
  57304. break loop;
  57305. } else {
  57306. err('Code point not allowed in scheme: ' + c);
  57307. break loop;
  57308. }
  57309. break;
  57310. case 'scheme data':
  57311. if (c === '?') {
  57312. this._query = '?';
  57313. state = 'query';
  57314. } else if (c === '#') {
  57315. this._fragment = '#';
  57316. state = 'fragment';
  57317. } else {
  57318. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57319. this._schemeData += percentEscape(c);
  57320. }
  57321. }
  57322. break;
  57323. case 'no scheme':
  57324. if (!base || !isRelativeScheme(base._scheme)) {
  57325. err('Missing scheme.');
  57326. invalid.call(this);
  57327. } else {
  57328. state = 'relative';
  57329. continue;
  57330. }
  57331. break;
  57332. case 'relative or authority':
  57333. if (c === '/' && input[cursor + 1] === '/') {
  57334. state = 'authority ignore slashes';
  57335. } else {
  57336. err('Expected /, got: ' + c);
  57337. state = 'relative';
  57338. continue;
  57339. }
  57340. break;
  57341. case 'relative':
  57342. this._isRelative = true;
  57343. if ('file' !== this._scheme) {
  57344. this._scheme = base._scheme;
  57345. }
  57346. if (EOF === c) {
  57347. this._host = base._host;
  57348. this._port = base._port;
  57349. this._path = base._path.slice();
  57350. this._query = base._query;
  57351. this._username = base._username;
  57352. this._password = base._password;
  57353. break loop;
  57354. } else if (c === '/' || c === '\\') {
  57355. if (c === '\\') {
  57356. err('\\ is an invalid code point.');
  57357. }
  57358. state = 'relative slash';
  57359. } else if (c === '?') {
  57360. this._host = base._host;
  57361. this._port = base._port;
  57362. this._path = base._path.slice();
  57363. this._query = '?';
  57364. this._username = base._username;
  57365. this._password = base._password;
  57366. state = 'query';
  57367. } else if (c === '#') {
  57368. this._host = base._host;
  57369. this._port = base._port;
  57370. this._path = base._path.slice();
  57371. this._query = base._query;
  57372. this._fragment = '#';
  57373. this._username = base._username;
  57374. this._password = base._password;
  57375. state = 'fragment';
  57376. } else {
  57377. var nextC = input[cursor + 1];
  57378. var nextNextC = input[cursor + 2];
  57379. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  57380. this._host = base._host;
  57381. this._port = base._port;
  57382. this._username = base._username;
  57383. this._password = base._password;
  57384. this._path = base._path.slice();
  57385. this._path.pop();
  57386. }
  57387. state = 'relative path';
  57388. continue;
  57389. }
  57390. break;
  57391. case 'relative slash':
  57392. if (c === '/' || c === '\\') {
  57393. if (c === '\\') {
  57394. err('\\ is an invalid code point.');
  57395. }
  57396. if (this._scheme === 'file') {
  57397. state = 'file host';
  57398. } else {
  57399. state = 'authority ignore slashes';
  57400. }
  57401. } else {
  57402. if ('file' !== this._scheme) {
  57403. this._host = base._host;
  57404. this._port = base._port;
  57405. this._username = base._username;
  57406. this._password = base._password;
  57407. }
  57408. state = 'relative path';
  57409. continue;
  57410. }
  57411. break;
  57412. case 'authority first slash':
  57413. if (c === '/') {
  57414. state = 'authority second slash';
  57415. } else {
  57416. err('Expected \'/\', got: ' + c);
  57417. state = 'authority ignore slashes';
  57418. continue;
  57419. }
  57420. break;
  57421. case 'authority second slash':
  57422. state = 'authority ignore slashes';
  57423. if ('/' !== c) {
  57424. err('Expected \'/\', got: ' + c);
  57425. continue;
  57426. }
  57427. break;
  57428. case 'authority ignore slashes':
  57429. if ('/' !== c && '\\' !== c) {
  57430. state = 'authority';
  57431. continue;
  57432. } else {
  57433. err('Expected authority, got: ' + c);
  57434. }
  57435. break;
  57436. case 'authority':
  57437. if (c === '@') {
  57438. if (seenAt) {
  57439. err('@ already seen.');
  57440. buffer += '%40';
  57441. }
  57442. seenAt = true;
  57443. for (var i = 0; i < buffer.length; i++) {
  57444. var cp = buffer[i];
  57445. if (cp === '\t' || cp === '\n' || cp === '\r') {
  57446. err('Invalid whitespace in authority.');
  57447. continue;
  57448. }
  57449. if (cp === ':' && this._password === null) {
  57450. this._password = '';
  57451. continue;
  57452. }
  57453. var tempC = percentEscape(cp);
  57454. if (null !== this._password) {
  57455. this._password += tempC;
  57456. } else {
  57457. this._username += tempC;
  57458. }
  57459. }
  57460. buffer = '';
  57461. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57462. cursor -= buffer.length;
  57463. buffer = '';
  57464. state = 'host';
  57465. continue;
  57466. } else {
  57467. buffer += c;
  57468. }
  57469. break;
  57470. case 'file host':
  57471. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57472. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  57473. state = 'relative path';
  57474. } else if (buffer.length === 0) {
  57475. state = 'relative path start';
  57476. } else {
  57477. this._host = IDNAToASCII.call(this, buffer);
  57478. buffer = '';
  57479. state = 'relative path start';
  57480. }
  57481. continue;
  57482. } else if (c === '\t' || c === '\n' || c === '\r') {
  57483. err('Invalid whitespace in file host.');
  57484. } else {
  57485. buffer += c;
  57486. }
  57487. break;
  57488. case 'host':
  57489. case 'hostname':
  57490. if (c === ':' && !seenBracket) {
  57491. this._host = IDNAToASCII.call(this, buffer);
  57492. buffer = '';
  57493. state = 'port';
  57494. if (stateOverride === 'hostname') {
  57495. break loop;
  57496. }
  57497. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57498. this._host = IDNAToASCII.call(this, buffer);
  57499. buffer = '';
  57500. state = 'relative path start';
  57501. if (stateOverride) {
  57502. break loop;
  57503. }
  57504. continue;
  57505. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57506. if (c === '[') {
  57507. seenBracket = true;
  57508. } else if (c === ']') {
  57509. seenBracket = false;
  57510. }
  57511. buffer += c;
  57512. } else {
  57513. err('Invalid code point in host/hostname: ' + c);
  57514. }
  57515. break;
  57516. case 'port':
  57517. if (/[0-9]/.test(c)) {
  57518. buffer += c;
  57519. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  57520. if ('' !== buffer) {
  57521. var temp = parseInt(buffer, 10);
  57522. if (temp !== relative[this._scheme]) {
  57523. this._port = temp + '';
  57524. }
  57525. buffer = '';
  57526. }
  57527. if (stateOverride) {
  57528. break loop;
  57529. }
  57530. state = 'relative path start';
  57531. continue;
  57532. } else if (c === '\t' || c === '\n' || c === '\r') {
  57533. err('Invalid code point in port: ' + c);
  57534. } else {
  57535. invalid.call(this);
  57536. }
  57537. break;
  57538. case 'relative path start':
  57539. if (c === '\\') {
  57540. err('\'\\\' not allowed in path.');
  57541. }
  57542. state = 'relative path';
  57543. if ('/' !== c && '\\' !== c) {
  57544. continue;
  57545. }
  57546. break;
  57547. case 'relative path':
  57548. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  57549. if (c === '\\') {
  57550. err('\\ not allowed in relative path.');
  57551. }
  57552. var tmp;
  57553. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  57554. buffer = tmp;
  57555. }
  57556. if (buffer === '..') {
  57557. this._path.pop();
  57558. if ('/' !== c && '\\' !== c) {
  57559. this._path.push('');
  57560. }
  57561. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  57562. this._path.push('');
  57563. } else if ('.' !== buffer) {
  57564. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  57565. buffer = buffer[0] + ':';
  57566. }
  57567. this._path.push(buffer);
  57568. }
  57569. buffer = '';
  57570. if (c === '?') {
  57571. this._query = '?';
  57572. state = 'query';
  57573. } else if (c === '#') {
  57574. this._fragment = '#';
  57575. state = 'fragment';
  57576. }
  57577. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  57578. buffer += percentEscape(c);
  57579. }
  57580. break;
  57581. case 'query':
  57582. if (!stateOverride && c === '#') {
  57583. this._fragment = '#';
  57584. state = 'fragment';
  57585. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57586. this._query += percentEscapeQuery(c);
  57587. }
  57588. break;
  57589. case 'fragment':
  57590. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  57591. this._fragment += c;
  57592. }
  57593. break;
  57594. }
  57595. cursor++;
  57596. }
  57597. }
  57598. function clear() {
  57599. this._scheme = '';
  57600. this._schemeData = '';
  57601. this._username = '';
  57602. this._password = null;
  57603. this._host = '';
  57604. this._port = '';
  57605. this._path = [];
  57606. this._query = '';
  57607. this._fragment = '';
  57608. this._isInvalid = false;
  57609. this._isRelative = false;
  57610. }
  57611. function JURL(url, base) {
  57612. if (base !== undefined && !(base instanceof JURL)) {
  57613. base = new JURL(String(base));
  57614. }
  57615. this._url = url;
  57616. clear.call(this);
  57617. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  57618. parse.call(this, input, null, base);
  57619. }
  57620. JURL.prototype = {
  57621. toString: function () {
  57622. return this.href;
  57623. },
  57624. get href() {
  57625. if (this._isInvalid) {
  57626. return this._url;
  57627. }
  57628. var authority = '';
  57629. if ('' !== this._username || null !== this._password) {
  57630. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  57631. }
  57632. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  57633. },
  57634. set href(href) {
  57635. clear.call(this);
  57636. parse.call(this, href);
  57637. },
  57638. get protocol() {
  57639. return this._scheme + ':';
  57640. },
  57641. set protocol(protocol) {
  57642. if (this._isInvalid) {
  57643. return;
  57644. }
  57645. parse.call(this, protocol + ':', 'scheme start');
  57646. },
  57647. get host() {
  57648. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  57649. },
  57650. set host(host) {
  57651. if (this._isInvalid || !this._isRelative) {
  57652. return;
  57653. }
  57654. parse.call(this, host, 'host');
  57655. },
  57656. get hostname() {
  57657. return this._host;
  57658. },
  57659. set hostname(hostname) {
  57660. if (this._isInvalid || !this._isRelative) {
  57661. return;
  57662. }
  57663. parse.call(this, hostname, 'hostname');
  57664. },
  57665. get port() {
  57666. return this._port;
  57667. },
  57668. set port(port) {
  57669. if (this._isInvalid || !this._isRelative) {
  57670. return;
  57671. }
  57672. parse.call(this, port, 'port');
  57673. },
  57674. get pathname() {
  57675. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  57676. },
  57677. set pathname(pathname) {
  57678. if (this._isInvalid || !this._isRelative) {
  57679. return;
  57680. }
  57681. this._path = [];
  57682. parse.call(this, pathname, 'relative path start');
  57683. },
  57684. get search() {
  57685. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  57686. },
  57687. set search(search) {
  57688. if (this._isInvalid || !this._isRelative) {
  57689. return;
  57690. }
  57691. this._query = '?';
  57692. if (search[0] === '?') {
  57693. search = search.slice(1);
  57694. }
  57695. parse.call(this, search, 'query');
  57696. },
  57697. get hash() {
  57698. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  57699. },
  57700. set hash(hash) {
  57701. if (this._isInvalid) {
  57702. return;
  57703. }
  57704. this._fragment = '#';
  57705. if (hash[0] === '#') {
  57706. hash = hash.slice(1);
  57707. }
  57708. parse.call(this, hash, 'fragment');
  57709. },
  57710. get origin() {
  57711. var host;
  57712. if (this._isInvalid || !this._scheme) {
  57713. return '';
  57714. }
  57715. switch (this._scheme) {
  57716. case 'data':
  57717. case 'file':
  57718. case 'javascript':
  57719. case 'mailto':
  57720. return 'null';
  57721. }
  57722. host = this.host;
  57723. if (!host) {
  57724. return '';
  57725. }
  57726. return this._scheme + '://' + host;
  57727. }
  57728. };
  57729. var OriginalURL = globalScope.URL;
  57730. if (OriginalURL) {
  57731. JURL.createObjectURL = function (blob) {
  57732. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  57733. };
  57734. JURL.revokeObjectURL = function (url) {
  57735. OriginalURL.revokeObjectURL(url);
  57736. };
  57737. }
  57738. globalScope.URL = JURL;
  57739. }());
  57740. }
  57741. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  57742. /***/ }),
  57743. /* 48 */
  57744. /***/ (function(module, exports, __w_pdfjs_require__) {
  57745. "use strict";
  57746. var pdfjsVersion = '1.7.361';
  57747. var pdfjsBuild = '224613a5';
  57748. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57749. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  57750. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57751. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57752. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57753. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57754. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57755. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57756. exports.build = pdfjsDisplayAPI.build;
  57757. exports.version = pdfjsDisplayAPI.version;
  57758. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57759. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57760. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57761. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57762. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57763. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57764. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57765. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57766. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57767. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57768. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57769. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57770. exports.OPS = pdfjsSharedUtil.OPS;
  57771. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57772. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57773. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57774. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57775. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57776. exports.shadow = pdfjsSharedUtil.shadow;
  57777. exports.createBlob = pdfjsSharedUtil.createBlob;
  57778. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57779. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57780. /***/ })
  57781. /******/ ]);
  57782. });