pdf.image_decoders.js 313 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/image_decoders/pdf.image_decoders", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/image_decoders/pdf.image_decoders"] = factory();
  29. else
  30. root["pdfjs-dist/image_decoders/pdf.image_decoders"] = root.pdfjsImageDecoders = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. Object.defineProperty(exports, "__esModule", {
  123. value: true
  124. });
  125. Object.defineProperty(exports, "getVerbosityLevel", {
  126. enumerable: true,
  127. get: function get() {
  128. return _util.getVerbosityLevel;
  129. }
  130. });
  131. Object.defineProperty(exports, "setVerbosityLevel", {
  132. enumerable: true,
  133. get: function get() {
  134. return _util.setVerbosityLevel;
  135. }
  136. });
  137. Object.defineProperty(exports, "Jbig2mage", {
  138. enumerable: true,
  139. get: function get() {
  140. return _jbig.Jbig2mage;
  141. }
  142. });
  143. Object.defineProperty(exports, "JpegImage", {
  144. enumerable: true,
  145. get: function get() {
  146. return _jpg.JpegImage;
  147. }
  148. });
  149. Object.defineProperty(exports, "JpxImage", {
  150. enumerable: true,
  151. get: function get() {
  152. return _jpx.JpxImage;
  153. }
  154. });
  155. var _util = __w_pdfjs_require__(1);
  156. var _jbig = __w_pdfjs_require__(132);
  157. var _jpg = __w_pdfjs_require__(135);
  158. var _jpx = __w_pdfjs_require__(136);
  159. var pdfjsVersion = '2.1.266';
  160. var pdfjsBuild = '81f5835c';
  161. /***/ }),
  162. /* 1 */
  163. /***/ (function(module, exports, __w_pdfjs_require__) {
  164. "use strict";
  165. Object.defineProperty(exports, "__esModule", {
  166. value: true
  167. });
  168. exports.toRomanNumerals = toRomanNumerals;
  169. exports.arrayByteLength = arrayByteLength;
  170. exports.arraysToBytes = arraysToBytes;
  171. exports.assert = assert;
  172. exports.bytesToString = bytesToString;
  173. exports.createPromiseCapability = createPromiseCapability;
  174. exports.deprecated = deprecated;
  175. exports.getInheritableProperty = getInheritableProperty;
  176. exports.getLookupTableFactory = getLookupTableFactory;
  177. exports.getVerbosityLevel = getVerbosityLevel;
  178. exports.info = info;
  179. exports.isArrayBuffer = isArrayBuffer;
  180. exports.isBool = isBool;
  181. exports.isEmptyObj = isEmptyObj;
  182. exports.isNum = isNum;
  183. exports.isString = isString;
  184. exports.isSpace = isSpace;
  185. exports.isSameOrigin = isSameOrigin;
  186. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  187. exports.isLittleEndian = isLittleEndian;
  188. exports.isEvalSupported = isEvalSupported;
  189. exports.log2 = log2;
  190. exports.readInt8 = readInt8;
  191. exports.readUint16 = readUint16;
  192. exports.readUint32 = readUint32;
  193. exports.removeNullCharacters = removeNullCharacters;
  194. exports.setVerbosityLevel = setVerbosityLevel;
  195. exports.shadow = shadow;
  196. exports.string32 = string32;
  197. exports.stringToBytes = stringToBytes;
  198. exports.stringToPDFString = stringToPDFString;
  199. exports.stringToUTF8String = stringToUTF8String;
  200. exports.utf8StringToString = utf8StringToString;
  201. exports.warn = warn;
  202. exports.unreachable = unreachable;
  203. Object.defineProperty(exports, "ReadableStream", {
  204. enumerable: true,
  205. get: function get() {
  206. return _streams_polyfill.ReadableStream;
  207. }
  208. });
  209. Object.defineProperty(exports, "URL", {
  210. enumerable: true,
  211. get: function get() {
  212. return _url_polyfill.URL;
  213. }
  214. });
  215. exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.XRefEntryException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0;
  216. __w_pdfjs_require__(2);
  217. var _streams_polyfill = __w_pdfjs_require__(130);
  218. var _url_polyfill = __w_pdfjs_require__(131);
  219. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  220. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  221. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  222. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  223. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  224. var NativeImageDecoding = {
  225. NONE: 'none',
  226. DECODE: 'decode',
  227. DISPLAY: 'display'
  228. };
  229. exports.NativeImageDecoding = NativeImageDecoding;
  230. var PermissionFlag = {
  231. PRINT: 0x04,
  232. MODIFY_CONTENTS: 0x08,
  233. COPY: 0x10,
  234. MODIFY_ANNOTATIONS: 0x20,
  235. FILL_INTERACTIVE_FORMS: 0x100,
  236. COPY_FOR_ACCESSIBILITY: 0x200,
  237. ASSEMBLE: 0x400,
  238. PRINT_HIGH_QUALITY: 0x800
  239. };
  240. exports.PermissionFlag = PermissionFlag;
  241. var TextRenderingMode = {
  242. FILL: 0,
  243. STROKE: 1,
  244. FILL_STROKE: 2,
  245. INVISIBLE: 3,
  246. FILL_ADD_TO_PATH: 4,
  247. STROKE_ADD_TO_PATH: 5,
  248. FILL_STROKE_ADD_TO_PATH: 6,
  249. ADD_TO_PATH: 7,
  250. FILL_STROKE_MASK: 3,
  251. ADD_TO_PATH_FLAG: 4
  252. };
  253. exports.TextRenderingMode = TextRenderingMode;
  254. var ImageKind = {
  255. GRAYSCALE_1BPP: 1,
  256. RGB_24BPP: 2,
  257. RGBA_32BPP: 3
  258. };
  259. exports.ImageKind = ImageKind;
  260. var AnnotationType = {
  261. TEXT: 1,
  262. LINK: 2,
  263. FREETEXT: 3,
  264. LINE: 4,
  265. SQUARE: 5,
  266. CIRCLE: 6,
  267. POLYGON: 7,
  268. POLYLINE: 8,
  269. HIGHLIGHT: 9,
  270. UNDERLINE: 10,
  271. SQUIGGLY: 11,
  272. STRIKEOUT: 12,
  273. STAMP: 13,
  274. CARET: 14,
  275. INK: 15,
  276. POPUP: 16,
  277. FILEATTACHMENT: 17,
  278. SOUND: 18,
  279. MOVIE: 19,
  280. WIDGET: 20,
  281. SCREEN: 21,
  282. PRINTERMARK: 22,
  283. TRAPNET: 23,
  284. WATERMARK: 24,
  285. THREED: 25,
  286. REDACT: 26
  287. };
  288. exports.AnnotationType = AnnotationType;
  289. var AnnotationFlag = {
  290. INVISIBLE: 0x01,
  291. HIDDEN: 0x02,
  292. PRINT: 0x04,
  293. NOZOOM: 0x08,
  294. NOROTATE: 0x10,
  295. NOVIEW: 0x20,
  296. READONLY: 0x40,
  297. LOCKED: 0x80,
  298. TOGGLENOVIEW: 0x100,
  299. LOCKEDCONTENTS: 0x200
  300. };
  301. exports.AnnotationFlag = AnnotationFlag;
  302. var AnnotationFieldFlag = {
  303. READONLY: 0x0000001,
  304. REQUIRED: 0x0000002,
  305. NOEXPORT: 0x0000004,
  306. MULTILINE: 0x0001000,
  307. PASSWORD: 0x0002000,
  308. NOTOGGLETOOFF: 0x0004000,
  309. RADIO: 0x0008000,
  310. PUSHBUTTON: 0x0010000,
  311. COMBO: 0x0020000,
  312. EDIT: 0x0040000,
  313. SORT: 0x0080000,
  314. FILESELECT: 0x0100000,
  315. MULTISELECT: 0x0200000,
  316. DONOTSPELLCHECK: 0x0400000,
  317. DONOTSCROLL: 0x0800000,
  318. COMB: 0x1000000,
  319. RICHTEXT: 0x2000000,
  320. RADIOSINUNISON: 0x2000000,
  321. COMMITONSELCHANGE: 0x4000000
  322. };
  323. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  324. var AnnotationBorderStyleType = {
  325. SOLID: 1,
  326. DASHED: 2,
  327. BEVELED: 3,
  328. INSET: 4,
  329. UNDERLINE: 5
  330. };
  331. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  332. var StreamType = {
  333. UNKNOWN: 0,
  334. FLATE: 1,
  335. LZW: 2,
  336. DCT: 3,
  337. JPX: 4,
  338. JBIG: 5,
  339. A85: 6,
  340. AHX: 7,
  341. CCF: 8,
  342. RL: 9
  343. };
  344. exports.StreamType = StreamType;
  345. var FontType = {
  346. UNKNOWN: 0,
  347. TYPE1: 1,
  348. TYPE1C: 2,
  349. CIDFONTTYPE0: 3,
  350. CIDFONTTYPE0C: 4,
  351. TRUETYPE: 5,
  352. CIDFONTTYPE2: 6,
  353. TYPE3: 7,
  354. OPENTYPE: 8,
  355. TYPE0: 9,
  356. MMTYPE1: 10
  357. };
  358. exports.FontType = FontType;
  359. var VerbosityLevel = {
  360. ERRORS: 0,
  361. WARNINGS: 1,
  362. INFOS: 5
  363. };
  364. exports.VerbosityLevel = VerbosityLevel;
  365. var CMapCompressionType = {
  366. NONE: 0,
  367. BINARY: 1,
  368. STREAM: 2
  369. };
  370. exports.CMapCompressionType = CMapCompressionType;
  371. var OPS = {
  372. dependency: 1,
  373. setLineWidth: 2,
  374. setLineCap: 3,
  375. setLineJoin: 4,
  376. setMiterLimit: 5,
  377. setDash: 6,
  378. setRenderingIntent: 7,
  379. setFlatness: 8,
  380. setGState: 9,
  381. save: 10,
  382. restore: 11,
  383. transform: 12,
  384. moveTo: 13,
  385. lineTo: 14,
  386. curveTo: 15,
  387. curveTo2: 16,
  388. curveTo3: 17,
  389. closePath: 18,
  390. rectangle: 19,
  391. stroke: 20,
  392. closeStroke: 21,
  393. fill: 22,
  394. eoFill: 23,
  395. fillStroke: 24,
  396. eoFillStroke: 25,
  397. closeFillStroke: 26,
  398. closeEOFillStroke: 27,
  399. endPath: 28,
  400. clip: 29,
  401. eoClip: 30,
  402. beginText: 31,
  403. endText: 32,
  404. setCharSpacing: 33,
  405. setWordSpacing: 34,
  406. setHScale: 35,
  407. setLeading: 36,
  408. setFont: 37,
  409. setTextRenderingMode: 38,
  410. setTextRise: 39,
  411. moveText: 40,
  412. setLeadingMoveText: 41,
  413. setTextMatrix: 42,
  414. nextLine: 43,
  415. showText: 44,
  416. showSpacedText: 45,
  417. nextLineShowText: 46,
  418. nextLineSetSpacingShowText: 47,
  419. setCharWidth: 48,
  420. setCharWidthAndBounds: 49,
  421. setStrokeColorSpace: 50,
  422. setFillColorSpace: 51,
  423. setStrokeColor: 52,
  424. setStrokeColorN: 53,
  425. setFillColor: 54,
  426. setFillColorN: 55,
  427. setStrokeGray: 56,
  428. setFillGray: 57,
  429. setStrokeRGBColor: 58,
  430. setFillRGBColor: 59,
  431. setStrokeCMYKColor: 60,
  432. setFillCMYKColor: 61,
  433. shadingFill: 62,
  434. beginInlineImage: 63,
  435. beginImageData: 64,
  436. endInlineImage: 65,
  437. paintXObject: 66,
  438. markPoint: 67,
  439. markPointProps: 68,
  440. beginMarkedContent: 69,
  441. beginMarkedContentProps: 70,
  442. endMarkedContent: 71,
  443. beginCompat: 72,
  444. endCompat: 73,
  445. paintFormXObjectBegin: 74,
  446. paintFormXObjectEnd: 75,
  447. beginGroup: 76,
  448. endGroup: 77,
  449. beginAnnotations: 78,
  450. endAnnotations: 79,
  451. beginAnnotation: 80,
  452. endAnnotation: 81,
  453. paintJpegXObject: 82,
  454. paintImageMaskXObject: 83,
  455. paintImageMaskXObjectGroup: 84,
  456. paintImageXObject: 85,
  457. paintInlineImageXObject: 86,
  458. paintInlineImageXObjectGroup: 87,
  459. paintImageXObjectRepeat: 88,
  460. paintImageMaskXObjectRepeat: 89,
  461. paintSolidColorImageMask: 90,
  462. constructPath: 91
  463. };
  464. exports.OPS = OPS;
  465. var UNSUPPORTED_FEATURES = {
  466. unknown: 'unknown',
  467. forms: 'forms',
  468. javaScript: 'javaScript',
  469. smask: 'smask',
  470. shadingPattern: 'shadingPattern',
  471. font: 'font'
  472. };
  473. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  474. var PasswordResponses = {
  475. NEED_PASSWORD: 1,
  476. INCORRECT_PASSWORD: 2
  477. };
  478. exports.PasswordResponses = PasswordResponses;
  479. var verbosity = VerbosityLevel.WARNINGS;
  480. function setVerbosityLevel(level) {
  481. if (Number.isInteger(level)) {
  482. verbosity = level;
  483. }
  484. }
  485. function getVerbosityLevel() {
  486. return verbosity;
  487. }
  488. function info(msg) {
  489. if (verbosity >= VerbosityLevel.INFOS) {
  490. console.log('Info: ' + msg);
  491. }
  492. }
  493. function warn(msg) {
  494. if (verbosity >= VerbosityLevel.WARNINGS) {
  495. console.log('Warning: ' + msg);
  496. }
  497. }
  498. function deprecated(details) {
  499. console.log('Deprecated API usage: ' + details);
  500. }
  501. function unreachable(msg) {
  502. throw new Error(msg);
  503. }
  504. function assert(cond, msg) {
  505. if (!cond) {
  506. unreachable(msg);
  507. }
  508. }
  509. function isSameOrigin(baseUrl, otherUrl) {
  510. try {
  511. var base = new _url_polyfill.URL(baseUrl);
  512. if (!base.origin || base.origin === 'null') {
  513. return false;
  514. }
  515. } catch (e) {
  516. return false;
  517. }
  518. var other = new _url_polyfill.URL(otherUrl, base);
  519. return base.origin === other.origin;
  520. }
  521. function _isValidProtocol(url) {
  522. if (!url) {
  523. return false;
  524. }
  525. switch (url.protocol) {
  526. case 'http:':
  527. case 'https:':
  528. case 'ftp:':
  529. case 'mailto:':
  530. case 'tel:':
  531. return true;
  532. default:
  533. return false;
  534. }
  535. }
  536. function createValidAbsoluteUrl(url, baseUrl) {
  537. if (!url) {
  538. return null;
  539. }
  540. try {
  541. var absoluteUrl = baseUrl ? new _url_polyfill.URL(url, baseUrl) : new _url_polyfill.URL(url);
  542. if (_isValidProtocol(absoluteUrl)) {
  543. return absoluteUrl;
  544. }
  545. } catch (ex) {}
  546. return null;
  547. }
  548. function shadow(obj, prop, value) {
  549. Object.defineProperty(obj, prop, {
  550. value: value,
  551. enumerable: true,
  552. configurable: true,
  553. writable: false
  554. });
  555. return value;
  556. }
  557. function getLookupTableFactory(initializer) {
  558. var lookup;
  559. return function () {
  560. if (initializer) {
  561. lookup = Object.create(null);
  562. initializer(lookup);
  563. initializer = null;
  564. }
  565. return lookup;
  566. };
  567. }
  568. var PasswordException = function PasswordExceptionClosure() {
  569. function PasswordException(msg, code) {
  570. this.name = 'PasswordException';
  571. this.message = msg;
  572. this.code = code;
  573. }
  574. PasswordException.prototype = new Error();
  575. PasswordException.constructor = PasswordException;
  576. return PasswordException;
  577. }();
  578. exports.PasswordException = PasswordException;
  579. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  580. function UnknownErrorException(msg, details) {
  581. this.name = 'UnknownErrorException';
  582. this.message = msg;
  583. this.details = details;
  584. }
  585. UnknownErrorException.prototype = new Error();
  586. UnknownErrorException.constructor = UnknownErrorException;
  587. return UnknownErrorException;
  588. }();
  589. exports.UnknownErrorException = UnknownErrorException;
  590. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  591. function InvalidPDFException(msg) {
  592. this.name = 'InvalidPDFException';
  593. this.message = msg;
  594. }
  595. InvalidPDFException.prototype = new Error();
  596. InvalidPDFException.constructor = InvalidPDFException;
  597. return InvalidPDFException;
  598. }();
  599. exports.InvalidPDFException = InvalidPDFException;
  600. var MissingPDFException = function MissingPDFExceptionClosure() {
  601. function MissingPDFException(msg) {
  602. this.name = 'MissingPDFException';
  603. this.message = msg;
  604. }
  605. MissingPDFException.prototype = new Error();
  606. MissingPDFException.constructor = MissingPDFException;
  607. return MissingPDFException;
  608. }();
  609. exports.MissingPDFException = MissingPDFException;
  610. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  611. function UnexpectedResponseException(msg, status) {
  612. this.name = 'UnexpectedResponseException';
  613. this.message = msg;
  614. this.status = status;
  615. }
  616. UnexpectedResponseException.prototype = new Error();
  617. UnexpectedResponseException.constructor = UnexpectedResponseException;
  618. return UnexpectedResponseException;
  619. }();
  620. exports.UnexpectedResponseException = UnexpectedResponseException;
  621. var MissingDataException = function MissingDataExceptionClosure() {
  622. function MissingDataException(begin, end) {
  623. this.begin = begin;
  624. this.end = end;
  625. this.message = 'Missing data [' + begin + ', ' + end + ')';
  626. }
  627. MissingDataException.prototype = new Error();
  628. MissingDataException.prototype.name = 'MissingDataException';
  629. MissingDataException.constructor = MissingDataException;
  630. return MissingDataException;
  631. }();
  632. exports.MissingDataException = MissingDataException;
  633. var XRefEntryException = function XRefEntryExceptionClosure() {
  634. function XRefEntryException(msg) {
  635. this.message = msg;
  636. }
  637. XRefEntryException.prototype = new Error();
  638. XRefEntryException.prototype.name = 'XRefEntryException';
  639. XRefEntryException.constructor = XRefEntryException;
  640. return XRefEntryException;
  641. }();
  642. exports.XRefEntryException = XRefEntryException;
  643. var XRefParseException = function XRefParseExceptionClosure() {
  644. function XRefParseException(msg) {
  645. this.message = msg;
  646. }
  647. XRefParseException.prototype = new Error();
  648. XRefParseException.prototype.name = 'XRefParseException';
  649. XRefParseException.constructor = XRefParseException;
  650. return XRefParseException;
  651. }();
  652. exports.XRefParseException = XRefParseException;
  653. var FormatError = function FormatErrorClosure() {
  654. function FormatError(msg) {
  655. this.message = msg;
  656. }
  657. FormatError.prototype = new Error();
  658. FormatError.prototype.name = 'FormatError';
  659. FormatError.constructor = FormatError;
  660. return FormatError;
  661. }();
  662. exports.FormatError = FormatError;
  663. var AbortException = function AbortExceptionClosure() {
  664. function AbortException(msg) {
  665. this.name = 'AbortException';
  666. this.message = msg;
  667. }
  668. AbortException.prototype = new Error();
  669. AbortException.constructor = AbortException;
  670. return AbortException;
  671. }();
  672. exports.AbortException = AbortException;
  673. var NullCharactersRegExp = /\x00/g;
  674. function removeNullCharacters(str) {
  675. if (typeof str !== 'string') {
  676. warn('The argument for removeNullCharacters must be a string.');
  677. return str;
  678. }
  679. return str.replace(NullCharactersRegExp, '');
  680. }
  681. function bytesToString(bytes) {
  682. assert(bytes !== null && _typeof(bytes) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  683. var length = bytes.length;
  684. var MAX_ARGUMENT_COUNT = 8192;
  685. if (length < MAX_ARGUMENT_COUNT) {
  686. return String.fromCharCode.apply(null, bytes);
  687. }
  688. var strBuf = [];
  689. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  690. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  691. var chunk = bytes.subarray(i, chunkEnd);
  692. strBuf.push(String.fromCharCode.apply(null, chunk));
  693. }
  694. return strBuf.join('');
  695. }
  696. function stringToBytes(str) {
  697. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  698. var length = str.length;
  699. var bytes = new Uint8Array(length);
  700. for (var i = 0; i < length; ++i) {
  701. bytes[i] = str.charCodeAt(i) & 0xFF;
  702. }
  703. return bytes;
  704. }
  705. function arrayByteLength(arr) {
  706. if (arr.length !== undefined) {
  707. return arr.length;
  708. }
  709. assert(arr.byteLength !== undefined);
  710. return arr.byteLength;
  711. }
  712. function arraysToBytes(arr) {
  713. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  714. return arr[0];
  715. }
  716. var resultLength = 0;
  717. var i,
  718. ii = arr.length;
  719. var item, itemLength;
  720. for (i = 0; i < ii; i++) {
  721. item = arr[i];
  722. itemLength = arrayByteLength(item);
  723. resultLength += itemLength;
  724. }
  725. var pos = 0;
  726. var data = new Uint8Array(resultLength);
  727. for (i = 0; i < ii; i++) {
  728. item = arr[i];
  729. if (!(item instanceof Uint8Array)) {
  730. if (typeof item === 'string') {
  731. item = stringToBytes(item);
  732. } else {
  733. item = new Uint8Array(item);
  734. }
  735. }
  736. itemLength = item.byteLength;
  737. data.set(item, pos);
  738. pos += itemLength;
  739. }
  740. return data;
  741. }
  742. function string32(value) {
  743. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  744. }
  745. function log2(x) {
  746. if (x <= 0) {
  747. return 0;
  748. }
  749. return Math.ceil(Math.log2(x));
  750. }
  751. function readInt8(data, start) {
  752. return data[start] << 24 >> 24;
  753. }
  754. function readUint16(data, offset) {
  755. return data[offset] << 8 | data[offset + 1];
  756. }
  757. function readUint32(data, offset) {
  758. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  759. }
  760. function isLittleEndian() {
  761. var buffer8 = new Uint8Array(4);
  762. buffer8[0] = 1;
  763. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  764. return view32[0] === 1;
  765. }
  766. function isEvalSupported() {
  767. try {
  768. new Function('');
  769. return true;
  770. } catch (e) {
  771. return false;
  772. }
  773. }
  774. function getInheritableProperty(_ref) {
  775. var dict = _ref.dict,
  776. key = _ref.key,
  777. _ref$getArray = _ref.getArray,
  778. getArray = _ref$getArray === void 0 ? false : _ref$getArray,
  779. _ref$stopWhenFound = _ref.stopWhenFound,
  780. stopWhenFound = _ref$stopWhenFound === void 0 ? true : _ref$stopWhenFound;
  781. var LOOP_LIMIT = 100;
  782. var loopCount = 0;
  783. var values;
  784. while (dict) {
  785. var value = getArray ? dict.getArray(key) : dict.get(key);
  786. if (value !== undefined) {
  787. if (stopWhenFound) {
  788. return value;
  789. }
  790. if (!values) {
  791. values = [];
  792. }
  793. values.push(value);
  794. }
  795. if (++loopCount > LOOP_LIMIT) {
  796. warn("getInheritableProperty: maximum loop count exceeded for \"".concat(key, "\""));
  797. break;
  798. }
  799. dict = dict.get('Parent');
  800. }
  801. return values;
  802. }
  803. var Util = function UtilClosure() {
  804. function Util() {}
  805. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  806. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  807. rgbBuf[1] = r;
  808. rgbBuf[3] = g;
  809. rgbBuf[5] = b;
  810. return rgbBuf.join('');
  811. };
  812. Util.transform = function Util_transform(m1, m2) {
  813. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  814. };
  815. Util.applyTransform = function Util_applyTransform(p, m) {
  816. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  817. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  818. return [xt, yt];
  819. };
  820. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  821. var d = m[0] * m[3] - m[1] * m[2];
  822. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  823. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  824. return [xt, yt];
  825. };
  826. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  827. var p1 = Util.applyTransform(r, m);
  828. var p2 = Util.applyTransform(r.slice(2, 4), m);
  829. var p3 = Util.applyTransform([r[0], r[3]], m);
  830. var p4 = Util.applyTransform([r[2], r[1]], m);
  831. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  832. };
  833. Util.inverseTransform = function Util_inverseTransform(m) {
  834. var d = m[0] * m[3] - m[1] * m[2];
  835. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  836. };
  837. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  838. return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
  839. };
  840. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  841. var transpose = [m[0], m[2], m[1], m[3]];
  842. var a = m[0] * transpose[0] + m[1] * transpose[2];
  843. var b = m[0] * transpose[1] + m[1] * transpose[3];
  844. var c = m[2] * transpose[0] + m[3] * transpose[2];
  845. var d = m[2] * transpose[1] + m[3] * transpose[3];
  846. var first = (a + d) / 2;
  847. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  848. var sx = first + second || 1;
  849. var sy = first - second || 1;
  850. return [Math.sqrt(sx), Math.sqrt(sy)];
  851. };
  852. Util.normalizeRect = function Util_normalizeRect(rect) {
  853. var r = rect.slice(0);
  854. if (rect[0] > rect[2]) {
  855. r[0] = rect[2];
  856. r[2] = rect[0];
  857. }
  858. if (rect[1] > rect[3]) {
  859. r[1] = rect[3];
  860. r[3] = rect[1];
  861. }
  862. return r;
  863. };
  864. Util.intersect = function Util_intersect(rect1, rect2) {
  865. function compare(a, b) {
  866. return a - b;
  867. }
  868. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  869. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  870. result = [];
  871. rect1 = Util.normalizeRect(rect1);
  872. rect2 = Util.normalizeRect(rect2);
  873. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  874. result[0] = orderedX[1];
  875. result[2] = orderedX[2];
  876. } else {
  877. return false;
  878. }
  879. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  880. result[1] = orderedY[1];
  881. result[3] = orderedY[2];
  882. } else {
  883. return false;
  884. }
  885. return result;
  886. };
  887. return Util;
  888. }();
  889. exports.Util = Util;
  890. var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
  891. function toRomanNumerals(number) {
  892. var lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  893. assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
  894. var pos,
  895. romanBuf = [];
  896. while (number >= 1000) {
  897. number -= 1000;
  898. romanBuf.push('M');
  899. }
  900. pos = number / 100 | 0;
  901. number %= 100;
  902. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  903. pos = number / 10 | 0;
  904. number %= 10;
  905. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  906. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  907. var romanStr = romanBuf.join('');
  908. return lowerCase ? romanStr.toLowerCase() : romanStr;
  909. }
  910. var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
  911. function stringToPDFString(str) {
  912. var i,
  913. n = str.length,
  914. strBuf = [];
  915. if (str[0] === '\xFE' && str[1] === '\xFF') {
  916. for (i = 2; i < n; i += 2) {
  917. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  918. }
  919. } else {
  920. for (i = 0; i < n; ++i) {
  921. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  922. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  923. }
  924. }
  925. return strBuf.join('');
  926. }
  927. function stringToUTF8String(str) {
  928. return decodeURIComponent(escape(str));
  929. }
  930. function utf8StringToString(str) {
  931. return unescape(encodeURIComponent(str));
  932. }
  933. function isEmptyObj(obj) {
  934. for (var key in obj) {
  935. return false;
  936. }
  937. return true;
  938. }
  939. function isBool(v) {
  940. return typeof v === 'boolean';
  941. }
  942. function isNum(v) {
  943. return typeof v === 'number';
  944. }
  945. function isString(v) {
  946. return typeof v === 'string';
  947. }
  948. function isArrayBuffer(v) {
  949. return _typeof(v) === 'object' && v !== null && v.byteLength !== undefined;
  950. }
  951. function isSpace(ch) {
  952. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  953. }
  954. function createPromiseCapability() {
  955. var capability = Object.create(null);
  956. var isSettled = false;
  957. Object.defineProperty(capability, 'settled', {
  958. get: function get() {
  959. return isSettled;
  960. }
  961. });
  962. capability.promise = new Promise(function (resolve, reject) {
  963. capability.resolve = function (data) {
  964. isSettled = true;
  965. resolve(data);
  966. };
  967. capability.reject = function (reason) {
  968. isSettled = true;
  969. reject(reason);
  970. };
  971. });
  972. return capability;
  973. }
  974. var createObjectURL = function createObjectURLClosure() {
  975. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  976. return function createObjectURL(data, contentType) {
  977. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  978. if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {
  979. var blob = new Blob([data], {
  980. type: contentType
  981. });
  982. return _url_polyfill.URL.createObjectURL(blob);
  983. }
  984. var buffer = 'data:' + contentType + ';base64,';
  985. for (var i = 0, ii = data.length; i < ii; i += 3) {
  986. var b1 = data[i] & 0xFF;
  987. var b2 = data[i + 1] & 0xFF;
  988. var b3 = data[i + 2] & 0xFF;
  989. var d1 = b1 >> 2,
  990. d2 = (b1 & 3) << 4 | b2 >> 4;
  991. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  992. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  993. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  994. }
  995. return buffer;
  996. };
  997. }();
  998. exports.createObjectURL = createObjectURL;
  999. /***/ }),
  1000. /* 2 */
  1001. /***/ (function(module, exports, __w_pdfjs_require__) {
  1002. "use strict";
  1003. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1004. var globalScope = __w_pdfjs_require__(3);
  1005. if (!globalScope._pdfjsCompatibilityChecked) {
  1006. globalScope._pdfjsCompatibilityChecked = true;
  1007. var isNodeJS = __w_pdfjs_require__(4);
  1008. var hasDOM = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object';
  1009. (function checkNodeBtoa() {
  1010. if (globalScope.btoa || !isNodeJS()) {
  1011. return;
  1012. }
  1013. globalScope.btoa = function (chars) {
  1014. return Buffer.from(chars, 'binary').toString('base64');
  1015. };
  1016. })();
  1017. (function checkNodeAtob() {
  1018. if (globalScope.atob || !isNodeJS()) {
  1019. return;
  1020. }
  1021. globalScope.atob = function (input) {
  1022. return Buffer.from(input, 'base64').toString('binary');
  1023. };
  1024. })();
  1025. (function checkChildNodeRemove() {
  1026. if (!hasDOM) {
  1027. return;
  1028. }
  1029. if (typeof Element.prototype.remove !== 'undefined') {
  1030. return;
  1031. }
  1032. Element.prototype.remove = function () {
  1033. if (this.parentNode) {
  1034. this.parentNode.removeChild(this);
  1035. }
  1036. };
  1037. })();
  1038. (function checkDOMTokenListAddRemove() {
  1039. if (!hasDOM || isNodeJS()) {
  1040. return;
  1041. }
  1042. var div = document.createElement('div');
  1043. div.classList.add('testOne', 'testTwo');
  1044. if (div.classList.contains('testOne') === true && div.classList.contains('testTwo') === true) {
  1045. return;
  1046. }
  1047. var OriginalDOMTokenListAdd = DOMTokenList.prototype.add;
  1048. var OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
  1049. DOMTokenList.prototype.add = function () {
  1050. for (var _len = arguments.length, tokens = new Array(_len), _key = 0; _key < _len; _key++) {
  1051. tokens[_key] = arguments[_key];
  1052. }
  1053. for (var _i = 0; _i < tokens.length; _i++) {
  1054. var token = tokens[_i];
  1055. OriginalDOMTokenListAdd.call(this, token);
  1056. }
  1057. };
  1058. DOMTokenList.prototype.remove = function () {
  1059. for (var _len2 = arguments.length, tokens = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1060. tokens[_key2] = arguments[_key2];
  1061. }
  1062. for (var _i2 = 0; _i2 < tokens.length; _i2++) {
  1063. var token = tokens[_i2];
  1064. OriginalDOMTokenListRemove.call(this, token);
  1065. }
  1066. };
  1067. })();
  1068. (function checkDOMTokenListToggle() {
  1069. if (!hasDOM || isNodeJS()) {
  1070. return;
  1071. }
  1072. var div = document.createElement('div');
  1073. if (div.classList.toggle('test', 0) === false) {
  1074. return;
  1075. }
  1076. DOMTokenList.prototype.toggle = function (token) {
  1077. var force = arguments.length > 1 ? !!arguments[1] : !this.contains(token);
  1078. return this[force ? 'add' : 'remove'](token), force;
  1079. };
  1080. })();
  1081. (function checkStringStartsWith() {
  1082. if (String.prototype.startsWith) {
  1083. return;
  1084. }
  1085. __w_pdfjs_require__(5);
  1086. })();
  1087. (function checkStringEndsWith() {
  1088. if (String.prototype.endsWith) {
  1089. return;
  1090. }
  1091. __w_pdfjs_require__(35);
  1092. })();
  1093. (function checkStringIncludes() {
  1094. if (String.prototype.includes) {
  1095. return;
  1096. }
  1097. __w_pdfjs_require__(37);
  1098. })();
  1099. (function checkArrayIncludes() {
  1100. if (Array.prototype.includes) {
  1101. return;
  1102. }
  1103. __w_pdfjs_require__(39);
  1104. })();
  1105. (function checkArrayFrom() {
  1106. if (Array.from) {
  1107. return;
  1108. }
  1109. __w_pdfjs_require__(46);
  1110. })();
  1111. (function checkObjectAssign() {
  1112. if (Object.assign) {
  1113. return;
  1114. }
  1115. __w_pdfjs_require__(69);
  1116. })();
  1117. (function checkMathLog2() {
  1118. if (Math.log2) {
  1119. return;
  1120. }
  1121. Math.log2 = __w_pdfjs_require__(74);
  1122. })();
  1123. (function checkNumberIsNaN() {
  1124. if (Number.isNaN) {
  1125. return;
  1126. }
  1127. Number.isNaN = __w_pdfjs_require__(76);
  1128. })();
  1129. (function checkNumberIsInteger() {
  1130. if (Number.isInteger) {
  1131. return;
  1132. }
  1133. Number.isInteger = __w_pdfjs_require__(78);
  1134. })();
  1135. (function checkPromise() {})();
  1136. (function checkWeakMap() {
  1137. if (globalScope.WeakMap) {
  1138. return;
  1139. }
  1140. globalScope.WeakMap = __w_pdfjs_require__(81);
  1141. })();
  1142. (function checkWeakSet() {
  1143. if (globalScope.WeakSet) {
  1144. return;
  1145. }
  1146. globalScope.WeakSet = __w_pdfjs_require__(105);
  1147. })();
  1148. (function checkStringCodePointAt() {
  1149. if (String.codePointAt) {
  1150. return;
  1151. }
  1152. String.codePointAt = __w_pdfjs_require__(109);
  1153. })();
  1154. (function checkStringFromCodePoint() {
  1155. if (String.fromCodePoint) {
  1156. return;
  1157. }
  1158. String.fromCodePoint = __w_pdfjs_require__(111);
  1159. })();
  1160. (function checkSymbol() {
  1161. if (globalScope.Symbol) {
  1162. return;
  1163. }
  1164. __w_pdfjs_require__(113);
  1165. })();
  1166. (function checkStringPadStart() {
  1167. if (String.prototype.padStart) {
  1168. return;
  1169. }
  1170. __w_pdfjs_require__(120);
  1171. })();
  1172. (function checkStringPadEnd() {
  1173. if (String.prototype.padEnd) {
  1174. return;
  1175. }
  1176. __w_pdfjs_require__(125);
  1177. })();
  1178. (function checkObjectValues() {
  1179. if (Object.values) {
  1180. return;
  1181. }
  1182. Object.values = __w_pdfjs_require__(127);
  1183. })();
  1184. }
  1185. /***/ }),
  1186. /* 3 */
  1187. /***/ (function(module, exports, __w_pdfjs_require__) {
  1188. "use strict";
  1189. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  1190. /***/ }),
  1191. /* 4 */
  1192. /***/ (function(module, exports, __w_pdfjs_require__) {
  1193. "use strict";
  1194. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1195. module.exports = function isNodeJS() {
  1196. return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process + '' === '[object process]' && !process.versions['nw'];
  1197. };
  1198. /***/ }),
  1199. /* 5 */
  1200. /***/ (function(module, exports, __w_pdfjs_require__) {
  1201. "use strict";
  1202. __w_pdfjs_require__(6);
  1203. module.exports = __w_pdfjs_require__(9).String.startsWith;
  1204. /***/ }),
  1205. /* 6 */
  1206. /***/ (function(module, exports, __w_pdfjs_require__) {
  1207. "use strict";
  1208. var $export = __w_pdfjs_require__(7);
  1209. var toLength = __w_pdfjs_require__(25);
  1210. var context = __w_pdfjs_require__(27);
  1211. var STARTS_WITH = 'startsWith';
  1212. var $startsWith = ''[STARTS_WITH];
  1213. $export($export.P + $export.F * __w_pdfjs_require__(34)(STARTS_WITH), 'String', {
  1214. startsWith: function startsWith(searchString) {
  1215. var that = context(this, searchString, STARTS_WITH);
  1216. var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  1217. var search = String(searchString);
  1218. return $startsWith ? $startsWith.call(that, search, index) : that.slice(index, index + search.length) === search;
  1219. }
  1220. });
  1221. /***/ }),
  1222. /* 7 */
  1223. /***/ (function(module, exports, __w_pdfjs_require__) {
  1224. "use strict";
  1225. var global = __w_pdfjs_require__(8);
  1226. var core = __w_pdfjs_require__(9);
  1227. var hide = __w_pdfjs_require__(10);
  1228. var redefine = __w_pdfjs_require__(20);
  1229. var ctx = __w_pdfjs_require__(23);
  1230. var PROTOTYPE = 'prototype';
  1231. var $export = function $export(type, name, source) {
  1232. var IS_FORCED = type & $export.F;
  1233. var IS_GLOBAL = type & $export.G;
  1234. var IS_STATIC = type & $export.S;
  1235. var IS_PROTO = type & $export.P;
  1236. var IS_BIND = type & $export.B;
  1237. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  1238. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  1239. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  1240. var key, own, out, exp;
  1241. if (IS_GLOBAL) source = name;
  1242. for (key in source) {
  1243. own = !IS_FORCED && target && target[key] !== undefined;
  1244. out = (own ? target : source)[key];
  1245. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1246. if (target) redefine(target, key, out, type & $export.U);
  1247. if (exports[key] != out) hide(exports, key, exp);
  1248. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  1249. }
  1250. };
  1251. global.core = core;
  1252. $export.F = 1;
  1253. $export.G = 2;
  1254. $export.S = 4;
  1255. $export.P = 8;
  1256. $export.B = 16;
  1257. $export.W = 32;
  1258. $export.U = 64;
  1259. $export.R = 128;
  1260. module.exports = $export;
  1261. /***/ }),
  1262. /* 8 */
  1263. /***/ (function(module, exports, __w_pdfjs_require__) {
  1264. "use strict";
  1265. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1266. if (typeof __g == 'number') __g = global;
  1267. /***/ }),
  1268. /* 9 */
  1269. /***/ (function(module, exports, __w_pdfjs_require__) {
  1270. "use strict";
  1271. var core = module.exports = {
  1272. version: '2.6.2'
  1273. };
  1274. if (typeof __e == 'number') __e = core;
  1275. /***/ }),
  1276. /* 10 */
  1277. /***/ (function(module, exports, __w_pdfjs_require__) {
  1278. "use strict";
  1279. var dP = __w_pdfjs_require__(11);
  1280. var createDesc = __w_pdfjs_require__(19);
  1281. module.exports = __w_pdfjs_require__(15) ? function (object, key, value) {
  1282. return dP.f(object, key, createDesc(1, value));
  1283. } : function (object, key, value) {
  1284. object[key] = value;
  1285. return object;
  1286. };
  1287. /***/ }),
  1288. /* 11 */
  1289. /***/ (function(module, exports, __w_pdfjs_require__) {
  1290. "use strict";
  1291. var anObject = __w_pdfjs_require__(12);
  1292. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  1293. var toPrimitive = __w_pdfjs_require__(18);
  1294. var dP = Object.defineProperty;
  1295. exports.f = __w_pdfjs_require__(15) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  1296. anObject(O);
  1297. P = toPrimitive(P, true);
  1298. anObject(Attributes);
  1299. if (IE8_DOM_DEFINE) try {
  1300. return dP(O, P, Attributes);
  1301. } catch (e) {}
  1302. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  1303. if ('value' in Attributes) O[P] = Attributes.value;
  1304. return O;
  1305. };
  1306. /***/ }),
  1307. /* 12 */
  1308. /***/ (function(module, exports, __w_pdfjs_require__) {
  1309. "use strict";
  1310. var isObject = __w_pdfjs_require__(13);
  1311. module.exports = function (it) {
  1312. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  1313. return it;
  1314. };
  1315. /***/ }),
  1316. /* 13 */
  1317. /***/ (function(module, exports, __w_pdfjs_require__) {
  1318. "use strict";
  1319. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1320. module.exports = function (it) {
  1321. return _typeof(it) === 'object' ? it !== null : typeof it === 'function';
  1322. };
  1323. /***/ }),
  1324. /* 14 */
  1325. /***/ (function(module, exports, __w_pdfjs_require__) {
  1326. "use strict";
  1327. module.exports = !__w_pdfjs_require__(15) && !__w_pdfjs_require__(16)(function () {
  1328. return Object.defineProperty(__w_pdfjs_require__(17)('div'), 'a', {
  1329. get: function get() {
  1330. return 7;
  1331. }
  1332. }).a != 7;
  1333. });
  1334. /***/ }),
  1335. /* 15 */
  1336. /***/ (function(module, exports, __w_pdfjs_require__) {
  1337. "use strict";
  1338. module.exports = !__w_pdfjs_require__(16)(function () {
  1339. return Object.defineProperty({}, 'a', {
  1340. get: function get() {
  1341. return 7;
  1342. }
  1343. }).a != 7;
  1344. });
  1345. /***/ }),
  1346. /* 16 */
  1347. /***/ (function(module, exports, __w_pdfjs_require__) {
  1348. "use strict";
  1349. module.exports = function (exec) {
  1350. try {
  1351. return !!exec();
  1352. } catch (e) {
  1353. return true;
  1354. }
  1355. };
  1356. /***/ }),
  1357. /* 17 */
  1358. /***/ (function(module, exports, __w_pdfjs_require__) {
  1359. "use strict";
  1360. var isObject = __w_pdfjs_require__(13);
  1361. var document = __w_pdfjs_require__(8).document;
  1362. var is = isObject(document) && isObject(document.createElement);
  1363. module.exports = function (it) {
  1364. return is ? document.createElement(it) : {};
  1365. };
  1366. /***/ }),
  1367. /* 18 */
  1368. /***/ (function(module, exports, __w_pdfjs_require__) {
  1369. "use strict";
  1370. var isObject = __w_pdfjs_require__(13);
  1371. module.exports = function (it, S) {
  1372. if (!isObject(it)) return it;
  1373. var fn, val;
  1374. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1375. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  1376. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1377. throw TypeError("Can't convert object to primitive value");
  1378. };
  1379. /***/ }),
  1380. /* 19 */
  1381. /***/ (function(module, exports, __w_pdfjs_require__) {
  1382. "use strict";
  1383. module.exports = function (bitmap, value) {
  1384. return {
  1385. enumerable: !(bitmap & 1),
  1386. configurable: !(bitmap & 2),
  1387. writable: !(bitmap & 4),
  1388. value: value
  1389. };
  1390. };
  1391. /***/ }),
  1392. /* 20 */
  1393. /***/ (function(module, exports, __w_pdfjs_require__) {
  1394. "use strict";
  1395. var global = __w_pdfjs_require__(8);
  1396. var hide = __w_pdfjs_require__(10);
  1397. var has = __w_pdfjs_require__(21);
  1398. var SRC = __w_pdfjs_require__(22)('src');
  1399. var TO_STRING = 'toString';
  1400. var $toString = Function[TO_STRING];
  1401. var TPL = ('' + $toString).split(TO_STRING);
  1402. __w_pdfjs_require__(9).inspectSource = function (it) {
  1403. return $toString.call(it);
  1404. };
  1405. (module.exports = function (O, key, val, safe) {
  1406. var isFunction = typeof val == 'function';
  1407. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  1408. if (O[key] === val) return;
  1409. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  1410. if (O === global) {
  1411. O[key] = val;
  1412. } else if (!safe) {
  1413. delete O[key];
  1414. hide(O, key, val);
  1415. } else if (O[key]) {
  1416. O[key] = val;
  1417. } else {
  1418. hide(O, key, val);
  1419. }
  1420. })(Function.prototype, TO_STRING, function toString() {
  1421. return typeof this == 'function' && this[SRC] || $toString.call(this);
  1422. });
  1423. /***/ }),
  1424. /* 21 */
  1425. /***/ (function(module, exports, __w_pdfjs_require__) {
  1426. "use strict";
  1427. var hasOwnProperty = {}.hasOwnProperty;
  1428. module.exports = function (it, key) {
  1429. return hasOwnProperty.call(it, key);
  1430. };
  1431. /***/ }),
  1432. /* 22 */
  1433. /***/ (function(module, exports, __w_pdfjs_require__) {
  1434. "use strict";
  1435. var id = 0;
  1436. var px = Math.random();
  1437. module.exports = function (key) {
  1438. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  1439. };
  1440. /***/ }),
  1441. /* 23 */
  1442. /***/ (function(module, exports, __w_pdfjs_require__) {
  1443. "use strict";
  1444. var aFunction = __w_pdfjs_require__(24);
  1445. module.exports = function (fn, that, length) {
  1446. aFunction(fn);
  1447. if (that === undefined) return fn;
  1448. switch (length) {
  1449. case 1:
  1450. return function (a) {
  1451. return fn.call(that, a);
  1452. };
  1453. case 2:
  1454. return function (a, b) {
  1455. return fn.call(that, a, b);
  1456. };
  1457. case 3:
  1458. return function (a, b, c) {
  1459. return fn.call(that, a, b, c);
  1460. };
  1461. }
  1462. return function () {
  1463. return fn.apply(that, arguments);
  1464. };
  1465. };
  1466. /***/ }),
  1467. /* 24 */
  1468. /***/ (function(module, exports, __w_pdfjs_require__) {
  1469. "use strict";
  1470. module.exports = function (it) {
  1471. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  1472. return it;
  1473. };
  1474. /***/ }),
  1475. /* 25 */
  1476. /***/ (function(module, exports, __w_pdfjs_require__) {
  1477. "use strict";
  1478. var toInteger = __w_pdfjs_require__(26);
  1479. var min = Math.min;
  1480. module.exports = function (it) {
  1481. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  1482. };
  1483. /***/ }),
  1484. /* 26 */
  1485. /***/ (function(module, exports, __w_pdfjs_require__) {
  1486. "use strict";
  1487. var ceil = Math.ceil;
  1488. var floor = Math.floor;
  1489. module.exports = function (it) {
  1490. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  1491. };
  1492. /***/ }),
  1493. /* 27 */
  1494. /***/ (function(module, exports, __w_pdfjs_require__) {
  1495. "use strict";
  1496. var isRegExp = __w_pdfjs_require__(28);
  1497. var defined = __w_pdfjs_require__(33);
  1498. module.exports = function (that, searchString, NAME) {
  1499. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  1500. return String(defined(that));
  1501. };
  1502. /***/ }),
  1503. /* 28 */
  1504. /***/ (function(module, exports, __w_pdfjs_require__) {
  1505. "use strict";
  1506. var isObject = __w_pdfjs_require__(13);
  1507. var cof = __w_pdfjs_require__(29);
  1508. var MATCH = __w_pdfjs_require__(30)('match');
  1509. module.exports = function (it) {
  1510. var isRegExp;
  1511. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  1512. };
  1513. /***/ }),
  1514. /* 29 */
  1515. /***/ (function(module, exports, __w_pdfjs_require__) {
  1516. "use strict";
  1517. var toString = {}.toString;
  1518. module.exports = function (it) {
  1519. return toString.call(it).slice(8, -1);
  1520. };
  1521. /***/ }),
  1522. /* 30 */
  1523. /***/ (function(module, exports, __w_pdfjs_require__) {
  1524. "use strict";
  1525. var store = __w_pdfjs_require__(31)('wks');
  1526. var uid = __w_pdfjs_require__(22);
  1527. var _Symbol = __w_pdfjs_require__(8).Symbol;
  1528. var USE_SYMBOL = typeof _Symbol == 'function';
  1529. var $exports = module.exports = function (name) {
  1530. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1531. };
  1532. $exports.store = store;
  1533. /***/ }),
  1534. /* 31 */
  1535. /***/ (function(module, exports, __w_pdfjs_require__) {
  1536. "use strict";
  1537. var core = __w_pdfjs_require__(9);
  1538. var global = __w_pdfjs_require__(8);
  1539. var SHARED = '__core-js_shared__';
  1540. var store = global[SHARED] || (global[SHARED] = {});
  1541. (module.exports = function (key, value) {
  1542. return store[key] || (store[key] = value !== undefined ? value : {});
  1543. })('versions', []).push({
  1544. version: core.version,
  1545. mode: __w_pdfjs_require__(32) ? 'pure' : 'global',
  1546. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  1547. });
  1548. /***/ }),
  1549. /* 32 */
  1550. /***/ (function(module, exports, __w_pdfjs_require__) {
  1551. "use strict";
  1552. module.exports = false;
  1553. /***/ }),
  1554. /* 33 */
  1555. /***/ (function(module, exports, __w_pdfjs_require__) {
  1556. "use strict";
  1557. module.exports = function (it) {
  1558. if (it == undefined) throw TypeError("Can't call method on " + it);
  1559. return it;
  1560. };
  1561. /***/ }),
  1562. /* 34 */
  1563. /***/ (function(module, exports, __w_pdfjs_require__) {
  1564. "use strict";
  1565. var MATCH = __w_pdfjs_require__(30)('match');
  1566. module.exports = function (KEY) {
  1567. var re = /./;
  1568. try {
  1569. '/./'[KEY](re);
  1570. } catch (e) {
  1571. try {
  1572. re[MATCH] = false;
  1573. return !'/./'[KEY](re);
  1574. } catch (f) {}
  1575. }
  1576. return true;
  1577. };
  1578. /***/ }),
  1579. /* 35 */
  1580. /***/ (function(module, exports, __w_pdfjs_require__) {
  1581. "use strict";
  1582. __w_pdfjs_require__(36);
  1583. module.exports = __w_pdfjs_require__(9).String.endsWith;
  1584. /***/ }),
  1585. /* 36 */
  1586. /***/ (function(module, exports, __w_pdfjs_require__) {
  1587. "use strict";
  1588. var $export = __w_pdfjs_require__(7);
  1589. var toLength = __w_pdfjs_require__(25);
  1590. var context = __w_pdfjs_require__(27);
  1591. var ENDS_WITH = 'endsWith';
  1592. var $endsWith = ''[ENDS_WITH];
  1593. $export($export.P + $export.F * __w_pdfjs_require__(34)(ENDS_WITH), 'String', {
  1594. endsWith: function endsWith(searchString) {
  1595. var that = context(this, searchString, ENDS_WITH);
  1596. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  1597. var len = toLength(that.length);
  1598. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  1599. var search = String(searchString);
  1600. return $endsWith ? $endsWith.call(that, search, end) : that.slice(end - search.length, end) === search;
  1601. }
  1602. });
  1603. /***/ }),
  1604. /* 37 */
  1605. /***/ (function(module, exports, __w_pdfjs_require__) {
  1606. "use strict";
  1607. __w_pdfjs_require__(38);
  1608. module.exports = __w_pdfjs_require__(9).String.includes;
  1609. /***/ }),
  1610. /* 38 */
  1611. /***/ (function(module, exports, __w_pdfjs_require__) {
  1612. "use strict";
  1613. var $export = __w_pdfjs_require__(7);
  1614. var context = __w_pdfjs_require__(27);
  1615. var INCLUDES = 'includes';
  1616. $export($export.P + $export.F * __w_pdfjs_require__(34)(INCLUDES), 'String', {
  1617. includes: function includes(searchString) {
  1618. return !!~context(this, searchString, INCLUDES).indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  1619. }
  1620. });
  1621. /***/ }),
  1622. /* 39 */
  1623. /***/ (function(module, exports, __w_pdfjs_require__) {
  1624. "use strict";
  1625. __w_pdfjs_require__(40);
  1626. module.exports = __w_pdfjs_require__(9).Array.includes;
  1627. /***/ }),
  1628. /* 40 */
  1629. /***/ (function(module, exports, __w_pdfjs_require__) {
  1630. "use strict";
  1631. var $export = __w_pdfjs_require__(7);
  1632. var $includes = __w_pdfjs_require__(41)(true);
  1633. $export($export.P, 'Array', {
  1634. includes: function includes(el) {
  1635. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  1636. }
  1637. });
  1638. __w_pdfjs_require__(45)('includes');
  1639. /***/ }),
  1640. /* 41 */
  1641. /***/ (function(module, exports, __w_pdfjs_require__) {
  1642. "use strict";
  1643. var toIObject = __w_pdfjs_require__(42);
  1644. var toLength = __w_pdfjs_require__(25);
  1645. var toAbsoluteIndex = __w_pdfjs_require__(44);
  1646. module.exports = function (IS_INCLUDES) {
  1647. return function ($this, el, fromIndex) {
  1648. var O = toIObject($this);
  1649. var length = toLength(O.length);
  1650. var index = toAbsoluteIndex(fromIndex, length);
  1651. var value;
  1652. if (IS_INCLUDES && el != el) while (length > index) {
  1653. value = O[index++];
  1654. if (value != value) return true;
  1655. } else for (; length > index; index++) {
  1656. if (IS_INCLUDES || index in O) {
  1657. if (O[index] === el) return IS_INCLUDES || index || 0;
  1658. }
  1659. }
  1660. return !IS_INCLUDES && -1;
  1661. };
  1662. };
  1663. /***/ }),
  1664. /* 42 */
  1665. /***/ (function(module, exports, __w_pdfjs_require__) {
  1666. "use strict";
  1667. var IObject = __w_pdfjs_require__(43);
  1668. var defined = __w_pdfjs_require__(33);
  1669. module.exports = function (it) {
  1670. return IObject(defined(it));
  1671. };
  1672. /***/ }),
  1673. /* 43 */
  1674. /***/ (function(module, exports, __w_pdfjs_require__) {
  1675. "use strict";
  1676. var cof = __w_pdfjs_require__(29);
  1677. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  1678. return cof(it) == 'String' ? it.split('') : Object(it);
  1679. };
  1680. /***/ }),
  1681. /* 44 */
  1682. /***/ (function(module, exports, __w_pdfjs_require__) {
  1683. "use strict";
  1684. var toInteger = __w_pdfjs_require__(26);
  1685. var max = Math.max;
  1686. var min = Math.min;
  1687. module.exports = function (index, length) {
  1688. index = toInteger(index);
  1689. return index < 0 ? max(index + length, 0) : min(index, length);
  1690. };
  1691. /***/ }),
  1692. /* 45 */
  1693. /***/ (function(module, exports, __w_pdfjs_require__) {
  1694. "use strict";
  1695. var UNSCOPABLES = __w_pdfjs_require__(30)('unscopables');
  1696. var ArrayProto = Array.prototype;
  1697. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(10)(ArrayProto, UNSCOPABLES, {});
  1698. module.exports = function (key) {
  1699. ArrayProto[UNSCOPABLES][key] = true;
  1700. };
  1701. /***/ }),
  1702. /* 46 */
  1703. /***/ (function(module, exports, __w_pdfjs_require__) {
  1704. "use strict";
  1705. __w_pdfjs_require__(47);
  1706. __w_pdfjs_require__(62);
  1707. module.exports = __w_pdfjs_require__(9).Array.from;
  1708. /***/ }),
  1709. /* 47 */
  1710. /***/ (function(module, exports, __w_pdfjs_require__) {
  1711. "use strict";
  1712. var $at = __w_pdfjs_require__(48)(true);
  1713. __w_pdfjs_require__(49)(String, 'String', function (iterated) {
  1714. this._t = String(iterated);
  1715. this._i = 0;
  1716. }, function () {
  1717. var O = this._t;
  1718. var index = this._i;
  1719. var point;
  1720. if (index >= O.length) return {
  1721. value: undefined,
  1722. done: true
  1723. };
  1724. point = $at(O, index);
  1725. this._i += point.length;
  1726. return {
  1727. value: point,
  1728. done: false
  1729. };
  1730. });
  1731. /***/ }),
  1732. /* 48 */
  1733. /***/ (function(module, exports, __w_pdfjs_require__) {
  1734. "use strict";
  1735. var toInteger = __w_pdfjs_require__(26);
  1736. var defined = __w_pdfjs_require__(33);
  1737. module.exports = function (TO_STRING) {
  1738. return function (that, pos) {
  1739. var s = String(defined(that));
  1740. var i = toInteger(pos);
  1741. var l = s.length;
  1742. var a, b;
  1743. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  1744. a = s.charCodeAt(i);
  1745. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  1746. };
  1747. };
  1748. /***/ }),
  1749. /* 49 */
  1750. /***/ (function(module, exports, __w_pdfjs_require__) {
  1751. "use strict";
  1752. var LIBRARY = __w_pdfjs_require__(32);
  1753. var $export = __w_pdfjs_require__(7);
  1754. var redefine = __w_pdfjs_require__(20);
  1755. var hide = __w_pdfjs_require__(10);
  1756. var Iterators = __w_pdfjs_require__(50);
  1757. var $iterCreate = __w_pdfjs_require__(51);
  1758. var setToStringTag = __w_pdfjs_require__(59);
  1759. var getPrototypeOf = __w_pdfjs_require__(60);
  1760. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  1761. var BUGGY = !([].keys && 'next' in [].keys());
  1762. var FF_ITERATOR = '@@iterator';
  1763. var KEYS = 'keys';
  1764. var VALUES = 'values';
  1765. var returnThis = function returnThis() {
  1766. return this;
  1767. };
  1768. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  1769. $iterCreate(Constructor, NAME, next);
  1770. var getMethod = function getMethod(kind) {
  1771. if (!BUGGY && kind in proto) return proto[kind];
  1772. switch (kind) {
  1773. case KEYS:
  1774. return function keys() {
  1775. return new Constructor(this, kind);
  1776. };
  1777. case VALUES:
  1778. return function values() {
  1779. return new Constructor(this, kind);
  1780. };
  1781. }
  1782. return function entries() {
  1783. return new Constructor(this, kind);
  1784. };
  1785. };
  1786. var TAG = NAME + ' Iterator';
  1787. var DEF_VALUES = DEFAULT == VALUES;
  1788. var VALUES_BUG = false;
  1789. var proto = Base.prototype;
  1790. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  1791. var $default = $native || getMethod(DEFAULT);
  1792. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  1793. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  1794. var methods, key, IteratorPrototype;
  1795. if ($anyNative) {
  1796. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  1797. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  1798. setToStringTag(IteratorPrototype, TAG, true);
  1799. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  1800. }
  1801. }
  1802. if (DEF_VALUES && $native && $native.name !== VALUES) {
  1803. VALUES_BUG = true;
  1804. $default = function values() {
  1805. return $native.call(this);
  1806. };
  1807. }
  1808. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  1809. hide(proto, ITERATOR, $default);
  1810. }
  1811. Iterators[NAME] = $default;
  1812. Iterators[TAG] = returnThis;
  1813. if (DEFAULT) {
  1814. methods = {
  1815. values: DEF_VALUES ? $default : getMethod(VALUES),
  1816. keys: IS_SET ? $default : getMethod(KEYS),
  1817. entries: $entries
  1818. };
  1819. if (FORCED) for (key in methods) {
  1820. if (!(key in proto)) redefine(proto, key, methods[key]);
  1821. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  1822. }
  1823. return methods;
  1824. };
  1825. /***/ }),
  1826. /* 50 */
  1827. /***/ (function(module, exports, __w_pdfjs_require__) {
  1828. "use strict";
  1829. module.exports = {};
  1830. /***/ }),
  1831. /* 51 */
  1832. /***/ (function(module, exports, __w_pdfjs_require__) {
  1833. "use strict";
  1834. var create = __w_pdfjs_require__(52);
  1835. var descriptor = __w_pdfjs_require__(19);
  1836. var setToStringTag = __w_pdfjs_require__(59);
  1837. var IteratorPrototype = {};
  1838. __w_pdfjs_require__(10)(IteratorPrototype, __w_pdfjs_require__(30)('iterator'), function () {
  1839. return this;
  1840. });
  1841. module.exports = function (Constructor, NAME, next) {
  1842. Constructor.prototype = create(IteratorPrototype, {
  1843. next: descriptor(1, next)
  1844. });
  1845. setToStringTag(Constructor, NAME + ' Iterator');
  1846. };
  1847. /***/ }),
  1848. /* 52 */
  1849. /***/ (function(module, exports, __w_pdfjs_require__) {
  1850. "use strict";
  1851. var anObject = __w_pdfjs_require__(12);
  1852. var dPs = __w_pdfjs_require__(53);
  1853. var enumBugKeys = __w_pdfjs_require__(57);
  1854. var IE_PROTO = __w_pdfjs_require__(56)('IE_PROTO');
  1855. var Empty = function Empty() {};
  1856. var PROTOTYPE = 'prototype';
  1857. var _createDict = function createDict() {
  1858. var iframe = __w_pdfjs_require__(17)('iframe');
  1859. var i = enumBugKeys.length;
  1860. var lt = '<';
  1861. var gt = '>';
  1862. var iframeDocument;
  1863. iframe.style.display = 'none';
  1864. __w_pdfjs_require__(58).appendChild(iframe);
  1865. iframe.src = 'javascript:';
  1866. iframeDocument = iframe.contentWindow.document;
  1867. iframeDocument.open();
  1868. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  1869. iframeDocument.close();
  1870. _createDict = iframeDocument.F;
  1871. while (i--) {
  1872. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  1873. }
  1874. return _createDict();
  1875. };
  1876. module.exports = Object.create || function create(O, Properties) {
  1877. var result;
  1878. if (O !== null) {
  1879. Empty[PROTOTYPE] = anObject(O);
  1880. result = new Empty();
  1881. Empty[PROTOTYPE] = null;
  1882. result[IE_PROTO] = O;
  1883. } else result = _createDict();
  1884. return Properties === undefined ? result : dPs(result, Properties);
  1885. };
  1886. /***/ }),
  1887. /* 53 */
  1888. /***/ (function(module, exports, __w_pdfjs_require__) {
  1889. "use strict";
  1890. var dP = __w_pdfjs_require__(11);
  1891. var anObject = __w_pdfjs_require__(12);
  1892. var getKeys = __w_pdfjs_require__(54);
  1893. module.exports = __w_pdfjs_require__(15) ? Object.defineProperties : function defineProperties(O, Properties) {
  1894. anObject(O);
  1895. var keys = getKeys(Properties);
  1896. var length = keys.length;
  1897. var i = 0;
  1898. var P;
  1899. while (length > i) {
  1900. dP.f(O, P = keys[i++], Properties[P]);
  1901. }
  1902. return O;
  1903. };
  1904. /***/ }),
  1905. /* 54 */
  1906. /***/ (function(module, exports, __w_pdfjs_require__) {
  1907. "use strict";
  1908. var $keys = __w_pdfjs_require__(55);
  1909. var enumBugKeys = __w_pdfjs_require__(57);
  1910. module.exports = Object.keys || function keys(O) {
  1911. return $keys(O, enumBugKeys);
  1912. };
  1913. /***/ }),
  1914. /* 55 */
  1915. /***/ (function(module, exports, __w_pdfjs_require__) {
  1916. "use strict";
  1917. var has = __w_pdfjs_require__(21);
  1918. var toIObject = __w_pdfjs_require__(42);
  1919. var arrayIndexOf = __w_pdfjs_require__(41)(false);
  1920. var IE_PROTO = __w_pdfjs_require__(56)('IE_PROTO');
  1921. module.exports = function (object, names) {
  1922. var O = toIObject(object);
  1923. var i = 0;
  1924. var result = [];
  1925. var key;
  1926. for (key in O) {
  1927. if (key != IE_PROTO) has(O, key) && result.push(key);
  1928. }
  1929. while (names.length > i) {
  1930. if (has(O, key = names[i++])) {
  1931. ~arrayIndexOf(result, key) || result.push(key);
  1932. }
  1933. }
  1934. return result;
  1935. };
  1936. /***/ }),
  1937. /* 56 */
  1938. /***/ (function(module, exports, __w_pdfjs_require__) {
  1939. "use strict";
  1940. var shared = __w_pdfjs_require__(31)('keys');
  1941. var uid = __w_pdfjs_require__(22);
  1942. module.exports = function (key) {
  1943. return shared[key] || (shared[key] = uid(key));
  1944. };
  1945. /***/ }),
  1946. /* 57 */
  1947. /***/ (function(module, exports, __w_pdfjs_require__) {
  1948. "use strict";
  1949. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  1950. /***/ }),
  1951. /* 58 */
  1952. /***/ (function(module, exports, __w_pdfjs_require__) {
  1953. "use strict";
  1954. var document = __w_pdfjs_require__(8).document;
  1955. module.exports = document && document.documentElement;
  1956. /***/ }),
  1957. /* 59 */
  1958. /***/ (function(module, exports, __w_pdfjs_require__) {
  1959. "use strict";
  1960. var def = __w_pdfjs_require__(11).f;
  1961. var has = __w_pdfjs_require__(21);
  1962. var TAG = __w_pdfjs_require__(30)('toStringTag');
  1963. module.exports = function (it, tag, stat) {
  1964. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  1965. configurable: true,
  1966. value: tag
  1967. });
  1968. };
  1969. /***/ }),
  1970. /* 60 */
  1971. /***/ (function(module, exports, __w_pdfjs_require__) {
  1972. "use strict";
  1973. var has = __w_pdfjs_require__(21);
  1974. var toObject = __w_pdfjs_require__(61);
  1975. var IE_PROTO = __w_pdfjs_require__(56)('IE_PROTO');
  1976. var ObjectProto = Object.prototype;
  1977. module.exports = Object.getPrototypeOf || function (O) {
  1978. O = toObject(O);
  1979. if (has(O, IE_PROTO)) return O[IE_PROTO];
  1980. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1981. return O.constructor.prototype;
  1982. }
  1983. return O instanceof Object ? ObjectProto : null;
  1984. };
  1985. /***/ }),
  1986. /* 61 */
  1987. /***/ (function(module, exports, __w_pdfjs_require__) {
  1988. "use strict";
  1989. var defined = __w_pdfjs_require__(33);
  1990. module.exports = function (it) {
  1991. return Object(defined(it));
  1992. };
  1993. /***/ }),
  1994. /* 62 */
  1995. /***/ (function(module, exports, __w_pdfjs_require__) {
  1996. "use strict";
  1997. var ctx = __w_pdfjs_require__(23);
  1998. var $export = __w_pdfjs_require__(7);
  1999. var toObject = __w_pdfjs_require__(61);
  2000. var call = __w_pdfjs_require__(63);
  2001. var isArrayIter = __w_pdfjs_require__(64);
  2002. var toLength = __w_pdfjs_require__(25);
  2003. var createProperty = __w_pdfjs_require__(65);
  2004. var getIterFn = __w_pdfjs_require__(66);
  2005. $export($export.S + $export.F * !__w_pdfjs_require__(68)(function (iter) {
  2006. Array.from(iter);
  2007. }), 'Array', {
  2008. from: function from(arrayLike) {
  2009. var O = toObject(arrayLike);
  2010. var C = typeof this == 'function' ? this : Array;
  2011. var aLen = arguments.length;
  2012. var mapfn = aLen > 1 ? arguments[1] : undefined;
  2013. var mapping = mapfn !== undefined;
  2014. var index = 0;
  2015. var iterFn = getIterFn(O);
  2016. var length, result, step, iterator;
  2017. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  2018. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  2019. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  2020. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  2021. }
  2022. } else {
  2023. length = toLength(O.length);
  2024. for (result = new C(length); length > index; index++) {
  2025. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  2026. }
  2027. }
  2028. result.length = index;
  2029. return result;
  2030. }
  2031. });
  2032. /***/ }),
  2033. /* 63 */
  2034. /***/ (function(module, exports, __w_pdfjs_require__) {
  2035. "use strict";
  2036. var anObject = __w_pdfjs_require__(12);
  2037. module.exports = function (iterator, fn, value, entries) {
  2038. try {
  2039. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  2040. } catch (e) {
  2041. var ret = iterator['return'];
  2042. if (ret !== undefined) anObject(ret.call(iterator));
  2043. throw e;
  2044. }
  2045. };
  2046. /***/ }),
  2047. /* 64 */
  2048. /***/ (function(module, exports, __w_pdfjs_require__) {
  2049. "use strict";
  2050. var Iterators = __w_pdfjs_require__(50);
  2051. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  2052. var ArrayProto = Array.prototype;
  2053. module.exports = function (it) {
  2054. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  2055. };
  2056. /***/ }),
  2057. /* 65 */
  2058. /***/ (function(module, exports, __w_pdfjs_require__) {
  2059. "use strict";
  2060. var $defineProperty = __w_pdfjs_require__(11);
  2061. var createDesc = __w_pdfjs_require__(19);
  2062. module.exports = function (object, index, value) {
  2063. if (index in object) $defineProperty.f(object, index, createDesc(0, value));else object[index] = value;
  2064. };
  2065. /***/ }),
  2066. /* 66 */
  2067. /***/ (function(module, exports, __w_pdfjs_require__) {
  2068. "use strict";
  2069. var classof = __w_pdfjs_require__(67);
  2070. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  2071. var Iterators = __w_pdfjs_require__(50);
  2072. module.exports = __w_pdfjs_require__(9).getIteratorMethod = function (it) {
  2073. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  2074. };
  2075. /***/ }),
  2076. /* 67 */
  2077. /***/ (function(module, exports, __w_pdfjs_require__) {
  2078. "use strict";
  2079. var cof = __w_pdfjs_require__(29);
  2080. var TAG = __w_pdfjs_require__(30)('toStringTag');
  2081. var ARG = cof(function () {
  2082. return arguments;
  2083. }()) == 'Arguments';
  2084. var tryGet = function tryGet(it, key) {
  2085. try {
  2086. return it[key];
  2087. } catch (e) {}
  2088. };
  2089. module.exports = function (it) {
  2090. var O, T, B;
  2091. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  2092. };
  2093. /***/ }),
  2094. /* 68 */
  2095. /***/ (function(module, exports, __w_pdfjs_require__) {
  2096. "use strict";
  2097. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  2098. var SAFE_CLOSING = false;
  2099. try {
  2100. var riter = [7][ITERATOR]();
  2101. riter['return'] = function () {
  2102. SAFE_CLOSING = true;
  2103. };
  2104. Array.from(riter, function () {
  2105. throw 2;
  2106. });
  2107. } catch (e) {}
  2108. module.exports = function (exec, skipClosing) {
  2109. if (!skipClosing && !SAFE_CLOSING) return false;
  2110. var safe = false;
  2111. try {
  2112. var arr = [7];
  2113. var iter = arr[ITERATOR]();
  2114. iter.next = function () {
  2115. return {
  2116. done: safe = true
  2117. };
  2118. };
  2119. arr[ITERATOR] = function () {
  2120. return iter;
  2121. };
  2122. exec(arr);
  2123. } catch (e) {}
  2124. return safe;
  2125. };
  2126. /***/ }),
  2127. /* 69 */
  2128. /***/ (function(module, exports, __w_pdfjs_require__) {
  2129. "use strict";
  2130. __w_pdfjs_require__(70);
  2131. module.exports = __w_pdfjs_require__(9).Object.assign;
  2132. /***/ }),
  2133. /* 70 */
  2134. /***/ (function(module, exports, __w_pdfjs_require__) {
  2135. "use strict";
  2136. var $export = __w_pdfjs_require__(7);
  2137. $export($export.S + $export.F, 'Object', {
  2138. assign: __w_pdfjs_require__(71)
  2139. });
  2140. /***/ }),
  2141. /* 71 */
  2142. /***/ (function(module, exports, __w_pdfjs_require__) {
  2143. "use strict";
  2144. var getKeys = __w_pdfjs_require__(54);
  2145. var gOPS = __w_pdfjs_require__(72);
  2146. var pIE = __w_pdfjs_require__(73);
  2147. var toObject = __w_pdfjs_require__(61);
  2148. var IObject = __w_pdfjs_require__(43);
  2149. var $assign = Object.assign;
  2150. module.exports = !$assign || __w_pdfjs_require__(16)(function () {
  2151. var A = {};
  2152. var B = {};
  2153. var S = Symbol();
  2154. var K = 'abcdefghijklmnopqrst';
  2155. A[S] = 7;
  2156. K.split('').forEach(function (k) {
  2157. B[k] = k;
  2158. });
  2159. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  2160. }) ? function assign(target, source) {
  2161. var T = toObject(target);
  2162. var aLen = arguments.length;
  2163. var index = 1;
  2164. var getSymbols = gOPS.f;
  2165. var isEnum = pIE.f;
  2166. while (aLen > index) {
  2167. var S = IObject(arguments[index++]);
  2168. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  2169. var length = keys.length;
  2170. var j = 0;
  2171. var key;
  2172. while (length > j) {
  2173. if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  2174. }
  2175. }
  2176. return T;
  2177. } : $assign;
  2178. /***/ }),
  2179. /* 72 */
  2180. /***/ (function(module, exports, __w_pdfjs_require__) {
  2181. "use strict";
  2182. exports.f = Object.getOwnPropertySymbols;
  2183. /***/ }),
  2184. /* 73 */
  2185. /***/ (function(module, exports, __w_pdfjs_require__) {
  2186. "use strict";
  2187. exports.f = {}.propertyIsEnumerable;
  2188. /***/ }),
  2189. /* 74 */
  2190. /***/ (function(module, exports, __w_pdfjs_require__) {
  2191. "use strict";
  2192. __w_pdfjs_require__(75);
  2193. module.exports = __w_pdfjs_require__(9).Math.log2;
  2194. /***/ }),
  2195. /* 75 */
  2196. /***/ (function(module, exports, __w_pdfjs_require__) {
  2197. "use strict";
  2198. var $export = __w_pdfjs_require__(7);
  2199. $export($export.S, 'Math', {
  2200. log2: function log2(x) {
  2201. return Math.log(x) / Math.LN2;
  2202. }
  2203. });
  2204. /***/ }),
  2205. /* 76 */
  2206. /***/ (function(module, exports, __w_pdfjs_require__) {
  2207. "use strict";
  2208. __w_pdfjs_require__(77);
  2209. module.exports = __w_pdfjs_require__(9).Number.isNaN;
  2210. /***/ }),
  2211. /* 77 */
  2212. /***/ (function(module, exports, __w_pdfjs_require__) {
  2213. "use strict";
  2214. var $export = __w_pdfjs_require__(7);
  2215. $export($export.S, 'Number', {
  2216. isNaN: function isNaN(number) {
  2217. return number != number;
  2218. }
  2219. });
  2220. /***/ }),
  2221. /* 78 */
  2222. /***/ (function(module, exports, __w_pdfjs_require__) {
  2223. "use strict";
  2224. __w_pdfjs_require__(79);
  2225. module.exports = __w_pdfjs_require__(9).Number.isInteger;
  2226. /***/ }),
  2227. /* 79 */
  2228. /***/ (function(module, exports, __w_pdfjs_require__) {
  2229. "use strict";
  2230. var $export = __w_pdfjs_require__(7);
  2231. $export($export.S, 'Number', {
  2232. isInteger: __w_pdfjs_require__(80)
  2233. });
  2234. /***/ }),
  2235. /* 80 */
  2236. /***/ (function(module, exports, __w_pdfjs_require__) {
  2237. "use strict";
  2238. var isObject = __w_pdfjs_require__(13);
  2239. var floor = Math.floor;
  2240. module.exports = function isInteger(it) {
  2241. return !isObject(it) && isFinite(it) && floor(it) === it;
  2242. };
  2243. /***/ }),
  2244. /* 81 */
  2245. /***/ (function(module, exports, __w_pdfjs_require__) {
  2246. "use strict";
  2247. __w_pdfjs_require__(82);
  2248. __w_pdfjs_require__(83);
  2249. __w_pdfjs_require__(86);
  2250. __w_pdfjs_require__(101);
  2251. __w_pdfjs_require__(103);
  2252. module.exports = __w_pdfjs_require__(9).WeakMap;
  2253. /***/ }),
  2254. /* 82 */
  2255. /***/ (function(module, exports, __w_pdfjs_require__) {
  2256. "use strict";
  2257. var classof = __w_pdfjs_require__(67);
  2258. var test = {};
  2259. test[__w_pdfjs_require__(30)('toStringTag')] = 'z';
  2260. if (test + '' != '[object z]') {
  2261. __w_pdfjs_require__(20)(Object.prototype, 'toString', function toString() {
  2262. return '[object ' + classof(this) + ']';
  2263. }, true);
  2264. }
  2265. /***/ }),
  2266. /* 83 */
  2267. /***/ (function(module, exports, __w_pdfjs_require__) {
  2268. "use strict";
  2269. var $iterators = __w_pdfjs_require__(84);
  2270. var getKeys = __w_pdfjs_require__(54);
  2271. var redefine = __w_pdfjs_require__(20);
  2272. var global = __w_pdfjs_require__(8);
  2273. var hide = __w_pdfjs_require__(10);
  2274. var Iterators = __w_pdfjs_require__(50);
  2275. var wks = __w_pdfjs_require__(30);
  2276. var ITERATOR = wks('iterator');
  2277. var TO_STRING_TAG = wks('toStringTag');
  2278. var ArrayValues = Iterators.Array;
  2279. var DOMIterables = {
  2280. CSSRuleList: true,
  2281. CSSStyleDeclaration: false,
  2282. CSSValueList: false,
  2283. ClientRectList: false,
  2284. DOMRectList: false,
  2285. DOMStringList: false,
  2286. DOMTokenList: true,
  2287. DataTransferItemList: false,
  2288. FileList: false,
  2289. HTMLAllCollection: false,
  2290. HTMLCollection: false,
  2291. HTMLFormElement: false,
  2292. HTMLSelectElement: false,
  2293. MediaList: true,
  2294. MimeTypeArray: false,
  2295. NamedNodeMap: false,
  2296. NodeList: true,
  2297. PaintRequestList: false,
  2298. Plugin: false,
  2299. PluginArray: false,
  2300. SVGLengthList: false,
  2301. SVGNumberList: false,
  2302. SVGPathSegList: false,
  2303. SVGPointList: false,
  2304. SVGStringList: false,
  2305. SVGTransformList: false,
  2306. SourceBufferList: false,
  2307. StyleSheetList: true,
  2308. TextTrackCueList: false,
  2309. TextTrackList: false,
  2310. TouchList: false
  2311. };
  2312. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  2313. var NAME = collections[i];
  2314. var explicit = DOMIterables[NAME];
  2315. var Collection = global[NAME];
  2316. var proto = Collection && Collection.prototype;
  2317. var key;
  2318. if (proto) {
  2319. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  2320. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  2321. Iterators[NAME] = ArrayValues;
  2322. if (explicit) for (key in $iterators) {
  2323. if (!proto[key]) redefine(proto, key, $iterators[key], true);
  2324. }
  2325. }
  2326. }
  2327. /***/ }),
  2328. /* 84 */
  2329. /***/ (function(module, exports, __w_pdfjs_require__) {
  2330. "use strict";
  2331. var addToUnscopables = __w_pdfjs_require__(45);
  2332. var step = __w_pdfjs_require__(85);
  2333. var Iterators = __w_pdfjs_require__(50);
  2334. var toIObject = __w_pdfjs_require__(42);
  2335. module.exports = __w_pdfjs_require__(49)(Array, 'Array', function (iterated, kind) {
  2336. this._t = toIObject(iterated);
  2337. this._i = 0;
  2338. this._k = kind;
  2339. }, function () {
  2340. var O = this._t;
  2341. var kind = this._k;
  2342. var index = this._i++;
  2343. if (!O || index >= O.length) {
  2344. this._t = undefined;
  2345. return step(1);
  2346. }
  2347. if (kind == 'keys') return step(0, index);
  2348. if (kind == 'values') return step(0, O[index]);
  2349. return step(0, [index, O[index]]);
  2350. }, 'values');
  2351. Iterators.Arguments = Iterators.Array;
  2352. addToUnscopables('keys');
  2353. addToUnscopables('values');
  2354. addToUnscopables('entries');
  2355. /***/ }),
  2356. /* 85 */
  2357. /***/ (function(module, exports, __w_pdfjs_require__) {
  2358. "use strict";
  2359. module.exports = function (done, value) {
  2360. return {
  2361. value: value,
  2362. done: !!done
  2363. };
  2364. };
  2365. /***/ }),
  2366. /* 86 */
  2367. /***/ (function(module, exports, __w_pdfjs_require__) {
  2368. "use strict";
  2369. var each = __w_pdfjs_require__(87)(0);
  2370. var redefine = __w_pdfjs_require__(20);
  2371. var meta = __w_pdfjs_require__(91);
  2372. var assign = __w_pdfjs_require__(71);
  2373. var weak = __w_pdfjs_require__(92);
  2374. var isObject = __w_pdfjs_require__(13);
  2375. var fails = __w_pdfjs_require__(16);
  2376. var validate = __w_pdfjs_require__(96);
  2377. var WEAK_MAP = 'WeakMap';
  2378. var getWeak = meta.getWeak;
  2379. var isExtensible = Object.isExtensible;
  2380. var uncaughtFrozenStore = weak.ufstore;
  2381. var tmp = {};
  2382. var InternalMap;
  2383. var wrapper = function wrapper(get) {
  2384. return function WeakMap() {
  2385. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  2386. };
  2387. };
  2388. var methods = {
  2389. get: function get(key) {
  2390. if (isObject(key)) {
  2391. var data = getWeak(key);
  2392. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  2393. return data ? data[this._i] : undefined;
  2394. }
  2395. },
  2396. set: function set(key, value) {
  2397. return weak.def(validate(this, WEAK_MAP), key, value);
  2398. }
  2399. };
  2400. var $WeakMap = module.exports = __w_pdfjs_require__(97)(WEAK_MAP, wrapper, methods, weak, true, true);
  2401. if (fails(function () {
  2402. return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7;
  2403. })) {
  2404. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  2405. assign(InternalMap.prototype, methods);
  2406. meta.NEED = true;
  2407. each(['delete', 'has', 'get', 'set'], function (key) {
  2408. var proto = $WeakMap.prototype;
  2409. var method = proto[key];
  2410. redefine(proto, key, function (a, b) {
  2411. if (isObject(a) && !isExtensible(a)) {
  2412. if (!this._f) this._f = new InternalMap();
  2413. var result = this._f[key](a, b);
  2414. return key == 'set' ? this : result;
  2415. }
  2416. return method.call(this, a, b);
  2417. });
  2418. });
  2419. }
  2420. /***/ }),
  2421. /* 87 */
  2422. /***/ (function(module, exports, __w_pdfjs_require__) {
  2423. "use strict";
  2424. var ctx = __w_pdfjs_require__(23);
  2425. var IObject = __w_pdfjs_require__(43);
  2426. var toObject = __w_pdfjs_require__(61);
  2427. var toLength = __w_pdfjs_require__(25);
  2428. var asc = __w_pdfjs_require__(88);
  2429. module.exports = function (TYPE, $create) {
  2430. var IS_MAP = TYPE == 1;
  2431. var IS_FILTER = TYPE == 2;
  2432. var IS_SOME = TYPE == 3;
  2433. var IS_EVERY = TYPE == 4;
  2434. var IS_FIND_INDEX = TYPE == 6;
  2435. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  2436. var create = $create || asc;
  2437. return function ($this, callbackfn, that) {
  2438. var O = toObject($this);
  2439. var self = IObject(O);
  2440. var f = ctx(callbackfn, that, 3);
  2441. var length = toLength(self.length);
  2442. var index = 0;
  2443. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  2444. var val, res;
  2445. for (; length > index; index++) {
  2446. if (NO_HOLES || index in self) {
  2447. val = self[index];
  2448. res = f(val, index, O);
  2449. if (TYPE) {
  2450. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  2451. case 3:
  2452. return true;
  2453. case 5:
  2454. return val;
  2455. case 6:
  2456. return index;
  2457. case 2:
  2458. result.push(val);
  2459. } else if (IS_EVERY) return false;
  2460. }
  2461. }
  2462. }
  2463. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  2464. };
  2465. };
  2466. /***/ }),
  2467. /* 88 */
  2468. /***/ (function(module, exports, __w_pdfjs_require__) {
  2469. "use strict";
  2470. var speciesConstructor = __w_pdfjs_require__(89);
  2471. module.exports = function (original, length) {
  2472. return new (speciesConstructor(original))(length);
  2473. };
  2474. /***/ }),
  2475. /* 89 */
  2476. /***/ (function(module, exports, __w_pdfjs_require__) {
  2477. "use strict";
  2478. var isObject = __w_pdfjs_require__(13);
  2479. var isArray = __w_pdfjs_require__(90);
  2480. var SPECIES = __w_pdfjs_require__(30)('species');
  2481. module.exports = function (original) {
  2482. var C;
  2483. if (isArray(original)) {
  2484. C = original.constructor;
  2485. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  2486. if (isObject(C)) {
  2487. C = C[SPECIES];
  2488. if (C === null) C = undefined;
  2489. }
  2490. }
  2491. return C === undefined ? Array : C;
  2492. };
  2493. /***/ }),
  2494. /* 90 */
  2495. /***/ (function(module, exports, __w_pdfjs_require__) {
  2496. "use strict";
  2497. var cof = __w_pdfjs_require__(29);
  2498. module.exports = Array.isArray || function isArray(arg) {
  2499. return cof(arg) == 'Array';
  2500. };
  2501. /***/ }),
  2502. /* 91 */
  2503. /***/ (function(module, exports, __w_pdfjs_require__) {
  2504. "use strict";
  2505. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2506. var META = __w_pdfjs_require__(22)('meta');
  2507. var isObject = __w_pdfjs_require__(13);
  2508. var has = __w_pdfjs_require__(21);
  2509. var setDesc = __w_pdfjs_require__(11).f;
  2510. var id = 0;
  2511. var isExtensible = Object.isExtensible || function () {
  2512. return true;
  2513. };
  2514. var FREEZE = !__w_pdfjs_require__(16)(function () {
  2515. return isExtensible(Object.preventExtensions({}));
  2516. });
  2517. var setMeta = function setMeta(it) {
  2518. setDesc(it, META, {
  2519. value: {
  2520. i: 'O' + ++id,
  2521. w: {}
  2522. }
  2523. });
  2524. };
  2525. var fastKey = function fastKey(it, create) {
  2526. if (!isObject(it)) return _typeof(it) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  2527. if (!has(it, META)) {
  2528. if (!isExtensible(it)) return 'F';
  2529. if (!create) return 'E';
  2530. setMeta(it);
  2531. }
  2532. return it[META].i;
  2533. };
  2534. var getWeak = function getWeak(it, create) {
  2535. if (!has(it, META)) {
  2536. if (!isExtensible(it)) return true;
  2537. if (!create) return false;
  2538. setMeta(it);
  2539. }
  2540. return it[META].w;
  2541. };
  2542. var onFreeze = function onFreeze(it) {
  2543. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  2544. return it;
  2545. };
  2546. var meta = module.exports = {
  2547. KEY: META,
  2548. NEED: false,
  2549. fastKey: fastKey,
  2550. getWeak: getWeak,
  2551. onFreeze: onFreeze
  2552. };
  2553. /***/ }),
  2554. /* 92 */
  2555. /***/ (function(module, exports, __w_pdfjs_require__) {
  2556. "use strict";
  2557. var redefineAll = __w_pdfjs_require__(93);
  2558. var getWeak = __w_pdfjs_require__(91).getWeak;
  2559. var anObject = __w_pdfjs_require__(12);
  2560. var isObject = __w_pdfjs_require__(13);
  2561. var anInstance = __w_pdfjs_require__(94);
  2562. var forOf = __w_pdfjs_require__(95);
  2563. var createArrayMethod = __w_pdfjs_require__(87);
  2564. var $has = __w_pdfjs_require__(21);
  2565. var validate = __w_pdfjs_require__(96);
  2566. var arrayFind = createArrayMethod(5);
  2567. var arrayFindIndex = createArrayMethod(6);
  2568. var id = 0;
  2569. var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
  2570. return that._l || (that._l = new UncaughtFrozenStore());
  2571. };
  2572. var UncaughtFrozenStore = function UncaughtFrozenStore() {
  2573. this.a = [];
  2574. };
  2575. var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
  2576. return arrayFind(store.a, function (it) {
  2577. return it[0] === key;
  2578. });
  2579. };
  2580. UncaughtFrozenStore.prototype = {
  2581. get: function get(key) {
  2582. var entry = findUncaughtFrozen(this, key);
  2583. if (entry) return entry[1];
  2584. },
  2585. has: function has(key) {
  2586. return !!findUncaughtFrozen(this, key);
  2587. },
  2588. set: function set(key, value) {
  2589. var entry = findUncaughtFrozen(this, key);
  2590. if (entry) entry[1] = value;else this.a.push([key, value]);
  2591. },
  2592. 'delete': function _delete(key) {
  2593. var index = arrayFindIndex(this.a, function (it) {
  2594. return it[0] === key;
  2595. });
  2596. if (~index) this.a.splice(index, 1);
  2597. return !!~index;
  2598. }
  2599. };
  2600. module.exports = {
  2601. getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
  2602. var C = wrapper(function (that, iterable) {
  2603. anInstance(that, C, NAME, '_i');
  2604. that._t = NAME;
  2605. that._i = id++;
  2606. that._l = undefined;
  2607. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  2608. });
  2609. redefineAll(C.prototype, {
  2610. 'delete': function _delete(key) {
  2611. if (!isObject(key)) return false;
  2612. var data = getWeak(key);
  2613. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  2614. return data && $has(data, this._i) && delete data[this._i];
  2615. },
  2616. has: function has(key) {
  2617. if (!isObject(key)) return false;
  2618. var data = getWeak(key);
  2619. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  2620. return data && $has(data, this._i);
  2621. }
  2622. });
  2623. return C;
  2624. },
  2625. def: function def(that, key, value) {
  2626. var data = getWeak(anObject(key), true);
  2627. if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
  2628. return that;
  2629. },
  2630. ufstore: uncaughtFrozenStore
  2631. };
  2632. /***/ }),
  2633. /* 93 */
  2634. /***/ (function(module, exports, __w_pdfjs_require__) {
  2635. "use strict";
  2636. var redefine = __w_pdfjs_require__(20);
  2637. module.exports = function (target, src, safe) {
  2638. for (var key in src) {
  2639. redefine(target, key, src[key], safe);
  2640. }
  2641. return target;
  2642. };
  2643. /***/ }),
  2644. /* 94 */
  2645. /***/ (function(module, exports, __w_pdfjs_require__) {
  2646. "use strict";
  2647. module.exports = function (it, Constructor, name, forbiddenField) {
  2648. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  2649. throw TypeError(name + ': incorrect invocation!');
  2650. }
  2651. return it;
  2652. };
  2653. /***/ }),
  2654. /* 95 */
  2655. /***/ (function(module, exports, __w_pdfjs_require__) {
  2656. "use strict";
  2657. var ctx = __w_pdfjs_require__(23);
  2658. var call = __w_pdfjs_require__(63);
  2659. var isArrayIter = __w_pdfjs_require__(64);
  2660. var anObject = __w_pdfjs_require__(12);
  2661. var toLength = __w_pdfjs_require__(25);
  2662. var getIterFn = __w_pdfjs_require__(66);
  2663. var BREAK = {};
  2664. var RETURN = {};
  2665. var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  2666. var iterFn = ITERATOR ? function () {
  2667. return iterable;
  2668. } : getIterFn(iterable);
  2669. var f = ctx(fn, that, entries ? 2 : 1);
  2670. var index = 0;
  2671. var length, step, iterator, result;
  2672. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  2673. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  2674. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  2675. if (result === BREAK || result === RETURN) return result;
  2676. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  2677. result = call(iterator, f, step.value, entries);
  2678. if (result === BREAK || result === RETURN) return result;
  2679. }
  2680. };
  2681. _exports.BREAK = BREAK;
  2682. _exports.RETURN = RETURN;
  2683. /***/ }),
  2684. /* 96 */
  2685. /***/ (function(module, exports, __w_pdfjs_require__) {
  2686. "use strict";
  2687. var isObject = __w_pdfjs_require__(13);
  2688. module.exports = function (it, TYPE) {
  2689. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  2690. return it;
  2691. };
  2692. /***/ }),
  2693. /* 97 */
  2694. /***/ (function(module, exports, __w_pdfjs_require__) {
  2695. "use strict";
  2696. var global = __w_pdfjs_require__(8);
  2697. var $export = __w_pdfjs_require__(7);
  2698. var redefine = __w_pdfjs_require__(20);
  2699. var redefineAll = __w_pdfjs_require__(93);
  2700. var meta = __w_pdfjs_require__(91);
  2701. var forOf = __w_pdfjs_require__(95);
  2702. var anInstance = __w_pdfjs_require__(94);
  2703. var isObject = __w_pdfjs_require__(13);
  2704. var fails = __w_pdfjs_require__(16);
  2705. var $iterDetect = __w_pdfjs_require__(68);
  2706. var setToStringTag = __w_pdfjs_require__(59);
  2707. var inheritIfRequired = __w_pdfjs_require__(98);
  2708. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  2709. var Base = global[NAME];
  2710. var C = Base;
  2711. var ADDER = IS_MAP ? 'set' : 'add';
  2712. var proto = C && C.prototype;
  2713. var O = {};
  2714. var fixMethod = function fixMethod(KEY) {
  2715. var fn = proto[KEY];
  2716. redefine(proto, KEY, KEY == 'delete' ? function (a) {
  2717. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  2718. } : KEY == 'has' ? function has(a) {
  2719. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  2720. } : KEY == 'get' ? function get(a) {
  2721. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  2722. } : KEY == 'add' ? function add(a) {
  2723. fn.call(this, a === 0 ? 0 : a);
  2724. return this;
  2725. } : function set(a, b) {
  2726. fn.call(this, a === 0 ? 0 : a, b);
  2727. return this;
  2728. });
  2729. };
  2730. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  2731. new C().entries().next();
  2732. }))) {
  2733. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  2734. redefineAll(C.prototype, methods);
  2735. meta.NEED = true;
  2736. } else {
  2737. var instance = new C();
  2738. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  2739. var THROWS_ON_PRIMITIVES = fails(function () {
  2740. instance.has(1);
  2741. });
  2742. var ACCEPT_ITERABLES = $iterDetect(function (iter) {
  2743. new C(iter);
  2744. });
  2745. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  2746. var $instance = new C();
  2747. var index = 5;
  2748. while (index--) {
  2749. $instance[ADDER](index, index);
  2750. }
  2751. return !$instance.has(-0);
  2752. });
  2753. if (!ACCEPT_ITERABLES) {
  2754. C = wrapper(function (target, iterable) {
  2755. anInstance(target, C, NAME);
  2756. var that = inheritIfRequired(new Base(), target, C);
  2757. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  2758. return that;
  2759. });
  2760. C.prototype = proto;
  2761. proto.constructor = C;
  2762. }
  2763. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  2764. fixMethod('delete');
  2765. fixMethod('has');
  2766. IS_MAP && fixMethod('get');
  2767. }
  2768. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  2769. if (IS_WEAK && proto.clear) delete proto.clear;
  2770. }
  2771. setToStringTag(C, NAME);
  2772. O[NAME] = C;
  2773. $export($export.G + $export.W + $export.F * (C != Base), O);
  2774. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  2775. return C;
  2776. };
  2777. /***/ }),
  2778. /* 98 */
  2779. /***/ (function(module, exports, __w_pdfjs_require__) {
  2780. "use strict";
  2781. var isObject = __w_pdfjs_require__(13);
  2782. var setPrototypeOf = __w_pdfjs_require__(99).set;
  2783. module.exports = function (that, target, C) {
  2784. var S = target.constructor;
  2785. var P;
  2786. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  2787. setPrototypeOf(that, P);
  2788. }
  2789. return that;
  2790. };
  2791. /***/ }),
  2792. /* 99 */
  2793. /***/ (function(module, exports, __w_pdfjs_require__) {
  2794. "use strict";
  2795. var isObject = __w_pdfjs_require__(13);
  2796. var anObject = __w_pdfjs_require__(12);
  2797. var check = function check(O, proto) {
  2798. anObject(O);
  2799. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  2800. };
  2801. module.exports = {
  2802. set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) {
  2803. try {
  2804. set = __w_pdfjs_require__(23)(Function.call, __w_pdfjs_require__(100).f(Object.prototype, '__proto__').set, 2);
  2805. set(test, []);
  2806. buggy = !(test instanceof Array);
  2807. } catch (e) {
  2808. buggy = true;
  2809. }
  2810. return function setPrototypeOf(O, proto) {
  2811. check(O, proto);
  2812. if (buggy) O.__proto__ = proto;else set(O, proto);
  2813. return O;
  2814. };
  2815. }({}, false) : undefined),
  2816. check: check
  2817. };
  2818. /***/ }),
  2819. /* 100 */
  2820. /***/ (function(module, exports, __w_pdfjs_require__) {
  2821. "use strict";
  2822. var pIE = __w_pdfjs_require__(73);
  2823. var createDesc = __w_pdfjs_require__(19);
  2824. var toIObject = __w_pdfjs_require__(42);
  2825. var toPrimitive = __w_pdfjs_require__(18);
  2826. var has = __w_pdfjs_require__(21);
  2827. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  2828. var gOPD = Object.getOwnPropertyDescriptor;
  2829. exports.f = __w_pdfjs_require__(15) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  2830. O = toIObject(O);
  2831. P = toPrimitive(P, true);
  2832. if (IE8_DOM_DEFINE) try {
  2833. return gOPD(O, P);
  2834. } catch (e) {}
  2835. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  2836. };
  2837. /***/ }),
  2838. /* 101 */
  2839. /***/ (function(module, exports, __w_pdfjs_require__) {
  2840. "use strict";
  2841. __w_pdfjs_require__(102)('WeakMap');
  2842. /***/ }),
  2843. /* 102 */
  2844. /***/ (function(module, exports, __w_pdfjs_require__) {
  2845. "use strict";
  2846. var $export = __w_pdfjs_require__(7);
  2847. module.exports = function (COLLECTION) {
  2848. $export($export.S, COLLECTION, {
  2849. of: function of() {
  2850. var length = arguments.length;
  2851. var A = new Array(length);
  2852. while (length--) {
  2853. A[length] = arguments[length];
  2854. }
  2855. return new this(A);
  2856. }
  2857. });
  2858. };
  2859. /***/ }),
  2860. /* 103 */
  2861. /***/ (function(module, exports, __w_pdfjs_require__) {
  2862. "use strict";
  2863. __w_pdfjs_require__(104)('WeakMap');
  2864. /***/ }),
  2865. /* 104 */
  2866. /***/ (function(module, exports, __w_pdfjs_require__) {
  2867. "use strict";
  2868. var $export = __w_pdfjs_require__(7);
  2869. var aFunction = __w_pdfjs_require__(24);
  2870. var ctx = __w_pdfjs_require__(23);
  2871. var forOf = __w_pdfjs_require__(95);
  2872. module.exports = function (COLLECTION) {
  2873. $export($export.S, COLLECTION, {
  2874. from: function from(source) {
  2875. var mapFn = arguments[1];
  2876. var mapping, A, n, cb;
  2877. aFunction(this);
  2878. mapping = mapFn !== undefined;
  2879. if (mapping) aFunction(mapFn);
  2880. if (source == undefined) return new this();
  2881. A = [];
  2882. if (mapping) {
  2883. n = 0;
  2884. cb = ctx(mapFn, arguments[2], 2);
  2885. forOf(source, false, function (nextItem) {
  2886. A.push(cb(nextItem, n++));
  2887. });
  2888. } else {
  2889. forOf(source, false, A.push, A);
  2890. }
  2891. return new this(A);
  2892. }
  2893. });
  2894. };
  2895. /***/ }),
  2896. /* 105 */
  2897. /***/ (function(module, exports, __w_pdfjs_require__) {
  2898. "use strict";
  2899. __w_pdfjs_require__(82);
  2900. __w_pdfjs_require__(83);
  2901. __w_pdfjs_require__(106);
  2902. __w_pdfjs_require__(107);
  2903. __w_pdfjs_require__(108);
  2904. module.exports = __w_pdfjs_require__(9).WeakSet;
  2905. /***/ }),
  2906. /* 106 */
  2907. /***/ (function(module, exports, __w_pdfjs_require__) {
  2908. "use strict";
  2909. var weak = __w_pdfjs_require__(92);
  2910. var validate = __w_pdfjs_require__(96);
  2911. var WEAK_SET = 'WeakSet';
  2912. __w_pdfjs_require__(97)(WEAK_SET, function (get) {
  2913. return function WeakSet() {
  2914. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  2915. };
  2916. }, {
  2917. add: function add(value) {
  2918. return weak.def(validate(this, WEAK_SET), value, true);
  2919. }
  2920. }, weak, false, true);
  2921. /***/ }),
  2922. /* 107 */
  2923. /***/ (function(module, exports, __w_pdfjs_require__) {
  2924. "use strict";
  2925. __w_pdfjs_require__(102)('WeakSet');
  2926. /***/ }),
  2927. /* 108 */
  2928. /***/ (function(module, exports, __w_pdfjs_require__) {
  2929. "use strict";
  2930. __w_pdfjs_require__(104)('WeakSet');
  2931. /***/ }),
  2932. /* 109 */
  2933. /***/ (function(module, exports, __w_pdfjs_require__) {
  2934. "use strict";
  2935. __w_pdfjs_require__(110);
  2936. module.exports = __w_pdfjs_require__(9).String.codePointAt;
  2937. /***/ }),
  2938. /* 110 */
  2939. /***/ (function(module, exports, __w_pdfjs_require__) {
  2940. "use strict";
  2941. var $export = __w_pdfjs_require__(7);
  2942. var $at = __w_pdfjs_require__(48)(false);
  2943. $export($export.P, 'String', {
  2944. codePointAt: function codePointAt(pos) {
  2945. return $at(this, pos);
  2946. }
  2947. });
  2948. /***/ }),
  2949. /* 111 */
  2950. /***/ (function(module, exports, __w_pdfjs_require__) {
  2951. "use strict";
  2952. __w_pdfjs_require__(112);
  2953. module.exports = __w_pdfjs_require__(9).String.fromCodePoint;
  2954. /***/ }),
  2955. /* 112 */
  2956. /***/ (function(module, exports, __w_pdfjs_require__) {
  2957. "use strict";
  2958. var $export = __w_pdfjs_require__(7);
  2959. var toAbsoluteIndex = __w_pdfjs_require__(44);
  2960. var fromCharCode = String.fromCharCode;
  2961. var $fromCodePoint = String.fromCodePoint;
  2962. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  2963. fromCodePoint: function fromCodePoint(x) {
  2964. var res = [];
  2965. var aLen = arguments.length;
  2966. var i = 0;
  2967. var code;
  2968. while (aLen > i) {
  2969. code = +arguments[i++];
  2970. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  2971. res.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00));
  2972. }
  2973. return res.join('');
  2974. }
  2975. });
  2976. /***/ }),
  2977. /* 113 */
  2978. /***/ (function(module, exports, __w_pdfjs_require__) {
  2979. "use strict";
  2980. __w_pdfjs_require__(114);
  2981. __w_pdfjs_require__(82);
  2982. module.exports = __w_pdfjs_require__(9).Symbol;
  2983. /***/ }),
  2984. /* 114 */
  2985. /***/ (function(module, exports, __w_pdfjs_require__) {
  2986. "use strict";
  2987. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2988. var global = __w_pdfjs_require__(8);
  2989. var has = __w_pdfjs_require__(21);
  2990. var DESCRIPTORS = __w_pdfjs_require__(15);
  2991. var $export = __w_pdfjs_require__(7);
  2992. var redefine = __w_pdfjs_require__(20);
  2993. var META = __w_pdfjs_require__(91).KEY;
  2994. var $fails = __w_pdfjs_require__(16);
  2995. var shared = __w_pdfjs_require__(31);
  2996. var setToStringTag = __w_pdfjs_require__(59);
  2997. var uid = __w_pdfjs_require__(22);
  2998. var wks = __w_pdfjs_require__(30);
  2999. var wksExt = __w_pdfjs_require__(115);
  3000. var wksDefine = __w_pdfjs_require__(116);
  3001. var enumKeys = __w_pdfjs_require__(117);
  3002. var isArray = __w_pdfjs_require__(90);
  3003. var anObject = __w_pdfjs_require__(12);
  3004. var isObject = __w_pdfjs_require__(13);
  3005. var toIObject = __w_pdfjs_require__(42);
  3006. var toPrimitive = __w_pdfjs_require__(18);
  3007. var createDesc = __w_pdfjs_require__(19);
  3008. var _create = __w_pdfjs_require__(52);
  3009. var gOPNExt = __w_pdfjs_require__(118);
  3010. var $GOPD = __w_pdfjs_require__(100);
  3011. var $DP = __w_pdfjs_require__(11);
  3012. var $keys = __w_pdfjs_require__(54);
  3013. var gOPD = $GOPD.f;
  3014. var dP = $DP.f;
  3015. var gOPN = gOPNExt.f;
  3016. var $Symbol = global.Symbol;
  3017. var $JSON = global.JSON;
  3018. var _stringify = $JSON && $JSON.stringify;
  3019. var PROTOTYPE = 'prototype';
  3020. var HIDDEN = wks('_hidden');
  3021. var TO_PRIMITIVE = wks('toPrimitive');
  3022. var isEnum = {}.propertyIsEnumerable;
  3023. var SymbolRegistry = shared('symbol-registry');
  3024. var AllSymbols = shared('symbols');
  3025. var OPSymbols = shared('op-symbols');
  3026. var ObjectProto = Object[PROTOTYPE];
  3027. var USE_NATIVE = typeof $Symbol == 'function';
  3028. var QObject = global.QObject;
  3029. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  3030. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  3031. return _create(dP({}, 'a', {
  3032. get: function get() {
  3033. return dP(this, 'a', {
  3034. value: 7
  3035. }).a;
  3036. }
  3037. })).a != 7;
  3038. }) ? function (it, key, D) {
  3039. var protoDesc = gOPD(ObjectProto, key);
  3040. if (protoDesc) delete ObjectProto[key];
  3041. dP(it, key, D);
  3042. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  3043. } : dP;
  3044. var wrap = function wrap(tag) {
  3045. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  3046. sym._k = tag;
  3047. return sym;
  3048. };
  3049. var isSymbol = USE_NATIVE && _typeof($Symbol.iterator) == 'symbol' ? function (it) {
  3050. return _typeof(it) == 'symbol';
  3051. } : function (it) {
  3052. return it instanceof $Symbol;
  3053. };
  3054. var $defineProperty = function defineProperty(it, key, D) {
  3055. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  3056. anObject(it);
  3057. key = toPrimitive(key, true);
  3058. anObject(D);
  3059. if (has(AllSymbols, key)) {
  3060. if (!D.enumerable) {
  3061. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  3062. it[HIDDEN][key] = true;
  3063. } else {
  3064. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  3065. D = _create(D, {
  3066. enumerable: createDesc(0, false)
  3067. });
  3068. }
  3069. return setSymbolDesc(it, key, D);
  3070. }
  3071. return dP(it, key, D);
  3072. };
  3073. var $defineProperties = function defineProperties(it, P) {
  3074. anObject(it);
  3075. var keys = enumKeys(P = toIObject(P));
  3076. var i = 0;
  3077. var l = keys.length;
  3078. var key;
  3079. while (l > i) {
  3080. $defineProperty(it, key = keys[i++], P[key]);
  3081. }
  3082. return it;
  3083. };
  3084. var $create = function create(it, P) {
  3085. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  3086. };
  3087. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  3088. var E = isEnum.call(this, key = toPrimitive(key, true));
  3089. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  3090. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  3091. };
  3092. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  3093. it = toIObject(it);
  3094. key = toPrimitive(key, true);
  3095. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  3096. var D = gOPD(it, key);
  3097. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  3098. return D;
  3099. };
  3100. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  3101. var names = gOPN(toIObject(it));
  3102. var result = [];
  3103. var i = 0;
  3104. var key;
  3105. while (names.length > i) {
  3106. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  3107. }
  3108. return result;
  3109. };
  3110. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  3111. var IS_OP = it === ObjectProto;
  3112. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  3113. var result = [];
  3114. var i = 0;
  3115. var key;
  3116. while (names.length > i) {
  3117. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  3118. }
  3119. return result;
  3120. };
  3121. if (!USE_NATIVE) {
  3122. $Symbol = function _Symbol() {
  3123. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  3124. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  3125. var $set = function $set(value) {
  3126. if (this === ObjectProto) $set.call(OPSymbols, value);
  3127. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  3128. setSymbolDesc(this, tag, createDesc(1, value));
  3129. };
  3130. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, {
  3131. configurable: true,
  3132. set: $set
  3133. });
  3134. return wrap(tag);
  3135. };
  3136. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  3137. return this._k;
  3138. });
  3139. $GOPD.f = $getOwnPropertyDescriptor;
  3140. $DP.f = $defineProperty;
  3141. __w_pdfjs_require__(119).f = gOPNExt.f = $getOwnPropertyNames;
  3142. __w_pdfjs_require__(73).f = $propertyIsEnumerable;
  3143. __w_pdfjs_require__(72).f = $getOwnPropertySymbols;
  3144. if (DESCRIPTORS && !__w_pdfjs_require__(32)) {
  3145. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  3146. }
  3147. wksExt.f = function (name) {
  3148. return wrap(wks(name));
  3149. };
  3150. }
  3151. $export($export.G + $export.W + $export.F * !USE_NATIVE, {
  3152. Symbol: $Symbol
  3153. });
  3154. for (var es6Symbols = 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) {
  3155. wks(es6Symbols[j++]);
  3156. }
  3157. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) {
  3158. wksDefine(wellKnownSymbols[k++]);
  3159. }
  3160. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  3161. 'for': function _for(key) {
  3162. return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key);
  3163. },
  3164. keyFor: function keyFor(sym) {
  3165. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  3166. for (var key in SymbolRegistry) {
  3167. if (SymbolRegistry[key] === sym) return key;
  3168. }
  3169. },
  3170. useSetter: function useSetter() {
  3171. setter = true;
  3172. },
  3173. useSimple: function useSimple() {
  3174. setter = false;
  3175. }
  3176. });
  3177. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  3178. create: $create,
  3179. defineProperty: $defineProperty,
  3180. defineProperties: $defineProperties,
  3181. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  3182. getOwnPropertyNames: $getOwnPropertyNames,
  3183. getOwnPropertySymbols: $getOwnPropertySymbols
  3184. });
  3185. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  3186. var S = $Symbol();
  3187. return _stringify([S]) != '[null]' || _stringify({
  3188. a: S
  3189. }) != '{}' || _stringify(Object(S)) != '{}';
  3190. })), 'JSON', {
  3191. stringify: function stringify(it) {
  3192. var args = [it];
  3193. var i = 1;
  3194. var replacer, $replacer;
  3195. while (arguments.length > i) {
  3196. args.push(arguments[i++]);
  3197. }
  3198. $replacer = replacer = args[1];
  3199. if (!isObject(replacer) && it === undefined || isSymbol(it)) return;
  3200. if (!isArray(replacer)) replacer = function replacer(key, value) {
  3201. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  3202. if (!isSymbol(value)) return value;
  3203. };
  3204. args[1] = replacer;
  3205. return _stringify.apply($JSON, args);
  3206. }
  3207. });
  3208. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __w_pdfjs_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  3209. setToStringTag($Symbol, 'Symbol');
  3210. setToStringTag(Math, 'Math', true);
  3211. setToStringTag(global.JSON, 'JSON', true);
  3212. /***/ }),
  3213. /* 115 */
  3214. /***/ (function(module, exports, __w_pdfjs_require__) {
  3215. "use strict";
  3216. exports.f = __w_pdfjs_require__(30);
  3217. /***/ }),
  3218. /* 116 */
  3219. /***/ (function(module, exports, __w_pdfjs_require__) {
  3220. "use strict";
  3221. var global = __w_pdfjs_require__(8);
  3222. var core = __w_pdfjs_require__(9);
  3223. var LIBRARY = __w_pdfjs_require__(32);
  3224. var wksExt = __w_pdfjs_require__(115);
  3225. var defineProperty = __w_pdfjs_require__(11).f;
  3226. module.exports = function (name) {
  3227. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  3228. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, {
  3229. value: wksExt.f(name)
  3230. });
  3231. };
  3232. /***/ }),
  3233. /* 117 */
  3234. /***/ (function(module, exports, __w_pdfjs_require__) {
  3235. "use strict";
  3236. var getKeys = __w_pdfjs_require__(54);
  3237. var gOPS = __w_pdfjs_require__(72);
  3238. var pIE = __w_pdfjs_require__(73);
  3239. module.exports = function (it) {
  3240. var result = getKeys(it);
  3241. var getSymbols = gOPS.f;
  3242. if (getSymbols) {
  3243. var symbols = getSymbols(it);
  3244. var isEnum = pIE.f;
  3245. var i = 0;
  3246. var key;
  3247. while (symbols.length > i) {
  3248. if (isEnum.call(it, key = symbols[i++])) result.push(key);
  3249. }
  3250. }
  3251. return result;
  3252. };
  3253. /***/ }),
  3254. /* 118 */
  3255. /***/ (function(module, exports, __w_pdfjs_require__) {
  3256. "use strict";
  3257. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3258. var toIObject = __w_pdfjs_require__(42);
  3259. var gOPN = __w_pdfjs_require__(119).f;
  3260. var toString = {}.toString;
  3261. var windowNames = (typeof window === "undefined" ? "undefined" : _typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  3262. var getWindowNames = function getWindowNames(it) {
  3263. try {
  3264. return gOPN(it);
  3265. } catch (e) {
  3266. return windowNames.slice();
  3267. }
  3268. };
  3269. module.exports.f = function getOwnPropertyNames(it) {
  3270. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  3271. };
  3272. /***/ }),
  3273. /* 119 */
  3274. /***/ (function(module, exports, __w_pdfjs_require__) {
  3275. "use strict";
  3276. var $keys = __w_pdfjs_require__(55);
  3277. var hiddenKeys = __w_pdfjs_require__(57).concat('length', 'prototype');
  3278. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  3279. return $keys(O, hiddenKeys);
  3280. };
  3281. /***/ }),
  3282. /* 120 */
  3283. /***/ (function(module, exports, __w_pdfjs_require__) {
  3284. "use strict";
  3285. __w_pdfjs_require__(121);
  3286. module.exports = __w_pdfjs_require__(9).String.padStart;
  3287. /***/ }),
  3288. /* 121 */
  3289. /***/ (function(module, exports, __w_pdfjs_require__) {
  3290. "use strict";
  3291. var $export = __w_pdfjs_require__(7);
  3292. var $pad = __w_pdfjs_require__(122);
  3293. var userAgent = __w_pdfjs_require__(124);
  3294. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  3295. padStart: function padStart(maxLength) {
  3296. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  3297. }
  3298. });
  3299. /***/ }),
  3300. /* 122 */
  3301. /***/ (function(module, exports, __w_pdfjs_require__) {
  3302. "use strict";
  3303. var toLength = __w_pdfjs_require__(25);
  3304. var repeat = __w_pdfjs_require__(123);
  3305. var defined = __w_pdfjs_require__(33);
  3306. module.exports = function (that, maxLength, fillString, left) {
  3307. var S = String(defined(that));
  3308. var stringLength = S.length;
  3309. var fillStr = fillString === undefined ? ' ' : String(fillString);
  3310. var intMaxLength = toLength(maxLength);
  3311. if (intMaxLength <= stringLength || fillStr == '') return S;
  3312. var fillLen = intMaxLength - stringLength;
  3313. var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  3314. if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
  3315. return left ? stringFiller + S : S + stringFiller;
  3316. };
  3317. /***/ }),
  3318. /* 123 */
  3319. /***/ (function(module, exports, __w_pdfjs_require__) {
  3320. "use strict";
  3321. var toInteger = __w_pdfjs_require__(26);
  3322. var defined = __w_pdfjs_require__(33);
  3323. module.exports = function repeat(count) {
  3324. var str = String(defined(this));
  3325. var res = '';
  3326. var n = toInteger(count);
  3327. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  3328. for (; n > 0; (n >>>= 1) && (str += str)) {
  3329. if (n & 1) res += str;
  3330. }
  3331. return res;
  3332. };
  3333. /***/ }),
  3334. /* 124 */
  3335. /***/ (function(module, exports, __w_pdfjs_require__) {
  3336. "use strict";
  3337. var global = __w_pdfjs_require__(8);
  3338. var navigator = global.navigator;
  3339. module.exports = navigator && navigator.userAgent || '';
  3340. /***/ }),
  3341. /* 125 */
  3342. /***/ (function(module, exports, __w_pdfjs_require__) {
  3343. "use strict";
  3344. __w_pdfjs_require__(126);
  3345. module.exports = __w_pdfjs_require__(9).String.padEnd;
  3346. /***/ }),
  3347. /* 126 */
  3348. /***/ (function(module, exports, __w_pdfjs_require__) {
  3349. "use strict";
  3350. var $export = __w_pdfjs_require__(7);
  3351. var $pad = __w_pdfjs_require__(122);
  3352. var userAgent = __w_pdfjs_require__(124);
  3353. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  3354. padEnd: function padEnd(maxLength) {
  3355. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  3356. }
  3357. });
  3358. /***/ }),
  3359. /* 127 */
  3360. /***/ (function(module, exports, __w_pdfjs_require__) {
  3361. "use strict";
  3362. __w_pdfjs_require__(128);
  3363. module.exports = __w_pdfjs_require__(9).Object.values;
  3364. /***/ }),
  3365. /* 128 */
  3366. /***/ (function(module, exports, __w_pdfjs_require__) {
  3367. "use strict";
  3368. var $export = __w_pdfjs_require__(7);
  3369. var $values = __w_pdfjs_require__(129)(false);
  3370. $export($export.S, 'Object', {
  3371. values: function values(it) {
  3372. return $values(it);
  3373. }
  3374. });
  3375. /***/ }),
  3376. /* 129 */
  3377. /***/ (function(module, exports, __w_pdfjs_require__) {
  3378. "use strict";
  3379. var getKeys = __w_pdfjs_require__(54);
  3380. var toIObject = __w_pdfjs_require__(42);
  3381. var isEnum = __w_pdfjs_require__(73).f;
  3382. module.exports = function (isEntries) {
  3383. return function (it) {
  3384. var O = toIObject(it);
  3385. var keys = getKeys(O);
  3386. var length = keys.length;
  3387. var i = 0;
  3388. var result = [];
  3389. var key;
  3390. while (length > i) {
  3391. if (isEnum.call(O, key = keys[i++])) {
  3392. result.push(isEntries ? [key, O[key]] : O[key]);
  3393. }
  3394. }
  3395. return result;
  3396. };
  3397. };
  3398. /***/ }),
  3399. /* 130 */
  3400. /***/ (function(module, exports, __w_pdfjs_require__) {
  3401. "use strict";
  3402. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3403. {
  3404. var isReadableStreamSupported = false;
  3405. if (typeof ReadableStream !== 'undefined') {
  3406. try {
  3407. new ReadableStream({
  3408. start: function start(controller) {
  3409. controller.close();
  3410. }
  3411. });
  3412. isReadableStreamSupported = true;
  3413. } catch (e) {}
  3414. }
  3415. if (isReadableStreamSupported) {
  3416. exports.ReadableStream = ReadableStream;
  3417. } else {
  3418. var DummyReadableStream = function DummyReadableStream() {
  3419. _classCallCheck(this, DummyReadableStream);
  3420. throw new Error('The current image decoders are synchronous, ' + 'hence `ReadableStream` shouldn\'t need to be ' + 'polyfilled for the IMAGE_DECODERS build target.');
  3421. };
  3422. exports.ReadableStream = DummyReadableStream;
  3423. }
  3424. }
  3425. /***/ }),
  3426. /* 131 */
  3427. /***/ (function(module, exports, __w_pdfjs_require__) {
  3428. "use strict";
  3429. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3430. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3431. {
  3432. var isURLSupported = false;
  3433. try {
  3434. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  3435. var u = new URL('b', 'http://a');
  3436. u.pathname = 'c%20d';
  3437. isURLSupported = u.href === 'http://a/c%20d';
  3438. }
  3439. } catch (ex) {}
  3440. if (isURLSupported) {
  3441. exports.URL = URL;
  3442. } else {
  3443. var DummyURL = function DummyURL() {
  3444. _classCallCheck(this, DummyURL);
  3445. throw new Error('The current image decoders doesn\'t utilize the ' + '`URL` constructor, hence it shouldn\'t need to be ' + 'polyfilled for the IMAGE_DECODERS build target.');
  3446. };
  3447. exports.URL = DummyURL;
  3448. }
  3449. }
  3450. /***/ }),
  3451. /* 132 */
  3452. /***/ (function(module, exports, __w_pdfjs_require__) {
  3453. "use strict";
  3454. Object.defineProperty(exports, "__esModule", {
  3455. value: true
  3456. });
  3457. exports.Jbig2Image = void 0;
  3458. var _util = __w_pdfjs_require__(1);
  3459. var _arithmetic_decoder = __w_pdfjs_require__(133);
  3460. var _ccitt = __w_pdfjs_require__(134);
  3461. var Jbig2Error = function Jbig2ErrorClosure() {
  3462. function Jbig2Error(msg) {
  3463. this.message = 'JBIG2 error: ' + msg;
  3464. }
  3465. Jbig2Error.prototype = new Error();
  3466. Jbig2Error.prototype.name = 'Jbig2Error';
  3467. Jbig2Error.constructor = Jbig2Error;
  3468. return Jbig2Error;
  3469. }();
  3470. var Jbig2Image = function Jbig2ImageClosure() {
  3471. function ContextCache() {}
  3472. ContextCache.prototype = {
  3473. getContexts: function getContexts(id) {
  3474. if (id in this) {
  3475. return this[id];
  3476. }
  3477. return this[id] = new Int8Array(1 << 16);
  3478. }
  3479. };
  3480. function DecodingContext(data, start, end) {
  3481. this.data = data;
  3482. this.start = start;
  3483. this.end = end;
  3484. }
  3485. DecodingContext.prototype = {
  3486. get decoder() {
  3487. var decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
  3488. return (0, _util.shadow)(this, 'decoder', decoder);
  3489. },
  3490. get contextCache() {
  3491. var cache = new ContextCache();
  3492. return (0, _util.shadow)(this, 'contextCache', cache);
  3493. }
  3494. };
  3495. function decodeInteger(contextCache, procedure, decoder) {
  3496. var contexts = contextCache.getContexts(procedure);
  3497. var prev = 1;
  3498. function readBits(length) {
  3499. var v = 0;
  3500. for (var i = 0; i < length; i++) {
  3501. var bit = decoder.readBit(contexts, prev);
  3502. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  3503. v = v << 1 | bit;
  3504. }
  3505. return v >>> 0;
  3506. }
  3507. var sign = readBits(1);
  3508. 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);
  3509. return sign === 0 ? value : value > 0 ? -value : null;
  3510. }
  3511. function decodeIAID(contextCache, decoder, codeLength) {
  3512. var contexts = contextCache.getContexts('IAID');
  3513. var prev = 1;
  3514. for (var i = 0; i < codeLength; i++) {
  3515. var bit = decoder.readBit(contexts, prev);
  3516. prev = prev << 1 | bit;
  3517. }
  3518. if (codeLength < 31) {
  3519. return prev & (1 << codeLength) - 1;
  3520. }
  3521. return prev & 0x7FFFFFFF;
  3522. }
  3523. var SegmentTypes = ['SymbolDictionary', null, null, null, 'IntermediateTextRegion', null, 'ImmediateTextRegion', 'ImmediateLosslessTextRegion', null, null, null, null, null, null, null, null, 'PatternDictionary', null, null, null, 'IntermediateHalftoneRegion', null, 'ImmediateHalftoneRegion', 'ImmediateLosslessHalftoneRegion', null, null, null, null, null, null, null, null, null, null, null, null, 'IntermediateGenericRegion', null, 'ImmediateGenericRegion', 'ImmediateLosslessGenericRegion', 'IntermediateGenericRefinementRegion', null, 'ImmediateGenericRefinementRegion', 'ImmediateLosslessGenericRefinementRegion', null, null, null, null, 'PageInformation', 'EndOfPage', 'EndOfStripe', 'EndOfFile', 'Profiles', 'Tables', null, null, null, null, null, null, null, null, 'Extension'];
  3524. var CodingTemplates = [[{
  3525. x: -1,
  3526. y: -2
  3527. }, {
  3528. x: 0,
  3529. y: -2
  3530. }, {
  3531. x: 1,
  3532. y: -2
  3533. }, {
  3534. x: -2,
  3535. y: -1
  3536. }, {
  3537. x: -1,
  3538. y: -1
  3539. }, {
  3540. x: 0,
  3541. y: -1
  3542. }, {
  3543. x: 1,
  3544. y: -1
  3545. }, {
  3546. x: 2,
  3547. y: -1
  3548. }, {
  3549. x: -4,
  3550. y: 0
  3551. }, {
  3552. x: -3,
  3553. y: 0
  3554. }, {
  3555. x: -2,
  3556. y: 0
  3557. }, {
  3558. x: -1,
  3559. y: 0
  3560. }], [{
  3561. x: -1,
  3562. y: -2
  3563. }, {
  3564. x: 0,
  3565. y: -2
  3566. }, {
  3567. x: 1,
  3568. y: -2
  3569. }, {
  3570. x: 2,
  3571. y: -2
  3572. }, {
  3573. x: -2,
  3574. y: -1
  3575. }, {
  3576. x: -1,
  3577. y: -1
  3578. }, {
  3579. x: 0,
  3580. y: -1
  3581. }, {
  3582. x: 1,
  3583. y: -1
  3584. }, {
  3585. x: 2,
  3586. y: -1
  3587. }, {
  3588. x: -3,
  3589. y: 0
  3590. }, {
  3591. x: -2,
  3592. y: 0
  3593. }, {
  3594. x: -1,
  3595. y: 0
  3596. }], [{
  3597. x: -1,
  3598. y: -2
  3599. }, {
  3600. x: 0,
  3601. y: -2
  3602. }, {
  3603. x: 1,
  3604. y: -2
  3605. }, {
  3606. x: -2,
  3607. y: -1
  3608. }, {
  3609. x: -1,
  3610. y: -1
  3611. }, {
  3612. x: 0,
  3613. y: -1
  3614. }, {
  3615. x: 1,
  3616. y: -1
  3617. }, {
  3618. x: -2,
  3619. y: 0
  3620. }, {
  3621. x: -1,
  3622. y: 0
  3623. }], [{
  3624. x: -3,
  3625. y: -1
  3626. }, {
  3627. x: -2,
  3628. y: -1
  3629. }, {
  3630. x: -1,
  3631. y: -1
  3632. }, {
  3633. x: 0,
  3634. y: -1
  3635. }, {
  3636. x: 1,
  3637. y: -1
  3638. }, {
  3639. x: -4,
  3640. y: 0
  3641. }, {
  3642. x: -3,
  3643. y: 0
  3644. }, {
  3645. x: -2,
  3646. y: 0
  3647. }, {
  3648. x: -1,
  3649. y: 0
  3650. }]];
  3651. var RefinementTemplates = [{
  3652. coding: [{
  3653. x: 0,
  3654. y: -1
  3655. }, {
  3656. x: 1,
  3657. y: -1
  3658. }, {
  3659. x: -1,
  3660. y: 0
  3661. }],
  3662. reference: [{
  3663. x: 0,
  3664. y: -1
  3665. }, {
  3666. x: 1,
  3667. y: -1
  3668. }, {
  3669. x: -1,
  3670. y: 0
  3671. }, {
  3672. x: 0,
  3673. y: 0
  3674. }, {
  3675. x: 1,
  3676. y: 0
  3677. }, {
  3678. x: -1,
  3679. y: 1
  3680. }, {
  3681. x: 0,
  3682. y: 1
  3683. }, {
  3684. x: 1,
  3685. y: 1
  3686. }]
  3687. }, {
  3688. coding: [{
  3689. x: -1,
  3690. y: -1
  3691. }, {
  3692. x: 0,
  3693. y: -1
  3694. }, {
  3695. x: 1,
  3696. y: -1
  3697. }, {
  3698. x: -1,
  3699. y: 0
  3700. }],
  3701. reference: [{
  3702. x: 0,
  3703. y: -1
  3704. }, {
  3705. x: -1,
  3706. y: 0
  3707. }, {
  3708. x: 0,
  3709. y: 0
  3710. }, {
  3711. x: 1,
  3712. y: 0
  3713. }, {
  3714. x: 0,
  3715. y: 1
  3716. }, {
  3717. x: 1,
  3718. y: 1
  3719. }]
  3720. }];
  3721. var ReusedContexts = [0x9B25, 0x0795, 0x00E5, 0x0195];
  3722. var RefinementReusedContexts = [0x0020, 0x0008];
  3723. function decodeBitmapTemplate0(width, height, decodingContext) {
  3724. var decoder = decodingContext.decoder;
  3725. var contexts = decodingContext.contextCache.getContexts('GB');
  3726. var contextLabel,
  3727. i,
  3728. j,
  3729. pixel,
  3730. row,
  3731. row1,
  3732. row2,
  3733. bitmap = [];
  3734. var OLD_PIXEL_MASK = 0x7BF7;
  3735. for (i = 0; i < height; i++) {
  3736. row = bitmap[i] = new Uint8Array(width);
  3737. row1 = i < 1 ? row : bitmap[i - 1];
  3738. row2 = i < 2 ? row : bitmap[i - 2];
  3739. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  3740. for (j = 0; j < width; j++) {
  3741. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  3742. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  3743. }
  3744. }
  3745. return bitmap;
  3746. }
  3747. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  3748. if (mmr) {
  3749. var input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  3750. return decodeMMRBitmap(input, width, height, false);
  3751. }
  3752. 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) {
  3753. return decodeBitmapTemplate0(width, height, decodingContext);
  3754. }
  3755. var useskip = !!skip;
  3756. var template = CodingTemplates[templateIndex].concat(at);
  3757. template.sort(function (a, b) {
  3758. return a.y - b.y || a.x - b.x;
  3759. });
  3760. var templateLength = template.length;
  3761. var templateX = new Int8Array(templateLength);
  3762. var templateY = new Int8Array(templateLength);
  3763. var changingTemplateEntries = [];
  3764. var reuseMask = 0,
  3765. minX = 0,
  3766. maxX = 0,
  3767. minY = 0;
  3768. var c, k;
  3769. for (k = 0; k < templateLength; k++) {
  3770. templateX[k] = template[k].x;
  3771. templateY[k] = template[k].y;
  3772. minX = Math.min(minX, template[k].x);
  3773. maxX = Math.max(maxX, template[k].x);
  3774. minY = Math.min(minY, template[k].y);
  3775. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  3776. reuseMask |= 1 << templateLength - 1 - k;
  3777. } else {
  3778. changingTemplateEntries.push(k);
  3779. }
  3780. }
  3781. var changingEntriesLength = changingTemplateEntries.length;
  3782. var changingTemplateX = new Int8Array(changingEntriesLength);
  3783. var changingTemplateY = new Int8Array(changingEntriesLength);
  3784. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  3785. for (c = 0; c < changingEntriesLength; c++) {
  3786. k = changingTemplateEntries[c];
  3787. changingTemplateX[c] = template[k].x;
  3788. changingTemplateY[c] = template[k].y;
  3789. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  3790. }
  3791. var sbb_left = -minX;
  3792. var sbb_top = -minY;
  3793. var sbb_right = width - maxX;
  3794. var pseudoPixelContext = ReusedContexts[templateIndex];
  3795. var row = new Uint8Array(width);
  3796. var bitmap = [];
  3797. var decoder = decodingContext.decoder;
  3798. var contexts = decodingContext.contextCache.getContexts('GB');
  3799. var ltp = 0,
  3800. j,
  3801. i0,
  3802. j0,
  3803. contextLabel = 0,
  3804. bit,
  3805. shift;
  3806. for (var i = 0; i < height; i++) {
  3807. if (prediction) {
  3808. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  3809. ltp ^= sltp;
  3810. if (ltp) {
  3811. bitmap.push(row);
  3812. continue;
  3813. }
  3814. }
  3815. row = new Uint8Array(row);
  3816. bitmap.push(row);
  3817. for (j = 0; j < width; j++) {
  3818. if (useskip && skip[i][j]) {
  3819. row[j] = 0;
  3820. continue;
  3821. }
  3822. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  3823. contextLabel = contextLabel << 1 & reuseMask;
  3824. for (k = 0; k < changingEntriesLength; k++) {
  3825. i0 = i + changingTemplateY[k];
  3826. j0 = j + changingTemplateX[k];
  3827. bit = bitmap[i0][j0];
  3828. if (bit) {
  3829. bit = changingTemplateBit[k];
  3830. contextLabel |= bit;
  3831. }
  3832. }
  3833. } else {
  3834. contextLabel = 0;
  3835. shift = templateLength - 1;
  3836. for (k = 0; k < templateLength; k++, shift--) {
  3837. j0 = j + templateX[k];
  3838. if (j0 >= 0 && j0 < width) {
  3839. i0 = i + templateY[k];
  3840. if (i0 >= 0) {
  3841. bit = bitmap[i0][j0];
  3842. if (bit) {
  3843. contextLabel |= bit << shift;
  3844. }
  3845. }
  3846. }
  3847. }
  3848. }
  3849. var pixel = decoder.readBit(contexts, contextLabel);
  3850. row[j] = pixel;
  3851. }
  3852. }
  3853. return bitmap;
  3854. }
  3855. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  3856. var codingTemplate = RefinementTemplates[templateIndex].coding;
  3857. if (templateIndex === 0) {
  3858. codingTemplate = codingTemplate.concat([at[0]]);
  3859. }
  3860. var codingTemplateLength = codingTemplate.length;
  3861. var codingTemplateX = new Int32Array(codingTemplateLength);
  3862. var codingTemplateY = new Int32Array(codingTemplateLength);
  3863. var k;
  3864. for (k = 0; k < codingTemplateLength; k++) {
  3865. codingTemplateX[k] = codingTemplate[k].x;
  3866. codingTemplateY[k] = codingTemplate[k].y;
  3867. }
  3868. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  3869. if (templateIndex === 0) {
  3870. referenceTemplate = referenceTemplate.concat([at[1]]);
  3871. }
  3872. var referenceTemplateLength = referenceTemplate.length;
  3873. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  3874. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  3875. for (k = 0; k < referenceTemplateLength; k++) {
  3876. referenceTemplateX[k] = referenceTemplate[k].x;
  3877. referenceTemplateY[k] = referenceTemplate[k].y;
  3878. }
  3879. var referenceWidth = referenceBitmap[0].length;
  3880. var referenceHeight = referenceBitmap.length;
  3881. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  3882. var bitmap = [];
  3883. var decoder = decodingContext.decoder;
  3884. var contexts = decodingContext.contextCache.getContexts('GR');
  3885. var ltp = 0;
  3886. for (var i = 0; i < height; i++) {
  3887. if (prediction) {
  3888. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  3889. ltp ^= sltp;
  3890. if (ltp) {
  3891. throw new Jbig2Error('prediction is not supported');
  3892. }
  3893. }
  3894. var row = new Uint8Array(width);
  3895. bitmap.push(row);
  3896. for (var j = 0; j < width; j++) {
  3897. var i0, j0;
  3898. var contextLabel = 0;
  3899. for (k = 0; k < codingTemplateLength; k++) {
  3900. i0 = i + codingTemplateY[k];
  3901. j0 = j + codingTemplateX[k];
  3902. if (i0 < 0 || j0 < 0 || j0 >= width) {
  3903. contextLabel <<= 1;
  3904. } else {
  3905. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  3906. }
  3907. }
  3908. for (k = 0; k < referenceTemplateLength; k++) {
  3909. i0 = i + referenceTemplateY[k] - offsetY;
  3910. j0 = j + referenceTemplateX[k] - offsetX;
  3911. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  3912. contextLabel <<= 1;
  3913. } else {
  3914. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  3915. }
  3916. }
  3917. var pixel = decoder.readBit(contexts, contextLabel);
  3918. row[j] = pixel;
  3919. }
  3920. }
  3921. return bitmap;
  3922. }
  3923. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext, huffmanInput) {
  3924. if (huffman && refinement) {
  3925. throw new Jbig2Error('symbol refinement with Huffman is not supported');
  3926. }
  3927. var newSymbols = [];
  3928. var currentHeight = 0;
  3929. var symbolCodeLength = (0, _util.log2)(symbols.length + numberOfNewSymbols);
  3930. var decoder = decodingContext.decoder;
  3931. var contextCache = decodingContext.contextCache;
  3932. var tableB1, symbolWidths;
  3933. if (huffman) {
  3934. tableB1 = getStandardTable(1);
  3935. symbolWidths = [];
  3936. symbolCodeLength = Math.max(symbolCodeLength, 1);
  3937. }
  3938. while (newSymbols.length < numberOfNewSymbols) {
  3939. var deltaHeight = huffman ? huffmanTables.tableDeltaHeight.decode(huffmanInput) : decodeInteger(contextCache, 'IADH', decoder);
  3940. currentHeight += deltaHeight;
  3941. var currentWidth = 0,
  3942. totalWidth = 0;
  3943. var firstSymbol = huffman ? symbolWidths.length : 0;
  3944. while (true) {
  3945. var deltaWidth = huffman ? huffmanTables.tableDeltaWidth.decode(huffmanInput) : decodeInteger(contextCache, 'IADW', decoder);
  3946. if (deltaWidth === null) {
  3947. break;
  3948. }
  3949. currentWidth += deltaWidth;
  3950. totalWidth += currentWidth;
  3951. var bitmap;
  3952. if (refinement) {
  3953. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  3954. if (numberOfInstances > 1) {
  3955. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, 0, huffmanInput);
  3956. } else {
  3957. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  3958. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  3959. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  3960. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  3961. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  3962. }
  3963. newSymbols.push(bitmap);
  3964. } else if (huffman) {
  3965. symbolWidths.push(currentWidth);
  3966. } else {
  3967. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  3968. newSymbols.push(bitmap);
  3969. }
  3970. }
  3971. if (huffman && !refinement) {
  3972. var bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
  3973. huffmanInput.byteAlign();
  3974. var collectiveBitmap = void 0;
  3975. if (bitmapSize === 0) {
  3976. collectiveBitmap = readUncompressedBitmap(huffmanInput, totalWidth, currentHeight);
  3977. } else {
  3978. var originalEnd = huffmanInput.end;
  3979. var bitmapEnd = huffmanInput.position + bitmapSize;
  3980. huffmanInput.end = bitmapEnd;
  3981. collectiveBitmap = decodeMMRBitmap(huffmanInput, totalWidth, currentHeight, false);
  3982. huffmanInput.end = originalEnd;
  3983. huffmanInput.position = bitmapEnd;
  3984. }
  3985. var numberOfSymbolsDecoded = symbolWidths.length;
  3986. if (firstSymbol === numberOfSymbolsDecoded - 1) {
  3987. newSymbols.push(collectiveBitmap);
  3988. } else {
  3989. var _i = void 0,
  3990. y = void 0,
  3991. xMin = 0,
  3992. xMax = void 0,
  3993. bitmapWidth = void 0,
  3994. symbolBitmap = void 0;
  3995. for (_i = firstSymbol; _i < numberOfSymbolsDecoded; _i++) {
  3996. bitmapWidth = symbolWidths[_i];
  3997. xMax = xMin + bitmapWidth;
  3998. symbolBitmap = [];
  3999. for (y = 0; y < currentHeight; y++) {
  4000. symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  4001. }
  4002. newSymbols.push(symbolBitmap);
  4003. xMin = xMax;
  4004. }
  4005. }
  4006. }
  4007. }
  4008. var exportedSymbols = [];
  4009. var flags = [],
  4010. currentFlag = false;
  4011. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  4012. while (flags.length < totalSymbolsLength) {
  4013. var runLength = huffman ? tableB1.decode(huffmanInput) : decodeInteger(contextCache, 'IAEX', decoder);
  4014. while (runLength--) {
  4015. flags.push(currentFlag);
  4016. }
  4017. currentFlag = !currentFlag;
  4018. }
  4019. for (var i = 0, ii = symbols.length; i < ii; i++) {
  4020. if (flags[i]) {
  4021. exportedSymbols.push(symbols[i]);
  4022. }
  4023. }
  4024. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  4025. if (flags[i]) {
  4026. exportedSymbols.push(newSymbols[j]);
  4027. }
  4028. }
  4029. return exportedSymbols;
  4030. }
  4031. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, logStripSize, huffmanInput) {
  4032. if (huffman && refinement) {
  4033. throw new Jbig2Error('refinement with Huffman is not supported');
  4034. }
  4035. var bitmap = [];
  4036. var i, row;
  4037. for (i = 0; i < height; i++) {
  4038. row = new Uint8Array(width);
  4039. if (defaultPixelValue) {
  4040. for (var j = 0; j < width; j++) {
  4041. row[j] = defaultPixelValue;
  4042. }
  4043. }
  4044. bitmap.push(row);
  4045. }
  4046. var decoder = decodingContext.decoder;
  4047. var contextCache = decodingContext.contextCache;
  4048. var stripT = huffman ? -huffmanTables.tableDeltaT.decode(huffmanInput) : -decodeInteger(contextCache, 'IADT', decoder);
  4049. var firstS = 0;
  4050. i = 0;
  4051. while (i < numberOfSymbolInstances) {
  4052. var deltaT = huffman ? huffmanTables.tableDeltaT.decode(huffmanInput) : decodeInteger(contextCache, 'IADT', decoder);
  4053. stripT += deltaT;
  4054. var deltaFirstS = huffman ? huffmanTables.tableFirstS.decode(huffmanInput) : decodeInteger(contextCache, 'IAFS', decoder);
  4055. firstS += deltaFirstS;
  4056. var currentS = firstS;
  4057. do {
  4058. var currentT = 0;
  4059. if (stripSize > 1) {
  4060. currentT = huffman ? huffmanInput.readBits(logStripSize) : decodeInteger(contextCache, 'IAIT', decoder);
  4061. }
  4062. var t = stripSize * stripT + currentT;
  4063. var symbolId = huffman ? huffmanTables.symbolIDTable.decode(huffmanInput) : decodeIAID(contextCache, decoder, symbolCodeLength);
  4064. var applyRefinement = refinement && (huffman ? huffmanInput.readBit() : decodeInteger(contextCache, 'IARI', decoder));
  4065. var symbolBitmap = inputSymbols[symbolId];
  4066. var symbolWidth = symbolBitmap[0].length;
  4067. var symbolHeight = symbolBitmap.length;
  4068. if (applyRefinement) {
  4069. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  4070. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  4071. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  4072. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  4073. symbolWidth += rdw;
  4074. symbolHeight += rdh;
  4075. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  4076. }
  4077. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
  4078. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
  4079. var s2, t2, symbolRow;
  4080. if (transposed) {
  4081. for (s2 = 0; s2 < symbolHeight; s2++) {
  4082. row = bitmap[offsetS + s2];
  4083. if (!row) {
  4084. continue;
  4085. }
  4086. symbolRow = symbolBitmap[s2];
  4087. var maxWidth = Math.min(width - offsetT, symbolWidth);
  4088. switch (combinationOperator) {
  4089. case 0:
  4090. for (t2 = 0; t2 < maxWidth; t2++) {
  4091. row[offsetT + t2] |= symbolRow[t2];
  4092. }
  4093. break;
  4094. case 2:
  4095. for (t2 = 0; t2 < maxWidth; t2++) {
  4096. row[offsetT + t2] ^= symbolRow[t2];
  4097. }
  4098. break;
  4099. default:
  4100. throw new Jbig2Error("operator ".concat(combinationOperator, " is not supported"));
  4101. }
  4102. }
  4103. currentS += symbolHeight - 1;
  4104. } else {
  4105. for (t2 = 0; t2 < symbolHeight; t2++) {
  4106. row = bitmap[offsetT + t2];
  4107. if (!row) {
  4108. continue;
  4109. }
  4110. symbolRow = symbolBitmap[t2];
  4111. switch (combinationOperator) {
  4112. case 0:
  4113. for (s2 = 0; s2 < symbolWidth; s2++) {
  4114. row[offsetS + s2] |= symbolRow[s2];
  4115. }
  4116. break;
  4117. case 2:
  4118. for (s2 = 0; s2 < symbolWidth; s2++) {
  4119. row[offsetS + s2] ^= symbolRow[s2];
  4120. }
  4121. break;
  4122. default:
  4123. throw new Jbig2Error("operator ".concat(combinationOperator, " is not supported"));
  4124. }
  4125. }
  4126. currentS += symbolWidth - 1;
  4127. }
  4128. i++;
  4129. var deltaS = huffman ? huffmanTables.tableDeltaS.decode(huffmanInput) : decodeInteger(contextCache, 'IADS', decoder);
  4130. if (deltaS === null) {
  4131. break;
  4132. }
  4133. currentS += deltaS + dsOffset;
  4134. } while (true);
  4135. }
  4136. return bitmap;
  4137. }
  4138. function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
  4139. var at = [];
  4140. if (!mmr) {
  4141. at.push({
  4142. x: -patternWidth,
  4143. y: 0
  4144. });
  4145. if (template === 0) {
  4146. at.push({
  4147. x: -3,
  4148. y: -1
  4149. });
  4150. at.push({
  4151. x: 2,
  4152. y: -2
  4153. });
  4154. at.push({
  4155. x: -2,
  4156. y: -2
  4157. });
  4158. }
  4159. }
  4160. var collectiveWidth = (maxPatternIndex + 1) * patternWidth;
  4161. var collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
  4162. var patterns = [],
  4163. i = 0,
  4164. patternBitmap,
  4165. xMin,
  4166. xMax,
  4167. y;
  4168. while (i <= maxPatternIndex) {
  4169. patternBitmap = [];
  4170. xMin = patternWidth * i;
  4171. xMax = xMin + patternWidth;
  4172. for (y = 0; y < patternHeight; y++) {
  4173. patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  4174. }
  4175. patterns.push(patternBitmap);
  4176. i++;
  4177. }
  4178. return patterns;
  4179. }
  4180. function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
  4181. var skip = null;
  4182. if (enableSkip) {
  4183. throw new Jbig2Error('skip is not supported');
  4184. }
  4185. if (combinationOperator !== 0) {
  4186. throw new Jbig2Error('operator ' + combinationOperator + ' is not supported in halftone region');
  4187. }
  4188. var regionBitmap = [];
  4189. var i, j, row;
  4190. for (i = 0; i < regionHeight; i++) {
  4191. row = new Uint8Array(regionWidth);
  4192. if (defaultPixelValue) {
  4193. for (j = 0; j < regionWidth; j++) {
  4194. row[j] = defaultPixelValue;
  4195. }
  4196. }
  4197. regionBitmap.push(row);
  4198. }
  4199. var numberOfPatterns = patterns.length;
  4200. var pattern0 = patterns[0];
  4201. var patternWidth = pattern0[0].length,
  4202. patternHeight = pattern0.length;
  4203. var bitsPerValue = (0, _util.log2)(numberOfPatterns);
  4204. var at = [];
  4205. if (!mmr) {
  4206. at.push({
  4207. x: template <= 1 ? 3 : 2,
  4208. y: -1
  4209. });
  4210. if (template === 0) {
  4211. at.push({
  4212. x: -3,
  4213. y: -1
  4214. });
  4215. at.push({
  4216. x: 2,
  4217. y: -2
  4218. });
  4219. at.push({
  4220. x: -2,
  4221. y: -2
  4222. });
  4223. }
  4224. }
  4225. var grayScaleBitPlanes = [],
  4226. mmrInput,
  4227. bitmap;
  4228. if (mmr) {
  4229. mmrInput = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  4230. }
  4231. for (i = bitsPerValue - 1; i >= 0; i--) {
  4232. if (mmr) {
  4233. bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
  4234. } else {
  4235. bitmap = decodeBitmap(false, gridWidth, gridHeight, template, false, skip, at, decodingContext);
  4236. }
  4237. grayScaleBitPlanes[i] = bitmap;
  4238. }
  4239. var mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
  4240. for (mg = 0; mg < gridHeight; mg++) {
  4241. for (ng = 0; ng < gridWidth; ng++) {
  4242. bit = 0;
  4243. patternIndex = 0;
  4244. for (j = bitsPerValue - 1; j >= 0; j--) {
  4245. bit = grayScaleBitPlanes[j][mg][ng] ^ bit;
  4246. patternIndex |= bit << j;
  4247. }
  4248. patternBitmap = patterns[patternIndex];
  4249. x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
  4250. y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
  4251. if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
  4252. for (i = 0; i < patternHeight; i++) {
  4253. regionRow = regionBitmap[y + i];
  4254. patternRow = patternBitmap[i];
  4255. for (j = 0; j < patternWidth; j++) {
  4256. regionRow[x + j] |= patternRow[j];
  4257. }
  4258. }
  4259. } else {
  4260. var regionX = void 0,
  4261. regionY = void 0;
  4262. for (i = 0; i < patternHeight; i++) {
  4263. regionY = y + i;
  4264. if (regionY < 0 || regionY >= regionHeight) {
  4265. continue;
  4266. }
  4267. regionRow = regionBitmap[regionY];
  4268. patternRow = patternBitmap[i];
  4269. for (j = 0; j < patternWidth; j++) {
  4270. regionX = x + j;
  4271. if (regionX >= 0 && regionX < regionWidth) {
  4272. regionRow[regionX] |= patternRow[j];
  4273. }
  4274. }
  4275. }
  4276. }
  4277. }
  4278. }
  4279. return regionBitmap;
  4280. }
  4281. function readSegmentHeader(data, start) {
  4282. var segmentHeader = {};
  4283. segmentHeader.number = (0, _util.readUint32)(data, start);
  4284. var flags = data[start + 4];
  4285. var segmentType = flags & 0x3F;
  4286. if (!SegmentTypes[segmentType]) {
  4287. throw new Jbig2Error('invalid segment type: ' + segmentType);
  4288. }
  4289. segmentHeader.type = segmentType;
  4290. segmentHeader.typeName = SegmentTypes[segmentType];
  4291. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  4292. var pageAssociationFieldSize = !!(flags & 0x40);
  4293. var referredFlags = data[start + 5];
  4294. var referredToCount = referredFlags >> 5 & 7;
  4295. var retainBits = [referredFlags & 31];
  4296. var position = start + 6;
  4297. if (referredFlags === 7) {
  4298. referredToCount = (0, _util.readUint32)(data, position - 1) & 0x1FFFFFFF;
  4299. position += 3;
  4300. var bytes = referredToCount + 7 >> 3;
  4301. retainBits[0] = data[position++];
  4302. while (--bytes > 0) {
  4303. retainBits.push(data[position++]);
  4304. }
  4305. } else if (referredFlags === 5 || referredFlags === 6) {
  4306. throw new Jbig2Error('invalid referred-to flags');
  4307. }
  4308. segmentHeader.retainBits = retainBits;
  4309. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  4310. var referredTo = [];
  4311. var i, ii;
  4312. for (i = 0; i < referredToCount; i++) {
  4313. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? (0, _util.readUint16)(data, position) : (0, _util.readUint32)(data, position);
  4314. referredTo.push(number);
  4315. position += referredToSegmentNumberSize;
  4316. }
  4317. segmentHeader.referredTo = referredTo;
  4318. if (!pageAssociationFieldSize) {
  4319. segmentHeader.pageAssociation = data[position++];
  4320. } else {
  4321. segmentHeader.pageAssociation = (0, _util.readUint32)(data, position);
  4322. position += 4;
  4323. }
  4324. segmentHeader.length = (0, _util.readUint32)(data, position);
  4325. position += 4;
  4326. if (segmentHeader.length === 0xFFFFFFFF) {
  4327. if (segmentType === 38) {
  4328. var genericRegionInfo = readRegionSegmentInformation(data, position);
  4329. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  4330. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  4331. var searchPatternLength = 6;
  4332. var searchPattern = new Uint8Array(searchPatternLength);
  4333. if (!genericRegionMmr) {
  4334. searchPattern[0] = 0xFF;
  4335. searchPattern[1] = 0xAC;
  4336. }
  4337. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  4338. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  4339. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  4340. searchPattern[5] = genericRegionInfo.height & 0xFF;
  4341. for (i = position, ii = data.length; i < ii; i++) {
  4342. var j = 0;
  4343. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  4344. j++;
  4345. }
  4346. if (j === searchPatternLength) {
  4347. segmentHeader.length = i + searchPatternLength;
  4348. break;
  4349. }
  4350. }
  4351. if (segmentHeader.length === 0xFFFFFFFF) {
  4352. throw new Jbig2Error('segment end was not found');
  4353. }
  4354. } else {
  4355. throw new Jbig2Error('invalid unknown segment length');
  4356. }
  4357. }
  4358. segmentHeader.headerEnd = position;
  4359. return segmentHeader;
  4360. }
  4361. function readSegments(header, data, start, end) {
  4362. var segments = [];
  4363. var position = start;
  4364. while (position < end) {
  4365. var segmentHeader = readSegmentHeader(data, position);
  4366. position = segmentHeader.headerEnd;
  4367. var segment = {
  4368. header: segmentHeader,
  4369. data: data
  4370. };
  4371. if (!header.randomAccess) {
  4372. segment.start = position;
  4373. position += segmentHeader.length;
  4374. segment.end = position;
  4375. }
  4376. segments.push(segment);
  4377. if (segmentHeader.type === 51) {
  4378. break;
  4379. }
  4380. }
  4381. if (header.randomAccess) {
  4382. for (var i = 0, ii = segments.length; i < ii; i++) {
  4383. segments[i].start = position;
  4384. position += segments[i].header.length;
  4385. segments[i].end = position;
  4386. }
  4387. }
  4388. return segments;
  4389. }
  4390. function readRegionSegmentInformation(data, start) {
  4391. return {
  4392. width: (0, _util.readUint32)(data, start),
  4393. height: (0, _util.readUint32)(data, start + 4),
  4394. x: (0, _util.readUint32)(data, start + 8),
  4395. y: (0, _util.readUint32)(data, start + 12),
  4396. combinationOperator: data[start + 16] & 7
  4397. };
  4398. }
  4399. var RegionSegmentInformationFieldLength = 17;
  4400. function processSegment(segment, visitor) {
  4401. var header = segment.header;
  4402. var data = segment.data,
  4403. position = segment.start,
  4404. end = segment.end;
  4405. var args, at, i, atLength;
  4406. switch (header.type) {
  4407. case 0:
  4408. var dictionary = {};
  4409. var dictionaryFlags = (0, _util.readUint16)(data, position);
  4410. dictionary.huffman = !!(dictionaryFlags & 1);
  4411. dictionary.refinement = !!(dictionaryFlags & 2);
  4412. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  4413. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  4414. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  4415. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  4416. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  4417. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  4418. dictionary.template = dictionaryFlags >> 10 & 3;
  4419. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  4420. position += 2;
  4421. if (!dictionary.huffman) {
  4422. atLength = dictionary.template === 0 ? 4 : 1;
  4423. at = [];
  4424. for (i = 0; i < atLength; i++) {
  4425. at.push({
  4426. x: (0, _util.readInt8)(data, position),
  4427. y: (0, _util.readInt8)(data, position + 1)
  4428. });
  4429. position += 2;
  4430. }
  4431. dictionary.at = at;
  4432. }
  4433. if (dictionary.refinement && !dictionary.refinementTemplate) {
  4434. at = [];
  4435. for (i = 0; i < 2; i++) {
  4436. at.push({
  4437. x: (0, _util.readInt8)(data, position),
  4438. y: (0, _util.readInt8)(data, position + 1)
  4439. });
  4440. position += 2;
  4441. }
  4442. dictionary.refinementAt = at;
  4443. }
  4444. dictionary.numberOfExportedSymbols = (0, _util.readUint32)(data, position);
  4445. position += 4;
  4446. dictionary.numberOfNewSymbols = (0, _util.readUint32)(data, position);
  4447. position += 4;
  4448. args = [dictionary, header.number, header.referredTo, data, position, end];
  4449. break;
  4450. case 6:
  4451. case 7:
  4452. var textRegion = {};
  4453. textRegion.info = readRegionSegmentInformation(data, position);
  4454. position += RegionSegmentInformationFieldLength;
  4455. var textRegionSegmentFlags = (0, _util.readUint16)(data, position);
  4456. position += 2;
  4457. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  4458. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  4459. textRegion.logStripSize = textRegionSegmentFlags >> 2 & 3;
  4460. textRegion.stripSize = 1 << textRegion.logStripSize;
  4461. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  4462. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  4463. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  4464. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  4465. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  4466. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  4467. if (textRegion.huffman) {
  4468. var textRegionHuffmanFlags = (0, _util.readUint16)(data, position);
  4469. position += 2;
  4470. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  4471. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  4472. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  4473. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  4474. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  4475. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  4476. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  4477. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 0x4000);
  4478. }
  4479. if (textRegion.refinement && !textRegion.refinementTemplate) {
  4480. at = [];
  4481. for (i = 0; i < 2; i++) {
  4482. at.push({
  4483. x: (0, _util.readInt8)(data, position),
  4484. y: (0, _util.readInt8)(data, position + 1)
  4485. });
  4486. position += 2;
  4487. }
  4488. textRegion.refinementAt = at;
  4489. }
  4490. textRegion.numberOfSymbolInstances = (0, _util.readUint32)(data, position);
  4491. position += 4;
  4492. args = [textRegion, header.referredTo, data, position, end];
  4493. break;
  4494. case 16:
  4495. var patternDictionary = {};
  4496. var patternDictionaryFlags = data[position++];
  4497. patternDictionary.mmr = !!(patternDictionaryFlags & 1);
  4498. patternDictionary.template = patternDictionaryFlags >> 1 & 3;
  4499. patternDictionary.patternWidth = data[position++];
  4500. patternDictionary.patternHeight = data[position++];
  4501. patternDictionary.maxPatternIndex = (0, _util.readUint32)(data, position);
  4502. position += 4;
  4503. args = [patternDictionary, header.number, data, position, end];
  4504. break;
  4505. case 22:
  4506. case 23:
  4507. var halftoneRegion = {};
  4508. halftoneRegion.info = readRegionSegmentInformation(data, position);
  4509. position += RegionSegmentInformationFieldLength;
  4510. var halftoneRegionFlags = data[position++];
  4511. halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
  4512. halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
  4513. halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
  4514. halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
  4515. halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
  4516. halftoneRegion.gridWidth = (0, _util.readUint32)(data, position);
  4517. position += 4;
  4518. halftoneRegion.gridHeight = (0, _util.readUint32)(data, position);
  4519. position += 4;
  4520. halftoneRegion.gridOffsetX = (0, _util.readUint32)(data, position) & 0xFFFFFFFF;
  4521. position += 4;
  4522. halftoneRegion.gridOffsetY = (0, _util.readUint32)(data, position) & 0xFFFFFFFF;
  4523. position += 4;
  4524. halftoneRegion.gridVectorX = (0, _util.readUint16)(data, position);
  4525. position += 2;
  4526. halftoneRegion.gridVectorY = (0, _util.readUint16)(data, position);
  4527. position += 2;
  4528. args = [halftoneRegion, header.referredTo, data, position, end];
  4529. break;
  4530. case 38:
  4531. case 39:
  4532. var genericRegion = {};
  4533. genericRegion.info = readRegionSegmentInformation(data, position);
  4534. position += RegionSegmentInformationFieldLength;
  4535. var genericRegionSegmentFlags = data[position++];
  4536. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  4537. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  4538. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  4539. if (!genericRegion.mmr) {
  4540. atLength = genericRegion.template === 0 ? 4 : 1;
  4541. at = [];
  4542. for (i = 0; i < atLength; i++) {
  4543. at.push({
  4544. x: (0, _util.readInt8)(data, position),
  4545. y: (0, _util.readInt8)(data, position + 1)
  4546. });
  4547. position += 2;
  4548. }
  4549. genericRegion.at = at;
  4550. }
  4551. args = [genericRegion, data, position, end];
  4552. break;
  4553. case 48:
  4554. var pageInfo = {
  4555. width: (0, _util.readUint32)(data, position),
  4556. height: (0, _util.readUint32)(data, position + 4),
  4557. resolutionX: (0, _util.readUint32)(data, position + 8),
  4558. resolutionY: (0, _util.readUint32)(data, position + 12)
  4559. };
  4560. if (pageInfo.height === 0xFFFFFFFF) {
  4561. delete pageInfo.height;
  4562. }
  4563. var pageSegmentFlags = data[position + 16];
  4564. (0, _util.readUint16)(data, position + 17);
  4565. pageInfo.lossless = !!(pageSegmentFlags & 1);
  4566. pageInfo.refinement = !!(pageSegmentFlags & 2);
  4567. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  4568. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  4569. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  4570. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  4571. args = [pageInfo];
  4572. break;
  4573. case 49:
  4574. break;
  4575. case 50:
  4576. break;
  4577. case 51:
  4578. break;
  4579. case 53:
  4580. args = [header.number, data, position, end];
  4581. break;
  4582. case 62:
  4583. break;
  4584. default:
  4585. throw new Jbig2Error("segment type ".concat(header.typeName, "(").concat(header.type, ")") + ' is not implemented');
  4586. }
  4587. var callbackName = 'on' + header.typeName;
  4588. if (callbackName in visitor) {
  4589. visitor[callbackName].apply(visitor, args);
  4590. }
  4591. }
  4592. function processSegments(segments, visitor) {
  4593. for (var i = 0, ii = segments.length; i < ii; i++) {
  4594. processSegment(segments[i], visitor);
  4595. }
  4596. }
  4597. function parseJbig2Chunks(chunks) {
  4598. var visitor = new SimpleSegmentVisitor();
  4599. for (var i = 0, ii = chunks.length; i < ii; i++) {
  4600. var chunk = chunks[i];
  4601. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  4602. processSegments(segments, visitor);
  4603. }
  4604. return visitor.buffer;
  4605. }
  4606. function parseJbig2(data) {
  4607. var position = 0,
  4608. end = data.length;
  4609. 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) {
  4610. throw new Jbig2Error('parseJbig2 - invalid header.');
  4611. }
  4612. var header = Object.create(null);
  4613. position += 8;
  4614. var flags = data[position++];
  4615. header.randomAccess = !(flags & 1);
  4616. if (!(flags & 2)) {
  4617. header.numberOfPages = (0, _util.readUint32)(data, position);
  4618. position += 4;
  4619. }
  4620. var segments = readSegments(header, data, position, end);
  4621. var visitor = new SimpleSegmentVisitor();
  4622. processSegments(segments, visitor);
  4623. var _visitor$currentPageI = visitor.currentPageInfo,
  4624. width = _visitor$currentPageI.width,
  4625. height = _visitor$currentPageI.height;
  4626. var bitPacked = visitor.buffer;
  4627. var imgData = new Uint8ClampedArray(width * height);
  4628. var q = 0,
  4629. k = 0;
  4630. for (var i = 0; i < height; i++) {
  4631. var mask = 0,
  4632. buffer = void 0;
  4633. for (var j = 0; j < width; j++) {
  4634. if (!mask) {
  4635. mask = 128;
  4636. buffer = bitPacked[k++];
  4637. }
  4638. imgData[q++] = buffer & mask ? 0 : 255;
  4639. mask >>= 1;
  4640. }
  4641. }
  4642. return {
  4643. imgData: imgData,
  4644. width: width,
  4645. height: height
  4646. };
  4647. }
  4648. function SimpleSegmentVisitor() {}
  4649. SimpleSegmentVisitor.prototype = {
  4650. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  4651. this.currentPageInfo = info;
  4652. var rowSize = info.width + 7 >> 3;
  4653. var buffer = new Uint8ClampedArray(rowSize * info.height);
  4654. if (info.defaultPixelValue) {
  4655. for (var i = 0, ii = buffer.length; i < ii; i++) {
  4656. buffer[i] = 0xFF;
  4657. }
  4658. }
  4659. this.buffer = buffer;
  4660. },
  4661. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  4662. var pageInfo = this.currentPageInfo;
  4663. var width = regionInfo.width,
  4664. height = regionInfo.height;
  4665. var rowSize = pageInfo.width + 7 >> 3;
  4666. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  4667. var buffer = this.buffer;
  4668. var mask0 = 128 >> (regionInfo.x & 7);
  4669. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  4670. var i, j, mask, offset;
  4671. switch (combinationOperator) {
  4672. case 0:
  4673. for (i = 0; i < height; i++) {
  4674. mask = mask0;
  4675. offset = offset0;
  4676. for (j = 0; j < width; j++) {
  4677. if (bitmap[i][j]) {
  4678. buffer[offset] |= mask;
  4679. }
  4680. mask >>= 1;
  4681. if (!mask) {
  4682. mask = 128;
  4683. offset++;
  4684. }
  4685. }
  4686. offset0 += rowSize;
  4687. }
  4688. break;
  4689. case 2:
  4690. for (i = 0; i < height; i++) {
  4691. mask = mask0;
  4692. offset = offset0;
  4693. for (j = 0; j < width; j++) {
  4694. if (bitmap[i][j]) {
  4695. buffer[offset] ^= mask;
  4696. }
  4697. mask >>= 1;
  4698. if (!mask) {
  4699. mask = 128;
  4700. offset++;
  4701. }
  4702. }
  4703. offset0 += rowSize;
  4704. }
  4705. break;
  4706. default:
  4707. throw new Jbig2Error("operator ".concat(combinationOperator, " is not supported"));
  4708. }
  4709. },
  4710. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  4711. var regionInfo = region.info;
  4712. var decodingContext = new DecodingContext(data, start, end);
  4713. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  4714. this.drawBitmap(regionInfo, bitmap);
  4715. },
  4716. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  4717. this.onImmediateGenericRegion.apply(this, arguments);
  4718. },
  4719. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  4720. var huffmanTables, huffmanInput;
  4721. if (dictionary.huffman) {
  4722. huffmanTables = getSymbolDictionaryHuffmanTables(dictionary, referredSegments, this.customTables);
  4723. huffmanInput = new Reader(data, start, end);
  4724. }
  4725. var symbols = this.symbols;
  4726. if (!symbols) {
  4727. this.symbols = symbols = {};
  4728. }
  4729. var inputSymbols = [];
  4730. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  4731. var referredSymbols = symbols[referredSegments[i]];
  4732. if (referredSymbols) {
  4733. inputSymbols = inputSymbols.concat(referredSymbols);
  4734. }
  4735. }
  4736. var decodingContext = new DecodingContext(data, start, end);
  4737. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext, huffmanInput);
  4738. },
  4739. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  4740. var regionInfo = region.info;
  4741. var huffmanTables, huffmanInput;
  4742. var symbols = this.symbols;
  4743. var inputSymbols = [];
  4744. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  4745. var referredSymbols = symbols[referredSegments[i]];
  4746. if (referredSymbols) {
  4747. inputSymbols = inputSymbols.concat(referredSymbols);
  4748. }
  4749. }
  4750. var symbolCodeLength = (0, _util.log2)(inputSymbols.length);
  4751. if (region.huffman) {
  4752. huffmanInput = new Reader(data, start, end);
  4753. huffmanTables = getTextRegionHuffmanTables(region, referredSegments, this.customTables, inputSymbols.length, huffmanInput);
  4754. }
  4755. var decodingContext = new DecodingContext(data, start, end);
  4756. 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, region.logStripSize, huffmanInput);
  4757. this.drawBitmap(regionInfo, bitmap);
  4758. },
  4759. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  4760. this.onImmediateTextRegion.apply(this, arguments);
  4761. },
  4762. onPatternDictionary: function onPatternDictionary(dictionary, currentSegment, data, start, end) {
  4763. var patterns = this.patterns;
  4764. if (!patterns) {
  4765. this.patterns = patterns = {};
  4766. }
  4767. var decodingContext = new DecodingContext(data, start, end);
  4768. patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
  4769. },
  4770. onImmediateHalftoneRegion: function onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
  4771. var patterns = this.patterns[referredSegments[0]];
  4772. var regionInfo = region.info;
  4773. var decodingContext = new DecodingContext(data, start, end);
  4774. var bitmap = decodeHalftoneRegion(region.mmr, patterns, region.template, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.enableSkip, region.combinationOperator, region.gridWidth, region.gridHeight, region.gridOffsetX, region.gridOffsetY, region.gridVectorX, region.gridVectorY, decodingContext);
  4775. this.drawBitmap(regionInfo, bitmap);
  4776. },
  4777. onImmediateLosslessHalftoneRegion: function onImmediateLosslessHalftoneRegion() {
  4778. this.onImmediateHalftoneRegion.apply(this, arguments);
  4779. },
  4780. onTables: function onTables(currentSegment, data, start, end) {
  4781. var customTables = this.customTables;
  4782. if (!customTables) {
  4783. this.customTables = customTables = {};
  4784. }
  4785. customTables[currentSegment] = decodeTablesSegment(data, start, end);
  4786. }
  4787. };
  4788. function HuffmanLine(lineData) {
  4789. if (lineData.length === 2) {
  4790. this.isOOB = true;
  4791. this.rangeLow = 0;
  4792. this.prefixLength = lineData[0];
  4793. this.rangeLength = 0;
  4794. this.prefixCode = lineData[1];
  4795. this.isLowerRange = false;
  4796. } else {
  4797. this.isOOB = false;
  4798. this.rangeLow = lineData[0];
  4799. this.prefixLength = lineData[1];
  4800. this.rangeLength = lineData[2];
  4801. this.prefixCode = lineData[3];
  4802. this.isLowerRange = lineData[4] === 'lower';
  4803. }
  4804. }
  4805. function HuffmanTreeNode(line) {
  4806. this.children = [];
  4807. if (line) {
  4808. this.isLeaf = true;
  4809. this.rangeLength = line.rangeLength;
  4810. this.rangeLow = line.rangeLow;
  4811. this.isLowerRange = line.isLowerRange;
  4812. this.isOOB = line.isOOB;
  4813. } else {
  4814. this.isLeaf = false;
  4815. }
  4816. }
  4817. HuffmanTreeNode.prototype = {
  4818. buildTree: function buildTree(line, shift) {
  4819. var bit = line.prefixCode >> shift & 1;
  4820. if (shift <= 0) {
  4821. this.children[bit] = new HuffmanTreeNode(line);
  4822. } else {
  4823. var node = this.children[bit];
  4824. if (!node) {
  4825. this.children[bit] = node = new HuffmanTreeNode(null);
  4826. }
  4827. node.buildTree(line, shift - 1);
  4828. }
  4829. },
  4830. decodeNode: function decodeNode(reader) {
  4831. if (this.isLeaf) {
  4832. if (this.isOOB) {
  4833. return null;
  4834. }
  4835. var htOffset = reader.readBits(this.rangeLength);
  4836. return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
  4837. }
  4838. var node = this.children[reader.readBit()];
  4839. if (!node) {
  4840. throw new Jbig2Error('invalid Huffman data');
  4841. }
  4842. return node.decodeNode(reader);
  4843. }
  4844. };
  4845. function HuffmanTable(lines, prefixCodesDone) {
  4846. if (!prefixCodesDone) {
  4847. this.assignPrefixCodes(lines);
  4848. }
  4849. this.rootNode = new HuffmanTreeNode(null);
  4850. var i,
  4851. ii = lines.length,
  4852. line;
  4853. for (i = 0; i < ii; i++) {
  4854. line = lines[i];
  4855. if (line.prefixLength > 0) {
  4856. this.rootNode.buildTree(line, line.prefixLength - 1);
  4857. }
  4858. }
  4859. }
  4860. HuffmanTable.prototype = {
  4861. decode: function decode(reader) {
  4862. return this.rootNode.decodeNode(reader);
  4863. },
  4864. assignPrefixCodes: function assignPrefixCodes(lines) {
  4865. var linesLength = lines.length,
  4866. prefixLengthMax = 0,
  4867. i;
  4868. for (i = 0; i < linesLength; i++) {
  4869. prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
  4870. }
  4871. var histogram = new Uint32Array(prefixLengthMax + 1);
  4872. for (i = 0; i < linesLength; i++) {
  4873. histogram[lines[i].prefixLength]++;
  4874. }
  4875. var currentLength = 1,
  4876. firstCode = 0,
  4877. currentCode,
  4878. currentTemp,
  4879. line;
  4880. histogram[0] = 0;
  4881. while (currentLength <= prefixLengthMax) {
  4882. firstCode = firstCode + histogram[currentLength - 1] << 1;
  4883. currentCode = firstCode;
  4884. currentTemp = 0;
  4885. while (currentTemp < linesLength) {
  4886. line = lines[currentTemp];
  4887. if (line.prefixLength === currentLength) {
  4888. line.prefixCode = currentCode;
  4889. currentCode++;
  4890. }
  4891. currentTemp++;
  4892. }
  4893. currentLength++;
  4894. }
  4895. }
  4896. };
  4897. function decodeTablesSegment(data, start, end) {
  4898. var flags = data[start];
  4899. var lowestValue = (0, _util.readUint32)(data, start + 1) & 0xFFFFFFFF;
  4900. var highestValue = (0, _util.readUint32)(data, start + 5) & 0xFFFFFFFF;
  4901. var reader = new Reader(data, start + 9, end);
  4902. var prefixSizeBits = (flags >> 1 & 7) + 1;
  4903. var rangeSizeBits = (flags >> 4 & 7) + 1;
  4904. var lines = [];
  4905. var prefixLength,
  4906. rangeLength,
  4907. currentRangeLow = lowestValue;
  4908. do {
  4909. prefixLength = reader.readBits(prefixSizeBits);
  4910. rangeLength = reader.readBits(rangeSizeBits);
  4911. lines.push(new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0]));
  4912. currentRangeLow += 1 << rangeLength;
  4913. } while (currentRangeLow < highestValue);
  4914. prefixLength = reader.readBits(prefixSizeBits);
  4915. lines.push(new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, 'lower']));
  4916. prefixLength = reader.readBits(prefixSizeBits);
  4917. lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
  4918. if (flags & 1) {
  4919. prefixLength = reader.readBits(prefixSizeBits);
  4920. lines.push(new HuffmanLine([prefixLength, 0]));
  4921. }
  4922. return new HuffmanTable(lines, false);
  4923. }
  4924. var standardTablesCache = {};
  4925. function getStandardTable(number) {
  4926. var table = standardTablesCache[number];
  4927. if (table) {
  4928. return table;
  4929. }
  4930. var lines;
  4931. switch (number) {
  4932. case 1:
  4933. lines = [[0, 1, 4, 0x0], [16, 2, 8, 0x2], [272, 3, 16, 0x6], [65808, 3, 32, 0x7]];
  4934. break;
  4935. case 2:
  4936. lines = [[0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xE], [11, 5, 6, 0x1E], [75, 6, 32, 0x3E], [6, 0x3F]];
  4937. break;
  4938. case 3:
  4939. lines = [[-256, 8, 8, 0xFE], [0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xE], [11, 5, 6, 0x1E], [-257, 8, 32, 0xFF, 'lower'], [75, 7, 32, 0x7E], [6, 0x3E]];
  4940. break;
  4941. case 4:
  4942. lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xE], [12, 5, 6, 0x1E], [76, 5, 32, 0x1F]];
  4943. break;
  4944. case 5:
  4945. lines = [[-255, 7, 8, 0x7E], [1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xE], [12, 5, 6, 0x1E], [-256, 7, 32, 0x7F, 'lower'], [76, 6, 32, 0x3E]];
  4946. break;
  4947. case 6:
  4948. lines = [[-2048, 5, 10, 0x1C], [-1024, 4, 9, 0x8], [-512, 4, 8, 0x9], [-256, 4, 7, 0xA], [-128, 5, 6, 0x1D], [-64, 5, 5, 0x1E], [-32, 4, 5, 0xB], [0, 2, 7, 0x0], [128, 3, 7, 0x2], [256, 3, 8, 0x3], [512, 4, 9, 0xC], [1024, 4, 10, 0xD], [-2049, 6, 32, 0x3E, 'lower'], [2048, 6, 32, 0x3F]];
  4949. break;
  4950. case 7:
  4951. lines = [[-1024, 4, 9, 0x8], [-512, 3, 8, 0x0], [-256, 4, 7, 0x9], [-128, 5, 6, 0x1A], [-64, 5, 5, 0x1B], [-32, 4, 5, 0xA], [0, 4, 5, 0xB], [32, 5, 5, 0x1C], [64, 5, 6, 0x1D], [128, 4, 7, 0xC], [256, 3, 8, 0x1], [512, 3, 9, 0x2], [1024, 3, 10, 0x3], [-1025, 5, 32, 0x1E, 'lower'], [2048, 5, 32, 0x1F]];
  4952. break;
  4953. case 8:
  4954. lines = [[-15, 8, 3, 0xFC], [-7, 9, 1, 0x1FC], [-5, 8, 1, 0xFD], [-3, 9, 0, 0x1FD], [-2, 7, 0, 0x7C], [-1, 4, 0, 0xA], [0, 2, 1, 0x0], [2, 5, 0, 0x1A], [3, 6, 0, 0x3A], [4, 3, 4, 0x4], [20, 6, 1, 0x3B], [22, 4, 4, 0xB], [38, 4, 5, 0xC], [70, 5, 6, 0x1B], [134, 5, 7, 0x1C], [262, 6, 7, 0x3C], [390, 7, 8, 0x7D], [646, 6, 10, 0x3D], [-16, 9, 32, 0x1FE, 'lower'], [1670, 9, 32, 0x1FF], [2, 0x1]];
  4955. break;
  4956. case 9:
  4957. lines = [[-31, 8, 4, 0xFC], [-15, 9, 2, 0x1FC], [-11, 8, 2, 0xFD], [-7, 9, 1, 0x1FD], [-5, 7, 1, 0x7C], [-3, 4, 1, 0xA], [-1, 3, 1, 0x2], [1, 3, 1, 0x3], [3, 5, 1, 0x1A], [5, 6, 1, 0x3A], [7, 3, 5, 0x4], [39, 6, 2, 0x3B], [43, 4, 5, 0xB], [75, 4, 6, 0xC], [139, 5, 7, 0x1B], [267, 5, 8, 0x1C], [523, 6, 8, 0x3C], [779, 7, 9, 0x7D], [1291, 6, 11, 0x3D], [-32, 9, 32, 0x1FE, 'lower'], [3339, 9, 32, 0x1FF], [2, 0x0]];
  4958. break;
  4959. case 10:
  4960. lines = [[-21, 7, 4, 0x7A], [-5, 8, 0, 0xFC], [-4, 7, 0, 0x7B], [-3, 5, 0, 0x18], [-2, 2, 2, 0x0], [2, 5, 0, 0x19], [3, 6, 0, 0x36], [4, 7, 0, 0x7C], [5, 8, 0, 0xFD], [6, 2, 6, 0x1], [70, 5, 5, 0x1A], [102, 6, 5, 0x37], [134, 6, 6, 0x38], [198, 6, 7, 0x39], [326, 6, 8, 0x3A], [582, 6, 9, 0x3B], [1094, 6, 10, 0x3C], [2118, 7, 11, 0x7D], [-22, 8, 32, 0xFE, 'lower'], [4166, 8, 32, 0xFF], [2, 0x2]];
  4961. break;
  4962. case 11:
  4963. lines = [[1, 1, 0, 0x0], [2, 2, 1, 0x2], [4, 4, 0, 0xC], [5, 4, 1, 0xD], [7, 5, 1, 0x1C], [9, 5, 2, 0x1D], [13, 6, 2, 0x3C], [17, 7, 2, 0x7A], [21, 7, 3, 0x7B], [29, 7, 4, 0x7C], [45, 7, 5, 0x7D], [77, 7, 6, 0x7E], [141, 7, 32, 0x7F]];
  4964. break;
  4965. case 12:
  4966. lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 1, 0x6], [5, 5, 0, 0x1C], [6, 5, 1, 0x1D], [8, 6, 1, 0x3C], [10, 7, 0, 0x7A], [11, 7, 1, 0x7B], [13, 7, 2, 0x7C], [17, 7, 3, 0x7D], [25, 7, 4, 0x7E], [41, 8, 5, 0xFE], [73, 8, 32, 0xFF]];
  4967. break;
  4968. case 13:
  4969. lines = [[1, 1, 0, 0x0], [2, 3, 0, 0x4], [3, 4, 0, 0xC], [4, 5, 0, 0x1C], [5, 4, 1, 0xD], [7, 3, 3, 0x5], [15, 6, 1, 0x3A], [17, 6, 2, 0x3B], [21, 6, 3, 0x3C], [29, 6, 4, 0x3D], [45, 6, 5, 0x3E], [77, 7, 6, 0x7E], [141, 7, 32, 0x7F]];
  4970. break;
  4971. case 14:
  4972. lines = [[-2, 3, 0, 0x4], [-1, 3, 0, 0x5], [0, 1, 0, 0x0], [1, 3, 0, 0x6], [2, 3, 0, 0x7]];
  4973. break;
  4974. case 15:
  4975. lines = [[-24, 7, 4, 0x7C], [-8, 6, 2, 0x3C], [-4, 5, 1, 0x1C], [-2, 4, 0, 0xC], [-1, 3, 0, 0x4], [0, 1, 0, 0x0], [1, 3, 0, 0x5], [2, 4, 0, 0xD], [3, 5, 1, 0x1D], [5, 6, 2, 0x3D], [9, 7, 4, 0x7D], [-25, 7, 32, 0x7E, 'lower'], [25, 7, 32, 0x7F]];
  4976. break;
  4977. default:
  4978. throw new Jbig2Error("standard table B.".concat(number, " does not exist"));
  4979. }
  4980. var length = lines.length,
  4981. i;
  4982. for (i = 0; i < length; i++) {
  4983. lines[i] = new HuffmanLine(lines[i]);
  4984. }
  4985. table = new HuffmanTable(lines, true);
  4986. standardTablesCache[number] = table;
  4987. return table;
  4988. }
  4989. function Reader(data, start, end) {
  4990. this.data = data;
  4991. this.start = start;
  4992. this.end = end;
  4993. this.position = start;
  4994. this.shift = -1;
  4995. this.currentByte = 0;
  4996. }
  4997. Reader.prototype = {
  4998. readBit: function readBit() {
  4999. if (this.shift < 0) {
  5000. if (this.position >= this.end) {
  5001. throw new Jbig2Error('end of data while reading bit');
  5002. }
  5003. this.currentByte = this.data[this.position++];
  5004. this.shift = 7;
  5005. }
  5006. var bit = this.currentByte >> this.shift & 1;
  5007. this.shift--;
  5008. return bit;
  5009. },
  5010. readBits: function readBits(numBits) {
  5011. var result = 0,
  5012. i;
  5013. for (i = numBits - 1; i >= 0; i--) {
  5014. result |= this.readBit() << i;
  5015. }
  5016. return result;
  5017. },
  5018. byteAlign: function byteAlign() {
  5019. this.shift = -1;
  5020. },
  5021. next: function next() {
  5022. if (this.position >= this.end) {
  5023. return -1;
  5024. }
  5025. return this.data[this.position++];
  5026. }
  5027. };
  5028. function getCustomHuffmanTable(index, referredTo, customTables) {
  5029. var currentIndex = 0,
  5030. i,
  5031. ii = referredTo.length,
  5032. table;
  5033. for (i = 0; i < ii; i++) {
  5034. table = customTables[referredTo[i]];
  5035. if (table) {
  5036. if (index === currentIndex) {
  5037. return table;
  5038. }
  5039. currentIndex++;
  5040. }
  5041. }
  5042. throw new Jbig2Error('can\'t find custom Huffman table');
  5043. }
  5044. function getTextRegionHuffmanTables(textRegion, referredTo, customTables, numberOfSymbols, reader) {
  5045. var codes = [],
  5046. i,
  5047. codeLength;
  5048. for (i = 0; i <= 34; i++) {
  5049. codeLength = reader.readBits(4);
  5050. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  5051. }
  5052. var runCodesTable = new HuffmanTable(codes, false);
  5053. codes.length = 0;
  5054. for (i = 0; i < numberOfSymbols;) {
  5055. codeLength = runCodesTable.decode(reader);
  5056. if (codeLength >= 32) {
  5057. var repeatedLength = void 0,
  5058. numberOfRepeats = void 0,
  5059. j = void 0;
  5060. switch (codeLength) {
  5061. case 32:
  5062. if (i === 0) {
  5063. throw new Jbig2Error('no previous value in symbol ID table');
  5064. }
  5065. numberOfRepeats = reader.readBits(2) + 3;
  5066. repeatedLength = codes[i - 1].prefixLength;
  5067. break;
  5068. case 33:
  5069. numberOfRepeats = reader.readBits(3) + 3;
  5070. repeatedLength = 0;
  5071. break;
  5072. case 34:
  5073. numberOfRepeats = reader.readBits(7) + 11;
  5074. repeatedLength = 0;
  5075. break;
  5076. default:
  5077. throw new Jbig2Error('invalid code length in symbol ID table');
  5078. }
  5079. for (j = 0; j < numberOfRepeats; j++) {
  5080. codes.push(new HuffmanLine([i, repeatedLength, 0, 0]));
  5081. i++;
  5082. }
  5083. } else {
  5084. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  5085. i++;
  5086. }
  5087. }
  5088. reader.byteAlign();
  5089. var symbolIDTable = new HuffmanTable(codes, false);
  5090. var customIndex = 0,
  5091. tableFirstS,
  5092. tableDeltaS,
  5093. tableDeltaT;
  5094. switch (textRegion.huffmanFS) {
  5095. case 0:
  5096. case 1:
  5097. tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
  5098. break;
  5099. case 3:
  5100. tableFirstS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5101. customIndex++;
  5102. break;
  5103. default:
  5104. throw new Jbig2Error('invalid Huffman FS selector');
  5105. }
  5106. switch (textRegion.huffmanDS) {
  5107. case 0:
  5108. case 1:
  5109. case 2:
  5110. tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
  5111. break;
  5112. case 3:
  5113. tableDeltaS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5114. customIndex++;
  5115. break;
  5116. default:
  5117. throw new Jbig2Error('invalid Huffman DS selector');
  5118. }
  5119. switch (textRegion.huffmanDT) {
  5120. case 0:
  5121. case 1:
  5122. case 2:
  5123. tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
  5124. break;
  5125. case 3:
  5126. tableDeltaT = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5127. customIndex++;
  5128. break;
  5129. default:
  5130. throw new Jbig2Error('invalid Huffman DT selector');
  5131. }
  5132. if (textRegion.refinement) {
  5133. throw new Jbig2Error('refinement with Huffman is not supported');
  5134. }
  5135. return {
  5136. symbolIDTable: symbolIDTable,
  5137. tableFirstS: tableFirstS,
  5138. tableDeltaS: tableDeltaS,
  5139. tableDeltaT: tableDeltaT
  5140. };
  5141. }
  5142. function getSymbolDictionaryHuffmanTables(dictionary, referredTo, customTables) {
  5143. var customIndex = 0,
  5144. tableDeltaHeight,
  5145. tableDeltaWidth;
  5146. switch (dictionary.huffmanDHSelector) {
  5147. case 0:
  5148. case 1:
  5149. tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
  5150. break;
  5151. case 3:
  5152. tableDeltaHeight = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5153. customIndex++;
  5154. break;
  5155. default:
  5156. throw new Jbig2Error('invalid Huffman DH selector');
  5157. }
  5158. switch (dictionary.huffmanDWSelector) {
  5159. case 0:
  5160. case 1:
  5161. tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
  5162. break;
  5163. case 3:
  5164. tableDeltaWidth = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5165. customIndex++;
  5166. break;
  5167. default:
  5168. throw new Jbig2Error('invalid Huffman DW selector');
  5169. }
  5170. var tableBitmapSize, tableAggregateInstances;
  5171. if (dictionary.bitmapSizeSelector) {
  5172. tableBitmapSize = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5173. customIndex++;
  5174. } else {
  5175. tableBitmapSize = getStandardTable(1);
  5176. }
  5177. if (dictionary.aggregationInstancesSelector) {
  5178. tableAggregateInstances = getCustomHuffmanTable(customIndex, referredTo, customTables);
  5179. } else {
  5180. tableAggregateInstances = getStandardTable(1);
  5181. }
  5182. return {
  5183. tableDeltaHeight: tableDeltaHeight,
  5184. tableDeltaWidth: tableDeltaWidth,
  5185. tableBitmapSize: tableBitmapSize,
  5186. tableAggregateInstances: tableAggregateInstances
  5187. };
  5188. }
  5189. function readUncompressedBitmap(reader, width, height) {
  5190. var bitmap = [],
  5191. x,
  5192. y,
  5193. row;
  5194. for (y = 0; y < height; y++) {
  5195. row = new Uint8Array(width);
  5196. bitmap.push(row);
  5197. for (x = 0; x < width; x++) {
  5198. row[x] = reader.readBit();
  5199. }
  5200. reader.byteAlign();
  5201. }
  5202. return bitmap;
  5203. }
  5204. function decodeMMRBitmap(input, width, height, endOfBlock) {
  5205. var params = {
  5206. K: -1,
  5207. Columns: width,
  5208. Rows: height,
  5209. BlackIs1: true,
  5210. EndOfBlock: endOfBlock
  5211. };
  5212. var decoder = new _ccitt.CCITTFaxDecoder(input, params);
  5213. var bitmap = [],
  5214. x,
  5215. y,
  5216. row,
  5217. currentByte,
  5218. shift,
  5219. eof = false;
  5220. for (y = 0; y < height; y++) {
  5221. row = new Uint8Array(width);
  5222. bitmap.push(row);
  5223. shift = -1;
  5224. for (x = 0; x < width; x++) {
  5225. if (shift < 0) {
  5226. currentByte = decoder.readNextChar();
  5227. if (currentByte === -1) {
  5228. currentByte = 0;
  5229. eof = true;
  5230. }
  5231. shift = 7;
  5232. }
  5233. row[x] = currentByte >> shift & 1;
  5234. shift--;
  5235. }
  5236. }
  5237. if (endOfBlock && !eof) {
  5238. var lookForEOFLimit = 5;
  5239. for (var i = 0; i < lookForEOFLimit; i++) {
  5240. if (decoder.readNextChar() === -1) {
  5241. break;
  5242. }
  5243. }
  5244. }
  5245. return bitmap;
  5246. }
  5247. function Jbig2Image() {}
  5248. Jbig2Image.prototype = {
  5249. parseChunks: function parseChunks(chunks) {
  5250. return parseJbig2Chunks(chunks);
  5251. },
  5252. parse: function parse(data) {
  5253. var _parseJbig = parseJbig2(data),
  5254. imgData = _parseJbig.imgData,
  5255. width = _parseJbig.width,
  5256. height = _parseJbig.height;
  5257. this.width = width;
  5258. this.height = height;
  5259. return imgData;
  5260. }
  5261. };
  5262. return Jbig2Image;
  5263. }();
  5264. exports.Jbig2Image = Jbig2Image;
  5265. /***/ }),
  5266. /* 133 */
  5267. /***/ (function(module, exports, __w_pdfjs_require__) {
  5268. "use strict";
  5269. Object.defineProperty(exports, "__esModule", {
  5270. value: true
  5271. });
  5272. exports.ArithmeticDecoder = void 0;
  5273. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5274. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5275. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5276. var QeTable = [{
  5277. qe: 0x5601,
  5278. nmps: 1,
  5279. nlps: 1,
  5280. switchFlag: 1
  5281. }, {
  5282. qe: 0x3401,
  5283. nmps: 2,
  5284. nlps: 6,
  5285. switchFlag: 0
  5286. }, {
  5287. qe: 0x1801,
  5288. nmps: 3,
  5289. nlps: 9,
  5290. switchFlag: 0
  5291. }, {
  5292. qe: 0x0AC1,
  5293. nmps: 4,
  5294. nlps: 12,
  5295. switchFlag: 0
  5296. }, {
  5297. qe: 0x0521,
  5298. nmps: 5,
  5299. nlps: 29,
  5300. switchFlag: 0
  5301. }, {
  5302. qe: 0x0221,
  5303. nmps: 38,
  5304. nlps: 33,
  5305. switchFlag: 0
  5306. }, {
  5307. qe: 0x5601,
  5308. nmps: 7,
  5309. nlps: 6,
  5310. switchFlag: 1
  5311. }, {
  5312. qe: 0x5401,
  5313. nmps: 8,
  5314. nlps: 14,
  5315. switchFlag: 0
  5316. }, {
  5317. qe: 0x4801,
  5318. nmps: 9,
  5319. nlps: 14,
  5320. switchFlag: 0
  5321. }, {
  5322. qe: 0x3801,
  5323. nmps: 10,
  5324. nlps: 14,
  5325. switchFlag: 0
  5326. }, {
  5327. qe: 0x3001,
  5328. nmps: 11,
  5329. nlps: 17,
  5330. switchFlag: 0
  5331. }, {
  5332. qe: 0x2401,
  5333. nmps: 12,
  5334. nlps: 18,
  5335. switchFlag: 0
  5336. }, {
  5337. qe: 0x1C01,
  5338. nmps: 13,
  5339. nlps: 20,
  5340. switchFlag: 0
  5341. }, {
  5342. qe: 0x1601,
  5343. nmps: 29,
  5344. nlps: 21,
  5345. switchFlag: 0
  5346. }, {
  5347. qe: 0x5601,
  5348. nmps: 15,
  5349. nlps: 14,
  5350. switchFlag: 1
  5351. }, {
  5352. qe: 0x5401,
  5353. nmps: 16,
  5354. nlps: 14,
  5355. switchFlag: 0
  5356. }, {
  5357. qe: 0x5101,
  5358. nmps: 17,
  5359. nlps: 15,
  5360. switchFlag: 0
  5361. }, {
  5362. qe: 0x4801,
  5363. nmps: 18,
  5364. nlps: 16,
  5365. switchFlag: 0
  5366. }, {
  5367. qe: 0x3801,
  5368. nmps: 19,
  5369. nlps: 17,
  5370. switchFlag: 0
  5371. }, {
  5372. qe: 0x3401,
  5373. nmps: 20,
  5374. nlps: 18,
  5375. switchFlag: 0
  5376. }, {
  5377. qe: 0x3001,
  5378. nmps: 21,
  5379. nlps: 19,
  5380. switchFlag: 0
  5381. }, {
  5382. qe: 0x2801,
  5383. nmps: 22,
  5384. nlps: 19,
  5385. switchFlag: 0
  5386. }, {
  5387. qe: 0x2401,
  5388. nmps: 23,
  5389. nlps: 20,
  5390. switchFlag: 0
  5391. }, {
  5392. qe: 0x2201,
  5393. nmps: 24,
  5394. nlps: 21,
  5395. switchFlag: 0
  5396. }, {
  5397. qe: 0x1C01,
  5398. nmps: 25,
  5399. nlps: 22,
  5400. switchFlag: 0
  5401. }, {
  5402. qe: 0x1801,
  5403. nmps: 26,
  5404. nlps: 23,
  5405. switchFlag: 0
  5406. }, {
  5407. qe: 0x1601,
  5408. nmps: 27,
  5409. nlps: 24,
  5410. switchFlag: 0
  5411. }, {
  5412. qe: 0x1401,
  5413. nmps: 28,
  5414. nlps: 25,
  5415. switchFlag: 0
  5416. }, {
  5417. qe: 0x1201,
  5418. nmps: 29,
  5419. nlps: 26,
  5420. switchFlag: 0
  5421. }, {
  5422. qe: 0x1101,
  5423. nmps: 30,
  5424. nlps: 27,
  5425. switchFlag: 0
  5426. }, {
  5427. qe: 0x0AC1,
  5428. nmps: 31,
  5429. nlps: 28,
  5430. switchFlag: 0
  5431. }, {
  5432. qe: 0x09C1,
  5433. nmps: 32,
  5434. nlps: 29,
  5435. switchFlag: 0
  5436. }, {
  5437. qe: 0x08A1,
  5438. nmps: 33,
  5439. nlps: 30,
  5440. switchFlag: 0
  5441. }, {
  5442. qe: 0x0521,
  5443. nmps: 34,
  5444. nlps: 31,
  5445. switchFlag: 0
  5446. }, {
  5447. qe: 0x0441,
  5448. nmps: 35,
  5449. nlps: 32,
  5450. switchFlag: 0
  5451. }, {
  5452. qe: 0x02A1,
  5453. nmps: 36,
  5454. nlps: 33,
  5455. switchFlag: 0
  5456. }, {
  5457. qe: 0x0221,
  5458. nmps: 37,
  5459. nlps: 34,
  5460. switchFlag: 0
  5461. }, {
  5462. qe: 0x0141,
  5463. nmps: 38,
  5464. nlps: 35,
  5465. switchFlag: 0
  5466. }, {
  5467. qe: 0x0111,
  5468. nmps: 39,
  5469. nlps: 36,
  5470. switchFlag: 0
  5471. }, {
  5472. qe: 0x0085,
  5473. nmps: 40,
  5474. nlps: 37,
  5475. switchFlag: 0
  5476. }, {
  5477. qe: 0x0049,
  5478. nmps: 41,
  5479. nlps: 38,
  5480. switchFlag: 0
  5481. }, {
  5482. qe: 0x0025,
  5483. nmps: 42,
  5484. nlps: 39,
  5485. switchFlag: 0
  5486. }, {
  5487. qe: 0x0015,
  5488. nmps: 43,
  5489. nlps: 40,
  5490. switchFlag: 0
  5491. }, {
  5492. qe: 0x0009,
  5493. nmps: 44,
  5494. nlps: 41,
  5495. switchFlag: 0
  5496. }, {
  5497. qe: 0x0005,
  5498. nmps: 45,
  5499. nlps: 42,
  5500. switchFlag: 0
  5501. }, {
  5502. qe: 0x0001,
  5503. nmps: 45,
  5504. nlps: 43,
  5505. switchFlag: 0
  5506. }, {
  5507. qe: 0x5601,
  5508. nmps: 46,
  5509. nlps: 46,
  5510. switchFlag: 0
  5511. }];
  5512. var ArithmeticDecoder =
  5513. /*#__PURE__*/
  5514. function () {
  5515. function ArithmeticDecoder(data, start, end) {
  5516. _classCallCheck(this, ArithmeticDecoder);
  5517. this.data = data;
  5518. this.bp = start;
  5519. this.dataEnd = end;
  5520. this.chigh = data[start];
  5521. this.clow = 0;
  5522. this.byteIn();
  5523. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  5524. this.clow = this.clow << 7 & 0xFFFF;
  5525. this.ct -= 7;
  5526. this.a = 0x8000;
  5527. }
  5528. _createClass(ArithmeticDecoder, [{
  5529. key: "byteIn",
  5530. value: function byteIn() {
  5531. var data = this.data;
  5532. var bp = this.bp;
  5533. if (data[bp] === 0xFF) {
  5534. if (data[bp + 1] > 0x8F) {
  5535. this.clow += 0xFF00;
  5536. this.ct = 8;
  5537. } else {
  5538. bp++;
  5539. this.clow += data[bp] << 9;
  5540. this.ct = 7;
  5541. this.bp = bp;
  5542. }
  5543. } else {
  5544. bp++;
  5545. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  5546. this.ct = 8;
  5547. this.bp = bp;
  5548. }
  5549. if (this.clow > 0xFFFF) {
  5550. this.chigh += this.clow >> 16;
  5551. this.clow &= 0xFFFF;
  5552. }
  5553. }
  5554. }, {
  5555. key: "readBit",
  5556. value: function readBit(contexts, pos) {
  5557. var cx_index = contexts[pos] >> 1,
  5558. cx_mps = contexts[pos] & 1;
  5559. var qeTableIcx = QeTable[cx_index];
  5560. var qeIcx = qeTableIcx.qe;
  5561. var d;
  5562. var a = this.a - qeIcx;
  5563. if (this.chigh < qeIcx) {
  5564. if (a < qeIcx) {
  5565. a = qeIcx;
  5566. d = cx_mps;
  5567. cx_index = qeTableIcx.nmps;
  5568. } else {
  5569. a = qeIcx;
  5570. d = 1 ^ cx_mps;
  5571. if (qeTableIcx.switchFlag === 1) {
  5572. cx_mps = d;
  5573. }
  5574. cx_index = qeTableIcx.nlps;
  5575. }
  5576. } else {
  5577. this.chigh -= qeIcx;
  5578. if ((a & 0x8000) !== 0) {
  5579. this.a = a;
  5580. return cx_mps;
  5581. }
  5582. if (a < qeIcx) {
  5583. d = 1 ^ cx_mps;
  5584. if (qeTableIcx.switchFlag === 1) {
  5585. cx_mps = d;
  5586. }
  5587. cx_index = qeTableIcx.nlps;
  5588. } else {
  5589. d = cx_mps;
  5590. cx_index = qeTableIcx.nmps;
  5591. }
  5592. }
  5593. do {
  5594. if (this.ct === 0) {
  5595. this.byteIn();
  5596. }
  5597. a <<= 1;
  5598. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  5599. this.clow = this.clow << 1 & 0xFFFF;
  5600. this.ct--;
  5601. } while ((a & 0x8000) === 0);
  5602. this.a = a;
  5603. contexts[pos] = cx_index << 1 | cx_mps;
  5604. return d;
  5605. }
  5606. }]);
  5607. return ArithmeticDecoder;
  5608. }();
  5609. exports.ArithmeticDecoder = ArithmeticDecoder;
  5610. /***/ }),
  5611. /* 134 */
  5612. /***/ (function(module, exports, __w_pdfjs_require__) {
  5613. "use strict";
  5614. Object.defineProperty(exports, "__esModule", {
  5615. value: true
  5616. });
  5617. exports.CCITTFaxDecoder = void 0;
  5618. var _util = __w_pdfjs_require__(1);
  5619. var CCITTFaxDecoder = function CCITTFaxDecoder() {
  5620. var ccittEOL = -2;
  5621. var ccittEOF = -1;
  5622. var twoDimPass = 0;
  5623. var twoDimHoriz = 1;
  5624. var twoDimVert0 = 2;
  5625. var twoDimVertR1 = 3;
  5626. var twoDimVertL1 = 4;
  5627. var twoDimVertR2 = 5;
  5628. var twoDimVertL2 = 6;
  5629. var twoDimVertR3 = 7;
  5630. var twoDimVertL3 = 8;
  5631. var twoDimTable = [[-1, -1], [-1, -1], [7, twoDimVertL3], [7, twoDimVertR3], [6, twoDimVertL2], [6, twoDimVertL2], [6, twoDimVertR2], [6, twoDimVertR2], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0]];
  5632. var whiteTable1 = [[-1, -1], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [12, 1984], [12, 2048], [12, 2112], [12, 2176], [12, 2240], [12, 2304], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [12, 2368], [12, 2432], [12, 2496], [12, 2560]];
  5633. var whiteTable2 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [8, 29], [8, 29], [8, 30], [8, 30], [8, 45], [8, 45], [8, 46], [8, 46], [7, 22], [7, 22], [7, 22], [7, 22], [7, 23], [7, 23], [7, 23], [7, 23], [8, 47], [8, 47], [8, 48], [8, 48], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [7, 20], [7, 20], [7, 20], [7, 20], [8, 33], [8, 33], [8, 34], [8, 34], [8, 35], [8, 35], [8, 36], [8, 36], [8, 37], [8, 37], [8, 38], [8, 38], [7, 19], [7, 19], [7, 19], [7, 19], [8, 31], [8, 31], [8, 32], [8, 32], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [8, 53], [8, 53], [8, 54], [8, 54], [7, 26], [7, 26], [7, 26], [7, 26], [8, 39], [8, 39], [8, 40], [8, 40], [8, 41], [8, 41], [8, 42], [8, 42], [8, 43], [8, 43], [8, 44], [8, 44], [7, 21], [7, 21], [7, 21], [7, 21], [7, 28], [7, 28], [7, 28], [7, 28], [8, 61], [8, 61], [8, 62], [8, 62], [8, 63], [8, 63], [8, 0], [8, 0], [8, 320], [8, 320], [8, 384], [8, 384], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [7, 27], [7, 27], [7, 27], [7, 27], [8, 59], [8, 59], [8, 60], [8, 60], [9, 1472], [9, 1536], [9, 1600], [9, 1728], [7, 18], [7, 18], [7, 18], [7, 18], [7, 24], [7, 24], [7, 24], [7, 24], [8, 49], [8, 49], [8, 50], [8, 50], [8, 51], [8, 51], [8, 52], [8, 52], [7, 25], [7, 25], [7, 25], [7, 25], [8, 55], [8, 55], [8, 56], [8, 56], [8, 57], [8, 57], [8, 58], [8, 58], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [8, 448], [8, 448], [8, 512], [8, 512], [9, 704], [9, 768], [8, 640], [8, 640], [8, 576], [8, 576], [9, 832], [9, 896], [9, 960], [9, 1024], [9, 1088], [9, 1152], [9, 1216], [9, 1280], [9, 1344], [9, 1408], [7, 256], [7, 256], [7, 256], [7, 256], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7]];
  5634. var blackTable1 = [[-1, -1], [-1, -1], [12, ccittEOL], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [11, 1792], [11, 1792], [12, 1984], [12, 1984], [12, 2048], [12, 2048], [12, 2112], [12, 2112], [12, 2176], [12, 2176], [12, 2240], [12, 2240], [12, 2304], [12, 2304], [11, 1856], [11, 1856], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [11, 1920], [11, 1920], [12, 2368], [12, 2368], [12, 2432], [12, 2432], [12, 2496], [12, 2496], [12, 2560], [12, 2560], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [12, 52], [12, 52], [13, 640], [13, 704], [13, 768], [13, 832], [12, 55], [12, 55], [12, 56], [12, 56], [13, 1280], [13, 1344], [13, 1408], [13, 1472], [12, 59], [12, 59], [12, 60], [12, 60], [13, 1536], [13, 1600], [11, 24], [11, 24], [11, 24], [11, 24], [11, 25], [11, 25], [11, 25], [11, 25], [13, 1664], [13, 1728], [12, 320], [12, 320], [12, 384], [12, 384], [12, 448], [12, 448], [13, 512], [13, 576], [12, 53], [12, 53], [12, 54], [12, 54], [13, 896], [13, 960], [13, 1024], [13, 1088], [13, 1152], [13, 1216], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64]];
  5635. var blackTable2 = [[8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [11, 23], [11, 23], [12, 50], [12, 51], [12, 44], [12, 45], [12, 46], [12, 47], [12, 57], [12, 58], [12, 61], [12, 256], [10, 16], [10, 16], [10, 16], [10, 16], [10, 17], [10, 17], [10, 17], [10, 17], [12, 48], [12, 49], [12, 62], [12, 63], [12, 30], [12, 31], [12, 32], [12, 33], [12, 40], [12, 41], [11, 22], [11, 22], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [12, 128], [12, 192], [12, 26], [12, 27], [12, 28], [12, 29], [11, 19], [11, 19], [11, 20], [11, 20], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [11, 21], [11, 21], [12, 42], [12, 43], [10, 0], [10, 0], [10, 0], [10, 0], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12]];
  5636. var blackTable3 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [6, 9], [6, 8], [5, 7], [5, 7], [4, 6], [4, 6], [4, 6], [4, 6], [4, 5], [4, 5], [4, 5], [4, 5], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]];
  5637. function CCITTFaxDecoder(source) {
  5638. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5639. if (!source || typeof source.next !== 'function') {
  5640. throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
  5641. }
  5642. this.source = source;
  5643. this.eof = false;
  5644. this.encoding = options['K'] || 0;
  5645. this.eoline = options['EndOfLine'] || false;
  5646. this.byteAlign = options['EncodedByteAlign'] || false;
  5647. this.columns = options['Columns'] || 1728;
  5648. this.rows = options['Rows'] || 0;
  5649. var eoblock = options['EndOfBlock'];
  5650. if (eoblock === null || eoblock === undefined) {
  5651. eoblock = true;
  5652. }
  5653. this.eoblock = eoblock;
  5654. this.black = options['BlackIs1'] || false;
  5655. this.codingLine = new Uint32Array(this.columns + 1);
  5656. this.refLine = new Uint32Array(this.columns + 2);
  5657. this.codingLine[0] = this.columns;
  5658. this.codingPos = 0;
  5659. this.row = 0;
  5660. this.nextLine2D = this.encoding < 0;
  5661. this.inputBits = 0;
  5662. this.inputBuf = 0;
  5663. this.outputBits = 0;
  5664. this.rowsDone = false;
  5665. var code1;
  5666. while ((code1 = this._lookBits(12)) === 0) {
  5667. this._eatBits(1);
  5668. }
  5669. if (code1 === 1) {
  5670. this._eatBits(12);
  5671. }
  5672. if (this.encoding > 0) {
  5673. this.nextLine2D = !this._lookBits(1);
  5674. this._eatBits(1);
  5675. }
  5676. }
  5677. CCITTFaxDecoder.prototype = {
  5678. readNextChar: function readNextChar() {
  5679. if (this.eof) {
  5680. return -1;
  5681. }
  5682. var refLine = this.refLine;
  5683. var codingLine = this.codingLine;
  5684. var columns = this.columns;
  5685. var refPos, blackPixels, bits, i;
  5686. if (this.outputBits === 0) {
  5687. if (this.rowsDone) {
  5688. this.eof = true;
  5689. }
  5690. if (this.eof) {
  5691. return -1;
  5692. }
  5693. this.err = false;
  5694. var code1, code2, code3;
  5695. if (this.nextLine2D) {
  5696. for (i = 0; codingLine[i] < columns; ++i) {
  5697. refLine[i] = codingLine[i];
  5698. }
  5699. refLine[i++] = columns;
  5700. refLine[i] = columns;
  5701. codingLine[0] = 0;
  5702. this.codingPos = 0;
  5703. refPos = 0;
  5704. blackPixels = 0;
  5705. while (codingLine[this.codingPos] < columns) {
  5706. code1 = this._getTwoDimCode();
  5707. switch (code1) {
  5708. case twoDimPass:
  5709. this._addPixels(refLine[refPos + 1], blackPixels);
  5710. if (refLine[refPos + 1] < columns) {
  5711. refPos += 2;
  5712. }
  5713. break;
  5714. case twoDimHoriz:
  5715. code1 = code2 = 0;
  5716. if (blackPixels) {
  5717. do {
  5718. code1 += code3 = this._getBlackCode();
  5719. } while (code3 >= 64);
  5720. do {
  5721. code2 += code3 = this._getWhiteCode();
  5722. } while (code3 >= 64);
  5723. } else {
  5724. do {
  5725. code1 += code3 = this._getWhiteCode();
  5726. } while (code3 >= 64);
  5727. do {
  5728. code2 += code3 = this._getBlackCode();
  5729. } while (code3 >= 64);
  5730. }
  5731. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  5732. if (codingLine[this.codingPos] < columns) {
  5733. this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  5734. }
  5735. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5736. refPos += 2;
  5737. }
  5738. break;
  5739. case twoDimVertR3:
  5740. this._addPixels(refLine[refPos] + 3, blackPixels);
  5741. blackPixels ^= 1;
  5742. if (codingLine[this.codingPos] < columns) {
  5743. ++refPos;
  5744. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5745. refPos += 2;
  5746. }
  5747. }
  5748. break;
  5749. case twoDimVertR2:
  5750. this._addPixels(refLine[refPos] + 2, blackPixels);
  5751. blackPixels ^= 1;
  5752. if (codingLine[this.codingPos] < columns) {
  5753. ++refPos;
  5754. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5755. refPos += 2;
  5756. }
  5757. }
  5758. break;
  5759. case twoDimVertR1:
  5760. this._addPixels(refLine[refPos] + 1, blackPixels);
  5761. blackPixels ^= 1;
  5762. if (codingLine[this.codingPos] < columns) {
  5763. ++refPos;
  5764. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5765. refPos += 2;
  5766. }
  5767. }
  5768. break;
  5769. case twoDimVert0:
  5770. this._addPixels(refLine[refPos], blackPixels);
  5771. blackPixels ^= 1;
  5772. if (codingLine[this.codingPos] < columns) {
  5773. ++refPos;
  5774. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5775. refPos += 2;
  5776. }
  5777. }
  5778. break;
  5779. case twoDimVertL3:
  5780. this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
  5781. blackPixels ^= 1;
  5782. if (codingLine[this.codingPos] < columns) {
  5783. if (refPos > 0) {
  5784. --refPos;
  5785. } else {
  5786. ++refPos;
  5787. }
  5788. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5789. refPos += 2;
  5790. }
  5791. }
  5792. break;
  5793. case twoDimVertL2:
  5794. this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
  5795. blackPixels ^= 1;
  5796. if (codingLine[this.codingPos] < columns) {
  5797. if (refPos > 0) {
  5798. --refPos;
  5799. } else {
  5800. ++refPos;
  5801. }
  5802. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5803. refPos += 2;
  5804. }
  5805. }
  5806. break;
  5807. case twoDimVertL1:
  5808. this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
  5809. blackPixels ^= 1;
  5810. if (codingLine[this.codingPos] < columns) {
  5811. if (refPos > 0) {
  5812. --refPos;
  5813. } else {
  5814. ++refPos;
  5815. }
  5816. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  5817. refPos += 2;
  5818. }
  5819. }
  5820. break;
  5821. case ccittEOF:
  5822. this._addPixels(columns, 0);
  5823. this.eof = true;
  5824. break;
  5825. default:
  5826. (0, _util.info)('bad 2d code');
  5827. this._addPixels(columns, 0);
  5828. this.err = true;
  5829. }
  5830. }
  5831. } else {
  5832. codingLine[0] = 0;
  5833. this.codingPos = 0;
  5834. blackPixels = 0;
  5835. while (codingLine[this.codingPos] < columns) {
  5836. code1 = 0;
  5837. if (blackPixels) {
  5838. do {
  5839. code1 += code3 = this._getBlackCode();
  5840. } while (code3 >= 64);
  5841. } else {
  5842. do {
  5843. code1 += code3 = this._getWhiteCode();
  5844. } while (code3 >= 64);
  5845. }
  5846. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  5847. blackPixels ^= 1;
  5848. }
  5849. }
  5850. var gotEOL = false;
  5851. if (this.byteAlign) {
  5852. this.inputBits &= ~7;
  5853. }
  5854. if (!this.eoblock && this.row === this.rows - 1) {
  5855. this.rowsDone = true;
  5856. } else {
  5857. code1 = this._lookBits(12);
  5858. if (this.eoline) {
  5859. while (code1 !== ccittEOF && code1 !== 1) {
  5860. this._eatBits(1);
  5861. code1 = this._lookBits(12);
  5862. }
  5863. } else {
  5864. while (code1 === 0) {
  5865. this._eatBits(1);
  5866. code1 = this._lookBits(12);
  5867. }
  5868. }
  5869. if (code1 === 1) {
  5870. this._eatBits(12);
  5871. gotEOL = true;
  5872. } else if (code1 === ccittEOF) {
  5873. this.eof = true;
  5874. }
  5875. }
  5876. if (!this.eof && this.encoding > 0 && !this.rowsDone) {
  5877. this.nextLine2D = !this._lookBits(1);
  5878. this._eatBits(1);
  5879. }
  5880. if (this.eoblock && gotEOL && this.byteAlign) {
  5881. code1 = this._lookBits(12);
  5882. if (code1 === 1) {
  5883. this._eatBits(12);
  5884. if (this.encoding > 0) {
  5885. this._lookBits(1);
  5886. this._eatBits(1);
  5887. }
  5888. if (this.encoding >= 0) {
  5889. for (i = 0; i < 4; ++i) {
  5890. code1 = this._lookBits(12);
  5891. if (code1 !== 1) {
  5892. (0, _util.info)('bad rtc code: ' + code1);
  5893. }
  5894. this._eatBits(12);
  5895. if (this.encoding > 0) {
  5896. this._lookBits(1);
  5897. this._eatBits(1);
  5898. }
  5899. }
  5900. }
  5901. this.eof = true;
  5902. }
  5903. } else if (this.err && this.eoline) {
  5904. while (true) {
  5905. code1 = this._lookBits(13);
  5906. if (code1 === ccittEOF) {
  5907. this.eof = true;
  5908. return -1;
  5909. }
  5910. if (code1 >> 1 === 1) {
  5911. break;
  5912. }
  5913. this._eatBits(1);
  5914. }
  5915. this._eatBits(12);
  5916. if (this.encoding > 0) {
  5917. this._eatBits(1);
  5918. this.nextLine2D = !(code1 & 1);
  5919. }
  5920. }
  5921. if (codingLine[0] > 0) {
  5922. this.outputBits = codingLine[this.codingPos = 0];
  5923. } else {
  5924. this.outputBits = codingLine[this.codingPos = 1];
  5925. }
  5926. this.row++;
  5927. }
  5928. var c;
  5929. if (this.outputBits >= 8) {
  5930. c = this.codingPos & 1 ? 0 : 0xFF;
  5931. this.outputBits -= 8;
  5932. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  5933. this.codingPos++;
  5934. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  5935. }
  5936. } else {
  5937. bits = 8;
  5938. c = 0;
  5939. do {
  5940. if (this.outputBits > bits) {
  5941. c <<= bits;
  5942. if (!(this.codingPos & 1)) {
  5943. c |= 0xFF >> 8 - bits;
  5944. }
  5945. this.outputBits -= bits;
  5946. bits = 0;
  5947. } else {
  5948. c <<= this.outputBits;
  5949. if (!(this.codingPos & 1)) {
  5950. c |= 0xFF >> 8 - this.outputBits;
  5951. }
  5952. bits -= this.outputBits;
  5953. this.outputBits = 0;
  5954. if (codingLine[this.codingPos] < columns) {
  5955. this.codingPos++;
  5956. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  5957. } else if (bits > 0) {
  5958. c <<= bits;
  5959. bits = 0;
  5960. }
  5961. }
  5962. } while (bits);
  5963. }
  5964. if (this.black) {
  5965. c ^= 0xFF;
  5966. }
  5967. return c;
  5968. },
  5969. _addPixels: function _addPixels(a1, blackPixels) {
  5970. var codingLine = this.codingLine;
  5971. var codingPos = this.codingPos;
  5972. if (a1 > codingLine[codingPos]) {
  5973. if (a1 > this.columns) {
  5974. (0, _util.info)('row is wrong length');
  5975. this.err = true;
  5976. a1 = this.columns;
  5977. }
  5978. if (codingPos & 1 ^ blackPixels) {
  5979. ++codingPos;
  5980. }
  5981. codingLine[codingPos] = a1;
  5982. }
  5983. this.codingPos = codingPos;
  5984. },
  5985. _addPixelsNeg: function _addPixelsNeg(a1, blackPixels) {
  5986. var codingLine = this.codingLine;
  5987. var codingPos = this.codingPos;
  5988. if (a1 > codingLine[codingPos]) {
  5989. if (a1 > this.columns) {
  5990. (0, _util.info)('row is wrong length');
  5991. this.err = true;
  5992. a1 = this.columns;
  5993. }
  5994. if (codingPos & 1 ^ blackPixels) {
  5995. ++codingPos;
  5996. }
  5997. codingLine[codingPos] = a1;
  5998. } else if (a1 < codingLine[codingPos]) {
  5999. if (a1 < 0) {
  6000. (0, _util.info)('invalid code');
  6001. this.err = true;
  6002. a1 = 0;
  6003. }
  6004. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  6005. --codingPos;
  6006. }
  6007. codingLine[codingPos] = a1;
  6008. }
  6009. this.codingPos = codingPos;
  6010. },
  6011. _findTableCode: function _findTableCode(start, end, table, limit) {
  6012. var limitValue = limit || 0;
  6013. for (var i = start; i <= end; ++i) {
  6014. var code = this._lookBits(i);
  6015. if (code === ccittEOF) {
  6016. return [true, 1, false];
  6017. }
  6018. if (i < end) {
  6019. code <<= end - i;
  6020. }
  6021. if (!limitValue || code >= limitValue) {
  6022. var p = table[code - limitValue];
  6023. if (p[0] === i) {
  6024. this._eatBits(i);
  6025. return [true, p[1], true];
  6026. }
  6027. }
  6028. }
  6029. return [false, 0, false];
  6030. },
  6031. _getTwoDimCode: function _getTwoDimCode() {
  6032. var code = 0;
  6033. var p;
  6034. if (this.eoblock) {
  6035. code = this._lookBits(7);
  6036. p = twoDimTable[code];
  6037. if (p && p[0] > 0) {
  6038. this._eatBits(p[0]);
  6039. return p[1];
  6040. }
  6041. } else {
  6042. var result = this._findTableCode(1, 7, twoDimTable);
  6043. if (result[0] && result[2]) {
  6044. return result[1];
  6045. }
  6046. }
  6047. (0, _util.info)('Bad two dim code');
  6048. return ccittEOF;
  6049. },
  6050. _getWhiteCode: function _getWhiteCode() {
  6051. var code = 0;
  6052. var p;
  6053. if (this.eoblock) {
  6054. code = this._lookBits(12);
  6055. if (code === ccittEOF) {
  6056. return 1;
  6057. }
  6058. if (code >> 5 === 0) {
  6059. p = whiteTable1[code];
  6060. } else {
  6061. p = whiteTable2[code >> 3];
  6062. }
  6063. if (p[0] > 0) {
  6064. this._eatBits(p[0]);
  6065. return p[1];
  6066. }
  6067. } else {
  6068. var result = this._findTableCode(1, 9, whiteTable2);
  6069. if (result[0]) {
  6070. return result[1];
  6071. }
  6072. result = this._findTableCode(11, 12, whiteTable1);
  6073. if (result[0]) {
  6074. return result[1];
  6075. }
  6076. }
  6077. (0, _util.info)('bad white code');
  6078. this._eatBits(1);
  6079. return 1;
  6080. },
  6081. _getBlackCode: function _getBlackCode() {
  6082. var code, p;
  6083. if (this.eoblock) {
  6084. code = this._lookBits(13);
  6085. if (code === ccittEOF) {
  6086. return 1;
  6087. }
  6088. if (code >> 7 === 0) {
  6089. p = blackTable1[code];
  6090. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  6091. p = blackTable2[(code >> 1) - 64];
  6092. } else {
  6093. p = blackTable3[code >> 7];
  6094. }
  6095. if (p[0] > 0) {
  6096. this._eatBits(p[0]);
  6097. return p[1];
  6098. }
  6099. } else {
  6100. var result = this._findTableCode(2, 6, blackTable3);
  6101. if (result[0]) {
  6102. return result[1];
  6103. }
  6104. result = this._findTableCode(7, 12, blackTable2, 64);
  6105. if (result[0]) {
  6106. return result[1];
  6107. }
  6108. result = this._findTableCode(10, 13, blackTable1);
  6109. if (result[0]) {
  6110. return result[1];
  6111. }
  6112. }
  6113. (0, _util.info)('bad black code');
  6114. this._eatBits(1);
  6115. return 1;
  6116. },
  6117. _lookBits: function _lookBits(n) {
  6118. var c;
  6119. while (this.inputBits < n) {
  6120. if ((c = this.source.next()) === -1) {
  6121. if (this.inputBits === 0) {
  6122. return ccittEOF;
  6123. }
  6124. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  6125. }
  6126. this.inputBuf = this.inputBuf << 8 | c;
  6127. this.inputBits += 8;
  6128. }
  6129. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  6130. },
  6131. _eatBits: function _eatBits(n) {
  6132. if ((this.inputBits -= n) < 0) {
  6133. this.inputBits = 0;
  6134. }
  6135. }
  6136. };
  6137. return CCITTFaxDecoder;
  6138. }();
  6139. exports.CCITTFaxDecoder = CCITTFaxDecoder;
  6140. /***/ }),
  6141. /* 135 */
  6142. /***/ (function(module, exports, __w_pdfjs_require__) {
  6143. "use strict";
  6144. Object.defineProperty(exports, "__esModule", {
  6145. value: true
  6146. });
  6147. exports.JpegImage = void 0;
  6148. var _util = __w_pdfjs_require__(1);
  6149. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6150. var JpegError = function JpegErrorClosure() {
  6151. function JpegError(msg) {
  6152. this.message = 'JPEG error: ' + msg;
  6153. }
  6154. JpegError.prototype = new Error();
  6155. JpegError.prototype.name = 'JpegError';
  6156. JpegError.constructor = JpegError;
  6157. return JpegError;
  6158. }();
  6159. var DNLMarkerError = function DNLMarkerErrorClosure() {
  6160. function DNLMarkerError(message, scanLines) {
  6161. this.message = message;
  6162. this.scanLines = scanLines;
  6163. }
  6164. DNLMarkerError.prototype = new Error();
  6165. DNLMarkerError.prototype.name = 'DNLMarkerError';
  6166. DNLMarkerError.constructor = DNLMarkerError;
  6167. return DNLMarkerError;
  6168. }();
  6169. var EOIMarkerError = function EOIMarkerErrorClosure() {
  6170. function EOIMarkerError(message) {
  6171. this.message = message;
  6172. }
  6173. EOIMarkerError.prototype = new Error();
  6174. EOIMarkerError.prototype.name = 'EOIMarkerError';
  6175. EOIMarkerError.constructor = EOIMarkerError;
  6176. return EOIMarkerError;
  6177. }();
  6178. var JpegImage = function JpegImageClosure() {
  6179. var dctZigZag = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]);
  6180. var dctCos1 = 4017;
  6181. var dctSin1 = 799;
  6182. var dctCos3 = 3406;
  6183. var dctSin3 = 2276;
  6184. var dctCos6 = 1567;
  6185. var dctSin6 = 3784;
  6186. var dctSqrt2 = 5793;
  6187. var dctSqrt1d2 = 2896;
  6188. function JpegImage() {
  6189. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6190. _ref$decodeTransform = _ref.decodeTransform,
  6191. decodeTransform = _ref$decodeTransform === void 0 ? null : _ref$decodeTransform,
  6192. _ref$colorTransform = _ref.colorTransform,
  6193. colorTransform = _ref$colorTransform === void 0 ? -1 : _ref$colorTransform;
  6194. this._decodeTransform = decodeTransform;
  6195. this._colorTransform = colorTransform;
  6196. }
  6197. function buildHuffmanTable(codeLengths, values) {
  6198. var k = 0,
  6199. code = [],
  6200. i,
  6201. j,
  6202. length = 16;
  6203. while (length > 0 && !codeLengths[length - 1]) {
  6204. length--;
  6205. }
  6206. code.push({
  6207. children: [],
  6208. index: 0
  6209. });
  6210. var p = code[0],
  6211. q;
  6212. for (i = 0; i < length; i++) {
  6213. for (j = 0; j < codeLengths[i]; j++) {
  6214. p = code.pop();
  6215. p.children[p.index] = values[k];
  6216. while (p.index > 0) {
  6217. p = code.pop();
  6218. }
  6219. p.index++;
  6220. code.push(p);
  6221. while (code.length <= i) {
  6222. code.push(q = {
  6223. children: [],
  6224. index: 0
  6225. });
  6226. p.children[p.index] = q.children;
  6227. p = q;
  6228. }
  6229. k++;
  6230. }
  6231. if (i + 1 < length) {
  6232. code.push(q = {
  6233. children: [],
  6234. index: 0
  6235. });
  6236. p.children[p.index] = q.children;
  6237. p = q;
  6238. }
  6239. }
  6240. return code[0].children;
  6241. }
  6242. function getBlockBufferOffset(component, row, col) {
  6243. return 64 * ((component.blocksPerLine + 1) * row + col);
  6244. }
  6245. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  6246. var parseDNLMarker = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
  6247. var mcusPerLine = frame.mcusPerLine;
  6248. var progressive = frame.progressive;
  6249. var startOffset = offset,
  6250. bitsData = 0,
  6251. bitsCount = 0;
  6252. function readBit() {
  6253. if (bitsCount > 0) {
  6254. bitsCount--;
  6255. return bitsData >> bitsCount & 1;
  6256. }
  6257. bitsData = data[offset++];
  6258. if (bitsData === 0xFF) {
  6259. var nextByte = data[offset++];
  6260. if (nextByte) {
  6261. if (nextByte === 0xDC && parseDNLMarker) {
  6262. offset += 2;
  6263. var scanLines = data[offset++] << 8 | data[offset++];
  6264. if (scanLines > 0 && scanLines !== frame.scanLines) {
  6265. throw new DNLMarkerError('Found DNL marker (0xFFDC) while parsing scan data', scanLines);
  6266. }
  6267. } else if (nextByte === 0xD9) {
  6268. throw new EOIMarkerError('Found EOI marker (0xFFD9) while parsing scan data');
  6269. }
  6270. throw new JpegError("unexpected marker ".concat((bitsData << 8 | nextByte).toString(16)));
  6271. }
  6272. }
  6273. bitsCount = 7;
  6274. return bitsData >>> 7;
  6275. }
  6276. function decodeHuffman(tree) {
  6277. var node = tree;
  6278. while (true) {
  6279. node = node[readBit()];
  6280. if (typeof node === 'number') {
  6281. return node;
  6282. }
  6283. if (_typeof(node) !== 'object') {
  6284. throw new JpegError('invalid huffman sequence');
  6285. }
  6286. }
  6287. }
  6288. function receive(length) {
  6289. var n = 0;
  6290. while (length > 0) {
  6291. n = n << 1 | readBit();
  6292. length--;
  6293. }
  6294. return n;
  6295. }
  6296. function receiveAndExtend(length) {
  6297. if (length === 1) {
  6298. return readBit() === 1 ? 1 : -1;
  6299. }
  6300. var n = receive(length);
  6301. if (n >= 1 << length - 1) {
  6302. return n;
  6303. }
  6304. return n + (-1 << length) + 1;
  6305. }
  6306. function decodeBaseline(component, offset) {
  6307. var t = decodeHuffman(component.huffmanTableDC);
  6308. var diff = t === 0 ? 0 : receiveAndExtend(t);
  6309. component.blockData[offset] = component.pred += diff;
  6310. var k = 1;
  6311. while (k < 64) {
  6312. var rs = decodeHuffman(component.huffmanTableAC);
  6313. var s = rs & 15,
  6314. r = rs >> 4;
  6315. if (s === 0) {
  6316. if (r < 15) {
  6317. break;
  6318. }
  6319. k += 16;
  6320. continue;
  6321. }
  6322. k += r;
  6323. var z = dctZigZag[k];
  6324. component.blockData[offset + z] = receiveAndExtend(s);
  6325. k++;
  6326. }
  6327. }
  6328. function decodeDCFirst(component, offset) {
  6329. var t = decodeHuffman(component.huffmanTableDC);
  6330. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  6331. component.blockData[offset] = component.pred += diff;
  6332. }
  6333. function decodeDCSuccessive(component, offset) {
  6334. component.blockData[offset] |= readBit() << successive;
  6335. }
  6336. var eobrun = 0;
  6337. function decodeACFirst(component, offset) {
  6338. if (eobrun > 0) {
  6339. eobrun--;
  6340. return;
  6341. }
  6342. var k = spectralStart,
  6343. e = spectralEnd;
  6344. while (k <= e) {
  6345. var rs = decodeHuffman(component.huffmanTableAC);
  6346. var s = rs & 15,
  6347. r = rs >> 4;
  6348. if (s === 0) {
  6349. if (r < 15) {
  6350. eobrun = receive(r) + (1 << r) - 1;
  6351. break;
  6352. }
  6353. k += 16;
  6354. continue;
  6355. }
  6356. k += r;
  6357. var z = dctZigZag[k];
  6358. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  6359. k++;
  6360. }
  6361. }
  6362. var successiveACState = 0,
  6363. successiveACNextValue;
  6364. function decodeACSuccessive(component, offset) {
  6365. var k = spectralStart;
  6366. var e = spectralEnd;
  6367. var r = 0;
  6368. var s;
  6369. var rs;
  6370. while (k <= e) {
  6371. var offsetZ = offset + dctZigZag[k];
  6372. var sign = component.blockData[offsetZ] < 0 ? -1 : 1;
  6373. switch (successiveACState) {
  6374. case 0:
  6375. rs = decodeHuffman(component.huffmanTableAC);
  6376. s = rs & 15;
  6377. r = rs >> 4;
  6378. if (s === 0) {
  6379. if (r < 15) {
  6380. eobrun = receive(r) + (1 << r);
  6381. successiveACState = 4;
  6382. } else {
  6383. r = 16;
  6384. successiveACState = 1;
  6385. }
  6386. } else {
  6387. if (s !== 1) {
  6388. throw new JpegError('invalid ACn encoding');
  6389. }
  6390. successiveACNextValue = receiveAndExtend(s);
  6391. successiveACState = r ? 2 : 3;
  6392. }
  6393. continue;
  6394. case 1:
  6395. case 2:
  6396. if (component.blockData[offsetZ]) {
  6397. component.blockData[offsetZ] += sign * (readBit() << successive);
  6398. } else {
  6399. r--;
  6400. if (r === 0) {
  6401. successiveACState = successiveACState === 2 ? 3 : 0;
  6402. }
  6403. }
  6404. break;
  6405. case 3:
  6406. if (component.blockData[offsetZ]) {
  6407. component.blockData[offsetZ] += sign * (readBit() << successive);
  6408. } else {
  6409. component.blockData[offsetZ] = successiveACNextValue << successive;
  6410. successiveACState = 0;
  6411. }
  6412. break;
  6413. case 4:
  6414. if (component.blockData[offsetZ]) {
  6415. component.blockData[offsetZ] += sign * (readBit() << successive);
  6416. }
  6417. break;
  6418. }
  6419. k++;
  6420. }
  6421. if (successiveACState === 4) {
  6422. eobrun--;
  6423. if (eobrun === 0) {
  6424. successiveACState = 0;
  6425. }
  6426. }
  6427. }
  6428. function decodeMcu(component, decode, mcu, row, col) {
  6429. var mcuRow = mcu / mcusPerLine | 0;
  6430. var mcuCol = mcu % mcusPerLine;
  6431. var blockRow = mcuRow * component.v + row;
  6432. var blockCol = mcuCol * component.h + col;
  6433. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  6434. decode(component, offset);
  6435. }
  6436. function decodeBlock(component, decode, mcu) {
  6437. var blockRow = mcu / component.blocksPerLine | 0;
  6438. var blockCol = mcu % component.blocksPerLine;
  6439. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  6440. decode(component, offset);
  6441. }
  6442. var componentsLength = components.length;
  6443. var component, i, j, k, n;
  6444. var decodeFn;
  6445. if (progressive) {
  6446. if (spectralStart === 0) {
  6447. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  6448. } else {
  6449. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  6450. }
  6451. } else {
  6452. decodeFn = decodeBaseline;
  6453. }
  6454. var mcu = 0,
  6455. fileMarker;
  6456. var mcuExpected;
  6457. if (componentsLength === 1) {
  6458. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  6459. } else {
  6460. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  6461. }
  6462. var h, v;
  6463. while (mcu < mcuExpected) {
  6464. var mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  6465. for (i = 0; i < componentsLength; i++) {
  6466. components[i].pred = 0;
  6467. }
  6468. eobrun = 0;
  6469. if (componentsLength === 1) {
  6470. component = components[0];
  6471. for (n = 0; n < mcuToRead; n++) {
  6472. decodeBlock(component, decodeFn, mcu);
  6473. mcu++;
  6474. }
  6475. } else {
  6476. for (n = 0; n < mcuToRead; n++) {
  6477. for (i = 0; i < componentsLength; i++) {
  6478. component = components[i];
  6479. h = component.h;
  6480. v = component.v;
  6481. for (j = 0; j < v; j++) {
  6482. for (k = 0; k < h; k++) {
  6483. decodeMcu(component, decodeFn, mcu, j, k);
  6484. }
  6485. }
  6486. }
  6487. mcu++;
  6488. }
  6489. }
  6490. bitsCount = 0;
  6491. fileMarker = findNextFileMarker(data, offset);
  6492. if (fileMarker && fileMarker.invalid) {
  6493. (0, _util.warn)('decodeScan - unexpected MCU data, current marker is: ' + fileMarker.invalid);
  6494. offset = fileMarker.offset;
  6495. }
  6496. var marker = fileMarker && fileMarker.marker;
  6497. if (!marker || marker <= 0xFF00) {
  6498. throw new JpegError('marker was not found');
  6499. }
  6500. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  6501. offset += 2;
  6502. } else {
  6503. break;
  6504. }
  6505. }
  6506. fileMarker = findNextFileMarker(data, offset);
  6507. if (fileMarker && fileMarker.invalid) {
  6508. (0, _util.warn)('decodeScan - unexpected Scan data, current marker is: ' + fileMarker.invalid);
  6509. offset = fileMarker.offset;
  6510. }
  6511. return offset - startOffset;
  6512. }
  6513. function quantizeAndInverse(component, blockBufferOffset, p) {
  6514. var qt = component.quantizationTable,
  6515. blockData = component.blockData;
  6516. var v0, v1, v2, v3, v4, v5, v6, v7;
  6517. var p0, p1, p2, p3, p4, p5, p6, p7;
  6518. var t;
  6519. if (!qt) {
  6520. throw new JpegError('missing required Quantization Table.');
  6521. }
  6522. for (var row = 0; row < 64; row += 8) {
  6523. p0 = blockData[blockBufferOffset + row];
  6524. p1 = blockData[blockBufferOffset + row + 1];
  6525. p2 = blockData[blockBufferOffset + row + 2];
  6526. p3 = blockData[blockBufferOffset + row + 3];
  6527. p4 = blockData[blockBufferOffset + row + 4];
  6528. p5 = blockData[blockBufferOffset + row + 5];
  6529. p6 = blockData[blockBufferOffset + row + 6];
  6530. p7 = blockData[blockBufferOffset + row + 7];
  6531. p0 *= qt[row];
  6532. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  6533. t = dctSqrt2 * p0 + 512 >> 10;
  6534. p[row] = t;
  6535. p[row + 1] = t;
  6536. p[row + 2] = t;
  6537. p[row + 3] = t;
  6538. p[row + 4] = t;
  6539. p[row + 5] = t;
  6540. p[row + 6] = t;
  6541. p[row + 7] = t;
  6542. continue;
  6543. }
  6544. p1 *= qt[row + 1];
  6545. p2 *= qt[row + 2];
  6546. p3 *= qt[row + 3];
  6547. p4 *= qt[row + 4];
  6548. p5 *= qt[row + 5];
  6549. p6 *= qt[row + 6];
  6550. p7 *= qt[row + 7];
  6551. v0 = dctSqrt2 * p0 + 128 >> 8;
  6552. v1 = dctSqrt2 * p4 + 128 >> 8;
  6553. v2 = p2;
  6554. v3 = p6;
  6555. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  6556. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  6557. v5 = p3 << 4;
  6558. v6 = p5 << 4;
  6559. v0 = v0 + v1 + 1 >> 1;
  6560. v1 = v0 - v1;
  6561. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  6562. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  6563. v3 = t;
  6564. v4 = v4 + v6 + 1 >> 1;
  6565. v6 = v4 - v6;
  6566. v7 = v7 + v5 + 1 >> 1;
  6567. v5 = v7 - v5;
  6568. v0 = v0 + v3 + 1 >> 1;
  6569. v3 = v0 - v3;
  6570. v1 = v1 + v2 + 1 >> 1;
  6571. v2 = v1 - v2;
  6572. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  6573. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  6574. v7 = t;
  6575. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  6576. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  6577. v6 = t;
  6578. p[row] = v0 + v7;
  6579. p[row + 7] = v0 - v7;
  6580. p[row + 1] = v1 + v6;
  6581. p[row + 6] = v1 - v6;
  6582. p[row + 2] = v2 + v5;
  6583. p[row + 5] = v2 - v5;
  6584. p[row + 3] = v3 + v4;
  6585. p[row + 4] = v3 - v4;
  6586. }
  6587. for (var col = 0; col < 8; ++col) {
  6588. p0 = p[col];
  6589. p1 = p[col + 8];
  6590. p2 = p[col + 16];
  6591. p3 = p[col + 24];
  6592. p4 = p[col + 32];
  6593. p5 = p[col + 40];
  6594. p6 = p[col + 48];
  6595. p7 = p[col + 56];
  6596. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  6597. t = dctSqrt2 * p0 + 8192 >> 14;
  6598. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  6599. blockData[blockBufferOffset + col] = t;
  6600. blockData[blockBufferOffset + col + 8] = t;
  6601. blockData[blockBufferOffset + col + 16] = t;
  6602. blockData[blockBufferOffset + col + 24] = t;
  6603. blockData[blockBufferOffset + col + 32] = t;
  6604. blockData[blockBufferOffset + col + 40] = t;
  6605. blockData[blockBufferOffset + col + 48] = t;
  6606. blockData[blockBufferOffset + col + 56] = t;
  6607. continue;
  6608. }
  6609. v0 = dctSqrt2 * p0 + 2048 >> 12;
  6610. v1 = dctSqrt2 * p4 + 2048 >> 12;
  6611. v2 = p2;
  6612. v3 = p6;
  6613. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  6614. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  6615. v5 = p3;
  6616. v6 = p5;
  6617. v0 = (v0 + v1 + 1 >> 1) + 4112;
  6618. v1 = v0 - v1;
  6619. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  6620. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  6621. v3 = t;
  6622. v4 = v4 + v6 + 1 >> 1;
  6623. v6 = v4 - v6;
  6624. v7 = v7 + v5 + 1 >> 1;
  6625. v5 = v7 - v5;
  6626. v0 = v0 + v3 + 1 >> 1;
  6627. v3 = v0 - v3;
  6628. v1 = v1 + v2 + 1 >> 1;
  6629. v2 = v1 - v2;
  6630. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  6631. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  6632. v7 = t;
  6633. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  6634. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  6635. v6 = t;
  6636. p0 = v0 + v7;
  6637. p7 = v0 - v7;
  6638. p1 = v1 + v6;
  6639. p6 = v1 - v6;
  6640. p2 = v2 + v5;
  6641. p5 = v2 - v5;
  6642. p3 = v3 + v4;
  6643. p4 = v3 - v4;
  6644. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  6645. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  6646. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  6647. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  6648. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  6649. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  6650. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  6651. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  6652. blockData[blockBufferOffset + col] = p0;
  6653. blockData[blockBufferOffset + col + 8] = p1;
  6654. blockData[blockBufferOffset + col + 16] = p2;
  6655. blockData[blockBufferOffset + col + 24] = p3;
  6656. blockData[blockBufferOffset + col + 32] = p4;
  6657. blockData[blockBufferOffset + col + 40] = p5;
  6658. blockData[blockBufferOffset + col + 48] = p6;
  6659. blockData[blockBufferOffset + col + 56] = p7;
  6660. }
  6661. }
  6662. function buildComponentData(frame, component) {
  6663. var blocksPerLine = component.blocksPerLine;
  6664. var blocksPerColumn = component.blocksPerColumn;
  6665. var computationBuffer = new Int16Array(64);
  6666. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  6667. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  6668. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  6669. quantizeAndInverse(component, offset, computationBuffer);
  6670. }
  6671. }
  6672. return component.blockData;
  6673. }
  6674. function findNextFileMarker(data, currentPos) {
  6675. var startPos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : currentPos;
  6676. function peekUint16(pos) {
  6677. return data[pos] << 8 | data[pos + 1];
  6678. }
  6679. var maxPos = data.length - 1;
  6680. var newPos = startPos < currentPos ? startPos : currentPos;
  6681. if (currentPos >= maxPos) {
  6682. return null;
  6683. }
  6684. var currentMarker = peekUint16(currentPos);
  6685. if (currentMarker >= 0xFFC0 && currentMarker <= 0xFFFE) {
  6686. return {
  6687. invalid: null,
  6688. marker: currentMarker,
  6689. offset: currentPos
  6690. };
  6691. }
  6692. var newMarker = peekUint16(newPos);
  6693. while (!(newMarker >= 0xFFC0 && newMarker <= 0xFFFE)) {
  6694. if (++newPos >= maxPos) {
  6695. return null;
  6696. }
  6697. newMarker = peekUint16(newPos);
  6698. }
  6699. return {
  6700. invalid: currentMarker.toString(16),
  6701. marker: newMarker,
  6702. offset: newPos
  6703. };
  6704. }
  6705. JpegImage.prototype = {
  6706. parse: function parse(data) {
  6707. var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  6708. _ref2$dnlScanLines = _ref2.dnlScanLines,
  6709. dnlScanLines = _ref2$dnlScanLines === void 0 ? null : _ref2$dnlScanLines;
  6710. function readUint16() {
  6711. var value = data[offset] << 8 | data[offset + 1];
  6712. offset += 2;
  6713. return value;
  6714. }
  6715. function readDataBlock() {
  6716. var length = readUint16();
  6717. var endOffset = offset + length - 2;
  6718. var fileMarker = findNextFileMarker(data, endOffset, offset);
  6719. if (fileMarker && fileMarker.invalid) {
  6720. (0, _util.warn)('readDataBlock - incorrect length, current marker is: ' + fileMarker.invalid);
  6721. endOffset = fileMarker.offset;
  6722. }
  6723. var array = data.subarray(offset, endOffset);
  6724. offset += array.length;
  6725. return array;
  6726. }
  6727. function prepareComponents(frame) {
  6728. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  6729. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  6730. for (var i = 0; i < frame.components.length; i++) {
  6731. component = frame.components[i];
  6732. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  6733. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  6734. var blocksPerLineForMcu = mcusPerLine * component.h;
  6735. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  6736. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  6737. component.blockData = new Int16Array(blocksBufferSize);
  6738. component.blocksPerLine = blocksPerLine;
  6739. component.blocksPerColumn = blocksPerColumn;
  6740. }
  6741. frame.mcusPerLine = mcusPerLine;
  6742. frame.mcusPerColumn = mcusPerColumn;
  6743. }
  6744. var offset = 0;
  6745. var jfif = null;
  6746. var adobe = null;
  6747. var frame, resetInterval;
  6748. var numSOSMarkers = 0;
  6749. var quantizationTables = [];
  6750. var huffmanTablesAC = [],
  6751. huffmanTablesDC = [];
  6752. var fileMarker = readUint16();
  6753. if (fileMarker !== 0xFFD8) {
  6754. throw new JpegError('SOI not found');
  6755. }
  6756. fileMarker = readUint16();
  6757. markerLoop: while (fileMarker !== 0xFFD9) {
  6758. var i, j, l;
  6759. switch (fileMarker) {
  6760. case 0xFFE0:
  6761. case 0xFFE1:
  6762. case 0xFFE2:
  6763. case 0xFFE3:
  6764. case 0xFFE4:
  6765. case 0xFFE5:
  6766. case 0xFFE6:
  6767. case 0xFFE7:
  6768. case 0xFFE8:
  6769. case 0xFFE9:
  6770. case 0xFFEA:
  6771. case 0xFFEB:
  6772. case 0xFFEC:
  6773. case 0xFFED:
  6774. case 0xFFEE:
  6775. case 0xFFEF:
  6776. case 0xFFFE:
  6777. var appData = readDataBlock();
  6778. if (fileMarker === 0xFFE0) {
  6779. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  6780. jfif = {
  6781. version: {
  6782. major: appData[5],
  6783. minor: appData[6]
  6784. },
  6785. densityUnits: appData[7],
  6786. xDensity: appData[8] << 8 | appData[9],
  6787. yDensity: appData[10] << 8 | appData[11],
  6788. thumbWidth: appData[12],
  6789. thumbHeight: appData[13],
  6790. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  6791. };
  6792. }
  6793. }
  6794. if (fileMarker === 0xFFEE) {
  6795. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  6796. adobe = {
  6797. version: appData[5] << 8 | appData[6],
  6798. flags0: appData[7] << 8 | appData[8],
  6799. flags1: appData[9] << 8 | appData[10],
  6800. transformCode: appData[11]
  6801. };
  6802. }
  6803. }
  6804. break;
  6805. case 0xFFDB:
  6806. var quantizationTablesLength = readUint16();
  6807. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  6808. var z;
  6809. while (offset < quantizationTablesEnd) {
  6810. var quantizationTableSpec = data[offset++];
  6811. var tableData = new Uint16Array(64);
  6812. if (quantizationTableSpec >> 4 === 0) {
  6813. for (j = 0; j < 64; j++) {
  6814. z = dctZigZag[j];
  6815. tableData[z] = data[offset++];
  6816. }
  6817. } else if (quantizationTableSpec >> 4 === 1) {
  6818. for (j = 0; j < 64; j++) {
  6819. z = dctZigZag[j];
  6820. tableData[z] = readUint16();
  6821. }
  6822. } else {
  6823. throw new JpegError('DQT - invalid table spec');
  6824. }
  6825. quantizationTables[quantizationTableSpec & 15] = tableData;
  6826. }
  6827. break;
  6828. case 0xFFC0:
  6829. case 0xFFC1:
  6830. case 0xFFC2:
  6831. if (frame) {
  6832. throw new JpegError('Only single frame JPEGs supported');
  6833. }
  6834. readUint16();
  6835. frame = {};
  6836. frame.extended = fileMarker === 0xFFC1;
  6837. frame.progressive = fileMarker === 0xFFC2;
  6838. frame.precision = data[offset++];
  6839. var sofScanLines = readUint16();
  6840. frame.scanLines = dnlScanLines || sofScanLines;
  6841. frame.samplesPerLine = readUint16();
  6842. frame.components = [];
  6843. frame.componentIds = {};
  6844. var componentsCount = data[offset++],
  6845. componentId;
  6846. var maxH = 0,
  6847. maxV = 0;
  6848. for (i = 0; i < componentsCount; i++) {
  6849. componentId = data[offset];
  6850. var h = data[offset + 1] >> 4;
  6851. var v = data[offset + 1] & 15;
  6852. if (maxH < h) {
  6853. maxH = h;
  6854. }
  6855. if (maxV < v) {
  6856. maxV = v;
  6857. }
  6858. var qId = data[offset + 2];
  6859. l = frame.components.push({
  6860. h: h,
  6861. v: v,
  6862. quantizationId: qId,
  6863. quantizationTable: null
  6864. });
  6865. frame.componentIds[componentId] = l - 1;
  6866. offset += 3;
  6867. }
  6868. frame.maxH = maxH;
  6869. frame.maxV = maxV;
  6870. prepareComponents(frame);
  6871. break;
  6872. case 0xFFC4:
  6873. var huffmanLength = readUint16();
  6874. for (i = 2; i < huffmanLength;) {
  6875. var huffmanTableSpec = data[offset++];
  6876. var codeLengths = new Uint8Array(16);
  6877. var codeLengthSum = 0;
  6878. for (j = 0; j < 16; j++, offset++) {
  6879. codeLengthSum += codeLengths[j] = data[offset];
  6880. }
  6881. var huffmanValues = new Uint8Array(codeLengthSum);
  6882. for (j = 0; j < codeLengthSum; j++, offset++) {
  6883. huffmanValues[j] = data[offset];
  6884. }
  6885. i += 17 + codeLengthSum;
  6886. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  6887. }
  6888. break;
  6889. case 0xFFDD:
  6890. readUint16();
  6891. resetInterval = readUint16();
  6892. break;
  6893. case 0xFFDA:
  6894. var parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
  6895. readUint16();
  6896. var selectorsCount = data[offset++];
  6897. var components = [],
  6898. component;
  6899. for (i = 0; i < selectorsCount; i++) {
  6900. var componentIndex = frame.componentIds[data[offset++]];
  6901. component = frame.components[componentIndex];
  6902. var tableSpec = data[offset++];
  6903. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  6904. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  6905. components.push(component);
  6906. }
  6907. var spectralStart = data[offset++];
  6908. var spectralEnd = data[offset++];
  6909. var successiveApproximation = data[offset++];
  6910. try {
  6911. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
  6912. offset += processed;
  6913. } catch (ex) {
  6914. if (ex instanceof DNLMarkerError) {
  6915. (0, _util.warn)("".concat(ex.message, " -- attempting to re-parse the JPEG image."));
  6916. return this.parse(data, {
  6917. dnlScanLines: ex.scanLines
  6918. });
  6919. } else if (ex instanceof EOIMarkerError) {
  6920. (0, _util.warn)("".concat(ex.message, " -- ignoring the rest of the image data."));
  6921. break markerLoop;
  6922. }
  6923. throw ex;
  6924. }
  6925. break;
  6926. case 0xFFDC:
  6927. offset += 4;
  6928. break;
  6929. case 0xFFFF:
  6930. if (data[offset] !== 0xFF) {
  6931. offset--;
  6932. }
  6933. break;
  6934. default:
  6935. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  6936. offset -= 3;
  6937. break;
  6938. }
  6939. var nextFileMarker = findNextFileMarker(data, offset - 2);
  6940. if (nextFileMarker && nextFileMarker.invalid) {
  6941. (0, _util.warn)('JpegImage.parse - unexpected data, current marker is: ' + nextFileMarker.invalid);
  6942. offset = nextFileMarker.offset;
  6943. break;
  6944. }
  6945. throw new JpegError('unknown marker ' + fileMarker.toString(16));
  6946. }
  6947. fileMarker = readUint16();
  6948. }
  6949. this.width = frame.samplesPerLine;
  6950. this.height = frame.scanLines;
  6951. this.jfif = jfif;
  6952. this.adobe = adobe;
  6953. this.components = [];
  6954. for (i = 0; i < frame.components.length; i++) {
  6955. component = frame.components[i];
  6956. var quantizationTable = quantizationTables[component.quantizationId];
  6957. if (quantizationTable) {
  6958. component.quantizationTable = quantizationTable;
  6959. }
  6960. this.components.push({
  6961. output: buildComponentData(frame, component),
  6962. scaleX: component.h / frame.maxH,
  6963. scaleY: component.v / frame.maxV,
  6964. blocksPerLine: component.blocksPerLine,
  6965. blocksPerColumn: component.blocksPerColumn
  6966. });
  6967. }
  6968. this.numComponents = this.components.length;
  6969. },
  6970. _getLinearizedBlockData: function _getLinearizedBlockData(width, height) {
  6971. var isSourcePDF = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6972. var scaleX = this.width / width,
  6973. scaleY = this.height / height;
  6974. var component, componentScaleX, componentScaleY, blocksPerScanline;
  6975. var x, y, i, j, k;
  6976. var index;
  6977. var offset = 0;
  6978. var output;
  6979. var numComponents = this.components.length;
  6980. var dataLength = width * height * numComponents;
  6981. var data = new Uint8ClampedArray(dataLength);
  6982. var xScaleBlockOffset = new Uint32Array(width);
  6983. var mask3LSB = 0xfffffff8;
  6984. for (i = 0; i < numComponents; i++) {
  6985. component = this.components[i];
  6986. componentScaleX = component.scaleX * scaleX;
  6987. componentScaleY = component.scaleY * scaleY;
  6988. offset = i;
  6989. output = component.output;
  6990. blocksPerScanline = component.blocksPerLine + 1 << 3;
  6991. for (x = 0; x < width; x++) {
  6992. j = 0 | x * componentScaleX;
  6993. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  6994. }
  6995. for (y = 0; y < height; y++) {
  6996. j = 0 | y * componentScaleY;
  6997. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  6998. for (x = 0; x < width; x++) {
  6999. data[offset] = output[index + xScaleBlockOffset[x]];
  7000. offset += numComponents;
  7001. }
  7002. }
  7003. }
  7004. var transform = this._decodeTransform;
  7005. if (!isSourcePDF && numComponents === 4 && !transform) {
  7006. transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
  7007. }
  7008. if (transform) {
  7009. for (i = 0; i < dataLength;) {
  7010. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  7011. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  7012. }
  7013. }
  7014. }
  7015. return data;
  7016. },
  7017. get _isColorConversionNeeded() {
  7018. if (this.adobe) {
  7019. return !!this.adobe.transformCode;
  7020. }
  7021. if (this.numComponents === 3) {
  7022. if (this._colorTransform === 0) {
  7023. return false;
  7024. }
  7025. return true;
  7026. }
  7027. if (this._colorTransform === 1) {
  7028. return true;
  7029. }
  7030. return false;
  7031. },
  7032. _convertYccToRgb: function convertYccToRgb(data) {
  7033. var Y, Cb, Cr;
  7034. for (var i = 0, length = data.length; i < length; i += 3) {
  7035. Y = data[i];
  7036. Cb = data[i + 1];
  7037. Cr = data[i + 2];
  7038. data[i] = Y - 179.456 + 1.402 * Cr;
  7039. data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  7040. data[i + 2] = Y - 226.816 + 1.772 * Cb;
  7041. }
  7042. return data;
  7043. },
  7044. _convertYcckToRgb: function convertYcckToRgb(data) {
  7045. var Y, Cb, Cr, k;
  7046. var offset = 0;
  7047. for (var i = 0, length = data.length; i < length; i += 4) {
  7048. Y = data[i];
  7049. Cb = data[i + 1];
  7050. Cr = data[i + 2];
  7051. k = data[i + 3];
  7052. data[offset++] = -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);
  7053. data[offset++] = 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);
  7054. data[offset++] = -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);
  7055. }
  7056. return data.subarray(0, offset);
  7057. },
  7058. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  7059. var Y, Cb, Cr;
  7060. for (var i = 0, length = data.length; i < length; i += 4) {
  7061. Y = data[i];
  7062. Cb = data[i + 1];
  7063. Cr = data[i + 2];
  7064. data[i] = 434.456 - Y - 1.402 * Cr;
  7065. data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
  7066. data[i + 2] = 481.816 - Y - 1.772 * Cb;
  7067. }
  7068. return data;
  7069. },
  7070. _convertCmykToRgb: function convertCmykToRgb(data) {
  7071. var c, m, y, k;
  7072. var offset = 0;
  7073. var scale = 1 / 255;
  7074. for (var i = 0, length = data.length; i < length; i += 4) {
  7075. c = data[i] * scale;
  7076. m = data[i + 1] * scale;
  7077. y = data[i + 2] * scale;
  7078. k = data[i + 3] * scale;
  7079. data[offset++] = 255 + 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);
  7080. data[offset++] = 255 + 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);
  7081. data[offset++] = 255 + 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);
  7082. }
  7083. return data.subarray(0, offset);
  7084. },
  7085. getData: function getData(_ref3) {
  7086. var width = _ref3.width,
  7087. height = _ref3.height,
  7088. _ref3$forceRGB = _ref3.forceRGB,
  7089. forceRGB = _ref3$forceRGB === void 0 ? false : _ref3$forceRGB,
  7090. _ref3$isSourcePDF = _ref3.isSourcePDF,
  7091. isSourcePDF = _ref3$isSourcePDF === void 0 ? false : _ref3$isSourcePDF;
  7092. if (this.numComponents > 4) {
  7093. throw new JpegError('Unsupported color mode');
  7094. }
  7095. var data = this._getLinearizedBlockData(width, height, isSourcePDF);
  7096. if (this.numComponents === 1 && forceRGB) {
  7097. var dataLength = data.length;
  7098. var rgbData = new Uint8ClampedArray(dataLength * 3);
  7099. var offset = 0;
  7100. for (var i = 0; i < dataLength; i++) {
  7101. var grayColor = data[i];
  7102. rgbData[offset++] = grayColor;
  7103. rgbData[offset++] = grayColor;
  7104. rgbData[offset++] = grayColor;
  7105. }
  7106. return rgbData;
  7107. } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
  7108. return this._convertYccToRgb(data);
  7109. } else if (this.numComponents === 4) {
  7110. if (this._isColorConversionNeeded) {
  7111. if (forceRGB) {
  7112. return this._convertYcckToRgb(data);
  7113. }
  7114. return this._convertYcckToCmyk(data);
  7115. } else if (forceRGB) {
  7116. return this._convertCmykToRgb(data);
  7117. }
  7118. }
  7119. return data;
  7120. }
  7121. };
  7122. return JpegImage;
  7123. }();
  7124. exports.JpegImage = JpegImage;
  7125. /***/ }),
  7126. /* 136 */
  7127. /***/ (function(module, exports, __w_pdfjs_require__) {
  7128. "use strict";
  7129. Object.defineProperty(exports, "__esModule", {
  7130. value: true
  7131. });
  7132. exports.JpxImage = void 0;
  7133. var _util = __w_pdfjs_require__(1);
  7134. var _arithmetic_decoder = __w_pdfjs_require__(133);
  7135. var JpxError = function JpxErrorClosure() {
  7136. function JpxError(msg) {
  7137. this.message = 'JPX error: ' + msg;
  7138. }
  7139. JpxError.prototype = new Error();
  7140. JpxError.prototype.name = 'JpxError';
  7141. JpxError.constructor = JpxError;
  7142. return JpxError;
  7143. }();
  7144. var JpxImage = function JpxImageClosure() {
  7145. var SubbandsGainLog2 = {
  7146. 'LL': 0,
  7147. 'LH': 1,
  7148. 'HL': 1,
  7149. 'HH': 2
  7150. };
  7151. function JpxImage() {
  7152. this.failOnCorruptedImage = false;
  7153. }
  7154. JpxImage.prototype = {
  7155. parse: function JpxImage_parse(data) {
  7156. var head = (0, _util.readUint16)(data, 0);
  7157. if (head === 0xFF4F) {
  7158. this.parseCodestream(data, 0, data.length);
  7159. return;
  7160. }
  7161. var position = 0,
  7162. length = data.length;
  7163. while (position < length) {
  7164. var headerSize = 8;
  7165. var lbox = (0, _util.readUint32)(data, position);
  7166. var tbox = (0, _util.readUint32)(data, position + 4);
  7167. position += headerSize;
  7168. if (lbox === 1) {
  7169. lbox = (0, _util.readUint32)(data, position) * 4294967296 + (0, _util.readUint32)(data, position + 4);
  7170. position += 8;
  7171. headerSize += 8;
  7172. }
  7173. if (lbox === 0) {
  7174. lbox = length - position + headerSize;
  7175. }
  7176. if (lbox < headerSize) {
  7177. throw new JpxError('Invalid box field size');
  7178. }
  7179. var dataLength = lbox - headerSize;
  7180. var jumpDataLength = true;
  7181. switch (tbox) {
  7182. case 0x6A703268:
  7183. jumpDataLength = false;
  7184. break;
  7185. case 0x636F6C72:
  7186. var method = data[position];
  7187. if (method === 1) {
  7188. var colorspace = (0, _util.readUint32)(data, position + 3);
  7189. switch (colorspace) {
  7190. case 16:
  7191. case 17:
  7192. case 18:
  7193. break;
  7194. default:
  7195. (0, _util.warn)('Unknown colorspace ' + colorspace);
  7196. break;
  7197. }
  7198. } else if (method === 2) {
  7199. (0, _util.info)('ICC profile not supported');
  7200. }
  7201. break;
  7202. case 0x6A703263:
  7203. this.parseCodestream(data, position, position + dataLength);
  7204. break;
  7205. case 0x6A502020:
  7206. if ((0, _util.readUint32)(data, position) !== 0x0d0a870a) {
  7207. (0, _util.warn)('Invalid JP2 signature');
  7208. }
  7209. break;
  7210. case 0x6A501A1A:
  7211. case 0x66747970:
  7212. case 0x72726571:
  7213. case 0x72657320:
  7214. case 0x69686472:
  7215. break;
  7216. default:
  7217. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  7218. (0, _util.warn)('Unsupported header type ' + tbox + ' (' + headerType + ')');
  7219. break;
  7220. }
  7221. if (jumpDataLength) {
  7222. position += dataLength;
  7223. }
  7224. }
  7225. },
  7226. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  7227. var newByte = stream.getByte();
  7228. while (newByte >= 0) {
  7229. var oldByte = newByte;
  7230. newByte = stream.getByte();
  7231. var code = oldByte << 8 | newByte;
  7232. if (code === 0xFF51) {
  7233. stream.skip(4);
  7234. var Xsiz = stream.getInt32() >>> 0;
  7235. var Ysiz = stream.getInt32() >>> 0;
  7236. var XOsiz = stream.getInt32() >>> 0;
  7237. var YOsiz = stream.getInt32() >>> 0;
  7238. stream.skip(16);
  7239. var Csiz = stream.getUint16();
  7240. this.width = Xsiz - XOsiz;
  7241. this.height = Ysiz - YOsiz;
  7242. this.componentsCount = Csiz;
  7243. this.bitsPerComponent = 8;
  7244. return;
  7245. }
  7246. }
  7247. throw new JpxError('No size marker found in JPX stream');
  7248. },
  7249. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  7250. var context = {};
  7251. var doNotRecover = false;
  7252. try {
  7253. var position = start;
  7254. while (position + 1 < end) {
  7255. var code = (0, _util.readUint16)(data, position);
  7256. position += 2;
  7257. var length = 0,
  7258. j,
  7259. sqcd,
  7260. spqcds,
  7261. spqcdSize,
  7262. scalarExpounded,
  7263. tile;
  7264. switch (code) {
  7265. case 0xFF4F:
  7266. context.mainHeader = true;
  7267. break;
  7268. case 0xFFD9:
  7269. break;
  7270. case 0xFF51:
  7271. length = (0, _util.readUint16)(data, position);
  7272. var siz = {};
  7273. siz.Xsiz = (0, _util.readUint32)(data, position + 4);
  7274. siz.Ysiz = (0, _util.readUint32)(data, position + 8);
  7275. siz.XOsiz = (0, _util.readUint32)(data, position + 12);
  7276. siz.YOsiz = (0, _util.readUint32)(data, position + 16);
  7277. siz.XTsiz = (0, _util.readUint32)(data, position + 20);
  7278. siz.YTsiz = (0, _util.readUint32)(data, position + 24);
  7279. siz.XTOsiz = (0, _util.readUint32)(data, position + 28);
  7280. siz.YTOsiz = (0, _util.readUint32)(data, position + 32);
  7281. var componentsCount = (0, _util.readUint16)(data, position + 36);
  7282. siz.Csiz = componentsCount;
  7283. var components = [];
  7284. j = position + 38;
  7285. for (var i = 0; i < componentsCount; i++) {
  7286. var component = {
  7287. precision: (data[j] & 0x7F) + 1,
  7288. isSigned: !!(data[j] & 0x80),
  7289. XRsiz: data[j + 1],
  7290. YRsiz: data[j + 2]
  7291. };
  7292. j += 3;
  7293. calculateComponentDimensions(component, siz);
  7294. components.push(component);
  7295. }
  7296. context.SIZ = siz;
  7297. context.components = components;
  7298. calculateTileGrids(context, components);
  7299. context.QCC = [];
  7300. context.COC = [];
  7301. break;
  7302. case 0xFF5C:
  7303. length = (0, _util.readUint16)(data, position);
  7304. var qcd = {};
  7305. j = position + 2;
  7306. sqcd = data[j++];
  7307. switch (sqcd & 0x1F) {
  7308. case 0:
  7309. spqcdSize = 8;
  7310. scalarExpounded = true;
  7311. break;
  7312. case 1:
  7313. spqcdSize = 16;
  7314. scalarExpounded = false;
  7315. break;
  7316. case 2:
  7317. spqcdSize = 16;
  7318. scalarExpounded = true;
  7319. break;
  7320. default:
  7321. throw new Error('Invalid SQcd value ' + sqcd);
  7322. }
  7323. qcd.noQuantization = spqcdSize === 8;
  7324. qcd.scalarExpounded = scalarExpounded;
  7325. qcd.guardBits = sqcd >> 5;
  7326. spqcds = [];
  7327. while (j < length + position) {
  7328. var spqcd = {};
  7329. if (spqcdSize === 8) {
  7330. spqcd.epsilon = data[j++] >> 3;
  7331. spqcd.mu = 0;
  7332. } else {
  7333. spqcd.epsilon = data[j] >> 3;
  7334. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  7335. j += 2;
  7336. }
  7337. spqcds.push(spqcd);
  7338. }
  7339. qcd.SPqcds = spqcds;
  7340. if (context.mainHeader) {
  7341. context.QCD = qcd;
  7342. } else {
  7343. context.currentTile.QCD = qcd;
  7344. context.currentTile.QCC = [];
  7345. }
  7346. break;
  7347. case 0xFF5D:
  7348. length = (0, _util.readUint16)(data, position);
  7349. var qcc = {};
  7350. j = position + 2;
  7351. var cqcc;
  7352. if (context.SIZ.Csiz < 257) {
  7353. cqcc = data[j++];
  7354. } else {
  7355. cqcc = (0, _util.readUint16)(data, j);
  7356. j += 2;
  7357. }
  7358. sqcd = data[j++];
  7359. switch (sqcd & 0x1F) {
  7360. case 0:
  7361. spqcdSize = 8;
  7362. scalarExpounded = true;
  7363. break;
  7364. case 1:
  7365. spqcdSize = 16;
  7366. scalarExpounded = false;
  7367. break;
  7368. case 2:
  7369. spqcdSize = 16;
  7370. scalarExpounded = true;
  7371. break;
  7372. default:
  7373. throw new Error('Invalid SQcd value ' + sqcd);
  7374. }
  7375. qcc.noQuantization = spqcdSize === 8;
  7376. qcc.scalarExpounded = scalarExpounded;
  7377. qcc.guardBits = sqcd >> 5;
  7378. spqcds = [];
  7379. while (j < length + position) {
  7380. spqcd = {};
  7381. if (spqcdSize === 8) {
  7382. spqcd.epsilon = data[j++] >> 3;
  7383. spqcd.mu = 0;
  7384. } else {
  7385. spqcd.epsilon = data[j] >> 3;
  7386. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  7387. j += 2;
  7388. }
  7389. spqcds.push(spqcd);
  7390. }
  7391. qcc.SPqcds = spqcds;
  7392. if (context.mainHeader) {
  7393. context.QCC[cqcc] = qcc;
  7394. } else {
  7395. context.currentTile.QCC[cqcc] = qcc;
  7396. }
  7397. break;
  7398. case 0xFF52:
  7399. length = (0, _util.readUint16)(data, position);
  7400. var cod = {};
  7401. j = position + 2;
  7402. var scod = data[j++];
  7403. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  7404. cod.sopMarkerUsed = !!(scod & 2);
  7405. cod.ephMarkerUsed = !!(scod & 4);
  7406. cod.progressionOrder = data[j++];
  7407. cod.layersCount = (0, _util.readUint16)(data, j);
  7408. j += 2;
  7409. cod.multipleComponentTransform = data[j++];
  7410. cod.decompositionLevelsCount = data[j++];
  7411. cod.xcb = (data[j++] & 0xF) + 2;
  7412. cod.ycb = (data[j++] & 0xF) + 2;
  7413. var blockStyle = data[j++];
  7414. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  7415. cod.resetContextProbabilities = !!(blockStyle & 2);
  7416. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  7417. cod.verticallyStripe = !!(blockStyle & 8);
  7418. cod.predictableTermination = !!(blockStyle & 16);
  7419. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  7420. cod.reversibleTransformation = data[j++];
  7421. if (cod.entropyCoderWithCustomPrecincts) {
  7422. var precinctsSizes = [];
  7423. while (j < length + position) {
  7424. var precinctsSize = data[j++];
  7425. precinctsSizes.push({
  7426. PPx: precinctsSize & 0xF,
  7427. PPy: precinctsSize >> 4
  7428. });
  7429. }
  7430. cod.precinctsSizes = precinctsSizes;
  7431. }
  7432. var unsupported = [];
  7433. if (cod.selectiveArithmeticCodingBypass) {
  7434. unsupported.push('selectiveArithmeticCodingBypass');
  7435. }
  7436. if (cod.resetContextProbabilities) {
  7437. unsupported.push('resetContextProbabilities');
  7438. }
  7439. if (cod.terminationOnEachCodingPass) {
  7440. unsupported.push('terminationOnEachCodingPass');
  7441. }
  7442. if (cod.verticallyStripe) {
  7443. unsupported.push('verticallyStripe');
  7444. }
  7445. if (cod.predictableTermination) {
  7446. unsupported.push('predictableTermination');
  7447. }
  7448. if (unsupported.length > 0) {
  7449. doNotRecover = true;
  7450. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  7451. }
  7452. if (context.mainHeader) {
  7453. context.COD = cod;
  7454. } else {
  7455. context.currentTile.COD = cod;
  7456. context.currentTile.COC = [];
  7457. }
  7458. break;
  7459. case 0xFF90:
  7460. length = (0, _util.readUint16)(data, position);
  7461. tile = {};
  7462. tile.index = (0, _util.readUint16)(data, position + 2);
  7463. tile.length = (0, _util.readUint32)(data, position + 4);
  7464. tile.dataEnd = tile.length + position - 2;
  7465. tile.partIndex = data[position + 8];
  7466. tile.partsCount = data[position + 9];
  7467. context.mainHeader = false;
  7468. if (tile.partIndex === 0) {
  7469. tile.COD = context.COD;
  7470. tile.COC = context.COC.slice(0);
  7471. tile.QCD = context.QCD;
  7472. tile.QCC = context.QCC.slice(0);
  7473. }
  7474. context.currentTile = tile;
  7475. break;
  7476. case 0xFF93:
  7477. tile = context.currentTile;
  7478. if (tile.partIndex === 0) {
  7479. initializeTile(context, tile.index);
  7480. buildPackets(context);
  7481. }
  7482. length = tile.dataEnd - position;
  7483. parseTilePackets(context, data, position, length);
  7484. break;
  7485. case 0xFF55:
  7486. case 0xFF57:
  7487. case 0xFF58:
  7488. case 0xFF64:
  7489. length = (0, _util.readUint16)(data, position);
  7490. break;
  7491. case 0xFF53:
  7492. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  7493. default:
  7494. throw new Error('Unknown codestream code: ' + code.toString(16));
  7495. }
  7496. position += length;
  7497. }
  7498. } catch (e) {
  7499. if (doNotRecover || this.failOnCorruptedImage) {
  7500. throw new JpxError(e.message);
  7501. } else {
  7502. (0, _util.warn)('JPX: Trying to recover from: ' + e.message);
  7503. }
  7504. }
  7505. this.tiles = transformComponents(context);
  7506. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  7507. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  7508. this.componentsCount = context.SIZ.Csiz;
  7509. }
  7510. };
  7511. function calculateComponentDimensions(component, siz) {
  7512. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  7513. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  7514. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  7515. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  7516. component.width = component.x1 - component.x0;
  7517. component.height = component.y1 - component.y0;
  7518. }
  7519. function calculateTileGrids(context, components) {
  7520. var siz = context.SIZ;
  7521. var tile,
  7522. tiles = [];
  7523. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  7524. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  7525. for (var q = 0; q < numYtiles; q++) {
  7526. for (var p = 0; p < numXtiles; p++) {
  7527. tile = {};
  7528. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  7529. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  7530. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  7531. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  7532. tile.width = tile.tx1 - tile.tx0;
  7533. tile.height = tile.ty1 - tile.ty0;
  7534. tile.components = [];
  7535. tiles.push(tile);
  7536. }
  7537. }
  7538. context.tiles = tiles;
  7539. var componentsCount = siz.Csiz;
  7540. for (var i = 0, ii = componentsCount; i < ii; i++) {
  7541. var component = components[i];
  7542. for (var j = 0, jj = tiles.length; j < jj; j++) {
  7543. var tileComponent = {};
  7544. tile = tiles[j];
  7545. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  7546. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  7547. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  7548. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  7549. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  7550. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  7551. tile.components[i] = tileComponent;
  7552. }
  7553. }
  7554. }
  7555. function getBlocksDimensions(context, component, r) {
  7556. var codOrCoc = component.codingStyleParameters;
  7557. var result = {};
  7558. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  7559. result.PPx = 15;
  7560. result.PPy = 15;
  7561. } else {
  7562. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  7563. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  7564. }
  7565. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  7566. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  7567. return result;
  7568. }
  7569. function buildPrecincts(context, resolution, dimensions) {
  7570. var precinctWidth = 1 << dimensions.PPx;
  7571. var precinctHeight = 1 << dimensions.PPy;
  7572. var isZeroRes = resolution.resLevel === 0;
  7573. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  7574. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  7575. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  7576. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  7577. var numprecincts = numprecinctswide * numprecinctshigh;
  7578. resolution.precinctParameters = {
  7579. precinctWidth: precinctWidth,
  7580. precinctHeight: precinctHeight,
  7581. numprecinctswide: numprecinctswide,
  7582. numprecinctshigh: numprecinctshigh,
  7583. numprecincts: numprecincts,
  7584. precinctWidthInSubband: precinctWidthInSubband,
  7585. precinctHeightInSubband: precinctHeightInSubband
  7586. };
  7587. }
  7588. function buildCodeblocks(context, subband, dimensions) {
  7589. var xcb_ = dimensions.xcb_;
  7590. var ycb_ = dimensions.ycb_;
  7591. var codeblockWidth = 1 << xcb_;
  7592. var codeblockHeight = 1 << ycb_;
  7593. var cbx0 = subband.tbx0 >> xcb_;
  7594. var cby0 = subband.tby0 >> ycb_;
  7595. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  7596. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  7597. var precinctParameters = subband.resolution.precinctParameters;
  7598. var codeblocks = [];
  7599. var precincts = [];
  7600. var i, j, codeblock, precinctNumber;
  7601. for (j = cby0; j < cby1; j++) {
  7602. for (i = cbx0; i < cbx1; i++) {
  7603. codeblock = {
  7604. cbx: i,
  7605. cby: j,
  7606. tbx0: codeblockWidth * i,
  7607. tby0: codeblockHeight * j,
  7608. tbx1: codeblockWidth * (i + 1),
  7609. tby1: codeblockHeight * (j + 1)
  7610. };
  7611. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  7612. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  7613. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  7614. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  7615. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  7616. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  7617. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  7618. codeblock.precinctNumber = precinctNumber;
  7619. codeblock.subbandType = subband.type;
  7620. codeblock.Lblock = 3;
  7621. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  7622. continue;
  7623. }
  7624. codeblocks.push(codeblock);
  7625. var precinct = precincts[precinctNumber];
  7626. if (precinct !== undefined) {
  7627. if (i < precinct.cbxMin) {
  7628. precinct.cbxMin = i;
  7629. } else if (i > precinct.cbxMax) {
  7630. precinct.cbxMax = i;
  7631. }
  7632. if (j < precinct.cbyMin) {
  7633. precinct.cbxMin = j;
  7634. } else if (j > precinct.cbyMax) {
  7635. precinct.cbyMax = j;
  7636. }
  7637. } else {
  7638. precincts[precinctNumber] = precinct = {
  7639. cbxMin: i,
  7640. cbyMin: j,
  7641. cbxMax: i,
  7642. cbyMax: j
  7643. };
  7644. }
  7645. codeblock.precinct = precinct;
  7646. }
  7647. }
  7648. subband.codeblockParameters = {
  7649. codeblockWidth: xcb_,
  7650. codeblockHeight: ycb_,
  7651. numcodeblockwide: cbx1 - cbx0 + 1,
  7652. numcodeblockhigh: cby1 - cby0 + 1
  7653. };
  7654. subband.codeblocks = codeblocks;
  7655. subband.precincts = precincts;
  7656. }
  7657. function createPacket(resolution, precinctNumber, layerNumber) {
  7658. var precinctCodeblocks = [];
  7659. var subbands = resolution.subbands;
  7660. for (var i = 0, ii = subbands.length; i < ii; i++) {
  7661. var subband = subbands[i];
  7662. var codeblocks = subband.codeblocks;
  7663. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  7664. var codeblock = codeblocks[j];
  7665. if (codeblock.precinctNumber !== precinctNumber) {
  7666. continue;
  7667. }
  7668. precinctCodeblocks.push(codeblock);
  7669. }
  7670. }
  7671. return {
  7672. layerNumber: layerNumber,
  7673. codeblocks: precinctCodeblocks
  7674. };
  7675. }
  7676. function LayerResolutionComponentPositionIterator(context) {
  7677. var siz = context.SIZ;
  7678. var tileIndex = context.currentTile.index;
  7679. var tile = context.tiles[tileIndex];
  7680. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  7681. var componentsCount = siz.Csiz;
  7682. var maxDecompositionLevelsCount = 0;
  7683. for (var q = 0; q < componentsCount; q++) {
  7684. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  7685. }
  7686. var l = 0,
  7687. r = 0,
  7688. i = 0,
  7689. k = 0;
  7690. this.nextPacket = function JpxImage_nextPacket() {
  7691. for (; l < layersCount; l++) {
  7692. for (; r <= maxDecompositionLevelsCount; r++) {
  7693. for (; i < componentsCount; i++) {
  7694. var component = tile.components[i];
  7695. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  7696. continue;
  7697. }
  7698. var resolution = component.resolutions[r];
  7699. var numprecincts = resolution.precinctParameters.numprecincts;
  7700. for (; k < numprecincts;) {
  7701. var packet = createPacket(resolution, k, l);
  7702. k++;
  7703. return packet;
  7704. }
  7705. k = 0;
  7706. }
  7707. i = 0;
  7708. }
  7709. r = 0;
  7710. }
  7711. throw new JpxError('Out of packets');
  7712. };
  7713. }
  7714. function ResolutionLayerComponentPositionIterator(context) {
  7715. var siz = context.SIZ;
  7716. var tileIndex = context.currentTile.index;
  7717. var tile = context.tiles[tileIndex];
  7718. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  7719. var componentsCount = siz.Csiz;
  7720. var maxDecompositionLevelsCount = 0;
  7721. for (var q = 0; q < componentsCount; q++) {
  7722. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  7723. }
  7724. var r = 0,
  7725. l = 0,
  7726. i = 0,
  7727. k = 0;
  7728. this.nextPacket = function JpxImage_nextPacket() {
  7729. for (; r <= maxDecompositionLevelsCount; r++) {
  7730. for (; l < layersCount; l++) {
  7731. for (; i < componentsCount; i++) {
  7732. var component = tile.components[i];
  7733. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  7734. continue;
  7735. }
  7736. var resolution = component.resolutions[r];
  7737. var numprecincts = resolution.precinctParameters.numprecincts;
  7738. for (; k < numprecincts;) {
  7739. var packet = createPacket(resolution, k, l);
  7740. k++;
  7741. return packet;
  7742. }
  7743. k = 0;
  7744. }
  7745. i = 0;
  7746. }
  7747. l = 0;
  7748. }
  7749. throw new JpxError('Out of packets');
  7750. };
  7751. }
  7752. function ResolutionPositionComponentLayerIterator(context) {
  7753. var siz = context.SIZ;
  7754. var tileIndex = context.currentTile.index;
  7755. var tile = context.tiles[tileIndex];
  7756. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  7757. var componentsCount = siz.Csiz;
  7758. var l, r, c, p;
  7759. var maxDecompositionLevelsCount = 0;
  7760. for (c = 0; c < componentsCount; c++) {
  7761. var component = tile.components[c];
  7762. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  7763. }
  7764. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  7765. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  7766. var maxNumPrecincts = 0;
  7767. for (c = 0; c < componentsCount; ++c) {
  7768. var resolutions = tile.components[c].resolutions;
  7769. if (r < resolutions.length) {
  7770. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  7771. }
  7772. }
  7773. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  7774. }
  7775. l = 0;
  7776. r = 0;
  7777. c = 0;
  7778. p = 0;
  7779. this.nextPacket = function JpxImage_nextPacket() {
  7780. for (; r <= maxDecompositionLevelsCount; r++) {
  7781. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  7782. for (; c < componentsCount; c++) {
  7783. var component = tile.components[c];
  7784. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  7785. continue;
  7786. }
  7787. var resolution = component.resolutions[r];
  7788. var numprecincts = resolution.precinctParameters.numprecincts;
  7789. if (p >= numprecincts) {
  7790. continue;
  7791. }
  7792. for (; l < layersCount;) {
  7793. var packet = createPacket(resolution, p, l);
  7794. l++;
  7795. return packet;
  7796. }
  7797. l = 0;
  7798. }
  7799. c = 0;
  7800. }
  7801. p = 0;
  7802. }
  7803. throw new JpxError('Out of packets');
  7804. };
  7805. }
  7806. function PositionComponentResolutionLayerIterator(context) {
  7807. var siz = context.SIZ;
  7808. var tileIndex = context.currentTile.index;
  7809. var tile = context.tiles[tileIndex];
  7810. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  7811. var componentsCount = siz.Csiz;
  7812. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  7813. var precinctsIterationSizes = precinctsSizes;
  7814. var l = 0,
  7815. r = 0,
  7816. c = 0,
  7817. px = 0,
  7818. py = 0;
  7819. this.nextPacket = function JpxImage_nextPacket() {
  7820. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  7821. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  7822. for (; c < componentsCount; c++) {
  7823. var component = tile.components[c];
  7824. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  7825. for (; r <= decompositionLevelsCount; r++) {
  7826. var resolution = component.resolutions[r];
  7827. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  7828. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  7829. if (k === null) {
  7830. continue;
  7831. }
  7832. for (; l < layersCount;) {
  7833. var packet = createPacket(resolution, k, l);
  7834. l++;
  7835. return packet;
  7836. }
  7837. l = 0;
  7838. }
  7839. r = 0;
  7840. }
  7841. c = 0;
  7842. }
  7843. px = 0;
  7844. }
  7845. throw new JpxError('Out of packets');
  7846. };
  7847. }
  7848. function ComponentPositionResolutionLayerIterator(context) {
  7849. var siz = context.SIZ;
  7850. var tileIndex = context.currentTile.index;
  7851. var tile = context.tiles[tileIndex];
  7852. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  7853. var componentsCount = siz.Csiz;
  7854. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  7855. var l = 0,
  7856. r = 0,
  7857. c = 0,
  7858. px = 0,
  7859. py = 0;
  7860. this.nextPacket = function JpxImage_nextPacket() {
  7861. for (; c < componentsCount; ++c) {
  7862. var component = tile.components[c];
  7863. var precinctsIterationSizes = precinctsSizes.components[c];
  7864. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  7865. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  7866. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  7867. for (; r <= decompositionLevelsCount; r++) {
  7868. var resolution = component.resolutions[r];
  7869. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  7870. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  7871. if (k === null) {
  7872. continue;
  7873. }
  7874. for (; l < layersCount;) {
  7875. var packet = createPacket(resolution, k, l);
  7876. l++;
  7877. return packet;
  7878. }
  7879. l = 0;
  7880. }
  7881. r = 0;
  7882. }
  7883. px = 0;
  7884. }
  7885. py = 0;
  7886. }
  7887. throw new JpxError('Out of packets');
  7888. };
  7889. }
  7890. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  7891. var posX = pxIndex * precinctIterationSizes.minWidth;
  7892. var posY = pyIndex * precinctIterationSizes.minHeight;
  7893. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  7894. return null;
  7895. }
  7896. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  7897. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  7898. }
  7899. function getPrecinctSizesInImageScale(tile) {
  7900. var componentsCount = tile.components.length;
  7901. var minWidth = Number.MAX_VALUE;
  7902. var minHeight = Number.MAX_VALUE;
  7903. var maxNumWide = 0;
  7904. var maxNumHigh = 0;
  7905. var sizePerComponent = new Array(componentsCount);
  7906. for (var c = 0; c < componentsCount; c++) {
  7907. var component = tile.components[c];
  7908. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  7909. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  7910. var minWidthCurrentComponent = Number.MAX_VALUE;
  7911. var minHeightCurrentComponent = Number.MAX_VALUE;
  7912. var maxNumWideCurrentComponent = 0;
  7913. var maxNumHighCurrentComponent = 0;
  7914. var scale = 1;
  7915. for (var r = decompositionLevelsCount; r >= 0; --r) {
  7916. var resolution = component.resolutions[r];
  7917. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  7918. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  7919. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  7920. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  7921. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  7922. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  7923. sizePerResolution[r] = {
  7924. width: widthCurrentResolution,
  7925. height: heightCurrentResolution
  7926. };
  7927. scale <<= 1;
  7928. }
  7929. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  7930. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  7931. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  7932. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  7933. sizePerComponent[c] = {
  7934. resolutions: sizePerResolution,
  7935. minWidth: minWidthCurrentComponent,
  7936. minHeight: minHeightCurrentComponent,
  7937. maxNumWide: maxNumWideCurrentComponent,
  7938. maxNumHigh: maxNumHighCurrentComponent
  7939. };
  7940. }
  7941. return {
  7942. components: sizePerComponent,
  7943. minWidth: minWidth,
  7944. minHeight: minHeight,
  7945. maxNumWide: maxNumWide,
  7946. maxNumHigh: maxNumHigh
  7947. };
  7948. }
  7949. function buildPackets(context) {
  7950. var siz = context.SIZ;
  7951. var tileIndex = context.currentTile.index;
  7952. var tile = context.tiles[tileIndex];
  7953. var componentsCount = siz.Csiz;
  7954. for (var c = 0; c < componentsCount; c++) {
  7955. var component = tile.components[c];
  7956. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  7957. var resolutions = [];
  7958. var subbands = [];
  7959. for (var r = 0; r <= decompositionLevelsCount; r++) {
  7960. var blocksDimensions = getBlocksDimensions(context, component, r);
  7961. var resolution = {};
  7962. var scale = 1 << decompositionLevelsCount - r;
  7963. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  7964. resolution.try0 = Math.ceil(component.tcy0 / scale);
  7965. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  7966. resolution.try1 = Math.ceil(component.tcy1 / scale);
  7967. resolution.resLevel = r;
  7968. buildPrecincts(context, resolution, blocksDimensions);
  7969. resolutions.push(resolution);
  7970. var subband;
  7971. if (r === 0) {
  7972. subband = {};
  7973. subband.type = 'LL';
  7974. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  7975. subband.tby0 = Math.ceil(component.tcy0 / scale);
  7976. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  7977. subband.tby1 = Math.ceil(component.tcy1 / scale);
  7978. subband.resolution = resolution;
  7979. buildCodeblocks(context, subband, blocksDimensions);
  7980. subbands.push(subband);
  7981. resolution.subbands = [subband];
  7982. } else {
  7983. var bscale = 1 << decompositionLevelsCount - r + 1;
  7984. var resolutionSubbands = [];
  7985. subband = {};
  7986. subband.type = 'HL';
  7987. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  7988. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  7989. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  7990. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  7991. subband.resolution = resolution;
  7992. buildCodeblocks(context, subband, blocksDimensions);
  7993. subbands.push(subband);
  7994. resolutionSubbands.push(subband);
  7995. subband = {};
  7996. subband.type = 'LH';
  7997. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  7998. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  7999. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  8000. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  8001. subband.resolution = resolution;
  8002. buildCodeblocks(context, subband, blocksDimensions);
  8003. subbands.push(subband);
  8004. resolutionSubbands.push(subband);
  8005. subband = {};
  8006. subband.type = 'HH';
  8007. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  8008. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  8009. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  8010. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  8011. subband.resolution = resolution;
  8012. buildCodeblocks(context, subband, blocksDimensions);
  8013. subbands.push(subband);
  8014. resolutionSubbands.push(subband);
  8015. resolution.subbands = resolutionSubbands;
  8016. }
  8017. }
  8018. component.resolutions = resolutions;
  8019. component.subbands = subbands;
  8020. }
  8021. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  8022. switch (progressionOrder) {
  8023. case 0:
  8024. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  8025. break;
  8026. case 1:
  8027. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  8028. break;
  8029. case 2:
  8030. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  8031. break;
  8032. case 3:
  8033. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  8034. break;
  8035. case 4:
  8036. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  8037. break;
  8038. default:
  8039. throw new JpxError("Unsupported progression order ".concat(progressionOrder));
  8040. }
  8041. }
  8042. function parseTilePackets(context, data, offset, dataLength) {
  8043. var position = 0;
  8044. var buffer,
  8045. bufferSize = 0,
  8046. skipNextBit = false;
  8047. function readBits(count) {
  8048. while (bufferSize < count) {
  8049. var b = data[offset + position];
  8050. position++;
  8051. if (skipNextBit) {
  8052. buffer = buffer << 7 | b;
  8053. bufferSize += 7;
  8054. skipNextBit = false;
  8055. } else {
  8056. buffer = buffer << 8 | b;
  8057. bufferSize += 8;
  8058. }
  8059. if (b === 0xFF) {
  8060. skipNextBit = true;
  8061. }
  8062. }
  8063. bufferSize -= count;
  8064. return buffer >>> bufferSize & (1 << count) - 1;
  8065. }
  8066. function skipMarkerIfEqual(value) {
  8067. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  8068. skipBytes(1);
  8069. return true;
  8070. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  8071. skipBytes(2);
  8072. return true;
  8073. }
  8074. return false;
  8075. }
  8076. function skipBytes(count) {
  8077. position += count;
  8078. }
  8079. function alignToByte() {
  8080. bufferSize = 0;
  8081. if (skipNextBit) {
  8082. position++;
  8083. skipNextBit = false;
  8084. }
  8085. }
  8086. function readCodingpasses() {
  8087. if (readBits(1) === 0) {
  8088. return 1;
  8089. }
  8090. if (readBits(1) === 0) {
  8091. return 2;
  8092. }
  8093. var value = readBits(2);
  8094. if (value < 3) {
  8095. return value + 3;
  8096. }
  8097. value = readBits(5);
  8098. if (value < 31) {
  8099. return value + 6;
  8100. }
  8101. value = readBits(7);
  8102. return value + 37;
  8103. }
  8104. var tileIndex = context.currentTile.index;
  8105. var tile = context.tiles[tileIndex];
  8106. var sopMarkerUsed = context.COD.sopMarkerUsed;
  8107. var ephMarkerUsed = context.COD.ephMarkerUsed;
  8108. var packetsIterator = tile.packetsIterator;
  8109. while (position < dataLength) {
  8110. alignToByte();
  8111. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  8112. skipBytes(4);
  8113. }
  8114. var packet = packetsIterator.nextPacket();
  8115. if (!readBits(1)) {
  8116. continue;
  8117. }
  8118. var layerNumber = packet.layerNumber;
  8119. var queue = [],
  8120. codeblock;
  8121. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  8122. codeblock = packet.codeblocks[i];
  8123. var precinct = codeblock.precinct;
  8124. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  8125. var codeblockRow = codeblock.cby - precinct.cbyMin;
  8126. var codeblockIncluded = false;
  8127. var firstTimeInclusion = false;
  8128. var valueReady;
  8129. if (codeblock['included'] !== undefined) {
  8130. codeblockIncluded = !!readBits(1);
  8131. } else {
  8132. precinct = codeblock.precinct;
  8133. var inclusionTree, zeroBitPlanesTree;
  8134. if (precinct['inclusionTree'] !== undefined) {
  8135. inclusionTree = precinct.inclusionTree;
  8136. } else {
  8137. var width = precinct.cbxMax - precinct.cbxMin + 1;
  8138. var height = precinct.cbyMax - precinct.cbyMin + 1;
  8139. inclusionTree = new InclusionTree(width, height, layerNumber);
  8140. zeroBitPlanesTree = new TagTree(width, height);
  8141. precinct.inclusionTree = inclusionTree;
  8142. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  8143. }
  8144. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  8145. while (true) {
  8146. if (readBits(1)) {
  8147. valueReady = !inclusionTree.nextLevel();
  8148. if (valueReady) {
  8149. codeblock.included = true;
  8150. codeblockIncluded = firstTimeInclusion = true;
  8151. break;
  8152. }
  8153. } else {
  8154. inclusionTree.incrementValue(layerNumber);
  8155. break;
  8156. }
  8157. }
  8158. }
  8159. }
  8160. if (!codeblockIncluded) {
  8161. continue;
  8162. }
  8163. if (firstTimeInclusion) {
  8164. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  8165. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  8166. while (true) {
  8167. if (readBits(1)) {
  8168. valueReady = !zeroBitPlanesTree.nextLevel();
  8169. if (valueReady) {
  8170. break;
  8171. }
  8172. } else {
  8173. zeroBitPlanesTree.incrementValue();
  8174. }
  8175. }
  8176. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  8177. }
  8178. var codingpasses = readCodingpasses();
  8179. while (readBits(1)) {
  8180. codeblock.Lblock++;
  8181. }
  8182. var codingpassesLog2 = (0, _util.log2)(codingpasses);
  8183. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  8184. var codedDataLength = readBits(bits);
  8185. queue.push({
  8186. codeblock: codeblock,
  8187. codingpasses: codingpasses,
  8188. dataLength: codedDataLength
  8189. });
  8190. }
  8191. alignToByte();
  8192. if (ephMarkerUsed) {
  8193. skipMarkerIfEqual(0x92);
  8194. }
  8195. while (queue.length > 0) {
  8196. var packetItem = queue.shift();
  8197. codeblock = packetItem.codeblock;
  8198. if (codeblock['data'] === undefined) {
  8199. codeblock.data = [];
  8200. }
  8201. codeblock.data.push({
  8202. data: data,
  8203. start: offset + position,
  8204. end: offset + position + packetItem.dataLength,
  8205. codingpasses: packetItem.codingpasses
  8206. });
  8207. position += packetItem.dataLength;
  8208. }
  8209. }
  8210. return position;
  8211. }
  8212. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  8213. var x0 = subband.tbx0;
  8214. var y0 = subband.tby0;
  8215. var width = subband.tbx1 - subband.tbx0;
  8216. var codeblocks = subband.codeblocks;
  8217. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  8218. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  8219. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  8220. var codeblock = codeblocks[i];
  8221. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  8222. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  8223. if (blockWidth === 0 || blockHeight === 0) {
  8224. continue;
  8225. }
  8226. if (codeblock['data'] === undefined) {
  8227. continue;
  8228. }
  8229. var bitModel, currentCodingpassType;
  8230. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  8231. currentCodingpassType = 2;
  8232. var data = codeblock.data,
  8233. totalLength = 0,
  8234. codingpasses = 0;
  8235. var j, jj, dataItem;
  8236. for (j = 0, jj = data.length; j < jj; j++) {
  8237. dataItem = data[j];
  8238. totalLength += dataItem.end - dataItem.start;
  8239. codingpasses += dataItem.codingpasses;
  8240. }
  8241. var encodedData = new Uint8Array(totalLength);
  8242. var position = 0;
  8243. for (j = 0, jj = data.length; j < jj; j++) {
  8244. dataItem = data[j];
  8245. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  8246. encodedData.set(chunk, position);
  8247. position += chunk.length;
  8248. }
  8249. var decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
  8250. bitModel.setDecoder(decoder);
  8251. for (j = 0; j < codingpasses; j++) {
  8252. switch (currentCodingpassType) {
  8253. case 0:
  8254. bitModel.runSignificancePropagationPass();
  8255. break;
  8256. case 1:
  8257. bitModel.runMagnitudeRefinementPass();
  8258. break;
  8259. case 2:
  8260. bitModel.runCleanupPass();
  8261. if (segmentationSymbolUsed) {
  8262. bitModel.checkSegmentationSymbol();
  8263. }
  8264. break;
  8265. }
  8266. currentCodingpassType = (currentCodingpassType + 1) % 3;
  8267. }
  8268. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  8269. var sign = bitModel.coefficentsSign;
  8270. var magnitude = bitModel.coefficentsMagnitude;
  8271. var bitsDecoded = bitModel.bitsDecoded;
  8272. var magnitudeCorrection = reversible ? 0 : 0.5;
  8273. var k, n, nb;
  8274. position = 0;
  8275. var interleave = subband.type !== 'LL';
  8276. for (j = 0; j < blockHeight; j++) {
  8277. var row = offset / width | 0;
  8278. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  8279. for (k = 0; k < blockWidth; k++) {
  8280. n = magnitude[position];
  8281. if (n !== 0) {
  8282. n = (n + magnitudeCorrection) * delta;
  8283. if (sign[position] !== 0) {
  8284. n = -n;
  8285. }
  8286. nb = bitsDecoded[position];
  8287. var pos = interleave ? levelOffset + (offset << 1) : offset;
  8288. if (reversible && nb >= mb) {
  8289. coefficients[pos] = n;
  8290. } else {
  8291. coefficients[pos] = n * (1 << mb - nb);
  8292. }
  8293. }
  8294. offset++;
  8295. position++;
  8296. }
  8297. offset += width - blockWidth;
  8298. }
  8299. }
  8300. }
  8301. function transformTile(context, tile, c) {
  8302. var component = tile.components[c];
  8303. var codingStyleParameters = component.codingStyleParameters;
  8304. var quantizationParameters = component.quantizationParameters;
  8305. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  8306. var spqcds = quantizationParameters.SPqcds;
  8307. var scalarExpounded = quantizationParameters.scalarExpounded;
  8308. var guardBits = quantizationParameters.guardBits;
  8309. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  8310. var precision = context.components[c].precision;
  8311. var reversible = codingStyleParameters.reversibleTransformation;
  8312. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  8313. var subbandCoefficients = [];
  8314. var b = 0;
  8315. for (var i = 0; i <= decompositionLevelsCount; i++) {
  8316. var resolution = component.resolutions[i];
  8317. var width = resolution.trx1 - resolution.trx0;
  8318. var height = resolution.try1 - resolution.try0;
  8319. var coefficients = new Float32Array(width * height);
  8320. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  8321. var mu, epsilon;
  8322. if (!scalarExpounded) {
  8323. mu = spqcds[0].mu;
  8324. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  8325. } else {
  8326. mu = spqcds[b].mu;
  8327. epsilon = spqcds[b].epsilon;
  8328. b++;
  8329. }
  8330. var subband = resolution.subbands[j];
  8331. var gainLog2 = SubbandsGainLog2[subband.type];
  8332. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  8333. var mb = guardBits + epsilon - 1;
  8334. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  8335. }
  8336. subbandCoefficients.push({
  8337. width: width,
  8338. height: height,
  8339. items: coefficients
  8340. });
  8341. }
  8342. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  8343. return {
  8344. left: component.tcx0,
  8345. top: component.tcy0,
  8346. width: result.width,
  8347. height: result.height,
  8348. items: result.items
  8349. };
  8350. }
  8351. function transformComponents(context) {
  8352. var siz = context.SIZ;
  8353. var components = context.components;
  8354. var componentsCount = siz.Csiz;
  8355. var resultImages = [];
  8356. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  8357. var tile = context.tiles[i];
  8358. var transformedTiles = [];
  8359. var c;
  8360. for (c = 0; c < componentsCount; c++) {
  8361. transformedTiles[c] = transformTile(context, tile, c);
  8362. }
  8363. var tile0 = transformedTiles[0];
  8364. var out = new Uint8ClampedArray(tile0.items.length * componentsCount);
  8365. var result = {
  8366. left: tile0.left,
  8367. top: tile0.top,
  8368. width: tile0.width,
  8369. height: tile0.height,
  8370. items: out
  8371. };
  8372. var shift, offset;
  8373. var pos = 0,
  8374. j,
  8375. jj,
  8376. y0,
  8377. y1,
  8378. y2;
  8379. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  8380. var fourComponents = componentsCount === 4;
  8381. var y0items = transformedTiles[0].items;
  8382. var y1items = transformedTiles[1].items;
  8383. var y2items = transformedTiles[2].items;
  8384. var y3items = fourComponents ? transformedTiles[3].items : null;
  8385. shift = components[0].precision - 8;
  8386. offset = (128 << shift) + 0.5;
  8387. var component0 = tile.components[0];
  8388. var alpha01 = componentsCount - 3;
  8389. jj = y0items.length;
  8390. if (!component0.codingStyleParameters.reversibleTransformation) {
  8391. for (j = 0; j < jj; j++, pos += alpha01) {
  8392. y0 = y0items[j] + offset;
  8393. y1 = y1items[j];
  8394. y2 = y2items[j];
  8395. out[pos++] = y0 + 1.402 * y2 >> shift;
  8396. out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
  8397. out[pos++] = y0 + 1.772 * y1 >> shift;
  8398. }
  8399. } else {
  8400. for (j = 0; j < jj; j++, pos += alpha01) {
  8401. y0 = y0items[j] + offset;
  8402. y1 = y1items[j];
  8403. y2 = y2items[j];
  8404. var g = y0 - (y2 + y1 >> 2);
  8405. out[pos++] = g + y2 >> shift;
  8406. out[pos++] = g >> shift;
  8407. out[pos++] = g + y1 >> shift;
  8408. }
  8409. }
  8410. if (fourComponents) {
  8411. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  8412. out[pos] = y3items[j] + offset >> shift;
  8413. }
  8414. }
  8415. } else {
  8416. for (c = 0; c < componentsCount; c++) {
  8417. var items = transformedTiles[c].items;
  8418. shift = components[c].precision - 8;
  8419. offset = (128 << shift) + 0.5;
  8420. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  8421. out[pos] = items[j] + offset >> shift;
  8422. pos += componentsCount;
  8423. }
  8424. }
  8425. }
  8426. resultImages.push(result);
  8427. }
  8428. return resultImages;
  8429. }
  8430. function initializeTile(context, tileIndex) {
  8431. var siz = context.SIZ;
  8432. var componentsCount = siz.Csiz;
  8433. var tile = context.tiles[tileIndex];
  8434. for (var c = 0; c < componentsCount; c++) {
  8435. var component = tile.components[c];
  8436. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  8437. component.quantizationParameters = qcdOrQcc;
  8438. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  8439. component.codingStyleParameters = codOrCoc;
  8440. }
  8441. tile.codingStyleDefaultParameters = context.currentTile.COD;
  8442. }
  8443. var TagTree = function TagTreeClosure() {
  8444. function TagTree(width, height) {
  8445. var levelsLength = (0, _util.log2)(Math.max(width, height)) + 1;
  8446. this.levels = [];
  8447. for (var i = 0; i < levelsLength; i++) {
  8448. var level = {
  8449. width: width,
  8450. height: height,
  8451. items: []
  8452. };
  8453. this.levels.push(level);
  8454. width = Math.ceil(width / 2);
  8455. height = Math.ceil(height / 2);
  8456. }
  8457. }
  8458. TagTree.prototype = {
  8459. reset: function TagTree_reset(i, j) {
  8460. var currentLevel = 0,
  8461. value = 0,
  8462. level;
  8463. while (currentLevel < this.levels.length) {
  8464. level = this.levels[currentLevel];
  8465. var index = i + j * level.width;
  8466. if (level.items[index] !== undefined) {
  8467. value = level.items[index];
  8468. break;
  8469. }
  8470. level.index = index;
  8471. i >>= 1;
  8472. j >>= 1;
  8473. currentLevel++;
  8474. }
  8475. currentLevel--;
  8476. level = this.levels[currentLevel];
  8477. level.items[level.index] = value;
  8478. this.currentLevel = currentLevel;
  8479. delete this.value;
  8480. },
  8481. incrementValue: function TagTree_incrementValue() {
  8482. var level = this.levels[this.currentLevel];
  8483. level.items[level.index]++;
  8484. },
  8485. nextLevel: function TagTree_nextLevel() {
  8486. var currentLevel = this.currentLevel;
  8487. var level = this.levels[currentLevel];
  8488. var value = level.items[level.index];
  8489. currentLevel--;
  8490. if (currentLevel < 0) {
  8491. this.value = value;
  8492. return false;
  8493. }
  8494. this.currentLevel = currentLevel;
  8495. level = this.levels[currentLevel];
  8496. level.items[level.index] = value;
  8497. return true;
  8498. }
  8499. };
  8500. return TagTree;
  8501. }();
  8502. var InclusionTree = function InclusionTreeClosure() {
  8503. function InclusionTree(width, height, defaultValue) {
  8504. var levelsLength = (0, _util.log2)(Math.max(width, height)) + 1;
  8505. this.levels = [];
  8506. for (var i = 0; i < levelsLength; i++) {
  8507. var items = new Uint8Array(width * height);
  8508. for (var j = 0, jj = items.length; j < jj; j++) {
  8509. items[j] = defaultValue;
  8510. }
  8511. var level = {
  8512. width: width,
  8513. height: height,
  8514. items: items
  8515. };
  8516. this.levels.push(level);
  8517. width = Math.ceil(width / 2);
  8518. height = Math.ceil(height / 2);
  8519. }
  8520. }
  8521. InclusionTree.prototype = {
  8522. reset: function InclusionTree_reset(i, j, stopValue) {
  8523. var currentLevel = 0;
  8524. while (currentLevel < this.levels.length) {
  8525. var level = this.levels[currentLevel];
  8526. var index = i + j * level.width;
  8527. level.index = index;
  8528. var value = level.items[index];
  8529. if (value === 0xFF) {
  8530. break;
  8531. }
  8532. if (value > stopValue) {
  8533. this.currentLevel = currentLevel;
  8534. this.propagateValues();
  8535. return false;
  8536. }
  8537. i >>= 1;
  8538. j >>= 1;
  8539. currentLevel++;
  8540. }
  8541. this.currentLevel = currentLevel - 1;
  8542. return true;
  8543. },
  8544. incrementValue: function InclusionTree_incrementValue(stopValue) {
  8545. var level = this.levels[this.currentLevel];
  8546. level.items[level.index] = stopValue + 1;
  8547. this.propagateValues();
  8548. },
  8549. propagateValues: function InclusionTree_propagateValues() {
  8550. var levelIndex = this.currentLevel;
  8551. var level = this.levels[levelIndex];
  8552. var currentValue = level.items[level.index];
  8553. while (--levelIndex >= 0) {
  8554. level = this.levels[levelIndex];
  8555. level.items[level.index] = currentValue;
  8556. }
  8557. },
  8558. nextLevel: function InclusionTree_nextLevel() {
  8559. var currentLevel = this.currentLevel;
  8560. var level = this.levels[currentLevel];
  8561. var value = level.items[level.index];
  8562. level.items[level.index] = 0xFF;
  8563. currentLevel--;
  8564. if (currentLevel < 0) {
  8565. return false;
  8566. }
  8567. this.currentLevel = currentLevel;
  8568. level = this.levels[currentLevel];
  8569. level.items[level.index] = value;
  8570. return true;
  8571. }
  8572. };
  8573. return InclusionTree;
  8574. }();
  8575. var BitModel = function BitModelClosure() {
  8576. var UNIFORM_CONTEXT = 17;
  8577. var RUNLENGTH_CONTEXT = 18;
  8578. var LLAndLHContextsLabel = new Uint8Array([0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8]);
  8579. var HLContextLabel = new Uint8Array([0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8]);
  8580. var HHContextLabel = new Uint8Array([0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8]);
  8581. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  8582. this.width = width;
  8583. this.height = height;
  8584. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  8585. var coefficientCount = width * height;
  8586. this.neighborsSignificance = new Uint8Array(coefficientCount);
  8587. this.coefficentsSign = new Uint8Array(coefficientCount);
  8588. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  8589. this.processingFlags = new Uint8Array(coefficientCount);
  8590. var bitsDecoded = new Uint8Array(coefficientCount);
  8591. if (zeroBitPlanes !== 0) {
  8592. for (var i = 0; i < coefficientCount; i++) {
  8593. bitsDecoded[i] = zeroBitPlanes;
  8594. }
  8595. }
  8596. this.bitsDecoded = bitsDecoded;
  8597. this.reset();
  8598. }
  8599. BitModel.prototype = {
  8600. setDecoder: function BitModel_setDecoder(decoder) {
  8601. this.decoder = decoder;
  8602. },
  8603. reset: function BitModel_reset() {
  8604. this.contexts = new Int8Array(19);
  8605. this.contexts[0] = 4 << 1 | 0;
  8606. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  8607. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  8608. },
  8609. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  8610. var neighborsSignificance = this.neighborsSignificance;
  8611. var width = this.width,
  8612. height = this.height;
  8613. var left = column > 0;
  8614. var right = column + 1 < width;
  8615. var i;
  8616. if (row > 0) {
  8617. i = index - width;
  8618. if (left) {
  8619. neighborsSignificance[i - 1] += 0x10;
  8620. }
  8621. if (right) {
  8622. neighborsSignificance[i + 1] += 0x10;
  8623. }
  8624. neighborsSignificance[i] += 0x04;
  8625. }
  8626. if (row + 1 < height) {
  8627. i = index + width;
  8628. if (left) {
  8629. neighborsSignificance[i - 1] += 0x10;
  8630. }
  8631. if (right) {
  8632. neighborsSignificance[i + 1] += 0x10;
  8633. }
  8634. neighborsSignificance[i] += 0x04;
  8635. }
  8636. if (left) {
  8637. neighborsSignificance[index - 1] += 0x01;
  8638. }
  8639. if (right) {
  8640. neighborsSignificance[index + 1] += 0x01;
  8641. }
  8642. neighborsSignificance[index] |= 0x80;
  8643. },
  8644. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  8645. var decoder = this.decoder;
  8646. var width = this.width,
  8647. height = this.height;
  8648. var coefficentsMagnitude = this.coefficentsMagnitude;
  8649. var coefficentsSign = this.coefficentsSign;
  8650. var neighborsSignificance = this.neighborsSignificance;
  8651. var processingFlags = this.processingFlags;
  8652. var contexts = this.contexts;
  8653. var labels = this.contextLabelTable;
  8654. var bitsDecoded = this.bitsDecoded;
  8655. var processedInverseMask = ~1;
  8656. var processedMask = 1;
  8657. var firstMagnitudeBitMask = 2;
  8658. for (var i0 = 0; i0 < height; i0 += 4) {
  8659. for (var j = 0; j < width; j++) {
  8660. var index = i0 * width + j;
  8661. for (var i1 = 0; i1 < 4; i1++, index += width) {
  8662. var i = i0 + i1;
  8663. if (i >= height) {
  8664. break;
  8665. }
  8666. processingFlags[index] &= processedInverseMask;
  8667. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  8668. continue;
  8669. }
  8670. var contextLabel = labels[neighborsSignificance[index]];
  8671. var decision = decoder.readBit(contexts, contextLabel);
  8672. if (decision) {
  8673. var sign = this.decodeSignBit(i, j, index);
  8674. coefficentsSign[index] = sign;
  8675. coefficentsMagnitude[index] = 1;
  8676. this.setNeighborsSignificance(i, j, index);
  8677. processingFlags[index] |= firstMagnitudeBitMask;
  8678. }
  8679. bitsDecoded[index]++;
  8680. processingFlags[index] |= processedMask;
  8681. }
  8682. }
  8683. }
  8684. },
  8685. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  8686. var width = this.width,
  8687. height = this.height;
  8688. var coefficentsMagnitude = this.coefficentsMagnitude;
  8689. var coefficentsSign = this.coefficentsSign;
  8690. var contribution, sign0, sign1, significance1;
  8691. var contextLabel, decoded;
  8692. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  8693. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  8694. sign1 = coefficentsSign[index + 1];
  8695. if (significance1) {
  8696. sign0 = coefficentsSign[index - 1];
  8697. contribution = 1 - sign1 - sign0;
  8698. } else {
  8699. contribution = 1 - sign1 - sign1;
  8700. }
  8701. } else if (significance1) {
  8702. sign0 = coefficentsSign[index - 1];
  8703. contribution = 1 - sign0 - sign0;
  8704. } else {
  8705. contribution = 0;
  8706. }
  8707. var horizontalContribution = 3 * contribution;
  8708. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  8709. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  8710. sign1 = coefficentsSign[index + width];
  8711. if (significance1) {
  8712. sign0 = coefficentsSign[index - width];
  8713. contribution = 1 - sign1 - sign0 + horizontalContribution;
  8714. } else {
  8715. contribution = 1 - sign1 - sign1 + horizontalContribution;
  8716. }
  8717. } else if (significance1) {
  8718. sign0 = coefficentsSign[index - width];
  8719. contribution = 1 - sign0 - sign0 + horizontalContribution;
  8720. } else {
  8721. contribution = horizontalContribution;
  8722. }
  8723. if (contribution >= 0) {
  8724. contextLabel = 9 + contribution;
  8725. decoded = this.decoder.readBit(this.contexts, contextLabel);
  8726. } else {
  8727. contextLabel = 9 - contribution;
  8728. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  8729. }
  8730. return decoded;
  8731. },
  8732. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  8733. var decoder = this.decoder;
  8734. var width = this.width,
  8735. height = this.height;
  8736. var coefficentsMagnitude = this.coefficentsMagnitude;
  8737. var neighborsSignificance = this.neighborsSignificance;
  8738. var contexts = this.contexts;
  8739. var bitsDecoded = this.bitsDecoded;
  8740. var processingFlags = this.processingFlags;
  8741. var processedMask = 1;
  8742. var firstMagnitudeBitMask = 2;
  8743. var length = width * height;
  8744. var width4 = width * 4;
  8745. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  8746. indexNext = Math.min(length, index0 + width4);
  8747. for (var j = 0; j < width; j++) {
  8748. for (var index = index0 + j; index < indexNext; index += width) {
  8749. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  8750. continue;
  8751. }
  8752. var contextLabel = 16;
  8753. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  8754. processingFlags[index] ^= firstMagnitudeBitMask;
  8755. var significance = neighborsSignificance[index] & 127;
  8756. contextLabel = significance === 0 ? 15 : 14;
  8757. }
  8758. var bit = decoder.readBit(contexts, contextLabel);
  8759. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  8760. bitsDecoded[index]++;
  8761. processingFlags[index] |= processedMask;
  8762. }
  8763. }
  8764. }
  8765. },
  8766. runCleanupPass: function BitModel_runCleanupPass() {
  8767. var decoder = this.decoder;
  8768. var width = this.width,
  8769. height = this.height;
  8770. var neighborsSignificance = this.neighborsSignificance;
  8771. var coefficentsMagnitude = this.coefficentsMagnitude;
  8772. var coefficentsSign = this.coefficentsSign;
  8773. var contexts = this.contexts;
  8774. var labels = this.contextLabelTable;
  8775. var bitsDecoded = this.bitsDecoded;
  8776. var processingFlags = this.processingFlags;
  8777. var processedMask = 1;
  8778. var firstMagnitudeBitMask = 2;
  8779. var oneRowDown = width;
  8780. var twoRowsDown = width * 2;
  8781. var threeRowsDown = width * 3;
  8782. var iNext;
  8783. for (var i0 = 0; i0 < height; i0 = iNext) {
  8784. iNext = Math.min(i0 + 4, height);
  8785. var indexBase = i0 * width;
  8786. var checkAllEmpty = i0 + 3 < height;
  8787. for (var j = 0; j < width; j++) {
  8788. var index0 = indexBase + j;
  8789. 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;
  8790. var i1 = 0,
  8791. index = index0;
  8792. var i = i0,
  8793. sign;
  8794. if (allEmpty) {
  8795. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  8796. if (!hasSignificantCoefficent) {
  8797. bitsDecoded[index0]++;
  8798. bitsDecoded[index0 + oneRowDown]++;
  8799. bitsDecoded[index0 + twoRowsDown]++;
  8800. bitsDecoded[index0 + threeRowsDown]++;
  8801. continue;
  8802. }
  8803. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  8804. if (i1 !== 0) {
  8805. i = i0 + i1;
  8806. index += i1 * width;
  8807. }
  8808. sign = this.decodeSignBit(i, j, index);
  8809. coefficentsSign[index] = sign;
  8810. coefficentsMagnitude[index] = 1;
  8811. this.setNeighborsSignificance(i, j, index);
  8812. processingFlags[index] |= firstMagnitudeBitMask;
  8813. index = index0;
  8814. for (var i2 = i0; i2 <= i; i2++, index += width) {
  8815. bitsDecoded[index]++;
  8816. }
  8817. i1++;
  8818. }
  8819. for (i = i0 + i1; i < iNext; i++, index += width) {
  8820. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  8821. continue;
  8822. }
  8823. var contextLabel = labels[neighborsSignificance[index]];
  8824. var decision = decoder.readBit(contexts, contextLabel);
  8825. if (decision === 1) {
  8826. sign = this.decodeSignBit(i, j, index);
  8827. coefficentsSign[index] = sign;
  8828. coefficentsMagnitude[index] = 1;
  8829. this.setNeighborsSignificance(i, j, index);
  8830. processingFlags[index] |= firstMagnitudeBitMask;
  8831. }
  8832. bitsDecoded[index]++;
  8833. }
  8834. }
  8835. }
  8836. },
  8837. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  8838. var decoder = this.decoder;
  8839. var contexts = this.contexts;
  8840. 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);
  8841. if (symbol !== 0xA) {
  8842. throw new JpxError('Invalid segmentation symbol');
  8843. }
  8844. }
  8845. };
  8846. return BitModel;
  8847. }();
  8848. var Transform = function TransformClosure() {
  8849. function Transform() {}
  8850. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  8851. var ll = subbands[0];
  8852. for (var i = 1, ii = subbands.length; i < ii; i++) {
  8853. ll = this.iterate(ll, subbands[i], u0, v0);
  8854. }
  8855. return ll;
  8856. };
  8857. Transform.prototype.extend = function extend(buffer, offset, size) {
  8858. var i1 = offset - 1,
  8859. j1 = offset + 1;
  8860. var i2 = offset + size - 2,
  8861. j2 = offset + size;
  8862. buffer[i1--] = buffer[j1++];
  8863. buffer[j2++] = buffer[i2--];
  8864. buffer[i1--] = buffer[j1++];
  8865. buffer[j2++] = buffer[i2--];
  8866. buffer[i1--] = buffer[j1++];
  8867. buffer[j2++] = buffer[i2--];
  8868. buffer[i1] = buffer[j1];
  8869. buffer[j2] = buffer[i2];
  8870. };
  8871. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  8872. var llWidth = ll.width,
  8873. llHeight = ll.height,
  8874. llItems = ll.items;
  8875. var width = hl_lh_hh.width;
  8876. var height = hl_lh_hh.height;
  8877. var items = hl_lh_hh.items;
  8878. var i, j, k, l, u, v;
  8879. for (k = 0, i = 0; i < llHeight; i++) {
  8880. l = i * 2 * width;
  8881. for (j = 0; j < llWidth; j++, k++, l += 2) {
  8882. items[l] = llItems[k];
  8883. }
  8884. }
  8885. llItems = ll.items = null;
  8886. var bufferPadding = 4;
  8887. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  8888. if (width === 1) {
  8889. if ((u0 & 1) !== 0) {
  8890. for (v = 0, k = 0; v < height; v++, k += width) {
  8891. items[k] *= 0.5;
  8892. }
  8893. }
  8894. } else {
  8895. for (v = 0, k = 0; v < height; v++, k += width) {
  8896. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  8897. this.extend(rowBuffer, bufferPadding, width);
  8898. this.filter(rowBuffer, bufferPadding, width);
  8899. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  8900. }
  8901. }
  8902. var numBuffers = 16;
  8903. var colBuffers = [];
  8904. for (i = 0; i < numBuffers; i++) {
  8905. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  8906. }
  8907. var b,
  8908. currentBuffer = 0;
  8909. ll = bufferPadding + height;
  8910. if (height === 1) {
  8911. if ((v0 & 1) !== 0) {
  8912. for (u = 0; u < width; u++) {
  8913. items[u] *= 0.5;
  8914. }
  8915. }
  8916. } else {
  8917. for (u = 0; u < width; u++) {
  8918. if (currentBuffer === 0) {
  8919. numBuffers = Math.min(width - u, numBuffers);
  8920. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  8921. for (b = 0; b < numBuffers; b++) {
  8922. colBuffers[b][l] = items[k + b];
  8923. }
  8924. }
  8925. currentBuffer = numBuffers;
  8926. }
  8927. currentBuffer--;
  8928. var buffer = colBuffers[currentBuffer];
  8929. this.extend(buffer, bufferPadding, height);
  8930. this.filter(buffer, bufferPadding, height);
  8931. if (currentBuffer === 0) {
  8932. k = u - numBuffers + 1;
  8933. for (l = bufferPadding; l < ll; k += width, l++) {
  8934. for (b = 0; b < numBuffers; b++) {
  8935. items[k + b] = colBuffers[b][l];
  8936. }
  8937. }
  8938. }
  8939. }
  8940. }
  8941. return {
  8942. width: width,
  8943. height: height,
  8944. items: items
  8945. };
  8946. };
  8947. return Transform;
  8948. }();
  8949. var IrreversibleTransform = function IrreversibleTransformClosure() {
  8950. function IrreversibleTransform() {
  8951. Transform.call(this);
  8952. }
  8953. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  8954. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  8955. var len = length >> 1;
  8956. offset = offset | 0;
  8957. var j, n, current, next;
  8958. var alpha = -1.586134342059924;
  8959. var beta = -0.052980118572961;
  8960. var gamma = 0.882911075530934;
  8961. var delta = 0.443506852043971;
  8962. var K = 1.230174104914001;
  8963. var K_ = 1 / K;
  8964. j = offset - 3;
  8965. for (n = len + 4; n--; j += 2) {
  8966. x[j] *= K_;
  8967. }
  8968. j = offset - 2;
  8969. current = delta * x[j - 1];
  8970. for (n = len + 3; n--; j += 2) {
  8971. next = delta * x[j + 1];
  8972. x[j] = K * x[j] - current - next;
  8973. if (n--) {
  8974. j += 2;
  8975. current = delta * x[j + 1];
  8976. x[j] = K * x[j] - current - next;
  8977. } else {
  8978. break;
  8979. }
  8980. }
  8981. j = offset - 1;
  8982. current = gamma * x[j - 1];
  8983. for (n = len + 2; n--; j += 2) {
  8984. next = gamma * x[j + 1];
  8985. x[j] -= current + next;
  8986. if (n--) {
  8987. j += 2;
  8988. current = gamma * x[j + 1];
  8989. x[j] -= current + next;
  8990. } else {
  8991. break;
  8992. }
  8993. }
  8994. j = offset;
  8995. current = beta * x[j - 1];
  8996. for (n = len + 1; n--; j += 2) {
  8997. next = beta * x[j + 1];
  8998. x[j] -= current + next;
  8999. if (n--) {
  9000. j += 2;
  9001. current = beta * x[j + 1];
  9002. x[j] -= current + next;
  9003. } else {
  9004. break;
  9005. }
  9006. }
  9007. if (len !== 0) {
  9008. j = offset + 1;
  9009. current = alpha * x[j - 1];
  9010. for (n = len; n--; j += 2) {
  9011. next = alpha * x[j + 1];
  9012. x[j] -= current + next;
  9013. if (n--) {
  9014. j += 2;
  9015. current = alpha * x[j + 1];
  9016. x[j] -= current + next;
  9017. } else {
  9018. break;
  9019. }
  9020. }
  9021. }
  9022. };
  9023. return IrreversibleTransform;
  9024. }();
  9025. var ReversibleTransform = function ReversibleTransformClosure() {
  9026. function ReversibleTransform() {
  9027. Transform.call(this);
  9028. }
  9029. ReversibleTransform.prototype = Object.create(Transform.prototype);
  9030. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  9031. var len = length >> 1;
  9032. offset = offset | 0;
  9033. var j, n;
  9034. for (j = offset, n = len + 1; n--; j += 2) {
  9035. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  9036. }
  9037. for (j = offset + 1, n = len; n--; j += 2) {
  9038. x[j] += x[j - 1] + x[j + 1] >> 1;
  9039. }
  9040. };
  9041. return ReversibleTransform;
  9042. }();
  9043. return JpxImage;
  9044. }();
  9045. exports.JpxImage = JpxImage;
  9046. /***/ })
  9047. /******/ ]);
  9048. });
  9049. //# sourceMappingURL=pdf.image_decoders.js.map